graphics: read unmapped shader resource memory as zero #1194

Closed
github-bot wants to merge 2 commits from gh-pr/1194/head into gh-pr/1194/base
Owner

@⁠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 merging

Summary

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 walker memcpys 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.

  • Ordinary SRT loads get a reader. Both readers return zeros (a null descriptor) for memory the guest has not mapped for the GPU; mapped memory is read exactly as before.
  • RenderContext::IsMapped keeps 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

  • Before: crash during boot.
  • After: the game runs past it (125 s with no crash).
  • Tests: no change.

Testing

Hardware and software:

  • CPU: Intel Core i9-9940X (14 cores, 28 threads)
  • GPU: AMD Radeon RX 6950 XT, driver 32.0.21045.5002 (amdvlk)
  • RAM: 32 GB
  • OS: Windows 11 Pro 10.0.26200
  • Build: Release, clang-cl, based on main at 5a880808

Tests: ctest -j 1 on this branch against unmodified main 5a880808 on 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

**@⁠akar995** on GitHub · 2026-10-08 09:15 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1194) `akar995:fix/srt-unmapped-shader-reads` → `main` · +92 −3 · 6 files · 2 commits · closed without merging ## Summary 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 walker `memcpy`s 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. - Ordinary SRT loads get a reader. Both readers return zeros (a null descriptor) for memory the guest has not mapped for the GPU; mapped memory is read exactly as before. - `RenderContext::IsMapped` keeps 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 - Before: crash during boot. - After: the game runs past it (125 s with no crash). - Tests: no change. ## Testing Hardware and software: - CPU: Intel Core i9-9940X (14 cores, 28 threads) - GPU: AMD Radeon RX 6950 XT, driver 32.0.21045.5002 (amdvlk) - RAM: 32 GB - OS: Windows 11 Pro 10.0.26200 - Build: Release, clang-cl, based on main at 5a880808 Tests: `ctest -j 1` on this branch against unmodified main 5a880808 on 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](https://claude.com/claude-code)
Resource tables can hold stale or null pointers that a shader only
follows on paths the game never takes. Evaluating them on the host
dereferenced the raw guest address: ordinary SRT loads had no reader
and fell back to a memcpy from the guest pointer. Astro Bot
(PPSA21567) crashes this way while booting, with an access violation
at address 0x18 inside SrtWalker::EvaluateRawRead.

Give the walker a reader for ordinary loads, and let both readers
return zeros (a null descriptor) for memory the guest has not mapped
for the GPU. Mapped memory is read as before. RenderContext::IsMapped
remembers the last mapping each thread found, keyed by an unmap
generation, so the extra check on every walk read stays cheap.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Check the GPU mapping before reading backing memory, so a range whose
GPU mapping was removed reads as zero even while its backing remains.
A read that crosses the end of a mapping now keeps its mapped words and
zero-fills only the rest.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:47:14 +00:00
github-bot closed this pull request 2026-11-26 09:47:14 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-08 09:24 UTC · original · edited 2026-10-08 10:00 UTC

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 254051a9-fac9-4864-a710-d5381ad3f840
📥 Commits

Reviewing files that changed from the base of the PR and between 4de2879892 and 3e80e4b71f.

📒 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)
  • src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp

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_memory and the guest-memory reader for specialization reads.

Priority: ➖ Normal

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 3e80e

No actionable issue remains from the reviewed changes; the PR is mergeable after normal checks.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.53% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 19 functions across 6 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: reading unmapped shader resource memory as zero.
Description check ✅ Passed The description explains the crash, the reader and mapping changes, the reported result, and the test status. It is directly related to the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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 help to get the list of available commands.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-08 09:24 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1194#issuecomment-6056813989) · edited 2026-10-08 10:00 UTC <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/1194?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=2" alt="Review in Change Stack →" width="220" height="32"></a> <!-- review_stack_entry_end --> <!-- recent_review_start --> No actionable comments were generated in the recent review. 🎉 <details> <summary>ℹ️ Recent review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `254051a9-fac9-4864-a710-d5381ad3f840` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 4de2879892c6373b86a5c9656ce2f5063f0a1bfd and 3e80e4b71fa2111101bcd66695605a1e0d3449ff. </details> <details> <summary>📒 Files selected for processing (1)</summary> * `src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp` </details> <details> <summary>🚧 Files skipped from review as they are similar to previous changes (1)</summary> * src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 2 remain after this review. </details> --- <!-- recent_review_end --> <!-- walkthrough_start --> <details> <summary>📝 Walkthrough</summary> ## 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_memory` and the guest-memory reader for specialization reads. </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ➖ Normal <!-- change_assessment_commit:"3e80e4b71fa2111101bcd66695605a1e0d3449ff" --> **Change:** Bug fix <!-- change_assessment_end --> <!-- final_review_risk_start --> **Merge Risk:** **⚪ Minimal** · up to `3e80e` <!-- final_review_risk_coverage:{"sourceCommitId":"3e80e4b71fa2111101bcd66695605a1e0d3449ff","coveredCommitId":"3e80e4b71fa2111101bcd66695605a1e0d3449ff","kind":"reviewed"} --> No actionable issue remains from the reviewed changes; the PR is mergeable after normal checks. <!-- final_review_risk_end --> <!-- pre_merge_checks_walkthrough_start --> <details> <summary>🚥 Pre-merge checks | ✅ 4 | ❌ 1</summary> ### ❌ Failed checks (1 warning) | Check name | Status | Explanation | Resolution | | :---------------- | :--------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :--------------------------------------------------------------------------------- | | Docstring Coverage | ⚠️ Warning | Docstring coverage is 10.53% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 19 functions across 6 files. | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary>✅ Passed checks (4 passed)</summary> | Check name | Status | Explanation | | :------------------------ | :------- | :----------------------------------------------------------------------------------------------------------------------------------------------------- | | Title check | ✅ Passed | The title clearly and concisely describes the main change: reading unmapped shader resource memory as zero. | | Description check | ✅ Passed | The description explains the crash, the reader and mapping changes, the reported result, and the test status. It is directly related to the changeset. | | Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. | </details> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- autopilot:start --> - [ ] <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autopilot</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts <!-- autopilot:end --> <!-- tips_start --> --- Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=1194)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary>❤️ Share</summary> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
Author
Owner

@⁠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.cpp line 113 (outdated):

@@ -103,11 +103,33 @@ void PipelineCacheLog(fmt::format_string<Args...> format, Args&&... args) {
 	Log::WriteToConsoleAndLog(message);
 }
 
+// Resource tables can hold a stale or null pointer that the shader only follows on paths the
+// game never takes. Unmapped memory reads as zero (a null descriptor) instead of failing, or
+// faulting on the host.
+bool ReadUnmappedShaderMemory(uint64_t address, std::span<uint32_t> values) {
+	if (Libs::LibKernel::Memory::IsGpuMapped(address, values.size_bytes())) {
+		return false;
+	}
+	std::ranges::fill(values, 0u);

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
# Inspect calls to the SrtRuntime readers and the span sizes they pass.
rg -n -C 5 'read_specialization_memory\s*\(|read_memory\s*\(' src/graphics/shader/recompiler

Repository: KytyPS5/KytyPS5

Length of output: 3777


🏁 Script executed:

set -eu
printf '%s\n' '--- changed reader definitions and surrounding code ---'
rg -n -C 18 -- 'ReadUnmappedShaderMemory|ReadShaderGuestMemory|ReadShaderOrdinaryMemory|read_memory|read_specialization_memory' src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp src/graphics/shader/recompiler src/graphics | head -n 360
printf '%s\n' '--- SrtRuntime declarations ---'
rg -n -C 12 -- 'struct SrtRuntime|class SrtRuntime|SrtRuntime' src/graphics/shader/recompiler src/graphics | head -n 260
printf '%s\n' '--- diff for the cited file ---'
git diff 5a8808086a9815b67d4822cd20cf1e8a7a05f002 4de2879892c6373b86a5c9656ce2f5063f0a1bfd -- src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp

Repository: KytyPS5/KytyPS5

Length of output: 42108


🏁 Script executed:

set -eu
printf '%s\n' '--- ResourceMaterialization callback blocks and callers ---'
sed -n '135,180p' src/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cpp
rg -n -C 8 -- 'CaptureOrdinaryRead|CaptureStrictRead|read_memory\s*\(|read_specialization_memory\s*\(' src/graphics/shader/recompiler
printf '%s\n' '--- all SrtRuntime callback invocations in the recompiler ---'
rg -n -C 5 -- 'm_runtime\.(read_memory|read_specialization_memory)|runtime\.(read_memory|read_specialization_memory)|source\.(read_memory|read_specialization_memory)' src/graphics/shader/recompiler
printf '%s\n' '--- raw-read implementation ---'
sed -n '475,535p' src/graphics/shader/recompiler/ir/passes/SrtWalker.cpp

Repository: KytyPS5/KytyPS5

Length of output: 21969


🏁 Script executed:

set -eu
printf '%s\n' '--- ReadWords definition and callers ---'
rg -n -C 14 -- 'ReadWords\s*\(' src/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cpp
printf '%s\n' '--- enclosing materialization logic ---'
sed -n '180,235p' src/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cpp

Repository: KytyPS5/KytyPS5

Length of output: 194


🏁 Script executed:

printf '%s\n' '--- source around the multiword prefix ---'
nl -ba src/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cpp | sed -n '180,230p'
printf '%s\n' '--- nearby helper and call references ---'
rg -n -C 10 -- 'words\.first|prefix\.size_bytes|runtime\.read_specialization_memory' src/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cpp || test "$?" -eq 1

Repository: KytyPS5/KytyPS5

Length of output: 5065


🏁 Script executed:

set -eu
printf '%s\n' '--- IsGpuMapped and TryReadBufferBacking definitions ---'
rg -n -C 18 -- 'IsGpuMapped\s*\(|TryReadBufferBacking\s*\(' src
printf '%s\n' '--- declarations if definitions are outside src matches ---'
rg -n -C 8 -- 'IsGpuMapped|TryReadBufferBacking' src/graphics src/core src/libs || test "$?" -eq 1

Repository: KytyPS5/KytyPS5

Length of output: 14191


🏁 Script executed:

set -eu
printf '%s\n' '--- all TryReadBacking declarations and definitions ---'
rg -n -C 16 -- 'TryReadBacking\s*\(' .

Repository: KytyPS5/KytyPS5

Length of output: 42350


Preserve mapped words in multiword scalar-table reads.

ReadScalarTable can pass multiple words to read_specialization_memory. If TryReadBufferBacking returns false for a range that crosses a GPU mapping boundary, ReadUnmappedShaderMemory checks 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](https://github.com/KytyPS5/KytyPS5/pull/1194#discussion_r4217198034) · edited 2026-10-08 09:54 UTC On `src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp` line 113 (outdated): ```diff @@ -103,11 +103,33 @@ void PipelineCacheLog(fmt::format_string<Args...> format, Args&&... args) { Log::WriteToConsoleAndLog(message); } +// Resource tables can hold a stale or null pointer that the shader only follows on paths the +// game never takes. Unmapped memory reads as zero (a null descriptor) instead of failing, or +// faulting on the host. +bool ReadUnmappedShaderMemory(uint64_t address, std::span<uint32_t> values) { + if (Libs::LibKernel::Memory::IsGpuMapped(address, values.size_bytes())) { + return false; + } + std::ranges::fill(values, 0u); ``` **🎯 Functional Correctness** | **🟠 Major** | **🏗️ Heavy lift** <details> <summary>🔎 Supported by static analysis</summary> 🏁 Script executed: ```bash #!/bin/bash # Inspect calls to the SrtRuntime readers and the span sizes they pass. rg -n -C 5 'read_specialization_memory\s*\(|read_memory\s*\(' src/graphics/shader/recompiler ``` Repository: KytyPS5/KytyPS5 Length of output: 3777 --- 🏁 Script executed: ```bash set -eu printf '%s\n' '--- changed reader definitions and surrounding code ---' rg -n -C 18 -- 'ReadUnmappedShaderMemory|ReadShaderGuestMemory|ReadShaderOrdinaryMemory|read_memory|read_specialization_memory' src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp src/graphics/shader/recompiler src/graphics | head -n 360 printf '%s\n' '--- SrtRuntime declarations ---' rg -n -C 12 -- 'struct SrtRuntime|class SrtRuntime|SrtRuntime' src/graphics/shader/recompiler src/graphics | head -n 260 printf '%s\n' '--- diff for the cited file ---' git diff 5a8808086a9815b67d4822cd20cf1e8a7a05f002 4de2879892c6373b86a5c9656ce2f5063f0a1bfd -- src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 42108 --- 🏁 Script executed: ```bash set -eu printf '%s\n' '--- ResourceMaterialization callback blocks and callers ---' sed -n '135,180p' src/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cpp rg -n -C 8 -- 'CaptureOrdinaryRead|CaptureStrictRead|read_memory\s*\(|read_specialization_memory\s*\(' src/graphics/shader/recompiler printf '%s\n' '--- all SrtRuntime callback invocations in the recompiler ---' rg -n -C 5 -- 'm_runtime\.(read_memory|read_specialization_memory)|runtime\.(read_memory|read_specialization_memory)|source\.(read_memory|read_specialization_memory)' src/graphics/shader/recompiler printf '%s\n' '--- raw-read implementation ---' sed -n '475,535p' src/graphics/shader/recompiler/ir/passes/SrtWalker.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 21969 --- 🏁 Script executed: ```bash set -eu printf '%s\n' '--- ReadWords definition and callers ---' rg -n -C 14 -- 'ReadWords\s*\(' src/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cpp printf '%s\n' '--- enclosing materialization logic ---' sed -n '180,235p' src/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 194 --- 🏁 Script executed: ```bash printf '%s\n' '--- source around the multiword prefix ---' nl -ba src/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cpp | sed -n '180,230p' printf '%s\n' '--- nearby helper and call references ---' rg -n -C 10 -- 'words\.first|prefix\.size_bytes|runtime\.read_specialization_memory' src/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cpp || test "$?" -eq 1 ``` Repository: KytyPS5/KytyPS5 Length of output: 5065 --- 🏁 Script executed: ```bash set -eu printf '%s\n' '--- IsGpuMapped and TryReadBufferBacking definitions ---' rg -n -C 18 -- 'IsGpuMapped\s*\(|TryReadBufferBacking\s*\(' src printf '%s\n' '--- declarations if definitions are outside src matches ---' rg -n -C 8 -- 'IsGpuMapped|TryReadBufferBacking' src/graphics src/core src/libs || test "$?" -eq 1 ``` Repository: KytyPS5/KytyPS5 Length of output: 14191 --- 🏁 Script executed: ```bash set -eu printf '%s\n' '--- all TryReadBacking declarations and definitions ---' rg -n -C 16 -- 'TryReadBacking\s*\(' . ``` Repository: KytyPS5/KytyPS5 Length of output: 42350 --- </details> **Preserve mapped words in multiword scalar-table reads.** `ReadScalarTable` can pass multiple words to `read_specialization_memory`. If `TryReadBufferBacking` returns false for a range that crosses a GPU mapping boundary, `ReadUnmappedShaderMemory` checks 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. <!-- fingerprinting:phantom:poseidon:wombat --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:23b935b929156c0066b83e6b --> <!-- This is an auto-generated comment by CodeRabbit --> ✅ Addressed in commit 3e80e4b
Author
Owner

@⁠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.cpp line 122 (outdated):

@@ -103,11 +103,33 @@ void PipelineCacheLog(fmt::format_string<Args...> format, Args&&... args) {
 	Log::WriteToConsoleAndLog(message);
 }
 
+// Resource tables can hold a stale or null pointer that the shader only follows on paths the
+// game never takes. Unmapped memory reads as zero (a null descriptor) instead of failing, or
+// faulting on the host.
+bool ReadUnmappedShaderMemory(uint64_t address, std::span<uint32_t> values) {
+	if (Libs::LibKernel::Memory::IsGpuMapped(address, values.size_bytes())) {
+		return false;
+	}
+	std::ranges::fill(values, 0u);
+	return true;
+}
+
 bool ReadShaderGuestMemory(void*, uint64_t address, std::span<uint32_t> values) {
 	// Scalar and unformatted buffer dependencies use the same backing as native raw loads.
 	// Image synchronization belongs to formatted buffer bindings, not these reads.
-	return !values.empty() &&
-	       Libs::LibKernel::Memory::TryReadBufferBacking(address, values.data(), values.size_bytes());
+	return !values.empty() && (Libs::LibKernel::Memory::TryReadBufferBacking(address, values.data(),
+	                                                                         values.size_bytes()) ||
+	                           ReadUnmappedShaderMemory(address, values));

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '95,138p' src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp
rg -n 'TryReadBufferBacking' src/graphics src/kernel

Repository: KytyPS5/KytyPS5

Length of output: 2200


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- memory declarations and implementations ---'
sed -n '80,135p' src/kernel/memory.h
sed -n '800,925p' src/kernel/memory.cpp
printf '%s\n' '--- mapping-related definitions and uses ---'
rg -n -F -- 'IsGpuMapped' src/kernel src/graphics
printf '%s\n' '--- shader reader wiring and specialization calls ---'
rg -n -F -- 'ReadShaderGuestMemory' src
rg -n -F -- 'read_memory' src/graphics/host_gpu/renderer/pipeline

Repository: KytyPS5/KytyPS5

Length of output: 8153


🏁 Script executed:

sed -n '840,915p' src/kernel/memory.cpp
sed -n '100,125p' src/kernel/memory.h
rg -n -C 8 -F -- 'IsGpuMapped' src/kernel src/graphics
rg -n -C 6 -F -- 'ReadShaderGuestMemory' src

Repository: KytyPS5/KytyPS5

Length of output: 11473


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- TryReadBacking definitions and owner ---'
rg -n -C 10 -F -- 'TryReadBacking' src
printf '%s\n' '--- GPU address-range and mapping definitions ---'
rg -n -C 10 -F -- 'IsGpuAddressRange' src
rg -n -C 10 -F -- 'bool IsMapped' src/graphics src/kernel
printf '%s\n' '--- GPU map registration paths ---'
rg -n -C 6 -E 'MapGpu|UnmapGpu|IsMapped\\(' src/graphics src/kernel

Repository: KytyPS5/KytyPS5

Length of output: 22521


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- TryReadBacking definitions and owner ---'
rg -n -C 10 -F -- 'TryReadBacking' src
printf '%s\n' '--- GPU address-range and mapping definitions ---'
rg -n -C 10 -F -- 'IsGpuAddressRange' src
rg -n -C 10 -F -- 'bool IsMapped' src/graphics src/kernel
printf '%s\n' '--- GPU map registration paths ---'
rg -n -C 6 -E 'MapGpu|UnmapGpu|IsMapped\(' src/graphics src/kernel

Repository: KytyPS5/KytyPS5

Length of output: 22520


🏁 Script executed:

set -o pipefail
sed -n '180,245p' src/kernel/memoryAddressSpace.inc
printf '%s\n' '--- backing map setup and GPU mapping call sites ---'
rg -n -C 5 -F -- 'MapGpuRange' src/kernel/memory.cpp
rg -n -C 5 -F -- 'UnmapGpuRange' src/kernel/memory.cpp
rg -n -C 5 -F -- 'MapMemory(' src/graphics/host_gpu/renderer/renderContext.cpp src/graphics/host_gpu/renderer/renderContext.h

Repository: KytyPS5/KytyPS5

Length of output: 13836


🏁 Script executed:

set -o pipefail
sed -n '235,265p' src/kernel/memoryAddressSpace.inc
sed -n '3895,3975p' src/kernel/memory.cpp

Repository: KytyPS5/KytyPS5

Length of output: 4385


Check GPU mapping before reading backing memory.

TryReadBufferBacking can read guest backing after GPU mapping is removed. ReadShaderGuestMemory currently returns that data before the zero-fill check. Check GPU mapping first so unmapped specialization reads return zeroes.

Suggested fix
-	return !values.empty() && (Libs::LibKernel::Memory::TryReadBufferBacking(address, values.data(),
-	                                                                         values.size_bytes()) ||
-	                           ReadUnmappedShaderMemory(address, values));
+	return !values.empty() &&
+	       (ReadUnmappedShaderMemory(address, values) ||
+	        Libs::LibKernel::Memory::TryReadBufferBacking(address, values.data(),
+	                                                      values.size_bytes()));

✅ Addressed in commit 3e80e4b

**@⁠coderabbitai[bot]** on GitHub · 2026-10-08 09:24 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1194#discussion_r4217198046) · edited 2026-10-08 09:54 UTC On `src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp` line 122 (outdated): ```diff @@ -103,11 +103,33 @@ void PipelineCacheLog(fmt::format_string<Args...> format, Args&&... args) { Log::WriteToConsoleAndLog(message); } +// Resource tables can hold a stale or null pointer that the shader only follows on paths the +// game never takes. Unmapped memory reads as zero (a null descriptor) instead of failing, or +// faulting on the host. +bool ReadUnmappedShaderMemory(uint64_t address, std::span<uint32_t> values) { + if (Libs::LibKernel::Memory::IsGpuMapped(address, values.size_bytes())) { + return false; + } + std::ranges::fill(values, 0u); + return true; +} + bool ReadShaderGuestMemory(void*, uint64_t address, std::span<uint32_t> values) { // Scalar and unformatted buffer dependencies use the same backing as native raw loads. // Image synchronization belongs to formatted buffer bindings, not these reads. - return !values.empty() && - Libs::LibKernel::Memory::TryReadBufferBacking(address, values.data(), values.size_bytes()); + return !values.empty() && (Libs::LibKernel::Memory::TryReadBufferBacking(address, values.data(), + values.size_bytes()) || + ReadUnmappedShaderMemory(address, values)); ``` **🎯 Functional Correctness** | **🟠 Major** | **⚡ Quick win** <details> <summary>🔎 Supported by static analysis</summary> 🏁 Script executed: ```bash sed -n '95,138p' src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp rg -n 'TryReadBufferBacking' src/graphics src/kernel ``` Repository: KytyPS5/KytyPS5 Length of output: 2200 --- 🏁 Script executed: ```bash set -o pipefail printf '%s\n' '--- memory declarations and implementations ---' sed -n '80,135p' src/kernel/memory.h sed -n '800,925p' src/kernel/memory.cpp printf '%s\n' '--- mapping-related definitions and uses ---' rg -n -F -- 'IsGpuMapped' src/kernel src/graphics printf '%s\n' '--- shader reader wiring and specialization calls ---' rg -n -F -- 'ReadShaderGuestMemory' src rg -n -F -- 'read_memory' src/graphics/host_gpu/renderer/pipeline ``` Repository: KytyPS5/KytyPS5 Length of output: 8153 --- 🏁 Script executed: ```bash sed -n '840,915p' src/kernel/memory.cpp sed -n '100,125p' src/kernel/memory.h rg -n -C 8 -F -- 'IsGpuMapped' src/kernel src/graphics rg -n -C 6 -F -- 'ReadShaderGuestMemory' src ``` Repository: KytyPS5/KytyPS5 Length of output: 11473 --- 🏁 Script executed: ```bash set -o pipefail printf '%s\n' '--- TryReadBacking definitions and owner ---' rg -n -C 10 -F -- 'TryReadBacking' src printf '%s\n' '--- GPU address-range and mapping definitions ---' rg -n -C 10 -F -- 'IsGpuAddressRange' src rg -n -C 10 -F -- 'bool IsMapped' src/graphics src/kernel printf '%s\n' '--- GPU map registration paths ---' rg -n -C 6 -E 'MapGpu|UnmapGpu|IsMapped\\(' src/graphics src/kernel ``` Repository: KytyPS5/KytyPS5 Length of output: 22521 --- 🏁 Script executed: ```bash set -o pipefail printf '%s\n' '--- TryReadBacking definitions and owner ---' rg -n -C 10 -F -- 'TryReadBacking' src printf '%s\n' '--- GPU address-range and mapping definitions ---' rg -n -C 10 -F -- 'IsGpuAddressRange' src rg -n -C 10 -F -- 'bool IsMapped' src/graphics src/kernel printf '%s\n' '--- GPU map registration paths ---' rg -n -C 6 -E 'MapGpu|UnmapGpu|IsMapped\(' src/graphics src/kernel ``` Repository: KytyPS5/KytyPS5 Length of output: 22520 --- 🏁 Script executed: ```bash set -o pipefail sed -n '180,245p' src/kernel/memoryAddressSpace.inc printf '%s\n' '--- backing map setup and GPU mapping call sites ---' rg -n -C 5 -F -- 'MapGpuRange' src/kernel/memory.cpp rg -n -C 5 -F -- 'UnmapGpuRange' src/kernel/memory.cpp rg -n -C 5 -F -- 'MapMemory(' src/graphics/host_gpu/renderer/renderContext.cpp src/graphics/host_gpu/renderer/renderContext.h ``` Repository: KytyPS5/KytyPS5 Length of output: 13836 --- 🏁 Script executed: ```bash set -o pipefail sed -n '235,265p' src/kernel/memoryAddressSpace.inc sed -n '3895,3975p' src/kernel/memory.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 4385 --- </details> **Check GPU mapping before reading backing memory.** `TryReadBufferBacking` can read guest backing after GPU mapping is removed. `ReadShaderGuestMemory` currently returns that data before the zero-fill check. Check GPU mapping first so unmapped specialization reads return zeroes. <details> <summary>Suggested fix</summary> ```diff - return !values.empty() && (Libs::LibKernel::Memory::TryReadBufferBacking(address, values.data(), - values.size_bytes()) || - ReadUnmappedShaderMemory(address, values)); + return !values.empty() && + (ReadUnmappedShaderMemory(address, values) || + Libs::LibKernel::Memory::TryReadBufferBacking(address, values.data(), + values.size_bytes())); ``` </details> <!-- fingerprinting:phantom:medusa:wombat --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:2ad84588f253d7b5fed73b3a --> <!-- This is an auto-generated comment by CodeRabbit --> ✅ Addressed in commit 3e80e4b
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-08 09:24 UTC · original · reviewed

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 75711bf6-a1ee-4e79-9ae0-2a01d618940c
📥 Commits

Reviewing files that changed from the base of the PR and between 5a8808086a and 4de2879892.

📒 Files selected for processing (6)
  • src/graphics/host_gpu/rangeSet.h
  • src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp
  • src/graphics/host_gpu/renderer/renderContext.cpp
  • src/graphics/host_gpu/renderer/renderContext.h
  • src/kernel/memory.cpp
  • src/kernel/memory.h

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-08 09:24 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1194#pullrequestreview-5454443164) · **reviewed** **Actionable comments posted: 2** --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `75711bf6-a1ee-4e79-9ae0-2a01d618940c` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 5a8808086a9815b67d4822cd20cf1e8a7a05f002 and 4de2879892c6373b86a5c9656ce2f5063f0a1bfd. </details> <details> <summary>📒 Files selected for processing (6)</summary> * `src/graphics/host_gpu/rangeSet.h` * `src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp` * `src/graphics/host_gpu/renderer/renderContext.cpp` * `src/graphics/host_gpu/renderer/renderContext.h` * `src/kernel/memory.cpp` * `src/kernel/memory.h` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=1152ff2c-d129-4d05-9f62-aa321f730bd4 attempt=565a0ca9-8b31-49b2-b74a-eff7d1ccb8df batch=1/1 -->

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.