Spider-Man: Miles Morales to gameplay: recompiler, PM4, cache and diagnostics fixes #780

Open
github-bot wants to merge 13 commits from github-bot/gh-780 into main AGit
Owner

@⁠itsmemac on GitHub · 2026-09-22 21:31 UTC · original
itsmemac:spiderman-running-22-09-2026 → main · +690 −174 · 35 files · 13 commits · open

Summary

Marvel's Spider-Man: Miles Morales (PPSA01417) boots, loads the world and is playable, and
Astro Bot (PPSA21564) runs with its non-RT patch (distributed separately, not part of this
PR). The work is split into topic commits that each build on their own, so they can be
reviewed and cherry-picked individually. Each commit message explains the problem it fixes
and how it was found.

Changes since the last version of this PR

Rebased on main at a0268f1d (912 commits since the previous base). Where main now does
the same job, its version is kept and our topic is dropped; where ours still adds something,
it was re-ported onto the new code.

Dropped, superseded by main:

  • shader: implement S_MEMREALTIME (77a8f307, b2f40c6c read the device clock divided to 100 MHz).
  • shader: cache declared shader hashes (the shader map hashes once at registration).
  • render: read GPU-owned descriptor words through the tracked mapping (TryReadBufferBacking
    downloads GPU-dirty bytes first).
  • render: skip clean tracker regions and redundant BDA synchronization (the BDA sync queue,
    f356fa37, and the early-out in ForEachModifiedRange cover it).
  • buffer cache: download ranges larger than the staging ring in windows (oversized downloads
    use a one-off buffer).
  • vulkan: place images in host memory when device memory is exhausted (6ff6e755 allocates
    with AUTO_PREFER_DEVICE within budget).
  • ampr: map commands, counters and asynchronous engines (implemented on main).
  • ajm: carry partial ATRAC9 superframes across decode jobs (main now reports partial input
    as unconsumed so the title resends it, and tests that contract; stashing the tail would
    decode a resend twice).

The commits the older description listed but that had already left the branch (GLC/SLC
coherence, EOP event 0x14, VrrStatus, agc tracing, the save_data_memory_tests build) are not
listed below either.

Re-ported onto the rewritten code:

  • Non-fatal translation: the pipeline cache now marks an untranslatable program
    skip_dispatch; tessellation pairs the analysis rejects are remembered next to
    m_tess_layouts. Resource tracking fails inside many nested planning helpers, so in
    non-fatal mode Tracker::Fail throws a private TrackingFailure that only
    TrackResources catches, instead of an early return at every call site.
  • Texture collector: the per-frame budget keeps main's heap-reference and eviction-counter
    handling.
  • Device loss: VK_EXT_device_fault and NV diagnostics config are wired into the new feature
    chain. The NV checkpoint markers are dropped: main removed the per-command debug info they
    were labelled with, and the fault's vendor dump is what names the hung shader.
  • Video out: reduced to the two 10-bit encodings main still lacks.
  • Smaller adjustments: the GPU rejection uses reject(), the presented-frame count sits next
    to main's, and image backing that cannot be read zero-fills through TryReadSparseBacking.

Commits

Shader recompiler

  • shader: skip programs the recompiler cannot translate instead of exiting
  • shader: snapshot pixel shader input semantics at registration

Command processor

  • gpu: skip PM4 type-0 packets

Renderer and caches

  • render: bind buffer descriptors in guest page 0 as null
  • buffer cache: age entries by presented frames and publish aged dirty buffers
  • buffer cache: zero-fill guest image backing that cannot be read
  • texture cache: budget eviction per frame and write back GPU-written tiled images
  • texture cache: stage image downloads larger than the download ring

Vulkan and video out

  • video out: add two 10-bit output format policies
  • vulkan: skip GPUs that cannot report surface capabilities

Libraries

  • dialog: keep progress bar dialogs open until the title closes them

Diagnostics

  • vulkan: report device loss with VK_EXT_device_fault
  • common: print a symbolized host stack on fatal errors

