st/mesa: use IO intrinsics in st_nir_lower_position_invariant
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32779>
This commit is contained in:
@@ -33,9 +33,18 @@ st_nir_lower_position_invariant(struct nir_shader *s, bool aos,
|
|||||||
}
|
}
|
||||||
|
|
||||||
nir_def *result;
|
nir_def *result;
|
||||||
nir_def *in_pos = nir_load_var(&b, nir_get_variable_with_location(s, nir_var_shader_in,
|
nir_def *in_pos;
|
||||||
VERT_ATTRIB_POS, glsl_vec4_type()));
|
|
||||||
s->info.inputs_read |= VERT_BIT_POS;
|
if (s->info.io_lowered) {
|
||||||
|
in_pos = nir_load_input(&b, 4, 32, nir_imm_int(&b, 0),
|
||||||
|
.io_semantics.location = VERT_ATTRIB_POS);
|
||||||
|
} else {
|
||||||
|
in_pos = nir_load_var(&b, nir_get_variable_with_location(s, nir_var_shader_in,
|
||||||
|
VERT_ATTRIB_POS,
|
||||||
|
glsl_vec4_type()));
|
||||||
|
s->info.inputs_read |= VERT_BIT_POS;
|
||||||
|
}
|
||||||
|
|
||||||
if (aos) {
|
if (aos) {
|
||||||
nir_def *chans[4];
|
nir_def *chans[4];
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
@@ -46,9 +55,16 @@ st_nir_lower_position_invariant(struct nir_shader *s, bool aos,
|
|||||||
for (int i = 1; i < 4; i++)
|
for (int i = 1; i < 4; i++)
|
||||||
result = nir_fmad(&b, mvp[i], nir_channel(&b, in_pos, i), result);
|
result = nir_fmad(&b, mvp[i], nir_channel(&b, in_pos, i), result);
|
||||||
}
|
}
|
||||||
nir_store_var(&b, nir_get_variable_with_location(s, nir_var_shader_out,
|
|
||||||
VARYING_SLOT_POS, glsl_vec4_type()), result, 0xf);
|
if (s->info.io_lowered) {
|
||||||
s->info.outputs_written |= VARYING_BIT_POS;
|
nir_store_output(&b, result, nir_imm_int(&b, 0),
|
||||||
|
.io_semantics.location = VARYING_SLOT_POS);
|
||||||
|
} else {
|
||||||
|
nir_store_var(&b, nir_get_variable_with_location(s, nir_var_shader_out,
|
||||||
|
VARYING_SLOT_POS,
|
||||||
|
glsl_vec4_type()), result, 0xf);
|
||||||
|
s->info.outputs_written |= VARYING_BIT_POS;
|
||||||
|
}
|
||||||
|
|
||||||
nir_metadata_preserve(b.impl, nir_metadata_control_flow);
|
nir_metadata_preserve(b.impl, nir_metadata_control_flow);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user