From 16c4c1a549ff07960c7452456ab32472f9563ab1 Mon Sep 17 00:00:00 2001 From: Jesse Natalie Date: Fri, 9 Dec 2022 10:48:13 -0800 Subject: [PATCH] microsoft/compiler: Handle holes in driver_location when adding sysvals All of the full runtime+compiler stacks reassign these driver_location values to compact them and sort between shader stages, but for the spirv2dxil tool, we leave the original shader's "location" intact. That means that there can be holes in the driver_location space, and simply counting how many inputs there are can lead to collisions. So instead place all sysvals after the last-used driver_location. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/7811 Part-of: --- src/microsoft/compiler/nir_to_dxil.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/microsoft/compiler/nir_to_dxil.c b/src/microsoft/compiler/nir_to_dxil.c index 09143ae54f9..f9cb78b6137 100644 --- a/src/microsoft/compiler/nir_to_dxil.c +++ b/src/microsoft/compiler/nir_to_dxil.c @@ -5958,9 +5958,9 @@ allocate_sysvalues(struct ntd_context *ctx) { unsigned driver_location = 0; nir_foreach_variable_with_modes(var, ctx->shader, nir_var_shader_in) - driver_location++; + driver_location = MAX2(driver_location, var->data.driver_location + 1); nir_foreach_variable_with_modes(var, ctx->shader, nir_var_system_value) - driver_location++; + driver_location = MAX2(driver_location, var->data.driver_location + 1); if (ctx->shader->info.stage == MESA_SHADER_FRAGMENT && ctx->shader->info.inputs_read &&