From: Jonathan Marek Date: Sun, 17 Nov 2019 17:17:47 +0000 (-0500) Subject: freedreno/ir3: support load_base_instance X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a3a70588c0a9a72255a69428af4a5ff22544d275;p=mesa.git freedreno/ir3: support load_base_instance Not supported by hardware, uses same mechanism as base vertex. Signed-off-by: Jonathan Marek Reviewed-by: Eric Anholt Part-of: --- diff --git a/src/freedreno/ir3/ir3_compiler_nir.c b/src/freedreno/ir3/ir3_compiler_nir.c index b6fc39f2fb1..7bbfe40dc91 100644 --- a/src/freedreno/ir3/ir3_compiler_nir.c +++ b/src/freedreno/ir3/ir3_compiler_nir.c @@ -1671,6 +1671,12 @@ emit_intrinsic(struct ir3_context *ctx, nir_intrinsic_instr *intr) } dst[0] = ctx->basevertex; break; + case nir_intrinsic_load_base_instance: + if (!ctx->base_instance) { + ctx->base_instance = create_driver_param(ctx, IR3_DP_INSTID_BASE); + } + dst[0] = ctx->base_instance; + break; case nir_intrinsic_load_vertex_id_zero_base: case nir_intrinsic_load_vertex_id: if (!ctx->vertex_id) { diff --git a/src/freedreno/ir3/ir3_context.h b/src/freedreno/ir3/ir3_context.h index 1ce5c6776ca..c5845d4e2c6 100644 --- a/src/freedreno/ir3/ir3_context.h +++ b/src/freedreno/ir3/ir3_context.h @@ -83,7 +83,7 @@ struct ir3_context { struct ir3_instruction *frag_face, *frag_coord; /* For vertex shaders, keep track of the system values sources */ - struct ir3_instruction *vertex_id, *basevertex, *instance_id; + struct ir3_instruction *vertex_id, *basevertex, *instance_id, *base_instance; /* For fragment shaders: */ struct ir3_instruction *samp_id, *samp_mask_in; diff --git a/src/freedreno/ir3/ir3_nir.c b/src/freedreno/ir3/ir3_nir.c index bf643c71439..5d4dbb1135d 100644 --- a/src/freedreno/ir3/ir3_nir.c +++ b/src/freedreno/ir3/ir3_nir.c @@ -415,6 +415,10 @@ ir3_nir_scan_driver_consts(nir_shader *shader, layout->num_driver_params = MAX2(layout->num_driver_params, IR3_DP_VTXID_BASE + 1); break; + case nir_intrinsic_load_base_instance: + layout->num_driver_params = + MAX2(layout->num_driver_params, IR3_DP_INSTID_BASE + 1); + break; case nir_intrinsic_load_user_clip_plane: layout->num_driver_params = MAX2(layout->num_driver_params, IR3_DP_UCP7_W + 1); diff --git a/src/freedreno/ir3/ir3_shader.h b/src/freedreno/ir3/ir3_shader.h index 3a0447a1334..528764b0e27 100644 --- a/src/freedreno/ir3/ir3_shader.h +++ b/src/freedreno/ir3/ir3_shader.h @@ -57,6 +57,7 @@ enum ir3_driver_param { /* vertex shader driver params: */ IR3_DP_VTXID_BASE = 0, IR3_DP_VTXCNT_MAX = 1, + IR3_DP_INSTID_BASE = 2, /* user-clip-plane components, up to 8x vec4's: */ IR3_DP_UCP0_X = 4, /* .... */