ins.load_store.arg_1 = compute_builtin_arg(instr->intrinsic);
emit_mir_instruction(ctx, ins);
}
+
+static unsigned
+vertex_builtin_arg(nir_op op)
+{
+ switch (op) {
+ case nir_intrinsic_load_vertex_id:
+ return PAN_VERTEX_ID;
+ case nir_intrinsic_load_instance_id:
+ return PAN_INSTANCE_ID;
+ default:
+ unreachable("Invalid vertex builtin");
+ }
+}
+
+static void
+emit_vertex_builtin(compiler_context *ctx, nir_intrinsic_instr *instr)
+{
+ unsigned reg = nir_dest_index(ctx, &instr->dest);
+ emit_attr_read(ctx, reg, vertex_builtin_arg(instr->intrinsic), 1, nir_type_int);
+}
+
static void
emit_intrinsic(compiler_context *ctx, nir_intrinsic_instr *instr)
{
emit_compute_builtin(ctx, instr);
break;
+ case nir_intrinsic_load_vertex_id:
+ case nir_intrinsic_load_instance_id:
+ emit_vertex_builtin(ctx, instr);
+ break;
+
default:
printf ("Unhandled intrinsic\n");
assert(0);
#define PAN_SYSVAL_ID_TO_TXS_DIM(id) (((id) >> 7) & 0x3)
#define PAN_SYSVAL_ID_TO_TXS_IS_ARRAY(id) !!((id) & (1 << 9))
+/* Special attribute slots for vertex builtings. Sort of arbitrary but let's be
+ * consistent with the blob so we can compare traces easier. */
+
+enum {
+ PAN_VERTEX_ID = 16,
+ PAN_INSTANCE_ID = 17,
+ PAN_MAX_ATTRIBUTE
+} pan_special_attributes;
+
typedef struct {
int work_register_count;
int uniform_count;