Commit 44aaf06b authored by Erik Faye-Lund 's avatar Erik Faye-Lund

fixup UCP-lowering

parent b1399e7b
......@@ -3711,7 +3711,7 @@ bool nir_lower_input_attachments(nir_shader *shader, bool use_fragcoord_sysval);
bool nir_lower_clip_vs(nir_shader *shader, unsigned ucp_enables,
bool use_vars,
const gl_state_index16 *clipplane_state_tokens,
const gl_state_index16 clipplane_state_tokens[][STATE_LENGTH],
bool use_clipdist_array);
bool nir_lower_clip_fs(nir_shader *shader, unsigned ucp_enables);
bool nir_lower_clip_cull_distance_arrays(nir_shader *nir);
......
......@@ -164,7 +164,7 @@ find_output(nir_shader *shader, unsigned drvloc)
*/
bool
nir_lower_clip_vs(nir_shader *shader, unsigned ucp_enables, bool use_vars,
const gl_state_index16 *clipplane_state_tokens,
const gl_state_index16 clipplane_state_tokens[][STATE_LENGTH],
bool use_clipdist_array)
{
nir_function_impl *impl = nir_shader_get_entrypoint(shader);
......@@ -246,30 +246,23 @@ nir_lower_clip_vs(nir_shader *shader, unsigned ucp_enables, bool use_vars,
VARYING_SLOT_CLIP_DIST1, 0);
}
nir_deref_instr *clipplane_deref;
if (clipplane_state_tokens) {
const struct glsl_type *type = glsl_array_type(glsl_vec4_type(),
MAX_CLIP_PLANES,
0);
nir_variable *var = nir_variable_create(shader,
nir_var_uniform,
type,
"gl_ClipPlanesMESA");
var->num_state_slots = 1;
var->state_slots = ralloc_array(var, nir_state_slot, 1);
memcpy(var->state_slots[0].tokens,
clipplane_state_tokens,
sizeof(var->state_slots[0].tokens));
clipplane_deref = nir_build_deref_var(&b, var);
}
for (int plane = 0; plane < MAX_CLIP_PLANES; plane++) {
if (ucp_enables & (1 << plane)) {
nir_ssa_def *ucp;
if (clipplane_state_tokens) {
nir_deref_instr *deref;
deref = nir_build_deref_array_imm(&b, clipplane_deref, plane);
ucp = nir_load_deref(&b, deref);
char tmp[100];
snprintf(tmp, ARRAY_SIZE(tmp), "gl_ClipPlane%dMESA", plane);
nir_variable *var = nir_variable_create(shader,
nir_var_uniform,
glsl_vec4_type(),
tmp);
var->num_state_slots = 1;
var->state_slots = ralloc_array(var, nir_state_slot, 1);
memcpy(var->state_slots[0].tokens,
clipplane_state_tokens[plane],
sizeof(var->state_slots[0].tokens));
ucp = nir_load_var(&b, var);
} else
ucp = nir_load_user_clip_plane(&b, plane);
......
......@@ -641,8 +641,6 @@ st_create_vp_variant(struct st_context *st,
struct st_vp_variant *vpv = CALLOC_STRUCT(st_vp_variant);
struct pipe_context *pipe = st->pipe;
static const gl_state_index16 clipplane_state[STATE_LENGTH] =
{ STATE_INTERNAL, STATE_CLIP_INTERNAL, 0 };
static const gl_state_index16 point_size_state[STATE_LENGTH] =
{ STATE_INTERNAL, STATE_POINT_SIZE_CLAMPED, 0 };
struct gl_program_parameter_list *params = stvp->Base.Parameters;
......@@ -673,7 +671,21 @@ st_create_vp_variant(struct st_context *st,
struct pipe_screen *screen = pipe->screen;
bool can_compact = screen->get_param(screen,
PIPE_CAP_NIR_COMPACT_ARRAYS);
_mesa_add_state_reference(params, clipplane_state);
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;
}
_mesa_add_state_reference(params, clipplane_state[i]);
}
NIR_PASS_V(vpv->tgsi.ir.nir, nir_lower_clip_vs, key->lower_ucp,
true, clipplane_state, can_compact);
NIR_PASS_V(vpv->tgsi.ir.nir, nir_lower_io_to_temporaries,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment