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: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20253>
This commit is contained in:
Jesse Natalie 2022-12-09 10:48:13 -08:00 committed by Marge Bot
parent 1071d33c37
commit 16c4c1a549

View file

@ -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 &&