From 1617778c3898499d44b41057d30eb8d7b8616f37 Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Wed, 28 May 2025 15:23:48 +0200 Subject: [PATCH] lima: make fp16 render-targets opt-in with driconf Lima can't do *both* FP16 *and* 4x MSAA at the same time. And because GLES2 requires MAX_SAMPLES to be valid for *all* supported formats, this means we can't support MSAA at all unless we disable support for the FP16 formats when used as render-targets. To allow applications that needs FP16 render-targets to still support it, we introduce a driconf that makes the opposite trade; support FP16, but not 4x MSAA. Unfortunately, we can't support both, and still be following the spec. Reviewed-by: Erico Nunes Part-of: --- docs/drivers/lima.rst | 8 ++++++++ src/gallium/drivers/lima/ci/lima-fails.txt | 1 - src/gallium/drivers/lima/driinfo_lima.h | 3 +++ src/gallium/drivers/lima/lima_screen.c | 14 +++++++++++--- src/gallium/drivers/lima/lima_screen.h | 1 + 5 files changed, 23 insertions(+), 4 deletions(-) diff --git a/docs/drivers/lima.rst b/docs/drivers/lima.rst index dde1155e20d..b4e5a8f7e7f 100644 --- a/docs/drivers/lima.rst +++ b/docs/drivers/lima.rst @@ -57,6 +57,14 @@ These are some display drivers that have been tested with Lima: - Tiny DRM: ``tinydrm`` - Xilinx ZynqMP: ``zynqmp-dpsub`` +DRIconf variables +----------------- + +``lima_allow_fp16_rts`` + Expose support for FP16 render-targets. This has the side-effect of + dropping support for 4xMSAA, which unfortunately can't be supported + at the same time due to API and hardware restrictions. + Environment variables --------------------- diff --git a/src/gallium/drivers/lima/ci/lima-fails.txt b/src/gallium/drivers/lima/ci/lima-fails.txt index d096a8ed15a..7844dca9b4d 100644 --- a/src/gallium/drivers/lima/ci/lima-fails.txt +++ b/src/gallium/drivers/lima/ci/lima-fails.txt @@ -44,7 +44,6 @@ dEQP-GLES2.functional.texture.mipmap.cube.projected.linear_nearest,Fail wayland-dEQP-EGL.functional.create_context.no_config,Fail wayland-dEQP-EGL.functional.image.modify.renderbuffer_depth16_renderbuffer_clear_depth,Fail -wayland-dEQP-EGL.functional.wide_color.window_fp16_default_colorspace,Fail wayland-dEQP-EGL.functional.wide_color.window_8888_colorspace_srgb,Fail wayland-dEQP-EGL.functional.wide_color.window_888_colorspace_srgb,Fail diff --git a/src/gallium/drivers/lima/driinfo_lima.h b/src/gallium/drivers/lima/driinfo_lima.h index 07e69ec3da9..b4480576866 100644 --- a/src/gallium/drivers/lima/driinfo_lima.h +++ b/src/gallium/drivers/lima/driinfo_lima.h @@ -1 +1,4 @@ /* lima specific driconf options */ +DRI_CONF_SECTION_MISCELLANEOUS + DRI_CONF_OPT_B(lima_allow_fp16_rts, false, "Allow using FP16 render-targets") +DRI_CONF_SECTION_END diff --git a/src/gallium/drivers/lima/lima_screen.c b/src/gallium/drivers/lima/lima_screen.c index 8657c18448c..d47fe51fe53 100644 --- a/src/gallium/drivers/lima/lima_screen.c +++ b/src/gallium/drivers/lima/lima_screen.c @@ -246,9 +246,14 @@ lima_screen_is_format_supported(struct pipe_screen *pscreen, if (!lima_format_pixel_supported(format)) return false; - /* multisample unsupported with half float target */ - if (sample_count > 1 && util_format_is_float(format)) - return false; + if (util_format_is_float(format)) { + if (!lima_screen(pscreen)->allow_fp16_rts) + return false; + + /* multisample unsupported with half float target */ + if (sample_count > 1) + return false; + } } if (usage & PIPE_BIND_DEPTH_STENCIL) { @@ -589,6 +594,9 @@ lima_screen_create(int fd, const struct pipe_screen_config *config, driParseConfigFiles(config->options, config->options_info, 0, "lima", NULL, NULL, NULL, 0, NULL, 0); + screen->allow_fp16_rts = driQueryOptionb(config->options, + "lima_allow_fp16_rts"); + if (!lima_screen_query_info(screen)) goto err_out0; diff --git a/src/gallium/drivers/lima/lima_screen.h b/src/gallium/drivers/lima/lima_screen.h index 5f76edd551a..76dedb99879 100644 --- a/src/gallium/drivers/lima/lima_screen.h +++ b/src/gallium/drivers/lima/lima_screen.h @@ -95,6 +95,7 @@ struct lima_screen { #define pp_buffer_size 0x1000 bool has_growable_heap_buffer; + bool allow_fp16_rts; struct disk_cache *disk_cache; };