Mesa (master): zink: add ntv handling for tess shader i/o variables

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Dec 22 13:56:09 UTC 2020


Module: Mesa
Branch: master
Commit: d09f9da4c4d30d2c2d683777e17832a071c307d7
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=d09f9da4c4d30d2c2d683777e17832a071c307d7

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Thu Dec 17 21:22:17 2020 -0500

zink: add ntv handling for tess shader i/o variables

Reviewed-by: Erik Faye-Lund <kusmabite at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8152>

---

 .../drivers/zink/nir_to_spirv/nir_to_spirv.c       | 32 ++++++++++++++++++----
 1 file changed, 27 insertions(+), 5 deletions(-)

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 fd329c877bf..b6e33b289d0 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
@@ -304,6 +304,19 @@ handle_slot(struct ntv_context *ctx, unsigned slot)
          break
 
 
+static inline unsigned
+handle_handle_slot(struct ntv_context *ctx, struct nir_variable *var)
+{
+   if (var->data.patch) {
+      assert(var->data.location >= VARYING_SLOT_PATCH0);
+      return var->data.location - VARYING_SLOT_PATCH0;
+   } else if (ctx->stage == MESA_SHADER_TESS_CTRL) {
+      assert(var->data.location >= VARYING_SLOT_VAR0);
+      return var->data.location - VARYING_SLOT_VAR0;
+   }
+   return handle_slot(ctx, var->data.location);
+}
+
 static void
 emit_input(struct ntv_context *ctx, struct nir_variable *var)
 {
@@ -357,7 +370,7 @@ emit_input(struct ntv_context *ctx, struct nir_variable *var)
          break;
 
       default:
-         slot = handle_slot(ctx, slot);
+         slot = handle_handle_slot(ctx, var);
          spirv_builder_emit_location(&ctx->builder, var_id, slot);
       }
    }
@@ -366,6 +379,9 @@ emit_input(struct ntv_context *ctx, struct nir_variable *var)
       spirv_builder_emit_component(&ctx->builder, var_id,
                                    var->data.location_frac);
 
+   if (var->data.patch)
+      spirv_builder_emit_decoration(&ctx->builder, var_id, SpvDecorationPatch);
+
    if (var->data.interpolation == INTERP_MODE_FLAT)
       spirv_builder_emit_decoration(&ctx->builder, var_id, SpvDecorationFlat);
 
@@ -413,12 +429,15 @@ emit_output(struct ntv_context *ctx, struct nir_variable *var)
          break;
 
       default:
-         slot = handle_slot(ctx, slot);
+         slot = handle_handle_slot(ctx, var);
          spirv_builder_emit_location(&ctx->builder, var_id, slot);
       }
-      ctx->outputs[var->data.location] = var_id;
-      ctx->so_output_gl_types[var->data.location] = var->type;
-      ctx->so_output_types[var->data.location] = var_type;
+      /* tcs can't do xfb */
+      if (ctx->stage != MESA_SHADER_TESS_CTRL) {
+         ctx->outputs[var->data.location] = var_id;
+         ctx->so_output_gl_types[var->data.location] = var->type;
+         ctx->so_output_types[var->data.location] = var_type;
+      }
    } else {
       if (var->data.location >= FRAG_RESULT_DATA0) {
          spirv_builder_emit_location(&ctx->builder, var_id,
@@ -468,6 +487,9 @@ emit_output(struct ntv_context *ctx, struct nir_variable *var)
       unreachable("unknown interpolation value");
    }
 
+   if (var->data.patch)
+      spirv_builder_emit_decoration(&ctx->builder, var_id, SpvDecorationPatch);
+
    _mesa_hash_table_insert(ctx->vars, var, (void *)(intptr_t)var_id);
 
    assert(ctx->num_entry_ifaces < ARRAY_SIZE(ctx->entry_ifaces));



More information about the mesa-commit mailing list