freedreno/ir3: support load_base_instance
authorJonathan Marek <jonathan@marek.ca>
Sun, 17 Nov 2019 17:17:47 +0000 (12:17 -0500)
committerJonathan Marek <jonathan@marek.ca>
Thu, 19 Dec 2019 20:13:40 +0000 (15:13 -0500)
Not supported by hardware, uses same mechanism as base vertex.

Signed-off-by: Jonathan Marek <jonathan@marek.ca>
Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3162>

src/freedreno/ir3/ir3_compiler_nir.c
src/freedreno/ir3/ir3_context.h
src/freedreno/ir3/ir3_nir.c
src/freedreno/ir3/ir3_shader.h

index b6fc39f2fb173ef94864f2807019f419107ff89b..7bbfe40dc91bd365ef35124981c270e3b9bb74cd 100644 (file)
@@ -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) {
index 1ce5c6776cad5cbea123e215ba5ab9597c844dee..c5845d4e2c6e124438545e07a307861df6f603f6 100644 (file)
@@ -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;
index bf643c7143974b0deb0a6a8218bdefb0d8fbb3ab..5d4dbb1135da890080c9b28767be42c532c77df4 100644 (file)
@@ -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);
index 3a0447a13345d7b9f0991cfe6d90e981ddb01e3e..528764b0e2707b55d3501f91646fef69b5d6d0b6 100644 (file)
@@ -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,
        /* .... */