Testing

  • Windows 11, clang-cl, Release: the emulator and the test targets build.
  • ctest: 74 of 79 pass. None of the five failures involves this PR: vdecsw does not
    compile with the VS 2019 STL (std::aligned_alloc), psml is not built by kyty_tests,
    kernel_file_system does not link on Windows (SDL_main), and common's
    File.GetTimesReportsExactNanoseconds throws in this STL's last_write_time.
    ngs2_sampler passes once the ATRAC9 topic is dropped.
  • shader_recompiler_compute passes, including the buffer and texture cache GC tests and
    the tessellation interface tests this PR updates.
  • Not yet run on games on this tip.
  • Built only on Windows with an NVIDIA GPU; the Linux and macOS builds are left to CI.

Known limitations

  • Programs that use still-unimplemented instructions are skipped along with their draw or
    dispatch.
  • Spider-Man: water does not render yet.

AI assistance was used

🤖 Generated with Claude Code

**@⁠itsmemac** on GitHub · 2026-09-22 21:31 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/780) `itsmemac:spiderman-running-22-09-2026` → `main` · +690 −174 · 35 files · 13 commits · open ## Summary Marvel's Spider-Man: Miles Morales (PPSA01417) boots, loads the world and is playable, and Astro Bot (PPSA21564) runs with its non-RT patch (distributed separately, not part of this PR). The work is split into topic commits that each build on their own, so they can be reviewed and cherry-picked individually. Each commit message explains the problem it fixes and how it was found. ## Changes since the last version of this PR Rebased on `main` at a0268f1d (912 commits since the previous base). Where `main` now does the same job, its version is kept and our topic is dropped; where ours still adds something, it was re-ported onto the new code. Dropped, superseded by `main`: - shader: implement S_MEMREALTIME (77a8f307, b2f40c6c read the device clock divided to 100 MHz). - shader: cache declared shader hashes (the shader map hashes once at registration). - render: read GPU-owned descriptor words through the tracked mapping (TryReadBufferBacking downloads GPU-dirty bytes first). - render: skip clean tracker regions and redundant BDA synchronization (the BDA sync queue, f356fa37, and the early-out in ForEachModifiedRange cover it). - buffer cache: download ranges larger than the staging ring in windows (oversized downloads use a one-off buffer). - vulkan: place images in host memory when device memory is exhausted (6ff6e755 allocates with AUTO_PREFER_DEVICE within budget). - ampr: map commands, counters and asynchronous engines (implemented on `main`). - ajm: carry partial ATRAC9 superframes across decode jobs (`main` now reports partial input as unconsumed so the title resends it, and tests that contract; stashing the tail would decode a resend twice). The commits the older description listed but that had already left the branch (GLC/SLC coherence, EOP event 0x14, VrrStatus, agc tracing, the save_data_memory_tests build) are not listed below either. Re-ported onto the rewritten code: - Non-fatal translation: the pipeline cache now marks an untranslatable program `skip_dispatch`; tessellation pairs the analysis rejects are remembered next to `m_tess_layouts`. Resource tracking fails inside many nested planning helpers, so in non-fatal mode `Tracker::Fail` throws a private `TrackingFailure` that only `TrackResources` catches, instead of an early return at every call site. - Texture collector: the per-frame budget keeps `main`'s heap-reference and eviction-counter handling. - Device loss: `VK_EXT_device_fault` and NV diagnostics config are wired into the new feature chain. The NV checkpoint markers are dropped: `main` removed the per-command debug info they were labelled with, and the fault's vendor dump is what names the hung shader. - Video out: reduced to the two 10-bit encodings `main` still lacks. - Smaller adjustments: the GPU rejection uses `reject()`, the presented-frame count sits next to `main`'s, and image backing that cannot be read zero-fills through `TryReadSparseBacking`. ## Commits Shader recompiler - shader: skip programs the recompiler cannot translate instead of exiting - shader: snapshot pixel shader input semantics at registration Command processor - gpu: skip PM4 type-0 packets Renderer and caches - render: bind buffer descriptors in guest page 0 as null - buffer cache: age entries by presented frames and publish aged dirty buffers - buffer cache: zero-fill guest image backing that cannot be read - texture cache: budget eviction per frame and write back GPU-written tiled images - texture cache: stage image downloads larger than the download ring Vulkan and video out - video out: add two 10-bit output format policies - vulkan: skip GPUs that cannot report surface capabilities Libraries - dialog: keep progress bar dialogs open until the title closes them Diagnostics - vulkan: report device loss with VK_EXT_device_fault - common: print a symbolized host stack on fatal errors ## Testing - Windows 11, clang-cl, Release: the emulator and the test targets build. - `ctest`: 74 of 79 pass. None of the five failures involves this PR: `vdecsw` does not compile with the VS 2019 STL (`std::aligned_alloc`), `psml` is not built by `kyty_tests`, `kernel_file_system` does not link on Windows (SDL_main), and `common`'s `File.GetTimesReportsExactNanoseconds` throws in this STL's `last_write_time`. `ngs2_sampler` passes once the ATRAC9 topic is dropped. - `shader_recompiler_compute` passes, including the buffer and texture cache GC tests and the tessellation interface tests this PR updates. - Not yet run on games on this tip. - Built only on Windows with an NVIDIA GPU; the Linux and macOS builds are left to CI. ## Known limitations - Programs that use still-unimplemented instructions are skipped along with their draw or dispatch. - Spider-Man: water does not render yet. AI assistance was used 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A program the recompiler cannot translate now costs its draw or dispatch
instead of the session. Marvel's Spider-Man: Miles Morales and Astro Bot each
have a handful of compute programs using instructions that are not implemented
yet (MIMG 0xe6 BVH intersection, VOP2 0x12 with SDWA), and upstream exits on the
first of them.

- CompileOptions::non_fatal and TranslateResult::unsupported; a
  TranslationNonFatalScope carries the policy into the frontend.
- The give-up points in Dispatch, ShaderCFG and the tessellation analysis and
  lowering record the reason, log it and return instead of calling EXIT.
  AnalyzeTessellationPrograms and LowerTessellationMemory return success.
- Resource tracking fails in many nested planning helpers, so in non-fatal mode
  Tracker::Fail logs and throws a TrackingFailure that only TrackResources
  catches; TrackResources returns false and the program is discarded.
- The pipeline cache marks an untranslatable program skip_dispatch, so it is
  not translated again, and remembers LS/HS pairs the tessellation analysis
  rejects.
- A draw is skipped when any of its vertex stages or its active pixel program
  is missing; GetGraphicsPrograms leaves stage 0 unbound for the existing check.
  A dispatch whose program is missing is skipped as before.
- A resource-materialization failure (a descriptor source not mapped or filled
  yet) skips that use and is logged, at most sixteen times.
- resource_tracking_tests and scalar_provenance_tests link common for the
  logging.
Titles leave reserved dwords in their command buffers as zeros, which decode as
type-0 packets and were reported as an unknown opcode. They are now skipped by
their encoded length.
A buffer descriptor whose base lies in guest page 0 is a null or garbage
descriptor; it now binds as null, as address 0 already did. The garbage
collector skips a buffer registered at address 0 (it had died on a page-aligned
buffer there, since the memory tracker cannot hold address 0), and the tracker's
invalid-range exit names the range.
- Pressure is judged by the cache's own bytes. Device-wide usage also counts
  the images spilled to host memory, which on a 6 GB card kept the collector in
  its aggressive mode forever, recreating ~100 buffers a second.
- An aged dirty buffer is always downloaded and dropped. Retaining it left its
  GPU-written bytes owning the pages, and images sharing those pages went black.
- Entries age in presented frames, not collector runs: the collector runs once
  per guest submission, and a title can submit a hundred times a frame.
  GraphicContext counts presented frames; the LRU clock adds one step per 512
  collector runs so a stretch without presents still ages.
- The cache tests present frames to age their entries, and the dirty-GC test
  follows the new policy.
ObtainBufferForImage zero-fills an image's staging copy when its guest backing
cannot be read yet (not mapped or not filled), instead of exiting.
The texture collector could not keep a 4K title in a 6 GB card. Measured on
Spider-Man:

- Entries age in presented frames. Counted in collector runs, one per guest
  submission, an age of 8 evicted textures inside the frame that used them, to
  recreate them the next: 11 000 image creations a second at the title menu.
  An image used in the frame being recorded is never a candidate. Title menu:
  1 fps to 30 fps.
