aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRob Clark <[email protected]>2020-06-14 12:33:54 -0700
committerMarge Bot <[email protected]>2020-06-19 13:16:57 +0000
commita8b995c055fb47f820b1615f303a66b0995eb16a (patch)
tree4a57a662e244e78a11af60f21c13956046937b31 /src
parentbd55533f5b00cdf76ec474d8c300fe8742ca11b6 (diff)
freedreno/a6xx: defer userconst cmdstream size calculation
The `ubo_state` will also need to move to `ir3_shader_variant`. But we can prepare for that and simplify things a bit if we calculate the cmdstream on first emit, once we already have the appropriate variant. Signed-off-by: Rob Clark <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5508>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/freedreno/a6xx/fd6_const.c33
-rw-r--r--src/gallium/drivers/freedreno/a6xx/fd6_const.h2
-rw-r--r--src/gallium/drivers/freedreno/a6xx/fd6_program.c15
3 files changed, 25 insertions, 25 deletions
diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_const.c b/src/gallium/drivers/freedreno/a6xx/fd6_const.c
index 57931991f4f..ad67378a27c 100644
--- a/src/gallium/drivers/freedreno/a6xx/fd6_const.c
+++ b/src/gallium/drivers/freedreno/a6xx/fd6_const.c
@@ -277,6 +277,28 @@ 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 = &v->shader->ubo_state;
+
+ if (unlikely(!ubo_state->cmdstream_size)) {
+ unsigned packets, size;
+
+ /* pre-calculate size required for userconst stateobj: */
+ ir3_user_consts_size(ubo_state, &packets, &size);
+
+ /* also account for UBO addresses: */
+ packets += 1;
+ size += 2 * v->shader->num_ubos;
+
+ unsigned sizedwords = (4 * packets) + size;
+ ubo_state->cmdstream_size = sizedwords * 4;
+ }
+
+ return ubo_state->cmdstream_size;
+}
+
static void
emit_user_consts(struct fd6_emit *emit)
{
@@ -284,7 +306,7 @@ emit_user_consts(struct fd6_emit *emit)
PIPE_SHADER_VERTEX, PIPE_SHADER_TESS_CTRL, PIPE_SHADER_TESS_EVAL,
PIPE_SHADER_GEOMETRY, PIPE_SHADER_FRAGMENT,
};
- const struct ir3_shader_variant *variants[] = {
+ struct ir3_shader_variant *variants[] = {
emit->vs, emit->hs, emit->ds, emit->gs, emit->fs,
};
struct fd_context *ctx = emit->ctx;
@@ -293,7 +315,7 @@ emit_user_consts(struct fd6_emit *emit)
for (unsigned i = 0; i < ARRAY_SIZE(types); i++) {
if (!variants[i])
continue;
- sz += variants[i]->shader->ubo_state.cmdstream_size;
+ sz += user_consts_cmdstream_size(variants[i]);
}
struct fd_ringbuffer *constobj = fd_submit_new_ringbuffer(
@@ -361,13 +383,6 @@ fd6_emit_immediates(struct fd_screen *screen, const struct ir3_shader_variant *v
}
void
-fd6_user_consts_size(struct ir3_ubo_analysis_state *state,
- unsigned *packets, unsigned *size)
-{
- ir3_user_consts_size(state, packets, size);
-}
-
-void
fd6_emit_link_map(struct fd_screen *screen,
const struct ir3_shader_variant *producer,
const struct ir3_shader_variant *v, struct fd_ringbuffer *ring)
diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_const.h b/src/gallium/drivers/freedreno/a6xx/fd6_const.h
index 3583abcf541..aa5b7293e77 100644
--- a/src/gallium/drivers/freedreno/a6xx/fd6_const.h
+++ b/src/gallium/drivers/freedreno/a6xx/fd6_const.h
@@ -35,8 +35,6 @@ void fd6_emit_cs_consts(const struct ir3_shader_variant *v, struct fd_ringbuffer
struct fd_context *ctx, const struct pipe_grid_info *info);
void fd6_emit_immediates(struct fd_screen *screen, const struct ir3_shader_variant *v,
struct fd_ringbuffer *ring);
-void fd6_user_consts_size(struct ir3_ubo_analysis_state *state,
- unsigned *packets, unsigned *size);
void fd6_emit_link_map(struct fd_screen *screen,
const struct ir3_shader_variant *producer,
const struct ir3_shader_variant *v, struct fd_ringbuffer *ring);
diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_program.c b/src/gallium/drivers/freedreno/a6xx/fd6_program.c
index 8d63e26005a..3a8f480a3cc 100644
--- a/src/gallium/drivers/freedreno/a6xx/fd6_program.c
+++ b/src/gallium/drivers/freedreno/a6xx/fd6_program.c
@@ -1057,20 +1057,7 @@ static const struct ir3_cache_funcs cache_funcs = {
static void *
fd6_shader_state_create(struct pipe_context *pctx, const struct pipe_shader_state *cso)
{
- struct ir3_shader *shader = ir3_shader_state_create(pctx, cso);
- unsigned packets, size;
-
- /* pre-calculate size required for userconst stateobj: */
- fd6_user_consts_size(&shader->ubo_state, &packets, &size);
-
- /* also account for UBO addresses: */
- packets += 1;
- size += 2 * shader->num_ubos;
-
- unsigned sizedwords = (4 * packets) + size;
- shader->ubo_state.cmdstream_size = sizedwords * 4;
-
- return shader;
+ return ir3_shader_state_create(pctx, cso);
}
static void