From d361655aae37ee204352f768282dae8c27b2847b Mon Sep 17 00:00:00 2001 From: Emma Anholt Date: Thu, 1 Jun 2023 12:35:09 -0700 Subject: [PATCH] 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 Part-of: --- src/mesa/state_tracker/st_pbo.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/mesa/state_tracker/st_pbo.c b/src/mesa/state_tracker/st_pbo.c index 3b5f121e4c9..15f37180e8f 100644 --- a/src/mesa/state_tracker/st_pbo.c +++ b/src/mesa/state_tracker/st_pbo.c @@ -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());