aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/freedreno/a5xx
diff options
context:
space:
mode:
authorRob Clark <[email protected]>2019-05-05 10:59:37 -0700
committerEric Anholt <[email protected]>2019-11-26 18:46:08 +0000
commit8d9f5a28e3879523fbdd018a2b87223313333379 (patch)
treed9a299cf24d5d6cee2ea13df04bc81fe5e356de7 /src/gallium/drivers/freedreno/a5xx
parent997b8d474901f1955ead4479d5de63eb9f150cb7 (diff)
freedreno: switch to layout helper
The slices table and most of the other layout fields in the freedreno_resource moves into fdl_layout. v2: Changes by anholt to not have duplicate fields, which was introducing a surprising behavior change in resource layout (using the level_linear helper before the setup of the shadowed fields) Reviewed-by: Eric Anholt <[email protected]> Acked-by: Rob Clark <[email protected]>
Diffstat (limited to 'src/gallium/drivers/freedreno/a5xx')
-rw-r--r--src/gallium/drivers/freedreno/a5xx/fd5_blitter.c20
-rw-r--r--src/gallium/drivers/freedreno/a5xx/fd5_emit.c2
-rw-r--r--src/gallium/drivers/freedreno/a5xx/fd5_gmem.c16
-rw-r--r--src/gallium/drivers/freedreno/a5xx/fd5_image.c10
-rw-r--r--src/gallium/drivers/freedreno/a5xx/fd5_resource.c20
-rw-r--r--src/gallium/drivers/freedreno/a5xx/fd5_texture.c10
6 files changed, 39 insertions, 39 deletions
diff --git a/src/gallium/drivers/freedreno/a5xx/fd5_blitter.c b/src/gallium/drivers/freedreno/a5xx/fd5_blitter.c
index bb02079b1d4..b5765263ce5 100644
--- a/src/gallium/drivers/freedreno/a5xx/fd5_blitter.c
+++ b/src/gallium/drivers/freedreno/a5xx/fd5_blitter.c
@@ -98,8 +98,8 @@ can_do_blit(const struct pipe_blit_info *info)
* untiling by setting both src and dst COLOR_SWAP=WZYX, but that
* means the formats must match:
*/
- if ((fd_resource(info->dst.resource)->tile_mode ||
- fd_resource(info->src.resource)->tile_mode) &&
+ if ((fd_resource(info->dst.resource)->layout.tile_mode ||
+ fd_resource(info->src.resource)->layout.tile_mode) &&
info->dst.format != info->src.format)
return false;
@@ -215,8 +215,8 @@ emit_blit_buffer(struct fd_ringbuffer *ring, const struct pipe_blit_info *info)
src = fd_resource(info->src.resource);
dst = fd_resource(info->dst.resource);
- debug_assert(src->cpp == 1);
- debug_assert(dst->cpp == 1);
+ debug_assert(src->layout.cpp == 1);
+ debug_assert(dst->layout.cpp == 1);
debug_assert(info->src.resource->format == info->dst.resource->format);
debug_assert((sbox->y == 0) && (sbox->height == 1));
debug_assert((dbox->y == 0) && (dbox->height == 1));
@@ -348,8 +348,8 @@ emit_blit(struct fd_ringbuffer *ring, const struct pipe_blit_info *info)
sswap = fd5_pipe2swap(info->src.format);
dswap = fd5_pipe2swap(info->dst.format);
- spitch = sslice->pitch * src->cpp;
- dpitch = dslice->pitch * dst->cpp;
+ spitch = sslice->pitch * src->layout.cpp;
+ dpitch = dslice->pitch * dst->layout.cpp;
/* if dtile, then dswap ignored by hw, and likewise if stile then sswap
* ignored by hw.. but in this case we have already rejected the blit
@@ -374,12 +374,12 @@ emit_blit(struct fd_ringbuffer *ring, const struct pipe_blit_info *info)
if (info->src.resource->target == PIPE_TEXTURE_3D)
ssize = sslice->size0;
else
- ssize = src->layer_size;
+ ssize = src->layout.layer_size;
if (info->dst.resource->target == PIPE_TEXTURE_3D)
dsize = dslice->size0;
else
- dsize = dst->layer_size;
+ dsize = dst->layout.layer_size;
for (unsigned i = 0; i < info->dst.box.depth; i++) {
unsigned soff = fd_resource_offset(src, info->src.level, sbox->z + i);
@@ -466,8 +466,8 @@ fd5_blitter_blit(struct fd_context *ctx, const struct pipe_blit_info *info)
if ((info->src.resource->target == PIPE_BUFFER) &&
(info->dst.resource->target == PIPE_BUFFER)) {
- assert(fd_resource(info->src.resource)->tile_mode == TILE5_LINEAR);
- assert(fd_resource(info->dst.resource)->tile_mode == TILE5_LINEAR);
+ assert(fd_resource(info->src.resource)->layout.tile_mode == TILE5_LINEAR);
+ assert(fd_resource(info->dst.resource)->layout.tile_mode == TILE5_LINEAR);
emit_blit_buffer(batch->draw, info);
} else {
/* I don't *think* we need to handle blits between buffer <-> !buffer */
diff --git a/src/gallium/drivers/freedreno/a5xx/fd5_emit.c b/src/gallium/drivers/freedreno/a5xx/fd5_emit.c
index 4de5d0aa62d..486657d92f4 100644
--- a/src/gallium/drivers/freedreno/a5xx/fd5_emit.c
+++ b/src/gallium/drivers/freedreno/a5xx/fd5_emit.c
@@ -365,7 +365,7 @@ emit_textures(struct fd_context *ctx, struct fd_ringbuffer *ring,
enum a5xx_tile_mode tile_mode = TILE5_LINEAR;
if (view->base.texture)
- tile_mode = fd_resource(view->base.texture)->tile_mode;
+ tile_mode = fd_resource(view->base.texture)->layout.tile_mode;
OUT_RING(ring, view->texconst0 |
A5XX_TEX_CONST_0_TILE_MODE(tile_mode));
diff --git a/src/gallium/drivers/freedreno/a5xx/fd5_gmem.c b/src/gallium/drivers/freedreno/a5xx/fd5_gmem.c
index 5b8bfb650c7..3380f8f6381 100644
--- a/src/gallium/drivers/freedreno/a5xx/fd5_gmem.c
+++ b/src/gallium/drivers/freedreno/a5xx/fd5_gmem.c
@@ -89,7 +89,7 @@ emit_mrt(struct fd_ringbuffer *ring, unsigned nr_bufs,
size = stride * gmem->bin_h;
base = gmem->cbuf_base[i];
} else {
- stride = slice->pitch * rsc->cpp;
+ stride = slice->pitch * rsc->layout.cpp;
size = slice->size0;
tile_mode = fd_resource_tile_mode(psurf->texture, psurf->u.tex.level);
@@ -136,7 +136,7 @@ emit_zs(struct fd_ringbuffer *ring, struct pipe_surface *zsbuf,
if (zsbuf) {
struct fd_resource *rsc = fd_resource(zsbuf->texture);
enum a5xx_depth_format fmt = fd5_pipe2depth(zsbuf->format);
- uint32_t cpp = rsc->cpp;
+ uint32_t cpp = rsc->layout.cpp;
uint32_t stride = 0;
uint32_t size = 0;
@@ -145,7 +145,7 @@ emit_zs(struct fd_ringbuffer *ring, struct pipe_surface *zsbuf,
size = stride * gmem->bin_h;
} else {
struct fdl_slice *slice = fd_resource_slice(rsc, 0);
- stride = slice->pitch * rsc->cpp;
+ stride = slice->pitch * rsc->layout.cpp;
size = slice->size0;
}
@@ -192,7 +192,7 @@ emit_zs(struct fd_ringbuffer *ring, struct pipe_surface *zsbuf,
size = stride * gmem->bin_h;
} else {
struct fdl_slice *slice = fd_resource_slice(rsc->stencil, 0);
- stride = slice->pitch * rsc->cpp;
+ stride = slice->pitch * rsc->layout.cpp;
size = slice->size0;
}
@@ -490,16 +490,16 @@ emit_mem2gmem_surf(struct fd_batch *batch, uint32_t base,
OUT_PKT4(ring, REG_A5XX_RB_MRT_BUF_INFO(0), 5);
OUT_RING(ring, A5XX_RB_MRT_BUF_INFO_COLOR_FORMAT(format) |
- A5XX_RB_MRT_BUF_INFO_COLOR_TILE_MODE(rsc->tile_mode) |
+ A5XX_RB_MRT_BUF_INFO_COLOR_TILE_MODE(rsc->layout.tile_mode) |
A5XX_RB_MRT_BUF_INFO_COLOR_SWAP(WZYX));
- OUT_RING(ring, A5XX_RB_MRT_PITCH(slice->pitch * rsc->cpp));
+ OUT_RING(ring, A5XX_RB_MRT_PITCH(slice->pitch * rsc->layout.cpp));
OUT_RING(ring, A5XX_RB_MRT_ARRAY_PITCH(slice->size0));
OUT_RELOC(ring, rsc->bo, 0, 0, 0); /* BASE_LO/HI */
buf = BLIT_MRT0;
}
- stride = gmem->bin_w * rsc->cpp;
+ stride = gmem->bin_w * rsc->layout.cpp;
size = stride * gmem->bin_h;
OUT_PKT4(ring, REG_A5XX_RB_BLIT_FLAG_DST_LO, 4);
@@ -637,7 +637,7 @@ emit_gmem2mem_surf(struct fd_batch *batch, uint32_t base,
OUT_RING(ring, 0x00000004 | /* XXX RB_RESOLVE_CNTL_3 */
COND(tiled, A5XX_RB_RESOLVE_CNTL_3_TILED));
OUT_RELOCW(ring, rsc->bo, offset, 0, 0); /* RB_BLIT_DST_LO/HI */
- OUT_RING(ring, A5XX_RB_BLIT_DST_PITCH(slice->pitch * rsc->cpp));
+ OUT_RING(ring, A5XX_RB_BLIT_DST_PITCH(slice->pitch * rsc->layout.cpp));
OUT_RING(ring, A5XX_RB_BLIT_DST_ARRAY_PITCH(slice->size0));
OUT_PKT4(ring, REG_A5XX_RB_BLIT_CNTL, 1);
diff --git a/src/gallium/drivers/freedreno/a5xx/fd5_image.c b/src/gallium/drivers/freedreno/a5xx/fd5_image.c
index 4e1f77a63ad..e46a21c4523 100644
--- a/src/gallium/drivers/freedreno/a5xx/fd5_image.c
+++ b/src/gallium/drivers/freedreno/a5xx/fd5_image.c
@@ -75,7 +75,7 @@ static void translate_image(struct fd5_image *img, struct pipe_image_view *pimg)
img->fetchsize = fd5_pipe2fetchsize(format);
img->type = fd5_tex_type(prsc->target);
img->srgb = util_format_is_srgb(format);
- img->cpp = rsc->cpp;
+ img->cpp = rsc->layout.cpp;
img->bo = rsc->bo;
if (prsc->target == PIPE_BUFFER) {
@@ -86,7 +86,7 @@ static void translate_image(struct fd5_image *img, struct pipe_image_view *pimg)
lvl = pimg->u.tex.level;
slice = fd_resource_slice(rsc, lvl);
img->offset = fd_resource_offset(rsc, lvl, pimg->u.tex.first_layer);
- img->pitch = slice->pitch * rsc->cpp;
+ img->pitch = slice->pitch * rsc->layout.cpp;
}
img->width = u_minify(prsc->width0, lvl);
@@ -98,17 +98,17 @@ static void translate_image(struct fd5_image *img, struct pipe_image_view *pimg)
case PIPE_TEXTURE_RECT:
case PIPE_TEXTURE_1D:
case PIPE_TEXTURE_2D:
- img->array_pitch = rsc->layer_size;
+ img->array_pitch = rsc->layout.layer_size;
img->depth = 1;
break;
case PIPE_TEXTURE_1D_ARRAY:
case PIPE_TEXTURE_2D_ARRAY:
- img->array_pitch = rsc->layer_size;
+ img->array_pitch = rsc->layout.layer_size;
img->depth = layers;
break;
case PIPE_TEXTURE_CUBE:
case PIPE_TEXTURE_CUBE_ARRAY:
- img->array_pitch = rsc->layer_size;
+ img->array_pitch = rsc->layout.layer_size;
img->depth = layers;
break;
case PIPE_TEXTURE_3D:
diff --git a/src/gallium/drivers/freedreno/a5xx/fd5_resource.c b/src/gallium/drivers/freedreno/a5xx/fd5_resource.c
index 00174b9afe1..7e1497630b0 100644
--- a/src/gallium/drivers/freedreno/a5xx/fd5_resource.c
+++ b/src/gallium/drivers/freedreno/a5xx/fd5_resource.c
@@ -58,9 +58,9 @@ setup_slices(struct fd_resource *rsc, uint32_t alignment, enum pipe_format forma
/* in layer_first layout, the level (slice) contains just one
* layer (since in fact the layer contains the slices)
*/
- uint32_t layers_in_level = rsc->layer_first ? 1 : prsc->array_size;
+ uint32_t layers_in_level = rsc->layout.layer_first ? 1 : prsc->array_size;
- heightalign = tile_alignment[rsc->cpp].heightalign;
+ heightalign = tile_alignment[rsc->layout.cpp].heightalign;
for (level = 0; level <= prsc->last_level; level++) {
struct fdl_slice *slice = fd_resource_slice(rsc, level);
@@ -68,7 +68,7 @@ setup_slices(struct fd_resource *rsc, uint32_t alignment, enum pipe_format forma
uint32_t blocks;
if (fd_resource_tile_mode(prsc, level)) {
- pitchalign = tile_alignment[rsc->cpp].pitchalign;
+ pitchalign = tile_alignment[rsc->layout.cpp].pitchalign;
aligned_height = align(aligned_height, heightalign);
} else {
pitchalign = 64;
@@ -102,17 +102,17 @@ setup_slices(struct fd_resource *rsc, uint32_t alignment, enum pipe_format forma
if (prsc->target == PIPE_TEXTURE_3D && (
level == 1 ||
(level > 1 && fd_resource_slice(rsc, level - 1)->size0 > 0xf000)))
- slice->size0 = align(blocks * rsc->cpp, alignment);
- else if (level == 0 || rsc->layer_first || alignment == 1)
- slice->size0 = align(blocks * rsc->cpp, alignment);
+ slice->size0 = align(blocks * rsc->layout.cpp, alignment);
+ else if (level == 0 || rsc->layout.layer_first || alignment == 1)
+ slice->size0 = align(blocks * rsc->layout.cpp, alignment);
else
slice->size0 = fd_resource_slice(rsc, level - 1)->size0;
#if 0
debug_printf("%s: %ux%ux%u@%u: %2u: stride=%4u, size=%7u, aligned_height=%3u\n",
util_format_name(prsc->format),
- prsc->width0, prsc->height0, prsc->depth0, rsc->cpp,
- level, slice->pitch * rsc->cpp,
+ prsc->width0, prsc->height0, prsc->depth0, rsc->layout.cpp,
+ level, slice->pitch * rsc->layout.cpp,
slice->size0 * depth * layers_in_level,
aligned_height);
#endif
@@ -134,11 +134,11 @@ fd5_setup_slices(struct fd_resource *rsc)
switch (rsc->base.target) {
case PIPE_TEXTURE_3D:
- rsc->layer_first = false;
+ rsc->layout.layer_first = false;
alignment = 4096;
break;
default:
- rsc->layer_first = true;
+ rsc->layout.layer_first = true;
alignment = 1;
break;
}
diff --git a/src/gallium/drivers/freedreno/a5xx/fd5_texture.c b/src/gallium/drivers/freedreno/a5xx/fd5_texture.c
index 0a3f2ec68af..5da1a3022e9 100644
--- a/src/gallium/drivers/freedreno/a5xx/fd5_texture.c
+++ b/src/gallium/drivers/freedreno/a5xx/fd5_texture.c
@@ -250,7 +250,7 @@ fd5_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc,
A5XX_TEX_CONST_1_HEIGHT(1);
so->texconst2 =
A5XX_TEX_CONST_2_FETCHSIZE(fd5_pipe2fetchsize(format)) |
- A5XX_TEX_CONST_2_PITCH(elements * rsc->cpp);
+ A5XX_TEX_CONST_2_PITCH(elements * rsc->layout.cpp);
so->offset = cso->u.buf.offset;
} else {
unsigned miplevels;
@@ -267,7 +267,7 @@ fd5_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc,
so->texconst2 =
A5XX_TEX_CONST_2_FETCHSIZE(fd5_pipe2fetchsize(format)) |
A5XX_TEX_CONST_2_PITCH(
- util_format_get_nblocksx(format, slice->pitch) * rsc->cpp);
+ util_format_get_nblocksx(format, slice->pitch) * rsc->layout.cpp);
so->offset = fd_resource_offset(rsc, lvl, cso->u.tex.first_layer);
}
@@ -278,21 +278,21 @@ fd5_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc,
case PIPE_TEXTURE_1D:
case PIPE_TEXTURE_2D:
so->texconst3 =
- A5XX_TEX_CONST_3_ARRAY_PITCH(rsc->layer_size);
+ A5XX_TEX_CONST_3_ARRAY_PITCH(rsc->layout.layer_size);
so->texconst5 =
A5XX_TEX_CONST_5_DEPTH(1);
break;
case PIPE_TEXTURE_1D_ARRAY:
case PIPE_TEXTURE_2D_ARRAY:
so->texconst3 =
- A5XX_TEX_CONST_3_ARRAY_PITCH(rsc->layer_size);
+ A5XX_TEX_CONST_3_ARRAY_PITCH(rsc->layout.layer_size);
so->texconst5 =
A5XX_TEX_CONST_5_DEPTH(layers);
break;
case PIPE_TEXTURE_CUBE:
case PIPE_TEXTURE_CUBE_ARRAY:
so->texconst3 =
- A5XX_TEX_CONST_3_ARRAY_PITCH(rsc->layer_size);
+ A5XX_TEX_CONST_3_ARRAY_PITCH(rsc->layout.layer_size);
so->texconst5 =
A5XX_TEX_CONST_5_DEPTH(layers / 6);
break;