From fed682c50666a1aa215be31dd93e85ca08db94d4 Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Wed, 6 Aug 2025 14:07:14 +0200 Subject: [PATCH] pan/lib: do not duplicate enum mali_pixel_kill The enum pan_earlyzs is just enum mali_pixel_kill under a different name, which was needed because the enum was missing from common.xml. However, because pan_earlyzs_lut is used in files that are both included with PAN_ARCH unset and set to values including values lower than 6, we get issues with the way genxml/common_pack.h gets included, resulting in the enum not being defined. We don't really depend on the values for this, only on the size. So let's just use unsigned values in the struct instead, to side-step the issue. Reviewed-by: Alyssa Rosenzweig Tested-by: Yiwei Zhang Reviewed-by: Eric R. Smith Part-of: --- src/panfrost/genxml/common.xml | 7 +++++++ src/panfrost/lib/pan_earlyzs.c | 13 ++++++++----- src/panfrost/lib/pan_earlyzs.h | 11 ++--------- src/panfrost/lib/tests/test-earlyzs.cpp | 7 ++++--- 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/panfrost/genxml/common.xml b/src/panfrost/genxml/common.xml index 11bd5fc22c1..ce74baa49d0 100644 --- a/src/panfrost/genxml/common.xml +++ b/src/panfrost/genxml/common.xml @@ -122,4 +122,11 @@ + + + + + + + diff --git a/src/panfrost/lib/pan_earlyzs.c b/src/panfrost/lib/pan_earlyzs.c index 6647409c2c3..6a5c467d216 100644 --- a/src/panfrost/lib/pan_earlyzs.c +++ b/src/panfrost/lib/pan_earlyzs.c @@ -21,21 +21,24 @@ * SOFTWARE. */ +#include "genxml/gen_macros.h" + #include "pan_earlyzs.h" #include "panfrost/util/pan_ir.h" + /* * Return an "early" mode. If it is known that the depth/stencil tests always * pass (so the shader is always executed), weak early is usually faster than * force early. */ -static enum pan_earlyzs +static enum mali_pixel_kill best_early_mode(bool zs_always_passes, bool force_early) { if (zs_always_passes && !force_early) - return PAN_EARLYZS_WEAK_EARLY; + return MALI_PIXEL_KILL_WEAK_EARLY; else - return PAN_EARLYZS_FORCE_EARLY; + return MALI_PIXEL_KILL_FORCE_EARLY; } /* @@ -121,9 +124,9 @@ analyze(const struct pan_shader_info *s, bool writes_zs_or_oq, /* Collect results */ return (struct pan_earlyzs_state){ .update = late_update - ? PAN_EARLYZS_FORCE_LATE + ? MALI_PIXEL_KILL_FORCE_LATE : best_early_mode(zs_always_passes, force_early_update), - .kill = late_kill ? PAN_EARLYZS_FORCE_LATE + .kill = late_kill ? MALI_PIXEL_KILL_FORCE_LATE : best_early_mode(zs_always_passes, force_early_kill), .shader_readonly_zs = optimize_shader_read_only_zs, }; diff --git a/src/panfrost/lib/pan_earlyzs.h b/src/panfrost/lib/pan_earlyzs.h index c4446bbdfde..3e2649da04b 100644 --- a/src/panfrost/lib/pan_earlyzs.h +++ b/src/panfrost/lib/pan_earlyzs.h @@ -30,20 +30,13 @@ extern "C" { #endif -/* Matches hardware Pixel Kill enum on Bifrost and Valhall */ -enum pan_earlyzs { - PAN_EARLYZS_FORCE_EARLY = 0, - PAN_EARLYZS_WEAK_EARLY = 2, - PAN_EARLYZS_FORCE_LATE = 3 -}; - /* Early-ZS pair. */ struct pan_earlyzs_state { /* Z/S test and update */ - enum pan_earlyzs update : 2; + unsigned update : 2; /* Pixel kill */ - enum pan_earlyzs kill : 2; + unsigned kill : 2; /* True if the shader read-only ZS optimization should be enabled */ bool shader_readonly_zs : 1; diff --git a/src/panfrost/lib/tests/test-earlyzs.cpp b/src/panfrost/lib/tests/test-earlyzs.cpp index 703dbc8ae8b..55b667b4696 100644 --- a/src/panfrost/lib/tests/test-earlyzs.cpp +++ b/src/panfrost/lib/tests/test-earlyzs.cpp @@ -23,6 +23,7 @@ #include "util/pan_ir.h" #include "pan_earlyzs.h" +#include "genxml/gen_macros.h" #include @@ -48,7 +49,7 @@ #define ARCH_HAS_STATE_TRACK_OPT BITFIELD_BIT(11) static void -test(enum pan_earlyzs expected_update, enum pan_earlyzs expected_kill, +test(enum mali_pixel_kill expected_update, enum mali_pixel_kill expected_kill, bool expected_shader_readonly_zs, uint32_t flags) { enum pan_earlyzs_zs_tilebuf_read zs_read = PAN_EARLYZS_ZS_TILEBUF_NOT_READ; @@ -84,11 +85,11 @@ test(enum pan_earlyzs expected_update, enum pan_earlyzs expected_kill, } #define CASE(expected_update, expected_kill, flags) \ - test(PAN_EARLYZS_##expected_update, PAN_EARLYZS_##expected_kill, false, \ + test(MALI_PIXEL_KILL_##expected_update, MALI_PIXEL_KILL_##expected_kill, false, \ flags) #define CASE_RO_ZS(expected_update, expected_kill, expected_ro_zs, flags) \ - test(PAN_EARLYZS_##expected_update, PAN_EARLYZS_##expected_kill, \ + test(MALI_PIXEL_KILL_##expected_update, MALI_PIXEL_KILL_##expected_kill, \ expected_ro_zs, flags) TEST(EarlyZS, APIForceEarly)