diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index a56f2506598..8eed848fccf 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -713,7 +713,8 @@ lower_ucp(struct st_context *st, clipplane_state[i][0] = STATE_CLIP_INTERNAL; clipplane_state[i][1] = i; } - _mesa_add_state_reference(params, clipplane_state[i]); + if (!st->allow_st_finalize_nir_twice) + _mesa_add_state_reference(params, clipplane_state[i]); } if (nir->info.stage == MESA_SHADER_VERTEX || @@ -724,6 +725,25 @@ lower_ucp(struct st_context *st, NIR_PASS(_, nir, nir_lower_clip_gs, ucp_enables, can_compact, clipplane_state); } + + if (st->allow_st_finalize_nir_twice) { + nir_foreach_variable_with_modes(uniform, nir, nir_var_uniform | + nir_var_image) { + if (!uniform->state_slots || !st->allow_st_finalize_nir_twice) + continue; + + for (int plane = 0; plane < MAX_CLIP_PLANES; plane++) { + char tmp[100]; + snprintf(tmp, ARRAY_SIZE(tmp), "gl_ClipPlane%dMESA", plane); + if (strcmp(uniform->name, tmp) == 0) { + unsigned loc = + _mesa_add_state_reference(params, clipplane_state[plane]); + uniform->data.driver_location = st->ctx->Const.PackedDriverUniformStorage ? + params->Parameters[loc].ValueOffset : loc; + } + } + } + } } }