[VARYING_SLOT_COL0] = 0, /* input/output */
[VARYING_SLOT_COL1] = 1, /* input/output */
[VARYING_SLOT_FOGC] = 2, /* input/output */
- /* TEX0-7 are translated to VAR0-7 by nir, so we don't need to reserve */
- [VARYING_SLOT_TEX0] = UINT_MAX, /* input/output */
- [VARYING_SLOT_TEX1] = UINT_MAX,
- [VARYING_SLOT_TEX2] = UINT_MAX,
- [VARYING_SLOT_TEX3] = UINT_MAX,
- [VARYING_SLOT_TEX4] = UINT_MAX,
- [VARYING_SLOT_TEX5] = UINT_MAX,
- [VARYING_SLOT_TEX6] = UINT_MAX,
- [VARYING_SLOT_TEX7] = UINT_MAX,
+ /* TEX0-7 are deprecated, so we put them at the end of the range and hope nobody uses them all */
+ [VARYING_SLOT_TEX0] = VARYING_SLOT_VAR0 - 1, /* input/output */
+ [VARYING_SLOT_TEX1] = VARYING_SLOT_VAR0 - 2,
+ [VARYING_SLOT_TEX2] = VARYING_SLOT_VAR0 - 3,
+ [VARYING_SLOT_TEX3] = VARYING_SLOT_VAR0 - 4,
+ [VARYING_SLOT_TEX4] = VARYING_SLOT_VAR0 - 5,
+ [VARYING_SLOT_TEX5] = VARYING_SLOT_VAR0 - 6,
+ [VARYING_SLOT_TEX6] = VARYING_SLOT_VAR0 - 7,
+ [VARYING_SLOT_TEX7] = VARYING_SLOT_VAR0 - 8,
/* PointSize is builtin */
[VARYING_SLOT_PSIZ] = UINT_MAX,
SpvId loop_break, loop_cont;
SpvId front_face_var, instance_id_var, vertex_id_var;
+#ifndef NDEBUG
+ bool seen_texcoord[8]; //whether we've seen a VARYING_SLOT_TEX[n] this pass
+#endif
};
static SpvId
unreachable("we shouldn't get here, I think...");
}
+static inline unsigned
+handle_slot(struct ntv_context *ctx, unsigned slot)
+{
+ unsigned orig = slot;
+ if (slot < VARYING_SLOT_VAR0) {
+#ifndef NDEBUG
+ if (slot >= VARYING_SLOT_TEX0 && slot <= VARYING_SLOT_TEX7)
+ ctx->seen_texcoord[slot - VARYING_SLOT_TEX0] = true;
+#endif
+ slot = slot_pack_map[slot];
+ if (slot == UINT_MAX)
+ debug_printf("unhandled varying slot: %s\n", gl_varying_slot_name(orig));
+ } else {
+ slot -= VARYING_SLOT_VAR0 - NTV_MIN_RESERVED_SLOTS;
+ assert(slot <= VARYING_SLOT_VAR0 - 8 ||
+ !ctx->seen_texcoord[VARYING_SLOT_VAR0 - slot - 1]);
+
+ }
+ assert(slot < VARYING_SLOT_VAR0);
+ return slot;
+}
+
#define HANDLE_EMIT_BUILTIN(SLOT, BUILTIN) \
case VARYING_SLOT_##SLOT: \
spirv_builder_emit_builtin(&ctx->builder, var_id, SpvBuiltIn##BUILTIN); \
HANDLE_EMIT_BUILTIN(FACE, FrontFacing);
default:
- if (slot < VARYING_SLOT_VAR0) {
- slot = slot_pack_map[slot];
- if (slot == UINT_MAX)
- debug_printf("unhandled varying slot: %s\n", gl_varying_slot_name(var->data.location));
- } else
- slot -= VARYING_SLOT_VAR0 - NTV_MIN_RESERVED_SLOTS;
- assert(slot < VARYING_SLOT_VAR0);
+ slot = handle_slot(ctx, slot);
spirv_builder_emit_location(&ctx->builder, var_id, slot);
}
} else {
break;
default:
- if (slot < VARYING_SLOT_VAR0) {
- slot = slot_pack_map[slot];
- if (slot == UINT_MAX)
- debug_printf("unhandled varying slot: %s\n", gl_varying_slot_name(var->data.location));
- } else
- slot -= VARYING_SLOT_VAR0 - NTV_MIN_RESERVED_SLOTS;
- assert(slot < VARYING_SLOT_VAR0);
+ slot = handle_slot(ctx, slot);
spirv_builder_emit_location(&ctx->builder, var_id, slot);
- /* non-builtins get location incremented by VARYING_SLOT_VAR0 in vtn, so
- * use driver_location for non-builtins with defined slots to avoid overlap
- */
}
ctx->outputs[var->data.location] = var_id;
ctx->so_output_gl_types[var->data.location] = var->type;
if (max_output_location >= VARYING_SLOT_VAR0)
location = max_output_location - VARYING_SLOT_VAR0 + 1 + i;
assert(location < VARYING_SLOT_VAR0);
+ assert(location <= VARYING_SLOT_VAR0 - 8 ||
+ !ctx->seen_texcoord[VARYING_SLOT_VAR0 - location - 1]);
spirv_builder_emit_location(&ctx->builder, var_id, location);
/* note: gl_ClipDistance[4] can the 0-indexed member of VARYING_SLOT_CLIP_DIST1 here,