iris: delete stencil mapping support

Now that we have ISL support.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Nanley Chery <nanley.g.chery@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31579>
This commit is contained in:
Lionel Landwerlin
2024-03-29 12:51:48 +02:00
committed by Marge Bot
parent 1a72fc013c
commit e4d1fd7fd6
+7 -149
View File
@@ -2164,130 +2164,6 @@ get_image_offset_el(const struct isl_surf *surf, unsigned level, unsigned z,
assert(z0_el == 0 && a0_el == 0);
}
/**
* Get pointer offset into stencil buffer.
*
* The stencil buffer is W tiled. Since the GTT is incapable of W fencing, we
* must decode the tile's layout in software.
*
* See
* - PRM, 2011 Sandy Bridge, Volume 1, Part 2, Section 4.5.2.1 W-Major Tile
* Format.
* - PRM, 2011 Sandy Bridge, Volume 1, Part 2, Section 4.5.3 Tiling Algorithm
*
* Even though the returned offset is always positive, the return type is
* signed due to
* commit e8b1c6d6f55f5be3bef25084fdd8b6127517e137
* mesa: Fix return type of _mesa_get_format_bytes() (#37351)
*/
static intptr_t
s8_offset(uint32_t stride, uint32_t x, uint32_t y)
{
uint32_t tile_size = 4096;
uint32_t tile_width = 64;
uint32_t tile_height = 64;
uint32_t row_size = 64 * stride / 2; /* Two rows are interleaved. */
uint32_t tile_x = x / tile_width;
uint32_t tile_y = y / tile_height;
/* The byte's address relative to the tile's base addres. */
uint32_t byte_x = x % tile_width;
uint32_t byte_y = y % tile_height;
uintptr_t u = tile_y * row_size
+ tile_x * tile_size
+ 512 * (byte_x / 8)
+ 64 * (byte_y / 8)
+ 32 * ((byte_y / 4) % 2)
+ 16 * ((byte_x / 4) % 2)
+ 8 * ((byte_y / 2) % 2)
+ 4 * ((byte_x / 2) % 2)
+ 2 * (byte_y % 2)
+ 1 * (byte_x % 2);
return u;
}
static void
iris_unmap_s8(struct iris_transfer *map)
{
struct pipe_transfer *xfer = &map->base.b;
const struct pipe_box *box = &xfer->box;
struct iris_resource *res = (struct iris_resource *) xfer->resource;
struct isl_surf *surf = &res->surf;
if (xfer->usage & PIPE_MAP_WRITE) {
uint8_t *untiled_s8_map = map->ptr;
uint8_t *tiled_s8_map = res->offset +
iris_bo_map(map->dbg, res->bo, (xfer->usage | MAP_RAW) & MAP_FLAGS);
for (int s = 0; s < box->depth; s++) {
unsigned x0_el, y0_el;
get_image_offset_el(surf, xfer->level, box->z + s, &x0_el, &y0_el);
for (uint32_t y = 0; y < box->height; y++) {
for (uint32_t x = 0; x < box->width; x++) {
ptrdiff_t offset = s8_offset(surf->row_pitch_B,
x0_el + box->x + x,
y0_el + box->y + y);
tiled_s8_map[offset] =
untiled_s8_map[s * xfer->layer_stride + y * xfer->stride + x];
}
}
}
}
free(map->buffer);
}
static void
iris_map_s8(struct iris_transfer *map)
{
struct pipe_transfer *xfer = &map->base.b;
const struct pipe_box *box = &xfer->box;
struct iris_resource *res = (struct iris_resource *) xfer->resource;
struct isl_surf *surf = &res->surf;
xfer->stride = surf->row_pitch_B;
xfer->layer_stride = xfer->stride * box->height;
/* The tiling and detiling functions require that the linear buffer has
* a 16-byte alignment (that is, its `x0` is 16-byte aligned). Here we
* over-allocate the linear buffer to get the proper alignment.
*/
map->buffer = map->ptr = malloc(xfer->layer_stride * box->depth);
assert(map->buffer);
/* One of either READ_BIT or WRITE_BIT or both is set. READ_BIT implies no
* INVALIDATE_RANGE_BIT. WRITE_BIT needs the original values read in unless
* invalidate is set, since we'll be writing the whole rectangle from our
* temporary buffer back out.
*/
if (xfer->usage & PIPE_MAP_READ) {
uint8_t *untiled_s8_map = map->ptr;
uint8_t *tiled_s8_map = res->offset +
iris_bo_map(map->dbg, res->bo, (xfer->usage | MAP_RAW) & MAP_FLAGS);
for (int s = 0; s < box->depth; s++) {
unsigned x0_el, y0_el;
get_image_offset_el(surf, xfer->level, box->z + s, &x0_el, &y0_el);
for (uint32_t y = 0; y < box->height; y++) {
for (uint32_t x = 0; x < box->width; x++) {
ptrdiff_t offset = s8_offset(surf->row_pitch_B,
x0_el + box->x + x,
y0_el + box->y + y);
untiled_s8_map[s * xfer->layer_stride + y * xfer->stride + x] =
tiled_s8_map[offset];
}
}
}
}
map->unmap = iris_unmap_s8;
}
/* Compute extent parameters for use with tiled_memcpy functions.
* xs are in units of bytes and ys are in units of strides.
*/
@@ -2632,10 +2508,7 @@ iris_transfer_map(struct pipe_context *ctx,
}
}
if (surf->tiling == ISL_TILING_W) {
/* TODO: Teach iris_map_tiled_memcpy about W-tiling... */
iris_map_s8(map);
} else if (surf->tiling != ISL_TILING_LINEAR) {
if (surf->tiling != ISL_TILING_LINEAR) {
iris_map_tiled_memcpy(map);
} else {
iris_map_direct(map);
@@ -2754,28 +2627,13 @@ iris_texture_subdata(struct pipe_context *ctx,
for (int s = 0; s < box->depth; s++) {
const uint8_t *src = data + s * layer_stride;
if (surf->tiling == ISL_TILING_W) {
unsigned x0_el, y0_el;
get_image_offset_el(surf, level, box->z + s, &x0_el, &y0_el);
unsigned x1, x2, y1, y2;
tile_extents(surf, box, level, s, &x1, &x2, &y1, &y2);
for (unsigned y = 0; y < box->height; y++) {
for (unsigned x = 0; x < box->width; x++) {
ptrdiff_t offset = s8_offset(surf->row_pitch_B,
x0_el + box->x + x,
y0_el + box->y + y);
dst[offset] = src[y * stride + x];
}
}
} else {
unsigned x1, x2, y1, y2;
tile_extents(surf, box, level, s, &x1, &x2, &y1, &y2);
isl_memcpy_linear_to_tiled(x1, x2, y1, y2,
(void *)dst, (void *)src,
surf->row_pitch_B, stride,
false, surf->tiling, ISL_MEMCPY);
}
isl_memcpy_linear_to_tiled(x1, x2, y1, y2,
(void *)dst, (void *)src,
surf->row_pitch_B, stride,
false, surf->tiling, ISL_MEMCPY);
}
}