Skip to content

Fix Mario Kart World lighting - #871

Merged
snowstormxd merged 3 commits into
Eglantine-Community:nx2-experimentalfrom
snowstormxd:fix/mkw-lighting-sparse-atlas-20261114
Nov 14, 2026
Merged

snowstormxd merged 3 commits into
Eglantine-Community:nx2-experimentalfrom
snowstormxd:fix/mkw-lighting-sparse-atlas-20261114

Conversation

@snowstormxd

Copy link
Copy Markdown
Contributor

Mario Kart World can lose ambient and indirect lighting when its light-probe buffer is truncated to 8 MiB or its large HDR lightmap array is addressed with 32-bit sizes and offsets.

This PR honors valid NVN graphics buffer descriptor sizes and keeps atlas sizes and layer offsets in 64 bits. BC6H lightmap arrays use sparse tiles and per-layer mip tails on supported devices, with the existing layer-based fallback retained. Uploads cover mapped or dirty rectangles, stage one layer at a time, and combine each rectangle's GOB rows into one copy.

The current storage-binding caches, device-limited pointer-table ranges, grass residency handling, driver checks and memory-budget policy are preserved. There are no shader-lowering changes. Two small Windows test-build fixes are isolated in the final commit.

Type of change

  • Bug fix
  • Game compatibility / game-support
  • CI / build (Windows test compilation only)

Validation

  • Windows Release build of yuzu and tests succeeded with Clang 23.1.5, PGO and ThinLTO.
  • Lighting, storage, sparse-residency and game-preset checks: 26 cases / 17,299 assertions passed.
  • New regressions cover atlas layers beyond 4 GiB, one-past-end addresses, sparse ranges crossing layer boundaries, and byte-for-byte comparisons between partial and full compressed uploads across layers and mips.
  • Full suite: 416 of 422 cases passed. Five existing Ampere numeric cases account for 14 assertion failures; all 14 were reproduced by a standalone check compiled against the unmodified upstream lowering header. The remaining failure is the previously documented NUP default-language metadata edit test. Neither lowering nor NUP code is changed here.
  • git diff --check passed. No game data, keys, firmware or captures are included.

The earlier reference fixes were reported to resolve the lighting issues. The newly ported Windows build has not yet been tested in game, and sustained FPS or frame pacing has not been measured. Linux, macOS and other GPU vendors have not been tested locally.

Commits

  1. Use the full size of Mario Kart World lighting buffers.
  2. Load Mario Kart World HDR lightmaps by sparse tile.
  3. Fix Windows builds of the page-table and preset tests.

AI disclosure

OpenAI Codex ported the fixes, added regression tests, performed local build and test validation, and drafted the commit messages and this description at the author's request. The author explicitly requested that this PR be opened ready for review.

NVN graphics storage slots contain an address and a size. Honor valid declared sizes so Mario Kart World's light-probe buffer is not truncated to 8 MiB.

Keep the existing limits for bare native pointers and pointer tables, including device-dependent read-only ranges and binding reuse. Add checks for descriptor slots, declared sizes and fallback limits.

Assisted-by: OpenAI Codex (porting and validation)
Keep atlas sizes and layer offsets in 64 bits so lightmap layers beyond 4 GiB remain addressable. Support BC6H array tiles and per-layer mip tails on devices with the required sparse-residency features.

Upload only mapped or dirty rectangles, stage one layer at a time, and combine each rectangle's GOB rows into one copy. Handle compressed block dimensions correctly and retain the existing fallback and memory-budget policy.

Add regression tests for large atlas offsets, layer boundaries and partial uploads compared with full uploads.

Assisted-by: OpenAI Codex (porting and validation)
Remove redundant local Entry aliases that Clang rejects as shadowing. Undefine the Windows SDK LoadString macro in the preset tests so it does not rename Settings methods and cause linker errors.

Assisted-by: OpenAI Codex (build compatibility and validation)
@coderabbitai

coderabbitai Bot commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 66397040-7128-4f87-aecd-4015ef8718ce

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@snowstormxd snowstormxd changed the title Fix Mario Kart World lighting buffers and sparse HDR lightmaps Fix Mario Kart World lighting Nov 14, 2026
@Shulbick Shulbick mentioned this pull request Nov 14, 2026
1 task done
@snowstormxd snowstormxd moved this from Backlog to Ready in Release Tracker Nov 14, 2026
@snowstormxd
snowstormxd merged commit 65f5650 into Eglantine-Community:nx2-experimental Nov 14, 2026
1 check passed
@github-project-automation github-project-automation Bot moved this from Ready to Done in Release Tracker Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant