mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-04-23 05:10:36 +02:00
panfrost: Remove AFBC format fixups
It's too complicated and probably for no actual benefit. The main reason we have BGR formats is for display, but that's export and doesn't get hit by this path. Internal BGRA textures are possible with a Mesa extension but sufficiently rare that I regret suggesting this as a possible optimization. My apologies, and thanks for the fish. Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com> Acked-by: Boris Brezillon <boris.brezillon@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11123>
This commit is contained in:
parent
e111464bfc
commit
317dd5b327
6 changed files with 12 additions and 124 deletions
|
|
@ -118,16 +118,6 @@ panfrost_resource_from_handle(struct pipe_screen *pscreen,
|
|||
rsc->state.slices[0].data_valid = true;
|
||||
panfrost_resource_set_damage_region(pscreen, &rsc->base, 0, NULL);
|
||||
|
||||
/* If we import an AFBC resource, it should be in a format that's
|
||||
* supported, otherwise we don't know if the fixup is expected to be
|
||||
* applied or not. In practice that's not a problem if the buffer has
|
||||
* been exported by the GPU because the same constraint applies to both
|
||||
* ends, but we might have issues if the exporter is a different piece
|
||||
* of hardware (VPU?) that supports the BGR variants.
|
||||
*/
|
||||
assert(!drm_is_afbc(whandle->modifier) ||
|
||||
!panfrost_afbc_format_needs_fixup(dev, rsc->image.layout.format));
|
||||
|
||||
if (dev->ro) {
|
||||
rsc->scanout =
|
||||
renderonly_create_gpu_import_for_resource(prsc, dev->ro, NULL);
|
||||
|
|
@ -148,16 +138,6 @@ panfrost_resource_get_handle(struct pipe_screen *pscreen,
|
|||
struct panfrost_resource *rsrc = (struct panfrost_resource *) pt;
|
||||
struct renderonly_scanout *scanout = rsrc->scanout;
|
||||
|
||||
/* If we export an AFBC resource, it should be in a format that's
|
||||
* supported, otherwise the importer has no clue about the format fixup
|
||||
* done internally. In practice that shouldn't be an issue for GPU
|
||||
* buffers because the same constraint applies to both ends, but we
|
||||
* might have issues if the importer is a different piece of hardware
|
||||
* that supports BGR variants.
|
||||
*/
|
||||
assert(!drm_is_afbc(rsrc->image.layout.modifier) ||
|
||||
!panfrost_afbc_format_needs_fixup(dev, rsrc->image.layout.format));
|
||||
|
||||
handle->modifier = rsrc->image.layout.modifier;
|
||||
rsrc->modifier_constant = true;
|
||||
|
||||
|
|
@ -389,14 +369,6 @@ panfrost_should_afbc(struct panfrost_device *dev,
|
|||
if (pres->base.width0 <= 16 && pres->base.height0 <= 16)
|
||||
return false;
|
||||
|
||||
/* AFBC(BGR) is not natively supported on Bifrost v7+. When we don't
|
||||
* share the buffer we can fake those formats since we're in control
|
||||
* of the format/swizzle we apply to the textures/RTs.
|
||||
*/
|
||||
if (panfrost_afbc_format_needs_fixup(dev, fmt) &&
|
||||
(pres->base.bind & (PIPE_BIND_SCANOUT | PIPE_BIND_SHARED)))
|
||||
return false;
|
||||
|
||||
/* Otherwise, we'd prefer AFBC as it is dramatically more efficient
|
||||
* than linear or usually even u-interleaved */
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -567,14 +567,6 @@ panfrost_walk_dmabuf_modifiers(struct pipe_screen *screen,
|
|||
/* Don't advertise AFBC before T760 */
|
||||
afbc &= !(dev->quirks & MIDGARD_NO_AFBC);
|
||||
|
||||
/* On Bifrost, AFBC is not supported if the format has a non-identity
|
||||
* swizzle. For internal resources we fix the format at runtime, but
|
||||
* this fixup is not applicable when we export the resource. Don't
|
||||
* advertise AFBC modifiers on such formats.
|
||||
*/
|
||||
if (panfrost_afbc_format_needs_fixup(dev, format))
|
||||
afbc = false;
|
||||
|
||||
unsigned count = 0;
|
||||
|
||||
for (unsigned i = 0; i < PAN_MODIFIER_COUNT; ++i) {
|
||||
|
|
|
|||
|
|
@ -78,28 +78,24 @@
|
|||
bool
|
||||
panfrost_format_supports_afbc(const struct panfrost_device *dev, enum pipe_format format)
|
||||
{
|
||||
const struct util_format_description *desc =
|
||||
util_format_description(format);
|
||||
|
||||
/* sRGB cannot be AFBC, but it can be tiled. TODO: Verify. The blob
|
||||
* does not do AFBC for SRGB8_ALPHA8, but it's not clear why it
|
||||
* shouldn't be able to. */
|
||||
|
||||
if (desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB)
|
||||
return false;
|
||||
|
||||
if (util_format_is_rgba8_variant(desc))
|
||||
return true;
|
||||
|
||||
switch (format) {
|
||||
case PIPE_FORMAT_R8G8B8A8_UNORM:
|
||||
case PIPE_FORMAT_R8G8B8X8_UNORM:
|
||||
case PIPE_FORMAT_R8G8B8_UNORM:
|
||||
case PIPE_FORMAT_B8G8R8_UNORM:
|
||||
case PIPE_FORMAT_R5G6B5_UNORM:
|
||||
case PIPE_FORMAT_B5G6R5_UNORM:
|
||||
case PIPE_FORMAT_Z24_UNORM_S8_UINT:
|
||||
case PIPE_FORMAT_Z24X8_UNORM:
|
||||
case PIPE_FORMAT_Z16_UNORM:
|
||||
return true;
|
||||
case PIPE_FORMAT_B8G8R8A8_UNORM:
|
||||
case PIPE_FORMAT_B8G8R8X8_UNORM:
|
||||
case PIPE_FORMAT_A8R8G8B8_UNORM:
|
||||
case PIPE_FORMAT_X8R8G8B8_UNORM:
|
||||
case PIPE_FORMAT_X8B8G8R8_UNORM:
|
||||
case PIPE_FORMAT_A8B8G8R8_UNORM:
|
||||
case PIPE_FORMAT_B8G8R8_UNORM:
|
||||
case PIPE_FORMAT_B5G6R5_UNORM:
|
||||
return (dev->arch < 7);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
|
@ -140,59 +136,3 @@ panfrost_afbc_can_ytr(enum pipe_format format)
|
|||
/* The fourth channel if it exists doesn't matter */
|
||||
return desc->colorspace == UTIL_FORMAT_COLORSPACE_RGB;
|
||||
}
|
||||
|
||||
bool
|
||||
panfrost_afbc_format_needs_fixup(const struct panfrost_device *dev,
|
||||
enum pipe_format format)
|
||||
{
|
||||
if (dev->arch < 7)
|
||||
return false;
|
||||
|
||||
const struct util_format_description *desc =
|
||||
util_format_description(format);
|
||||
|
||||
unsigned nr_channels = desc->nr_channels;
|
||||
|
||||
/* rgb1 is a valid component order, don't test channel 3 in that
|
||||
* case.
|
||||
*/
|
||||
if (nr_channels == 4 && desc->swizzle[3] == PIPE_SWIZZLE_1)
|
||||
nr_channels = 3;
|
||||
|
||||
bool identity_swizzle = true;
|
||||
for (unsigned c = 0; c < nr_channels; c++) {
|
||||
if (desc->swizzle[c] != c) {
|
||||
identity_swizzle = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (identity_swizzle ||
|
||||
desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
enum pipe_format
|
||||
panfrost_afbc_format_fixup(const struct panfrost_device *dev,
|
||||
enum pipe_format format)
|
||||
{
|
||||
if (!panfrost_afbc_format_needs_fixup(dev, format))
|
||||
return format;
|
||||
|
||||
const struct util_format_description *desc =
|
||||
util_format_description(format);
|
||||
|
||||
switch (format) {
|
||||
case PIPE_FORMAT_B8G8R8_UNORM:
|
||||
return PIPE_FORMAT_R8G8B8_UNORM;
|
||||
case PIPE_FORMAT_B5G6R5_UNORM:
|
||||
return PIPE_FORMAT_R5G6B5_UNORM;
|
||||
default:
|
||||
if (util_format_is_rgba8_variant(desc))
|
||||
return PIPE_FORMAT_R8G8B8A8_UNORM;
|
||||
|
||||
unreachable("Invalid format");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -390,15 +390,10 @@ pan_rt_init_format(const struct panfrost_device *dev,
|
|||
const struct pan_image_view *rt,
|
||||
struct MALI_RENDER_TARGET *cfg)
|
||||
{
|
||||
enum pipe_format format =
|
||||
drm_is_afbc(rt->image->layout.modifier) ?
|
||||
panfrost_afbc_format_fixup(dev, rt->format) :
|
||||
rt->format;
|
||||
|
||||
/* Explode details on the format */
|
||||
|
||||
const struct util_format_description *desc =
|
||||
util_format_description(format);
|
||||
util_format_description(rt->format);
|
||||
|
||||
/* The swizzle for rendering is inverted from texturing */
|
||||
|
||||
|
|
|
|||
|
|
@ -413,9 +413,6 @@ panfrost_new_texture(const struct panfrost_device *dev,
|
|||
enum pipe_format format = iview->format;
|
||||
unsigned swizzle;
|
||||
|
||||
if (drm_is_afbc(layout->modifier))
|
||||
format = panfrost_afbc_format_fixup(dev, format);
|
||||
|
||||
if (dev->arch == 7 && util_format_is_depth_or_stencil(format)) {
|
||||
/* v7 doesn't have an _RRRR component order, combine the
|
||||
* user swizzle with a .XXXX swizzle to emulate that.
|
||||
|
|
|
|||
|
|
@ -164,14 +164,6 @@ panfrost_afbc_header_size(unsigned width, unsigned height);
|
|||
bool
|
||||
panfrost_afbc_can_ytr(enum pipe_format format);
|
||||
|
||||
bool
|
||||
panfrost_afbc_format_needs_fixup(const struct panfrost_device *dev,
|
||||
enum pipe_format format);
|
||||
|
||||
enum pipe_format
|
||||
panfrost_afbc_format_fixup(const struct panfrost_device *dev,
|
||||
enum pipe_format format);
|
||||
|
||||
unsigned
|
||||
panfrost_block_dim(uint64_t modifier, bool width, unsigned plane);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue