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 <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10068>
This commit is contained in:
Dave Airlie
2021-04-07 13:18:29 +10:00
parent da166f648f
commit f96f016c22
@@ -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]) {