From a885f91617885216c81b8495e04ced309597164f Mon Sep 17 00:00:00 2001 From: Christian Gmeiner Date: Mon, 24 Jun 2024 18:36:19 +0200 Subject: [PATCH] etnaviv: Rework uniform handling for UBO addresses We are not using this 'feature'. Doing this in the compiler would be lot of pain, as there is no backend IR. The right way to do it would be nir address opt pass, that does some offset and shift lowering. Lets see this commit as prep change for a nir pass and/or backend IR. Use the content to store the index of the UBO. Signed-off-by: Christian Gmeiner Reviewed-by: Philipp Zabel Part-of: --- src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c | 2 +- src/gallium/drivers/etnaviv/etnaviv_context.h | 3 +-- src/gallium/drivers/etnaviv/etnaviv_uniforms.c | 8 +++----- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c b/src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c index cd284d95a9a..c7406358b70 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c +++ b/src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c @@ -599,7 +599,7 @@ emit_intrinsic(struct etna_compile *c, nir_intrinsic_instr * intr) .type = ISA_TYPE_U32, .dst = ra_def(c, &intr->def, &dst_swiz), .src[0] = get_src(c, &intr->src[1]), - .src[1] = const_src(c, &CONST_VAL(ETNA_UNIFORM_UBO0_ADDR + idx, 0), 1), + .src[1] = const_src(c, &CONST_VAL(ETNA_UNIFORM_UBO_ADDR, idx), 1), }); } break; case nir_intrinsic_load_front_face: diff --git a/src/gallium/drivers/etnaviv/etnaviv_context.h b/src/gallium/drivers/etnaviv/etnaviv_context.h index d288150589c..bdf5c2d2256 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_context.h +++ b/src/gallium/drivers/etnaviv/etnaviv_context.h @@ -99,8 +99,7 @@ enum etna_uniform_contents { ETNA_UNIFORM_TEXTURE_WIDTH, ETNA_UNIFORM_TEXTURE_HEIGHT, ETNA_UNIFORM_TEXTURE_DEPTH, - ETNA_UNIFORM_UBO0_ADDR, - ETNA_UNIFORM_UBOMAX_ADDR = ETNA_UNIFORM_UBO0_ADDR + ETNA_MAX_CONST_BUF - 1, + ETNA_UNIFORM_UBO_ADDR, }; struct etna_shader_uniform_info { diff --git a/src/gallium/drivers/etnaviv/etnaviv_uniforms.c b/src/gallium/drivers/etnaviv/etnaviv_uniforms.c index 2e1cc4469f7..1b1211030ec 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_uniforms.c +++ b/src/gallium/drivers/etnaviv/etnaviv_uniforms.c @@ -117,7 +117,6 @@ etna_uniforms_write(const struct etna_context *ctx, const struct etna_shader_uniform_info *uinfo = &sobj->uniforms; bool frag = (sobj == ctx->shader.fs); uint32_t base = frag ? screen->specs.ps_uniforms_offset : screen->specs.vs_uniforms_offset; - unsigned idx; if (!uinfo->count) return; @@ -151,12 +150,11 @@ etna_uniforms_write(const struct etna_context *ctx, get_texture_size(ctx, frag, uinfo->contents[i], val)); break; - case ETNA_UNIFORM_UBO0_ADDR ... ETNA_UNIFORM_UBOMAX_ADDR: - idx = uinfo->contents[i] - ETNA_UNIFORM_UBO0_ADDR; + case ETNA_UNIFORM_UBO_ADDR: etna_cmd_stream_reloc(stream, &(struct etna_reloc) { - .bo = etna_resource(cb[idx].buffer)->bo, + .bo = etna_resource(cb[val].buffer)->bo, .flags = ETNA_RELOC_READ, - .offset = cb[idx].buffer_offset + val, + .offset = cb[val].buffer_offset, }); break;