mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-22 17:50:12 +01:00
panfrost: Choose AFBC when available
There are lots of reasons we might fallback on u-interleaved tiling, but when we can use AFBC, it's a big win. Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Tested-by: Icecream95 <ixn@keemail.me> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6159>
This commit is contained in:
parent
c54d45dd90
commit
acb8dcfebd
2 changed files with 68 additions and 6 deletions
|
|
@ -382,7 +382,9 @@ panfrost_setup_slices(struct panfrost_resource *pres, size_t *bo_size)
|
||||||
* that the contents frequently change, tiling will be a loss.
|
* that the contents frequently change, tiling will be a loss.
|
||||||
*
|
*
|
||||||
* Due to incomplete information on some platforms, we may need to force tiling
|
* Due to incomplete information on some platforms, we may need to force tiling
|
||||||
* in some cases */
|
* in some cases.
|
||||||
|
*
|
||||||
|
* On platforms where it is supported, AFBC is even better. */
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
panfrost_can_linear(struct panfrost_device *dev, const struct panfrost_resource *pres)
|
panfrost_can_linear(struct panfrost_device *dev, const struct panfrost_resource *pres)
|
||||||
|
|
@ -392,6 +394,53 @@ panfrost_can_linear(struct panfrost_device *dev, const struct panfrost_resource
|
||||||
(dev->quirks & (MIDGARD_SFBD | IS_BIFROST)));
|
(dev->quirks & (MIDGARD_SFBD | IS_BIFROST)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
panfrost_should_afbc(struct panfrost_device *dev, const struct panfrost_resource *pres)
|
||||||
|
{
|
||||||
|
/* AFBC resources may be rendered to, textured from, or shared across
|
||||||
|
* processes, but may not be used as e.g buffers */
|
||||||
|
const unsigned valid_binding =
|
||||||
|
PIPE_BIND_DEPTH_STENCIL |
|
||||||
|
PIPE_BIND_RENDER_TARGET |
|
||||||
|
PIPE_BIND_BLENDABLE |
|
||||||
|
PIPE_BIND_SAMPLER_VIEW |
|
||||||
|
PIPE_BIND_DISPLAY_TARGET |
|
||||||
|
PIPE_BIND_SCANOUT |
|
||||||
|
PIPE_BIND_SHARED;
|
||||||
|
|
||||||
|
if (pres->base.bind & ~valid_binding)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
/* AFBC introduced with Mali T760 */
|
||||||
|
if (dev->quirks & MIDGARD_NO_AFBC)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
/* AFBC<-->staging is expensive */
|
||||||
|
if (pres->base.usage == PIPE_USAGE_STREAM)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
/* Only a small selection of formats are AFBC'able */
|
||||||
|
if (!panfrost_format_supports_afbc(pres->internal_format))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
/* AFBC does not support layered (GLES3 style) multisampling. Use
|
||||||
|
* EXT_multisampled_render_to_texture instead */
|
||||||
|
if (pres->base.nr_samples > 1)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
/* TODO: Is AFBC of 3D textures possible? */
|
||||||
|
if ((pres->base.target != PIPE_TEXTURE_2D) && (pres->base.target != PIPE_TEXTURE_RECT))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
/* For one tile, AFBC is a loss compared to u-interleaved */
|
||||||
|
if (pres->base.width0 <= 16 && pres->base.height0 <= 16)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
/* Otherwise, we'd prefer AFBC as it is dramatically more efficient
|
||||||
|
* than linear or usually even u-interleaved */
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
panfrost_should_tile(struct panfrost_device *dev, const struct panfrost_resource *pres)
|
panfrost_should_tile(struct panfrost_device *dev, const struct panfrost_resource *pres)
|
||||||
{
|
{
|
||||||
|
|
@ -400,7 +449,9 @@ panfrost_should_tile(struct panfrost_device *dev, const struct panfrost_resource
|
||||||
PIPE_BIND_RENDER_TARGET |
|
PIPE_BIND_RENDER_TARGET |
|
||||||
PIPE_BIND_BLENDABLE |
|
PIPE_BIND_BLENDABLE |
|
||||||
PIPE_BIND_SAMPLER_VIEW |
|
PIPE_BIND_SAMPLER_VIEW |
|
||||||
PIPE_BIND_DISPLAY_TARGET;
|
PIPE_BIND_DISPLAY_TARGET |
|
||||||
|
PIPE_BIND_SCANOUT |
|
||||||
|
PIPE_BIND_SHARED;
|
||||||
|
|
||||||
unsigned bpp = util_format_get_blocksizebits(pres->internal_format);
|
unsigned bpp = util_format_get_blocksizebits(pres->internal_format);
|
||||||
|
|
||||||
|
|
@ -425,7 +476,13 @@ static uint64_t
|
||||||
panfrost_best_modifier(struct panfrost_device *dev,
|
panfrost_best_modifier(struct panfrost_device *dev,
|
||||||
const struct panfrost_resource *pres)
|
const struct panfrost_resource *pres)
|
||||||
{
|
{
|
||||||
if (panfrost_should_tile(dev, pres))
|
if (panfrost_should_afbc(dev, pres)) {
|
||||||
|
uint64_t afbc =
|
||||||
|
AFBC_FORMAT_MOD_BLOCK_SIZE_16x16 |
|
||||||
|
AFBC_FORMAT_MOD_SPARSE;
|
||||||
|
|
||||||
|
return DRM_FORMAT_MOD_ARM_AFBC(afbc);
|
||||||
|
} else if (panfrost_should_tile(dev, pres))
|
||||||
return DRM_FORMAT_MOD_ARM_16X16_BLOCK_U_INTERLEAVED;
|
return DRM_FORMAT_MOD_ARM_16X16_BLOCK_U_INTERLEAVED;
|
||||||
else
|
else
|
||||||
return DRM_FORMAT_MOD_LINEAR;
|
return DRM_FORMAT_MOD_LINEAR;
|
||||||
|
|
|
||||||
|
|
@ -68,13 +68,17 @@
|
||||||
/* Has some missing formats for typed loads */
|
/* Has some missing formats for typed loads */
|
||||||
#define MIDGARD_MISSING_LOADS (1 << 9)
|
#define MIDGARD_MISSING_LOADS (1 << 9)
|
||||||
|
|
||||||
|
/* Lack support for AFBC */
|
||||||
|
#define MIDGARD_NO_AFBC (1 << 10)
|
||||||
|
|
||||||
/* Quirk collections common to particular uarchs */
|
/* Quirk collections common to particular uarchs */
|
||||||
|
|
||||||
#define MIDGARD_QUIRKS (MIDGARD_BROKEN_FP16 | HAS_SWIZZLES \
|
#define MIDGARD_QUIRKS (MIDGARD_BROKEN_FP16 | HAS_SWIZZLES \
|
||||||
| MIDGARD_NO_TYPED_BLEND_STORES \
|
| MIDGARD_NO_TYPED_BLEND_STORES \
|
||||||
| MIDGARD_MISSING_LOADS)
|
| MIDGARD_MISSING_LOADS)
|
||||||
|
|
||||||
#define BIFROST_QUIRKS (IS_BIFROST | NO_BLEND_PACKS)
|
/* TODO: AFBC on Bifrost */
|
||||||
|
#define BIFROST_QUIRKS (IS_BIFROST | NO_BLEND_PACKS | MIDGARD_NO_AFBC)
|
||||||
|
|
||||||
static inline unsigned
|
static inline unsigned
|
||||||
panfrost_get_quirks(unsigned gpu_id)
|
panfrost_get_quirks(unsigned gpu_id)
|
||||||
|
|
@ -84,10 +88,11 @@ panfrost_get_quirks(unsigned gpu_id)
|
||||||
case 0x620:
|
case 0x620:
|
||||||
return MIDGARD_QUIRKS | MIDGARD_SFBD
|
return MIDGARD_QUIRKS | MIDGARD_SFBD
|
||||||
| MIDGARD_NO_TYPED_BLEND_LOADS
|
| MIDGARD_NO_TYPED_BLEND_LOADS
|
||||||
| NO_BLEND_PACKS;
|
| NO_BLEND_PACKS | MIDGARD_NO_AFBC;
|
||||||
|
|
||||||
case 0x720:
|
case 0x720:
|
||||||
return MIDGARD_QUIRKS | MIDGARD_SFBD | MIDGARD_NO_HIER_TILING;
|
return MIDGARD_QUIRKS | MIDGARD_SFBD | MIDGARD_NO_HIER_TILING
|
||||||
|
| MIDGARD_NO_AFBC;
|
||||||
|
|
||||||
case 0x820:
|
case 0x820:
|
||||||
case 0x830:
|
case 0x830:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue