Mesa (master): nir/clip_disable: handle 2x vec4 case
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Nov 5 22:15:06 UTC 2020
Module: Mesa
Branch: master
Commit: 0b0f152c54eba919cf8851e6407d25eae4b8faa5
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0b0f152c54eba919cf8851e6407d25eae4b8faa5
Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date: Wed Sep 2 10:26:15 2020 -0400
nir/clip_disable: handle 2x vec4 case
some drivers may have pre-lowered gl_ClipDistance to 2x vec4 to match hw
usage, so for those cases we'll be getting deref_var here and then components
will be stored to the deref at some point
fixes mesa/mesa#3480
Reviewed-by: Eric Anholt <eric at anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6563>
---
src/compiler/nir/nir_lower_clip_disable.c | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/src/compiler/nir/nir_lower_clip_disable.c b/src/compiler/nir/nir_lower_clip_disable.c
index 3ca25620e7e..6c5958e51de 100644
--- a/src/compiler/nir/nir_lower_clip_disable.c
+++ b/src/compiler/nir/nir_lower_clip_disable.c
@@ -72,12 +72,29 @@ lower_clip_plane_store(nir_intrinsic_instr *instr, unsigned clip_plane_enable, n
nir_deref_instr *deref = nir_src_as_deref(instr->src[0]);
out = nir_deref_instr_get_variable(deref);
- if ((out->data.location != VARYING_SLOT_CLIP_DIST0) ||
+ if ((out->data.location != VARYING_SLOT_CLIP_DIST0 &&
+ out->data.location != VARYING_SLOT_CLIP_DIST1) ||
out->data.mode != nir_var_shader_out)
return false;
b->cursor = nir_after_instr(&instr->instr);
- if (nir_src_is_const(deref->arr.index)) {
+ if (deref->deref_type == nir_deref_type_var) {
+ int wrmask = nir_intrinsic_write_mask(instr);
+
+ nir_ssa_def *components[4];
+ int start = out->data.location == VARYING_SLOT_CLIP_DIST1 ? 4 : 0;
+ /* rewrite components as zeroes for planes that aren't enabled */
+ for (int i = 0; i < 4; i++) {
+ if (wrmask & (1 << i)) {
+ if (!(clip_plane_enable & (1 << (start + i))))
+ components[i] = nir_imm_int(b, 0);
+ else
+ components[i] = nir_channel(b, nir_ssa_for_src(b, instr->src[1], nir_src_num_components(instr->src[1])), i);
+ } else
+ components[i] = nir_ssa_undef(b, 1, 32);
+ }
+ nir_store_deref(b, deref, nir_vec(b, components, instr->num_components), wrmask);
+ } else if (nir_src_is_const(deref->arr.index)) {
/* storing using a constant index */
plane = nir_src_as_uint(deref->arr.index);
/* no need to make changes if the clip plane is enabled */
More information about the mesa-commit
mailing list