From: Erik Faye-Lund Date: Fri, 3 Jan 2020 11:21:02 +0000 (+0100) Subject: zink: implement load_vertex_id X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e51bf4914c4412644b4049385286596abead22d8;p=mesa.git zink: implement load_vertex_id Not 100% sure if this matches the semantics, but it seems to pass the tests, so it seems like an improvement. Reviewed-by: Alyssa Rosenzweig --- 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 3ccf90d83ca..b9fb5380b17 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 @@ -56,7 +56,7 @@ struct ntv_context { bool block_started; SpvId loop_break, loop_cont; - SpvId front_face_var; + SpvId front_face_var, vertex_id_var; }; static SpvId @@ -1280,6 +1280,22 @@ emit_load_front_face(struct ntv_context *ctx, nir_intrinsic_instr *intr) 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) { @@ -1304,6 +1320,10 @@ 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);