mesa: Emit full output write in st_pbo_create_vs().

In most VS creation paths in the frontend, nir_lower_io_to_temporaries()
is called, which ensures that all outputs have a single write to them
(with a full writemask).  The builtins don't, however, and this VS was an
oddball that overwrote one channel of an output that it had already
written.  We can avoid surprises for backends (such as d3d12 and v3d) by
emitting a single write per output here.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23114>
This commit is contained in:
Emma Anholt 2023-06-01 12:35:09 -07:00 committed by Marge Bot
parent 0cffef54e5
commit d361655aae

View file

@ -299,17 +299,18 @@ st_pbo_create_vs(struct st_context *st)
nir_variable *out_pos = nir_create_variable_with_location(b.shader, nir_var_shader_out,
VARYING_SLOT_POS, vec4);
nir_copy_var(&b, out_pos, in_pos);
if (!st->pbo.use_gs)
nir_copy_var(&b, out_pos, in_pos);
if (st->pbo.layers) {
nir_variable *instance_id = nir_create_variable_with_location(b.shader, nir_var_system_value,
SYSTEM_VALUE_INSTANCE_ID, glsl_int_type());
if (st->pbo.use_gs) {
unsigned swiz_x[4] = {0, 0, 0, 0};
nir_store_var(&b, out_pos,
nir_swizzle(&b, nir_i2f32(&b, nir_load_var(&b, instance_id)), swiz_x, 4),
(1 << 2));
nir_vector_insert_imm(&b, nir_load_var(&b, in_pos),
nir_i2f32(&b, nir_load_var(&b, instance_id)), 2),
0xf);
} else {
nir_variable *out_layer = nir_create_variable_with_location(b.shader, nir_var_shader_out,
VARYING_SLOT_LAYER, glsl_int_type());