Fix the Marvel-logo hang in Spider-Man: Miles Morales (PPSA01411) #2012
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!2012
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2012"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Xx-LiDAF-xX on GitHub · 2026-10-31 10:34 UTC · original
Xx-LiDAF-xX:codex/ppsa01411-linear-storage-readback→main· +177 −40 · 8 files · 5 commits · openProblem
Spider-Man: Miles Morales (PPSA01411) stalls at the Marvel logo while polling the last float in a 384×216 reprojection image written by a compute shader. On upstream
02618916, that value remained-1.0in guest memory. Full linear readback alone also stalled because frame-boundary processing depended on the guest submitting another frame.Fix
Track writes to linear storage images with at most 512 KiB of backing. At the end of each draw or dispatch,
RenderExecutor::ResetBindingscopies pending image results into the buffer cache at the same guest address, before a subsequentReleaseMempacket or completion interrupt.The buffer cache marks the copied range GPU-written and protects its guest pages. Guest read faults retrieve the current bytes; write faults resolve pending GPU data before the CPU store proceeds. A write fault before publication waits for the GPU command thread to publish the image and resolve ownership for the faulting page. This preserves untouched GPU-written texels while allowing a later CPU store to change one texel.
Publication replaces older overlapping buffer contents and avoids deferred callbacks that could overwrite newer CPU stores. With full linear readback enabled, eager readback uses the same buffer-cache path. Before publication, neighboring writes that removed a page watch are checked and unchanged images are tracked again. Partial writes into a published buffer invalidate the overlapping native image before reuse.
Integration
Rebased onto
mainat9a29dc62; the current head iscd839081. Conflict resolutions retain upstream's texture-cache simplifications and adapt pending-storage detection to the current overlap API while preserving coverage of the full faulting page. The Windows test compilation fix from #2010 is already upstream and is no longer a separate commit in this PR.Verification
For the rebased head
cd839081:shader_recompiler_compute(the full GPU suite),texture_cache_layered_image,image_page_table,memory_tracker, andpage_manager.image_page_tableandmemory_trackerpassed with AddressSanitizer and UndefinedBehaviorSanitizer enabled. The instrumentedpage_managertest could not complete because its fixed-addressVirtualAllocfailed; its normal Release test passed.cd839081passed its Windows, Linux, and macOS build and test jobs.Earlier Windows gameplay validation established the original fix's effect: the game passed the PlayStation and Marvel logos, reached the menu, and entered gameplay at approximately 1–2 FPS. In a controlled RTX 4060 Ti run, upstream remained at the Marvel logo for 85 seconds, while
6f3ef314reached the interactive “Before You Start” menu at 90 seconds and continued presenting frames through three minutes. Gameplay was not rerun for the rebased head.Codex assisted with diagnosis, implementation, rebase conflict resolution, and automated testing.
@coderabbitai[bot] on GitHub · 2026-10-31 10:41 UTC · original · edited 2026-11-06 05:11 UTC
No actionable comments were generated in the recent review.
Walkthrough
TextureCache queues eligible non-tiled storage images separately from ordinary downloads and publishes safe images to buffer-cache ranges. Binding resets and download processing invoke publication. Image state and GPU invalidation handling now track buffer mirrors. RenderContext handles write faults that overlap pending storage images. Tests cover publication, guest memory faults, and preservation of guest writes. RenderContext adds synchronous GPU-command dispatch, which UnmapMemory and BufferCache use.
Suggested reviewers:
nmzikChange: Bug fix
Merge Risk:
Moderate · up to
6f3efSome overlapping GPU and guest-memory writes can lose data. These cases should be addressed before merging.
Pre-merge checks:
4 ·
1
Full details: Docstring Coverage
Explanation
Docstring coverage is 4.35% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 23 functions across 7 files. (1 skipped: 1 too large.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Share
3c609533-c2fb-46e1-8598-fe8044c37915Reviewing files that changed from the base of the PR and between 3ab75f2188248045171e98bfcd48fd323720da2c and 6f3ef31408ecd097349bd1c213fe611ec38358c0.
src/graphics/host_gpu/renderer/cache/textureCache.cppsrc/graphics/host_gpu/renderer/cache/textureCache.hsrc/graphics/host_gpu/renderer/renderContext.cpptests/ShaderRecompilerComputeTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
@coderabbitai[bot] on GitHub · 2026-10-31 10:41 UTC · original · edited 2026-10-31 16:57 UTC
On
src/graphics/guest_gpu/graphicsRun.cppline 227 (outdated):Publish storage results before signaling completion.
If a submission writes a storage image and then issues
ReleaseMemwith an interrupt,ReleaseMemqueues the interrupt before this call queues the image publication. The priority queue runs the interrupt first, so the guest can wake and read stale image data. Queue the readback before the completion signal. (raw.githubusercontent.com)✅ Addressed in commits 0964efc to d98028b
@coderabbitai[bot] on GitHub · 2026-10-31 10:41 UTC · original · edited 2026-10-31 16:59 UTC
On
src/graphics/host_gpu/renderer/cache/textureCache.cppline 2085 (outdated):Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 3579
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 42469
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 42365
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 42740
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 43315
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 42838
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 42717
Reconcile older buffer ownership before publishing the image.
DownloadImageMemorypublishes the image to guest backing but does not clear or update overlappingBufferCacheGPU-dirty ranges. A later guest fault can therefore download the stale buffer and overwrite the image result.SynchronizeBufferFromImagedoes not protect this path because the fault callsReadMemorywithis_write=true.The same ownership gap existed through the previous
TrackImageDownloadpath, but this change makes it reachable for small storage images even when linear readback is disabled. Reconcile the overlapping buffer’s dirty ranges and contents when the image becomes authoritative.Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 2433
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 15695
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 4276
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 3032
Protect queued storage readbacks from later CPU writes.
DownloadImageMemoryqueues a deferred callback that writes the full image range back to guest memory. A CPU write to that range after the readback is queued, and before the callback runs, is overwritten by the callback's snapshot. CPU write invalidation does not wait for or cancel the pending callback. The write path marks the image CPU-dirty and untracks it, but it does not serialize with the priority queue.The general download path (
m_download_images) already has this window before this change. This change extends it to the storage queue.Serialize CPU writes with pending readbacks that overlap the written range, or merge the CPU write into the readback before publication. The inspected code does not establish a safe localized edit, so this comment does not include a patch.
✅ Addressed in commits 0964efc to d98028b
@coderabbitai[bot] on GitHub · 2026-10-31 10:41 UTC · original · reviewed
Actionable comments posted: 3
5f673feb-e398-4826-9185-1cbfd725ce0eReviewing files that changed from the base of the PR and between
026189166fand 120e9717628f5700e53fc2cc1bcf23c4ed5b7474.src/graphics/guest_gpu/graphicsRun.cppsrc/graphics/host_gpu/renderer/cache/textureCache.cppsrc/graphics/host_gpu/renderer/cache/textureCache.htests/ShaderRecompilerComputeTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
@ -1996,0 +2018,4 @@eager_readbacks.push_back(image.info.data);}}m_storage_downloads.clear();@coderabbitai[bot] on GitHub · 2026-10-31 17:05 UTC · original · edited 2026-10-31 22:24 UTC
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 3762
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 10007
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 3608
Keep a maybe-dirty storage image on the publish path.
A CPU write to the same page, but outside the image range, marks a queued storage image maybe-dirty.
SafeToDownload()then returns false for that image.PublishStorageImagesskips it and clearsm_storage_downloads, so the GPU result is not copied to the buffer cache at that boundary. The state is resolved only when a later binding of the image runsRefreshImage. Until that happens, a guest read of the storage memory can return stale data.The write does not need to change any bytes to cause this. The maybe-dirty mark is set first. The byte comparison happens only when
ResolveMaybeCpuHashruns. Earlier wording about the state lasting indefinitely is too broad. It persists until the next binding of that image.The correction should resolve the maybe-dirty state before the
SafeToDownload()check, using the same hash comparison asRefreshImage. An unchanged image should then publish at the draw boundary. The image must also be re-tracked after resolution, becauseMarkAsMaybeDirtyuntracks it.✅ Addressed in commit 6f3ef31
@ -1997,0 +2031,4 @@}const auto range = image.info.data;auto [buffer, offset] = m_buffer_cache.ObtainBuffer(range.address, range.size, true);DownloadImage(image, *buffer, offset, range.size, image.info.resources.levels);@coderabbitai[bot] on GitHub · 2026-10-31 17:05 UTC · original
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 3330
Invalidate overlapping images before partial buffer writes.
When
CopyImageToBufferCachepublishes an image, the buffer cache marks the image range as GPU-dirty, but the image remains GPU-current. A later partialFillBufferor buffer write can update an address inside that range.InvalidateMemoryFromGPUmust invalidate every overlapping image, not only an image whose base address equals the write address. Otherwise, a laterPublishStorageImagescall can copy the stale image over the newer buffer bytes.@coderabbitai[bot] on GitHub · 2026-10-31 17:05 UTC · original · reviewed
Follow-up Comments
466c8b12-a2d1-491c-b500-f2b90c04d7acReviewing files that changed from the base of the PR and between 120e9717628f5700e53fc2cc1bcf23c4ed5b7474 and d98028bbb0a1bbafe4efd32e9d7e04ca6b85e0cc.
src/graphics/host_gpu/renderer/cache/textureCache.cppsrc/graphics/host_gpu/renderer/cache/textureCache.hsrc/graphics/host_gpu/renderer/pipeline/descriptors.cpptests/ShaderRecompilerComputeTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
@ -1996,0 +2011,4 @@TrackImage(id);(void)image.ResolveMaybeCpuHash(image.HashGuestEdges());}if (!image.SafeToDownload() || !CopyImageToBufferCache(image)) {@coderabbitai[bot] on GitHub · 2026-10-31 22:00 UTC · original
Preserve GPU results when a guest write precedes publication.
If a guest write faults after a storage draw is recorded but before
ResetBindings()publishes it, the buffer cache may not yet have GPU ownership. The fault then marks the image CPU-dirty without resolving its GPU contents. This check skips the image and the queue is cleared, so untouched GPU-written texels can be lost. The existing pending-write test faults only after publication. (raw.githubusercontent.com)Establish GPU ownership before guest writes can proceed, or merge the pending image result with the guest write.
@coderabbitai[bot] on GitHub · 2026-10-31 22:00 UTC · original · reviewed
Actionable comments posted: 1
5e23539b-c921-4629-ae19-3b6c2cbc5db6Reviewing files that changed from the base of the PR and between d98028bbb0a1bbafe4efd32e9d7e04ca6b85e0cc and 47723af7e63122e6117cb01403a96a7927639db1.
src/graphics/host_gpu/renderer/cache/bufferCache.cppsrc/graphics/host_gpu/renderer/cache/textureCache.cppsrc/graphics/host_gpu/renderer/image/image.hsrc/graphics/host_gpu/renderer/renderContext.cppsrc/graphics/host_gpu/renderer/renderContext.htests/ShaderRecompilerComputeTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
@coderabbitai[bot] on GitHub · 2026-10-31 22:21 UTC · original · reviewed
2d43175c-7c7b-4774-bebd-74811577f65eReviewing files that changed from the base of the PR and between 47723af7e63122e6117cb01403a96a7927639db1 and 3ab75f2188248045171e98bfcd48fd323720da2c.
src/graphics/host_gpu/renderer/cache/textureCache.hsrc/graphics/host_gpu/renderer/image/image.hsrc/graphics/host_gpu/renderer/renderContext.htests/ShaderRecompilerComputeTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
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.Merge
Merge the changes and update on Forgejo.