freedreno/a6xx: pre-calculate userconst stateobj size
The AnTuTu "garden" benchmark overflows the fixed size constbuffer stateobject, so lets be more clever and calculate (a potentially slightly pessimistic) actual size. Signed-off-by: Rob Clark <robdclark@chromium.org>
This commit is contained in:
parent
5a9dec7534
commit
b4df115d3f
|
@ -527,6 +527,7 @@ struct ir3_ubo_analysis_state
|
|||
struct ir3_ubo_range range[IR3_MAX_CONSTANT_BUFFERS];
|
||||
uint32_t size;
|
||||
uint32_t lower_count;
|
||||
uint32_t cmdstream_size; /* for per-gen backend to stash required cmdstream size */
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -928,7 +928,8 @@ fd6_emit_state(struct fd_ringbuffer *ring, struct fd6_emit *emit)
|
|||
|
||||
if (ctx->dirty_shader[PIPE_SHADER_VERTEX] & DIRTY_CONST) {
|
||||
struct fd_ringbuffer *vsconstobj = fd_submit_new_ringbuffer(
|
||||
ctx->batch->submit, 0x1000, FD_RINGBUFFER_STREAMING);
|
||||
ctx->batch->submit, vp->shader->ubo_state.cmdstream_size,
|
||||
FD_RINGBUFFER_STREAMING);
|
||||
|
||||
ir3_emit_user_consts(ctx->screen, vp, vsconstobj,
|
||||
&ctx->constbuf[PIPE_SHADER_VERTEX]);
|
||||
|
@ -940,7 +941,8 @@ fd6_emit_state(struct fd_ringbuffer *ring, struct fd6_emit *emit)
|
|||
|
||||
if (ctx->dirty_shader[PIPE_SHADER_FRAGMENT] & DIRTY_CONST) {
|
||||
struct fd_ringbuffer *fsconstobj = fd_submit_new_ringbuffer(
|
||||
ctx->batch->submit, 0x1000, FD_RINGBUFFER_STREAMING);
|
||||
ctx->batch->submit, fp->shader->ubo_state.cmdstream_size,
|
||||
FD_RINGBUFFER_STREAMING);
|
||||
|
||||
ir3_emit_user_consts(ctx->screen, fp, fsconstobj,
|
||||
&ctx->constbuf[PIPE_SHADER_FRAGMENT]);
|
||||
|
|
|
@ -45,7 +45,21 @@ create_shader_stateobj(struct pipe_context *pctx, const struct pipe_shader_state
|
|||
{
|
||||
struct fd_context *ctx = fd_context(pctx);
|
||||
struct ir3_compiler *compiler = ctx->screen->compiler;
|
||||
return ir3_shader_create(compiler, cso, type, &ctx->debug, pctx->screen);
|
||||
struct ir3_shader *shader =
|
||||
ir3_shader_create(compiler, cso, type, &ctx->debug, pctx->screen);
|
||||
unsigned packets, size;
|
||||
|
||||
/* pre-calculate size required for userconst stateobj: */
|
||||
ir3_user_consts_size(&shader->ubo_state, &packets, &size);
|
||||
|
||||
/* also account for UBO addresses: */
|
||||
packets += 1;
|
||||
size += 2 * shader->const_state.num_ubos;
|
||||
|
||||
unsigned sizedwords = (4 * packets) + size;
|
||||
shader->ubo_state.cmdstream_size = sizedwords * 4;
|
||||
|
||||
return shader;
|
||||
}
|
||||
|
||||
static void *
|
||||
|
|
|
@ -211,6 +211,29 @@ emit_const(struct fd_screen *screen, struct fd_ringbuffer *ring,
|
|||
offset, size, user_buffer, buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indirectly calculates size of cmdstream needed for ir3_emit_user_consts().
|
||||
* Returns number of packets, and total size of all the payload.
|
||||
*
|
||||
* The value can be a worst-case, ie. some shader variants may not read all
|
||||
* consts, etc.
|
||||
*
|
||||
* Returns size in dwords.
|
||||
*/
|
||||
void
|
||||
ir3_user_consts_size(struct ir3_ubo_analysis_state *state,
|
||||
unsigned *packets, unsigned *size)
|
||||
{
|
||||
*packets = *size = 0;
|
||||
|
||||
for (uint32_t i = 0; i < ARRAY_SIZE(state->range); i++) {
|
||||
if (state->range[i].start < state->range[i].end) {
|
||||
*size += state->range[i].end - state->range[i].start;
|
||||
(*packets)++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ir3_emit_user_consts(struct fd_screen *screen, const struct ir3_shader_variant *v,
|
||||
struct fd_ringbuffer *ring, struct fd_constbuf_stateobj *constbuf)
|
||||
|
|
|
@ -51,6 +51,8 @@ struct fd_constbuf_stateobj;
|
|||
struct fd_shaderbuf_stateobj;
|
||||
struct fd_shaderimg_stateobj;
|
||||
|
||||
void ir3_user_consts_size(struct ir3_ubo_analysis_state *state,
|
||||
unsigned *packets, unsigned *size);
|
||||
void ir3_emit_user_consts(struct fd_screen *screen, const struct ir3_shader_variant *v,
|
||||
struct fd_ringbuffer *ring, struct fd_constbuf_stateobj *constbuf);
|
||||
void ir3_emit_ubos(struct fd_screen *screen, const struct ir3_shader_variant *v,
|
||||
|
|
Loading…
Reference in New Issue