freedreno/ir3: switch to shader_enums.h interp constants
authorRob Clark <robclark@freedesktop.org>
Thu, 10 Sep 2015 21:25:18 +0000 (17:25 -0400)
committerRob Clark <robclark@freedesktop.org>
Thu, 17 Sep 2015 23:55:43 +0000 (19:55 -0400)
A small step towards un-TGSI'ifying ir3.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
src/gallium/drivers/freedreno/a3xx/fd3_program.c
src/gallium/drivers/freedreno/a4xx/fd4_program.c
src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c
src/gallium/drivers/freedreno/ir3/ir3_shader.h

index b536079774507f3e9aa0dfcad6b6bff875daf0c7..ef8a849617ff26fb9fe1ef4495fca5a7eb61f58f 100644 (file)
@@ -394,7 +394,6 @@ fd3_program_emit(struct fd_ringbuffer *ring, struct fd3_emit *emit,
 
                /* figure out VARYING_INTERP / FLAT_SHAD register values: */
                for (j = -1; (j = ir3_next_varying(fp, j)) < (int)fp->inputs_count; ) {
-                       uint32_t interp = fp->inputs[j].interpolate;
 
                        /* TODO might be cleaner to just +8 in SP_VS_VPC_DST_REG
                         * instead.. rather than -8 everywhere else..
@@ -406,8 +405,8 @@ fd3_program_emit(struct fd_ringbuffer *ring, struct fd3_emit *emit,
                         */
                        debug_assert((inloc % 4) == 0);
 
-                       if ((interp == TGSI_INTERPOLATE_CONSTANT) ||
-                                       ((interp == TGSI_INTERPOLATE_COLOR) && emit->rasterflat)) {
+                       if ((fp->inputs[j].interpolate == INTERP_QUALIFIER_FLAT) ||
+                                       (fp->inputs[j].rasterflat && emit->rasterflat)) {
                                uint32_t loc = inloc;
                                for (i = 0; i < 4; i++, loc++) {
                                        vinterp[loc / 16] |= FLAT << ((loc % 16) * 2);
index a3d7123ccee3902d4e1047ca3882f2cc6d3f17cc..619eb860111a7191c1732cff7da8faf76ac14462 100644 (file)
@@ -492,7 +492,6 @@ fd4_program_emit(struct fd_ringbuffer *ring, struct fd4_emit *emit,
                 */
                /* figure out VARYING_INTERP / VARYING_PS_REPL register values: */
                for (j = -1; (j = ir3_next_varying(s[FS].v, j)) < (int)s[FS].v->inputs_count; ) {
-                       uint32_t interp = s[FS].v->inputs[j].interpolate;
 
                        /* TODO might be cleaner to just +8 in SP_VS_VPC_DST_REG
                         * instead.. rather than -8 everywhere else..
@@ -504,8 +503,8 @@ fd4_program_emit(struct fd_ringbuffer *ring, struct fd4_emit *emit,
                         */
                        debug_assert((inloc % 4) == 0);
 
-                       if ((interp == TGSI_INTERPOLATE_CONSTANT) ||
-                                       ((interp == TGSI_INTERPOLATE_COLOR) && emit->rasterflat)) {
+                       if ((s[FS].v->inputs[j].interpolate == INTERP_QUALIFIER_FLAT) ||
+                                       (s[FS].v->inputs[j].rasterflat && emit->rasterflat)) {
                                uint32_t loc = inloc;
 
                                for (i = 0; i < 4; i++, loc++) {
index 83a138515b578fe12738e48e1f9dafa0279722b6..e4dbe64f753bf0adb8c55c9e96923a87fdc27343 100644 (file)
@@ -1359,7 +1359,7 @@ static void add_sysval_input(struct ir3_compile *ctx, unsigned name,
        so->inputs[n].semantic = ir3_semantic_name(name, 0);
        so->inputs[n].compmask = 1;
        so->inputs[n].regid = r;
-       so->inputs[n].interpolate = TGSI_INTERPOLATE_CONSTANT;
+       so->inputs[n].interpolate = INTERP_QUALIFIER_FLAT;
        so->total_in++;
 
        ctx->ir->ninputs = MAX2(ctx->ir->ninputs, r + 1);
@@ -2141,23 +2141,9 @@ setup_input(struct ir3_compile *ctx, nir_variable *in)
 
        so->inputs[n].compmask = (1 << ncomp) - 1;
        so->inputs[n].inloc = ctx->next_inloc;
-       so->inputs[n].interpolate = 0;
+       so->inputs[n].interpolate = INTERP_QUALIFIER_NONE;
        so->inputs_count = MAX2(so->inputs_count, n + 1);
-
-       /* the fdN_program_emit() code expects tgsi consts here, so map
-        * things back to tgsi for now:
-        */
-       switch (in->data.interpolation) {
-       case INTERP_QUALIFIER_FLAT:
-               so->inputs[n].interpolate = TGSI_INTERPOLATE_CONSTANT;
-               break;
-       case INTERP_QUALIFIER_NOPERSPECTIVE:
-               so->inputs[n].interpolate = TGSI_INTERPOLATE_LINEAR;
-               break;
-       case INTERP_QUALIFIER_SMOOTH:
-               so->inputs[n].interpolate = TGSI_INTERPOLATE_PERSPECTIVE;
-               break;
-       }
+       so->inputs[n].interpolate = in->data.interpolation;
 
        if (ctx->so->type == SHADER_FRAGMENT) {
                unsigned semantic_name, semantic_index;
@@ -2183,27 +2169,19 @@ setup_input(struct ir3_compile *ctx, nir_variable *in)
                        } else {
                                bool use_ldlv = false;
 
-                               /* with NIR, we need to infer TGSI_INTERPOLATE_COLOR
-                                * from the semantic name:
+                               /* detect the special case for front/back colors where
+                                * we need to do flat vs smooth shading depending on
+                                * rast state:
                                 */
                                if ((in->data.interpolation == INTERP_QUALIFIER_NONE) &&
                                                ((semantic_name == TGSI_SEMANTIC_COLOR) ||
                                                        (semantic_name == TGSI_SEMANTIC_BCOLOR)))
-                                       so->inputs[n].interpolate = TGSI_INTERPOLATE_COLOR;
+                                       so->inputs[n].rasterflat = true;
 
                                if (ctx->flat_bypass) {
-                                       /* with NIR, we need to infer TGSI_INTERPOLATE_COLOR
-                                        * from the semantic name:
-                                        */
-                                       switch (so->inputs[n].interpolate) {
-                                       case TGSI_INTERPOLATE_COLOR:
-                                               if (!ctx->so->key.rasterflat)
-                                                       break;
-                                               /* fallthrough */
-                                       case TGSI_INTERPOLATE_CONSTANT:
+                                       if ((so->inputs[n].interpolate == INTERP_QUALIFIER_FLAT) ||
+                                                       (so->inputs[n].rasterflat && ctx->so->key.rasterflat))
                                                use_ldlv = true;
-                                               break;
-                                       }
                                }
 
                                so->inputs[n].bary = true;
index 1bbbdbd224d05bff6347b9690ccd2bb3d57d7240..13b3f6a2a8599d1163b411c05b27b53a56bd50b1 100644 (file)
@@ -30,6 +30,7 @@
 #define IR3_SHADER_H_
 
 #include "pipe/p_state.h"
+#include "glsl/shader_enums.h"
 
 #include "ir3.h"
 #include "disasm.h"
@@ -82,8 +83,8 @@ struct ir3_shader_key {
                         */
                        unsigned color_two_side : 1;
                        unsigned half_precision : 1;
-                       /* used when shader needs to handle flat varyings (a4xx),
-                        * for TGSI_INTERPOLATE_COLOR:
+                       /* used when shader needs to handle flat varyings (a4xx)
+                        * for front/back color inputs to frag shader:
                         */
                        unsigned rasterflat : 1;
                };
@@ -174,8 +175,10 @@ struct ir3_shader_variant {
                 * spots where inloc is used.
                 */
                uint8_t inloc;
-               uint8_t bary;
-               uint8_t interpolate;
+               /* fragment shader specfic: */
+               bool    bary       : 1;   /* fetched varying (vs one loaded into reg) */
+               bool    rasterflat : 1;   /* special handling for emit->rasterflat */
+               enum glsl_interp_qualifier interpolate;
        } inputs[16 + 2];  /* +POSITION +FACE */
 
        unsigned total_in;       /* sum of inputs (scalar) */