panfrost: Add tool to print supported texture formats
While all Panfrost-supported Mali GPUs support all the compressed texture formats architecturally, the system integrator decides which formats will actually be wired up in the production system-on-chip. In the past there may have been legal considerations, I'm neither a lawyer nor a system integrator so couldn't say. It's useful for users to know which compressed texture formats are supported by their hardware, to understand its performance characteristics (and perhaps to buy systems that support their needs, especially if they need BCn formats which are omitted in many Mali implementations). To help with that, this commit adds a small standalone tool that prints which formats are supported. It is tested so far on Mali-T860 and Mali-G57. Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com> Tested-by: Chris Healy <healych@amazon.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20086>
This commit is contained in:
parent
dafbdd8a35
commit
a861501632
3 changed files with 121 additions and 0 deletions
|
|
@ -57,6 +57,24 @@ Panfrost developers and users hang out on IRC at ``#panfrost`` on OFTC. Note
|
|||
that registering and authenticating with ``NickServ`` is required to prevent
|
||||
spam. `Join the chat. <https://webchat.oftc.net/?channels=panfrost>`_
|
||||
|
||||
Compressed texture support
|
||||
--------------------------
|
||||
|
||||
In the driver, Panfrost supports ASTC, ETC, and all BCn formats (e.g. RGTC,
|
||||
S3TC, etc.) However, Panfrost depends on the hardware to support these formats
|
||||
efficiently. All supported Mali architectures support these formats, but not
|
||||
every system-on-chip with a Mali GPU support all these formats. Many lower-end
|
||||
systems lack support for some BCn formats, which can cause problems when playing
|
||||
desktop games with Panfrost. To check whether this issue applies to your
|
||||
system-on-chip, Panfrost includes a ``panfrost_texfeatures`` tool to query
|
||||
supported formats.
|
||||
|
||||
To use this tool, include the option ``-Dtools=panfrost`` when configuring Mesa.
|
||||
Then inside your Mesa build directory, the tool is located at
|
||||
``src/panfrost/tools/panfrost_texfeatures``. Copy it to your target device,
|
||||
set as executable as necessary, and run on the target device. A table of
|
||||
supported formats will be printed to standard output.
|
||||
|
||||
drm-shim
|
||||
--------
|
||||
|
||||
|
|
|
|||
|
|
@ -28,3 +28,14 @@ coredumpdec = executable(
|
|||
build_by_default : true,
|
||||
install: true
|
||||
)
|
||||
|
||||
panfrost_texfeatures = executable(
|
||||
'panfrost_texfeatures',
|
||||
files('panfrost_texfeatures.c'),
|
||||
c_args : [c_msvc_compat_args, no_override_init_args, compile_args_panfrost],
|
||||
gnu_symbol_visibility : 'hidden',
|
||||
include_directories : [inc_include, inc_src, inc_mesa],
|
||||
dependencies: [libpanfrost_dep],
|
||||
build_by_default : true,
|
||||
install: true
|
||||
)
|
||||
|
|
|
|||
92
src/panfrost/tools/panfrost_texfeatures.c
Normal file
92
src/panfrost/tools/panfrost_texfeatures.c
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
* Copyright 2022 Collabora, Ltd.
|
||||
* Copyright 2022 Amazon.com, Inc. or its affiliates.
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <lib/pan_device.h>
|
||||
|
||||
/*
|
||||
* Mapping of texture feature bits to compressed formats on Mali-G57, other
|
||||
* Malis should be similar.
|
||||
*/
|
||||
struct format {
|
||||
unsigned bit;
|
||||
const char *name;
|
||||
};
|
||||
|
||||
#define FMT(bit, name) { bit, name ":" }
|
||||
|
||||
static struct format formats[] = {
|
||||
FMT( 1, "ETC2"),
|
||||
FMT( 3, "ETC2 EAC"),
|
||||
FMT(19, "ETC2 PTA"),
|
||||
FMT( 2, "EAC 1"),
|
||||
FMT( 4, "EAC 2"),
|
||||
FMT(17, "EAC snorm 1"),
|
||||
FMT(18, "EAC snorm 2"),
|
||||
{ 0, NULL },
|
||||
FMT(20, "ASTC 3D LDR"),
|
||||
FMT(21, "ASTC 3D HDR"),
|
||||
FMT(22, "ASTC 2D LDR"),
|
||||
FMT(23, "ASTC 3D HDR"),
|
||||
{ 0, NULL },
|
||||
FMT( 7, "BC1"),
|
||||
FMT( 8, "BC2"),
|
||||
FMT( 9, "BC3"),
|
||||
FMT(10, "BC4 unorm"),
|
||||
FMT(11, "BC4 snorm"),
|
||||
FMT(12, "BC5 unorm"),
|
||||
FMT(13, "BC5 snorm"),
|
||||
FMT(14, "BC6H UF16"),
|
||||
FMT(15, "BC6H SF16"),
|
||||
FMT(16, "BC7"),
|
||||
};
|
||||
|
||||
/* ANSI escape code */
|
||||
#define RESET "\033[0m"
|
||||
#define RED(x) "\033[31m" x RESET
|
||||
#define GREEN(x) "\033[32m" x RESET
|
||||
|
||||
int main(void) {
|
||||
int fd = drmOpenWithType("panfrost", NULL, DRM_NODE_RENDER);
|
||||
if (fd < 0) {
|
||||
fprintf(stderr, "No panfrost device\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void *ctx = ralloc_context(NULL);
|
||||
struct panfrost_device dev = { 0 };
|
||||
panfrost_open_device(ctx, fd, &dev);
|
||||
|
||||
uint32_t supported = dev.compressed_formats;
|
||||
bool all_ok = true;
|
||||
|
||||
printf("System-on-chip compressed texture support:" "\n\n");
|
||||
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(formats); ++i) {
|
||||
if (formats[i].name == NULL) {
|
||||
printf("\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Maximum length for justification */
|
||||
assert(strlen(formats[i].name) <= 12);
|
||||
|
||||
bool ok = (supported & BITFIELD_BIT(formats[i].bit));
|
||||
all_ok &= ok;
|
||||
|
||||
printf("%-14s %s\n", formats[i].name,
|
||||
ok ? GREEN("YES") : RED(" NO"));
|
||||
}
|
||||
|
||||
if (!all_ok) {
|
||||
printf("\n"
|
||||
"This system-on-chip lacks support for some formats. This is not a driver bug.\n"
|
||||
"Unsupported formats will be emulated at a performance and memory cost.\n");
|
||||
}
|
||||
|
||||
panfrost_close_device(&dev);
|
||||
ralloc_free(ctx);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue