freedreno/a6xx+ir3: stop generating pointless binning shaders
authorRob Clark <robdclark@chromium.org>
Sat, 20 Jun 2020 19:39:14 +0000 (12:39 -0700)
committerRob Clark <robdclark@chromium.org>
Fri, 26 Jun 2020 15:53:00 +0000 (08:53 -0700)
Currently we always do sysmem if there is tess.  And for GS, the binning
pass VS ends up identical to the draw pass VS, so no point in compiling
it twice.  (For GS what we should do someday is generate a binning pass
GS, and possibly if we can do cross-stage linking opts, an optimized
binning pass VS, but the required outputs would somehow have to end up
in the shader variant key.)

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5372>

src/freedreno/ir3/ir3_shader.h
src/freedreno/vulkan/tu_pipeline.c
src/gallium/drivers/freedreno/a6xx/fd6_program.c
src/gallium/drivers/freedreno/ir3/ir3_cache.c

index cbbdce767eeb72373f48717c2e49d2fa21b3063c..2ccc9a86cd355a2495282b4b5381801e145d2374 100644 (file)
@@ -643,6 +643,17 @@ ir3_shader_stage(struct ir3_shader_variant *v)
        }
 }
 
+/* Currently we do not do binning for tess.  And for GS there is no
+ * cross-stage VS+GS optimization, so the full VS+GS is used in
+ * the binning pass.
+ */
+static inline bool
+ir3_has_binning_vs(const struct ir3_shader_key *key)
+{
+       if (key->tessellation || key->has_gs)
+               return false;
+       return true;
+}
 
 /**
  * Represents a shader at the API level, before state-specific variants are
index 54d011b002ad2644b205221f30e41b8b467edb72..64a92008af2a34d142343873e0d74675f824c706 100644 (file)
@@ -2001,7 +2001,8 @@ tu_pipeline_builder_compile_shaders(struct tu_pipeline_builder *builder,
    const struct tu_shader *vs = builder->shaders[MESA_SHADER_VERTEX];
    struct ir3_shader_variant *variant;
 
-   if (vs->ir3_shader->stream_output.num_outputs) {
+   if (vs->ir3_shader->stream_output.num_outputs ||
+       !ir3_has_binning_vs(&key)) {
       variant = builder->variants[MESA_SHADER_VERTEX];
    } else {
       bool created;
index dbf145359df1373f07179209f8b20f5c5ea6517c..5b5d9b56420c8b31f7bba691431baec52a6277a2 100644 (file)
@@ -228,10 +228,7 @@ setup_config_stateobj(struct fd_ringbuffer *ring, struct fd6_program_state *stat
        OUT_PKT4(ring, REG_A6XX_HLSQ_UPDATE_CNTL, 1);
        OUT_RING(ring, 0xff);        /* XXX */
 
-       if (state->ds)
-               debug_assert(state->ds->constlen >= state->bs->constlen);
-       else
-               debug_assert(state->vs->constlen >= state->bs->constlen);
+       debug_assert(state->vs->constlen >= state->bs->constlen);
 
        OUT_PKT4(ring, REG_A6XX_HLSQ_VS_CNTL, 4);
        OUT_RING(ring, A6XX_HLSQ_VS_CNTL_CONSTLEN(state->vs->constlen) |
index 5f6bb20fe8b788d376fc251e2311431ff0002336..606e610be79f571be1495c74b07ae2a67aace403 100644 (file)
@@ -132,17 +132,16 @@ ir3_cache_lookup(struct ir3_cache *cache, const struct ir3_cache_key *key,
                }
        }
 
-       /* For tessellation, the binning shader is derived from the DS. */
        struct ir3_shader_variant *bs;
-       if (key->ds) {
-               shader_key.safe_constlen = !!(safe_constlens & (1 << MESA_SHADER_TESS_EVAL));
-               bs = ir3_shader_variant(key->ds, shader_key, true, debug);
-       } else {
+
+       if (ir3_has_binning_vs(&key->key)) {
                shader_key.safe_constlen = !!(safe_constlens & (1 << MESA_SHADER_VERTEX));
-               bs = ir3_shader_variant(key->vs, shader_key, true, debug);
+               bs = ir3_shader_variant(key->vs, key->key, true, debug);
+               if (!bs)
+                       return NULL;
+       } else {
+               bs = variants[MESA_SHADER_VERTEX];
        }
-       if (!bs)
-               return NULL;
 
        struct ir3_program_state *state =
                cache->funcs->create_state(cache->data, bs,