summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorErik Faye-Lund <[email protected]>2019-06-13 11:03:55 +0200
committerErik Faye-Lund <[email protected]>2019-10-28 08:51:44 +0000
commite0a93ba35184ec3872de01f2cd2b92fff7b755ff (patch)
treec1cbd0845fea3295dcd0d0359bafbbaf4dbb9926 /src
parentcedf3598b48546eb6809ad74e5686c98f1bec7c6 (diff)
zink: assign increasing locations to varyings
Acked-by: Jordan Justen <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c58
1 files changed, 35 insertions, 23 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 4ab14b455e7..e5792694f43 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
@@ -38,6 +38,7 @@ struct ntv_context {
SpvId input_types[PIPE_MAX_SHADER_INPUTS][4];
SpvId outputs[PIPE_MAX_SHADER_OUTPUTS][4];
SpvId output_types[PIPE_MAX_SHADER_OUTPUTS][4];
+ int var_location;
SpvId ubos[128];
size_t num_ubos;
@@ -192,19 +193,24 @@ 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) {
- switch (var->data.location) {
- case VARYING_SLOT_POS:
- spirv_builder_emit_builtin(&ctx->builder, var_id, SpvBuiltInFragCoord);
- break;
-
- case VARYING_SLOT_PNTC:
- spirv_builder_emit_builtin(&ctx->builder, var_id, SpvBuiltInPointCoord);
- break;
-
- default:
+ if (var->data.location >= VARYING_SLOT_VAR0 ||
+ (var->data.location >= VARYING_SLOT_COL0 &&
+ var->data.location <= VARYING_SLOT_TEX7)) {
spirv_builder_emit_location(&ctx->builder, var_id,
- var->data.driver_location);
- break;
+ ctx->var_location++);
+ } else {
+ switch (var->data.location) {
+ case VARYING_SLOT_POS:
+ spirv_builder_emit_builtin(&ctx->builder, var_id, SpvBuiltInFragCoord);
+ break;
+
+ case VARYING_SLOT_PNTC:
+ spirv_builder_emit_builtin(&ctx->builder, var_id, SpvBuiltInPointCoord);
+ break;
+
+ default:
+ unreachable("unknown varying slot");
+ }
}
} else {
spirv_builder_emit_location(&ctx->builder, var_id,
@@ -242,18 +248,24 @@ emit_output(struct ntv_context *ctx, struct nir_variable *var)
if (ctx->stage == MESA_SHADER_VERTEX) {
- switch (var->data.location) {
- case VARYING_SLOT_POS:
- spirv_builder_emit_builtin(&ctx->builder, var_id, SpvBuiltInPosition);
- break;
-
- case VARYING_SLOT_PSIZ:
- spirv_builder_emit_builtin(&ctx->builder, var_id, SpvBuiltInPointSize);
- break;
-
- default:
+ if (var->data.location >= VARYING_SLOT_VAR0 ||
+ (var->data.location >= VARYING_SLOT_COL0 &&
+ var->data.location <= VARYING_SLOT_TEX7)) {
spirv_builder_emit_location(&ctx->builder, var_id,
- var->data.driver_location - 1);
+ ctx->var_location++);
+ } else {
+ switch (var->data.location) {
+ case VARYING_SLOT_POS:
+ spirv_builder_emit_builtin(&ctx->builder, var_id, SpvBuiltInPosition);
+ break;
+
+ case VARYING_SLOT_PSIZ:
+ spirv_builder_emit_builtin(&ctx->builder, var_id, SpvBuiltInPointSize);
+ break;
+
+ default:
+ unreachable("unknown varying slot");
+ }
}
} else if (ctx->stage == MESA_SHADER_FRAGMENT) {
switch (var->data.location) {