mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 09:08:10 +02:00
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 <robdclark@chromium.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5508>
This commit is contained in:
parent
bd55533f5b
commit
a8b995c055
3 changed files with 25 additions and 25 deletions
|
|
@ -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(
|
||||
|
|
@ -360,13 +382,6 @@ fd6_emit_immediates(struct fd_screen *screen, const struct ir3_shader_variant *v
|
|||
ir3_emit_immediates(screen, v, ring);
|
||||
}
|
||||
|
||||
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,
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue