graphics: read unmapped guest memory as zeros in the SRT walk #1549
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!1549
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1549/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?
@theantipopau on GitHub · 2026-10-16 02:59 UTC · original
theantipopau:shader-srt-null-read-zero→main· +12 −0 · 1 files · 2 commits · closed without mergingSame direction as #1365: the SRT walk evaluates loads the shader may never execute (e.g. through a null SRT table pointer, the Astro Bot startup shape in #1268/#1528). This gives the pipeline-cache SRT runtime an ordinary reader that zero-fills unmapped guest ranges via TryReadBacking instead of leaving raw host dereferences to fault. Additive, production-path only; no test expectations touched.
@coderabbitai[bot] on GitHub · 2026-10-16 03:02 UTC · original · edited 2026-10-18 23:07 UTC
📝 Walkthrough
The change adds
ReadShaderScalarMemoryto read guest backing memory. If the read fails, it fills the requested values with zero and returnstrue.ProgramCache::Getassigns this function as the runtime scalar-memory callback. The specialization-memory callback remains unchanged.Suggested reviewers:
nmzikPriority: ⬇️ Low
Change: Bug fix
Merge Risk: 🟡 Moderate · up to
795ccThe new shader-table reader correctly returns zeros for unmapped memory. However, it also returns zeros for valid tables in private guest memory and can read stale data that the GPU has modified. Either case can cause shaders to bind the wrong resources and render incorrectly. Both reads should be fixed before merging.
Pre-merge checks:
4 ·
1
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-18 22:18 UTC · original · edited 2026-10-18 23:07 UTC
On
src/graphics/host_gpu/renderer/pipeline/pipelineCache.cppline 121 (outdated):🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
Synchronize GPU-written data before the scalar read.
If the GPU has modified a scalar table,
TryReadBackingcopies its backing bytes without downloading the GPU-dirty bytes. The walker can then use stale values to select resources.TryReadBufferBackingperforms that download when needed; use the synchronized read path for backing mappings while retaining the zero fallback for unmapped addresses. (raw.githubusercontent.com)@coderabbitai[bot] on GitHub · 2026-10-18 22:18 UTC · original · edited 2026-10-18 23:08 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: 17990
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 28297
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 15571
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 19612
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 12110
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 33347
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 16088
Read private guest mappings before zero-filling.
ReadShaderScalarMemorytreats everyTryReadBackingfailure as an unmapped address.TryReadBackingdoes not readMappingType::Privateranges. The merge-base ordinary reader used a raw host read, so valid scalar SRT values in private GPU-mapped ranges can become zero.Use
CopySparseMemory, which handles private and backing mappings, and keep the zero-fill fallback for invalid ranges.Suggested fix
📝 Committable suggestion
✅ Addressed in commit
c09d09c@coderabbitai[bot] on GitHub · 2026-10-18 22:18 UTC · original · reviewed
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
e40d44ce-9ba9-4961-b7a2-073938681b2f📥 Commits
Reviewing files that changed from the base of the PR and between 42c20993e5436107fc307a70a2988e80314edfc6 and
795cc0158d.📒 Files selected for processing: 1
src/graphics/host_gpu/renderer/pipeline/pipelineCache.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.
@JazzzOk on GitHub · 2026-10-18 22:38 UTC · original · approved these changes
Approved in CodeRabbit Change Stack
@JazzzOk on GitHub · 2026-10-18 22:42 UTC · original · approved these changes
Approved in CodeRabbit Change Stack
@theantipopau on GitHub · 2026-10-18 23:07 UTC · original
On
src/graphics/host_gpu/renderer/pipeline/pipelineCache.cppline 122 (outdated):Adopted in
c09d09c9: scalar reads now use CopySparseMemory, which covers private mappings in addition to backing mappings and still reports unmapped ranges as failure (zero-fill preserved, never faults).@theantipopau on GitHub · 2026-10-18 23:07 UTC · original
On
src/graphics/host_gpu/renderer/pipeline/pipelineCache.cppline 121 (outdated):Verified but deferring: GPU-dirty staleness predates this PR (scalar reads were previously a raw host memcpy with no GPU sync either), and switching this speculative walk to the synchronized path would add GPU-download stalls plus GPU-thread constraints to compilation. The zero-fill behavior for unmapped ranges — this PR's purpose — is unaffected either way. Happy to take synchronization as a separate follow-up if a stale-table miscompile is observed.
@coderabbitai[bot] on GitHub · 2026-10-18 23:08 UTC · original
On
src/graphics/host_gpu/renderer/pipeline/pipelineCache.cppline 122 (outdated):@theantipopau Thanks for the fix in
c09d09c9. UsingCopySparseMemoryaddresses the private-mapping concern while preserving the zero-fill fallback for unmapped ranges.If you found this review helpful, would you consider giving us a shout-out on X?
Thank you for using CodeRabbit!
✅ Review thread resolved.
You are interacting with an AI system.
@coderabbitai[bot] on GitHub · 2026-10-18 23:08 UTC · original
On
src/graphics/host_gpu/renderer/pipeline/pipelineCache.cppline 121 (outdated):@theantipopau Thanks for the clarification. The GPU-dirty staleness is pre-existing, not a regression from this PR. Deferring synchronization is reasonable because it adds GPU-download stalls and GPU-thread constraints to the speculative walk.
Would you like me to open a follow-up GitHub issue?
✏️ Learnings added
You are interacting with an AI system.
@Nmzik on GitHub · 2026-10-21 19:42 UTC · original
Duplicate of #1365.
Pull request closed