From 2f3b980caace799e920513a54f81f2cca7b10406 Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Sun, 18 Sep 2022 11:34:33 -0700 Subject: [PATCH] freedreno/a6xx: Move user const upload to bind Signed-off-by: Rob Clark Part-of: --- .../drivers/freedreno/a6xx/fd6_const.c | 19 ++++--------------- .../drivers/freedreno/freedreno_state.c | 12 ++++++++++++ 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_const.c b/src/gallium/drivers/freedreno/a6xx/fd6_const.c index 5ec98cdf41c..1069c8a92dd 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_const.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_const.c @@ -187,8 +187,8 @@ fd6_build_tess_consts(struct fd6_emit *emit) } static void -fd6_emit_ubos(struct fd_context *ctx, const struct ir3_shader_variant *v, - struct fd_ringbuffer *ring, struct fd_constbuf_stateobj *constbuf) +fd6_emit_ubos(const struct ir3_shader_variant *v, struct fd_ringbuffer *ring, + struct fd_constbuf_stateobj *constbuf) { const struct ir3_const_state *const_state = ir3_const_state(v); int num_ubos = const_state->num_ubos; @@ -216,17 +216,6 @@ fd6_emit_ubos(struct fd_context *ctx, const struct ir3_shader_variant *v, struct pipe_constant_buffer *cb = &constbuf->cb[i]; - /* If we have user pointers (constbuf 0, aka GL uniforms), upload them - * to a buffer now, and save it in the constbuf so that we don't have - * to reupload until they get changed. - */ - if (cb->user_buffer) { - struct pipe_context *pctx = &ctx->base; - u_upload_data(pctx->stream_uploader, 0, cb->buffer_size, 64, - cb->user_buffer, &cb->buffer_offset, &cb->buffer); - cb->user_buffer = NULL; - } - if (cb->buffer) { int size_vec4s = DIV_ROUND_UP(cb->buffer_size, 16); OUT_RELOC(ring, fd_resource(cb->buffer)->bo, cb->buffer_offset, @@ -280,7 +269,7 @@ fd6_build_user_consts(struct fd6_emit *emit) continue; ir3_emit_user_consts(variants[i], constobj, &ctx->constbuf[types[i]]); - fd6_emit_ubos(ctx, variants[i], constobj, &ctx->constbuf[types[i]]); + fd6_emit_ubos(variants[i], constobj, &ctx->constbuf[types[i]]); } return constobj; @@ -337,7 +326,7 @@ fd6_emit_cs_consts(const struct ir3_shader_variant *v, const struct pipe_grid_info *info) { ir3_emit_cs_consts(v, ring, ctx, info); - fd6_emit_ubos(ctx, v, ring, &ctx->constbuf[PIPE_SHADER_COMPUTE]); + fd6_emit_ubos(v, ring, &ctx->constbuf[PIPE_SHADER_COMPUTE]); } void diff --git a/src/gallium/drivers/freedreno/freedreno_state.c b/src/gallium/drivers/freedreno/freedreno_state.c index cee035f679f..801fea1673a 100644 --- a/src/gallium/drivers/freedreno/freedreno_state.c +++ b/src/gallium/drivers/freedreno/freedreno_state.c @@ -29,6 +29,7 @@ #include "util/u_helpers.h" #include "util/u_memory.h" #include "util/u_string.h" +#include "util/u_upload_mgr.h" #include "freedreno_context.h" #include "freedreno_gmem.h" @@ -103,6 +104,14 @@ fd_set_min_samples(struct pipe_context *pctx, unsigned min_samples) in_dt fd_context_dirty(ctx, FD_DIRTY_MIN_SAMPLES); } +static void +upload_user_buffer(struct pipe_context *pctx, struct pipe_constant_buffer *cb) +{ + u_upload_data(pctx->stream_uploader, 0, cb->buffer_size, 64, + cb->user_buffer, &cb->buffer_offset, &cb->buffer); + cb->user_buffer = NULL; +} + /* notes from calim on #dri-devel: * index==0 will be non-UBO (ie. glUniformXYZ()) all packed together padded * out to vec4's @@ -129,6 +138,9 @@ fd_set_constant_buffer(struct pipe_context *pctx, enum pipe_shader_type shader, return; } + if (cb->user_buffer && ctx->screen->gen >= 6) + upload_user_buffer(pctx, &so->cb[index]); + so->enabled_mask |= 1 << index; fd_context_dirty_shader(ctx, shader, FD_DIRTY_SHADER_CONST);