From: Connor Abbott Date: Wed, 1 Jul 2020 14:46:22 +0000 (+0200) Subject: ir3: Add support for gl_ViewIndex in VS & FS X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5ef960e93cd0321c92c324274c77e7ebf4b1bb86;p=mesa.git ir3: Add support for gl_ViewIndex in VS & FS Part-of: --- diff --git a/src/freedreno/ir3/ir3_compiler_nir.c b/src/freedreno/ir3/ir3_compiler_nir.c index c3461c85c7d..8d9d8ef18d1 100644 --- a/src/freedreno/ir3/ir3_compiler_nir.c +++ b/src/freedreno/ir3/ir3_compiler_nir.c @@ -1861,6 +1861,12 @@ emit_intrinsic(struct ir3_context *ctx, nir_intrinsic_instr *intr) } dst[0] = ctx->base_instance; break; + case nir_intrinsic_load_view_index: + if (!ctx->view_index) { + ctx->view_index = create_sysval_input(ctx, SYSTEM_VALUE_VIEW_INDEX, 0x1); + } + dst[0] = ctx->view_index; + 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 30caf9d7b85..8cf2922f02c 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, *base_instance, *draw_id; + struct ir3_instruction *vertex_id, *basevertex, *instance_id, *base_instance, *draw_id, *view_index; /* For fragment shaders: */ struct ir3_instruction *samp_id, *samp_mask_in; diff --git a/src/freedreno/ir3/ir3_shader.h b/src/freedreno/ir3/ir3_shader.h index 99084e22f8c..53be9a6833d 100644 --- a/src/freedreno/ir3/ir3_shader.h +++ b/src/freedreno/ir3/ir3_shader.h @@ -851,6 +851,9 @@ struct ir3_shader_linkage { /* location for fixed-function gl_PrimitiveID passthrough */ uint8_t primid_loc; + + /* location for fixed-function gl_ViewIndex passthrough */ + uint8_t viewid_loc; }; static inline void @@ -891,6 +894,7 @@ ir3_link_shaders(struct ir3_shader_linkage *l, int j = -1, k; l->primid_loc = 0xff; + l->viewid_loc = 0xff; while (l->cnt < ARRAY_SIZE(l->var)) { j = ir3_next_varying(fs, j); @@ -907,6 +911,11 @@ ir3_link_shaders(struct ir3_shader_linkage *l, l->primid_loc = fs->inputs[j].inloc; } + if (fs->inputs[j].slot == VARYING_SLOT_VIEW_INDEX) { + assert(k < 0); + l->viewid_loc = fs->inputs[j].inloc; + } + ir3_link_add(l, k >= 0 ? vs->outputs[k].regid : default_regid, fs->inputs[j].compmask, fs->inputs[j].inloc); }