mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-06 17:30:20 +01:00
freedreno/a6xx: Pre-calculate user const state size
We can do this when we construct the program state object, rather than at draw time. Signed-off-by: Rob Clark <robdclark@chromium.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18646>
This commit is contained in:
parent
a81c6d7439
commit
075218f756
5 changed files with 29 additions and 24 deletions
|
|
@ -128,8 +128,6 @@ struct ir3_ubo_analysis_state {
|
|||
struct ir3_ubo_range range[IR3_MAX_UBO_PUSH_RANGES];
|
||||
uint32_t num_enabled;
|
||||
uint32_t size;
|
||||
uint32_t
|
||||
cmdstream_size; /* for per-gen backend to stash required cmdstream size */
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -238,27 +238,25 @@ fd6_emit_ubos(struct fd_context *ctx, const struct ir3_shader_variant *v,
|
|||
}
|
||||
}
|
||||
|
||||
static unsigned
|
||||
user_consts_cmdstream_size(struct ir3_shader_variant *v)
|
||||
unsigned
|
||||
fd6_user_consts_cmdstream_size(struct ir3_shader_variant *v)
|
||||
{
|
||||
if (!v)
|
||||
return 0;
|
||||
|
||||
struct ir3_const_state *const_state = ir3_const_state(v);
|
||||
struct ir3_ubo_analysis_state *ubo_state = &const_state->ubo_state;
|
||||
unsigned packets, size;
|
||||
|
||||
if (unlikely(!ubo_state->cmdstream_size)) {
|
||||
unsigned packets, size;
|
||||
/* pre-calculate size required for userconst stateobj: */
|
||||
ir3_user_consts_size(ubo_state, &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 * const_state->num_ubos;
|
||||
|
||||
/* also account for UBO addresses: */
|
||||
packets += 1;
|
||||
size += 2 * const_state->num_ubos;
|
||||
|
||||
unsigned sizedwords = (4 * packets) + size;
|
||||
ubo_state->cmdstream_size = sizedwords * 4;
|
||||
}
|
||||
|
||||
return ubo_state->cmdstream_size;
|
||||
unsigned sizedwords = (4 * packets) + size;
|
||||
return sizedwords * 4;
|
||||
}
|
||||
|
||||
struct fd_ringbuffer *
|
||||
|
|
@ -272,13 +270,7 @@ fd6_build_user_consts(struct fd6_emit *emit)
|
|||
emit->vs, emit->hs, emit->ds, emit->gs, emit->fs,
|
||||
};
|
||||
struct fd_context *ctx = emit->ctx;
|
||||
unsigned sz = 0;
|
||||
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(types); i++) {
|
||||
if (!variants[i])
|
||||
continue;
|
||||
sz += user_consts_cmdstream_size(variants[i]);
|
||||
}
|
||||
unsigned sz = emit->prog->user_consts_cmdstream_size;
|
||||
|
||||
struct fd_ringbuffer *constobj =
|
||||
fd_submit_new_ringbuffer(ctx->batch->submit, sz, FD_RINGBUFFER_STREAMING);
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
#include "fd6_emit.h"
|
||||
|
||||
struct fd_ringbuffer *fd6_build_tess_consts(struct fd6_emit *emit) assert_dt;
|
||||
unsigned fd6_user_consts_cmdstream_size(struct ir3_shader_variant *v);
|
||||
struct fd_ringbuffer *fd6_build_user_consts(struct fd6_emit *emit) assert_dt;
|
||||
struct fd_ringbuffer *
|
||||
fd6_build_driver_params(struct fd6_emit *emit) assert_dt;
|
||||
|
|
|
|||
|
|
@ -1288,6 +1288,14 @@ fd6_program_create(void *data, struct ir3_shader_variant *bs,
|
|||
if (stream_output->num_outputs > 0)
|
||||
state->stream_output = stream_output;
|
||||
|
||||
/* Note that binning pass uses same const state as draw pass: */
|
||||
state->user_consts_cmdstream_size =
|
||||
fd6_user_consts_cmdstream_size(state->vs) +
|
||||
fd6_user_consts_cmdstream_size(state->hs) +
|
||||
fd6_user_consts_cmdstream_size(state->ds) +
|
||||
fd6_user_consts_cmdstream_size(state->gs) +
|
||||
fd6_user_consts_cmdstream_size(state->fs);
|
||||
|
||||
return &state->base;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -58,6 +58,12 @@ struct fd6_program_state {
|
|||
* render targets.
|
||||
*/
|
||||
uint32_t mrt_components;
|
||||
|
||||
/**
|
||||
* Rather than calculating user consts state size each draw,
|
||||
* calculate it up-front.
|
||||
*/
|
||||
uint32_t user_consts_cmdstream_size;
|
||||
};
|
||||
|
||||
static inline struct fd6_program_state *
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue