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 <alyssa@rosenzweig.io>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Eric R. Smith <eric.smith@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36606>
This commit is contained in:
Erik Faye-Lund 2025-08-06 14:07:14 +02:00 committed by Marge Bot
parent 0dcf510c05
commit fed682c506
4 changed files with 21 additions and 17 deletions

View file

@ -122,4 +122,11 @@
<value name="I16" value="4"/>
<value name="U16" value="5"/>
</enum>
<!-- v6+ -->
<enum name="Pixel Kill">
<value name="Force Early" value="0"/>
<value name="Weak Early" value="2"/>
<value name="Force Late" value="3"/>
</enum>
</panxml>

View file

@ -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,
};

View file

@ -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;

View file

@ -23,6 +23,7 @@
#include "util/pan_ir.h"
#include "pan_earlyzs.h"
#include "genxml/gen_macros.h"
#include <gtest/gtest.h>
@ -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)