aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Blumenkrantz <[email protected]>2020-06-17 09:40:51 -0400
committerMarge Bot <[email protected]>2020-07-03 08:56:30 +0000
commita79ca675f3d61d22853657831d8b1c3a6b27e9fa (patch)
tree1a396c859fb02e1a05eeaa75bc86939fc8b9f894
parentfb2fe802f638d7a70f0d00ec1d496f317d241765 (diff)
st/program: use nir_lower_clip_disable instead of nir_lower_clip_vs conditionally
if the shader already outputs gl_ClipDistance, nir_lower_clip_vs will create duplicate variables when what we want is to just change the existing values Reviewed-by: Erik Faye-Lund <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5529>
-rw-r--r--src/mesa/state_tracker/st_program.c38
1 files changed, 22 insertions, 16 deletions
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
index cb9fcfdbdd6..d0e16cf16a8 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -716,24 +716,30 @@ st_create_vp_variant(struct st_context *st,
PIPE_CAP_NIR_COMPACT_ARRAYS);
bool use_eye = st->ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX] != NULL;
- gl_state_index16 clipplane_state[MAX_CLIP_PLANES][STATE_LENGTH];
- for (int i = 0; i < MAX_CLIP_PLANES; ++i) {
- if (use_eye) {
- clipplane_state[i][0] = STATE_CLIPPLANE;
- clipplane_state[i][1] = i;
- } else {
- clipplane_state[i][0] = STATE_INTERNAL;
- clipplane_state[i][1] = STATE_CLIP_INTERNAL;
- clipplane_state[i][2] = i;
+ struct nir_shader *nir = state.ir.nir;
+
+ if (nir->info.outputs_written & VARYING_BIT_CLIP_DIST0)
+ NIR_PASS_V(state.ir.nir, nir_lower_clip_disable, key->lower_ucp);
+ else {
+ gl_state_index16 clipplane_state[MAX_CLIP_PLANES][STATE_LENGTH];
+ for (int i = 0; i < MAX_CLIP_PLANES; ++i) {
+ if (use_eye) {
+ clipplane_state[i][0] = STATE_CLIPPLANE;
+ clipplane_state[i][1] = i;
+ } else {
+ clipplane_state[i][0] = STATE_INTERNAL;
+ clipplane_state[i][1] = STATE_CLIP_INTERNAL;
+ clipplane_state[i][2] = i;
+ }
+ _mesa_add_state_reference(params, clipplane_state[i]);
}
- _mesa_add_state_reference(params, clipplane_state[i]);
- }
- NIR_PASS_V(state.ir.nir, nir_lower_clip_vs, key->lower_ucp,
- true, can_compact, clipplane_state);
- NIR_PASS_V(state.ir.nir, nir_lower_io_to_temporaries,
- nir_shader_get_entrypoint(state.ir.nir), true, false);
- NIR_PASS_V(state.ir.nir, nir_lower_global_vars_to_local);
+ NIR_PASS_V(state.ir.nir, nir_lower_clip_vs, key->lower_ucp,
+ true, can_compact, clipplane_state);
+ NIR_PASS_V(state.ir.nir, nir_lower_io_to_temporaries,
+ nir_shader_get_entrypoint(state.ir.nir), true, false);
+ NIR_PASS_V(state.ir.nir, nir_lower_global_vars_to_local);
+ }
finalize = true;
}