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>
This commit is contained in:
Mike Blumenkrantz 2020-12-17 21:22:17 -05:00 committed by Marge Bot
parent 244310eddc
commit d09f9da4c4

View file

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