summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlyssa Rosenzweig <[email protected]>2020-02-18 09:49:13 -0500
committerMarge Bot <[email protected]>2020-02-18 16:20:56 +0000
commitbee5c9b0dc13dbae0ccf124124eaccebf7f2a435 (patch)
tree0478144918861ce5b8a6c43fa8b3311e300fe37a
parent28e94e0a948ebdc98decb5cdbb2ddfcf31cb2b0b (diff)
panfrost: Remove enum panfrost_memory_layout
It duplicates mali_texture_layout. Let's use the native hardware enum and spare a pointless translation. Signed-off-by: Alyssa Rosenzweig <[email protected]> Reviewed-by: Boris Brezillon <[email protected]> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3854> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3854>
-rw-r--r--src/gallium/drivers/panfrost/pan_context.c25
-rw-r--r--src/gallium/drivers/panfrost/pan_mfbd.c12
-rw-r--r--src/gallium/drivers/panfrost/pan_resource.c23
-rw-r--r--src/gallium/drivers/panfrost/pan_resource.h12
-rw-r--r--src/gallium/drivers/panfrost/pan_sfbd.c6
5 files changed, 28 insertions, 50 deletions
diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c
index 6f45901ee81..b0a5e784b04 100644
--- a/src/gallium/drivers/panfrost/pan_context.c
+++ b/src/gallium/drivers/panfrost/pan_context.c
@@ -471,21 +471,6 @@ panfrost_upload_sampler_descriptors(struct panfrost_context *ctx)
}
}
-static enum mali_texture_layout
-panfrost_layout_for_texture(struct panfrost_resource *rsrc)
-{
- switch (rsrc->layout) {
- case PAN_AFBC:
- return MALI_TEXTURE_AFBC;
- case PAN_TILED:
- return MALI_TEXTURE_TILED;
- case PAN_LINEAR:
- return MALI_TEXTURE_LINEAR;
- default:
- unreachable("Invalid texture layout");
- }
-}
-
static mali_ptr
panfrost_upload_tex(
struct panfrost_context *ctx,
@@ -532,7 +517,7 @@ panfrost_upload_tex(
}
/* Lower-bit is set when sampling from colour AFBC */
- bool is_afbc = rsrc->layout == PAN_AFBC;
+ bool is_afbc = rsrc->layout == MALI_TEXTURE_AFBC;
bool is_zs = rsrc->base.bind & PIPE_BIND_DEPTH_STENCIL;
unsigned afbc_bit = (is_afbc && !is_zs) ? 1 : 0;
@@ -545,7 +530,7 @@ panfrost_upload_tex(
/* Add the usage flags in, since they can change across the CSO
* lifetime due to layout switches */
- view->hw.format.layout = panfrost_layout_for_texture(rsrc);
+ view->hw.format.layout = rsrc->layout;
view->hw.format.manual_stride = has_manual_stride;
/* Inject the addresses in, interleaving array indices, mip levels,
@@ -2161,7 +2146,7 @@ panfrost_create_sampler_view(
unsigned first_level = template->u.tex.first_level;
unsigned last_level = template->u.tex.last_level;
- if (prsrc->layout == PAN_LINEAR) {
+ if (prsrc->layout == MALI_TEXTURE_LINEAR) {
for (unsigned l = first_level; l <= last_level; ++l) {
unsigned actual_stride = prsrc->slices[l].stride;
unsigned width = u_minify(texture->width0, l);
@@ -2276,14 +2261,14 @@ panfrost_hint_afbc(
for (unsigned i = 0; i < fb->nr_cbufs; ++i) {
struct pipe_surface *surf = fb->cbufs[i];
struct panfrost_resource *rsrc = pan_resource(surf->texture);
- panfrost_resource_hint_layout(screen, rsrc, PAN_AFBC, 1);
+ panfrost_resource_hint_layout(screen, rsrc, MALI_TEXTURE_AFBC, 1);
}
/* Also hint it to the depth buffer */
if (fb->zsbuf) {
struct panfrost_resource *rsrc = pan_resource(fb->zsbuf->texture);
- panfrost_resource_hint_layout(screen, rsrc, PAN_AFBC, 1);
+ panfrost_resource_hint_layout(screen, rsrc, MALI_TEXTURE_AFBC, 1);
}
}
diff --git a/src/gallium/drivers/panfrost/pan_mfbd.c b/src/gallium/drivers/panfrost/pan_mfbd.c
index 72a0743e9f3..c2cc11d1119 100644
--- a/src/gallium/drivers/panfrost/pan_mfbd.c
+++ b/src/gallium/drivers/panfrost/pan_mfbd.c
@@ -199,15 +199,15 @@ panfrost_mfbd_set_cbuf(
/* Now, we set the layout specific pieces */
- if (rsrc->layout == PAN_LINEAR) {
+ if (rsrc->layout == MALI_TEXTURE_LINEAR) {
rt->format.block = MALI_BLOCK_LINEAR;
rt->framebuffer = base;
rt->framebuffer_stride = stride / 16;
- } else if (rsrc->layout == PAN_TILED) {
+ } else if (rsrc->layout == MALI_TEXTURE_TILED) {
rt->format.block = MALI_BLOCK_TILED;
rt->framebuffer = base;
rt->framebuffer_stride = stride;
- } else if (rsrc->layout == PAN_AFBC) {
+ } else if (rsrc->layout == MALI_TEXTURE_AFBC) {
rt->format.block = MALI_BLOCK_AFBC;
unsigned header_size = rsrc->slices[level].header_size;
@@ -240,7 +240,7 @@ panfrost_mfbd_set_zsbuf(
mali_ptr base = panfrost_get_texture_address(rsrc, level, first_layer);
- if (rsrc->layout == PAN_AFBC) {
+ if (rsrc->layout == MALI_TEXTURE_AFBC) {
/* The only Z/S format we can compress is Z24S8 or variants
* thereof (handled by the state tracker) */
assert(panfrost_is_z24s8_variant(surf->format));
@@ -259,7 +259,7 @@ panfrost_mfbd_set_zsbuf(
fbx->ds_afbc.zero1 = 0x10009;
fbx->ds_afbc.padding = 0x1000;
- } else if (rsrc->layout == PAN_LINEAR || rsrc->layout == PAN_TILED) {
+ } else if (rsrc->layout == MALI_TEXTURE_LINEAR || rsrc->layout == MALI_TEXTURE_TILED) {
/* TODO: Z32F(S8) support, which is always linear */
int stride = rsrc->slices[level].stride;
@@ -270,7 +270,7 @@ panfrost_mfbd_set_zsbuf(
fbx->ds_linear.depth = base;
- if (rsrc->layout == PAN_LINEAR) {
+ if (rsrc->layout == MALI_TEXTURE_LINEAR) {
fbx->zs_block = MALI_BLOCK_LINEAR;
fbx->ds_linear.depth_stride = stride / 16;
} else {
diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c
index 6eeb4b832ed..483450af9f8 100644
--- a/src/gallium/drivers/panfrost/pan_resource.c
+++ b/src/gallium/drivers/panfrost/pan_resource.c
@@ -85,6 +85,7 @@ panfrost_resource_from_handle(struct pipe_screen *pscreen,
rsc->bo = panfrost_bo_import(screen, whandle->handle);
rsc->internal_format = templat->format;
+ rsc->layout = MALI_TEXTURE_LINEAR;
rsc->slices[0].stride = whandle->stride;
rsc->slices[0].offset = whandle->offset;
rsc->slices[0].initialized = true;
@@ -277,8 +278,8 @@ panfrost_setup_slices(struct panfrost_resource *pres, size_t *bo_size)
bool renderable = res->bind &
(PIPE_BIND_RENDER_TARGET | PIPE_BIND_DEPTH_STENCIL);
- bool afbc = pres->layout == PAN_AFBC;
- bool tiled = pres->layout == PAN_TILED;
+ bool afbc = pres->layout == MALI_TEXTURE_AFBC;
+ bool tiled = pres->layout == MALI_TEXTURE_TILED;
bool should_align = renderable || tiled;
/* We don't know how to specify a 2D stride for 3D textures */
@@ -319,7 +320,7 @@ panfrost_setup_slices(struct panfrost_resource *pres, size_t *bo_size)
stride /= 4;
/* ..but cache-line align it for performance */
- if (can_align_stride && pres->layout == PAN_LINEAR)
+ if (can_align_stride && pres->layout == MALI_TEXTURE_LINEAR)
stride = ALIGN_POT(stride, 64);
slice->stride = stride;
@@ -420,7 +421,7 @@ panfrost_resource_create_bo(struct panfrost_screen *screen, struct panfrost_reso
/* Set the layout appropriately */
assert(!(must_tile && !can_tile)); /* must_tile => can_tile */
- pres->layout = ((can_tile && should_tile) || must_tile) ? PAN_TILED : PAN_LINEAR;
+ pres->layout = ((can_tile && should_tile) || must_tile) ? MALI_TEXTURE_TILED : MALI_TEXTURE_LINEAR;
size_t bo_size;
@@ -639,7 +640,7 @@ panfrost_transfer_map(struct pipe_context *pctx,
}
}
- if (rsrc->layout != PAN_LINEAR) {
+ if (rsrc->layout != MALI_TEXTURE_LINEAR) {
/* Non-linear resources need to be indirectly mapped */
if (usage & PIPE_TRANSFER_MAP_DIRECTLY)
@@ -651,9 +652,9 @@ panfrost_transfer_map(struct pipe_context *pctx,
assert(box->depth == 1);
if ((usage & PIPE_TRANSFER_READ) && rsrc->slices[level].initialized) {
- if (rsrc->layout == PAN_AFBC) {
+ if (rsrc->layout == MALI_TEXTURE_AFBC) {
DBG("Unimplemented: reads from AFBC");
- } else if (rsrc->layout == PAN_TILED) {
+ } else if (rsrc->layout == MALI_TEXTURE_TILED) {
panfrost_load_tiled_image(
transfer->map,
bo->cpu + rsrc->slices[level].offset,
@@ -700,9 +701,9 @@ panfrost_transfer_unmap(struct pipe_context *pctx,
struct panfrost_bo *bo = prsrc->bo;
if (transfer->usage & PIPE_TRANSFER_WRITE) {
- if (prsrc->layout == PAN_AFBC) {
+ if (prsrc->layout == MALI_TEXTURE_AFBC) {
DBG("Unimplemented: writes to AFBC\n");
- } else if (prsrc->layout == PAN_TILED) {
+ } else if (prsrc->layout == MALI_TEXTURE_TILED) {
assert(transfer->box.depth == 1);
panfrost_store_tiled_image(
@@ -828,7 +829,7 @@ void
panfrost_resource_hint_layout(
struct panfrost_screen *screen,
struct panfrost_resource *rsrc,
- enum panfrost_memory_layout layout,
+ enum mali_texture_layout layout,
signed weight)
{
/* Nothing to do, although a sophisticated implementation might store
@@ -845,7 +846,7 @@ panfrost_resource_hint_layout(
/* Check if the preferred layout is legal for this buffer */
- if (layout == PAN_AFBC) {
+ if (layout == MALI_TEXTURE_AFBC) {
bool can_afbc = panfrost_format_supports_afbc(rsrc->base.format);
bool is_scanout = rsrc->base.bind &
(PIPE_BIND_DISPLAY_TARGET | PIPE_BIND_SCANOUT | PIPE_BIND_SHARED);
diff --git a/src/gallium/drivers/panfrost/pan_resource.h b/src/gallium/drivers/panfrost/pan_resource.h
index 107c08dc628..f3ba339add7 100644
--- a/src/gallium/drivers/panfrost/pan_resource.h
+++ b/src/gallium/drivers/panfrost/pan_resource.h
@@ -32,14 +32,6 @@
#include "drm-uapi/drm.h"
#include "util/u_range.h"
-/* Describes the memory layout of a BO */
-
-enum panfrost_memory_layout {
- PAN_LINEAR,
- PAN_TILED,
- PAN_AFBC
-};
-
struct panfrost_slice {
unsigned offset;
unsigned stride;
@@ -79,7 +71,7 @@ struct panfrost_resource {
unsigned cubemap_stride;
/* Internal layout (tiled?) */
- enum panfrost_memory_layout layout;
+ enum mali_texture_layout layout;
/* Is transaciton elimination enabled? */
bool checksummed;
@@ -117,7 +109,7 @@ void
panfrost_resource_hint_layout(
struct panfrost_screen *screen,
struct panfrost_resource *rsrc,
- enum panfrost_memory_layout layout,
+ enum mali_texture_layout layout,
signed weight);
/* AFBC */
diff --git a/src/gallium/drivers/panfrost/pan_sfbd.c b/src/gallium/drivers/panfrost/pan_sfbd.c
index a4d29adc460..6e80649abf6 100644
--- a/src/gallium/drivers/panfrost/pan_sfbd.c
+++ b/src/gallium/drivers/panfrost/pan_sfbd.c
@@ -141,9 +141,9 @@ panfrost_sfbd_set_cbuf(
fb->framebuffer = base;
fb->stride = stride;
- if (rsrc->layout == PAN_LINEAR)
+ if (rsrc->layout == MALI_TEXTURE_LINEAR)
fb->format.block = MALI_BLOCK_LINEAR;
- else if (rsrc->layout == PAN_TILED) {
+ else if (rsrc->layout == MALI_TEXTURE_TILED) {
fb->format.block = MALI_BLOCK_TILED;
fb->stride *= 16;
} else {
@@ -163,7 +163,7 @@ panfrost_sfbd_set_zsbuf(
unsigned level = surf->u.tex.level;
assert(surf->u.tex.first_layer == 0);
- if (rsrc->layout != PAN_TILED)
+ if (rsrc->layout != MALI_TEXTURE_TILED)
unreachable("Invalid render layout.");
fb->depth_buffer = rsrc->bo->gpu + rsrc->slices[level].offset;