From f96f016c2280bb7df1c67f251abeac866ff3997e Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Wed, 7 Apr 2021 13:18:29 +1000 Subject: [PATCH] llvmpipe: when depth clamp is disable clamp to 0.0/1.0 When depth clamp is disabled the viewport values aren't meaningful, however the value is about to be converted to a unorm so needs to still be clamped to 0/1. This might not be the best place for this, maybe it should be in the write swizzled code. Reviewed-by: Roland Scheidegger Part-of: --- src/gallium/drivers/llvmpipe/lp_state_fs.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index e091f98a37e..b90a13f83e7 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -1132,12 +1132,19 @@ generate_fs_loop(struct gallivm_state *gallivm, z = interp->pos[2]; } } + /* * Clamp according to ARB_depth_clamp semantics. */ if (key->depth_clamp) { z = lp_build_depth_clamp(gallivm, builder, type, context_ptr, thread_data_ptr, z); + } else { + struct lp_build_context f32_bld; + lp_build_context_init(&f32_bld, gallivm, type); + z = lp_build_clamp(&f32_bld, z, + lp_build_const_vec(gallivm, type, 0.0), + lp_build_const_vec(gallivm, type, 1.0)); } if (s_out != -1 && outputs[s_out][1]) {