panfrost: Detect implementations support AFBC

AFBC is an optional feature on Bifrost. If it is missing, a bit will be
set in the poorly named AFBC_FEATURES register. Check this so we can act
appropriately.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13497>
(cherry picked from commit 3e168b97cc)
This commit is contained in:
Alyssa Rosenzweig 2021-10-05 16:01:00 -04:00 committed by Dylan Baker
parent af4a05f15c
commit f80f983226
3 changed files with 16 additions and 1 deletions

View file

@ -121,7 +121,7 @@
"description": "panfrost: Detect implementations support AFBC",
"nominated": true,
"nomination_type": 0,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null
},

View file

@ -157,6 +157,7 @@ struct panfrost_device {
unsigned thread_tls_alloc;
struct panfrost_tiler_features tiler_features;
unsigned quirks;
bool has_afbc;
/* Table of formats, indexed by a PIPE format */
const struct panfrost_format *formats;

View file

@ -237,6 +237,19 @@ panfrost_model_name(unsigned gpu_id)
}
}
/* Check for AFBC hardware support. AFBC is introduced in v5. Implementations
* may omit it, signaled as a nonzero value in the AFBC_FEATURES property. */
static bool
panfrost_query_afbc(int fd, unsigned arch)
{
unsigned reg = panfrost_query_raw(fd,
DRM_PANFROST_PARAM_AFBC_FEATURES,
false, 0);
return (arch >= 5) && (reg == 0);
}
void
panfrost_open_device(void *memctx, int fd, struct panfrost_device *dev)
{
@ -251,6 +264,7 @@ panfrost_open_device(void *memctx, int fd, struct panfrost_device *dev)
dev->quirks = panfrost_get_quirks(dev->gpu_id, revision);
dev->compressed_formats = panfrost_query_compressed_formats(fd);
dev->tiler_features = panfrost_query_tiler_features(fd);
dev->has_afbc = panfrost_query_afbc(fd, dev->arch);
if (dev->quirks & HAS_SWIZZLES)
dev->formats = panfrost_pipe_format_v6;