zink/spirv: alias generic varyings on non-generic ones
authorErik Faye-Lund <erik.faye-lund@collabora.com>
Mon, 22 Jul 2019 14:16:40 +0000 (16:16 +0200)
committerErik Faye-Lund <erik.faye-lund@collabora.com>
Mon, 28 Oct 2019 08:51:48 +0000 (08:51 +0000)
This gets rid of the nasty location-allocation hack.

Acked-by: Jordan Justen <jordan.l.justen@intel.com>
src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c

index 8e34b629a079ce38fd83e97c53d138da0eac140c..2f75d5b70fa22e32d3641a56413f885afed3ec35 100644 (file)
@@ -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: