eden/src/core
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
..
arm [core/core_timing] better MWAITX and WAITPKG delays (#3984) 2026-05-30 21:59:10 +02:00
crypto [common/logging] Simplify logging logic and fix issues when logging before system is created (#3688) 2026-03-12 18:29:15 +01:00
debugger [core/debugger] Protocol-compliant vCont support (#3896) 2026-06-04 05:49:23 +02:00
file_sys [file_sys] Avoid crash on empty NACP language entries (#4062) 2026-06-05 17:20:24 +02:00
frontend [common/logging] Simplify logging logic and fix issues when logging before system is created (#3688) 2026-03-12 18:29:15 +01:00
hle [video_core, maxwell] fixes for homebrew games that use MESA compiler (#4012) 2026-06-15 03:05:11 +02:00
internal_network [net] support SCTP protocols (+all base FBSD protos), ban more NS domains (#3955) 2026-05-21 21:24:18 +02:00
loader [hle] support passing arguments to homebrew applications (#4013) 2026-06-15 03:02:33 +02:00
memory [file_sys, cheats] fix cheat_xxx.txt not being able to be disabled from Qt frontend (#3223) 2025-12-31 17:10:36 +01:00
tools [*] basic in-house cpp linting (#4039) 2026-06-04 05:49:07 +02:00
CMakeLists.txt [hle] Fixes for nxident, nxmp and nxplay, remove hbl.nsp workarounds (#3996) 2026-06-12 23:48:24 +02:00
constants.cpp [core] Use a eden profile picture instead of the default grey one. (#3350) 2026-01-20 18:32:08 +01:00
constants.h [core] Use a eden profile picture instead of the default grey one. (#3350) 2026-01-20 18:32:08 +01:00
core.cpp [core] Fix qlaunch crash on second launch (#3930) 2026-05-06 04:20:55 +02:00
core.h [vfs] remove usage of 'dynamic_cast', use ankerl::map for files (#3594) 2026-02-21 18:38:32 +01:00
core_timing.cpp [core/core_timing] better MWAITX and WAITPKG delays (#3984) 2026-05-30 21:59:10 +02:00
core_timing.h [core/core_timing] better MWAITX and WAITPKG delays (#3984) 2026-05-30 21:59:10 +02:00
cpu_manager.cpp [android, core] pin core threads to logical CPUs 0-3 (#3121) 2026-02-01 01:54:59 +01:00
cpu_manager.h Fix typos in src/core (#12625) 2024-01-08 13:31:48 -06:00
device_memory.cpp core: Define HAS_NCE macro 2023-11-25 00:47:36 -05:00
device_memory.h Core: Initial implementation of device memory mapping 2024-01-18 21:12:30 -05:00
device_memory_manager.h [core] coalesce tracking entries for GPU (#3677) 2026-03-08 22:45:38 +01:00
device_memory_manager.inc [core] coalesce tracking entries for GPU (#3677) 2026-03-08 22:45:38 +01:00
game_settings.cpp [common/logging] Simplify logging logic and fix issues when logging before system is created (#3688) 2026-03-12 18:29:15 +01:00
game_settings.h [core] Add overridable game setting functionality (#2963) 2025-12-17 03:59:27 +01:00
gpu_dirty_memory_manager.h Core: Eliminate core/memory dependancies. 2024-01-18 21:12:30 -05:00
guest_memory.h Solves warning about GuestMemory having internal linkage. 2025-04-04 03:40:47 +02:00
hardware_properties.h [dynarmic] jit fix branch v2 (#203) 2025-08-27 06:49:50 +02:00
launch_timestamp_cache.cpp [common/logging] Simplify logging logic and fix issues when logging before system is created (#3688) 2026-03-12 18:29:15 +01:00
launch_timestamp_cache.h [tests] fix compile+linking issues with PlayTime (#3345) 2026-01-19 16:27:18 +01:00
memory.cpp [core/memory] remove duplicates from template when unsafe=T/F, remove increment, remove sad path for exception code on cache op (#3972) 2026-05-18 23:28:01 +02:00
memory.h Revert "[core/memory] Remove defered heap allocation on Linux." (#2974) 2025-11-09 22:42:09 +01:00
perf_stats.cpp [frontend] Slow and Turbo modes (#3525) 2026-02-12 01:31:55 +01:00
perf_stats.h chore: make yuzu REUSE compliant 2022-07-27 12:53:49 +02:00
reporter.cpp [hle] inline HLE cmif request to not allocate on heap stuff (#3605) 2026-05-15 22:07:03 +02:00
reporter.h [prepo] Add support for missing PlayReport commands (#3674) 2026-03-06 15:02:59 +01:00