graphics: read unmapped shader resource memory as zero #1194
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!1194
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1194/head"
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?
@akar995 on GitHub · 2026-10-08 09:15 UTC · original
akar995:fix/srt-unmapped-shader-reads→main· +92 −3 · 6 files · 2 commits · closed without mergingSummary
Astro Bot crashes on main while booting (about 30 frames in), with an access violation reading address 0x18 inside
SrtWalker::EvaluateRawRead. Ordinary SRT loads have no reader, so the walkermemcpys straight from the guest pointer. That pointer comes from a stale or null table entry that the shader only follows on a path the game never takes.RenderContext::IsMappedkeeps the last mapping each thread found, invalidated by an unmap generation counter. The check added to every walk read therefore takes no lock in the common case.Results
Testing
Hardware and software:
5a880808Tests:
ctest -j 1on this branch against unmodified main5a880808on the same machine. main fails 12 of 53 tests here. They were compared one by one, and each fails with the same output on this branch (listed below).Game: Astro Bot (PPSA21567). On this machine, main renders at about 250 ms per frame and stays on the boot logos. So the stage-level effects described above were measured with this change as part of my larger local branch, not on main alone.
Tests that fail on both main and each branch, with the same output: kernel_file_system, save_data_memory, shader_recompiler_compute, graphics_pipeline_rasterization, texture_cache_layered_image, texture_cache_image_views, texture_cache_storage_sampled, compute_meta_clear_classification, texture_cache_image_overlap, texture_cache_htile_clear, buffer_cache_ranges (plus gpu_tiler, which the tiler shader PR "graphics: avoid vector spec-constant selects in tiler shaders" fixes).
AI use
I used Claude Code (Anthropic) to investigate, write and test these changes. I reviewed the diff and ran the tests above before submitting.
🤖 Generated with Claude Code
@coderabbitai[bot] on GitHub · 2026-10-08 09:24 UTC · original · edited 2026-10-08 10:00 UTC
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
254051a9-fac9-4864-a710-d5381ad3f840📥 Commits
Reviewing files that changed from the base of the PR and between
4de2879892and3e80e4b71f.📒 Files selected for processing (1)
src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 2 remain after this review.
📝 Walkthrough
Walkthrough
The changes add a containing-range lookup and cache GPU mapping checks in the render context. They expose a kernel API to query whether a guest range is GPU-mapped. Shader memory readers now read mapped spans and zero-fill unmapped words. The runtime uses the ordinary-memory reader for
read_memoryand the guest-memory reader for specialization reads.Priority: ➖ Normal
Change: Bug fix
Merge Risk: ⚪ Minimal · up to
3e80eNo actionable issue remains from the reviewed changes; the PR is mergeable after normal checks.
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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
Comment
@coderabbitai helpto get the list of available commands.@coderabbitai[bot] on GitHub · 2026-10-08 09:24 UTC · original · edited 2026-10-08 09:54 UTC
On
src/graphics/host_gpu/renderer/pipeline/pipelineCache.cppline 113 (outdated):🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 3777
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 42108
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 21969
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 194
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 5065
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 14191
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 42350
Preserve mapped words in multiword scalar-table reads.
ReadScalarTablecan pass multiple words toread_specialization_memory. IfTryReadBufferBackingreturns false for a range that crosses a GPU mapping boundary,ReadUnmappedShaderMemorychecks the full span once and then zero-fills the full span. This can erase mapped descriptor words. Split the read at mapping boundaries and zero-fill only the unmapped segments.✅ Addressed in commit
3e80e4b@coderabbitai[bot] on GitHub · 2026-10-08 09:24 UTC · original · edited 2026-10-08 09:54 UTC
On
src/graphics/host_gpu/renderer/pipeline/pipelineCache.cppline 122 (outdated):🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 2200
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 8153
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 11473
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 22521
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 22520
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 13836
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 4385
Check GPU mapping before reading backing memory.
TryReadBufferBackingcan read guest backing after GPU mapping is removed.ReadShaderGuestMemorycurrently returns that data before the zero-fill check. Check GPU mapping first so unmapped specialization reads return zeroes.Suggested fix
✅ Addressed in commit
3e80e4b@coderabbitai[bot] on GitHub · 2026-10-08 09:24 UTC · original · reviewed
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
75711bf6-a1ee-4e79-9ae0-2a01d618940c📥 Commits
Reviewing files that changed from the base of the PR and between
5a8808086aand4de2879892.📒 Files selected for processing (6)
src/graphics/host_gpu/rangeSet.hsrc/graphics/host_gpu/renderer/pipeline/pipelineCache.cppsrc/graphics/host_gpu/renderer/renderContext.cppsrc/graphics/host_gpu/renderer/renderContext.hsrc/kernel/memory.cppsrc/kernel/memory.hIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
Pull request closed