From 11563da8fa852c19c45b90a6a8427ea79008fd80 Mon Sep 17 00:00:00 2001 From: "Kristian H. Kristensen" Date: Wed, 7 Oct 2020 21:33:57 +0000 Subject: [PATCH] freedreno/a6xx: Generalize pointers in struct fd6_pipe_sampler_view Add resource pointers ptr1 and ptr2 and offsets offset1 and offset2, and just emit relocs if the pointers are non-NULL. This lets us move a little more logic to the CSO building. Reviewed-by: Rob Clark Part-of: --- src/gallium/drivers/freedreno/a6xx/fd6_emit.c | 14 ++++---------- src/gallium/drivers/freedreno/a6xx/fd6_texture.c | 15 ++++++++++----- src/gallium/drivers/freedreno/a6xx/fd6_texture.h | 4 ++-- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_emit.c b/src/gallium/drivers/freedreno/a6xx/fd6_emit.c index d4f73c4..e07abee 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_emit.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_emit.c @@ -391,20 +391,14 @@ fd6_emit_textures(struct fd_pipe *pipe, struct fd_ringbuffer *ring, static const struct fd6_pipe_sampler_view dummy_view = {}; const struct fd6_pipe_sampler_view *view = tex->textures[i] ? fd6_pipe_sampler_view(tex->textures[i]) : &dummy_view; - struct fd_resource *rsc = NULL; - - if (view->base.texture) - rsc = fd_resource(view->base.texture); OUT_RING(state, view->texconst0); OUT_RING(state, view->texconst1); OUT_RING(state, view->texconst2); OUT_RING(state, view->texconst3); - if (rsc) { - if (view->base.format == PIPE_FORMAT_X32_S8X24_UINT) - rsc = rsc->stencil; - OUT_RELOC(state, rsc->bo, view->offset, + if (view->ptr1) { + OUT_RELOC(state, view->ptr1->bo, view->offset1, (uint64_t)view->texconst5 << 32, 0); } else { OUT_RING(state, 0x00000000); @@ -413,8 +407,8 @@ fd6_emit_textures(struct fd_pipe *pipe, struct fd_ringbuffer *ring, OUT_RING(state, view->texconst6); - if (rsc && view->ubwc_enabled) { - OUT_RELOC(state, rsc->bo, view->ubwc_offset, 0, 0); + if (view->ptr2) { + OUT_RELOC(state, view->ptr2->bo, view->offset2, 0, 0); } else { OUT_RING(state, 0); OUT_RING(state, 0); diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_texture.c b/src/gallium/drivers/freedreno/a6xx/fd6_texture.c index e428f75..05022fb 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_texture.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_texture.c @@ -221,6 +221,7 @@ fd6_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc, struct fd6_pipe_sampler_view *so = CALLOC_STRUCT(fd6_pipe_sampler_view); struct fd_resource *rsc = fd_resource(prsc); enum pipe_format format = cso->format; + bool ubwc_enabled = false; unsigned lvl, layers = 0; if (!so) @@ -239,6 +240,7 @@ fd6_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc, so->base.reference.count = 1; so->base.context = pctx; so->seqno = ++fd6_context(fd_context(pctx))->tex_seqno; + so->ptr1 = rsc; if (cso->target == PIPE_BUFFER) { unsigned elements = cso->u.buf.size / util_format_get_blocksize(format); @@ -250,7 +252,7 @@ fd6_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc, so->texconst2 = A6XX_TEX_CONST_2_UNK4 | A6XX_TEX_CONST_2_UNK31; - so->offset = cso->u.buf.offset; + so->offset1 = cso->u.buf.offset; } else { unsigned miplevels; @@ -265,9 +267,12 @@ fd6_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc, so->texconst2 = A6XX_TEX_CONST_2_PITCHALIGN(rsc->layout.pitchalign - 6) | A6XX_TEX_CONST_2_PITCH(fd_resource_pitch(rsc, lvl)); - so->offset = fd_resource_offset(rsc, lvl, cso->u.tex.first_layer); - so->ubwc_offset = fd_resource_ubwc_offset(rsc, lvl, cso->u.tex.first_layer); - so->ubwc_enabled = fd_resource_ubwc_enabled(rsc, lvl); + so->offset1 = fd_resource_offset(rsc, lvl, cso->u.tex.first_layer); + ubwc_enabled = fd_resource_ubwc_enabled(rsc, lvl); + if (ubwc_enabled) { + so->ptr2 = rsc; + so->offset2 = fd_resource_ubwc_offset(rsc, lvl, cso->u.tex.first_layer); + } } so->texconst0 |= fd6_tex_const_0(prsc, lvl, cso->format, @@ -314,7 +319,7 @@ fd6_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc, if (rsc->layout.tile_all) so->texconst3 |= A6XX_TEX_CONST_3_TILE_ALL; - if (so->ubwc_enabled) { + if (ubwc_enabled) { uint32_t block_width, block_height; fdl6_get_ubwc_blockwidth(&rsc->layout, &block_width, &block_height); diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_texture.h b/src/gallium/drivers/freedreno/a6xx/fd6_texture.h index 09b14c2..44e5c32 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_texture.h +++ b/src/gallium/drivers/freedreno/a6xx/fd6_texture.h @@ -54,9 +54,9 @@ struct fd6_pipe_sampler_view { struct pipe_sampler_view base; uint32_t texconst0, texconst1, texconst2, texconst3, texconst5; uint32_t texconst6, texconst7, texconst8, texconst9, texconst10, texconst11; - uint32_t offset, ubwc_offset; + uint32_t offset1, offset2; + struct fd_resource *ptr1, *ptr2; uint16_t seqno; - bool ubwc_enabled; }; static inline struct fd6_pipe_sampler_view * -- 2.7.4