shader: support GPU-selected buffer loads and packed image reads #976

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

@⁠tototomate123 on GitHub · 2026-10-02 14:23 UTC · original
tototomate123:fix/rdna2-shader-compatibility → main · +272 −57 · 13 files · 3 commits · closed without merging

Groups shader fixes encountered during HFW bring-up, with separate commits for each change.

  • Support scalar DWORD loads from GPU-selected buffer descriptors.
  • Implement IMAGE_LOAD_PCK for 32-bit texels (DMASK=1), preserving raw bits through an identity R32_UINT view.
  • Support dynamic BUFFER_LOAD_FORMAT_X/XY/XYZ/XYZW for complete 32-bit channels with identity selection and combined bounds checks.

Sources: AMD RDNA2 ISA XML (amdgpu_isa_rdna2.xml), SPIR-V scalar/vector rules, and image fetch semantics.

Validation: Linux/Clang build, eight focused GPU cases, CFG, resource-tracking, and materialization tests pass. The full compute suite hits Pm4NativeTargetGeometry, also reproduced on unchanged main (e317465).

AI-assisted implementation.

**@⁠tototomate123** on GitHub · 2026-10-02 14:23 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/976) `tototomate123:fix/rdna2-shader-compatibility` → `main` · +272 −57 · 13 files · 3 commits · closed without merging Groups shader fixes encountered during HFW bring-up, with separate commits for each change. - Support scalar DWORD loads from GPU-selected buffer descriptors. - Implement `IMAGE_LOAD_PCK` for 32-bit texels (`DMASK=1`), preserving raw bits through an identity `R32_UINT` view. - Support dynamic `BUFFER_LOAD_FORMAT_X/XY/XYZ/XYZW` for complete 32-bit channels with identity selection and combined bounds checks. Sources: [AMD RDNA2 ISA XML](https://gpuopen.com/download/AMD_GPU_MR_ISA_XML_2026_08_06.zip) (`amdgpu_isa_rdna2.xml`), [SPIR-V scalar/vector rules](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#OpTypeVector), and [image fetch semantics](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#OpImageFetch). Validation: Linux/Clang build, eight focused GPU cases, CFG, resource-tracking, and materialization tests pass. The full compute suite hits `Pm4NativeTargetGeometry`, also reproduced on unchanged main (`e317465`). AI-assisted implementation.
Extend the existing raw x2/x3/x4 descriptor path to x1 without constructing an invalid one-component SPIR-V vector. Preserve EXEC, address swizzling and per-component bounds checks. Exercise GPU-selected scalar reads across the existing descriptor addressing fixtures.
Decode IMAGE_LOAD_PCK and distinguish packed from converted image resources. Use an identity R32_UINT view and bypass shader unpacking for the supported single-DWORD form; retain explicit rejection of other widths. Preserve upstream signed atomic, BVH and specialization changes. Add a packed-float-format GPU readback and DMASK decode regressions.
Group FORMAT_X/XY/XYZ/XYZW support in the dynamic descriptor path. Permit only identity-selected complete 32-bit UInt/SInt/Float channels; unsupported layouts return zero. Check every requested channel before a formatted read while retaining per-component raw-load bounds. Add GPU-selected full/partial/unbound/unsupported-format/swizzle regressions for each width.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:38:58 +00:00
github-bot closed this pull request 2026-11-26 09:38:58 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-02 14:57 UTC · original · edited 2026-10-02 14:59 UTC

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

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: 2acce748-3d89-4640-8864-0aa3e73b3679

📥 Commits

Reviewing files that changed from the base of the PR and between e317465d8a and 140ca9fae7.

📒 Files selected for processing (13)
  • src/graphics/host_gpu/renderer/pipeline/descriptors.cpp
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterImage.cpp
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cpp
  • src/graphics/shader/recompiler/frontend/decode/ImageOps.cpp
  • src/graphics/shader/recompiler/frontend/decode/ShaderDecoder.cpp
  • src/graphics/shader/recompiler/frontend/decode/ShaderDecoder.h
  • src/graphics/shader/recompiler/frontend/translate/Memory.cpp
  • src/graphics/shader/recompiler/ir/ShaderIR.h
  • src/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cpp
  • src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp
  • tests/ResourceTrackingTests.cpp
  • tests/ShaderRecompilerComputeTests.cpp
  • tests/shaderCfgTests.cpp

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


📝 Walkthrough

Walkthrough

The change adds packed image-load decoding and carries packed-image metadata through resource specialization and image reads. It also expands GPU-selected indirect-buffer loads to support scalar and formatted loads, with descriptor and bounds validation. Tests cover both paths.

Suggested reviewers: nmzik, brandostrong, techx3

Priority: ⬇️ Low

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 140ca

The packed image load does not use a sampler, so the reported filtering issue does not block merge. No other actionable merge risk is established.

Security Architecture Review

Security architecture risk: 🟡 Moderate · up to 140ca

A potential disagreement in handling newly supported image formats can cause application-wide failure. The expanded buffer reads retain important checks, but their memory-isolation guarantees are not fully established.

Retained concerns

  • Medium · reliability · inferred: Packed specialization accepts four-byte texel formats and forces their numeric class to Uint, but sampled binding still requires the original format's numeric class. For a non-Uint format, specialized metadata reaching this binding path would trigger application termination before the intended R32_UINT view is selected. This is a cross-stage representation and failure-containment conflict; its complete runtime reachability and change in effective failure exposure remain unresolved.
Security review details

Security Blast Radius

  • inferred — The relevant attacker-controlled inputs are guest shader instructions, descriptor words, and address operands. Potential outcomes are GPU memory reads and renderer-process failure. The inspected path does not establish a tenant or service boundary; maximum physical memory exposure remains unresolved because descriptor-to-allocation containment and page-table range enforcement were not demonstrated.

Security Findings and Attack Paths

  • inferred — The unresolved packed-image path is an accepted four-byte non-Uint format, followed by Uint specialization, followed by original-format numeric validation at binding. If those specialized fields reach ResolveTexture, the mismatch invokes a process-fatal handler. This is a potential failure-containment problem, not a verified new security attack capability; the end-to-end handoff and prior rejection outcome remain unproven.

Trust Boundaries and Controls

  • observed — Formatted reads require compatible formats and identity selectors before memory access. They combine component bounds before loading, while execution gating supplies zero defaults for inactive loads. Missing translated pages return a zero pointer, which prevents the subsequent physical load; these controls do not by themselves prove allocation-level isolation.

Resilience and Maintainability Implications

  • observed — Image replacement marks bindings for rebind, views are reacquired from the owning image, and image destruction releases its cached views. Validation failures using EXIT are terminal rather than recoverable: the handler returns a nonzero value and the macro invokes emergency shutdown and std::_Exit. Consequently, the inspected validation path does not resume with a partially populated cache.
🚥 Pre-merge checks | ✅ 4 | ❓ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ❓ Inconclusive Docstring coverage is 5.26% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 19 functions across 11 files. (2 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly summarizes the main changes: GPU-selected buffer loads and packed image reads.
Description check ✅ Passed The description directly explains the implemented shader features, supporting sources, validation results, and known full-suite limitation.
Full details: Docstring Coverage

Explanation

Docstring coverage is 5.26% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 19 functions across 11 files. (2 skipped: 2 too large.)

  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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-02 14:57 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/976#issuecomment-5955127144) · edited 2026-10-02 14:59 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/976?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> Navigate logical layers of code changes, visualize relationships, and explore their blast radius. <!-- 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**: `2acce748-3d89-4640-8864-0aa3e73b3679` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between e317465d8a773b33482ad367ad2f856154c8bc6d and 140ca9fae79b10f884d3b39d53788b30f19d7826. </details> <details> <summary>📒 Files selected for processing (13)</summary> * `src/graphics/host_gpu/renderer/pipeline/descriptors.cpp` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterImage.cpp` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cpp` * `src/graphics/shader/recompiler/frontend/decode/ImageOps.cpp` * `src/graphics/shader/recompiler/frontend/decode/ShaderDecoder.cpp` * `src/graphics/shader/recompiler/frontend/decode/ShaderDecoder.h` * `src/graphics/shader/recompiler/frontend/translate/Memory.cpp` * `src/graphics/shader/recompiler/ir/ShaderIR.h` * `src/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cpp` * `src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp` * `tests/ResourceTrackingTests.cpp` * `tests/ShaderRecompilerComputeTests.cpp` * `tests/shaderCfgTests.cpp` </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> --- <!-- recent_review_end --> <!-- walkthrough_start --> <details> <summary>📝 Walkthrough</summary> ## Walkthrough The change adds packed image-load decoding and carries packed-image metadata through resource specialization and image reads. It also expands GPU-selected indirect-buffer loads to support scalar and formatted loads, with descriptor and bounds validation. Tests cover both paths. **Suggested reviewers:** `nmzik`, `brandostrong`, `techx3` </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ⬇️ Low <!-- change_assessment_commit:"140ca9fae79b10f884d3b39d53788b30f19d7826" --> **Change:** Bug fix <!-- change_assessment_end --> <!-- final_review_risk_start --> **Merge Risk:** _⚪ Minimal_ · up to `140ca` <!-- final_review_risk_coverage:{"sourceCommitId":"140ca9fae79b10f884d3b39d53788b30f19d7826","coveredCommitId":"140ca9fae79b10f884d3b39d53788b30f19d7826","kind":"reviewed"} --> The packed image load does not use a sampler, so the reported filtering issue does not block merge. No other actionable merge risk is established. <!-- final_review_risk_end --> <!-- architecture_review_start --> ### Security Architecture Review **Security architecture risk:** _🟡 Moderate_ · up to `140ca` A potential disagreement in handling newly supported image formats can cause application-wide failure. The expanded buffer reads retain important checks, but their memory-isolation guarantees are not fully established. **Retained concerns** - **Medium · reliability · inferred:** Packed specialization accepts four-byte texel formats and forces their numeric class to Uint, but sampled binding still requires the original format's numeric class. For a non-Uint format, specialized metadata reaching this binding path would trigger application termination before the intended R32_UINT view is selected. This is a cross-stage representation and failure-containment conflict; its complete runtime reachability and change in effective failure exposure remain unresolved. <details> <summary>Security review details</summary> **Security Blast Radius** - _inferred_ — The relevant attacker-controlled inputs are guest shader instructions, descriptor words, and address operands. Potential outcomes are GPU memory reads and renderer-process failure. The inspected path does not establish a tenant or service boundary; maximum physical memory exposure remains unresolved because descriptor-to-allocation containment and page-table range enforcement were not demonstrated. **Security Findings and Attack Paths** - _inferred_ — The unresolved packed-image path is an accepted four-byte non-Uint format, followed by Uint specialization, followed by original-format numeric validation at binding. If those specialized fields reach ResolveTexture, the mismatch invokes a process-fatal handler. This is a potential failure-containment problem, not a verified new security attack capability; the end-to-end handoff and prior rejection outcome remain unproven. **Trust Boundaries and Controls** - _observed_ — Formatted reads require compatible formats and identity selectors before memory access. They combine component bounds before loading, while execution gating supplies zero defaults for inactive loads. Missing translated pages return a zero pointer, which prevents the subsequent physical load; these controls do not by themselves prove allocation-level isolation. **Resilience and Maintainability Implications** - _observed_ — Image replacement marks bindings for rebind, views are reacquired from the owning image, and image destruction releases its cached views. Validation failures using EXIT are terminal rather than recoverable: the handler returns a nonzero value and the macro invokes emergency shutdown and std::_Exit. Consequently, the inspected validation path does not resume with a partially populated cache. </details> <!-- architecture_review_end --> <!-- pre_merge_checks_walkthrough_start --> <details> <summary>🚥 Pre-merge checks | ✅ 4 | ❓ 1</summary> ### ❌ Failed checks (1 inconclusive) | Check name | Status | Explanation | Resolution | | :----------------: | :------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ❓ Inconclusive | Docstring coverage is 5.26% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 19 functions across 11 files. (2 skipped: … | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary>✅ Passed checks (4 passed)</summary> | Check name | Status | Explanation | | :------------------------: | :------- | :------------------------------------------------------------------------------------------------------------------------------------------ | | 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. | | Title check | ✅ Passed | The title clearly summarizes the main changes: GPU-selected buffer loads and packed image reads. | | Description check | ✅ Passed | The description directly explains the implemented shader features, supporting sources, validation results, and known full-suite limitation. | </details> <details> <summary>Full details: Docstring Coverage</summary> **Explanation** Docstring coverage is 5.26% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 19 functions across 11 files. (2 skipped: 2 too large.) </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 is currently an internal CodeRabbit preview. <!-- autopilot:end --> <!-- tips_start --> --- Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=976)! 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 -->

Pull request closed

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