freedreno/ir3: Add tessellation field to shader key
authorKristian H. Kristensen <hoegsberg@google.com>
Wed, 23 Oct 2019 00:16:09 +0000 (17:16 -0700)
committerKristian H. Kristensen <hoegsberg@google.com>
Fri, 8 Nov 2019 00:36:56 +0000 (16:36 -0800)
Whether we're tessellating and which primitives the TES outputs
affects the entire pipeline so let's add a field to the key to track
that.

Signed-off-by: Kristian H. Kristensen <hoegsberg@google.com>
Acked-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Rob Clark <robdclark@gmail.com>
src/freedreno/ir3/ir3_nir.c
src/freedreno/ir3/ir3_shader.h
src/gallium/drivers/freedreno/a6xx/fd6_draw.c

index 99659a7ddef40253e3d671f069e84e189f3c8065..ab092ff1eda4e851e9f2b67d4fbde2c426fdac9f 100644 (file)
@@ -104,7 +104,7 @@ ir3_key_lowers_nir(const struct ir3_shader_key *key)
                        key->vsaturate_s | key->vsaturate_t | key->vsaturate_r |
                        key->ucp_enables | key->color_two_side |
                        key->fclamp_color | key->vclamp_color |
-                       key->has_gs;
+                       key->tessellation | key->has_gs;
 }
 
 #define OPT(nir, pass, ...) ({                             \
index 84a7807a0c897a8c6a1a2a4d4d554ad73bbcb4a3..c829422ca4d2bb4e92626eb70ca71224fcf28395 100644 (file)
@@ -249,6 +249,17 @@ struct ir3_shader_key {
                        unsigned rasterflat : 1;
                        unsigned fclamp_color : 1;
 
+                       /* Indicates that this is a tessellation pipeline which requires a
+                        * whole different kind of vertex shader.  In case of
+                        * tessellation, this field also tells us which kind of output
+                        * topology the TES uses, which the TCS needs to know.
+                        */
+#define IR3_TESS_NONE          0
+#define IR3_TESS_TRIANGLES     1
+#define IR3_TESS_QUADS         2
+#define IR3_TESS_ISOLINES      3
+                       unsigned tessellation : 2;
+
                        unsigned has_gs : 1;
                };
                uint32_t global;
@@ -348,6 +359,7 @@ ir3_normalize_key(struct ir3_shader_key *key, gl_shader_stage type)
                        key->vastc_srgb = 0;
                        key->vsamples = 0;
                        key->has_gs = false; /* FS doesn't care */
+                       key->tessellation = IR3_TESS_NONE;
                }
                break;
        case MESA_SHADER_VERTEX:
@@ -362,6 +374,27 @@ ir3_normalize_key(struct ir3_shader_key *key, gl_shader_stage type)
                        key->fastc_srgb = 0;
                        key->fsamples = 0;
                }
+
+               /* VS and GS only care about whether or not we're tessellating. */
+               key->tessellation = !!key->tessellation;
+               break;
+       case MESA_SHADER_TESS_CTRL:
+       case MESA_SHADER_TESS_EVAL:
+               key->color_two_side = false;
+               key->half_precision = false;
+               key->rasterflat = false;
+               if (key->has_per_samp) {
+                       key->fsaturate_s = 0;
+                       key->fsaturate_t = 0;
+                       key->fsaturate_r = 0;
+                       key->fastc_srgb = 0;
+                       key->fsamples = 0;
+                       key->vsaturate_s = 0;
+                       key->vsaturate_t = 0;
+                       key->vsaturate_r = 0;
+                       key->vastc_srgb = 0;
+                       key->vsamples = 0;
+               }
                break;
        default:
                /* TODO */
index fcf0dc19233dbcbcfe658abb6af29e8f3f6a0b6b..a635e66d9323b41d9a1a3beef7a5cd41fd44fc0a 100644 (file)
@@ -157,6 +157,23 @@ fd6_draw_vbo(struct fd_context *ctx, const struct pipe_draw_info *info,
                .sprite_coord_mode = ctx->rasterizer->sprite_coord_mode,
        };
 
+       if (info->mode == PIPE_PRIM_PATCHES) {
+               shader_info *ds_info = &emit.key.ds->nir->info;
+               switch (ds_info->tess.primitive_mode) {
+               case GL_ISOLINES:
+                       emit.key.key.tessellation = IR3_TESS_ISOLINES;
+                       break;
+               case GL_TRIANGLES:
+                       emit.key.key.tessellation = IR3_TESS_TRIANGLES;
+                       break;
+               case GL_QUADS:
+                       emit.key.key.tessellation = IR3_TESS_QUADS;
+                       break;
+               default:
+                       unreachable("bad tessmode");
+               }
+       }
+
        if (emit.key.gs)
                emit.key.key.has_gs = true;