Browse Source

freedreno: Convert the slice struct to the new resource header.

This gets the worst of the sed required for shared resource layout out of
the way.  The texture layout comment is dropped now that we're referencing
the shared header, which has a more complete description.

Acked-by: Rob Clark <robdclark@chromium.org>
master
Eric Anholt 7 years ago
parent
commit
2e62a622e7

+ 3
- 6
src/gallium/drivers/freedreno/a2xx/fd2_gmem.c View File

@@ -89,8 +89,7 @@ emit_gmem2mem_surf(struct fd_batch *batch, uint32_t base,
{
struct fd_ringbuffer *ring = batch->tile_fini;
struct fd_resource *rsc = fd_resource(psurf->texture);
struct fd_resource_slice *slice =
fd_resource_slice(rsc, psurf->u.tex.level);
struct fdl_slice *slice = fd_resource_slice(rsc, psurf->u.tex.level);
uint32_t offset =
fd_resource_offset(rsc, psurf->u.tex.level, psurf->u.tex.first_layer);
enum pipe_format format = fd_gmem_restore_format(psurf->format);
@@ -230,8 +229,7 @@ emit_mem2gmem_surf(struct fd_batch *batch, uint32_t base,
{
struct fd_ringbuffer *ring = batch->gmem;
struct fd_resource *rsc = fd_resource(psurf->texture);
struct fd_resource_slice *slice =
fd_resource_slice(rsc, psurf->u.tex.level);
struct fdl_slice *slice = fd_resource_slice(rsc, psurf->u.tex.level);
uint32_t offset =
fd_resource_offset(rsc, psurf->u.tex.level, psurf->u.tex.first_layer);
enum pipe_format format = fd_gmem_restore_format(psurf->format);
@@ -437,8 +435,7 @@ fd2_emit_sysmem_prep(struct fd_batch *batch)
return;

struct fd_resource *rsc = fd_resource(psurf->texture);
struct fd_resource_slice *slice =
fd_resource_slice(rsc, psurf->u.tex.level);
struct fdl_slice *slice = fd_resource_slice(rsc, psurf->u.tex.level);
uint32_t offset =
fd_resource_offset(rsc, psurf->u.tex.level, psurf->u.tex.first_layer);


+ 1
- 1
src/gallium/drivers/freedreno/a2xx/fd2_resource.c View File

@@ -37,7 +37,7 @@ fd2_setup_slices(struct fd_resource *rsc)
uint32_t depth = prsc->depth0;

for (level = 0; level <= prsc->last_level; level++) {
struct fd_resource_slice *slice = fd_resource_slice(rsc, level);
struct fdl_slice *slice = fd_resource_slice(rsc, level);
uint32_t blocks;

/* 32 * 32 block alignment */

+ 1
- 1
src/gallium/drivers/freedreno/a2xx/fd2_texture.c View File

@@ -181,7 +181,7 @@ fd2_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc,
so->base.reference.count = 1;
so->base.context = pctx;

struct fd_resource_slice *slice0 = fd_resource_slice(rsc, 0);
struct fdl_slice *slice0 = fd_resource_slice(rsc, 0);
so->tex0 =
A2XX_SQ_TEX_0_SIGN_X(fmt.sign) |
A2XX_SQ_TEX_0_SIGN_Y(fmt.sign) |

+ 2
- 3
src/gallium/drivers/freedreno/a3xx/fd3_emit.c View File

@@ -215,8 +215,7 @@ emit_textures(struct fd_context *ctx, struct fd_ringbuffer *ring,
unsigned end = fd_sampler_last_level(&view->base);

for (j = 0; j < (end - start + 1); j++) {
struct fd_resource_slice *slice =
fd_resource_slice(rsc, j + start);
struct fdl_slice *slice = fd_resource_slice(rsc, j + start);
OUT_RELOC(ring, rsc->bo, slice->offset, 0, 0);
}
}
@@ -311,7 +310,7 @@ fd3_emit_gmem_restore_tex(struct fd_ringbuffer *ring,

/* note: PIPE_BUFFER disallowed for surfaces */
unsigned lvl = psurf[i]->u.tex.level;
struct fd_resource_slice *slice = fd_resource_slice(rsc, lvl);
struct fdl_slice *slice = fd_resource_slice(rsc, lvl);

debug_assert(psurf[i]->u.tex.first_layer == psurf[i]->u.tex.last_layer);


+ 3
- 3
src/gallium/drivers/freedreno/a3xx/fd3_gmem.c View File

@@ -55,7 +55,7 @@ emit_mrt(struct fd_ringbuffer *ring, unsigned nr_bufs,
enum a3xx_color_swap swap = WZYX;
bool srgb = false;
struct fd_resource *rsc = NULL;
struct fd_resource_slice *slice = NULL;
struct fdl_slice *slice = NULL;
uint32_t stride = 0;
uint32_t base = 0;
uint32_t offset = 0;
@@ -330,7 +330,7 @@ emit_gmem2mem_surf(struct fd_batch *batch,
format = rsc->base.format;
}

struct fd_resource_slice *slice = fd_resource_slice(rsc, psurf->u.tex.level);
struct fdl_slice *slice = fd_resource_slice(rsc, psurf->u.tex.level);
uint32_t offset = fd_resource_offset(rsc, psurf->u.tex.level,
psurf->u.tex.first_layer);

@@ -738,7 +738,7 @@ fd3_emit_sysmem_prep(struct fd_batch *batch)
struct pipe_surface *psurf = pfb->cbufs[i];
if (!psurf)
continue;
struct fd_resource_slice *slice =
struct fdl_slice *slice =
fd_resource_slice(fd_resource(psurf->texture),
psurf->u.tex.level);
pitch = slice->pitch;

+ 1
- 1
src/gallium/drivers/freedreno/a3xx/fd3_resource.c View File

@@ -37,7 +37,7 @@ setup_slices(struct fd_resource *rsc, uint32_t alignment, enum pipe_format forma
uint32_t depth = prsc->depth0;

for (level = 0; level <= prsc->last_level; level++) {
struct fd_resource_slice *slice = fd_resource_slice(rsc, level);
struct fdl_slice *slice = fd_resource_slice(rsc, level);
uint32_t blocks;

if (rsc->tile_mode) {

+ 1
- 1
src/gallium/drivers/freedreno/a3xx/fd3_texture.c View File

@@ -263,7 +263,7 @@ fd3_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc,
A3XX_TEX_CONST_1_HEIGHT(u_minify(prsc->height0, lvl));
}
/* when emitted, A3XX_TEX_CONST_2_INDX() must be OR'd in: */
struct fd_resource_slice *slice = fd_resource_slice(rsc, lvl);
struct fdl_slice *slice = fd_resource_slice(rsc, lvl);
so->texconst2 =
A3XX_TEX_CONST_2_PITCH(fd3_pipe2nblocksx(cso->format, slice->pitch) * rsc->cpp);
switch (prsc->target) {

+ 1
- 1
src/gallium/drivers/freedreno/a4xx/fd4_emit.c View File

@@ -301,7 +301,7 @@ fd4_emit_gmem_restore_tex(struct fd_ringbuffer *ring, unsigned nr_bufs,

/* note: PIPE_BUFFER disallowed for surfaces */
unsigned lvl = bufs[i]->u.tex.level;
struct fd_resource_slice *slice = fd_resource_slice(rsc, lvl);
struct fdl_slice *slice = fd_resource_slice(rsc, lvl);
unsigned offset = fd_resource_offset(rsc, lvl, bufs[i]->u.tex.first_layer);

/* z32 restore is accomplished using depth write. If there is

+ 2
- 2
src/gallium/drivers/freedreno/a4xx/fd4_gmem.c View File

@@ -61,7 +61,7 @@ emit_mrt(struct fd_ringbuffer *ring, unsigned nr_bufs,
enum a3xx_color_swap swap = WZYX;
bool srgb = false;
struct fd_resource *rsc = NULL;
struct fd_resource_slice *slice = NULL;
struct fdl_slice *slice = NULL;
uint32_t stride = 0;
uint32_t base = 0;
uint32_t offset = 0;
@@ -152,7 +152,7 @@ emit_gmem2mem_surf(struct fd_batch *batch, bool stencil,
struct fd_ringbuffer *ring = batch->gmem;
struct fd_resource *rsc = fd_resource(psurf->texture);
enum pipe_format pformat = psurf->format;
struct fd_resource_slice *slice;
struct fdl_slice *slice;
uint32_t offset;

if (!rsc->valid)

+ 1
- 1
src/gallium/drivers/freedreno/a4xx/fd4_texture.c View File

@@ -222,7 +222,7 @@ fd4_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc,
{
struct fd4_pipe_sampler_view *so = CALLOC_STRUCT(fd4_pipe_sampler_view);
struct fd_resource *rsc = fd_resource(prsc);
struct fd_resource_slice *slice = NULL;
struct fdl_slice *slice = NULL;
enum pipe_format format = cso->format;
unsigned lvl, layers = 0;


+ 1
- 1
src/gallium/drivers/freedreno/a5xx/fd5_blitter.c View File

@@ -325,7 +325,7 @@ emit_blit(struct fd_ringbuffer *ring, const struct pipe_blit_info *info)
const struct pipe_box *sbox = &info->src.box;
const struct pipe_box *dbox = &info->dst.box;
struct fd_resource *src, *dst;
struct fd_resource_slice *sslice, *dslice;
struct fdl_slice *sslice, *dslice;
enum a5xx_color_fmt sfmt, dfmt;
enum a5xx_tile_mode stile, dtile;
enum a3xx_color_swap sswap, dswap;

+ 5
- 5
src/gallium/drivers/freedreno/a5xx/fd5_gmem.c View File

@@ -54,7 +54,7 @@ emit_mrt(struct fd_ringbuffer *ring, unsigned nr_bufs,
enum a3xx_color_swap swap = WZYX;
bool srgb = false, sint = false, uint = false;
struct fd_resource *rsc = NULL;
struct fd_resource_slice *slice = NULL;
struct fdl_slice *slice = NULL;
uint32_t stride = 0;
uint32_t size = 0;
uint32_t base = 0;
@@ -144,7 +144,7 @@ emit_zs(struct fd_ringbuffer *ring, struct pipe_surface *zsbuf,
stride = cpp * gmem->bin_w;
size = stride * gmem->bin_h;
} else {
struct fd_resource_slice *slice = fd_resource_slice(rsc, 0);
struct fdl_slice *slice = fd_resource_slice(rsc, 0);
stride = slice->pitch * rsc->cpp;
size = slice->size0;
}
@@ -191,7 +191,7 @@ emit_zs(struct fd_ringbuffer *ring, struct pipe_surface *zsbuf,
stride = 1 * gmem->bin_w;
size = stride * gmem->bin_h;
} else {
struct fd_resource_slice *slice = fd_resource_slice(rsc->stencil, 0);
struct fdl_slice *slice = fd_resource_slice(rsc->stencil, 0);
stride = slice->pitch * rsc->cpp;
size = slice->size0;
}
@@ -484,7 +484,7 @@ emit_mem2gmem_surf(struct fd_batch *batch, uint32_t base,
// possibly we want to flip this around gmem2mem and keep depth
// tiled in sysmem (and fixup sampler state to assume tiled).. this
// might be required for doing depth/stencil in bypass mode?
struct fd_resource_slice *slice = fd_resource_slice(rsc, 0);
struct fdl_slice *slice = fd_resource_slice(rsc, 0);
enum a5xx_color_fmt format =
fd5_pipe2color(fd_gmem_restore_format(rsc->base.format));

@@ -609,7 +609,7 @@ emit_gmem2mem_surf(struct fd_batch *batch, uint32_t base,
{
struct fd_ringbuffer *ring = batch->gmem;
struct fd_resource *rsc = fd_resource(psurf->texture);
struct fd_resource_slice *slice;
struct fdl_slice *slice;
bool tiled;
uint32_t offset;


+ 1
- 1
src/gallium/drivers/freedreno/a5xx/fd5_image.c View File

@@ -62,7 +62,7 @@ static void translate_image(struct fd5_image *img, struct pipe_image_view *pimg)
enum pipe_format format = pimg->format;
struct pipe_resource *prsc = pimg->resource;
struct fd_resource *rsc = fd_resource(prsc);
struct fd_resource_slice *slice = NULL;
struct fdl_slice *slice = NULL;
unsigned lvl;

if (!pimg->resource) {

+ 1
- 1
src/gallium/drivers/freedreno/a5xx/fd5_resource.c View File

@@ -63,7 +63,7 @@ setup_slices(struct fd_resource *rsc, uint32_t alignment, enum pipe_format forma
heightalign = tile_alignment[rsc->cpp].heightalign;

for (level = 0; level <= prsc->last_level; level++) {
struct fd_resource_slice *slice = fd_resource_slice(rsc, level);
struct fdl_slice *slice = fd_resource_slice(rsc, level);
uint32_t aligned_height = height;
uint32_t blocks;


+ 1
- 1
src/gallium/drivers/freedreno/a5xx/fd5_texture.c View File

@@ -198,7 +198,7 @@ fd5_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc,
{
struct fd5_pipe_sampler_view *so = CALLOC_STRUCT(fd5_pipe_sampler_view);
struct fd_resource *rsc = fd_resource(prsc);
struct fd_resource_slice *slice = NULL;
struct fdl_slice *slice = NULL;
enum pipe_format format = cso->format;
unsigned lvl, layers = 0;


+ 1
- 1
src/gallium/drivers/freedreno/a6xx/fd6_blitter.c View File

@@ -348,7 +348,7 @@ emit_blit_or_clear_texture(struct fd_context *ctx, struct fd_ringbuffer *ring,
const struct pipe_box *sbox = &info->src.box;
const struct pipe_box *dbox = &info->dst.box;
struct fd_resource *src, *dst;
struct fd_resource_slice *sslice, *dslice;
struct fdl_slice *sslice, *dslice;
enum a6xx_color_fmt sfmt, dfmt;
enum a6xx_tile_mode stile, dtile;
enum a3xx_color_swap sswap, dswap;

+ 4
- 4
src/gallium/drivers/freedreno/a6xx/fd6_gmem.c View File

@@ -65,7 +65,7 @@ emit_mrt(struct fd_ringbuffer *ring, struct pipe_framebuffer_state *pfb,
enum a3xx_color_swap swap = WZYX;
bool sint = false, uint = false;
struct fd_resource *rsc = NULL;
struct fd_resource_slice *slice = NULL;
struct fdl_slice *slice = NULL;
uint32_t stride = 0;
uint32_t offset, ubwc_offset;
uint32_t tile_mode;
@@ -182,7 +182,7 @@ emit_zs(struct fd_ringbuffer *ring, struct pipe_surface *zsbuf,
if (zsbuf) {
struct fd_resource *rsc = fd_resource(zsbuf->texture);
enum a6xx_depth_format fmt = fd6_pipe2depth(zsbuf->format);
struct fd_resource_slice *slice = fd_resource_slice(rsc, 0);
struct fdl_slice *slice = fd_resource_slice(rsc, 0);
uint32_t stride = slice->pitch * rsc->cpp;
uint32_t size = slice->size0;
uint32_t base = gmem ? gmem->zsbuf_base[0] : 0;
@@ -238,7 +238,7 @@ emit_zs(struct fd_ringbuffer *ring, struct pipe_surface *zsbuf,
OUT_RING(ring, CP_EVENT_WRITE_0_EVENT(UNK_25));

if (rsc->stencil) {
struct fd_resource_slice *slice = fd_resource_slice(rsc->stencil, 0);
struct fdl_slice *slice = fd_resource_slice(rsc->stencil, 0);
stride = slice->pitch * rsc->stencil->cpp;
size = slice->size0;
uint32_t base = gmem ? gmem->zsbuf_base[1] : 0;
@@ -966,7 +966,7 @@ emit_blit(struct fd_batch *batch,
struct pipe_surface *psurf,
bool stencil)
{
struct fd_resource_slice *slice;
struct fdl_slice *slice;
struct fd_resource *rsc = fd_resource(psurf->texture);
enum pipe_format pfmt = psurf->format;
uint32_t offset, ubwc_offset;

+ 1
- 1
src/gallium/drivers/freedreno/a6xx/fd6_image.c View File

@@ -97,7 +97,7 @@ static void translate_image(struct fd6_image *img, const struct pipe_image_view
img->buffer = false;

unsigned lvl = pimg->u.tex.level;
struct fd_resource_slice *slice = fd_resource_slice(rsc, lvl);
struct fdl_slice *slice = fd_resource_slice(rsc, lvl);
unsigned layers = pimg->u.tex.last_layer - pimg->u.tex.first_layer + 1;

img->ubwc_offset = fd_resource_ubwc_offset(rsc, lvl, pimg->u.tex.first_layer);

+ 1
- 1
src/gallium/drivers/freedreno/a6xx/fd6_resource.c View File

@@ -84,7 +84,7 @@ setup_slices(struct fd_resource *rsc, uint32_t alignment, enum pipe_format forma
debug_assert(tile_alignment[ta].pitchalign);

for (level = 0; level <= prsc->last_level; level++) {
struct fd_resource_slice *slice = fd_resource_slice(rsc, level);
struct fdl_slice *slice = fd_resource_slice(rsc, level);
uint32_t tile_mode = fd_resource_tile_mode(prsc, level);
uint32_t width, height;


+ 1
- 1
src/gallium/drivers/freedreno/a6xx/fd6_texture.c View File

@@ -220,7 +220,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);
struct fd_resource_slice *slice = NULL;
struct fdl_slice *slice = NULL;
enum pipe_format format = cso->format;
unsigned lvl, layers = 0;


+ 5
- 5
src/gallium/drivers/freedreno/freedreno_resource.c View File

@@ -506,7 +506,7 @@ fd_resource_transfer_map(struct pipe_context *pctx,
{
struct fd_context *ctx = fd_context(pctx);
struct fd_resource *rsc = fd_resource(prsc);
struct fd_resource_slice *slice = fd_resource_slice(rsc, level);
struct fdl_slice *slice = fd_resource_slice(rsc, level);
struct fd_transfer *trans;
struct pipe_transfer *ptrans;
enum pipe_format format = prsc->format;
@@ -544,7 +544,7 @@ fd_resource_transfer_map(struct pipe_context *pctx,

staging_rsc = fd_alloc_staging(ctx, rsc, level, box);
if (staging_rsc) {
struct fd_resource_slice *staging_slice =
struct fdl_slice *staging_slice =
fd_resource_slice(staging_rsc, 0);
// TODO for PIPE_TRANSFER_READ, need to do untiling blit..
trans->staging_prsc = &staging_rsc->base;
@@ -661,7 +661,7 @@ fd_resource_transfer_map(struct pipe_context *pctx,
*/
staging_rsc = fd_alloc_staging(ctx, rsc, level, box);
if (staging_rsc) {
struct fd_resource_slice *staging_slice =
struct fdl_slice *staging_slice =
fd_resource_slice(staging_rsc, 0);
trans->staging_prsc = &staging_rsc->base;
trans->base.stride = util_format_get_nblocksx(format,
@@ -782,7 +782,7 @@ setup_slices(struct fd_resource *rsc, uint32_t alignment, enum pipe_format forma
uint32_t layers_in_level = rsc->layer_first ? 1 : prsc->array_size;

for (level = 0; level <= prsc->last_level; level++) {
struct fd_resource_slice *slice = fd_resource_slice(rsc, level);
struct fdl_slice *slice = fd_resource_slice(rsc, level);
uint32_t blocks;

if (layout == UTIL_FORMAT_LAYOUT_ASTC)
@@ -1093,7 +1093,7 @@ fd_resource_from_handle(struct pipe_screen *pscreen,
{
struct fd_screen *screen = fd_screen(pscreen);
struct fd_resource *rsc = CALLOC_STRUCT(fd_resource);
struct fd_resource_slice *slice = fd_resource_slice(rsc, 0);
struct fdl_slice *slice = fd_resource_slice(rsc, 0);
struct pipe_resource *prsc = &rsc->base;
uint32_t pitchalign = fd_screen(pscreen)->gmem_alignw;


+ 4
- 28
src/gallium/drivers/freedreno/freedreno_resource.h View File

@@ -33,31 +33,7 @@

#include "freedreno_batch.h"
#include "freedreno_util.h"

/* Texture Layout on a3xx:
*
* Each mipmap-level contains all of it's layers (ie. all cubmap
* faces, all 1d/2d array elements, etc). The texture sampler is
* programmed with the start address of each mipmap level, and hw
* derives the layer offset within the level.
*
* Texture Layout on a4xx+:
*
* For cubemap and 2d array, each layer contains all of it's mipmap
* levels (layer_first layout).
*
* 3d textures are layed out as on a3xx, but unknown about 3d-array
* textures.
*
* In either case, the slice represents the per-miplevel information,
* but in layer_first layout it only includes the first layer, and
* an additional offset of (rsc->layer_size * layer) must be added.
*/
struct fd_resource_slice {
uint32_t offset; /* offset of first layer in slice */
uint32_t pitch;
uint32_t size0; /* size of first layer in slice */
};
#include "freedreno/fdl/freedreno_layout.h"

struct fd_resource {
struct pipe_resource base;
@@ -66,7 +42,7 @@ struct fd_resource {
enum pipe_format internal_format;
bool layer_first; /* see above description */
uint32_t layer_size;
struct fd_resource_slice slices[MAX_MIP_LEVELS];
struct fdl_slice slices[MAX_MIP_LEVELS];
/* buffer range that has been initialized */
struct util_range valid_buffer_range;
bool valid;
@@ -149,7 +125,7 @@ fd_transfer(struct pipe_transfer *ptrans)
return (struct fd_transfer *)ptrans;
}

static inline struct fd_resource_slice *
static inline struct fdl_slice *
fd_resource_slice(struct fd_resource *rsc, unsigned level)
{
assert(level <= rsc->base.last_level);
@@ -169,7 +145,7 @@ fd_resource_layer_stride(struct fd_resource *rsc, unsigned level)
static inline uint32_t
fd_resource_offset(struct fd_resource *rsc, unsigned level, unsigned layer)
{
struct fd_resource_slice *slice = fd_resource_slice(rsc, level);
struct fdl_slice *slice = fd_resource_slice(rsc, level);
unsigned offset = slice->offset;
offset += fd_resource_layer_stride(rsc, level) * layer;
debug_assert(offset < fd_bo_size(rsc->bo));

+ 1
- 1
src/gallium/drivers/freedreno/ir3/ir3_gallium.c View File

@@ -343,7 +343,7 @@ ir3_emit_image_dims(struct fd_screen *screen, const struct ir3_shader_variant *v

dims[off + 0] = util_format_get_blocksize(img->format);
if (img->resource->target != PIPE_BUFFER) {
struct fd_resource_slice *slice =
struct fdl_slice *slice =
fd_resource_slice(rsc, img->u.tex.level);
/* note for 2d/cube/etc images, even if re-interpreted
* as a different color format, the pixel size should

Loading…
Cancel
Save