ir3: Add support for gl_ViewIndex in VS & FS
[mesa.git] / src / freedreno / ir3 / ir3_shader.h
index 99084e22f8c237445a63490ced5c9cc2d17908ee..53be9a6833d87455c4c65c091e6e2238986abaf4 100644 (file)
@@ -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);
        }