freedreno/ir3: drop shader->num_ubos
authorRob Clark <robdclark@chromium.org>
Sun, 14 Jun 2020 19:54:05 +0000 (12:54 -0700)
committerMarge Bot <eric+marge@anholt.net>
Fri, 19 Jun 2020 13:16:57 +0000 (13:16 +0000)
The only difference between this and `const_state->num_ubos` was that
the latter is counting # of ubos loaded via `ldg` (based on UBO addrs
in push-consts).  But turns out there isn't really any reason to care.
Instead just add an early return in the one code-path that cares about
the number of `ldg` UBOs.

This gets rid of one more thing we need to move from `ir3_shader` to
`ir3_shader_variant`.

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

src/freedreno/ir3/ir3_nir.c
src/freedreno/ir3/ir3_shader.h
src/gallium/drivers/freedreno/a6xx/fd6_const.c
src/gallium/drivers/freedreno/ir3/ir3_const.h

index e1c163ddc5cb1d9fbca574249c9779fdcdc81886..0afe624a3552734bc6c970c4062a661639bc4f16 100644 (file)
@@ -468,13 +468,7 @@ ir3_setup_const_state(struct ir3_shader *shader, nir_shader *nir,
                        MAX2(const_state->num_driver_params, IR3_DP_VTXCNT_MAX + 1);
        }
 
-       /* On a6xx, we use UBO descriptors and LDC instead of UBO pointers in the
-        * constbuf.
-        */
-       if (compiler->gpu_id >= 600)
-               shader->num_ubos = nir->info.num_ubos;
-       else
-               const_state->num_ubos = nir->info.num_ubos;
+       const_state->num_ubos = nir->info.num_ubos;
 
        /* num_driver_params is scalar, align to vec4: */
        const_state->num_driver_params = align(const_state->num_driver_params, 4);
index a89abfe9e166d1ec268c651d38a5f15e6e019687..1ee7371d8f422a9c7891a86ccf3bce9fd5e547c5 100644 (file)
@@ -622,11 +622,6 @@ struct ir3_shader {
 
        struct ir3_compiler *compiler;
 
-       /* Number of UBOs loaded by LDC, as opposed to LDG through pointers in
-        * ubo_state.
-        */
-       unsigned num_ubos;
-
        struct ir3_const_state const_state;
 
        struct nir_shader *nir;
index 5b591441839291537a7ed507ac14fbc48be31749..2e9af8c03ae2f6ab45b6a687783967f91c3bb610 100644 (file)
@@ -233,10 +233,11 @@ static void
 fd6_emit_ubos(struct fd_context *ctx, const struct ir3_shader_variant *v,
                struct fd_ringbuffer *ring, struct fd_constbuf_stateobj *constbuf)
 {
-       if (!v->shader->num_ubos)
-               return;
+       const struct ir3_const_state *const_state = ir3_const_state(v);
+       int num_ubos = const_state->num_ubos;
 
-       int num_ubos = v->shader->num_ubos;
+       if (!num_ubos)
+               return;
 
        OUT_PKT7(ring, fd6_stage2opcode(v->type), 3 + (2 * num_ubos));
        OUT_RING(ring, CP_LOAD_STATE6_0_DST_OFF(0) |
@@ -280,7 +281,8 @@ fd6_emit_ubos(struct fd_context *ctx, const struct ir3_shader_variant *v,
 static unsigned
 user_consts_cmdstream_size(struct ir3_shader_variant *v)
 {
-       struct ir3_ubo_analysis_state *ubo_state = &ir3_const_state(v)->ubo_state;
+       struct ir3_const_state *const_state = ir3_const_state(v);
+       struct ir3_ubo_analysis_state *ubo_state = &const_state->ubo_state;
 
        if (unlikely(!ubo_state->cmdstream_size)) {
                unsigned packets, size;
@@ -290,7 +292,7 @@ user_consts_cmdstream_size(struct ir3_shader_variant *v)
 
                /* also account for UBO addresses: */
                packets += 1;
-               size += 2 * v->shader->num_ubos;
+               size += 2 * const_state->num_ubos;
 
                unsigned sizedwords = (4 * packets) + size;
                ubo_state->cmdstream_size = sizedwords * 4;
index 2b92ac920b77bbd175213524396df9913b780bb5..ee73bc501d9665edbec8d97de4011a545c95794b 100644 (file)
@@ -136,6 +136,13 @@ ir3_emit_ubos(struct fd_context *ctx, const struct ir3_shader_variant *v,
 {
        const struct ir3_const_state *const_state = ir3_const_state(v);
        uint32_t offset = const_state->offsets.ubo;
+
+       /* a6xx+ uses UBO state and ldc instead of pointers emitted in
+        * const state and ldg:
+        */
+       if (ctx->screen->gpu_id >= 600)
+               return;
+
        if (v->constlen > offset) {
                uint32_t params = const_state->num_ubos;
                uint32_t offsets[params];