eden-miror/src
xbzk 73918d23d5
[video_core, maxwell] fixes for homebrew games that use MESA compiler (#4012)
two main issues:

shader_environment.cpp

Support Mesa nv50_ir-compiled homebrew fragment shaders
Mesa nv50_ir (used by NZP-Switch via libdrm_nouveau) emits Maxwell SASS that differs from NVN in two ways our shader pipeline didn't account for, causing "infinite" loops during shader scanning.

How?  TryFindSize() previously detected end-of-shader only via NVN's "BRA $-1" self-branch trailer (SELF_BRANCH_A/B). Mesa-compiled shaders end with an unconditional @PT EXIT and emit no trailer, so scanning ran past the shader and looped to MAXIMUM_SIZE.

Fix: Added a secondary match against @PT EXIT T (opcode 0xE30, predicate PT, flow T) as a fallback terminator. The mask is estrictive enough to reject predicated EXITs, conditional-flow EXITs, and sched control words, so well-formed NVN shaders see no ehavior change (their single @PT EXIT immediately precedes BRA $-1, and both detections return the same size).

load_store_attribute.cpp + attribute.h

IPA's is_perspective check only applied the ×position_w correction for IR::IsGeneric() attributes, and used a per-component SPH lookup. Two failure modes followed:

1. Mesa fragment shaders read varyings via legacy attribute slots
(ColorFrontDiffuse, FixedFncTexture, FogCoordinate) which are
remapped to generic varyings later by ConvertLegacyToGeneric. At
IPA-translation time they're still legacy, so IsGeneric() was
false and the inject was skipped — but the resulting GLSL/SPIR-V
varying was Smooth (perspective-correct), and the SASS still
issued its manual perspective dance via MUFU.RCP(ATTR_W)+FMUL,
compounding an extra ×clip_w factor. NZP fog (eye_z distance
varying) ended up as eye_z⁴×density² instead of eye_z²×density²,
saturating fog to white everywhere.

2. Even for legacy attrs that should inject, Mesa stores them in two formats selected by the IPA's interpolation_mode field:
Pass/Multiply/Constant → attr/w (perspective); inject ×position_w
Sc (ScreenLinear)      → raw attr; do NOT inject
Unconditionally injecting for Sc dims vertex colors by 1/clip_w because there's no SASS multiplier to round-trip it back.

Fix: extend the IPA correction path to also fire on IsLegacyAttribute(), gated on interpolation_mode != Sc. While here, the generic-path check is widened from per-component to vector-level (first non-Unused PixelImap, with all-Unused fallthrough treated as Perspective) so it matches the GLSL interpolation qualifier picked by CollectInterpolationInfo — this fixes the same all-zeroed-imap case Mesa exposes for explicit generics. IsLegacyAttribute moved from translate_program.cpp's anonymous namespace into attribute.h next to IsGeneric so IPA can reach it.

Tested on NaziZombies:Portable (Switch homebrew): fog now matches real
hardware, vertex-colored geometry (hand, gun, decals) renders correctly.

Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4012
Reviewed-by: Lizzie <lizzie@eden-emu.dev>
Reviewed-by: MaranBr <maranbr@eden-emu.dev>
2026-06-15 03:05:11 +02:00
..
android [hle] support passing arguments to homebrew applications (#4013) 2026-06-15 03:02:33 +02:00
audio_core [audio_core] fix OOB copy when silencing channel on shutdown (#3969) 2026-05-31 02:38:26 +02:00
common [hle] support passing arguments to homebrew applications (#4013) 2026-06-15 03:02:33 +02:00
core [video_core, maxwell] fixes for homebrew games that use MESA compiler (#4012) 2026-06-15 03:05:11 +02:00
dedicated_room [desktop] More qt_common reorganization (#3916) 2026-05-20 04:49:16 +02:00
dynarmic [dynarmic, loongarch64] Add minimal toy implementation enough to execute LSLS (#4054) 2026-06-05 02:32:06 +02:00
frontend_common [qt] fix various crashes due to invalid/corrupted/outdated settings (#4070) 2026-06-14 20:48:24 +02:00
hid_core [hid_core] fix bounds-check aruid index in GetControllerFromNpadIdType (#4064) 2026-06-05 19:26:21 +02:00
input_common [qt] fix various crashes due to invalid/corrupted/outdated settings (#4070) 2026-06-14 20:48:24 +02:00
network [common] unify std::random_device (#3801) 2026-03-31 20:12:41 +02:00
qt_common [hle] support passing arguments to homebrew applications (#4013) 2026-06-15 03:02:33 +02:00
shader_recompiler [video_core, maxwell] fixes for homebrew games that use MESA compiler (#4012) 2026-06-15 03:05:11 +02:00
tests [cmake] fixes for XCode when having languages other than C/C++ (#3772) 2026-03-26 04:46:43 +01:00
video_core [video_core, maxwell] fixes for homebrew games that use MESA compiler (#4012) 2026-06-15 03:05:11 +02:00
web_service [cmake, deps] conjure common/httplib.h and remove global def for httplib macros (#3800) 2026-04-06 19:13:09 +02:00
yuzu [qt] fix various crashes due to invalid/corrupted/outdated settings (#4070) 2026-06-14 20:48:24 +02:00
yuzu_cmd [externals] Update to SDL3 (#3952) 2026-05-18 19:07:41 +02:00
yuzu_room_standalone [cmake] add a YUZU_STATIC_ROOM option (#3411) 2026-01-28 23:54:49 +01:00
.clang-format
CMakeLists.txt [dynarmic] bootstrap loongarch64 host build (#4015) 2026-05-30 01:42:23 +02:00
dep_hashes.h.in