From f4a5cbcdf5c8b8cb05cca27308ca60e437d5d802 Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Fri, 26 May 2023 09:48:56 +0200 Subject: [PATCH] zink: compute correct location for line-smooth gs The GS and the FS needs to agree on the driver_location. But we just used the num_outputs variable for the GS instead of matching the logic from lower_aaline_instr in nir_draw_helpers.c. This does that, but cleans up our copy slightly to avoid computing the needless location, as well as using unsigned values. This used to *mostly* work before, but only because we were lucky and not too much crazy stuff went on with the inputs / outputs in smooth-line cases. Fixes: edecb66b018 ("nir: avoid generating conflicting output variables") Part-of: (cherry picked from commit ffc77d52629dead73dcdb45306834d55210512c6) --- .pick_status.json | 2 +- src/gallium/drivers/zink/zink_compiler.c | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 753b5dcc5a3..cb7ec9a4dbb 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -958,7 +958,7 @@ "description": "zink: compute correct location for line-smooth gs", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "edecb66b01849effdf859f3cfaeebb9af5e1c1da" }, diff --git a/src/gallium/drivers/zink/zink_compiler.c b/src/gallium/drivers/zink/zink_compiler.c index 697ecac667c..e03036ca8f8 100644 --- a/src/gallium/drivers/zink/zink_compiler.c +++ b/src/gallium/drivers/zink/zink_compiler.c @@ -1098,13 +1098,20 @@ lower_line_smooth_gs(nir_shader *shader) if (!state.pos_out) return false; + unsigned location = 0; + nir_foreach_shader_in_variable(var, shader) { + if (var->data.driver_location >= location) + location = var->data.driver_location + 1; + } + state.line_coord_out = nir_variable_create(shader, nir_var_shader_out, glsl_vec4_type(), "__line_coord"); state.line_coord_out->data.interpolation = INTERP_MODE_NOPERSPECTIVE; - state.line_coord_out->data.driver_location = shader->num_outputs++; + state.line_coord_out->data.driver_location = location; state.line_coord_out->data.location = MAX2(util_last_bit64(shader->info.outputs_written), VARYING_SLOT_VAR0); shader->info.outputs_written |= BITFIELD64_BIT(state.line_coord_out->data.location); + shader->num_outputs++; // create temp variables state.prev_pos = nir_variable_create(shader, nir_var_shader_temp,