summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>2020-12-17 21:22:17 -0500
committerMarge Bot <eric+marge@anholt.net>2020-12-22 13:46:38 +0000
commitd09f9da4c4d30d2c2d683777e17832a071c307d7 (patch)
tree471fd9cbbb6bb468d14d27a48596bbf0c5472400
parent244310eddcfdab51cd4cc0c668883fa9834420ec (diff)
zink: add ntv handling for tess shader i/o variables
Reviewed-by: Erik Faye-Lund <kusmabite@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8152>
-rw-r--r--src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c32
1 files 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));