ir3: Add support for gl_ViewIndex in VS & FS
[mesa.git] / src / freedreno / ir3 / ir3_shader.h
index 3d5dac453d3d6bb56e858a41095e6469cec88e49..53be9a6833d87455c4c65c091e6e2238986abaf4 100644 (file)
@@ -74,6 +74,18 @@ enum ir3_driver_param {
 #define IR3_MAX_SO_OUTPUTS       64
 #define IR3_MAX_UBO_PUSH_RANGES  32
 
+/* mirrors SYSTEM_VALUE_BARYCENTRIC_ but starting from 0 */
+enum ir3_bary {
+       IJ_PERSP_PIXEL,
+       IJ_PERSP_SAMPLE,
+       IJ_PERSP_CENTROID,
+       IJ_PERSP_SIZE,
+       IJ_LINEAR_PIXEL,
+       IJ_LINEAR_CENTROID,
+       IJ_LINEAR_SAMPLE,
+       IJ_COUNT,
+};
+
 /**
  * Description of a lowered UBO.
  */
@@ -179,12 +191,9 @@ struct ir3_const_state {
                uint32_t off[IR3_MAX_SHADER_IMAGES];
        } image_dims;
 
-       unsigned immediate_idx;
        unsigned immediates_count;
        unsigned immediates_size;
-       struct {
-               uint32_t val[4];
-       } *immediates;
+       uint32_t *immediates;
 
        /* State of ubo access lowered to push consts: */
        struct ir3_ubo_analysis_state ubo_state;
@@ -306,6 +315,9 @@ struct ir3_shader_key {
                         * the limit:
                         */
                        unsigned safe_constlen : 1;
+
+                       /* Whether gl_Layer must be forced to 0 because it isn't written. */
+                       unsigned layer_zero : 1;
                };
                uint32_t global;
        };
@@ -373,6 +385,9 @@ ir3_shader_key_changes_fs(struct ir3_shader_key *key, struct ir3_shader_key *las
        if (last_key->rasterflat != key->rasterflat)
                return true;
 
+       if (last_key->layer_zero != key->layer_zero)
+               return true;
+
        if (last_key->ucp_enables != key->ucp_enables)
                return true;
 
@@ -546,7 +561,7 @@ struct ir3_shader_variant {
                uint8_t regid;
                bool    half : 1;
        } outputs[32 + 2];  /* +POSITION +PSIZE */
-       bool writes_pos, writes_smask, writes_psize;
+       bool writes_pos, writes_smask, writes_psize, writes_stencilref;
 
        /* Size in dwords of all outputs for VS, size of entire patch for HS. */
        uint32_t output_size;
@@ -836,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
@@ -876,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);
@@ -892,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);
        }