From 67a9749adac7cd3f204e9b00389f03d083fbed5a Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Mon, 22 Jul 2019 16:16:40 +0200 Subject: zink/spirv: alias generic varyings on non-generic ones This gets rid of the nasty location-allocation hack. Acked-by: Jordan Justen --- .../drivers/zink/nir_to_spirv/nir_to_spirv.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c index 8e34b629a07..2f75d5b70fa 100644 --- a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c +++ b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c @@ -35,7 +35,6 @@ struct ntv_context { SpvId GLSL_std_450; gl_shader_stage stage; - int var_location; SpvId ubos[128]; size_t num_ubos; @@ -234,11 +233,13 @@ emit_input(struct ntv_context *ctx, struct nir_variable *var) spirv_builder_emit_name(&ctx->builder, var_id, var->name); if (ctx->stage == MESA_SHADER_FRAGMENT) { - if (var->data.location >= VARYING_SLOT_VAR0 || - (var->data.location >= VARYING_SLOT_COL0 && - var->data.location <= VARYING_SLOT_TEX7)) { + if (var->data.location >= VARYING_SLOT_VAR0) spirv_builder_emit_location(&ctx->builder, var_id, - ctx->var_location++); + var->data.location - VARYING_SLOT_VAR0); + else if (var->data.location >= VARYING_SLOT_COL0 && + var->data.location <= VARYING_SLOT_TEX7) { + spirv_builder_emit_location(&ctx->builder, var_id, + var->data.location); } else { switch (var->data.location) { case VARYING_SLOT_POS: @@ -286,11 +287,13 @@ emit_output(struct ntv_context *ctx, struct nir_variable *var) if (ctx->stage == MESA_SHADER_VERTEX) { - if (var->data.location >= VARYING_SLOT_VAR0 || - (var->data.location >= VARYING_SLOT_COL0 && - var->data.location <= VARYING_SLOT_TEX7)) { + if (var->data.location >= VARYING_SLOT_VAR0) + spirv_builder_emit_location(&ctx->builder, var_id, + var->data.location - VARYING_SLOT_VAR0); + else if (var->data.location >= VARYING_SLOT_COL0 && + var->data.location <= VARYING_SLOT_TEX7) { spirv_builder_emit_location(&ctx->builder, var_id, - ctx->var_location++); + var->data.location); } else { switch (var->data.location) { case VARYING_SLOT_POS: -- cgit v1.2.3