bool block_started;
SpvId loop_break, loop_cont;
- SpvId front_face_var;
+ SpvId front_face_var, vertex_id_var;
};
static SpvId
store_dest_uint(ctx, &intr->dest, result);
}
+static void
+emit_load_vertex_id(struct ntv_context *ctx, nir_intrinsic_instr *intr)
+{
+ SpvId var_type = spirv_builder_type_uint(&ctx->builder, 32);
+ if (!ctx->vertex_id_var)
+ ctx->vertex_id_var = create_builtin_var(ctx, var_type,
+ SpvStorageClassInput,
+ "gl_VertexID",
+ SpvBuiltInVertexIndex);
+
+ SpvId result = spirv_builder_emit_load(&ctx->builder, var_type,
+ ctx->vertex_id_var);
+ assert(1 == nir_dest_num_components(intr->dest));
+ store_dest_uint(ctx, &intr->dest, result);
+}
+
static void
emit_intrinsic(struct ntv_context *ctx, nir_intrinsic_instr *intr)
{
emit_load_front_face(ctx, intr);
break;
+ case nir_intrinsic_load_vertex_id:
+ emit_load_vertex_id(ctx, intr);
+ break;
+
default:
fprintf(stderr, "emit_intrinsic: not implemented (%s)\n",
nir_intrinsic_infos[intr->intrinsic].name);