- Pressure is judged by the cache's own image bytes. Device-wide usage counts
  the images the cache spilled to host memory and never falls.
- Under pressure, eviction is budgeted per frame in bytes actually freed, in
  proportion to the excess (a quarter of it over the critical mark, an eighth
  over the pressure mark, at least 64 or 16 MiB, at most 1 024 images a
  frame). A budget per run churned; a small fixed count was spent on images the
  collector then skipped.
- Under pressure a GPU-written tiled image is written back, detiled, and
  evicted like any other, within 256 MiB of write-back a frame (an image that
  does not fit what is left waits for the next frame, unless it is the first).
  They were never
  evicted before: 3 500 of every 4 000 candidates, so the cache grew to 13.5 GB
  and the NVIDIA driver crashed in present. A streaming burst now returns to the
  threshold within nine frames.
- The collector test helper starts each scenario with an empty frame budget.
An image larger than the download ring gets a staging buffer of its own for
the transfer instead of exiting: the ring cannot map it, and an image's
regions cannot be cut into ring-sized pieces the way a buffer range can.
Adds the video-out pixel format encodings 0x8100000622000000 (A2B10G10R10)
and 0x8100000600000000 (A2R10G10B10), which titles register beside the ones
already listed. Upstream has since added the BT.2100 PQ and FP16 encodings
this change originally carried.
A candidate GPU whose driver fails the surface capabilities query for the
window (vkGetPhysicalDeviceSurfaceCapabilitiesKHR) is skipped during device
selection instead of ending the session. The integrated GPU of a hybrid laptop
does this intermittently (ErrorUnknown), and the discrete GPU was never
considered.
A progress bar dialog has no button: the title closes it when its work is
done. The save-data dialog (mode 5) and the message dialog (mode 2) reported
their progress bars as finished at once, so the title took them for dismissed
and opened them again every frame. Spider-Man's manual save did that ~470
times a frame. They now stay running until closed; every other mode is answered as
before.
A lost device used to end in a bare EXIT from vkQueueSubmit or the timeline
wait, with nothing saying which work hung.

- VK_EXT_device_fault is enabled when the device offers it. When a submit or
  MasterSemaphore::Wait returns VK_ERROR_DEVICE_LOST, the fault description,
  address records and vendor records are printed and logged, and the vendor
  binary (on NVIDIA a GPU crash dump that names the hung shader) is written to
  _device_fault.nv-gpudmp.
- VK_NV_device_diagnostics_config is enabled with shader debug info, resource
  tracking and shader error reporting where available, which the NVIDIA dump
  draws on.
- MasterSemaphore::Wait reports the failing result and ticks instead of a
  bare EXIT_NOT_IMPLEMENTED.
A fatal EXIT prints a symbolized host stack (dbghelp on Windows, serialized
with a mutex since dbghelp is not thread-safe) after the build and error
lines.
Pixel shader input semantics are copied into ShaderMappedData when the shader
is registered, and ShaderGetStaticInputInfoPS reads the copy instead of reading
through the guest pointer for every lookup.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:32:15 +00:00
This pull request has changes conflicting with the target branch.
  • src/graphics/host_gpu/renderer/cache/textureCache.cpp
  • src/graphics/host_gpu/renderer/cache/textureCache.h
  • src/graphics/host_gpu/renderer/image/imageInfo.h
  • src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp
  • src/graphics/host_gpu/renderer/pipeline/pipelineCache.h
  • src/graphics/host_gpu/renderer/renderDraw.cpp
  • src/graphics/presentation/window/vulkanWindow.cpp
  • src/graphics/shader/recompiler/Tessellation.cpp
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/780/head:github-bot/gh-780'
git switch 'github-bot/gh-780'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-780'
git switch 'github-bot/gh-780'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-780'
git switch 'github-bot/gh-780'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-780'
git switch 'main'
git merge --squash 'github-bot/gh-780'
git switch 'main'
git merge --ff-only 'github-bot/gh-780'
git switch 'main'
git merge 'github-bot/gh-780'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.