graphics: use static feedback loop pipelines without the dynamic-state extension #2213

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

@⁠theantipopau on GitHub · 2026-11-11 10:43 UTC · original
theantipopau:fix/static-feedback-loop-rebase → main · +168 −43 · 9 files · 6 commits · closed without merging

Summary

This is a rebased replacement for #1187. It keeps the original static feedback-loop design but brings it onto current main and adds the layout-only test split requested during review.

  • Enables VK_EXT_attachment_feedback_loop_layout independently of VK_EXT_attachment_feedback_loop_dynamic_state.
  • Tracks dynamic-state support separately; hosts with both extensions keep the existing per-draw path.
  • When dynamic state is unavailable, bakes VK_PIPELINE_CREATE_DEPTH_STENCIL_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT into the graphics pipeline key and enables the feedback-loop layout for the attachment.
  • Adds the opt-in kDepthFeedback harness profile and --depth-feedback-static-only selector, including the layout-only/static pipeline path.

Supersedes #1187.

Validation

Built shader_recompiler_compute_tests on Windows and ran the static selector under Khronos Validation Layer 1.4.357.0 on an AMD Radeon RX 9070 XT:

[gpu]     DepthAttachmentFeedbackStatic    ok

Exit status 0; zero Validation Error lines and zero VUIDs. The loader inserted the validation layer as both an instance and device layer. git diff --check is clean and the touched test file remains CRLF.

The full strict suite cannot start on this machine because the AMD driver reports robustStorageBufferAccessSizeAlignment = 4, while the strict harness requires byte-granular alignment 1. That is a pre-existing device-capability gate; the dedicated selector uses the opt-in depth-feedback profile and passes cleanly.

**@⁠theantipopau** on GitHub · 2026-11-11 10:43 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2213) `theantipopau:fix/static-feedback-loop-rebase` → `main` · +168 −43 · 9 files · 6 commits · closed without merging ## Summary This is a rebased replacement for #1187. It keeps the original static feedback-loop design but brings it onto current `main` and adds the layout-only test split requested during review. - Enables `VK_EXT_attachment_feedback_loop_layout` independently of `VK_EXT_attachment_feedback_loop_dynamic_state`. - Tracks dynamic-state support separately; hosts with both extensions keep the existing per-draw path. - When dynamic state is unavailable, bakes `VK_PIPELINE_CREATE_DEPTH_STENCIL_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT` into the graphics pipeline key and enables the feedback-loop layout for the attachment. - Adds the opt-in `kDepthFeedback` harness profile and `--depth-feedback-static-only` selector, including the layout-only/static pipeline path. Supersedes #1187. ## Validation Built `shader_recompiler_compute_tests` on Windows and ran the static selector under Khronos Validation Layer `1.4.357.0` on an AMD Radeon RX 9070 XT: ```text [gpu] DepthAttachmentFeedbackStatic ok ``` Exit status `0`; zero `Validation Error` lines and zero VUIDs. The loader inserted the validation layer as both an instance and device layer. `git diff --check` is clean and the touched test file remains CRLF. The full strict suite cannot start on this machine because the AMD driver reports `robustStorageBufferAccessSizeAlignment = 4`, while the strict harness requires byte-granular alignment `1`. That is a pre-existing device-capability gate; the dedicated selector uses the opt-in depth-feedback profile and passes cleanly.
Rebase the static feedback-loop path onto current main and adapt it to the
copy-fallback capability split: layout support enables feedback, dynamic-state
support selects the per-draw command, and layout-only hosts bake the feedback
flag into the pipeline.

Add a layout-only test path that forces the static pipeline and skips the
dynamic command. The host capability check now verifies the split independently.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <[email protected]>
The static feedback path runs with fully initialized descriptors, so it does
not need the byte-granular robust-buffer capabilities required by the full test
suite. Keep the strict profile as the default and opt into the relaxed profile
only for the dedicated selector.

Generated with Codebuff 🤖
Co-Authored-By: Codebuff <[email protected]>
Enable null descriptors in the depth-feedback profile and require the depth
clamp feature for production rasterization so the static selector passes
Vulkan validation.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <[email protected]>
Prevent static depth-feedback pipeline records from being restored on
hosts that cannot create the required attachment feedback loop pipeline.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <[email protected]>
Keep robustness2 enabled for both profiles and enable pipeline robustness
only for the strict profile that requires it.
Run the shared layout-only helper on hosts without dynamic feedback state
and route the dedicated selector through it. Check the dynamic command with
the extension that actually enables it.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:16:53 +00:00
github-bot closed this pull request 2026-11-26 10:16:53 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-11 10:47 UTC · original · edited 2026-11-13 20:51 UTC

Explain Change →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • Resume reviews
  • Trigger review
Walkthrough

The changes separate Vulkan attachment feedback-loop layout support from dynamic-state support. Draw execution now passes depth-attachment feedback state to pipeline lookup, which selects static pipeline feedback state when dynamic state is unavailable. Pipeline creation and dynamic commands check their respective support flags. The Vulkan test harness adds a depth-feedback profile and a static-only test path.

Suggested reviewers: nmzik

Change: Feature

Merge Risk: High · previous review 1ebdc

The feedback-loop change itself is coherent, but the test harness now enables robustness features without enabling the extensions that provide them. That can make device creation fail or leave null descriptors unavailable in the test harness. Several earlier concerns in other files, including possible compile errors, also remain open, so this should be fixed before merge.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: graphics pipelines use static feedback-loop state when the attachment feedback-loop dynamic-state extension is unavailable. The changeset adds the static pipeline key …
Description check Passed The description states that this is a rebased replacement for #1187. It lists the main changes: enabling the layout extension independently of the dynamic-state extension, tracking dynamic-state suppo…
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.
Full details: Title check

Explanation

The title names the main change: graphics pipelines use static feedback-loop state when the attachment feedback-loop dynamic-state extension is unavailable. The changeset adds the static pipeline key flag, separates layout and dynamic-state tracking, and updates device feature enablement to match. The title is specific and concise, and it is 10 words and 80 characters, which is within a reasonable length.

Full details: Description check

Explanation

The description states that this is a rebased replacement for #1187. It lists the main changes: enabling the layout extension independently of the dynamic-state extension, tracking dynamic-state support separately, baking the depth/stencil feedback-loop flag into the pipeline key, and adding the kDepthFeedback harness profile and selector. It also reports validation results. It is directly related to the changeset.

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

**@⁠coderabbitai[bot]** on GitHub · 2026-11-11 10:47 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2213#issuecomment-6793781703) · edited 2026-11-13 20:51 UTC <!-- coderabbit-ai-generated:v1 --> <!-- 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/2213?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change.svg" alt="Explain Change →" height="32"></picture></a> <!-- review_stack_entry_end --> <!-- This is an auto-generated comment: review paused by coderabbit.ai --> > [!NOTE] > ## Reviews paused > > It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the `reviews.auto_review.auto_pause_after_reviewed_commits` setting. > > - Last reviewed commit: 1ebdce1dce402dde033e4eb655d9d28e5964e1a2 > - Latest commit, not reviewed: 23efc076bbce6198601a1c6afd0c708a2e133dce > > Use the following commands to manage reviews: > - `@coderabbitai resume` to resume automatic reviews. > - `@coderabbitai review` to trigger a single review. > > Use the checkboxes below for quick actions: > - [ ] <!-- {"checkboxId":"7f6cc2e2-2e4e-497a-8c31-c9e4573e93d1"} --> Resume reviews > - [ ] <!-- {"checkboxId":"e9bb8d72-00e8-4f67-9cb2-caf3b22574fe"} --> Trigger review <!-- end of auto-generated comment: review paused by coderabbit.ai --> <!-- walkthrough_start --> <details> <summary><strong>Walkthrough</strong></summary> <dl> <dd> <br> The changes separate Vulkan attachment feedback-loop layout support from dynamic-state support. Draw execution now passes depth-attachment feedback state to pipeline lookup, which selects static pipeline feedback state when dynamic state is unavailable. Pipeline creation and dynamic commands check their respective support flags. The Vulkan test harness adds a depth-feedback profile and a static-only test path. **Suggested reviewers:** `nmzik` </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> <!-- change_assessment_commit:"1ebdce1dce402dde033e4eb655d9d28e5964e1a2" --> <!-- change_assessment_priority:{"version":1,"urgency":"p2","manual":false} --> **Change:** Feature <!-- change_assessment_end --> <details> <summary><strong>Merge Risk:</strong> <strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/risk-high-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> High</strong> · previous review <code>1ebdc</code></summary> <dl> <dd> <br> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **🟠 High** · up to `1ebdc` --> <!-- final_review_risk_coverage:{"sourceCommitId":"1ebdce1dce402dde033e4eb655d9d28e5964e1a2","coveredCommitId":"1ebdce1dce402dde033e4eb655d9d28e5964e1a2","kind":"reviewed"} --> The feedback-loop change itself is coherent, but the test harness now enables robustness features without enabling the extensions that provide them. That can make device creation fail or leave null descriptors unavailable in the test harness. Several earlier concerns in other files, including possible compile errors, also remain open, so this should be fixed before merge. <!-- final_review_risk_end --> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_start --> <details> <summary><strong>Pre-merge checks: <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> 4</strong></summary> <dl> <dd> <br> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title names the main change: graphics pipelines use static feedback-loop state when the attachment feedback-loop dynamic-state extension is unavailable. The changeset adds the static pipeline key … | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description states that this is a rebased replacement for `#1187`. It lists the main changes: enabling the layout extension independently of the dynamic-state extension, tracking dynamic-state suppo… | | Linked Issues check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | <details> <summary><strong>Full details: Title check</strong></summary> <dl> <dd> <br> **Explanation** The title names the main change: graphics pipelines use static feedback-loop state when the attachment feedback-loop dynamic-state extension is unavailable. The changeset adds the static pipeline key flag, separates layout and dynamic-state tracking, and updates device feature enablement to match. The title is specific and concise, and it is 10 words and 80 characters, which is within a reasonable length. </dd> </dl> </details> <details> <summary><strong>Full details: Description check</strong></summary> <dl> <dd> <br> **Explanation** The description states that this is a rebased replacement for `#1187`. It lists the main changes: enabling the layout extension independently of the dynamic-state extension, tracking dynamic-state support separately, baking the depth/stencil feedback-loop flag into the pipeline key, and adding the kDepthFeedback harness profile and selector. It also reports validation results. It is directly related to the changeset. </dd> </dl> </details> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- tips_start --> Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=2213)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary><strong>Share</strong></summary> <dl> <dd> <br> - [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) </dd> </dl> </details> <!-- tips_end -->
@ -80,0 +80,4 @@
// Static VK_PIPELINE_CREATE_DEPTH_STENCIL_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT, used when
// the host cannot enable attachment feedback loops per draw. A uint32_t keeps the packed
// key aligned for its raw-byte hash.
uint32_t depth_stencil_feedback_loop = 0;
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-11 10:48 UTC · original · edited 2026-11-11 20:16 UTC

Minor · Stability & Availability · Quick win

Include feedback-loop support in shader-store compatibility checks.

This field persists a host-dependent pipeline requirement. pipelineSerialization.cpp, Lines 237–244 and Lines 276–283, restores and stores the complete key. Its header at Lines 61–68 does not include feedback-loop support. SpirvProfile also omits that support. (raw.githubusercontent.com)

If a user switches from a layout-capable device to an unsupported device with the same header inputs, warm-up restores a nonzero field. The new check in shaders.cpp, Line 356, then terminates startup until the user removes the shader store.

Include the capability in the store header, or skip incompatible pipeline records during warm-up.

✅ Addressed in commit 0aa25f9

**@⁠coderabbitai[bot]** on GitHub · 2026-11-11 10:48 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2213#discussion_r4536939734) · edited 2026-11-11 20:16 UTC <!-- coderabbit-ai-generated:v1 --> **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/amber-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minor** · **Stability & Availability** · **Quick win** **Include feedback-loop support in shader-store compatibility checks.** This field persists a host-dependent pipeline requirement. `pipelineSerialization.cpp`, Lines 237–244 and Lines 276–283, restores and stores the complete key. Its header at Lines 61–68 does not include feedback-loop support. `SpirvProfile` also omits that support. ([raw.githubusercontent.com](https://raw.githubusercontent.com/KytyPS5/KytyPS5/252e2aa37793cc7c47b953eaf0f79f794474b2d0/src/graphics/host_gpu/renderer/pipeline/pipelineSerialization.cpp)) If a user switches from a layout-capable device to an unsupported device with the same header inputs, warm-up restores a nonzero field. The new check in `shaders.cpp`, Line 356, then terminates startup until the user removes the shader store. Include the capability in the store header, or skip incompatible pipeline records during warm-up. <!-- fingerprinting:phantom:poseidon:wombat61 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:940f587ff269c9f60d150426 --> <!-- This is an auto-generated comment by CodeRabbit --> ✅ Addressed in commit 0aa25f9
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-11 10:48 UTC · original · reviewed

Actionable comments posted: 1

Nitpick comments: 1

tests/ShaderRecompilerComputeTests.cpp: 1

56790-56791: Trivial · Maintainability & Code Quality · Quick win

Disable dynamic feedback support before device creation for the static-only profile.

On hosts supporting both extensions, Init() still enables the dynamic feedback feature and extension. This selector changes only the runtime flag after device creation. The test therefore does not exercise device initialization without the dynamic extension. Make kDepthFeedback omit that feature and extension before vkCreateDevice, so dual-capability hosts test the layout-only device configuration too. (raw.githubusercontent.com)

Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between bc934ef034 and 252e2aa37793cc7c47b953eaf0f79f794474b2d0.

Files selected for processing: 8

  • src/graphics/host_gpu/graphicContext.h
  • src/graphics/host_gpu/renderer/dynamicState.cpp
  • src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp
  • src/graphics/host_gpu/renderer/pipeline/pipelineCache.h
  • src/graphics/host_gpu/renderer/pipeline/shaders.cpp
  • src/graphics/host_gpu/renderer/renderDraw.cpp
  • src/graphics/presentation/window/vulkanWindow.cpp
  • tests/ShaderRecompilerComputeTests.cpp

Included 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-11-11 10:48 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2213#pullrequestreview-5857545696) · **reviewed** <!-- coderabbit-ai-generated:v1 --> **Actionable comments posted: 1** <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/brush-cleaning-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/brush-cleaning.svg" width="16" height="16" align="absmiddle" alt=""></picture> Nitpick comments: 1</summary><blockquote> <dl> <dd> <br> <details> <summary>tests/ShaderRecompilerComputeTests.cpp: 1</summary><blockquote> <dl> <dd> <br> `56790-56791`: **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/neutral-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Trivial** · **Maintainability & Code Quality** · **Quick win** **Disable dynamic feedback support before device creation for the static-only profile.** On hosts supporting both extensions, `Init()` still enables the dynamic feedback feature and extension. This selector changes only the runtime flag after device creation. The test therefore does not exercise device initialization without the dynamic extension. Make `kDepthFeedback` omit that feature and extension before `vkCreateDevice`, so dual-capability hosts test the layout-only device configuration too. ([raw.githubusercontent.com](https://raw.githubusercontent.com/KytyPS5/KytyPS5/252e2aa37793cc7c47b953eaf0f79f794474b2d0/tests/ShaderRecompilerComputeTests.cpp)) <!-- cr-comment:v1:43a076a3a6d8d7d67dc5d152 --> </dd> </dl> </blockquote></details> </dd> </dl> </blockquote></details> <h6> <details> <summary><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/info.svg" width="12" height="12" align="absmiddle" alt=""></picture> Review info</summary> <dl> <dd> <br> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog.svg" width="16" height="16" align="absmiddle" alt=""></picture> Run configuration</summary> <dl> <dd> <br> - **Source mode**: Auto - **Repository**: [KytyPS5/KytyPS5](<https://github.com/KytyPS5/KytyPS5>) - **Branch**: [main](<https://github.com/KytyPS5/KytyPS5/tree/main>) - **File**: [.coderabbit.yaml](<https://github.com/KytyPS5/KytyPS5/blob/bc934ef03410b760fbf8e49db1d79485e7e5f887/.coderabbit.yaml>) - **Commit**: [bc934ef](<https://github.com/KytyPS5/KytyPS5/commit/bc934ef03410b760fbf8e49db1d79485e7e5f887>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `879e4950-4719-4ce5-8a7e-ce512cfdd695` </dd> </dl> </details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal.svg" width="16" height="16" align="absmiddle" alt=""></picture> Commits</summary> <dl> <dd> <br> Reviewing files that changed from the base of the PR and between bc934ef03410b760fbf8e49db1d79485e7e5f887 and 252e2aa37793cc7c47b953eaf0f79f794474b2d0. </dd> </dl> </details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner.svg" width="16" height="16" align="absmiddle" alt=""></picture> Files selected for processing: 8</summary> <dl> <dd> <br> * `src/graphics/host_gpu/graphicContext.h` * `src/graphics/host_gpu/renderer/dynamicState.cpp` * `src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp` * `src/graphics/host_gpu/renderer/pipeline/pipelineCache.h` * `src/graphics/host_gpu/renderer/pipeline/shaders.cpp` * `src/graphics/host_gpu/renderer/renderDraw.cpp` * `src/graphics/presentation/window/vulkanWindow.cpp` * `tests/ShaderRecompilerComputeTests.cpp` </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. </dd> </dl> </details> </h6> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=a9345beb-e3d9-4c37-a93a-246fabe9bd97 attempt=c49458b1-2377-4a74-85c4-15da3aa203ab batch=1/1 -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-11 10:59 UTC · original · reviewed

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

Major · Include image-heap entries in depth feedback detection. · renderDraw.cpp:499-502

src/graphics/host_gpu/renderer/renderDraw.cpp:499-502
Major · Data Integrity & Integration · Heavy lift

Include image-heap entries in depth feedback detection.

A heap entry can sample the active depth attachment, but PrepareBindings leaves its entry empty. If no non-heap binding identifies the alias, the scan can miss the feedback loop. The draw then lacks the feedback layout and, without dynamic-state support, the static pipeline flag. Include active heap views in the detection before selecting the pipeline.

Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 252e2aa37793cc7c47b953eaf0f79f794474b2d0 and 4eb2af7be94abf5c1b19f24323fddcf90401b794.

Files selected for processing: 4

  • src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp
  • src/graphics/host_gpu/renderer/pipeline/pipelineCache.h
  • src/graphics/host_gpu/renderer/renderDraw.cpp
  • tests/ShaderRecompilerComputeTests.cpp

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

**@⁠coderabbitai[bot]** on GitHub · 2026-11-11 10:59 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2213#pullrequestreview-5857682801) · **reviewed** <!-- coderabbit-ai-generated:v1 --> > [!CAUTION] > Some comments are outside the diff and can’t be posted inline due to GitHub limitations. > > **⚠️ Outside diff range comments (1)** > > <details> > <summary><strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/major-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Major</strong> · Include image-heap entries in depth feedback detection. · <code>renderDraw.cpp:499-502</code></summary><blockquote> > <dl> > <dd> > <br> > > `src/graphics/host_gpu/renderer/renderDraw.cpp:499-502` > **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/major-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Major** · **Data Integrity & Integration** · **Heavy lift** > > **Include image-heap entries in depth feedback detection.** > > A heap entry can sample the active depth attachment, but `PrepareBindings` leaves its entry empty. If no non-heap binding identifies the alias, the scan can miss the feedback loop. The draw then lacks the feedback layout and, without dynamic-state support, the static pipeline flag. Include active heap views in the detection before selecting the pipeline. > > <!-- cr-comment:v1:aab41177f4ab0777126d0c67 --> > > </dd> > </dl> > </blockquote></details> <h6> <details> <summary><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/info.svg" width="12" height="12" align="absmiddle" alt=""></picture> Review info</summary> <dl> <dd> <br> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog.svg" width="16" height="16" align="absmiddle" alt=""></picture> Run configuration</summary> <dl> <dd> <br> - **Source mode**: Auto - **Repository**: [KytyPS5/KytyPS5](<https://github.com/KytyPS5/KytyPS5>) - **Branch**: [main](<https://github.com/KytyPS5/KytyPS5/tree/main>) - **File**: [.coderabbit.yaml](<https://github.com/KytyPS5/KytyPS5/blob/bc934ef03410b760fbf8e49db1d79485e7e5f887/.coderabbit.yaml>) - **Commit**: [bc934ef](<https://github.com/KytyPS5/KytyPS5/commit/bc934ef03410b760fbf8e49db1d79485e7e5f887>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `460af277-0c67-4e5c-93e2-948966a099f6` </dd> </dl> </details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal.svg" width="16" height="16" align="absmiddle" alt=""></picture> Commits</summary> <dl> <dd> <br> Reviewing files that changed from the base of the PR and between 252e2aa37793cc7c47b953eaf0f79f794474b2d0 and 4eb2af7be94abf5c1b19f24323fddcf90401b794. </dd> </dl> </details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner.svg" width="16" height="16" align="absmiddle" alt=""></picture> Files selected for processing: 4</summary> <dl> <dd> <br> * `src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp` * `src/graphics/host_gpu/renderer/pipeline/pipelineCache.h` * `src/graphics/host_gpu/renderer/renderDraw.cpp` * `tests/ShaderRecompilerComputeTests.cpp` </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review. </dd> </dl> </details> </h6> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=029340f4-1d67-4848-a47a-95ecb44cc1b8 attempt=42021f63-c148-48db-9eb6-4b736e37c526 batch=1/1 -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-13 04:39 UTC · original
On src/graphics/host_gpu/renderer/pipeline/descriptors.cpp line 68 (outdated):

@@ -37,12 +38,66 @@
 #include <span>
 #include <vector>
 
+#ifdef min
+#undef min
+#endif
+#ifdef max
+#undef max
+#endif
+
 namespace Libs::Graphics {
 
 namespace {
 
 using BindingKind = ShaderRecompiler::IR::DescriptorBindingKind;
 
+// PS5 sampler color state is paired with an image, while Vulkan stores the decoded format in
+// the image view. Only override the view when every pair using the image agrees.
+SamplerColorMode ResolveSamplerColorMode(const ShaderRecompiler::IR::CompiledShaderInfo& program,
+                                          const ShaderRecompiler::IR::ResourceSnapshot& snapshot,
+                                          uint32_t image_index) {
+	SamplerColorMode result;
+	for (const auto& pair: program.info.sampled_pairs) {
+		if (pair.image != image_index) {
+			continue;
+		}
+		if (pair.sampler >= snapshot.samplers.size()) {
+			return {};
+		}
+		const auto sampler =
+		    DecodeNativeDescriptor<ShaderSamplerResource>(snapshot.samplers[pair.sampler]);

Major · Functional Correctness · Quick win

Resolve sampler descriptors through snapshot_index.

pair.sampler indexes program.info.samplers, not necessarily snapshot.samplers. Native filtering and border variants share the original runtime descriptor through SamplerResource::snapshot_index. PrepareBindings uses that mapping at Line 745.

For such a variant, this lookup can decode another sampler's color flags. If the variant index exceeds the snapshot size, it instead disables the color override. Both paths can select the wrong sRGB or unorm view.

Resolve program.info.samplers[pair.sampler].snapshot_index, validate that snapshot index, and decode its descriptor.

**@⁠coderabbitai[bot]** on GitHub · 2026-11-13 04:39 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2213#discussion_r4559714358) On `src/graphics/host_gpu/renderer/pipeline/descriptors.cpp` line 68 (outdated): ```diff @@ -37,12 +38,66 @@ #include <span> #include <vector> +#ifdef min +#undef min +#endif +#ifdef max +#undef max +#endif + namespace Libs::Graphics { namespace { using BindingKind = ShaderRecompiler::IR::DescriptorBindingKind; +// PS5 sampler color state is paired with an image, while Vulkan stores the decoded format in +// the image view. Only override the view when every pair using the image agrees. +SamplerColorMode ResolveSamplerColorMode(const ShaderRecompiler::IR::CompiledShaderInfo& program, + const ShaderRecompiler::IR::ResourceSnapshot& snapshot, + uint32_t image_index) { + SamplerColorMode result; + for (const auto& pair: program.info.sampled_pairs) { + if (pair.image != image_index) { + continue; + } + if (pair.sampler >= snapshot.samplers.size()) { + return {}; + } + const auto sampler = + DecodeNativeDescriptor<ShaderSamplerResource>(snapshot.samplers[pair.sampler]); ``` <!-- coderabbit-ai-generated:v1 --> **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/major-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Major** · **Functional Correctness** · **Quick win** **Resolve sampler descriptors through `snapshot_index`.** `pair.sampler` indexes `program.info.samplers`, not necessarily `snapshot.samplers`. Native filtering and border variants share the original runtime descriptor through `SamplerResource::snapshot_index`. `PrepareBindings` uses that mapping at Line 745. For such a variant, this lookup can decode another sampler's color flags. If the variant index exceeds the snapshot size, it instead disables the color override. Both paths can select the wrong sRGB or unorm view. Resolve `program.info.samplers[pair.sampler].snapshot_index`, validate that snapshot index, and decode its descriptor. <!-- fingerprinting:phantom:medusa:wombat61 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:f11b331ae014ddfc790c3f60 --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-13 04:39 UTC · original
On src/graphics/shader/recompiler/backend/spirv/spirvEmitterAluHelpers.cpp line 226 (outdated):

@@ -196,4 +207,111 @@ uint32_t EmitF16BitsToF32(EmitterState& state, uint32_t bits) {
 	return ret;
 }
 
+// GLSLstd450PackHalf2x16 misrounds on some GPUs: the low lane (and only the low
+// lane on the observed driver) truncates F32->F16 instead of round-to-nearest-
+// even, breaking the half-precision 1-ulp edge cases. Lower the pack to the
+// bitwise RTZ conversion (already exact) plus a mid-round increment. The width
+// of the dropped mantissa region depends on the input exponent band, so the
+// increment decision is computed per band:
+//   exp 113..142 : normal half output; 13-bit dropped region, tie at 0x1000.
+//   exp 103..112 : subnormal half output; shift width 126-exp, tie at 1<<shift.
+//   exp     102  : rounds to 0x0001 unless the input is exactly 2^-25 (tie -> zero).
+//   exp    >=143 : every finite input sits above the 65520 Inf tie; +1 turns the
+//                  saturated 0x7bff into 0x7c00 (Inf), the architectural result.
+//   exp    ==255 : Inf/NaN keep their RTZ bit pattern (no payload drift).
+// An incremented half mantissa carries as exponents do (0x7bff+1 -> 0x7c00,
+// subnormal 0x3ff+1 -> 0x0400 wraps into the smallest normal), which is IEEE
+// RNE into the rounding-up direction. Both packed lanes use the same math.
+uint32_t EmitF32ToF16RneBits(EmitterState& state, uint32_t f32) {
+	const auto rtz_bits = EmitF32ToF16RtzBits(state, f32);

Critical · Functional Correctness · Quick win

Declare the helper functions that EmitF32ToF16RneBits calls.

spirvEmitterAluHelpers.cpp is compiled as its own translation unit through the spirv/*.cpp glob in CMakeLists.txt:233. Three names used there are not visible to that unit:

  • EmitF32ToF16RtzBits (line 226) is defined at spirvEmitterAlu.cpp:70, inside the unnamed namespace that spans lines 6–140. It has internal linkage.
  • EmitShiftRightConstant (line 230) and EmitSubConstantMinusU32 (line 251) have no declaration or definition anywhere in the repository.

These undeclared identifiers stop compilation of the file. Because the glob includes it, the emulator target cannot build.

Move EmitF32ToF16RtzBits out of the unnamed namespace, and declare it in spirvEmitterInternal.h beside the other Emit* helpers. Define EmitShiftRightConstant and EmitSubConstantMinusU32 with the same EmitterState& signature convention as the other helpers, or replace these two calls with existing helpers.

**@⁠coderabbitai[bot]** on GitHub · 2026-11-13 04:39 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2213#discussion_r4559714363) On `src/graphics/shader/recompiler/backend/spirv/spirvEmitterAluHelpers.cpp` line 226 (outdated): ```diff @@ -196,4 +207,111 @@ uint32_t EmitF16BitsToF32(EmitterState& state, uint32_t bits) { return ret; } +// GLSLstd450PackHalf2x16 misrounds on some GPUs: the low lane (and only the low +// lane on the observed driver) truncates F32->F16 instead of round-to-nearest- +// even, breaking the half-precision 1-ulp edge cases. Lower the pack to the +// bitwise RTZ conversion (already exact) plus a mid-round increment. The width +// of the dropped mantissa region depends on the input exponent band, so the +// increment decision is computed per band: +// exp 113..142 : normal half output; 13-bit dropped region, tie at 0x1000. +// exp 103..112 : subnormal half output; shift width 126-exp, tie at 1<<shift. +// exp 102 : rounds to 0x0001 unless the input is exactly 2^-25 (tie -> zero). +// exp >=143 : every finite input sits above the 65520 Inf tie; +1 turns the +// saturated 0x7bff into 0x7c00 (Inf), the architectural result. +// exp ==255 : Inf/NaN keep their RTZ bit pattern (no payload drift). +// An incremented half mantissa carries as exponents do (0x7bff+1 -> 0x7c00, +// subnormal 0x3ff+1 -> 0x0400 wraps into the smallest normal), which is IEEE +// RNE into the rounding-up direction. Both packed lanes use the same math. +uint32_t EmitF32ToF16RneBits(EmitterState& state, uint32_t f32) { + const auto rtz_bits = EmitF32ToF16RtzBits(state, f32); ``` <!-- coderabbit-ai-generated:v1 --> **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/critical-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Critical** · **Functional Correctness** · **Quick win** **Declare the helper functions that `EmitF32ToF16RneBits` calls.** `spirvEmitterAluHelpers.cpp` is compiled as its own translation unit through the `spirv/*.cpp` glob in `CMakeLists.txt:233`. Three names used there are not visible to that unit: - `EmitF32ToF16RtzBits` (line 226) is defined at `spirvEmitterAlu.cpp:70`, inside the unnamed namespace that spans lines 6–140. It has internal linkage. - `EmitShiftRightConstant` (line 230) and `EmitSubConstantMinusU32` (line 251) have no declaration or definition anywhere in the repository. These undeclared identifiers stop compilation of the file. Because the glob includes it, the emulator target cannot build. Move `EmitF32ToF16RtzBits` out of the unnamed namespace, and declare it in `spirvEmitterInternal.h` beside the other `Emit*` helpers. Define `EmitShiftRightConstant` and `EmitSubConstantMinusU32` with the same `EmitterState&` signature convention as the other helpers, or replace these two calls with existing helpers. <!-- fingerprinting:phantom:medusa:wombat61 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:df71e5e560a00682e7011d81 --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-13 04:39 UTC · original
On src/graphics/shader/recompiler/backend/spirv/spirvEmitterInstructions.h line 46 (outdated):

@@ -41,7 +41,9 @@ uint32_t              EmitCompositeExtractU64(EmitterState& state, uint32_t arg0
 uint32_t              EmitCompositeExtractU32x2(EmitterState& state, uint32_t arg0, IR::Value arg1);
 inline constexpr auto EmitCompositeExtractU32x3 = EmitCompositeExtractU32x2;
 inline constexpr auto EmitCompositeExtractU32x4 = EmitCompositeExtractU32x2;
-inline constexpr auto EmitPackHalf2x16 = EmitGlsl<GLSLstd450PackHalf2x16, IR::Type::U32, uint32_t>;
+// GLSLstd450PackHalf2x16 truncates instead of RNE on some GPUs; route to the
+// bitwise RNE conversion (see EmitF32ToF16RneBits).
+uint32_t              EmitPackHalf2x16(EmitterState& state, uint32_t pair);

Major · Functional Correctness · Quick win

Update the PackHalf2x16 structural check in the float16 buffer-store fixture.

BufferStoreFormatXyzwFloat16ConvertsComponents requires PackHalf2x16 in the disassembly. The buffer-store path now reaches the new EmitPackHalf2x16, which emits OpCompositeExtract, the RNE bit conversion, OpShiftLeftLogical, and an OR. It does not emit the GLSL extended instruction. The check therefore fails even when the packed values are correct.

Keep the image-path expectations at lines 37484 and 38214 unchanged. The image path still emits GLSLstd450PackHalf2x16 directly at spirvEmitterImage.cpp:272.

Replace the structural check with an instruction that the new helper emits:

Suggested fix

-  test.required_spirv = {"PackHalf2x16"};
+  test.required_spirv = {"OpShiftLeftLogical"};
**@⁠coderabbitai[bot]** on GitHub · 2026-11-13 04:39 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2213#discussion_r4559714367) On `src/graphics/shader/recompiler/backend/spirv/spirvEmitterInstructions.h` line 46 (outdated): ```diff @@ -41,7 +41,9 @@ uint32_t EmitCompositeExtractU64(EmitterState& state, uint32_t arg0 uint32_t EmitCompositeExtractU32x2(EmitterState& state, uint32_t arg0, IR::Value arg1); inline constexpr auto EmitCompositeExtractU32x3 = EmitCompositeExtractU32x2; inline constexpr auto EmitCompositeExtractU32x4 = EmitCompositeExtractU32x2; -inline constexpr auto EmitPackHalf2x16 = EmitGlsl<GLSLstd450PackHalf2x16, IR::Type::U32, uint32_t>; +// GLSLstd450PackHalf2x16 truncates instead of RNE on some GPUs; route to the +// bitwise RNE conversion (see EmitF32ToF16RneBits). +uint32_t EmitPackHalf2x16(EmitterState& state, uint32_t pair); ``` <!-- coderabbit-ai-generated:v1 --> **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/major-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Major** · **Functional Correctness** · **Quick win** **Update the `PackHalf2x16` structural check in the float16 buffer-store fixture.** `BufferStoreFormatXyzwFloat16ConvertsComponents` requires `PackHalf2x16` in the disassembly. The buffer-store path now reaches the new `EmitPackHalf2x16`, which emits `OpCompositeExtract`, the RNE bit conversion, `OpShiftLeftLogical`, and an OR. It does not emit the GLSL extended instruction. The check therefore fails even when the packed values are correct. Keep the image-path expectations at lines 37484 and 38214 unchanged. The image path still emits `GLSLstd450PackHalf2x16` directly at `spirvEmitterImage.cpp:272`. Replace the structural check with an instruction that the new helper emits: <details> <summary>Suggested fix</summary> <dl> <dd> <br> ```diff - test.required_spirv = {"PackHalf2x16"}; + test.required_spirv = {"OpShiftLeftLogical"}; ``` </dd> </dl> </details> <!-- fingerprinting:phantom:medusa:wombat61 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:53f0b4a8c27825dd63d5faae --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-13 04:39 UTC · original
On src/graphics/shader/recompiler/frontend/translate/Vector.cpp line 288 (outdated):

@@ -25,311 +23,451 @@ void Translator::EmitVector(const Decoder::Instruction& inst) {
 		case O::V_PERMLANEX16_B32: V_PERMLANE16_B32(inst, true); return;
 
 		case O::V_CMP_F_I32:
-		case O::V_CMP_F_U32: EmitCompareConstant(inst, false, false); return;
+		case O::V_CMP_F_U32: EmitCompareConstant(inst, false, false, false); return;
 		case O::V_CMP_T_I32:
-		case O::V_CMP_T_U32: EmitCompareConstant(inst, true, false); return;
+		case O::V_CMP_T_U32: EmitCompareConstant(inst, true, false, false); return;
 		case O::V_CMP_EQ_U32:
 		case O::V_CMP_EQ_I32:
+			EmitIntegerCompare(inst, IR::ValueOpcode::IEqual32, IR::Type::U32, false, false);
+			return;
 		case O::V_CMPX_EQ_U32:
 		case O::V_CMPX_EQ_I32:
-			EmitIntegerCompare(inst, IR::ValueOpcode::IEqual32, IR::Type::U32, false);
+			EmitIntegerCompare(inst, IR::ValueOpcode::IEqual32, IR::Type::U32, false, true);
 			return;
 		case O::V_CMP_NE_U32:
 		case O::V_CMP_NE_I32:
+			EmitIntegerCompare(inst, IR::ValueOpcode::INotEqual32, IR::Type::U32, false, false);
+			return;
 		case O::V_CMPX_NE_U32:
 		case O::V_CMPX_NE_I32:
-			EmitIntegerCompare(inst, IR::ValueOpcode::INotEqual32, IR::Type::U32, false);
+			EmitIntegerCompare(inst, IR::ValueOpcode::INotEqual32, IR::Type::U32, false, true);
 			return;
 		case O::V_CMP_GT_U32:
+			EmitIntegerCompare(inst, IR::ValueOpcode::UGreaterThan32, IR::Type::U32, false, false);
+			return;
 		case O::V_CMPX_GT_U32:
-			EmitIntegerCompare(inst, IR::ValueOpcode::UGreaterThan32, IR::Type::U32, false);
+			EmitIntegerCompare(inst, IR::ValueOpcode::UGreaterThan32, IR::Type::U32, false, true);
 			return;
 		case O::V_CMP_GE_U32:
+			EmitIntegerCompare(inst, IR::ValueOpcode::UGreaterThanEqual32, IR::Type::U32, false,
+			                   false);
+			return;
 		case O::V_CMPX_GE_U32:
-			EmitIntegerCompare(inst, IR::ValueOpcode::UGreaterThanEqual32, IR::Type::U32, false);
+			EmitIntegerCompare(inst, IR::ValueOpcode::UGreaterThanEqual32, IR::Type::U32, false,
+			                   true);
 			return;
 		case O::V_CMP_LT_U32:
+			EmitIntegerCompare(inst, IR::ValueOpcode::ULessThan32, IR::Type::U32, false, false);
+			return;
 		case O::V_CMPX_LT_U32:
-			EmitIntegerCompare(inst, IR::ValueOpcode::ULessThan32, IR::Type::U32, false);
+			EmitIntegerCompare(inst, IR::ValueOpcode::ULessThan32, IR::Type::U32, false, true);
 			return;
 		case O::V_CMP_LE_U32:
+			EmitIntegerCompare(inst, IR::ValueOpcode::ULessThanEqual32, IR::Type::U32, false,
+			                   false);
+			return;
 		case O::V_CMPX_LE_U32:
-			EmitIntegerCompare(inst, IR::ValueOpcode::ULessThanEqual32, IR::Type::U32, false);
+			EmitIntegerCompare(inst, IR::ValueOpcode::ULessThanEqual32, IR::Type::U32, false, true);
 			return;
 		case O::V_CMP_GT_I32:
+			EmitIntegerCompare(inst, IR::ValueOpcode::SGreaterThan32, IR::Type::U32, false, false);
+			return;
 		case O::V_CMPX_GT_I32:
-			EmitIntegerCompare(inst, IR::ValueOpcode::SGreaterThan32, IR::Type::U32, false);
+			EmitIntegerCompare(inst, IR::ValueOpcode::SGreaterThan32, IR::Type::U32, false, true);
 			return;
 		case O::V_CMP_GE_I32:
+			EmitIntegerCompare(inst, IR::ValueOpcode::SGreaterThanEqual32, IR::Type::U32, false,
+			                   false);
+			return;
 		case O::V_CMPX_GE_I32:
-			EmitIntegerCompare(inst, IR::ValueOpcode::SGreaterThanEqual32, IR::Type::U32, false);
+			EmitIntegerCompare(inst, IR::ValueOpcode::SGreaterThanEqual32, IR::Type::U32, false,
+			                   true);
 			return;
 		case O::V_CMP_LT_I32:
+			EmitIntegerCompare(inst, IR::ValueOpcode::SLessThan32, IR::Type::U32, false, false);
+			return;
 		case O::V_CMPX_LT_I32:
-			EmitIntegerCompare(inst, IR::ValueOpcode::SLessThan32, IR::Type::U32, false);
+			EmitIntegerCompare(inst, IR::ValueOpcode::SLessThan32, IR::Type::U32, false, true);
 			return;
 		case O::V_CMP_LE_I32:
+			EmitIntegerCompare(inst, IR::ValueOpcode::SLessThanEqual32, IR::Type::U32, false,
+			                   false);
+			return;
 		case O::V_CMPX_LE_I32:
-			EmitIntegerCompare(inst, IR::ValueOpcode::SLessThanEqual32, IR::Type::U32, false);
+			EmitIntegerCompare(inst, IR::ValueOpcode::SLessThanEqual32, IR::Type::U32, false, true);
 			return;
 		case O::V_CMP_F_I64:
-		case O::V_CMP_F_U64:
-		case O::V_CMPX_F_I64:
-		case O::V_CMPX_F_U64: EmitCompareConstant(inst, false, false); return;
+		case O::V_CMP_F_U64: EmitCompareConstant(inst, false, false, false); return;
 		case O::V_CMP_T_I64:
-		case O::V_CMP_T_U64:
+		case O::V_CMP_T_U64: EmitCompareConstant(inst, true, false, false); return;
+		case O::V_CMPX_F_I64:
+		case O::V_CMPX_F_U64: EmitCompareConstant(inst, false, false, true); return;
 		case O::V_CMPX_T_I64:
-		case O::V_CMPX_T_U64: EmitCompareConstant(inst, true, false); return;
+		case O::V_CMPX_T_U64: EmitCompareConstant(inst, true, false, true); return;
 		case O::V_CMP_EQ_I64:
 		case O::V_CMP_EQ_U64:
+			EmitIntegerCompare(inst, IR::ValueOpcode::IEqual64, IR::Type::U64, false, false);
+			return;
 		case O::V_CMPX_EQ_I64:
 		case O::V_CMPX_EQ_U64:
-			EmitIntegerCompare(inst, IR::ValueOpcode::IEqual64, IR::Type::U64, false);
+			EmitIntegerCompare(inst, IR::ValueOpcode::IEqual64, IR::Type::U64, false, true);
 			return;
 		case O::V_CMP_LT_U64:
+			EmitIntegerCompare(inst, IR::ValueOpcode::ULessThan64, IR::Type::U64, false, false);
+			return;
 		case O::V_CMPX_LT_U64:
-			EmitIntegerCompare(inst, IR::ValueOpcode::ULessThan64, IR::Type::U64, false);
+			EmitIntegerCompare(inst, IR::ValueOpcode::ULessThan64, IR::Type::U64, false, true);
 			return;
 		case O::V_CMP_GT_U64:
+			EmitIntegerCompare(inst, IR::ValueOpcode::UGreaterThan64, IR::Type::U64, false, false);
+			return;
 		case O::V_CMPX_GT_U64:
-			EmitIntegerCompare(inst, IR::ValueOpcode::UGreaterThan64, IR::Type::U64, false);
+			EmitIntegerCompare(inst, IR::ValueOpcode::UGreaterThan64, IR::Type::U64, false, true);
 			return;
 		case O::V_CMP_NE_I64:
 		case O::V_CMP_NE_U64:
+			EmitIntegerCompare(inst, IR::ValueOpcode::INotEqual64, IR::Type::U64, false, false);
+			return;
 		case O::V_CMPX_NE_I64:
 		case O::V_CMPX_NE_U64:
-			EmitIntegerCompare(inst, IR::ValueOpcode::INotEqual64, IR::Type::U64, false);
+			EmitIntegerCompare(inst, IR::ValueOpcode::INotEqual64, IR::Type::U64, false, true);
 			return;
 
 		case O::V_CMP_LT_I64:
+			EmitIntegerCompare(inst, IR::ValueOpcode::SLessThan64, IR::Type::U64, false, false);
+			return;
 		case O::V_CMPX_LT_I64:
-			EmitIntegerCompare(inst, IR::ValueOpcode::SLessThan64, IR::Type::U64, false);
+			EmitIntegerCompare(inst, IR::ValueOpcode::SLessThan64, IR::Type::U64, false, true);
 			return;
 		case O::V_CMP_LE_I64:
+			EmitIntegerCompare(inst, IR::ValueOpcode::SLessThanEqual64, IR::Type::U64, false, false);
+			return;
 		case O::V_CMPX_LE_I64:
-			EmitIntegerCompare(inst, IR::ValueOpcode::SLessThanEqual64, IR::Type::U64, false);
+			EmitIntegerCompare(inst, IR::ValueOpcode::SLessThanEqual64, IR::Type::U64, false, true);
 			return;
 		// The IR has no signed 64-bit greater-than: a > b is b < a, and a >= b is b <= a.
 		case O::V_CMP_GT_I64:
+			EmitIntegerCompare(inst, IR::ValueOpcode::SLessThan64, IR::Type::U64, false, false,
+			                   true);
+			return;
 		case O::V_CMPX_GT_I64:
-			EmitIntegerCompare(inst, IR::ValueOpcode::SLessThan64, IR::Type::U64, false, true);
+			EmitIntegerCompare(inst, IR::ValueOpcode::SLessThan64, IR::Type::U64, false, true,
+			                   true);
 			return;
 		case O::V_CMP_GE_I64:
+			EmitIntegerCompare(inst, IR::ValueOpcode::SLessThanEqual64, IR::Type::U64, false, false,
+			                   true);
+			return;
 		case O::V_CMPX_GE_I64:
-			EmitIntegerCompare(inst, IR::ValueOpcode::SLessThanEqual64, IR::Type::U64, false, true);
+			EmitIntegerCompare(inst, IR::ValueOpcode::SLessThanEqual64, IR::Type::U64, false, true,
+			                   true);
 			return;
 		case O::V_CMP_LE_U64:
+			EmitIntegerCompare(inst, IR::ValueOpcode::ULessThanEqual64, IR::Type::U64, false, false);
+			return;
 		case O::V_CMPX_LE_U64:
-			EmitIntegerCompare(inst, IR::ValueOpcode::ULessThanEqual64, IR::Type::U64, false);
+			EmitIntegerCompare(inst, IR::ValueOpcode::ULessThanEqual64, IR::Type::U64, false, true);
 			return;
 		case O::V_CMP_GE_U64:
+			EmitIntegerCompare(inst, IR::ValueOpcode::UGreaterThanEqual64, IR::Type::U64, false, false);
+			return;
 		case O::V_CMPX_GE_U64:
-			EmitIntegerCompare(inst, IR::ValueOpcode::UGreaterThanEqual64, IR::Type::U64, false);
+			EmitIntegerCompare(inst, IR::ValueOpcode::UGreaterThanEqual64, IR::Type::U64, false, true);
 			return;
 
 		case O::V_CMP_EQ_U16:
-		case O::V_CMPX_EQ_U16:
-			EmitInteger16Compare(inst, IR::ValueOpcode::IEqual32, false);
+			EmitInteger16Compare(inst, IR::ValueOpcode::IEqual32, false, false);
 			return;
 		case O::V_CMP_EQ_I16:
+			EmitInteger16Compare(inst, IR::ValueOpcode::IEqual32, true, false);
+			return;
 		case O::V_CMPX_EQ_I16:
-			EmitInteger16Compare(inst, IR::ValueOpcode::IEqual32, true);
+			EmitInteger16Compare(inst, IR::ValueOpcode::IEqual32, true, true);
 			return;
 		case O::V_CMP_NE_U16:
+			EmitInteger16Compare(inst, IR::ValueOpcode::INotEqual32, false, false);
+			return;
 		case O::V_CMPX_NE_U16:
-			EmitInteger16Compare(inst, IR::ValueOpcode::INotEqual32, false);
+			EmitInteger16Compare(inst, IR::ValueOpcode::INotEqual32, false, true);
 			return;
 		case O::V_CMP_NE_I16:
+			EmitInteger16Compare(inst, IR::ValueOpcode::INotEqual32, true, false);
+			return;
 		case O::V_CMPX_NE_I16:
-			EmitInteger16Compare(inst, IR::ValueOpcode::INotEqual32, true);
+			EmitInteger16Compare(inst, IR::ValueOpcode::INotEqual32, true, true);
 			return;
 		case O::V_CMP_GT_U16:
+			EmitInteger16Compare(inst, IR::ValueOpcode::UGreaterThan32, false, false);
+			return;
 		case O::V_CMPX_GT_U16:
-			EmitInteger16Compare(inst, IR::ValueOpcode::UGreaterThan32, false);
+			EmitInteger16Compare(inst, IR::ValueOpcode::UGreaterThan32, false, true);
 			return;
 		case O::V_CMP_GE_U16:
-			EmitInteger16Compare(inst, IR::ValueOpcode::UGreaterThanEqual32, false);
+			EmitInteger16Compare(inst, IR::ValueOpcode::UGreaterThanEqual32, false, false);
 			return;
 		case O::V_CMP_LT_U16:
+			EmitInteger16Compare(inst, IR::ValueOpcode::ULessThan32, false, false);
+			return;
 		case O::V_CMPX_LT_U16:
-			EmitInteger16Compare(inst, IR::ValueOpcode::ULessThan32, false);
+			EmitInteger16Compare(inst, IR::ValueOpcode::ULessThan32, false, true);
+			return;
+		case O::V_CMPX_EQ_U16:
+			EmitInteger16Compare(inst, IR::ValueOpcode::IEqual32, false, true);
 			return;
 		case O::V_CMP_LE_U16:
-			EmitInteger16Compare(inst, IR::ValueOpcode::ULessThanEqual32, false);
+			EmitInteger16Compare(inst, IR::ValueOpcode::ULessThanEqual32, false, false);
 			return;
 		case O::V_CMP_GT_I16:
+			EmitInteger16Compare(inst, IR::ValueOpcode::SGreaterThan32, true, false);
+			return;
 		case O::V_CMPX_GT_I16:
-			EmitInteger16Compare(inst, IR::ValueOpcode::SGreaterThan32, true);
+			EmitInteger16Compare(inst, IR::ValueOpcode::SGreaterThan32, true, true);
 			return;
 		case O::V_CMP_GE_I16:
+			EmitInteger16Compare(inst, IR::ValueOpcode::SGreaterThanEqual32, true, false);
+			return;
 		case O::V_CMPX_GE_I16:
-			EmitInteger16Compare(inst, IR::ValueOpcode::SGreaterThanEqual32, true);
+			EmitInteger16Compare(inst, IR::ValueOpcode::SGreaterThanEqual32, true, true);
 			return;
 		case O::V_CMP_LT_I16:
+			EmitInteger16Compare(inst, IR::ValueOpcode::SLessThan32, true, false);
+			return;
 		case O::V_CMPX_LT_I16:
-			EmitInteger16Compare(inst, IR::ValueOpcode::SLessThan32, true);
+			EmitInteger16Compare(inst, IR::ValueOpcode::SLessThan32, true, true);
 			return;
 		case O::V_CMP_LE_I16:
+			EmitInteger16Compare(inst, IR::ValueOpcode::SLessThanEqual32, true, false);
+			return;
 		case O::V_CMPX_LE_I16:
-			EmitInteger16Compare(inst, IR::ValueOpcode::SLessThanEqual32, true);
+			EmitInteger16Compare(inst, IR::ValueOpcode::SLessThanEqual32, true, true);
 			return;
 
-		case O::V_CMP_F_F32: EmitCompareConstant(inst, false, false); return;
-		case O::V_CMP_TRU_F32: EmitCompareConstant(inst, true, false); return;
+		case O::V_CMP_F_F32: EmitCompareConstant(inst, false, false, false); return;
+		case O::V_CMP_TRU_F32: EmitCompareConstant(inst, true, false, false); return;
 		case O::V_CMP_EQ_F32:
-		case O::V_CMPX_EQ_F32:
-			EmitFloatCompare(inst, IR::ValueOpcode::FPOrdEqual32, false);
+			EmitFloatCompare(inst, IR::ValueOpcode::FPOrdEqual32, false, false);
 			return;
 		case O::V_CMP_EQ_F64:
-		case O::V_CMPX_EQ_F64:
-			EmitFloatCompare(inst, IR::ValueOpcode::FPOrdEqual64, false);
+			// Some GPUs miscompile OpFOrdEqual64; derive EQ from integer bit logic.
+			EmitFloatEqual(inst, false, true);
 			return;
 		case O::V_CMP_LE_F64:
+			EmitFloatCompare(inst, IR::ValueOpcode::FPOrdLessThanEqual64, false, false);
+			return;
 		case O::V_CMPX_LE_F64:
-			EmitFloatCompare(inst, IR::ValueOpcode::FPOrdLessThanEqual64, false);
+			EmitFloatCompare(inst, IR::ValueOpcode::FPOrdLessThanEqual64, false, true);
 			return;
-		case O::V_CMP_GE_F64:
 		case O::V_CMPX_GE_F64:
-			EmitFloatCompare(inst, IR::ValueOpcode::FPOrdGreaterThanEqual64, false);
+			EmitFloatCompare(inst, IR::ValueOpcode::FPOrdGreaterThanEqual64, false, true);
 			return;
-		case O::V_CMP_F_F64:
-		case O::V_CMPX_F_F64: EmitCompareConstant(inst, false, false); return;
-		case O::V_CMP_TRU_F64:
-		case O::V_CMPX_TRU_F64: EmitCompareConstant(inst, true, false); return;
+		case O::V_CMP_F_F64: EmitCompareConstant(inst, false, false, false); return;
+		case O::V_CMP_TRU_F64: EmitCompareConstant(inst, true, false, false); return;
+		case O::V_CMPX_F_F64: EmitCompareConstant(inst, false, false, true); return;
+		case O::V_CMPX_TRU_F64: EmitCompareConstant(inst, true, false, true); return;
 		case O::V_CMP_LT_F64:
+			EmitFloatCompare(inst, IR::ValueOpcode::FPOrdLessThan64, false, false);
+			return;
 		case O::V_CMPX_LT_F64:
-			EmitFloatCompare(inst, IR::ValueOpcode::FPOrdLessThan64, false);
+			EmitFloatCompare(inst, IR::ValueOpcode::FPOrdLessThan64, false, true);
+			return;
+		case O::V_CMPX_EQ_F64:
+			EmitFloatEqual(inst, true, true);
 			return;
 		case O::V_CMP_GT_F64:
+			EmitFloatCompare(inst, IR::ValueOpcode::FPOrdGreaterThan64, false, false);
+			return;
 		case O::V_CMPX_GT_F64:
-			EmitFloatCompare(inst, IR::ValueOpcode::FPOrdGreaterThan64, false);
+			EmitFloatCompare(inst, IR::ValueOpcode::FPOrdGreaterThan64, false, true);
 			return;
 		case O::V_CMP_LG_F64:
+			// Some GPUs miscompile OpFOrdNotEqual/OpFUnordEqual on F64, so derive the
+			// ordered compare from FPOrdEqual64 and FPIsNan64 instead.
+			EmitFloatNotEqual(inst, false, true);
+			return;
 		case O::V_CMPX_LG_F64:
-			EmitFloatCompare(inst, IR::ValueOpcode::FPOrdNotEqual64, false);
+			EmitFloatNotEqual(inst, false, true);

Major · Functional Correctness · Quick win

Pass true for the V_CMPX_LG_F64 EXEC update.

This case passes cmpx=false. EmitCompareResult therefore calls WriteMask instead of updating the per-lane EXEC predicate and both EXEC words. If the operands are equal, lanes that should become inactive can continue executing subsequent shader operations.

Proposed fix

-			EmitFloatNotEqual(inst, false, true);
+			EmitFloatNotEqual(inst, true, true);
Committable suggestion

IMPORTANT
Review the replacement and indentation, then test before committing.

			EmitFloatNotEqual(inst, true, true);
**@⁠coderabbitai[bot]** on GitHub · 2026-11-13 04:39 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2213#discussion_r4559714380) On `src/graphics/shader/recompiler/frontend/translate/Vector.cpp` line 288 (outdated): ```diff @@ -25,311 +23,451 @@ void Translator::EmitVector(const Decoder::Instruction& inst) { case O::V_PERMLANEX16_B32: V_PERMLANE16_B32(inst, true); return; case O::V_CMP_F_I32: - case O::V_CMP_F_U32: EmitCompareConstant(inst, false, false); return; + case O::V_CMP_F_U32: EmitCompareConstant(inst, false, false, false); return; case O::V_CMP_T_I32: - case O::V_CMP_T_U32: EmitCompareConstant(inst, true, false); return; + case O::V_CMP_T_U32: EmitCompareConstant(inst, true, false, false); return; case O::V_CMP_EQ_U32: case O::V_CMP_EQ_I32: + EmitIntegerCompare(inst, IR::ValueOpcode::IEqual32, IR::Type::U32, false, false); + return; case O::V_CMPX_EQ_U32: case O::V_CMPX_EQ_I32: - EmitIntegerCompare(inst, IR::ValueOpcode::IEqual32, IR::Type::U32, false); + EmitIntegerCompare(inst, IR::ValueOpcode::IEqual32, IR::Type::U32, false, true); return; case O::V_CMP_NE_U32: case O::V_CMP_NE_I32: + EmitIntegerCompare(inst, IR::ValueOpcode::INotEqual32, IR::Type::U32, false, false); + return; case O::V_CMPX_NE_U32: case O::V_CMPX_NE_I32: - EmitIntegerCompare(inst, IR::ValueOpcode::INotEqual32, IR::Type::U32, false); + EmitIntegerCompare(inst, IR::ValueOpcode::INotEqual32, IR::Type::U32, false, true); return; case O::V_CMP_GT_U32: + EmitIntegerCompare(inst, IR::ValueOpcode::UGreaterThan32, IR::Type::U32, false, false); + return; case O::V_CMPX_GT_U32: - EmitIntegerCompare(inst, IR::ValueOpcode::UGreaterThan32, IR::Type::U32, false); + EmitIntegerCompare(inst, IR::ValueOpcode::UGreaterThan32, IR::Type::U32, false, true); return; case O::V_CMP_GE_U32: + EmitIntegerCompare(inst, IR::ValueOpcode::UGreaterThanEqual32, IR::Type::U32, false, + false); + return; case O::V_CMPX_GE_U32: - EmitIntegerCompare(inst, IR::ValueOpcode::UGreaterThanEqual32, IR::Type::U32, false); + EmitIntegerCompare(inst, IR::ValueOpcode::UGreaterThanEqual32, IR::Type::U32, false, + true); return; case O::V_CMP_LT_U32: + EmitIntegerCompare(inst, IR::ValueOpcode::ULessThan32, IR::Type::U32, false, false); + return; case O::V_CMPX_LT_U32: - EmitIntegerCompare(inst, IR::ValueOpcode::ULessThan32, IR::Type::U32, false); + EmitIntegerCompare(inst, IR::ValueOpcode::ULessThan32, IR::Type::U32, false, true); return; case O::V_CMP_LE_U32: + EmitIntegerCompare(inst, IR::ValueOpcode::ULessThanEqual32, IR::Type::U32, false, + false); + return; case O::V_CMPX_LE_U32: - EmitIntegerCompare(inst, IR::ValueOpcode::ULessThanEqual32, IR::Type::U32, false); + EmitIntegerCompare(inst, IR::ValueOpcode::ULessThanEqual32, IR::Type::U32, false, true); return; case O::V_CMP_GT_I32: + EmitIntegerCompare(inst, IR::ValueOpcode::SGreaterThan32, IR::Type::U32, false, false); + return; case O::V_CMPX_GT_I32: - EmitIntegerCompare(inst, IR::ValueOpcode::SGreaterThan32, IR::Type::U32, false); + EmitIntegerCompare(inst, IR::ValueOpcode::SGreaterThan32, IR::Type::U32, false, true); return; case O::V_CMP_GE_I32: + EmitIntegerCompare(inst, IR::ValueOpcode::SGreaterThanEqual32, IR::Type::U32, false, + false); + return; case O::V_CMPX_GE_I32: - EmitIntegerCompare(inst, IR::ValueOpcode::SGreaterThanEqual32, IR::Type::U32, false); + EmitIntegerCompare(inst, IR::ValueOpcode::SGreaterThanEqual32, IR::Type::U32, false, + true); return; case O::V_CMP_LT_I32: + EmitIntegerCompare(inst, IR::ValueOpcode::SLessThan32, IR::Type::U32, false, false); + return; case O::V_CMPX_LT_I32: - EmitIntegerCompare(inst, IR::ValueOpcode::SLessThan32, IR::Type::U32, false); + EmitIntegerCompare(inst, IR::ValueOpcode::SLessThan32, IR::Type::U32, false, true); return; case O::V_CMP_LE_I32: + EmitIntegerCompare(inst, IR::ValueOpcode::SLessThanEqual32, IR::Type::U32, false, + false); + return; case O::V_CMPX_LE_I32: - EmitIntegerCompare(inst, IR::ValueOpcode::SLessThanEqual32, IR::Type::U32, false); + EmitIntegerCompare(inst, IR::ValueOpcode::SLessThanEqual32, IR::Type::U32, false, true); return; case O::V_CMP_F_I64: - case O::V_CMP_F_U64: - case O::V_CMPX_F_I64: - case O::V_CMPX_F_U64: EmitCompareConstant(inst, false, false); return; + case O::V_CMP_F_U64: EmitCompareConstant(inst, false, false, false); return; case O::V_CMP_T_I64: - case O::V_CMP_T_U64: + case O::V_CMP_T_U64: EmitCompareConstant(inst, true, false, false); return; + case O::V_CMPX_F_I64: + case O::V_CMPX_F_U64: EmitCompareConstant(inst, false, false, true); return; case O::V_CMPX_T_I64: - case O::V_CMPX_T_U64: EmitCompareConstant(inst, true, false); return; + case O::V_CMPX_T_U64: EmitCompareConstant(inst, true, false, true); return; case O::V_CMP_EQ_I64: case O::V_CMP_EQ_U64: + EmitIntegerCompare(inst, IR::ValueOpcode::IEqual64, IR::Type::U64, false, false); + return; case O::V_CMPX_EQ_I64: case O::V_CMPX_EQ_U64: - EmitIntegerCompare(inst, IR::ValueOpcode::IEqual64, IR::Type::U64, false); + EmitIntegerCompare(inst, IR::ValueOpcode::IEqual64, IR::Type::U64, false, true); return; case O::V_CMP_LT_U64: + EmitIntegerCompare(inst, IR::ValueOpcode::ULessThan64, IR::Type::U64, false, false); + return; case O::V_CMPX_LT_U64: - EmitIntegerCompare(inst, IR::ValueOpcode::ULessThan64, IR::Type::U64, false); + EmitIntegerCompare(inst, IR::ValueOpcode::ULessThan64, IR::Type::U64, false, true); return; case O::V_CMP_GT_U64: + EmitIntegerCompare(inst, IR::ValueOpcode::UGreaterThan64, IR::Type::U64, false, false); + return; case O::V_CMPX_GT_U64: - EmitIntegerCompare(inst, IR::ValueOpcode::UGreaterThan64, IR::Type::U64, false); + EmitIntegerCompare(inst, IR::ValueOpcode::UGreaterThan64, IR::Type::U64, false, true); return; case O::V_CMP_NE_I64: case O::V_CMP_NE_U64: + EmitIntegerCompare(inst, IR::ValueOpcode::INotEqual64, IR::Type::U64, false, false); + return; case O::V_CMPX_NE_I64: case O::V_CMPX_NE_U64: - EmitIntegerCompare(inst, IR::ValueOpcode::INotEqual64, IR::Type::U64, false); + EmitIntegerCompare(inst, IR::ValueOpcode::INotEqual64, IR::Type::U64, false, true); return; case O::V_CMP_LT_I64: + EmitIntegerCompare(inst, IR::ValueOpcode::SLessThan64, IR::Type::U64, false, false); + return; case O::V_CMPX_LT_I64: - EmitIntegerCompare(inst, IR::ValueOpcode::SLessThan64, IR::Type::U64, false); + EmitIntegerCompare(inst, IR::ValueOpcode::SLessThan64, IR::Type::U64, false, true); return; case O::V_CMP_LE_I64: + EmitIntegerCompare(inst, IR::ValueOpcode::SLessThanEqual64, IR::Type::U64, false, false); + return; case O::V_CMPX_LE_I64: - EmitIntegerCompare(inst, IR::ValueOpcode::SLessThanEqual64, IR::Type::U64, false); + EmitIntegerCompare(inst, IR::ValueOpcode::SLessThanEqual64, IR::Type::U64, false, true); return; // The IR has no signed 64-bit greater-than: a > b is b < a, and a >= b is b <= a. case O::V_CMP_GT_I64: + EmitIntegerCompare(inst, IR::ValueOpcode::SLessThan64, IR::Type::U64, false, false, + true); + return; case O::V_CMPX_GT_I64: - EmitIntegerCompare(inst, IR::ValueOpcode::SLessThan64, IR::Type::U64, false, true); + EmitIntegerCompare(inst, IR::ValueOpcode::SLessThan64, IR::Type::U64, false, true, + true); return; case O::V_CMP_GE_I64: + EmitIntegerCompare(inst, IR::ValueOpcode::SLessThanEqual64, IR::Type::U64, false, false, + true); + return; case O::V_CMPX_GE_I64: - EmitIntegerCompare(inst, IR::ValueOpcode::SLessThanEqual64, IR::Type::U64, false, true); + EmitIntegerCompare(inst, IR::ValueOpcode::SLessThanEqual64, IR::Type::U64, false, true, + true); return; case O::V_CMP_LE_U64: + EmitIntegerCompare(inst, IR::ValueOpcode::ULessThanEqual64, IR::Type::U64, false, false); + return; case O::V_CMPX_LE_U64: - EmitIntegerCompare(inst, IR::ValueOpcode::ULessThanEqual64, IR::Type::U64, false); + EmitIntegerCompare(inst, IR::ValueOpcode::ULessThanEqual64, IR::Type::U64, false, true); return; case O::V_CMP_GE_U64: + EmitIntegerCompare(inst, IR::ValueOpcode::UGreaterThanEqual64, IR::Type::U64, false, false); + return; case O::V_CMPX_GE_U64: - EmitIntegerCompare(inst, IR::ValueOpcode::UGreaterThanEqual64, IR::Type::U64, false); + EmitIntegerCompare(inst, IR::ValueOpcode::UGreaterThanEqual64, IR::Type::U64, false, true); return; case O::V_CMP_EQ_U16: - case O::V_CMPX_EQ_U16: - EmitInteger16Compare(inst, IR::ValueOpcode::IEqual32, false); + EmitInteger16Compare(inst, IR::ValueOpcode::IEqual32, false, false); return; case O::V_CMP_EQ_I16: + EmitInteger16Compare(inst, IR::ValueOpcode::IEqual32, true, false); + return; case O::V_CMPX_EQ_I16: - EmitInteger16Compare(inst, IR::ValueOpcode::IEqual32, true); + EmitInteger16Compare(inst, IR::ValueOpcode::IEqual32, true, true); return; case O::V_CMP_NE_U16: + EmitInteger16Compare(inst, IR::ValueOpcode::INotEqual32, false, false); + return; case O::V_CMPX_NE_U16: - EmitInteger16Compare(inst, IR::ValueOpcode::INotEqual32, false); + EmitInteger16Compare(inst, IR::ValueOpcode::INotEqual32, false, true); return; case O::V_CMP_NE_I16: + EmitInteger16Compare(inst, IR::ValueOpcode::INotEqual32, true, false); + return; case O::V_CMPX_NE_I16: - EmitInteger16Compare(inst, IR::ValueOpcode::INotEqual32, true); + EmitInteger16Compare(inst, IR::ValueOpcode::INotEqual32, true, true); return; case O::V_CMP_GT_U16: + EmitInteger16Compare(inst, IR::ValueOpcode::UGreaterThan32, false, false); + return; case O::V_CMPX_GT_U16: - EmitInteger16Compare(inst, IR::ValueOpcode::UGreaterThan32, false); + EmitInteger16Compare(inst, IR::ValueOpcode::UGreaterThan32, false, true); return; case O::V_CMP_GE_U16: - EmitInteger16Compare(inst, IR::ValueOpcode::UGreaterThanEqual32, false); + EmitInteger16Compare(inst, IR::ValueOpcode::UGreaterThanEqual32, false, false); return; case O::V_CMP_LT_U16: + EmitInteger16Compare(inst, IR::ValueOpcode::ULessThan32, false, false); + return; case O::V_CMPX_LT_U16: - EmitInteger16Compare(inst, IR::ValueOpcode::ULessThan32, false); + EmitInteger16Compare(inst, IR::ValueOpcode::ULessThan32, false, true); + return; + case O::V_CMPX_EQ_U16: + EmitInteger16Compare(inst, IR::ValueOpcode::IEqual32, false, true); return; case O::V_CMP_LE_U16: - EmitInteger16Compare(inst, IR::ValueOpcode::ULessThanEqual32, false); + EmitInteger16Compare(inst, IR::ValueOpcode::ULessThanEqual32, false, false); return; case O::V_CMP_GT_I16: + EmitInteger16Compare(inst, IR::ValueOpcode::SGreaterThan32, true, false); + return; case O::V_CMPX_GT_I16: - EmitInteger16Compare(inst, IR::ValueOpcode::SGreaterThan32, true); + EmitInteger16Compare(inst, IR::ValueOpcode::SGreaterThan32, true, true); return; case O::V_CMP_GE_I16: + EmitInteger16Compare(inst, IR::ValueOpcode::SGreaterThanEqual32, true, false); + return; case O::V_CMPX_GE_I16: - EmitInteger16Compare(inst, IR::ValueOpcode::SGreaterThanEqual32, true); + EmitInteger16Compare(inst, IR::ValueOpcode::SGreaterThanEqual32, true, true); return; case O::V_CMP_LT_I16: + EmitInteger16Compare(inst, IR::ValueOpcode::SLessThan32, true, false); + return; case O::V_CMPX_LT_I16: - EmitInteger16Compare(inst, IR::ValueOpcode::SLessThan32, true); + EmitInteger16Compare(inst, IR::ValueOpcode::SLessThan32, true, true); return; case O::V_CMP_LE_I16: + EmitInteger16Compare(inst, IR::ValueOpcode::SLessThanEqual32, true, false); + return; case O::V_CMPX_LE_I16: - EmitInteger16Compare(inst, IR::ValueOpcode::SLessThanEqual32, true); + EmitInteger16Compare(inst, IR::ValueOpcode::SLessThanEqual32, true, true); return; - case O::V_CMP_F_F32: EmitCompareConstant(inst, false, false); return; - case O::V_CMP_TRU_F32: EmitCompareConstant(inst, true, false); return; + case O::V_CMP_F_F32: EmitCompareConstant(inst, false, false, false); return; + case O::V_CMP_TRU_F32: EmitCompareConstant(inst, true, false, false); return; case O::V_CMP_EQ_F32: - case O::V_CMPX_EQ_F32: - EmitFloatCompare(inst, IR::ValueOpcode::FPOrdEqual32, false); + EmitFloatCompare(inst, IR::ValueOpcode::FPOrdEqual32, false, false); return; case O::V_CMP_EQ_F64: - case O::V_CMPX_EQ_F64: - EmitFloatCompare(inst, IR::ValueOpcode::FPOrdEqual64, false); + // Some GPUs miscompile OpFOrdEqual64; derive EQ from integer bit logic. + EmitFloatEqual(inst, false, true); return; case O::V_CMP_LE_F64: + EmitFloatCompare(inst, IR::ValueOpcode::FPOrdLessThanEqual64, false, false); + return; case O::V_CMPX_LE_F64: - EmitFloatCompare(inst, IR::ValueOpcode::FPOrdLessThanEqual64, false); + EmitFloatCompare(inst, IR::ValueOpcode::FPOrdLessThanEqual64, false, true); return; - case O::V_CMP_GE_F64: case O::V_CMPX_GE_F64: - EmitFloatCompare(inst, IR::ValueOpcode::FPOrdGreaterThanEqual64, false); + EmitFloatCompare(inst, IR::ValueOpcode::FPOrdGreaterThanEqual64, false, true); return; - case O::V_CMP_F_F64: - case O::V_CMPX_F_F64: EmitCompareConstant(inst, false, false); return; - case O::V_CMP_TRU_F64: - case O::V_CMPX_TRU_F64: EmitCompareConstant(inst, true, false); return; + case O::V_CMP_F_F64: EmitCompareConstant(inst, false, false, false); return; + case O::V_CMP_TRU_F64: EmitCompareConstant(inst, true, false, false); return; + case O::V_CMPX_F_F64: EmitCompareConstant(inst, false, false, true); return; + case O::V_CMPX_TRU_F64: EmitCompareConstant(inst, true, false, true); return; case O::V_CMP_LT_F64: + EmitFloatCompare(inst, IR::ValueOpcode::FPOrdLessThan64, false, false); + return; case O::V_CMPX_LT_F64: - EmitFloatCompare(inst, IR::ValueOpcode::FPOrdLessThan64, false); + EmitFloatCompare(inst, IR::ValueOpcode::FPOrdLessThan64, false, true); + return; + case O::V_CMPX_EQ_F64: + EmitFloatEqual(inst, true, true); return; case O::V_CMP_GT_F64: + EmitFloatCompare(inst, IR::ValueOpcode::FPOrdGreaterThan64, false, false); + return; case O::V_CMPX_GT_F64: - EmitFloatCompare(inst, IR::ValueOpcode::FPOrdGreaterThan64, false); + EmitFloatCompare(inst, IR::ValueOpcode::FPOrdGreaterThan64, false, true); return; case O::V_CMP_LG_F64: + // Some GPUs miscompile OpFOrdNotEqual/OpFUnordEqual on F64, so derive the + // ordered compare from FPOrdEqual64 and FPIsNan64 instead. + EmitFloatNotEqual(inst, false, true); + return; case O::V_CMPX_LG_F64: - EmitFloatCompare(inst, IR::ValueOpcode::FPOrdNotEqual64, false); + EmitFloatNotEqual(inst, false, true); ``` <!-- coderabbit-ai-generated:v1 --> **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/major-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Major** · **Functional Correctness** · **Quick win** **Pass `true` for the `V_CMPX_LG_F64` EXEC update.** This case passes `cmpx=false`. `EmitCompareResult` therefore calls `WriteMask` instead of updating the per-lane EXEC predicate and both EXEC words. If the operands are equal, lanes that should become inactive can continue executing subsequent shader operations. <details> <summary>Proposed fix</summary> <dl> <dd> <br> ```diff - EmitFloatNotEqual(inst, false, true); + EmitFloatNotEqual(inst, true, true); ``` </dd> </dl> </details> <!-- suggestion_start --> <details> <summary>Committable suggestion</summary> <dl> <dd> <br> > <picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-warning.svg" width="20" height="20" align="absmiddle" alt=""></picture> **IMPORTANT** > Review the replacement and indentation, then test before committing. ```suggestion EmitFloatNotEqual(inst, true, true); ``` </dd> </dl> </details> <!-- suggestion_end --> <!-- fingerprinting:phantom:medusa:wombat61 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:594b457b65207534f0539d73 --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-13 04:39 UTC · original
On src/graphics/shader/recompiler/ir/passes/SrtWalker.cpp line 750 (outdated):

@@ -365,1063 +373,912 @@ class RuntimeValidator {
 };
 
 
-// Emits one x86 function per plan. Each value, per EXEC-mask context, is a memoized thunk with a
-// state byte (0 unevaluated, 1 unknown or in progress, 2 known, 3 a control Phi holding its first
-// value) and a qword slot; a reference is `call thunk; cmp state, 2`. Operands that are unknown,
-// constant or plain user data are folded at emission. Registers: rdi user data, rsi flat buffer,
-// rdx scratch, r8 capture cursor.
-class WalkerCompiler {
-public:
-	WalkerCompiler(ResourcePlan& plan, Xbyak::CodeGenerator& code): m_plan(plan), m_code(code) {}
-
-	void Compile(std::span<const Value> values);
-
-private:
-	enum class Kind : uint8_t { Unknown, Constant, UserData, ShaderBase, Node };
-	struct Operand {
-		Kind     kind  = Kind::Unknown;
-		uint64_t value = 0;
-
-		bool operator==(const Operand& other) const = default;
-	};
-	// masked: the operand depends on its context's EXEC mask, so it is not the root context's.
-	struct Ref {
-		Operand operand;
-		bool    masked = false;
-	};
-	struct Node {
-		const Inst*          inst    = nullptr;
-		uint32_t             context = 0;
-		Operand              result;
-		std::vector<Operand> args;
-		uint32_t             slot = 0, state = 0;
-		Xbyak::Label         label;
-		bool                 pending = true, referenced = false, masked = false;
-	};
+} // namespace
 
-	static constexpr auto Near = Xbyak::CodeGenerator::T_NEAR;
+void CompileSrtWalker(ResourcePlan& program) {
+	if (!program.resource_tracking_complete || !program.srt_plan_complete ||
+	    program.capture_specialization_reads || !program.control_flow.empty() ||
+	    program.srt_reads.empty()) return;
 
-	bool Thunk(uint32_t index) const {
-		const auto& node = m_nodes[index];
-		return node.referenced || node.result == Operand {Kind::Node, index};
+	using Reads = std::map<int32_t, const SrtRead*>;
+	std::map<uint32_t, Reads> roots;
+	std::unordered_map<const Inst*, Reads> pointer_uses;
+	std::unordered_map<const Inst*, int32_t> offsets;
+	for (const auto& read: program.srt_reads) {
+		const auto* inst = read.value.Resolve().TryInstruction();
+		if (inst == nullptr || inst->GetOpcode() != ValueOpcode::LoadAddressU32 ||
+		    inst->NumArgs() < 2 || !IsRawRead(program, *inst) ||
+		    read.flat_offset >= program.srt_reads.size()) return;
+		const auto offset = inst->Arg(1).Resolve();
+		if (!offset.IsImmediate() || offset.GetType() != Type::U32) return;
+		const auto& memory = program.memory_info[inst->Flags<SrtReadFlags>().index];
+		const auto relative =
+		    (static_cast<int64_t>(static_cast<int32_t>(memory.offset)) & ~int64_t {3}) +
+		    static_cast<int64_t>(offset.U32() & ~3u);
+		if (relative < INT32_MIN || relative > INT32_MAX ||
+		    !offsets.emplace(inst, static_cast<int32_t>(relative)).second) return;
+	}
+	uint32_t user_data_count = 0;
+	for (const auto& read: program.srt_reads) {
+		const auto* inst = read.value.ResolveInstruction();
+		const auto* handle = inst->Arg(0).Resolve().TryInstruction();
+		if (handle == nullptr || handle->GetOpcode() != ValueOpcode::GetAddressResource ||
+		    handle->NumArgs() != 2) return;
+		const auto* low = handle->Arg(0).Resolve().TryInstruction();
+		const auto* high = handle->Arg(1).Resolve().TryInstruction();
+		if (low == nullptr || high == nullptr) return;
+		Reads* uses = nullptr;
+		if (low->GetOpcode() == ValueOpcode::GetUserData &&
+		    high->GetOpcode() == ValueOpcode::GetUserData && low->NumArgs() == 1 &&
+		    high->NumArgs() == 1 && low->Arg(0).GetType() == Type::ScalarReg &&
+		    high->Arg(0).GetType() == Type::ScalarReg) {
+			const auto reg = RegIndex(low->Arg(0).ScalarRegister());
+			if (reg < program.user_data_base ||
+			    RegIndex(high->Arg(0).ScalarRegister()) != reg + 1u) return;
+			const auto base = reg - program.user_data_base;
+			user_data_count = std::max(user_data_count, base + 2u);
+			uses = &roots[base];
+		} else {
+			const auto lo = offsets.find(low);
+			const auto hi = offsets.find(high);
+			if (lo == offsets.end() || hi == offsets.end() ||
+			    static_cast<int64_t>(lo->second) + 4 != hi->second ||
+			    !EquivalentValue(program, low->Arg(0), high->Arg(0))) return;
+			uses = &pointer_uses[low];
+		}
+		if (!uses->emplace(offsets.at(inst), &read).second) return;
 	}
-	static bool MayBeUnknown(const Operand& operand) {
-		return operand.kind == Kind::Unknown || operand.kind == Kind::Node;
+	std::unordered_set<const Inst*> visited;
+	const auto reachable = [&](auto&& self, const Reads& reads) -> bool {
+		for (const auto& [offset, read]: reads) {
+			const auto* inst = read->value.ResolveInstruction();
+			const auto child = pointer_uses.find(inst);
+			if (child != pointer_uses.end() &&
+			    (!visited.insert(inst).second || !self(self, child->second))) return false;
+		}
+		return true;
+	};
+	for (const auto& [reg, reads]: roots) {
+		if (!reachable(reachable, reads)) return;
 	}
+	if (visited.size() != pointer_uses.size()) return;
 
-	uint32_t Context(Value mask) {
-		mask = mask.Resolve();
-		const auto found = std::ranges::find(m_masks, mask);
-		if (found != m_masks.end()) return static_cast<uint32_t>(found - m_masks.begin());
-		m_masks.push_back(mask);
-		return static_cast<uint32_t>(m_masks.size() - 1u);
+	program.srt_code = std::make_unique<Xbyak::CodeGenerator>(4096, Xbyak::AutoGrow);
+	auto& code = *program.srt_code;
+	Xbyak::Label failed, finished;
+	code.push(code.rbp);
+	code.mov(code.rbp, code.rsp);
+	code.cmp(code.r8, user_data_count);
+	code.jb(failed, Xbyak::CodeGenerator::T_NEAR);
+	code.mov(code.r9, AddressMask & ~uint64_t {3});
+	// Follow shadPS4's VisitPointer: copy one table level in offset order, then
+	// descend through its child pointers. Seed the descriptor evaluator's memo.
+	const auto visit = [&](auto&& self, int32_t pointer_offset, const Reads& reads) -> void {
+		code.push(code.rdi);
+		code.mov(code.rdi, code.qword[code.rdi + pointer_offset]);
+		code.and_(code.rdi, code.r9);
+		const auto first = reads.begin()->first;
+		const auto last = reads.rbegin()->first;
+		if (first < 0) {
+			code.mov(code.r10, -static_cast<int64_t>(first));
+			code.cmp(code.rdi, code.r10);
+			code.jb(failed, Xbyak::CodeGenerator::T_NEAR);
+		}
+		if (last > 0) {
+			code.mov(code.r10, AddressMask - last);
+			code.cmp(code.rdi, code.r10);
+			code.ja(failed, Xbyak::CodeGenerator::T_NEAR);
+		}
+		for (const auto& [offset, read]: reads) {
+			const auto index = read->value.ResolveInstruction()->EvaluationIndex(program.evaluation_value_count);
+			using Entry = ResourcePlan::EvaluationContext::Entry;
+			const auto slot = code.rdx + index * sizeof(Entry);
+			code.mov(code.r10d, code.dword[code.rdi + offset]);
+			code.mov(code.dword[code.rsi + read->flat_offset * sizeof(uint32_t)], code.r10d);
+			code.mov(code.qword[slot + offsetof(Entry, value)], code.r10);
+			code.mov(code.qword[slot + offsetof(Entry, generation)], code.rcx);
+		}
+		for (const auto& [offset, read]: reads) {
+			const auto child = pointer_uses.find(read->value.ResolveInstruction());
+			if (child == pointer_uses.end()) continue;
+			self(self, offset, child->second);
+		}
+		code.pop(code.rdi);
+	};
+	for (const auto& [reg, reads]: roots) {
+		visit(visit, reg * sizeof(uint32_t), reads);
 	}
+	code.mov(code.eax, 1);
+	code.jmp(finished, Xbyak::CodeGenerator::T_NEAR);
+	code.L(failed);
+	code.xor_(code.eax, code.eax);
+	code.L(finished);
+	code.mov(code.rsp, code.rbp);
+	code.pop(code.rbp);
+	code.ret();
+	code.readyRE();
+	EXIT_IF(Xbyak::GetError() != 0);
+}
 
-	void AddOutput(Value value, uint32_t gate);
-	void Consume(std::vector<std::vector<uint32_t>>& gates);
-	Ref Evaluate(Value value, uint32_t context);
-	Operand Analyze(uint32_t index);
-	Operand AnalyzeRead(Node& node, const auto& arg, Operand self);
-	void Layout();
-	void Gate(std::vector<uint32_t>& gates, const Xbyak::Label& skip);
-	void Zero(uint32_t offset, uint32_t size);
-	void Branch(const Operand& operand, const Xbyak::Label& unknown);
-	void Load(const Xbyak::Reg64& reg, const Operand& operand);
-	void Fetch(const Operand& operand, const Xbyak::Label& unknown);
-	void Set(void (Xbyak::CodeGenerator::*condition)(const Xbyak::Operand&));
-	void Store(const Node& node);
-	void EmitNode(uint32_t index);
-	void EmitRead(const Node& node);
-	void EmitStrict(const Node& node);
+SrtWalker::SrtWalker(const ResourcePlan& program, const SrtRuntime& runtime,
+                     SrtWalker* clean_evaluator)
+    : m_program(program), m_runtime(runtime), m_clean_evaluator(clean_evaluator),
+      m_session(this),
+      m_read_policy(clean_evaluator != nullptr ? 2u : 0u), m_context(AcquireContext()) {}
 
-	ResourcePlan&                                     m_plan;
-	Xbyak::CodeGenerator&                             m_code;
-	std::vector<Value>                                m_masks {Value {}};
-	std::deque<Node>                                  m_nodes;
-	std::map<std::pair<const Inst*, uint32_t>, uint32_t> m_memo;
-	std::vector<Value>                                m_outputs;
-	std::vector<std::vector<uint32_t>>                m_output_gates;
-	Xbyak::Label                                      m_ret;
-	uint32_t m_shader_base = 0, m_reach = 0, m_states = 0, m_states_end = 0;
-	uint32_t m_user_data = 0, m_captures = 0;
-};
+SrtWalker::SrtWalker(SrtWalker& parent, Value active_mask, bool clean,
+                     SrtWalker* clean_evaluator)
+    : m_program(parent.m_program), m_runtime(clean ? CleanRuntime(parent.m_runtime) : parent.m_runtime),
+      m_clean_evaluator(clean_evaluator), m_active_mask(active_mask.Resolve()),
+      m_reachable_blocks(parent.m_reachable_blocks), m_session(parent.m_session),
+      m_read_policy((parent.m_read_policy & 1u) | (clean ? 1u : 0u) |
+                    (clean_evaluator != nullptr ? 2u : 0u)), m_context(AcquireContext()) {}
+
+SrtWalker::~SrtWalker() {
+	if (m_session != this) return;
+	for (auto& context: m_program.evaluation_contexts)
+		if (context.session == this) context.session = nullptr;
+}
 
-void WalkerCompiler::AddOutput(Value value, uint32_t gate) {
-	const auto* inst = value.Resolve().TryInstruction();
-	if (inst == nullptr) return;
-	auto index = inst->WalkOutput();
-	if (index >= m_outputs.size() || m_outputs[index].TryInstruction() != inst) {
-		index = static_cast<uint32_t>(m_outputs.size());
-		inst->SetWalkOutput(index);
-		m_outputs.push_back(value.Resolve());
-		m_output_gates.emplace_back();
+bool SrtWalker::Evaluate(Value value, uint32_t& result) {
+	uint64_t wide = 0;
+	if (!EvaluateWide(value, wide)) {
+		return false;
 	}
-	m_output_gates[index].push_back(gate);
+	result = static_cast<uint32_t>(wide);
+	return true;
 }
 
-// Mirrors MaterializeResources: each descriptor it reads back is gated by the activity of the
-// resource root that needs it, and so are an indirect root's selector values.
-void WalkerCompiler::Consume(std::vector<std::vector<uint32_t>>& gates) {
-	const auto& sources = m_plan.descriptor_sources;
-	const auto  consume = [&](uint32_t root) {
-		if (root >= sources.size()) return;
-		const auto& indirect = sources[root].indirect_descriptor;
-		if (!indirect) {
-			gates[root].push_back(root);
-			return;
-		}
-		const auto add = [&](uint32_t source) {
-			if (source < sources.size()) gates[source].push_back(root);
-		};
-		if (indirect->sources.empty()) {
-			add(indirect->table_source);
-			if (indirect->selector) {
-				add(indirect->selector->source);
-				if (indirect->selector->rows) add(indirect->selector->rows->source);
-			}
-		}
-		for (const auto source: indirect->sources) add(source);
-		AddOutput(indirect->key_count, root);
-		AddOutput(indirect->selector_first, root);
-		AddOutput(indirect->selector_mask, root);
-	};
-	for (const auto& buffer: m_plan.info.buffers) consume(buffer.source);
-	for (const auto& image: m_plan.info.images) consume(image.source);
-	for (const auto& sampler: m_plan.info.samplers) {
-		const auto* indirect = sampler.source < sources.size() && sources[sampler.source].indirect_descriptor
-		    ? &*sources[sampler.source].indirect_descriptor : nullptr;
-		if (indirect == nullptr || indirect->sources.empty()) {
-			consume(sampler.source);
-		} else if (indirect->sources[0] < sources.size()) {
-			gates[indirect->sources[0]].push_back(indirect->sources[0]);
-		}
+ResourcePlan::EvaluationContext& SrtWalker::AcquireContext() {
+	ResourcePlan::EvaluationContext* unused = nullptr;
+	for (auto& context: m_program.evaluation_contexts) {
+		if (context.session == m_session && context.active_mask == m_active_mask &&
+		    context.read_policy == m_read_policy) return context;
+		if (context.session == nullptr && unused == nullptr) unused = &context;
 	}
-	const auto& fill = m_plan.uniform_fill;
-	if (fill.fill.words != 0) {
-		AddOutput(fill.pattern_size, UINT32_MAX);
-		AddOutput(fill.element_count, UINT32_MAX);
-		for (const auto value: fill.values) AddOutput(value, UINT32_MAX);
+	auto& context = unused != nullptr ? *unused : m_program.evaluation_contexts.emplace_back();
+	context.session = m_session;
+	context.active_mask = m_active_mask;
+	context.read_policy = m_read_policy;
+	context.generation += 4;
+	return context;
+}
+
+void SrtWalker::ResetUnknowns() {
+	for (auto& context: m_program.evaluation_contexts) {
+		if (context.session != m_session) continue;
+		for (auto& entry: context.values)
+			if (entry.generation == (context.generation | 2u)) entry.generation = 0;
 	}
 }
 
-WalkerCompiler::Ref WalkerCompiler::Evaluate(Value value, uint32_t context) {
+float SrtWalker::Float32(uint64_t bits) {
+	return std::bit_cast<float>(static_cast<uint32_t>(bits));
+}
+
+bool SrtWalker::EvaluateWide(Value value, uint64_t& result) {
 	value = value.Resolve();
-	if (value.IsEmpty()) return {};
 	if (value.IsImmediate()) {
-		uint64_t bits = 0;
-		return ImmediateBits(value, bits) ? Ref {{Kind::Constant, bits}} : Ref {};
+		switch (value.GetType()) {
+			case Type::U1: result = value.U1(); return true;
+			case Type::U8: result = value.U8(); return true;
+			case Type::U16: result = value.U16(); return true;
+			case Type::U32: result = value.U32(); return true;
+			case Type::U64: result = value.U64(); return true;
+			case Type::F32: result = std::bit_cast<uint32_t>(value.F32Value()); return true;
+			default: return false;
+		}
 	}
-	const auto mask = m_masks[context];
-	if (context != 0 && value == mask) return {{Kind::Constant, 1u}, true};
-	const auto* inst = value.TryInstruction();
-	if (inst == nullptr) return {};
-	const auto op = inst->GetOpcode();
-	if (context != 0 && IsRuntimeSelect(op) && inst->NumArgs() == 3 && inst->Arg(0).Resolve() == mask) {
-		return {Evaluate(inst->Arg(1), context).operand, true};
+	if (!m_active_mask.IsEmpty() && value == m_active_mask) {
+		result = 1u;
+		return true;
 	}
-	switch (op) {
-		case ValueOpcode::BitCastU32F32:
-		case ValueOpcode::BitCastF32U32:
-		case ValueOpcode::ConditionRef: return Evaluate(inst->Arg(0), context);
-		case ValueOpcode::CompositeExtractU32x2: {
-			const auto* source = inst->Arg(0).ResolveInstruction();
-			const auto  index  = inst->Arg(1).Resolve();
-			if (source == nullptr || source->GetOpcode() != ValueOpcode::CompositeConstructU32x2 ||
-			    !index.IsImmediate() || index.GetType() != Type::U32 || index.U32() >= 2u) return {};
-			return Evaluate(source->Arg(index.U32()), context);
-		}
-		case ValueOpcode::ReadFirstLane:
-			// The lane read does not depend on the EXEC mask it is read under.
-			return {Evaluate(inst->Arg(0), Context(inst->Arg(1))).operand};
-		case ValueOpcode::GetUserData: {
-			const auto reg = RegIndex(inst->Arg(0).ScalarRegister());
-			if (reg < m_plan.user_data_base || reg - m_plan.user_data_base >= m_plan.user_data_count) return {};
-			return {{Kind::UserData, reg - m_plan.user_data_base}};
-		}
-		case ValueOpcode::GetShaderBase: return {{Kind::ShaderBase}};
-		case ValueOpcode::Phi:
-			if (!m_plan.control_phi_predecessors.contains(inst)) {
-				const auto invariant = ResolveInvariantPhi(m_plan, value);
-				return invariant.IsEmpty() ? Ref {} : Evaluate(invariant, context);
-			}
-			break;
-		default: break;
+	auto* inst = value.TryInstruction();
+	if (inst == nullptr) {
+		return false;
+	}
+	if (!m_active_mask.IsEmpty() && IsRuntimeSelect(inst->GetOpcode()) &&
+	    inst->NumArgs() == 3 && inst->Arg(0).Resolve() == m_active_mask) {
+		return EvaluateWide(inst->Arg(1), result);
 	}
-	const auto [found, inserted] = m_memo.try_emplace({inst, context}, static_cast<uint32_t>(m_nodes.size()));
-	const auto index = found->second;
-	if (!inserted) {
-		auto& node = m_nodes[index];
-		if (!node.pending) return {node.result, node.masked};
-		// A cycle: the thunk reads as unknown while it runs.
-		node.referenced = true;
-		return {{Kind::Node, index}, context != 0};
+	const auto index = inst->EvaluationIndex(m_program.evaluation_value_count);
+	if (index >= m_context.values.size()) {
+		m_context.values.resize(m_program.evaluation_value_count);
 	}
-	auto& node   = m_nodes.emplace_back();
-	node.inst    = inst;
-	node.context = context;
-	node.result  = Analyze(index);
-	node.pending = false;
-	if (context != 0 && !node.masked && !node.referenced) {
-		node.result = Evaluate(value, 0).operand;
-		return {node.result};
+	if (m_context.values[index].generation == m_context.generation) {
+		result = m_context.values[index].value;
+		return true;
+	}
+	// Visiting and completed-unknown entries both stop repeated evaluation in this
+	// context. Only completed unknowns are retried when reachability becomes tighter.
+	if (m_context.values[index].generation == (m_context.generation | 1u) ||
+	    m_context.values[index].generation == (m_context.generation | 2u)) {
+		return false;
 	}
-	return {node.result, node.masked};
+	m_context.values[index].generation = m_context.generation | 1u;
+	uint64_t out = 0;
+	const bool evaluated = EvaluateInst(*inst, out);
+	// Recursive evaluation may grow the dense memo vector.
+	auto& memo = m_context.values[index];
+	if (!evaluated) {
+		memo.generation = m_context.generation | 2u;
+		return false;
+	}
+	memo.value      = out;
+	memo.generation = m_context.generation;
+	result = out;
+	return true;
 }
 
-WalkerCompiler::Operand WalkerCompiler::Analyze(uint32_t index) {
-	auto&       node = m_nodes[index];
-	const auto& inst = *node.inst;
-	const auto  self = Operand {Kind::Node, index};
-	const auto  arg  = [&](Value value) {
-		const auto ref = Evaluate(value, node.context);
-		node.masked |= ref.masked;
-		return ref.operand;
-	};
-	const auto constant = [](uint64_t value) { return Operand {Kind::Constant, value}; };
-	switch (inst.GetOpcode()) {
-		case ValueOpcode::Phi: {
-			bool known = false;
-			for (size_t i = 0; i < inst.NumArgs(); ++i) {
-				node.args.push_back(arg(inst.Arg(i)));
-				known |= node.args.back().kind != Kind::Unknown;
-			}
-			return known ? self : Operand {};
-		}
-		case ValueOpcode::LoadAddressU32:
-		case ValueOpcode::ReadConstBuffer:
-		case ValueOpcode::LoadBufferU32: return AnalyzeRead(node, arg, self);
-		case ValueOpcode::SelectU1:
-		case ValueOpcode::SelectU32:
-		case ValueOpcode::SelectF32: {
-			const auto predicate = arg(inst.Arg(0));
-			if (predicate.kind == Kind::Unknown) return {};
-			if (predicate.kind == Kind::Constant) return arg(inst.Arg(predicate.value != 0u ? 1 : 2));
-			node.args = {predicate, arg(inst.Arg(1)), arg(inst.Arg(2))};
-			return node.args[1].kind == Kind::Unknown && node.args[2].kind == Kind::Unknown ? Operand {} : self;
-		}
-		case ValueOpcode::ULessThan32:
-		case ValueOpcode::ULessThanEqual32: {
-			// No U32 is below zero and every U32 is at least zero, including an unknown loop-carried
-			// or varying lane value. args[0] is that zero-tested bound.
-			const bool less  = inst.GetOpcode() == ValueOpcode::ULessThan32;
-			const auto bound = arg(inst.Arg(less ? 1 : 0));
-			if (bound.kind == Kind::Unknown) return {};
-			if (bound.kind == Kind::Constant && static_cast<uint32_t>(bound.value) == 0u) return constant(!less);
-			node.args = {bound, arg(inst.Arg(less ? 0 : 1))};
-			return node.args[1].kind == Kind::Unknown && bound.kind == Kind::Constant ? Operand {} : self;
-		}
-		case ValueOpcode::LogicalOr:
-		case ValueOpcode::LogicalAnd: {
-			// A deciding operand, nonzero for Or and zero for And, fixes the result.
-			const bool conjunction = inst.GetOpcode() == ValueOpcode::LogicalAnd;
-			const auto decides     = [&](const Operand& x) {
-				return x.kind == Kind::Constant && (x.value == 0u) == conjunction;
-			};
-			const auto a = arg(inst.Arg(0));
-			if (decides(a)) return constant(!conjunction);
-			const auto b = arg(inst.Arg(1));
-			if (decides(b)) return constant(!conjunction);
-			if (a.kind == Kind::Constant && b.kind == Kind::Constant) return constant(conjunction);
-			if (a.kind == Kind::Constant && b.kind == Kind::Unknown) return {};
-			// Only lanes satisfying the left EXEC factor can make a conjunction true, so an
-			// unknown left side retries the right one under that factor as its mask.
-			Operand refined;
-			if (conjunction && MayBeUnknown(a)) {
-				refined = Evaluate(inst.Arg(1), Context(inst.Arg(0))).operand;
-				if (refined == b || (refined.kind == Kind::Constant && refined.value != 0u)) refined = {};
-				if (a.kind == Kind::Unknown && refined.kind == Kind::Constant) return constant(0u);
-			}
-			if (a.kind == Kind::Unknown && refined.kind == Kind::Unknown &&
-			    (b.kind == Kind::Unknown || b.kind == Kind::Constant)) return {};
-			node.args = {a, b, refined};
-			return self;
-		}
-		case ValueOpcode::CompositeExtractU64: {
-			const auto component = inst.Arg(1).Resolve();
-			if (!component.IsImmediate() || component.GetType() != Type::U32 || component.U32() >= 2u) return {};
-			[[fallthrough]];
+bool SrtWalker::Arg(const Inst& inst, size_t index, uint64_t& result) {
+	return EvaluateWide(inst.Arg(index), result);
+}
+
+bool SrtWalker::EvaluatePhi(const Inst& inst, uint64_t& result) {
+	if (const auto control = m_program.control_phi_predecessors.find(&inst);
+	    control != m_program.control_phi_predecessors.end()) {
+		bool found = false;
+		for (size_t index = 0; index < inst.NumArgs(); ++index) {
+			if (m_reachable_blocks != nullptr &&
+			    !m_reachable_blocks->at(control->second[index])) continue;
+			uint64_t incoming = 0;
+			if (!Arg(inst, index, incoming) || (found && incoming != result)) return false;
+			result = incoming;
+			found = true;
 		}
-		default:
-			// The other runtime-uniform ops are strict; a U32x2 pair is only read through its extracts.
-			if (!IsRuntimeUniformOp(inst.GetOpcode()) || inst.GetOpcode() == ValueOpcode::CompositeConstructU32x2)
-				return {};
-			for (size_t i = 0; i < inst.NumArgs(); ++i) {
-				node.args.push_back(arg(inst.Arg(i)));
-				if (node.args.back().kind == Kind::Unknown) return {};
-			}
-			return self;
+		return found;
 	}
+	const auto value = ResolveInvariantPhi(m_program, Value(const_cast<Inst*>(&inst)));
+	return !value.IsEmpty() && EvaluateWide(value, result);
 }
 
-WalkerCompiler::Operand WalkerCompiler::AnalyzeRead(Node& node, const auto& arg, Operand self) {
-	const auto& inst = *node.inst;
-	const auto* handle = inst.Arg(0).ResolveInstruction();
-	if (!IsRawRead(m_plan, inst) || handle == nullptr) return {};
-	const bool vector = inst.GetOpcode() == ValueOpcode::LoadBufferU32;
-	if (vector) {
-		const auto guard = arg(inst.Arg(4));
-		if (guard.kind == Kind::Unknown) return {};
-		if (guard.kind == Kind::Constant && guard.value == 0u) return {Kind::Constant, 0u};
-		node.args.push_back(guard);
+bool SrtWalker::EvaluateExtract(const Inst& inst, uint64_t& result) {
+	const auto index = inst.Arg(1).Resolve();
+	if (!index.IsImmediate() || index.GetType() != Type::U32) {
+		return false;
 	}
-	const bool buffer = inst.GetOpcode() != ValueOpcode::LoadAddressU32;
-	const auto offset = static_cast<int32_t>(m_plan.memory_info[inst.Flags<MemoryFlags>().index].offset);
-	bool failed = buffer && (handle->NumArgs() != 4u || offset < 0);
-	for (const auto& word: {handle->Arg(0), handle->Arg(1), inst.Arg(1)}) {
-		node.args.push_back(arg(word));
-		failed |= node.args.back().kind == Kind::Unknown;
+	const auto component = index.U32();
+	if (component >= 2u) {
+		return false;
 	}
-	for (uint32_t word = 2; buffer && !failed && word < 4u; ++word) {
-		node.args.push_back(arg(handle->Arg(word)));
-		failed |= node.args.back().kind == Kind::Unknown;
+	if (inst.GetOpcode() == ValueOpcode::CompositeExtractU64) {
+		uint64_t packed = 0;
+		if (!Arg(inst, 0, packed)) {
+			return false;
+		}
+		result = static_cast<uint32_t>(packed >> (component * 32u));
+		return true;
 	}
-	if (!failed) return self;
-	// A disabled vector lane still reads zero.
-	if (!vector || node.args[0].kind == Kind::Constant) return {};
-	node.args.resize(1);
-	return self;
-}
-
-void WalkerCompiler::Layout() {
-	uint32_t offset = OutputOffset(m_plan) + static_cast<uint32_t>(m_outputs.size()) * 8u;
-	m_shader_base = offset;
-	offset += 8u;
-	for (uint32_t index = 0; index < m_nodes.size(); ++index) {
-		if (!Thunk(index)) continue;
-		m_nodes[index].slot = offset;
-		offset += 8u;
+	const auto* source = inst.Arg(0).ResolveInstruction();
+	if (source == nullptr) {
+		return false;
 	}
-	m_reach = offset;
-	offset += static_cast<uint32_t>(m_plan.control_flow.size());
-	m_states = offset;
-	for (uint32_t index = 0; index < m_nodes.size(); ++index) {
-		if (Thunk(index)) m_nodes[index].state = offset++;
+	if (source->GetOpcode() == ValueOpcode::CompositeConstructU32x2) {
+		return EvaluateWide(source->Arg(component), result);
 	}
-	m_states_end = offset;
-	// Captured addresses come last; EmitRead counts them.
-	m_plan.srt_captures = (offset + 7u) & ~7u;
-}
-
-// Falls through when any gating source is active. The list is not empty.
-void WalkerCompiler::Gate(std::vector<uint32_t>& gates, const Xbyak::Label& skip) {
-	auto& c = m_code;
-	std::ranges::sort(gates);
-	if (gates.back() == UINT32_MAX) return;
-	gates.erase(std::unique(gates.begin(), gates.end()), gates.end());
-	Xbyak::Label active;
-	for (size_t i = 0; i < gates.size(); ++i) {
-		c.cmp(c.byte[c.rdx + ActiveOffset(m_plan) + gates[i]], 0);
-		if (i + 1u < gates.size()) {
-			c.jne(active, Near);
-		} else {
-			c.je(skip, Near);
+	if (source->GetOpcode() == ValueOpcode::IAddCarry32) {
+		uint64_t lhs = 0;
+		uint64_t rhs = 0;
+		if (!Arg(*source, 0, lhs) || !Arg(*source, 1, rhs)) {
+			return false;
 		}
+		const auto sum =
+		    static_cast<uint64_t>(static_cast<uint32_t>(lhs)) + static_cast<uint32_t>(rhs);
+		result =
+		    component == 0u ? static_cast<uint32_t>(sum) : static_cast<uint32_t>(sum >> 32u);
+		return true;
 	}
-	c.L(active);
+	return false;
 }
 
-void WalkerCompiler::Zero(uint32_t offset, uint32_t size) {
-	auto& c = m_code;
-	if (size == 0) return;
-	c.mov(c.r11, c.rdi);
-	c.lea(c.rdi, c.ptr[c.rdx + offset]);
-	c.mov(c.ecx, size);
-	c.xor_(c.eax, c.eax);
-	c.rep();
-	c.stosb();
-	c.mov(c.rdi, c.r11);
-}
-
-// Jumps to unknown unless the operand has a value at run time.
-void WalkerCompiler::Branch(const Operand& operand, const Xbyak::Label& unknown) {
-	auto& c = m_code;
-	if (operand.kind == Kind::Unknown) {
-		c.jmp(unknown, Near);
-	} else if (operand.kind == Kind::Node) {
-		auto& node = m_nodes[operand.value];
-		c.call(node.label);
-		c.cmp(c.byte[c.rdx + node.state], 2);
-		c.jne(unknown, Near);
+bool SrtWalker::EvaluateRawRead(const Inst& inst, uint64_t& result) {
+	const auto flags = inst.Flags<SrtReadFlags>();
+	if (flags.index >= m_program.memory_info.size()) {
+		return false;
 	}
-}
-
-void WalkerCompiler::Load(const Xbyak::Reg64& reg, const Operand& operand) {
-	auto& c = m_code;
-	switch (operand.kind) {
-		case Kind::Constant: c.mov(reg, operand.value); break;
-		case Kind::UserData:
-			m_user_data = std::max(m_user_data, static_cast<uint32_t>(operand.value) + 1u);
-			c.mov(reg.cvt32(), c.dword[c.rdi + operand.value * sizeof(uint32_t)]);
-			break;
-		case Kind::ShaderBase: c.mov(reg, c.qword[c.rdx + m_shader_base]); break;
-		case Kind::Node: c.mov(reg, c.qword[c.rdx + m_nodes[operand.value].slot]); break;
-		case Kind::Unknown: break;
+	const auto& mem    = m_program.memory_info[flags.index];
+	const bool vector = inst.GetOpcode() == ValueOpcode::LoadBufferU32;
+	const auto guard = vector ? inst.Arg(4).Resolve() : Value {};
+	if (vector && (guard.IsImmediate() || guard != m_active_mask)) {
+		uint64_t enabled = 0;
+		if (!Arg(inst, 4, enabled)) return false;
+		if (enabled == 0u) {
+			result = 0u;
+			return true;
+		}
 	}
-}
-
-// Loads the operand into rax, or jumps to unknown when it has no value at run time.
-void WalkerCompiler::Fetch(const Operand& operand, const Xbyak::Label& unknown) {
-	Branch(operand, unknown);
-	Load(m_code.rax, operand);
-}
-
-// Sets eax to 1 when the condition holds, else 0.
-void WalkerCompiler::Set(void (Xbyak::CodeGenerator::*condition)(const Xbyak::Operand&)) {
-	(m_code.*condition)(m_code.al);
-	m_code.movzx(m_code.eax, m_code.al);
-}
-
-void WalkerCompiler::Store(const Node& node) {
-	auto& c = m_code;
-	c.mov(c.qword[c.rdx + node.slot], c.rax);
-	c.mov(c.byte[c.rdx + node.state], 2);
-	c.ret();
-}
-
-void WalkerCompiler::EmitNode(uint32_t index) {
-	auto&       c    = m_code;
-	auto&       node = m_nodes[index];
-	const auto& args = node.args;
-	c.L(node.label);
-	c.cmp(c.byte[c.rdx + node.state], 0);
-	c.jne(m_ret, Near);
-	c.mov(c.byte[c.rdx + node.state], 1);
-	if (node.result != Operand {Kind::Node, index}) {
-		// A cycle referenced this value before it folded to another operand.
-		Fetch(node.result, m_ret);
-		Store(node);
-		return;
+	const auto* handle = inst.Arg(0).ResolveInstruction();
+	if (handle == nullptr) {
+		return false;
+	}
+	uint64_t low    = 0;
+	uint64_t high   = 0;
+	uint64_t offset = 0;
+	if (!Arg(*handle, 0, low) || !Arg(*handle, 1, high) || !Arg(inst, 1, offset)) {
+		return false;
 	}
-	switch (node.inst->GetOpcode()) {
-		case ValueOpcode::Phi: {
-			// Only predecessors reached by this walk contribute, and they must agree. The state is 3
-			// once one of them has stored the value; callers read it like 1, as unknown.
-			const auto& blocks = m_plan.control_phi_predecessors.at(node.inst);
-			const auto  state  = c.byte[c.rdx + node.state];
-			for (size_t i = 0; i < args.size(); ++i) {
-				Xbyak::Label next, first;
-				c.cmp(c.byte[c.rdx + m_reach + blocks[i]], 0);
-				c.je(next, Near);
-				Fetch(args[i], m_ret);
-				c.cmp(state, 1);
-				c.je(first, Near);
-				c.cmp(c.rax, c.qword[c.rdx + node.slot]);
-				c.jne(m_ret, Near);
-				c.jmp(next, Near);
-				c.L(first);
-				c.mov(c.qword[c.rdx + node.slot], c.rax);
-				c.mov(state, 3);
-				c.L(next);
-			}
-			c.cmp(state, 3);
-			c.jne(m_ret, Near);
-			c.mov(state, 2);
-			c.ret();
-			return;
+	const auto base      = ((high << 32u) | static_cast<uint32_t>(low)) & AddressMask;
+	const auto immediate = static_cast<int64_t>(static_cast<int32_t>(mem.offset));
+	uint64_t   address   = 0;
+	if (inst.GetOpcode() == ValueOpcode::ReadConstBuffer || vector) {
+		uint64_t records = 0;
+		uint64_t word3   = 0;
+		if (handle->NumArgs() != 4u || !Arg(*handle, 2, records) || !Arg(*handle, 3, word3)) {
+			return false;
 		}
-		case ValueOpcode::LoadAddressU32:
-		case ValueOpcode::ReadConstBuffer:
-		case ValueOpcode::LoadBufferU32: EmitRead(node); return;
-		case ValueOpcode::SelectU1:
-		case ValueOpcode::SelectU32:
-		case ValueOpcode::SelectF32: {
-			Xbyak::Label other;
-			Fetch(args[0], m_ret);
-			c.test(c.rax, c.rax);
-			c.jz(other, Near);
-			Fetch(args[1], m_ret);
-			Store(node);
-			c.L(other);
-			Fetch(args[2], m_ret);
-			Store(node);
-			return;
+		if (immediate < 0) {
+			return false;
 		}
-		case ValueOpcode::ULessThan32:
-		case ValueOpcode::ULessThanEqual32: {
-			const bool less = node.inst->GetOpcode() == ValueOpcode::ULessThan32;
-			Xbyak::Label bound_zero;
-			Fetch(args[0], m_ret);
-			c.test(c.eax, c.eax);
-			c.jz(bound_zero, Near);
-			Branch(args[1], m_ret);
-			Load(c.rax, args[0]);
-			Load(c.rcx, args[1]);
-			// ULT tests other < bound, ULE bound <= other.
-			c.cmp(c.ecx, c.eax);
-			Set(less ? &Xbyak::CodeGenerator::setb : &Xbyak::CodeGenerator::setae);
-			Store(node);
-			c.L(bound_zero);
-			c.mov(c.eax, uint32_t {!less});
-			Store(node);
-			return;
+		const auto byte_offset =
+		    (static_cast<uint64_t>(immediate) & ~uint64_t {3}) + (static_cast<uint32_t>(offset) & ~3u);
+		const auto stride  = (static_cast<uint32_t>(high) >> 16u) & 0x3fffu;
+		if (vector) {
+			// Only the uniform, unswizzled structured DWORD address is evaluated on the host.
+			if ((high & (1u << 31u)) != 0u || (word3 & ((1u << 23u) | 0xf0000000u)) != 0u)
+				return false;
+			if (stride == 0u || records == 0u || ((word3 >> 12u) & 0x7fu) == 0u) {
+				result = 0u;
+				return true;
+			}
 		}
-		case ValueOpcode::LogicalOr:
-		case ValueOpcode::LogicalAnd: {
-			const bool conjunction = node.inst->GetOpcode() == ValueOpcode::LogicalAnd;
-			Xbyak::Label unknown_left, refine, decided;
-			const auto decide = [&] {
-				if (conjunction) {
-					c.jz(decided, Near);
-				} else {
-					c.jnz(decided, Near);
-				}
-			};
-			Branch(args[0], unknown_left);
-			if (args[0].kind != Kind::Unknown) {
-				Load(c.rax, args[0]);
-				c.test(c.rax, c.rax);
-				decide();
-				Fetch(args[1], m_ret);
-				c.test(c.rax, c.rax);
-				Set(&Xbyak::CodeGenerator::setne);
-				Store(node);
-			}
-			c.L(unknown_left);
-			if (MayBeUnknown(args[0])) {
-				// Without the left side only a deciding right side, or a conjunction's zero
-				// refined right side, is known.
-				if (args[1].kind != Kind::Unknown) {
-					Fetch(args[1], refine);
-					c.test(c.rax, c.rax);
-					decide();
-				}
-				c.L(refine);
-				Fetch(args[2], m_ret);
-				c.test(c.rax, c.rax);
-				c.jnz(m_ret, Near);
-			}
-			c.L(decided);
-			c.mov(c.eax, uint32_t {!conjunction});
-			Store(node);
-			return;
+		const auto size = stride == 0u
+		                      ? static_cast<uint64_t>(static_cast<uint32_t>(records))
+		                      : static_cast<uint64_t>(stride) * static_cast<uint32_t>(records);
+		if (byte_offset > size || size - byte_offset < sizeof(uint32_t)) {
+			result = 0u;
+			return true;
+		}
+		address = (base & ~uint64_t {3}) + byte_offset;
+	} else {
+		const auto relative = (immediate & ~int64_t {3}) +
+		                      static_cast<int64_t>(static_cast<uint32_t>(offset) & ~3u);
+		if (!AddSignedAddress(base & ~uint64_t {3}, relative, address)) {
+			return false;
 		}
-		default: EmitStrict(node); return;
-	}
-}
-
-// Raw scalar and uniform DWORD buffer loads; out-of-bounds reads are zero.
-void WalkerCompiler::EmitRead(const Node& node) {
-	auto&      c    = m_code;
-	const auto& inst = *node.inst;
-	const auto op = inst.GetOpcode();
-	const bool vector = op == ValueOpcode::LoadBufferU32;
-	auto args = std::span(node.args);
-	Xbyak::Label zero;
-	if (vector) {
-		Fetch(args[0], m_ret);
-		c.test(c.rax, c.rax);
-		c.jz(zero, Near);
-		args = args.subspan(1);
-		if (args.empty()) c.jmp(m_ret, Near);
 	}
-	if (!args.empty()) {
-		for (const auto& arg: args) Branch(arg, m_ret);
-		const auto immediate =
-		    static_cast<int64_t>(static_cast<int32_t>(m_plan.memory_info[inst.Flags<MemoryFlags>().index].offset)) &
-		    ~int64_t {3};
-		// rax = the 48-bit base (high << 32 | low) with its low two bits clear.
-		Load(c.rax, args[1]);
-		c.shl(c.rax, 48);
-		c.shr(c.rax, 16);
-		Load(c.rcx, args[0]);
-		c.and_(c.ecx, ~3u);
-		c.or_(c.rax, c.rcx);
-		Load(c.r9, args[2]);
-		c.and_(c.r9d, ~3u);
-		if (op == ValueOpcode::LoadAddressU32) {
-			c.lea(c.rax, c.ptr[c.rax + c.r9 + static_cast<size_t>(immediate)]);
-			c.mov(c.rcx, c.rax);
-			c.shr(c.rcx, 48);
-			c.jnz(m_ret, Near);
-			LoadGuest(c, c.rax);
-		} else {
-			Load(c.r11, args[1]);
-			c.shr(c.r11d, 16);
-			if (vector) {
-				// Only the uniform, unswizzled structured DWORD address is evaluated on the host.
-				c.test(c.r11d, 1u << 15u);
-				c.jnz(m_ret, Near);
-				Load(c.rcx, args[4]);
-				c.test(c.ecx, (1u << 23u) | 0xf0000000u);
-				c.jnz(m_ret, Near);
-				c.test(c.r11d, 0x3fffu);
-				c.jz(zero, Near);
-				c.test(c.ecx, 0x7fu << 12u);
-				c.jz(zero, Near);
-			}
-			c.and_(c.r11d, 0x3fffu);
-			Load(c.rcx, args[3]);
-			if (vector) {
-				c.test(c.ecx, c.ecx);
-				c.jz(zero, Near);
-			}
-			Xbyak::Label sized;
-			c.test(c.r11d, c.r11d);
-			c.jz(sized, Near);
-			c.imul(c.rcx, c.r11);
-			c.L(sized);
-			c.lea(c.r11, c.ptr[c.r9 + static_cast<size_t>(immediate) + 4u]);
-			c.cmp(c.r11, c.rcx);
-			c.ja(zero, Near);
-			LoadGuest(c, c.rax + c.r9 + static_cast<size_t>(immediate));
+	uint32_t word = 0;
+	const auto reader = vector ? m_runtime.read_specialization_memory : m_runtime.read_memory;
+	if (reader != nullptr) {
+		if (!reader(m_runtime.userdata, address, {&word, 1})) {
+			return false;
+		}
+	} else {
+		// Without an ordinary reader a checked specialization reader still beats a raw
+		// dereference: a table the guest never set (null base) must fail, not fault the host.
+		if (vector || m_runtime.read_specialization_memory == nullptr ||
+		    !m_runtime.read_specialization_memory(m_runtime.userdata, address, {&word, 1})) {
+			return false;

Major · Stability & Availability · Quick win

Use the checked specialization reader for captured ordinary reads.

When capture_reads is true, MaterializeResources walks with capture.ObservedRuntime() (ResourceMaterialization.cpp:1688). ObservedRuntime always installs ReadOrdinary as read_memory (SrtWalker.cpp:24). The raw-read path therefore takes the ordinary branch, and the checked specialization fallback in EvaluateRawRead (SrtWalker.cpp:748-749) is not reached.

If the source provides a specialization reader but no ordinary reader, ReadOrdinary falls through to std::memcpy from the guest address (SrtWalker.cpp:39-42). An unmapped table address can fault the host instead of returning false. Other code in this change selects the specialization reader for this case (ResourceMaterialization.cpp:199-200).

Use the specialization reader inside ReadOrdinary when no ordinary reader is present. Call the raw specialization reader, not ReadStrict, so the range is recorded once.

Suggested fix

 bool SrtReadCapture::ReadOrdinary(void* userdata, uint64_t address, std::span<uint32_t> values) {
 	auto& capture = *static_cast<SrtReadCapture*>(userdata);
 	if (capture.m_source.read_memory != nullptr) {
 		if (!capture.m_source.read_memory(capture.m_source.userdata, address, values)) return false;
+	} else if (capture.m_source.read_specialization_memory != nullptr) {
+		if (!capture.m_source.read_specialization_memory(capture.m_source.userdata, address, values)) return false;
 	} else {
 		std::memcpy(values.data(), reinterpret_cast<const void*>(address), values.size_bytes());
 	}
 	capture.m_ranges.emplace_back(address, values.size_bytes());
 	return true;
 }
**@⁠coderabbitai[bot]** on GitHub · 2026-11-13 04:39 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2213#discussion_r4559714388) On `src/graphics/shader/recompiler/ir/passes/SrtWalker.cpp` line 750 (outdated): ```diff @@ -365,1063 +373,912 @@ class RuntimeValidator { }; -// Emits one x86 function per plan. Each value, per EXEC-mask context, is a memoized thunk with a -// state byte (0 unevaluated, 1 unknown or in progress, 2 known, 3 a control Phi holding its first -// value) and a qword slot; a reference is `call thunk; cmp state, 2`. Operands that are unknown, -// constant or plain user data are folded at emission. Registers: rdi user data, rsi flat buffer, -// rdx scratch, r8 capture cursor. -class WalkerCompiler { -public: - WalkerCompiler(ResourcePlan& plan, Xbyak::CodeGenerator& code): m_plan(plan), m_code(code) {} - - void Compile(std::span<const Value> values); - -private: - enum class Kind : uint8_t { Unknown, Constant, UserData, ShaderBase, Node }; - struct Operand { - Kind kind = Kind::Unknown; - uint64_t value = 0; - - bool operator==(const Operand& other) const = default; - }; - // masked: the operand depends on its context's EXEC mask, so it is not the root context's. - struct Ref { - Operand operand; - bool masked = false; - }; - struct Node { - const Inst* inst = nullptr; - uint32_t context = 0; - Operand result; - std::vector<Operand> args; - uint32_t slot = 0, state = 0; - Xbyak::Label label; - bool pending = true, referenced = false, masked = false; - }; +} // namespace - static constexpr auto Near = Xbyak::CodeGenerator::T_NEAR; +void CompileSrtWalker(ResourcePlan& program) { + if (!program.resource_tracking_complete || !program.srt_plan_complete || + program.capture_specialization_reads || !program.control_flow.empty() || + program.srt_reads.empty()) return; - bool Thunk(uint32_t index) const { - const auto& node = m_nodes[index]; - return node.referenced || node.result == Operand {Kind::Node, index}; + using Reads = std::map<int32_t, const SrtRead*>; + std::map<uint32_t, Reads> roots; + std::unordered_map<const Inst*, Reads> pointer_uses; + std::unordered_map<const Inst*, int32_t> offsets; + for (const auto& read: program.srt_reads) { + const auto* inst = read.value.Resolve().TryInstruction(); + if (inst == nullptr || inst->GetOpcode() != ValueOpcode::LoadAddressU32 || + inst->NumArgs() < 2 || !IsRawRead(program, *inst) || + read.flat_offset >= program.srt_reads.size()) return; + const auto offset = inst->Arg(1).Resolve(); + if (!offset.IsImmediate() || offset.GetType() != Type::U32) return; + const auto& memory = program.memory_info[inst->Flags<SrtReadFlags>().index]; + const auto relative = + (static_cast<int64_t>(static_cast<int32_t>(memory.offset)) & ~int64_t {3}) + + static_cast<int64_t>(offset.U32() & ~3u); + if (relative < INT32_MIN || relative > INT32_MAX || + !offsets.emplace(inst, static_cast<int32_t>(relative)).second) return; + } + uint32_t user_data_count = 0; + for (const auto& read: program.srt_reads) { + const auto* inst = read.value.ResolveInstruction(); + const auto* handle = inst->Arg(0).Resolve().TryInstruction(); + if (handle == nullptr || handle->GetOpcode() != ValueOpcode::GetAddressResource || + handle->NumArgs() != 2) return; + const auto* low = handle->Arg(0).Resolve().TryInstruction(); + const auto* high = handle->Arg(1).Resolve().TryInstruction(); + if (low == nullptr || high == nullptr) return; + Reads* uses = nullptr; + if (low->GetOpcode() == ValueOpcode::GetUserData && + high->GetOpcode() == ValueOpcode::GetUserData && low->NumArgs() == 1 && + high->NumArgs() == 1 && low->Arg(0).GetType() == Type::ScalarReg && + high->Arg(0).GetType() == Type::ScalarReg) { + const auto reg = RegIndex(low->Arg(0).ScalarRegister()); + if (reg < program.user_data_base || + RegIndex(high->Arg(0).ScalarRegister()) != reg + 1u) return; + const auto base = reg - program.user_data_base; + user_data_count = std::max(user_data_count, base + 2u); + uses = &roots[base]; + } else { + const auto lo = offsets.find(low); + const auto hi = offsets.find(high); + if (lo == offsets.end() || hi == offsets.end() || + static_cast<int64_t>(lo->second) + 4 != hi->second || + !EquivalentValue(program, low->Arg(0), high->Arg(0))) return; + uses = &pointer_uses[low]; + } + if (!uses->emplace(offsets.at(inst), &read).second) return; } - static bool MayBeUnknown(const Operand& operand) { - return operand.kind == Kind::Unknown || operand.kind == Kind::Node; + std::unordered_set<const Inst*> visited; + const auto reachable = [&](auto&& self, const Reads& reads) -> bool { + for (const auto& [offset, read]: reads) { + const auto* inst = read->value.ResolveInstruction(); + const auto child = pointer_uses.find(inst); + if (child != pointer_uses.end() && + (!visited.insert(inst).second || !self(self, child->second))) return false; + } + return true; + }; + for (const auto& [reg, reads]: roots) { + if (!reachable(reachable, reads)) return; } + if (visited.size() != pointer_uses.size()) return; - uint32_t Context(Value mask) { - mask = mask.Resolve(); - const auto found = std::ranges::find(m_masks, mask); - if (found != m_masks.end()) return static_cast<uint32_t>(found - m_masks.begin()); - m_masks.push_back(mask); - return static_cast<uint32_t>(m_masks.size() - 1u); + program.srt_code = std::make_unique<Xbyak::CodeGenerator>(4096, Xbyak::AutoGrow); + auto& code = *program.srt_code; + Xbyak::Label failed, finished; + code.push(code.rbp); + code.mov(code.rbp, code.rsp); + code.cmp(code.r8, user_data_count); + code.jb(failed, Xbyak::CodeGenerator::T_NEAR); + code.mov(code.r9, AddressMask & ~uint64_t {3}); + // Follow shadPS4's VisitPointer: copy one table level in offset order, then + // descend through its child pointers. Seed the descriptor evaluator's memo. + const auto visit = [&](auto&& self, int32_t pointer_offset, const Reads& reads) -> void { + code.push(code.rdi); + code.mov(code.rdi, code.qword[code.rdi + pointer_offset]); + code.and_(code.rdi, code.r9); + const auto first = reads.begin()->first; + const auto last = reads.rbegin()->first; + if (first < 0) { + code.mov(code.r10, -static_cast<int64_t>(first)); + code.cmp(code.rdi, code.r10); + code.jb(failed, Xbyak::CodeGenerator::T_NEAR); + } + if (last > 0) { + code.mov(code.r10, AddressMask - last); + code.cmp(code.rdi, code.r10); + code.ja(failed, Xbyak::CodeGenerator::T_NEAR); + } + for (const auto& [offset, read]: reads) { + const auto index = read->value.ResolveInstruction()->EvaluationIndex(program.evaluation_value_count); + using Entry = ResourcePlan::EvaluationContext::Entry; + const auto slot = code.rdx + index * sizeof(Entry); + code.mov(code.r10d, code.dword[code.rdi + offset]); + code.mov(code.dword[code.rsi + read->flat_offset * sizeof(uint32_t)], code.r10d); + code.mov(code.qword[slot + offsetof(Entry, value)], code.r10); + code.mov(code.qword[slot + offsetof(Entry, generation)], code.rcx); + } + for (const auto& [offset, read]: reads) { + const auto child = pointer_uses.find(read->value.ResolveInstruction()); + if (child == pointer_uses.end()) continue; + self(self, offset, child->second); + } + code.pop(code.rdi); + }; + for (const auto& [reg, reads]: roots) { + visit(visit, reg * sizeof(uint32_t), reads); } + code.mov(code.eax, 1); + code.jmp(finished, Xbyak::CodeGenerator::T_NEAR); + code.L(failed); + code.xor_(code.eax, code.eax); + code.L(finished); + code.mov(code.rsp, code.rbp); + code.pop(code.rbp); + code.ret(); + code.readyRE(); + EXIT_IF(Xbyak::GetError() != 0); +} - void AddOutput(Value value, uint32_t gate); - void Consume(std::vector<std::vector<uint32_t>>& gates); - Ref Evaluate(Value value, uint32_t context); - Operand Analyze(uint32_t index); - Operand AnalyzeRead(Node& node, const auto& arg, Operand self); - void Layout(); - void Gate(std::vector<uint32_t>& gates, const Xbyak::Label& skip); - void Zero(uint32_t offset, uint32_t size); - void Branch(const Operand& operand, const Xbyak::Label& unknown); - void Load(const Xbyak::Reg64& reg, const Operand& operand); - void Fetch(const Operand& operand, const Xbyak::Label& unknown); - void Set(void (Xbyak::CodeGenerator::*condition)(const Xbyak::Operand&)); - void Store(const Node& node); - void EmitNode(uint32_t index); - void EmitRead(const Node& node); - void EmitStrict(const Node& node); +SrtWalker::SrtWalker(const ResourcePlan& program, const SrtRuntime& runtime, + SrtWalker* clean_evaluator) + : m_program(program), m_runtime(runtime), m_clean_evaluator(clean_evaluator), + m_session(this), + m_read_policy(clean_evaluator != nullptr ? 2u : 0u), m_context(AcquireContext()) {} - ResourcePlan& m_plan; - Xbyak::CodeGenerator& m_code; - std::vector<Value> m_masks {Value {}}; - std::deque<Node> m_nodes; - std::map<std::pair<const Inst*, uint32_t>, uint32_t> m_memo; - std::vector<Value> m_outputs; - std::vector<std::vector<uint32_t>> m_output_gates; - Xbyak::Label m_ret; - uint32_t m_shader_base = 0, m_reach = 0, m_states = 0, m_states_end = 0; - uint32_t m_user_data = 0, m_captures = 0; -}; +SrtWalker::SrtWalker(SrtWalker& parent, Value active_mask, bool clean, + SrtWalker* clean_evaluator) + : m_program(parent.m_program), m_runtime(clean ? CleanRuntime(parent.m_runtime) : parent.m_runtime), + m_clean_evaluator(clean_evaluator), m_active_mask(active_mask.Resolve()), + m_reachable_blocks(parent.m_reachable_blocks), m_session(parent.m_session), + m_read_policy((parent.m_read_policy & 1u) | (clean ? 1u : 0u) | + (clean_evaluator != nullptr ? 2u : 0u)), m_context(AcquireContext()) {} + +SrtWalker::~SrtWalker() { + if (m_session != this) return; + for (auto& context: m_program.evaluation_contexts) + if (context.session == this) context.session = nullptr; +} -void WalkerCompiler::AddOutput(Value value, uint32_t gate) { - const auto* inst = value.Resolve().TryInstruction(); - if (inst == nullptr) return; - auto index = inst->WalkOutput(); - if (index >= m_outputs.size() || m_outputs[index].TryInstruction() != inst) { - index = static_cast<uint32_t>(m_outputs.size()); - inst->SetWalkOutput(index); - m_outputs.push_back(value.Resolve()); - m_output_gates.emplace_back(); +bool SrtWalker::Evaluate(Value value, uint32_t& result) { + uint64_t wide = 0; + if (!EvaluateWide(value, wide)) { + return false; } - m_output_gates[index].push_back(gate); + result = static_cast<uint32_t>(wide); + return true; } -// Mirrors MaterializeResources: each descriptor it reads back is gated by the activity of the -// resource root that needs it, and so are an indirect root's selector values. -void WalkerCompiler::Consume(std::vector<std::vector<uint32_t>>& gates) { - const auto& sources = m_plan.descriptor_sources; - const auto consume = [&](uint32_t root) { - if (root >= sources.size()) return; - const auto& indirect = sources[root].indirect_descriptor; - if (!indirect) { - gates[root].push_back(root); - return; - } - const auto add = [&](uint32_t source) { - if (source < sources.size()) gates[source].push_back(root); - }; - if (indirect->sources.empty()) { - add(indirect->table_source); - if (indirect->selector) { - add(indirect->selector->source); - if (indirect->selector->rows) add(indirect->selector->rows->source); - } - } - for (const auto source: indirect->sources) add(source); - AddOutput(indirect->key_count, root); - AddOutput(indirect->selector_first, root); - AddOutput(indirect->selector_mask, root); - }; - for (const auto& buffer: m_plan.info.buffers) consume(buffer.source); - for (const auto& image: m_plan.info.images) consume(image.source); - for (const auto& sampler: m_plan.info.samplers) { - const auto* indirect = sampler.source < sources.size() && sources[sampler.source].indirect_descriptor - ? &*sources[sampler.source].indirect_descriptor : nullptr; - if (indirect == nullptr || indirect->sources.empty()) { - consume(sampler.source); - } else if (indirect->sources[0] < sources.size()) { - gates[indirect->sources[0]].push_back(indirect->sources[0]); - } +ResourcePlan::EvaluationContext& SrtWalker::AcquireContext() { + ResourcePlan::EvaluationContext* unused = nullptr; + for (auto& context: m_program.evaluation_contexts) { + if (context.session == m_session && context.active_mask == m_active_mask && + context.read_policy == m_read_policy) return context; + if (context.session == nullptr && unused == nullptr) unused = &context; } - const auto& fill = m_plan.uniform_fill; - if (fill.fill.words != 0) { - AddOutput(fill.pattern_size, UINT32_MAX); - AddOutput(fill.element_count, UINT32_MAX); - for (const auto value: fill.values) AddOutput(value, UINT32_MAX); + auto& context = unused != nullptr ? *unused : m_program.evaluation_contexts.emplace_back(); + context.session = m_session; + context.active_mask = m_active_mask; + context.read_policy = m_read_policy; + context.generation += 4; + return context; +} + +void SrtWalker::ResetUnknowns() { + for (auto& context: m_program.evaluation_contexts) { + if (context.session != m_session) continue; + for (auto& entry: context.values) + if (entry.generation == (context.generation | 2u)) entry.generation = 0; } } -WalkerCompiler::Ref WalkerCompiler::Evaluate(Value value, uint32_t context) { +float SrtWalker::Float32(uint64_t bits) { + return std::bit_cast<float>(static_cast<uint32_t>(bits)); +} + +bool SrtWalker::EvaluateWide(Value value, uint64_t& result) { value = value.Resolve(); - if (value.IsEmpty()) return {}; if (value.IsImmediate()) { - uint64_t bits = 0; - return ImmediateBits(value, bits) ? Ref {{Kind::Constant, bits}} : Ref {}; + switch (value.GetType()) { + case Type::U1: result = value.U1(); return true; + case Type::U8: result = value.U8(); return true; + case Type::U16: result = value.U16(); return true; + case Type::U32: result = value.U32(); return true; + case Type::U64: result = value.U64(); return true; + case Type::F32: result = std::bit_cast<uint32_t>(value.F32Value()); return true; + default: return false; + } } - const auto mask = m_masks[context]; - if (context != 0 && value == mask) return {{Kind::Constant, 1u}, true}; - const auto* inst = value.TryInstruction(); - if (inst == nullptr) return {}; - const auto op = inst->GetOpcode(); - if (context != 0 && IsRuntimeSelect(op) && inst->NumArgs() == 3 && inst->Arg(0).Resolve() == mask) { - return {Evaluate(inst->Arg(1), context).operand, true}; + if (!m_active_mask.IsEmpty() && value == m_active_mask) { + result = 1u; + return true; } - switch (op) { - case ValueOpcode::BitCastU32F32: - case ValueOpcode::BitCastF32U32: - case ValueOpcode::ConditionRef: return Evaluate(inst->Arg(0), context); - case ValueOpcode::CompositeExtractU32x2: { - const auto* source = inst->Arg(0).ResolveInstruction(); - const auto index = inst->Arg(1).Resolve(); - if (source == nullptr || source->GetOpcode() != ValueOpcode::CompositeConstructU32x2 || - !index.IsImmediate() || index.GetType() != Type::U32 || index.U32() >= 2u) return {}; - return Evaluate(source->Arg(index.U32()), context); - } - case ValueOpcode::ReadFirstLane: - // The lane read does not depend on the EXEC mask it is read under. - return {Evaluate(inst->Arg(0), Context(inst->Arg(1))).operand}; - case ValueOpcode::GetUserData: { - const auto reg = RegIndex(inst->Arg(0).ScalarRegister()); - if (reg < m_plan.user_data_base || reg - m_plan.user_data_base >= m_plan.user_data_count) return {}; - return {{Kind::UserData, reg - m_plan.user_data_base}}; - } - case ValueOpcode::GetShaderBase: return {{Kind::ShaderBase}}; - case ValueOpcode::Phi: - if (!m_plan.control_phi_predecessors.contains(inst)) { - const auto invariant = ResolveInvariantPhi(m_plan, value); - return invariant.IsEmpty() ? Ref {} : Evaluate(invariant, context); - } - break; - default: break; + auto* inst = value.TryInstruction(); + if (inst == nullptr) { + return false; + } + if (!m_active_mask.IsEmpty() && IsRuntimeSelect(inst->GetOpcode()) && + inst->NumArgs() == 3 && inst->Arg(0).Resolve() == m_active_mask) { + return EvaluateWide(inst->Arg(1), result); } - const auto [found, inserted] = m_memo.try_emplace({inst, context}, static_cast<uint32_t>(m_nodes.size())); - const auto index = found->second; - if (!inserted) { - auto& node = m_nodes[index]; - if (!node.pending) return {node.result, node.masked}; - // A cycle: the thunk reads as unknown while it runs. - node.referenced = true; - return {{Kind::Node, index}, context != 0}; + const auto index = inst->EvaluationIndex(m_program.evaluation_value_count); + if (index >= m_context.values.size()) { + m_context.values.resize(m_program.evaluation_value_count); } - auto& node = m_nodes.emplace_back(); - node.inst = inst; - node.context = context; - node.result = Analyze(index); - node.pending = false; - if (context != 0 && !node.masked && !node.referenced) { - node.result = Evaluate(value, 0).operand; - return {node.result}; + if (m_context.values[index].generation == m_context.generation) { + result = m_context.values[index].value; + return true; + } + // Visiting and completed-unknown entries both stop repeated evaluation in this + // context. Only completed unknowns are retried when reachability becomes tighter. + if (m_context.values[index].generation == (m_context.generation | 1u) || + m_context.values[index].generation == (m_context.generation | 2u)) { + return false; } - return {node.result, node.masked}; + m_context.values[index].generation = m_context.generation | 1u; + uint64_t out = 0; + const bool evaluated = EvaluateInst(*inst, out); + // Recursive evaluation may grow the dense memo vector. + auto& memo = m_context.values[index]; + if (!evaluated) { + memo.generation = m_context.generation | 2u; + return false; + } + memo.value = out; + memo.generation = m_context.generation; + result = out; + return true; } -WalkerCompiler::Operand WalkerCompiler::Analyze(uint32_t index) { - auto& node = m_nodes[index]; - const auto& inst = *node.inst; - const auto self = Operand {Kind::Node, index}; - const auto arg = [&](Value value) { - const auto ref = Evaluate(value, node.context); - node.masked |= ref.masked; - return ref.operand; - }; - const auto constant = [](uint64_t value) { return Operand {Kind::Constant, value}; }; - switch (inst.GetOpcode()) { - case ValueOpcode::Phi: { - bool known = false; - for (size_t i = 0; i < inst.NumArgs(); ++i) { - node.args.push_back(arg(inst.Arg(i))); - known |= node.args.back().kind != Kind::Unknown; - } - return known ? self : Operand {}; - } - case ValueOpcode::LoadAddressU32: - case ValueOpcode::ReadConstBuffer: - case ValueOpcode::LoadBufferU32: return AnalyzeRead(node, arg, self); - case ValueOpcode::SelectU1: - case ValueOpcode::SelectU32: - case ValueOpcode::SelectF32: { - const auto predicate = arg(inst.Arg(0)); - if (predicate.kind == Kind::Unknown) return {}; - if (predicate.kind == Kind::Constant) return arg(inst.Arg(predicate.value != 0u ? 1 : 2)); - node.args = {predicate, arg(inst.Arg(1)), arg(inst.Arg(2))}; - return node.args[1].kind == Kind::Unknown && node.args[2].kind == Kind::Unknown ? Operand {} : self; - } - case ValueOpcode::ULessThan32: - case ValueOpcode::ULessThanEqual32: { - // No U32 is below zero and every U32 is at least zero, including an unknown loop-carried - // or varying lane value. args[0] is that zero-tested bound. - const bool less = inst.GetOpcode() == ValueOpcode::ULessThan32; - const auto bound = arg(inst.Arg(less ? 1 : 0)); - if (bound.kind == Kind::Unknown) return {}; - if (bound.kind == Kind::Constant && static_cast<uint32_t>(bound.value) == 0u) return constant(!less); - node.args = {bound, arg(inst.Arg(less ? 0 : 1))}; - return node.args[1].kind == Kind::Unknown && bound.kind == Kind::Constant ? Operand {} : self; - } - case ValueOpcode::LogicalOr: - case ValueOpcode::LogicalAnd: { - // A deciding operand, nonzero for Or and zero for And, fixes the result. - const bool conjunction = inst.GetOpcode() == ValueOpcode::LogicalAnd; - const auto decides = [&](const Operand& x) { - return x.kind == Kind::Constant && (x.value == 0u) == conjunction; - }; - const auto a = arg(inst.Arg(0)); - if (decides(a)) return constant(!conjunction); - const auto b = arg(inst.Arg(1)); - if (decides(b)) return constant(!conjunction); - if (a.kind == Kind::Constant && b.kind == Kind::Constant) return constant(conjunction); - if (a.kind == Kind::Constant && b.kind == Kind::Unknown) return {}; - // Only lanes satisfying the left EXEC factor can make a conjunction true, so an - // unknown left side retries the right one under that factor as its mask. - Operand refined; - if (conjunction && MayBeUnknown(a)) { - refined = Evaluate(inst.Arg(1), Context(inst.Arg(0))).operand; - if (refined == b || (refined.kind == Kind::Constant && refined.value != 0u)) refined = {}; - if (a.kind == Kind::Unknown && refined.kind == Kind::Constant) return constant(0u); - } - if (a.kind == Kind::Unknown && refined.kind == Kind::Unknown && - (b.kind == Kind::Unknown || b.kind == Kind::Constant)) return {}; - node.args = {a, b, refined}; - return self; - } - case ValueOpcode::CompositeExtractU64: { - const auto component = inst.Arg(1).Resolve(); - if (!component.IsImmediate() || component.GetType() != Type::U32 || component.U32() >= 2u) return {}; - [[fallthrough]]; +bool SrtWalker::Arg(const Inst& inst, size_t index, uint64_t& result) { + return EvaluateWide(inst.Arg(index), result); +} + +bool SrtWalker::EvaluatePhi(const Inst& inst, uint64_t& result) { + if (const auto control = m_program.control_phi_predecessors.find(&inst); + control != m_program.control_phi_predecessors.end()) { + bool found = false; + for (size_t index = 0; index < inst.NumArgs(); ++index) { + if (m_reachable_blocks != nullptr && + !m_reachable_blocks->at(control->second[index])) continue; + uint64_t incoming = 0; + if (!Arg(inst, index, incoming) || (found && incoming != result)) return false; + result = incoming; + found = true; } - default: - // The other runtime-uniform ops are strict; a U32x2 pair is only read through its extracts. - if (!IsRuntimeUniformOp(inst.GetOpcode()) || inst.GetOpcode() == ValueOpcode::CompositeConstructU32x2) - return {}; - for (size_t i = 0; i < inst.NumArgs(); ++i) { - node.args.push_back(arg(inst.Arg(i))); - if (node.args.back().kind == Kind::Unknown) return {}; - } - return self; + return found; } + const auto value = ResolveInvariantPhi(m_program, Value(const_cast<Inst*>(&inst))); + return !value.IsEmpty() && EvaluateWide(value, result); } -WalkerCompiler::Operand WalkerCompiler::AnalyzeRead(Node& node, const auto& arg, Operand self) { - const auto& inst = *node.inst; - const auto* handle = inst.Arg(0).ResolveInstruction(); - if (!IsRawRead(m_plan, inst) || handle == nullptr) return {}; - const bool vector = inst.GetOpcode() == ValueOpcode::LoadBufferU32; - if (vector) { - const auto guard = arg(inst.Arg(4)); - if (guard.kind == Kind::Unknown) return {}; - if (guard.kind == Kind::Constant && guard.value == 0u) return {Kind::Constant, 0u}; - node.args.push_back(guard); +bool SrtWalker::EvaluateExtract(const Inst& inst, uint64_t& result) { + const auto index = inst.Arg(1).Resolve(); + if (!index.IsImmediate() || index.GetType() != Type::U32) { + return false; } - const bool buffer = inst.GetOpcode() != ValueOpcode::LoadAddressU32; - const auto offset = static_cast<int32_t>(m_plan.memory_info[inst.Flags<MemoryFlags>().index].offset); - bool failed = buffer && (handle->NumArgs() != 4u || offset < 0); - for (const auto& word: {handle->Arg(0), handle->Arg(1), inst.Arg(1)}) { - node.args.push_back(arg(word)); - failed |= node.args.back().kind == Kind::Unknown; + const auto component = index.U32(); + if (component >= 2u) { + return false; } - for (uint32_t word = 2; buffer && !failed && word < 4u; ++word) { - node.args.push_back(arg(handle->Arg(word))); - failed |= node.args.back().kind == Kind::Unknown; + if (inst.GetOpcode() == ValueOpcode::CompositeExtractU64) { + uint64_t packed = 0; + if (!Arg(inst, 0, packed)) { + return false; + } + result = static_cast<uint32_t>(packed >> (component * 32u)); + return true; } - if (!failed) return self; - // A disabled vector lane still reads zero. - if (!vector || node.args[0].kind == Kind::Constant) return {}; - node.args.resize(1); - return self; -} - -void WalkerCompiler::Layout() { - uint32_t offset = OutputOffset(m_plan) + static_cast<uint32_t>(m_outputs.size()) * 8u; - m_shader_base = offset; - offset += 8u; - for (uint32_t index = 0; index < m_nodes.size(); ++index) { - if (!Thunk(index)) continue; - m_nodes[index].slot = offset; - offset += 8u; + const auto* source = inst.Arg(0).ResolveInstruction(); + if (source == nullptr) { + return false; } - m_reach = offset; - offset += static_cast<uint32_t>(m_plan.control_flow.size()); - m_states = offset; - for (uint32_t index = 0; index < m_nodes.size(); ++index) { - if (Thunk(index)) m_nodes[index].state = offset++; + if (source->GetOpcode() == ValueOpcode::CompositeConstructU32x2) { + return EvaluateWide(source->Arg(component), result); } - m_states_end = offset; - // Captured addresses come last; EmitRead counts them. - m_plan.srt_captures = (offset + 7u) & ~7u; -} - -// Falls through when any gating source is active. The list is not empty. -void WalkerCompiler::Gate(std::vector<uint32_t>& gates, const Xbyak::Label& skip) { - auto& c = m_code; - std::ranges::sort(gates); - if (gates.back() == UINT32_MAX) return; - gates.erase(std::unique(gates.begin(), gates.end()), gates.end()); - Xbyak::Label active; - for (size_t i = 0; i < gates.size(); ++i) { - c.cmp(c.byte[c.rdx + ActiveOffset(m_plan) + gates[i]], 0); - if (i + 1u < gates.size()) { - c.jne(active, Near); - } else { - c.je(skip, Near); + if (source->GetOpcode() == ValueOpcode::IAddCarry32) { + uint64_t lhs = 0; + uint64_t rhs = 0; + if (!Arg(*source, 0, lhs) || !Arg(*source, 1, rhs)) { + return false; } + const auto sum = + static_cast<uint64_t>(static_cast<uint32_t>(lhs)) + static_cast<uint32_t>(rhs); + result = + component == 0u ? static_cast<uint32_t>(sum) : static_cast<uint32_t>(sum >> 32u); + return true; } - c.L(active); + return false; } -void WalkerCompiler::Zero(uint32_t offset, uint32_t size) { - auto& c = m_code; - if (size == 0) return; - c.mov(c.r11, c.rdi); - c.lea(c.rdi, c.ptr[c.rdx + offset]); - c.mov(c.ecx, size); - c.xor_(c.eax, c.eax); - c.rep(); - c.stosb(); - c.mov(c.rdi, c.r11); -} - -// Jumps to unknown unless the operand has a value at run time. -void WalkerCompiler::Branch(const Operand& operand, const Xbyak::Label& unknown) { - auto& c = m_code; - if (operand.kind == Kind::Unknown) { - c.jmp(unknown, Near); - } else if (operand.kind == Kind::Node) { - auto& node = m_nodes[operand.value]; - c.call(node.label); - c.cmp(c.byte[c.rdx + node.state], 2); - c.jne(unknown, Near); +bool SrtWalker::EvaluateRawRead(const Inst& inst, uint64_t& result) { + const auto flags = inst.Flags<SrtReadFlags>(); + if (flags.index >= m_program.memory_info.size()) { + return false; } -} - -void WalkerCompiler::Load(const Xbyak::Reg64& reg, const Operand& operand) { - auto& c = m_code; - switch (operand.kind) { - case Kind::Constant: c.mov(reg, operand.value); break; - case Kind::UserData: - m_user_data = std::max(m_user_data, static_cast<uint32_t>(operand.value) + 1u); - c.mov(reg.cvt32(), c.dword[c.rdi + operand.value * sizeof(uint32_t)]); - break; - case Kind::ShaderBase: c.mov(reg, c.qword[c.rdx + m_shader_base]); break; - case Kind::Node: c.mov(reg, c.qword[c.rdx + m_nodes[operand.value].slot]); break; - case Kind::Unknown: break; + const auto& mem = m_program.memory_info[flags.index]; + const bool vector = inst.GetOpcode() == ValueOpcode::LoadBufferU32; + const auto guard = vector ? inst.Arg(4).Resolve() : Value {}; + if (vector && (guard.IsImmediate() || guard != m_active_mask)) { + uint64_t enabled = 0; + if (!Arg(inst, 4, enabled)) return false; + if (enabled == 0u) { + result = 0u; + return true; + } } -} - -// Loads the operand into rax, or jumps to unknown when it has no value at run time. -void WalkerCompiler::Fetch(const Operand& operand, const Xbyak::Label& unknown) { - Branch(operand, unknown); - Load(m_code.rax, operand); -} - -// Sets eax to 1 when the condition holds, else 0. -void WalkerCompiler::Set(void (Xbyak::CodeGenerator::*condition)(const Xbyak::Operand&)) { - (m_code.*condition)(m_code.al); - m_code.movzx(m_code.eax, m_code.al); -} - -void WalkerCompiler::Store(const Node& node) { - auto& c = m_code; - c.mov(c.qword[c.rdx + node.slot], c.rax); - c.mov(c.byte[c.rdx + node.state], 2); - c.ret(); -} - -void WalkerCompiler::EmitNode(uint32_t index) { - auto& c = m_code; - auto& node = m_nodes[index]; - const auto& args = node.args; - c.L(node.label); - c.cmp(c.byte[c.rdx + node.state], 0); - c.jne(m_ret, Near); - c.mov(c.byte[c.rdx + node.state], 1); - if (node.result != Operand {Kind::Node, index}) { - // A cycle referenced this value before it folded to another operand. - Fetch(node.result, m_ret); - Store(node); - return; + const auto* handle = inst.Arg(0).ResolveInstruction(); + if (handle == nullptr) { + return false; + } + uint64_t low = 0; + uint64_t high = 0; + uint64_t offset = 0; + if (!Arg(*handle, 0, low) || !Arg(*handle, 1, high) || !Arg(inst, 1, offset)) { + return false; } - switch (node.inst->GetOpcode()) { - case ValueOpcode::Phi: { - // Only predecessors reached by this walk contribute, and they must agree. The state is 3 - // once one of them has stored the value; callers read it like 1, as unknown. - const auto& blocks = m_plan.control_phi_predecessors.at(node.inst); - const auto state = c.byte[c.rdx + node.state]; - for (size_t i = 0; i < args.size(); ++i) { - Xbyak::Label next, first; - c.cmp(c.byte[c.rdx + m_reach + blocks[i]], 0); - c.je(next, Near); - Fetch(args[i], m_ret); - c.cmp(state, 1); - c.je(first, Near); - c.cmp(c.rax, c.qword[c.rdx + node.slot]); - c.jne(m_ret, Near); - c.jmp(next, Near); - c.L(first); - c.mov(c.qword[c.rdx + node.slot], c.rax); - c.mov(state, 3); - c.L(next); - } - c.cmp(state, 3); - c.jne(m_ret, Near); - c.mov(state, 2); - c.ret(); - return; + const auto base = ((high << 32u) | static_cast<uint32_t>(low)) & AddressMask; + const auto immediate = static_cast<int64_t>(static_cast<int32_t>(mem.offset)); + uint64_t address = 0; + if (inst.GetOpcode() == ValueOpcode::ReadConstBuffer || vector) { + uint64_t records = 0; + uint64_t word3 = 0; + if (handle->NumArgs() != 4u || !Arg(*handle, 2, records) || !Arg(*handle, 3, word3)) { + return false; } - case ValueOpcode::LoadAddressU32: - case ValueOpcode::ReadConstBuffer: - case ValueOpcode::LoadBufferU32: EmitRead(node); return; - case ValueOpcode::SelectU1: - case ValueOpcode::SelectU32: - case ValueOpcode::SelectF32: { - Xbyak::Label other; - Fetch(args[0], m_ret); - c.test(c.rax, c.rax); - c.jz(other, Near); - Fetch(args[1], m_ret); - Store(node); - c.L(other); - Fetch(args[2], m_ret); - Store(node); - return; + if (immediate < 0) { + return false; } - case ValueOpcode::ULessThan32: - case ValueOpcode::ULessThanEqual32: { - const bool less = node.inst->GetOpcode() == ValueOpcode::ULessThan32; - Xbyak::Label bound_zero; - Fetch(args[0], m_ret); - c.test(c.eax, c.eax); - c.jz(bound_zero, Near); - Branch(args[1], m_ret); - Load(c.rax, args[0]); - Load(c.rcx, args[1]); - // ULT tests other < bound, ULE bound <= other. - c.cmp(c.ecx, c.eax); - Set(less ? &Xbyak::CodeGenerator::setb : &Xbyak::CodeGenerator::setae); - Store(node); - c.L(bound_zero); - c.mov(c.eax, uint32_t {!less}); - Store(node); - return; + const auto byte_offset = + (static_cast<uint64_t>(immediate) & ~uint64_t {3}) + (static_cast<uint32_t>(offset) & ~3u); + const auto stride = (static_cast<uint32_t>(high) >> 16u) & 0x3fffu; + if (vector) { + // Only the uniform, unswizzled structured DWORD address is evaluated on the host. + if ((high & (1u << 31u)) != 0u || (word3 & ((1u << 23u) | 0xf0000000u)) != 0u) + return false; + if (stride == 0u || records == 0u || ((word3 >> 12u) & 0x7fu) == 0u) { + result = 0u; + return true; + } } - case ValueOpcode::LogicalOr: - case ValueOpcode::LogicalAnd: { - const bool conjunction = node.inst->GetOpcode() == ValueOpcode::LogicalAnd; - Xbyak::Label unknown_left, refine, decided; - const auto decide = [&] { - if (conjunction) { - c.jz(decided, Near); - } else { - c.jnz(decided, Near); - } - }; - Branch(args[0], unknown_left); - if (args[0].kind != Kind::Unknown) { - Load(c.rax, args[0]); - c.test(c.rax, c.rax); - decide(); - Fetch(args[1], m_ret); - c.test(c.rax, c.rax); - Set(&Xbyak::CodeGenerator::setne); - Store(node); - } - c.L(unknown_left); - if (MayBeUnknown(args[0])) { - // Without the left side only a deciding right side, or a conjunction's zero - // refined right side, is known. - if (args[1].kind != Kind::Unknown) { - Fetch(args[1], refine); - c.test(c.rax, c.rax); - decide(); - } - c.L(refine); - Fetch(args[2], m_ret); - c.test(c.rax, c.rax); - c.jnz(m_ret, Near); - } - c.L(decided); - c.mov(c.eax, uint32_t {!conjunction}); - Store(node); - return; + const auto size = stride == 0u + ? static_cast<uint64_t>(static_cast<uint32_t>(records)) + : static_cast<uint64_t>(stride) * static_cast<uint32_t>(records); + if (byte_offset > size || size - byte_offset < sizeof(uint32_t)) { + result = 0u; + return true; + } + address = (base & ~uint64_t {3}) + byte_offset; + } else { + const auto relative = (immediate & ~int64_t {3}) + + static_cast<int64_t>(static_cast<uint32_t>(offset) & ~3u); + if (!AddSignedAddress(base & ~uint64_t {3}, relative, address)) { + return false; } - default: EmitStrict(node); return; - } -} - -// Raw scalar and uniform DWORD buffer loads; out-of-bounds reads are zero. -void WalkerCompiler::EmitRead(const Node& node) { - auto& c = m_code; - const auto& inst = *node.inst; - const auto op = inst.GetOpcode(); - const bool vector = op == ValueOpcode::LoadBufferU32; - auto args = std::span(node.args); - Xbyak::Label zero; - if (vector) { - Fetch(args[0], m_ret); - c.test(c.rax, c.rax); - c.jz(zero, Near); - args = args.subspan(1); - if (args.empty()) c.jmp(m_ret, Near); } - if (!args.empty()) { - for (const auto& arg: args) Branch(arg, m_ret); - const auto immediate = - static_cast<int64_t>(static_cast<int32_t>(m_plan.memory_info[inst.Flags<MemoryFlags>().index].offset)) & - ~int64_t {3}; - // rax = the 48-bit base (high << 32 | low) with its low two bits clear. - Load(c.rax, args[1]); - c.shl(c.rax, 48); - c.shr(c.rax, 16); - Load(c.rcx, args[0]); - c.and_(c.ecx, ~3u); - c.or_(c.rax, c.rcx); - Load(c.r9, args[2]); - c.and_(c.r9d, ~3u); - if (op == ValueOpcode::LoadAddressU32) { - c.lea(c.rax, c.ptr[c.rax + c.r9 + static_cast<size_t>(immediate)]); - c.mov(c.rcx, c.rax); - c.shr(c.rcx, 48); - c.jnz(m_ret, Near); - LoadGuest(c, c.rax); - } else { - Load(c.r11, args[1]); - c.shr(c.r11d, 16); - if (vector) { - // Only the uniform, unswizzled structured DWORD address is evaluated on the host. - c.test(c.r11d, 1u << 15u); - c.jnz(m_ret, Near); - Load(c.rcx, args[4]); - c.test(c.ecx, (1u << 23u) | 0xf0000000u); - c.jnz(m_ret, Near); - c.test(c.r11d, 0x3fffu); - c.jz(zero, Near); - c.test(c.ecx, 0x7fu << 12u); - c.jz(zero, Near); - } - c.and_(c.r11d, 0x3fffu); - Load(c.rcx, args[3]); - if (vector) { - c.test(c.ecx, c.ecx); - c.jz(zero, Near); - } - Xbyak::Label sized; - c.test(c.r11d, c.r11d); - c.jz(sized, Near); - c.imul(c.rcx, c.r11); - c.L(sized); - c.lea(c.r11, c.ptr[c.r9 + static_cast<size_t>(immediate) + 4u]); - c.cmp(c.r11, c.rcx); - c.ja(zero, Near); - LoadGuest(c, c.rax + c.r9 + static_cast<size_t>(immediate)); + uint32_t word = 0; + const auto reader = vector ? m_runtime.read_specialization_memory : m_runtime.read_memory; + if (reader != nullptr) { + if (!reader(m_runtime.userdata, address, {&word, 1})) { + return false; + } + } else { + // Without an ordinary reader a checked specialization reader still beats a raw + // dereference: a table the guest never set (null base) must fail, not fault the host. + if (vector || m_runtime.read_specialization_memory == nullptr || + !m_runtime.read_specialization_memory(m_runtime.userdata, address, {&word, 1})) { + return false; ``` <!-- coderabbit-ai-generated:v1 --> **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/major-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Major** · **Stability & Availability** · **Quick win** **Use the checked specialization reader for captured ordinary reads.** When `capture_reads` is true, `MaterializeResources` walks with `capture.ObservedRuntime()` (`ResourceMaterialization.cpp:1688`). `ObservedRuntime` always installs `ReadOrdinary` as `read_memory` (`SrtWalker.cpp:24`). The raw-read path therefore takes the ordinary branch, and the checked specialization fallback in `EvaluateRawRead` (`SrtWalker.cpp:748-749`) is not reached. If the source provides a specialization reader but no ordinary reader, `ReadOrdinary` falls through to `std::memcpy` from the guest address (`SrtWalker.cpp:39-42`). An unmapped table address can fault the host instead of returning false. Other code in this change selects the specialization reader for this case (`ResourceMaterialization.cpp:199-200`). Use the specialization reader inside `ReadOrdinary` when no ordinary reader is present. Call the raw specialization reader, not `ReadStrict`, so the range is recorded once. <details> <summary>Suggested fix</summary> <dl> <dd> <br> ```diff bool SrtReadCapture::ReadOrdinary(void* userdata, uint64_t address, std::span<uint32_t> values) { auto& capture = *static_cast<SrtReadCapture*>(userdata); if (capture.m_source.read_memory != nullptr) { if (!capture.m_source.read_memory(capture.m_source.userdata, address, values)) return false; + } else if (capture.m_source.read_specialization_memory != nullptr) { + if (!capture.m_source.read_specialization_memory(capture.m_source.userdata, address, values)) return false; } else { std::memcpy(values.data(), reinterpret_cast<const void*>(address), values.size_bytes()); } capture.m_ranges.emplace_back(address, values.size_bytes()); return true; } ``` </dd> </dl> </details> <!-- fingerprinting:phantom:medusa:wombat61 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:0fa21e0f275bea36a86e57ec --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-13 04:39 UTC · original
On src/libs/dialog.cpp line 918 (outdated):

@@ -827,4 +874,169 @@ int KYTY_SYSV_ABI ErrorDialogGetStatus() {
 
 } // namespace ErrorDialog
 
+namespace WebBrowserDialog {
+
+LIB_NAME("WebBrowserDialog", "WebBrowserDialog");
+
+// Same state progression rules the other common dialogs use.
+constexpr int WEB_STATUS_NONE        = 0;
+constexpr int WEB_STATUS_INITIALIZED = 1;
+constexpr int WEB_STATUS_RUNNING     = 2;
+constexpr int WEB_STATUS_FINISHED    = 3;
+
+constexpr int WEB_RESULT_USER_CANCELED = 1;
+
+// NOTE(unverified): the numeric error values reuse the 0x8135xxxx CommonDialog family
+// pattern of Kyty's SigninDialog. The real SceWebBrowserDialogError codes were never
+// confirmed from an SDK header; games normally branch only on zero/non-zero.
+constexpr int WEB_ERROR_NOT_INITIALIZED     = static_cast<int>(0x81350041u);
+constexpr int WEB_ERROR_ALREADY_INITIALIZED = static_cast<int>(0x81350042u);
+constexpr int WEB_ERROR_PARAM_INVALID       = static_cast<int>(0x81350043u);
+constexpr int WEB_ERROR_INVALID_STATE       = static_cast<int>(0x81350045u);
+
+int KYTY_SYSV_ABI Initialize() {
+	PRINT_NAME();
+
+	std::scoped_lock lock(g_dialog_mutex);
+	if (g_web.status != WEB_STATUS_NONE) {
+		return WEB_ERROR_ALREADY_INITIALIZED;
+	}
+
+	g_web.status = WEB_STATUS_INITIALIZED;
+
+	return OK;
+}
+
+int KYTY_SYSV_ABI Terminate() {
+	PRINT_NAME();
+
+	std::unique_lock lock(g_dialog_mutex);
+	if (g_web.status == WEB_STATUS_NONE) {
+		return WEB_ERROR_NOT_INITIALIZED;
+	}
+	if (g_web.status == WEB_STATUS_RUNNING) {
+		CloseWebBrowserRunning(lock);

Major · Functional Correctness · Quick win

Make running termination leave the browser uninitialized.

Initialize → Open → Terminate returns success but leaves g_web.status as WEB_STATUS_FINISHED. CloseWebBrowserRunning never sets WEB_STATUS_NONE. A subsequent Initialize therefore returns already-initialized, and Open remains permitted after termination. Complete the transition to NONE while preserving the close notification.

**@⁠coderabbitai[bot]** on GitHub · 2026-11-13 04:39 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2213#discussion_r4559714396) On `src/libs/dialog.cpp` line 918 (outdated): ```diff @@ -827,4 +874,169 @@ int KYTY_SYSV_ABI ErrorDialogGetStatus() { } // namespace ErrorDialog +namespace WebBrowserDialog { + +LIB_NAME("WebBrowserDialog", "WebBrowserDialog"); + +// Same state progression rules the other common dialogs use. +constexpr int WEB_STATUS_NONE = 0; +constexpr int WEB_STATUS_INITIALIZED = 1; +constexpr int WEB_STATUS_RUNNING = 2; +constexpr int WEB_STATUS_FINISHED = 3; + +constexpr int WEB_RESULT_USER_CANCELED = 1; + +// NOTE(unverified): the numeric error values reuse the 0x8135xxxx CommonDialog family +// pattern of Kyty's SigninDialog. The real SceWebBrowserDialogError codes were never +// confirmed from an SDK header; games normally branch only on zero/non-zero. +constexpr int WEB_ERROR_NOT_INITIALIZED = static_cast<int>(0x81350041u); +constexpr int WEB_ERROR_ALREADY_INITIALIZED = static_cast<int>(0x81350042u); +constexpr int WEB_ERROR_PARAM_INVALID = static_cast<int>(0x81350043u); +constexpr int WEB_ERROR_INVALID_STATE = static_cast<int>(0x81350045u); + +int KYTY_SYSV_ABI Initialize() { + PRINT_NAME(); + + std::scoped_lock lock(g_dialog_mutex); + if (g_web.status != WEB_STATUS_NONE) { + return WEB_ERROR_ALREADY_INITIALIZED; + } + + g_web.status = WEB_STATUS_INITIALIZED; + + return OK; +} + +int KYTY_SYSV_ABI Terminate() { + PRINT_NAME(); + + std::unique_lock lock(g_dialog_mutex); + if (g_web.status == WEB_STATUS_NONE) { + return WEB_ERROR_NOT_INITIALIZED; + } + if (g_web.status == WEB_STATUS_RUNNING) { + CloseWebBrowserRunning(lock); ``` <!-- coderabbit-ai-generated:v1 --> **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/major-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Major** · **Functional Correctness** · **Quick win** **Make running termination leave the browser uninitialized.** `Initialize → Open → Terminate` returns success but leaves `g_web.status` as `WEB_STATUS_FINISHED`. `CloseWebBrowserRunning` never sets `WEB_STATUS_NONE`. A subsequent `Initialize` therefore returns already-initialized, and `Open` remains permitted after termination. Complete the transition to NONE while preserving the close notification. <!-- fingerprinting:phantom:medusa:wombat61 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:d4d849abeafb0f210a7fbab7 --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-13 04:39 UTC · original
On src/libs/dialog.cpp line 949 (outdated):

@@ -827,4 +874,169 @@ int KYTY_SYSV_ABI ErrorDialogGetStatus() {
 
 } // namespace ErrorDialog
 
+namespace WebBrowserDialog {
+
+LIB_NAME("WebBrowserDialog", "WebBrowserDialog");
+
+// Same state progression rules the other common dialogs use.
+constexpr int WEB_STATUS_NONE        = 0;
+constexpr int WEB_STATUS_INITIALIZED = 1;
+constexpr int WEB_STATUS_RUNNING     = 2;
+constexpr int WEB_STATUS_FINISHED    = 3;
+
+constexpr int WEB_RESULT_USER_CANCELED = 1;
+
+// NOTE(unverified): the numeric error values reuse the 0x8135xxxx CommonDialog family
+// pattern of Kyty's SigninDialog. The real SceWebBrowserDialogError codes were never
+// confirmed from an SDK header; games normally branch only on zero/non-zero.
+constexpr int WEB_ERROR_NOT_INITIALIZED     = static_cast<int>(0x81350041u);
+constexpr int WEB_ERROR_ALREADY_INITIALIZED = static_cast<int>(0x81350042u);
+constexpr int WEB_ERROR_PARAM_INVALID       = static_cast<int>(0x81350043u);
+constexpr int WEB_ERROR_INVALID_STATE       = static_cast<int>(0x81350045u);
+
+int KYTY_SYSV_ABI Initialize() {
+	PRINT_NAME();
+
+	std::scoped_lock lock(g_dialog_mutex);
+	if (g_web.status != WEB_STATUS_NONE) {
+		return WEB_ERROR_ALREADY_INITIALIZED;
+	}
+
+	g_web.status = WEB_STATUS_INITIALIZED;
+
+	return OK;
+}
+
+int KYTY_SYSV_ABI Terminate() {
+	PRINT_NAME();
+
+	std::unique_lock lock(g_dialog_mutex);
+	if (g_web.status == WEB_STATUS_NONE) {
+		return WEB_ERROR_NOT_INITIALIZED;
+	}
+	if (g_web.status == WEB_STATUS_RUNNING) {
+		CloseWebBrowserRunning(lock);
+	} else {
+		g_web.status = WEB_STATUS_NONE;
+	}
+
+	return OK;
+}
+
+int KYTY_SYSV_ABI Open(const void* param) {
+	PRINT_NAME();
+
+	{
+		std::scoped_lock lock(g_dialog_mutex);
+		if (g_web.status == WEB_STATUS_NONE) {
+			return WEB_ERROR_NOT_INITIALIZED;
+		}
+		if (g_web.status != WEB_STATUS_INITIALIZED && g_web.status != WEB_STATUS_FINISHED) {
+			return WEB_ERROR_INVALID_STATE;
+		}
+	}
+
+	// The guest param is SceWebBrowserDialogParam whose layout is unverified, so no hard
+	// validation: probe only the leading size field for the log, and hand the overlay an
+	// editable address bar instead of a pre-extracted URL.
+	uint32_t param_size = 0;
+	if (param != nullptr) {
+		std::memcpy(&param_size, param, sizeof(param_size));
+	}
+	LOGF("\t param = 0x%016" PRIx64 ", size = %u\n", reinterpret_cast<uint64_t>(param),
+	     static_cast<uint32_t>(param_size));
+
+	std::unique_lock lock(g_dialog_mutex);

Major · Stability & Availability · Quick win

Keep state validation and the RUNNING transition under one lock.

After Open releases the first lock, another call can terminate the initialized browser. This call then acquires the second lock and changes NONE to RUNNING without initialization. Two concurrent Open calls can also both pass validation and return success for one session. Retain one lock through validation and state mutation, or repeat validation after reacquiring it.

**@⁠coderabbitai[bot]** on GitHub · 2026-11-13 04:39 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2213#discussion_r4559714410) On `src/libs/dialog.cpp` line 949 (outdated): ```diff @@ -827,4 +874,169 @@ int KYTY_SYSV_ABI ErrorDialogGetStatus() { } // namespace ErrorDialog +namespace WebBrowserDialog { + +LIB_NAME("WebBrowserDialog", "WebBrowserDialog"); + +// Same state progression rules the other common dialogs use. +constexpr int WEB_STATUS_NONE = 0; +constexpr int WEB_STATUS_INITIALIZED = 1; +constexpr int WEB_STATUS_RUNNING = 2; +constexpr int WEB_STATUS_FINISHED = 3; + +constexpr int WEB_RESULT_USER_CANCELED = 1; + +// NOTE(unverified): the numeric error values reuse the 0x8135xxxx CommonDialog family +// pattern of Kyty's SigninDialog. The real SceWebBrowserDialogError codes were never +// confirmed from an SDK header; games normally branch only on zero/non-zero. +constexpr int WEB_ERROR_NOT_INITIALIZED = static_cast<int>(0x81350041u); +constexpr int WEB_ERROR_ALREADY_INITIALIZED = static_cast<int>(0x81350042u); +constexpr int WEB_ERROR_PARAM_INVALID = static_cast<int>(0x81350043u); +constexpr int WEB_ERROR_INVALID_STATE = static_cast<int>(0x81350045u); + +int KYTY_SYSV_ABI Initialize() { + PRINT_NAME(); + + std::scoped_lock lock(g_dialog_mutex); + if (g_web.status != WEB_STATUS_NONE) { + return WEB_ERROR_ALREADY_INITIALIZED; + } + + g_web.status = WEB_STATUS_INITIALIZED; + + return OK; +} + +int KYTY_SYSV_ABI Terminate() { + PRINT_NAME(); + + std::unique_lock lock(g_dialog_mutex); + if (g_web.status == WEB_STATUS_NONE) { + return WEB_ERROR_NOT_INITIALIZED; + } + if (g_web.status == WEB_STATUS_RUNNING) { + CloseWebBrowserRunning(lock); + } else { + g_web.status = WEB_STATUS_NONE; + } + + return OK; +} + +int KYTY_SYSV_ABI Open(const void* param) { + PRINT_NAME(); + + { + std::scoped_lock lock(g_dialog_mutex); + if (g_web.status == WEB_STATUS_NONE) { + return WEB_ERROR_NOT_INITIALIZED; + } + if (g_web.status != WEB_STATUS_INITIALIZED && g_web.status != WEB_STATUS_FINISHED) { + return WEB_ERROR_INVALID_STATE; + } + } + + // The guest param is SceWebBrowserDialogParam whose layout is unverified, so no hard + // validation: probe only the leading size field for the log, and hand the overlay an + // editable address bar instead of a pre-extracted URL. + uint32_t param_size = 0; + if (param != nullptr) { + std::memcpy(&param_size, param, sizeof(param_size)); + } + LOGF("\t param = 0x%016" PRIx64 ", size = %u\n", reinterpret_cast<uint64_t>(param), + static_cast<uint32_t>(param_size)); + + std::unique_lock lock(g_dialog_mutex); ``` <!-- coderabbit-ai-generated:v1 --> **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/major-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Major** · **Stability & Availability** · **Quick win** **Keep state validation and the RUNNING transition under one lock.** After `Open` releases the first lock, another call can terminate the initialized browser. This call then acquires the second lock and changes NONE to RUNNING without initialization. Two concurrent `Open` calls can also both pass validation and return success for one session. Retain one lock through validation and state mutation, or repeat validation after reacquiring it. <!-- fingerprinting:phantom:medusa:wombat61 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:6a682e35cc742e5d3c741388 --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-13 04:39 UTC · original
On src/libs/libKernel.cpp line 2299 (outdated):

@@ -2227,9 +2280,24 @@ LIB_DEFINE(InitLibKernel_1_Posix) {
 	LIB_FUNC("oBr313PppNE", Posix::sendto);
 	LIB_FUNC("Ez8xjo9UF4E", Posix::recv);
 	LIB_FUNC("lUk6wrGXyMw", Posix::recvfrom);
+	// Real titles (Stray, PAW Patrol, Hollow Knight Silksong) import these peer-address and
+	// scatter/gather calls through the Posix library. NIDs from game captures, names from the
+	// PS5 3.20 stub tables (https://github.com/DNNDHH/PS5-3.20_Libs, libkernel.c).
+	LIB_FUNC("TXFFFiNldU8", Posix::getpeername);
+	LIB_FUNC("aNeavPDNKzA", Posix::sendmsg);
+	LIB_FUNC("hI7oVeOluPM", Posix::recvmsg);
 	LIB_FUNC("4n51s0zEf0c", Posix::inet_pton);
 	LIB_FUNC("5jRCs2axtr4", Posix::inet_ntop);
 	LIB_FUNC("cfwBSQyr5Ys", cfwBSQyr5Ys);
+
+	// Guest-verified NIDs real titles (Stray, PAW Patrol, Hollow Knight Silksong)
+	// import through the Posix library that this block lacked. Names come from
+	// shadPS4's libScePosix table (https://github.com/shadps4-emu/shadPS4,
+	// src/core/libraries/kernel/kernel.cpp, issues #860/#4764) and bind the
+	// imports to the same Kyty implementations the SDK-spelled names use.
+	LIB_FUNC("NN01qLRhiqU", LibKernel::FileSystem::KernelRename); // rename
+	LIB_FUNC("c7ZnT7V1B98", LibKernel::FileSystem::KernelRmdir); // rmdir

Major · Functional Correctness · Quick win

Convert filesystem errors for the POSIX exports.

If the source path does not exist, KernelRename and KernelRmdir return KERNEL_ERROR_ENOENT without setting POSIX errno. These direct registrations expose that kernel error instead of -1, which breaks POSIX error handling. Add wrappers that use POSIX_CALL, as the neighboring filesystem exports do. See src/kernel/fileSystem.cpp, Lines 1355–1384 and 1468–1490, at the reviewed revision. (raw.githubusercontent.com)

**@⁠coderabbitai[bot]** on GitHub · 2026-11-13 04:39 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2213#discussion_r4559714416) On `src/libs/libKernel.cpp` line 2299 (outdated): ```diff @@ -2227,9 +2280,24 @@ LIB_DEFINE(InitLibKernel_1_Posix) { LIB_FUNC("oBr313PppNE", Posix::sendto); LIB_FUNC("Ez8xjo9UF4E", Posix::recv); LIB_FUNC("lUk6wrGXyMw", Posix::recvfrom); + // Real titles (Stray, PAW Patrol, Hollow Knight Silksong) import these peer-address and + // scatter/gather calls through the Posix library. NIDs from game captures, names from the + // PS5 3.20 stub tables (https://github.com/DNNDHH/PS5-3.20_Libs, libkernel.c). + LIB_FUNC("TXFFFiNldU8", Posix::getpeername); + LIB_FUNC("aNeavPDNKzA", Posix::sendmsg); + LIB_FUNC("hI7oVeOluPM", Posix::recvmsg); LIB_FUNC("4n51s0zEf0c", Posix::inet_pton); LIB_FUNC("5jRCs2axtr4", Posix::inet_ntop); LIB_FUNC("cfwBSQyr5Ys", cfwBSQyr5Ys); + + // Guest-verified NIDs real titles (Stray, PAW Patrol, Hollow Knight Silksong) + // import through the Posix library that this block lacked. Names come from + // shadPS4's libScePosix table (https://github.com/shadps4-emu/shadPS4, + // src/core/libraries/kernel/kernel.cpp, issues #860/#4764) and bind the + // imports to the same Kyty implementations the SDK-spelled names use. + LIB_FUNC("NN01qLRhiqU", LibKernel::FileSystem::KernelRename); // rename + LIB_FUNC("c7ZnT7V1B98", LibKernel::FileSystem::KernelRmdir); // rmdir ``` <!-- coderabbit-ai-generated:v1 --> **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/major-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Major** · **Functional Correctness** · **Quick win** **Convert filesystem errors for the POSIX exports.** If the source path does not exist, `KernelRename` and `KernelRmdir` return `KERNEL_ERROR_ENOENT` without setting POSIX errno. These direct registrations expose that kernel error instead of `-1`, which breaks POSIX error handling. Add wrappers that use `POSIX_CALL`, as the neighboring filesystem exports do. See `src/kernel/fileSystem.cpp`, Lines 1355–1384 and 1468–1490, at the reviewed revision. ([raw.githubusercontent.com](https://raw.githubusercontent.com/KytyPS5/KytyPS5/da94befdaf3550fe361b74b52f7d61e4bc4c69f1/src/kernel/fileSystem.cpp)) <!-- fingerprinting:phantom:medusa:wombat61 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:273dc14e5cbffc120d75592f --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-13 04:39 UTC · original
On src/libs/libKernel.cpp line 2300 (outdated):

@@ -2227,9 +2280,24 @@ LIB_DEFINE(InitLibKernel_1_Posix) {
 	LIB_FUNC("oBr313PppNE", Posix::sendto);
 	LIB_FUNC("Ez8xjo9UF4E", Posix::recv);
 	LIB_FUNC("lUk6wrGXyMw", Posix::recvfrom);
+	// Real titles (Stray, PAW Patrol, Hollow Knight Silksong) import these peer-address and
+	// scatter/gather calls through the Posix library. NIDs from game captures, names from the
+	// PS5 3.20 stub tables (https://github.com/DNNDHH/PS5-3.20_Libs, libkernel.c).
+	LIB_FUNC("TXFFFiNldU8", Posix::getpeername);
+	LIB_FUNC("aNeavPDNKzA", Posix::sendmsg);
+	LIB_FUNC("hI7oVeOluPM", Posix::recvmsg);
 	LIB_FUNC("4n51s0zEf0c", Posix::inet_pton);
 	LIB_FUNC("5jRCs2axtr4", Posix::inet_ntop);
 	LIB_FUNC("cfwBSQyr5Ys", cfwBSQyr5Ys);
+
+	// Guest-verified NIDs real titles (Stray, PAW Patrol, Hollow Knight Silksong)
+	// import through the Posix library that this block lacked. Names come from
+	// shadPS4's libScePosix table (https://github.com/shadps4-emu/shadPS4,
+	// src/core/libraries/kernel/kernel.cpp, issues #860/#4764) and bind the
+	// imports to the same Kyty implementations the SDK-spelled names use.
+	LIB_FUNC("NN01qLRhiqU", LibKernel::FileSystem::KernelRename); // rename
+	LIB_FUNC("c7ZnT7V1B98", LibKernel::FileSystem::KernelRmdir); // rmdir
+	LIB_FUNC("TUuiYS2kE8s", LibNet::NetShutdown);                // shutdown

Major · Functional Correctness · Quick win

Keep the existing POSIX shutdown registration.

This NID already maps to Posix::shutdown at Line 2273. SymbolDatabase::Add replaces that mapping with this registration. LibNet::NetShutdown converts failures into NET_ERROR_* values, so POSIX callers no longer receive -1. Remove this duplicate registration. The relevant implementations are in src/loader/symbolDatabase.cpp, Lines 29–35, and src/libs/libNet.cpp, Lines 72–73 and 97–98, at the reviewed revision. (raw.githubusercontent.com)

**@⁠coderabbitai[bot]** on GitHub · 2026-11-13 04:39 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2213#discussion_r4559714421) On `src/libs/libKernel.cpp` line 2300 (outdated): ```diff @@ -2227,9 +2280,24 @@ LIB_DEFINE(InitLibKernel_1_Posix) { LIB_FUNC("oBr313PppNE", Posix::sendto); LIB_FUNC("Ez8xjo9UF4E", Posix::recv); LIB_FUNC("lUk6wrGXyMw", Posix::recvfrom); + // Real titles (Stray, PAW Patrol, Hollow Knight Silksong) import these peer-address and + // scatter/gather calls through the Posix library. NIDs from game captures, names from the + // PS5 3.20 stub tables (https://github.com/DNNDHH/PS5-3.20_Libs, libkernel.c). + LIB_FUNC("TXFFFiNldU8", Posix::getpeername); + LIB_FUNC("aNeavPDNKzA", Posix::sendmsg); + LIB_FUNC("hI7oVeOluPM", Posix::recvmsg); LIB_FUNC("4n51s0zEf0c", Posix::inet_pton); LIB_FUNC("5jRCs2axtr4", Posix::inet_ntop); LIB_FUNC("cfwBSQyr5Ys", cfwBSQyr5Ys); + + // Guest-verified NIDs real titles (Stray, PAW Patrol, Hollow Knight Silksong) + // import through the Posix library that this block lacked. Names come from + // shadPS4's libScePosix table (https://github.com/shadps4-emu/shadPS4, + // src/core/libraries/kernel/kernel.cpp, issues #860/#4764) and bind the + // imports to the same Kyty implementations the SDK-spelled names use. + LIB_FUNC("NN01qLRhiqU", LibKernel::FileSystem::KernelRename); // rename + LIB_FUNC("c7ZnT7V1B98", LibKernel::FileSystem::KernelRmdir); // rmdir + LIB_FUNC("TUuiYS2kE8s", LibNet::NetShutdown); // shutdown ``` <!-- coderabbit-ai-generated:v1 --> **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/major-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Major** · **Functional Correctness** · **Quick win** **Keep the existing POSIX shutdown registration.** This NID already maps to `Posix::shutdown` at Line 2273. `SymbolDatabase::Add` replaces that mapping with this registration. `LibNet::NetShutdown` converts failures into `NET_ERROR_*` values, so POSIX callers no longer receive `-1`. Remove this duplicate registration. The relevant implementations are in `src/loader/symbolDatabase.cpp`, Lines 29–35, and `src/libs/libNet.cpp`, Lines 72–73 and 97–98, at the reviewed revision. ([raw.githubusercontent.com](https://raw.githubusercontent.com/KytyPS5/KytyPS5/da94befdaf3550fe361b74b52f7d61e4bc4c69f1/src/loader/symbolDatabase.cpp)) <!-- fingerprinting:phantom:medusa:wombat61 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:02f02b1a80503fe8c257d497 --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-13 04:39 UTC · original
On src/libs/libNet.cpp line 1963 (outdated):

@@ -1741,47 +1669,336 @@ static int KYTY_SYSV_ABI NpSessionSignalingInitialize(void* param) {
 	return 0;
 }
 
+// Guest-verified NIDs Hollow Knight Silksong's PSN.prx plugin imports. Names come
+// from the PS5 3.20 generated stub table (https://github.com/DNNDHH/PS5-3.20_Libs,
+// libSceNpSessionSignaling.c); Kyty has no signaling transport, so every call logs
+// and takes the same offline path as NpSessionSignalingInitialize. Guest signatures
+// are unverified, so emulator-side functions take no parameters and never write
+// presumed-out parameters; callers that zero their own structs observe a clean,
+// offline-neutral state.
+static int KYTY_SYSV_ABI NpSessionSignalingActivateUser() {
+	PRINT_NAME();
+	LOGF("\t no signaling transport, accepted offline\n");
+	return 0;
+}
+
+static int KYTY_SYSV_ABI NpSessionSignalingTerminate() {
+	PRINT_NAME();
+	LOGF("\t no signaling transport\n");
+	return 0;
+}
+
+static int KYTY_SYSV_ABI NpSessionSignalingGetLocalNetInfo() {
+	PRINT_NAME();
+	LOGF("\t no net info available offline (no output written)\n");
+	return 0;
+}
+
+static int KYTY_SYSV_ABI NpSessionSignalingDestroyContext() {
+	PRINT_NAME();
+	return 0;
+}
+
+static int KYTY_SYSV_ABI NpSessionSignalingCreateContext2() {
+	PRINT_NAME();
+	LOGF("\t context creation accepted offline\n");
+	return 0;
+}
+
+static int KYTY_SYSV_ABI NpSessionSignalingDeactivate() {
+	PRINT_NAME();
+	return 0;
+}
+
+static int KYTY_SYSV_ABI NpSessionSignalingGetConnectionStatus() {
+	PRINT_NAME();
+	LOGF("\t no connection available offline (no output written)\n");
+	return 0;
+}
+
+static int KYTY_SYSV_ABI NpSessionSignalingActivateSession() {
+	PRINT_NAME();
+	LOGF("\t no session peers offline\n");
+	return 0;
+}
+
+static int KYTY_SYSV_ABI NpSessionSignalingRequestPrepare() {
+	PRINT_NAME();
+	LOGF("\t prepare accepted offline\n");
+	return 0;
+}
+
+static int KYTY_SYSV_ABI NpSessionSignalingGetConnectionInfo() {
+	PRINT_NAME();
+	LOGF("\t no connection info available offline (no output written)\n");
+	return 0;
+}
+
 LIB_DEFINE(InitNet_1_NpSessionSignaling) {
 	LIB_FUNC("ysmw6J-P8Ak", NpSessionSignalingInitialize);
+	LIB_FUNC("9r7dM3puxMk", NpSessionSignalingActivateUser);
+	LIB_FUNC("CqJuNXo5yiM", NpSessionSignalingTerminate);
+	LIB_FUNC("OTilStjd9L8", NpSessionSignalingGetLocalNetInfo);
+	LIB_FUNC("Z9Q9LzQDXf0", NpSessionSignalingDestroyContext);
+	LIB_FUNC("aBuX0PX-T7I", NpSessionSignalingCreateContext2);
+	LIB_FUNC("cQkBH-pXhF0", NpSessionSignalingDeactivate);
+	LIB_FUNC("n1fn2KFeLDA", NpSessionSignalingGetConnectionStatus);
+	LIB_FUNC("r4XacqHvkn4", NpSessionSignalingActivateSession);
+	LIB_FUNC("r8mVMwlafF8", NpSessionSignalingRequestPrepare);
+	LIB_FUNC("yJw2m6UWDYU", NpSessionSignalingGetConnectionInfo);
 }
 
 } // namespace LibNpSessionSignaling
 
+namespace LibNpEntitlementAccess {
+
+LIB_VERSION("NpEntitlementAccess", 1, "NpEntitlementAccess", 1, 1);
+
+constexpr int      NP_ENTITLEMENT_ACCESS_ERROR_PARAMETER      = -2122514430; /* 0x817D0002 */
+constexpr int      NP_ENTITLEMENT_ACCESS_ERROR_NO_ENTITLEMENT = -2122514425; /* 0x817D0007 */
+constexpr uint32_t NP_ENTITLEMENT_ACCESS_SKU_FLAG_FULL        = 3;
+
+struct NpEntitlementAccessInitParam {
+	char reserved[32];
+};
+
+struct NpEntitlementAccessBootParam {
+	char reserved[32];
+};
+
+struct NpUnifiedEntitlementLabel {
+	char data[17];
+	char padding[3];
+};
+
+struct NpEntitlementAccessAddcontEntitlementInfo {
+	NpUnifiedEntitlementLabel entitlement_label;
+	uint32_t                  package_type;
+	uint32_t                  download_status;
+};
+
+struct NpEntitlementAccessEntitlementKey {
+	uint8_t data[16];
+};
+
+static constexpr NpEntitlementAccessAddcontEntitlementInfo NP_ENTITLEMENT_ACCESS_ADDON_LIST[] = {
+    {{{"85y-je"}, {}}, 3, 4}, // GTA V hash 0xf4315381
+    {{{"5d5c48"}, {}}, 3, 4}, // GTA V hash 0x961c34b0
+    {{{"_mtqu6"}, {}}, 3, 4}, // GTA V hash 0x9cd1bcad
+};
+
+static int KYTY_SYSV_ABI NpEntitlementAccessInitialize(
+    const NpEntitlementAccessInitParam* init_param, NpEntitlementAccessBootParam* boot_param) {
+	PRINT_NAME();
+
+	if (init_param == nullptr || boot_param == nullptr) {
+		return NP_ENTITLEMENT_ACCESS_ERROR_PARAMETER;
+	}
+
+	memset(boot_param, 0, sizeof(*boot_param));
+
+	return 0;
+}
+
+static int KYTY_SYSV_ABI NpEntitlementAccessGetSkuFlag(uint32_t* sku_flag) {
+	PRINT_NAME();
+
+	if (sku_flag == nullptr) {
+		return NP_ENTITLEMENT_ACCESS_ERROR_PARAMETER;
+	}
+
+	*sku_flag = NP_ENTITLEMENT_ACCESS_SKU_FLAG_FULL;
+	return 0;
+}
+
+static int KYTY_SYSV_ABI NpEntitlementAccessGetAddcontEntitlementInfoList(
+    uint32_t service_label, NpEntitlementAccessAddcontEntitlementInfo* list, uint32_t list_num,
+    uint32_t* hit_num) {
+	PRINT_NAME();
+
+	LOGF("\t service_label = %" PRIu32 "\n", service_label);
+	LOGF("\t list          = 0x%016" PRIx64 "\n", reinterpret_cast<uint64_t>(list));
+	LOGF("\t list_num      = %" PRIu32 "\n", list_num);
+	LOGF("\t hit_num       = 0x%016" PRIx64 "\n", reinterpret_cast<uint64_t>(hit_num));
+
+	if (hit_num == nullptr || (list == nullptr && list_num != 0)) {
+		return NP_ENTITLEMENT_ACCESS_ERROR_PARAMETER;
+	}
+
+	*hit_num = static_cast<uint32_t>(sizeof(NP_ENTITLEMENT_ACCESS_ADDON_LIST) /
+	                                 sizeof(NP_ENTITLEMENT_ACCESS_ADDON_LIST[0]));
+
+	if (list != nullptr && list_num != 0) {
+		memset(list, 0, sizeof(*list) * list_num);
+
+		const auto copy_num = (list_num < *hit_num ? list_num : *hit_num);
+		for (uint32_t i = 0; i < copy_num; i++) {
+			list[i] = NP_ENTITLEMENT_ACCESS_ADDON_LIST[i];
+		}
+	}
+
+	return 0;
+}
+
+static int KYTY_SYSV_ABI NpEntitlementAccessGetAddcontEntitlementInfo(
+    uint32_t service_label, const NpUnifiedEntitlementLabel* entitlement_label,
+    NpEntitlementAccessAddcontEntitlementInfo* info) {
+	PRINT_NAME();
+
+	LOGF("\t service_label     = %" PRIu32 "\n", service_label);
+	LOGF("\t entitlement_label = 0x%016" PRIx64 "\n",
+	     reinterpret_cast<uint64_t>(entitlement_label));
+	LOGF("\t info              = 0x%016" PRIx64 "\n", reinterpret_cast<uint64_t>(info));
+
+	if (entitlement_label == nullptr || info == nullptr) {
+		return NP_ENTITLEMENT_ACCESS_ERROR_PARAMETER;
+	}
+
+	memset(info, 0, sizeof(*info));
+
+	for (const auto& entitlement: NP_ENTITLEMENT_ACCESS_ADDON_LIST) {
+		if (strncmp(entitlement_label->data, entitlement.entitlement_label.data,
+		            sizeof(entitlement_label->data)) == 0) {
+			*info = entitlement;
+			return 0;
+		}
+	}
+
+	return NP_ENTITLEMENT_ACCESS_ERROR_NO_ENTITLEMENT;
+}
+
+static int KYTY_SYSV_ABI NpEntitlementAccessGetEntitlementKey(
+    uint32_t service_label, const NpUnifiedEntitlementLabel* entitlement_label,
+    NpEntitlementAccessEntitlementKey* key) {
+	PRINT_NAME();
+
+	LOGF("\t service_label     = %" PRIu32 "\n"
+	     "\t entitlement_label = 0x%016" PRIx64 "\n"
+	     "\t key               = 0x%016" PRIx64 "\n",
+	     service_label, reinterpret_cast<uint64_t>(entitlement_label),
+	     reinterpret_cast<uint64_t>(key));
+
+	if (entitlement_label == nullptr || key == nullptr) {
+		return NP_ENTITLEMENT_ACCESS_ERROR_PARAMETER;
+	}
+
+	return NP_ENTITLEMENT_ACCESS_ERROR_NO_ENTITLEMENT;
+}
+
+// Guest-verified NIDs Hollow Knight Silksong's PSN.prx plugin imports. Names come
+// from the PS5 3.20 generated stub table (https://github.com/DNNDHH/PS5-3.20_Libs,
+// libSceNpEntitlementAccess.c). Offline path matches the block's own
+// GetEntitlementKey precedent: request/poll always complete with
+// ERROR_NO_ENTITLEMENT because there is no PSN backend; lifecycle acks OK. Guest
+// signatures are unverified, so these take no parameters and never write presumed
+// out-parameters.
+static int KYTY_SYSV_ABI EntitlementOfflineNoEntitlement() {
+	PRINT_NAME();
+	LOGF("\t no PSN backend, reporting no entitlement\n");
+	return NP_ENTITLEMENT_ACCESS_ERROR_NO_ENTITLEMENT;
+}
+
+static int KYTY_SYSV_ABI EntitlementOfflineAck() {
+	PRINT_NAME();
+	return 0;
+}
+
+static int KYTY_SYSV_ABI NpEntitlementAccessPollConsumeEntitlement() {
+	return EntitlementOfflineNoEntitlement();
+}
+
+static int KYTY_SYSV_ABI NpEntitlementAccessRequestConsumeServiceEntitlement() {
+	return EntitlementOfflineNoEntitlement();
+}
+
+static int KYTY_SYSV_ABI NpEntitlementAccessAbortRequest() {
+	return EntitlementOfflineAck();
+}
+
+static int KYTY_SYSV_ABI NpEntitlementAccessGenerateTransactionId() {
+	// Transaction ids only matter to a PSN backend; offline they are unused.
+	return EntitlementOfflineAck();
+}
+
+static int KYTY_SYSV_ABI NpEntitlementAccessPollUnifiedEntitlementInfo() {
+	return EntitlementOfflineNoEntitlement();
+}
+
+static int KYTY_SYSV_ABI NpEntitlementAccessRequestServiceEntitlementInfo() {
+	return EntitlementOfflineNoEntitlement();
+}
+
+static int KYTY_SYSV_ABI NpEntitlementAccessPollServiceEntitlementInfo() {
+	return EntitlementOfflineNoEntitlement();
+}
+
+static int KYTY_SYSV_ABI NpEntitlementAccessDeleteRequest() {
+	return EntitlementOfflineAck();
+}
+
+static int KYTY_SYSV_ABI NpEntitlementAccessPollServiceEntitlementInfoList() {
+	return EntitlementOfflineNoEntitlement();
+}
+
+static int KYTY_SYSV_ABI NpEntitlementAccessRequestServiceEntitlementInfoList() {
+	return EntitlementOfflineNoEntitlement();
+}
+
+static int KYTY_SYSV_ABI NpEntitlementAccessRequestConsumeUnifiedEntitlement() {
+	return EntitlementOfflineNoEntitlement();
+}
+
+static int KYTY_SYSV_ABI NpEntitlementAccessRequestUnifiedEntitlementInfo() {
+	return EntitlementOfflineNoEntitlement();
+}
+
+static int KYTY_SYSV_ABI NpEntitlementAccessPollUnifiedEntitlementInfoList() {
+	return EntitlementOfflineNoEntitlement();
+}
+
+static int KYTY_SYSV_ABI NpEntitlementAccessRequestUnifiedEntitlementInfoList() {
+	return EntitlementOfflineNoEntitlement();
+}
+
+LIB_DEFINE(InitNet_1_NpEntitlementAccess) {

Major · Functional Correctness · Quick win

Remove one of the two InitNet_1_NpEntitlementAccess definitions.

src/libs/libNet.cpp:1963 and src/libs/libNpEntitlementAccess.cpp:492 both define Libs::LibNpEntitlementAccess::InitNet_1_NpEntitlementAccess with external linkage. The CMake glob compiles both files into the emulator target. The link then fails with a multiple-definition error.

Keep one initializer. Register the new entitlement functions in the initializer that owns the LibNpEntitlementAccess implementation.

**@⁠coderabbitai[bot]** on GitHub · 2026-11-13 04:39 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2213#discussion_r4559714425) On `src/libs/libNet.cpp` line 1963 (outdated): ```diff @@ -1741,47 +1669,336 @@ static int KYTY_SYSV_ABI NpSessionSignalingInitialize(void* param) { return 0; } +// Guest-verified NIDs Hollow Knight Silksong's PSN.prx plugin imports. Names come +// from the PS5 3.20 generated stub table (https://github.com/DNNDHH/PS5-3.20_Libs, +// libSceNpSessionSignaling.c); Kyty has no signaling transport, so every call logs +// and takes the same offline path as NpSessionSignalingInitialize. Guest signatures +// are unverified, so emulator-side functions take no parameters and never write +// presumed-out parameters; callers that zero their own structs observe a clean, +// offline-neutral state. +static int KYTY_SYSV_ABI NpSessionSignalingActivateUser() { + PRINT_NAME(); + LOGF("\t no signaling transport, accepted offline\n"); + return 0; +} + +static int KYTY_SYSV_ABI NpSessionSignalingTerminate() { + PRINT_NAME(); + LOGF("\t no signaling transport\n"); + return 0; +} + +static int KYTY_SYSV_ABI NpSessionSignalingGetLocalNetInfo() { + PRINT_NAME(); + LOGF("\t no net info available offline (no output written)\n"); + return 0; +} + +static int KYTY_SYSV_ABI NpSessionSignalingDestroyContext() { + PRINT_NAME(); + return 0; +} + +static int KYTY_SYSV_ABI NpSessionSignalingCreateContext2() { + PRINT_NAME(); + LOGF("\t context creation accepted offline\n"); + return 0; +} + +static int KYTY_SYSV_ABI NpSessionSignalingDeactivate() { + PRINT_NAME(); + return 0; +} + +static int KYTY_SYSV_ABI NpSessionSignalingGetConnectionStatus() { + PRINT_NAME(); + LOGF("\t no connection available offline (no output written)\n"); + return 0; +} + +static int KYTY_SYSV_ABI NpSessionSignalingActivateSession() { + PRINT_NAME(); + LOGF("\t no session peers offline\n"); + return 0; +} + +static int KYTY_SYSV_ABI NpSessionSignalingRequestPrepare() { + PRINT_NAME(); + LOGF("\t prepare accepted offline\n"); + return 0; +} + +static int KYTY_SYSV_ABI NpSessionSignalingGetConnectionInfo() { + PRINT_NAME(); + LOGF("\t no connection info available offline (no output written)\n"); + return 0; +} + LIB_DEFINE(InitNet_1_NpSessionSignaling) { LIB_FUNC("ysmw6J-P8Ak", NpSessionSignalingInitialize); + LIB_FUNC("9r7dM3puxMk", NpSessionSignalingActivateUser); + LIB_FUNC("CqJuNXo5yiM", NpSessionSignalingTerminate); + LIB_FUNC("OTilStjd9L8", NpSessionSignalingGetLocalNetInfo); + LIB_FUNC("Z9Q9LzQDXf0", NpSessionSignalingDestroyContext); + LIB_FUNC("aBuX0PX-T7I", NpSessionSignalingCreateContext2); + LIB_FUNC("cQkBH-pXhF0", NpSessionSignalingDeactivate); + LIB_FUNC("n1fn2KFeLDA", NpSessionSignalingGetConnectionStatus); + LIB_FUNC("r4XacqHvkn4", NpSessionSignalingActivateSession); + LIB_FUNC("r8mVMwlafF8", NpSessionSignalingRequestPrepare); + LIB_FUNC("yJw2m6UWDYU", NpSessionSignalingGetConnectionInfo); } } // namespace LibNpSessionSignaling +namespace LibNpEntitlementAccess { + +LIB_VERSION("NpEntitlementAccess", 1, "NpEntitlementAccess", 1, 1); + +constexpr int NP_ENTITLEMENT_ACCESS_ERROR_PARAMETER = -2122514430; /* 0x817D0002 */ +constexpr int NP_ENTITLEMENT_ACCESS_ERROR_NO_ENTITLEMENT = -2122514425; /* 0x817D0007 */ +constexpr uint32_t NP_ENTITLEMENT_ACCESS_SKU_FLAG_FULL = 3; + +struct NpEntitlementAccessInitParam { + char reserved[32]; +}; + +struct NpEntitlementAccessBootParam { + char reserved[32]; +}; + +struct NpUnifiedEntitlementLabel { + char data[17]; + char padding[3]; +}; + +struct NpEntitlementAccessAddcontEntitlementInfo { + NpUnifiedEntitlementLabel entitlement_label; + uint32_t package_type; + uint32_t download_status; +}; + +struct NpEntitlementAccessEntitlementKey { + uint8_t data[16]; +}; + +static constexpr NpEntitlementAccessAddcontEntitlementInfo NP_ENTITLEMENT_ACCESS_ADDON_LIST[] = { + {{{"85y-je"}, {}}, 3, 4}, // GTA V hash 0xf4315381 + {{{"5d5c48"}, {}}, 3, 4}, // GTA V hash 0x961c34b0 + {{{"_mtqu6"}, {}}, 3, 4}, // GTA V hash 0x9cd1bcad +}; + +static int KYTY_SYSV_ABI NpEntitlementAccessInitialize( + const NpEntitlementAccessInitParam* init_param, NpEntitlementAccessBootParam* boot_param) { + PRINT_NAME(); + + if (init_param == nullptr || boot_param == nullptr) { + return NP_ENTITLEMENT_ACCESS_ERROR_PARAMETER; + } + + memset(boot_param, 0, sizeof(*boot_param)); + + return 0; +} + +static int KYTY_SYSV_ABI NpEntitlementAccessGetSkuFlag(uint32_t* sku_flag) { + PRINT_NAME(); + + if (sku_flag == nullptr) { + return NP_ENTITLEMENT_ACCESS_ERROR_PARAMETER; + } + + *sku_flag = NP_ENTITLEMENT_ACCESS_SKU_FLAG_FULL; + return 0; +} + +static int KYTY_SYSV_ABI NpEntitlementAccessGetAddcontEntitlementInfoList( + uint32_t service_label, NpEntitlementAccessAddcontEntitlementInfo* list, uint32_t list_num, + uint32_t* hit_num) { + PRINT_NAME(); + + LOGF("\t service_label = %" PRIu32 "\n", service_label); + LOGF("\t list = 0x%016" PRIx64 "\n", reinterpret_cast<uint64_t>(list)); + LOGF("\t list_num = %" PRIu32 "\n", list_num); + LOGF("\t hit_num = 0x%016" PRIx64 "\n", reinterpret_cast<uint64_t>(hit_num)); + + if (hit_num == nullptr || (list == nullptr && list_num != 0)) { + return NP_ENTITLEMENT_ACCESS_ERROR_PARAMETER; + } + + *hit_num = static_cast<uint32_t>(sizeof(NP_ENTITLEMENT_ACCESS_ADDON_LIST) / + sizeof(NP_ENTITLEMENT_ACCESS_ADDON_LIST[0])); + + if (list != nullptr && list_num != 0) { + memset(list, 0, sizeof(*list) * list_num); + + const auto copy_num = (list_num < *hit_num ? list_num : *hit_num); + for (uint32_t i = 0; i < copy_num; i++) { + list[i] = NP_ENTITLEMENT_ACCESS_ADDON_LIST[i]; + } + } + + return 0; +} + +static int KYTY_SYSV_ABI NpEntitlementAccessGetAddcontEntitlementInfo( + uint32_t service_label, const NpUnifiedEntitlementLabel* entitlement_label, + NpEntitlementAccessAddcontEntitlementInfo* info) { + PRINT_NAME(); + + LOGF("\t service_label = %" PRIu32 "\n", service_label); + LOGF("\t entitlement_label = 0x%016" PRIx64 "\n", + reinterpret_cast<uint64_t>(entitlement_label)); + LOGF("\t info = 0x%016" PRIx64 "\n", reinterpret_cast<uint64_t>(info)); + + if (entitlement_label == nullptr || info == nullptr) { + return NP_ENTITLEMENT_ACCESS_ERROR_PARAMETER; + } + + memset(info, 0, sizeof(*info)); + + for (const auto& entitlement: NP_ENTITLEMENT_ACCESS_ADDON_LIST) { + if (strncmp(entitlement_label->data, entitlement.entitlement_label.data, + sizeof(entitlement_label->data)) == 0) { + *info = entitlement; + return 0; + } + } + + return NP_ENTITLEMENT_ACCESS_ERROR_NO_ENTITLEMENT; +} + +static int KYTY_SYSV_ABI NpEntitlementAccessGetEntitlementKey( + uint32_t service_label, const NpUnifiedEntitlementLabel* entitlement_label, + NpEntitlementAccessEntitlementKey* key) { + PRINT_NAME(); + + LOGF("\t service_label = %" PRIu32 "\n" + "\t entitlement_label = 0x%016" PRIx64 "\n" + "\t key = 0x%016" PRIx64 "\n", + service_label, reinterpret_cast<uint64_t>(entitlement_label), + reinterpret_cast<uint64_t>(key)); + + if (entitlement_label == nullptr || key == nullptr) { + return NP_ENTITLEMENT_ACCESS_ERROR_PARAMETER; + } + + return NP_ENTITLEMENT_ACCESS_ERROR_NO_ENTITLEMENT; +} + +// Guest-verified NIDs Hollow Knight Silksong's PSN.prx plugin imports. Names come +// from the PS5 3.20 generated stub table (https://github.com/DNNDHH/PS5-3.20_Libs, +// libSceNpEntitlementAccess.c). Offline path matches the block's own +// GetEntitlementKey precedent: request/poll always complete with +// ERROR_NO_ENTITLEMENT because there is no PSN backend; lifecycle acks OK. Guest +// signatures are unverified, so these take no parameters and never write presumed +// out-parameters. +static int KYTY_SYSV_ABI EntitlementOfflineNoEntitlement() { + PRINT_NAME(); + LOGF("\t no PSN backend, reporting no entitlement\n"); + return NP_ENTITLEMENT_ACCESS_ERROR_NO_ENTITLEMENT; +} + +static int KYTY_SYSV_ABI EntitlementOfflineAck() { + PRINT_NAME(); + return 0; +} + +static int KYTY_SYSV_ABI NpEntitlementAccessPollConsumeEntitlement() { + return EntitlementOfflineNoEntitlement(); +} + +static int KYTY_SYSV_ABI NpEntitlementAccessRequestConsumeServiceEntitlement() { + return EntitlementOfflineNoEntitlement(); +} + +static int KYTY_SYSV_ABI NpEntitlementAccessAbortRequest() { + return EntitlementOfflineAck(); +} + +static int KYTY_SYSV_ABI NpEntitlementAccessGenerateTransactionId() { + // Transaction ids only matter to a PSN backend; offline they are unused. + return EntitlementOfflineAck(); +} + +static int KYTY_SYSV_ABI NpEntitlementAccessPollUnifiedEntitlementInfo() { + return EntitlementOfflineNoEntitlement(); +} + +static int KYTY_SYSV_ABI NpEntitlementAccessRequestServiceEntitlementInfo() { + return EntitlementOfflineNoEntitlement(); +} + +static int KYTY_SYSV_ABI NpEntitlementAccessPollServiceEntitlementInfo() { + return EntitlementOfflineNoEntitlement(); +} + +static int KYTY_SYSV_ABI NpEntitlementAccessDeleteRequest() { + return EntitlementOfflineAck(); +} + +static int KYTY_SYSV_ABI NpEntitlementAccessPollServiceEntitlementInfoList() { + return EntitlementOfflineNoEntitlement(); +} + +static int KYTY_SYSV_ABI NpEntitlementAccessRequestServiceEntitlementInfoList() { + return EntitlementOfflineNoEntitlement(); +} + +static int KYTY_SYSV_ABI NpEntitlementAccessRequestConsumeUnifiedEntitlement() { + return EntitlementOfflineNoEntitlement(); +} + +static int KYTY_SYSV_ABI NpEntitlementAccessRequestUnifiedEntitlementInfo() { + return EntitlementOfflineNoEntitlement(); +} + +static int KYTY_SYSV_ABI NpEntitlementAccessPollUnifiedEntitlementInfoList() { + return EntitlementOfflineNoEntitlement(); +} + +static int KYTY_SYSV_ABI NpEntitlementAccessRequestUnifiedEntitlementInfoList() { + return EntitlementOfflineNoEntitlement(); +} + +LIB_DEFINE(InitNet_1_NpEntitlementAccess) { ``` <!-- coderabbit-ai-generated:v1 --> **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/major-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Major** · **Functional Correctness** · **Quick win** **Remove one of the two `InitNet_1_NpEntitlementAccess` definitions.** `src/libs/libNet.cpp:1963` and `src/libs/libNpEntitlementAccess.cpp:492` both define `Libs::LibNpEntitlementAccess::InitNet_1_NpEntitlementAccess` with external linkage. The CMake glob compiles both files into the emulator target. The link then fails with a multiple-definition error. Keep one initializer. Register the new entitlement functions in the initializer that owns the `LibNpEntitlementAccess` implementation. <!-- fingerprinting:phantom:medusa:wombat61 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:52d73bdf64e5a9336dbae5bb --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-13 04:39 UTC · original
On src/libs/network.cpp line 1278 (outdated):

@@ -1230,6 +1254,36 @@ static int ConvertHostSockaddr(const sockaddr_storage* addr, SocketLength addrle
 	return 0;
 }
 
+// Validation shared by sendmsg/recvmsg, following shadPS4's GatherSize semantics for
+// the same guest callers: a signed iovec count, a 1024-iovec cap, null-base checking
+// for nonzero lengths, and an INT32_MAX total-size cap.
+static int GuestMsgGatherSize(const GuestMsghdr& guest, uint64_t* out_total) {
+	EXIT_IF(out_total == nullptr);
+
+	if (guest.msg_iovlen < 0 || (guest.msg_iovlen > 0 && guest.msg_iov == nullptr)) {
+		*Posix::GetErrorAddr() = Posix::POSIX_EINVAL;
+		return -1;
+	}
+	if (guest.msg_iovlen > 1024) {
+		*Posix::GetErrorAddr() = Posix::POSIX_EMSGSIZE;
+		return -1;
+	}
+	uint64_t total = 0;
+	for (int32_t i = 0; i < guest.msg_iovlen; i++) {
+		if (guest.msg_iov[i].iov_base == nullptr && guest.msg_iov[i].iov_len != 0) {
+			*Posix::GetErrorAddr() = Posix::POSIX_EFAULT;
+			return -1;
+		}
+		total += guest.msg_iov[i].iov_len;
+		if (total > static_cast<uint64_t>(std::numeric_limits<int32_t>::max())) {

Major · Security & Privacy · Quick win

Check each length before adding it to total.

Two non-null iovecs with lengths 16 and UINT64_MAX - 7 pass this validation: the second addition wraps total to 8. Sendmsg then allocates eight bytes and copies sixteen bytes into that allocation before attempting the second copy. Reject a length greater than INT32_MAX - total before the addition.

**@⁠coderabbitai[bot]** on GitHub · 2026-11-13 04:39 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2213#discussion_r4559714430) On `src/libs/network.cpp` line 1278 (outdated): ```diff @@ -1230,6 +1254,36 @@ static int ConvertHostSockaddr(const sockaddr_storage* addr, SocketLength addrle return 0; } +// Validation shared by sendmsg/recvmsg, following shadPS4's GatherSize semantics for +// the same guest callers: a signed iovec count, a 1024-iovec cap, null-base checking +// for nonzero lengths, and an INT32_MAX total-size cap. +static int GuestMsgGatherSize(const GuestMsghdr& guest, uint64_t* out_total) { + EXIT_IF(out_total == nullptr); + + if (guest.msg_iovlen < 0 || (guest.msg_iovlen > 0 && guest.msg_iov == nullptr)) { + *Posix::GetErrorAddr() = Posix::POSIX_EINVAL; + return -1; + } + if (guest.msg_iovlen > 1024) { + *Posix::GetErrorAddr() = Posix::POSIX_EMSGSIZE; + return -1; + } + uint64_t total = 0; + for (int32_t i = 0; i < guest.msg_iovlen; i++) { + if (guest.msg_iov[i].iov_base == nullptr && guest.msg_iov[i].iov_len != 0) { + *Posix::GetErrorAddr() = Posix::POSIX_EFAULT; + return -1; + } + total += guest.msg_iov[i].iov_len; + if (total > static_cast<uint64_t>(std::numeric_limits<int32_t>::max())) { ``` <!-- coderabbit-ai-generated:v1 --> **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/major-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Major** · **Security & Privacy** · **Quick win** **Check each length before adding it to `total`.** Two non-null iovecs with lengths `16` and `UINT64_MAX - 7` pass this validation: the second addition wraps `total` to `8`. `Sendmsg` then allocates eight bytes and copies sixteen bytes into that allocation before attempting the second copy. Reject a length greater than `INT32_MAX - total` before the addition. <!-- fingerprinting:phantom:medusa:wombat61 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:d103d56ab7d91c30611da34d --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-13 04:39 UTC · original
On src/libs/network.cpp line 2622 (outdated):

@@ -2544,6 +2616,10 @@ int64_t KYTY_SYSV_ABI Recvfrom(int s, void* buf, uint64_t len, int flags, void*
 	sockaddr_storage host_addr {};
 	SocketLength     host_addrlen = sizeof(host_addr);
 	int64_t          result       = 0;
+	// Winsock rejects MSG_PEEK | MSG_WAITALL with WSAEOPNOTSUPP on datagram sockets, while a
+	// datagram is delivered whole anyway; only stream receives keep the combined flag.
+	const int recv_flags =
+	    transport->type == SOCK_STREAM ? host_flags : (host_flags & ~MSG_WAITALL);

Critical · Functional Correctness · Quick win

Use state.transport to select receive flags.

Recvfrom declares state, but it does not declare transport. This expression prevents network.cpp from compiling on every platform.

Proposed fix

-	    transport->type == SOCK_STREAM ? host_flags : (host_flags & ~MSG_WAITALL);
+	    state.transport->type == SOCK_STREAM ? host_flags : (host_flags & ~MSG_WAITALL);
Committable suggestion

IMPORTANT
Review the replacement and indentation, then test before committing.

	    state.transport->type == SOCK_STREAM ? host_flags : (host_flags & ~MSG_WAITALL);
**@⁠coderabbitai[bot]** on GitHub · 2026-11-13 04:39 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2213#discussion_r4559714436) On `src/libs/network.cpp` line 2622 (outdated): ```diff @@ -2544,6 +2616,10 @@ int64_t KYTY_SYSV_ABI Recvfrom(int s, void* buf, uint64_t len, int flags, void* sockaddr_storage host_addr {}; SocketLength host_addrlen = sizeof(host_addr); int64_t result = 0; + // Winsock rejects MSG_PEEK | MSG_WAITALL with WSAEOPNOTSUPP on datagram sockets, while a + // datagram is delivered whole anyway; only stream receives keep the combined flag. + const int recv_flags = + transport->type == SOCK_STREAM ? host_flags : (host_flags & ~MSG_WAITALL); ``` <!-- coderabbit-ai-generated:v1 --> **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/critical-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Critical** · **Functional Correctness** · **Quick win** **Use `state.transport` to select receive flags.** `Recvfrom` declares `state`, but it does not declare `transport`. This expression prevents `network.cpp` from compiling on every platform. <details> <summary>Proposed fix</summary> <dl> <dd> <br> ```diff - transport->type == SOCK_STREAM ? host_flags : (host_flags & ~MSG_WAITALL); + state.transport->type == SOCK_STREAM ? host_flags : (host_flags & ~MSG_WAITALL); ``` </dd> </dl> </details> <!-- suggestion_start --> <details> <summary>Committable suggestion</summary> <dl> <dd> <br> > <picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-warning.svg" width="20" height="20" align="absmiddle" alt=""></picture> **IMPORTANT** > Review the replacement and indentation, then test before committing. ```suggestion state.transport->type == SOCK_STREAM ? host_flags : (host_flags & ~MSG_WAITALL); ``` </dd> </dl> </details> <!-- suggestion_end --> <!-- fingerprinting:phantom:medusa:wombat61 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:d982613a7be670b008fbf455 --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-13 04:39 UTC · original
On src/libs/network.cpp line 2786 (outdated):

@@ -2582,6 +2659,166 @@ int64_t KYTY_SYSV_ABI Recvfrom(int s, void* buf, uint64_t len, int flags, void*
 	return result;
 }
 
+int64_t KYTY_SYSV_ABI Sendmsg(int s, const void* msg, int flags) {
+	PRINT_NAME();
+
+	LOGF("\t s     = %d\n"
+	     "\t msg   = 0x%016" PRIx64 "\n"
+	     "\t flags = 0x%08" PRIx32 "\n",
+	     s, reinterpret_cast<uint64_t>(msg), static_cast<uint32_t>(flags));
+
+	NativeSocket socket = INVALID_NATIVE_SOCKET;
+	if (msg == nullptr) {
+		return SetGuestSocketError(Posix::POSIX_EFAULT);
+	}
+	// UDPP2P requires protocol framing; the native-only lookup rejects virtual-port
+	// sockets (same behavior as sendto).
+	if (!GetSocketBackend(s, &socket)) {
+		return -1;
+	}
+
+	const auto* guest  = static_cast<const GuestMsghdr*>(msg);
+	uint64_t    total  = 0;
+	if (GuestMsgGatherSize(*guest, &total) != 0) {
+		return -1;
+	}
+	const int host_flags = ConvertMessageFlags(flags);
+	if (host_flags < 0) {
+		return -1;
+	}
+	if (guest->msg_control != nullptr) {
+		// Ancillary control data is not carried by the socket backend.
+		return SetGuestSocketError(Posix::POSIX_EOPNOTSUPP);
+	}
+
+	std::vector<char> buffer(static_cast<size_t>(total));
+	const char*       payload = total != 0 ? buffer.data() : "";
+	uint64_t          written = 0;
+	for (int32_t i = 0; i < guest->msg_iovlen; i++) {
+		if (guest->msg_iov[i].iov_len != 0) {
+			std::memcpy(buffer.data() + written, guest->msg_iov[i].iov_base,
+			            static_cast<size_t>(guest->msg_iov[i].iov_len));
+		}
+		written += guest->msg_iov[i].iov_len;
+	}
+
+	int64_t result = 0;
+	if (guest->msg_name == nullptr) {
+		result = ::send(socket, payload, static_cast<SocketIoLength>(total), host_flags);
+	} else {
+		sockaddr_storage host_addr {};
+		SocketLength     host_addrlen = 0;
+		if (ConvertGuestSockaddr(guest->msg_name, guest->msg_namelen, &host_addr,
+		                         &host_addrlen) != 0) {
+			return -1;
+		}
+		result = ::sendto(socket, payload, static_cast<SocketIoLength>(total), host_flags,
+		                  reinterpret_cast<const sockaddr*>(&host_addr), host_addrlen);
+	}
+	if (result < 0) {
+		return SetHostSocketError();
+	}
+
+	return result;
+}
+
+int64_t KYTY_SYSV_ABI Recvmsg(int s, void* msg, int flags) {
+	PRINT_NAME();
+
+	LOGF("\t s     = %d\n"
+	     "\t msg   = 0x%016" PRIx64 "\n"
+	     "\t flags = 0x%08" PRIx32 "\n",
+	     s, reinterpret_cast<uint64_t>(msg), static_cast<uint32_t>(flags));
+
+	auto* guest = static_cast<GuestMsghdr*>(msg);
+	if (guest == nullptr) {
+		return SetGuestSocketError(Posix::POSIX_EFAULT);
+	}
+
+	NativeSocket                    socket = INVALID_NATIVE_SOCKET;
+	std::shared_ptr<SocketTransport> transport;
+	if (!GetSocketBackend(s, &socket, nullptr, &transport)) {
+		return -1;
+	}
+
+	uint64_t total = 0;
+	if (GuestMsgGatherSize(*guest, &total) != 0) {
+		return -1;
+	}
+	const int host_flags = ConvertMessageFlags(flags);
+	if (host_flags < 0) {
+		return -1;
+	}
+	if (guest->msg_control != nullptr) {
+		// Ancillary control data is not produced by the socket backend.
+		return SetGuestSocketError(Posix::POSIX_EOPNOTSUPP);
+	}
+
+	std::vector<char> buffer(static_cast<size_t>(total));
+	char*             payload = total != 0 ? buffer.data() : nullptr;
+
+	const int recv_flags =
+	    transport->type == SOCK_STREAM ? host_flags : (host_flags & ~MSG_WAITALL);
+
+	sockaddr_storage host_addr {};
+	SocketLength     host_addrlen = sizeof(host_addr);
+	int64_t          result       = 0;
+
+#if defined(_WIN32)
+	if (transport->type == SOCK_STREAM) {
+		if (guest->msg_name != nullptr &&
+		    ::getpeername(socket, reinterpret_cast<sockaddr*>(&host_addr), &host_addrlen) != 0) {
+			return SetHostSocketError();
+		}
+		result = ReceiveStream(*transport, payload, static_cast<int>(total), host_flags,
+		                       (flags & 0x80) != 0);
+		if (result < 0) {
+			return result;
+		}
+	} else
+#endif
+	{
+		transport.reset();
+		if (guest->msg_name == nullptr) {
+			result = ::recv(socket, payload, static_cast<SocketIoLength>(total), recv_flags);
+		} else {
+			result = ::recvfrom(socket, payload, static_cast<SocketIoLength>(total), recv_flags,
+			                    reinterpret_cast<sockaddr*>(&host_addr), &host_addrlen);

Major · Stability & Availability · Heavy lift

Honor MSG_DONTWAIT for Windows datagram receives.

On Windows, ConvertMessageFlags removes guest MSG_DONTWAIT without producing a host flag. Only the stream branch handles the flag separately. If a blocking UDP socket has no queued datagram, these native calls therefore wait instead of returning EWOULDBLOCK. Implement per-call nonblocking behavior for this branch without changing the socket mode observed by concurrent callers. Winsock documents that an empty blocking receive waits for data. (learn.microsoft.com)

**@⁠coderabbitai[bot]** on GitHub · 2026-11-13 04:39 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2213#discussion_r4559714443) On `src/libs/network.cpp` line 2786 (outdated): ```diff @@ -2582,6 +2659,166 @@ int64_t KYTY_SYSV_ABI Recvfrom(int s, void* buf, uint64_t len, int flags, void* return result; } +int64_t KYTY_SYSV_ABI Sendmsg(int s, const void* msg, int flags) { + PRINT_NAME(); + + LOGF("\t s = %d\n" + "\t msg = 0x%016" PRIx64 "\n" + "\t flags = 0x%08" PRIx32 "\n", + s, reinterpret_cast<uint64_t>(msg), static_cast<uint32_t>(flags)); + + NativeSocket socket = INVALID_NATIVE_SOCKET; + if (msg == nullptr) { + return SetGuestSocketError(Posix::POSIX_EFAULT); + } + // UDPP2P requires protocol framing; the native-only lookup rejects virtual-port + // sockets (same behavior as sendto). + if (!GetSocketBackend(s, &socket)) { + return -1; + } + + const auto* guest = static_cast<const GuestMsghdr*>(msg); + uint64_t total = 0; + if (GuestMsgGatherSize(*guest, &total) != 0) { + return -1; + } + const int host_flags = ConvertMessageFlags(flags); + if (host_flags < 0) { + return -1; + } + if (guest->msg_control != nullptr) { + // Ancillary control data is not carried by the socket backend. + return SetGuestSocketError(Posix::POSIX_EOPNOTSUPP); + } + + std::vector<char> buffer(static_cast<size_t>(total)); + const char* payload = total != 0 ? buffer.data() : ""; + uint64_t written = 0; + for (int32_t i = 0; i < guest->msg_iovlen; i++) { + if (guest->msg_iov[i].iov_len != 0) { + std::memcpy(buffer.data() + written, guest->msg_iov[i].iov_base, + static_cast<size_t>(guest->msg_iov[i].iov_len)); + } + written += guest->msg_iov[i].iov_len; + } + + int64_t result = 0; + if (guest->msg_name == nullptr) { + result = ::send(socket, payload, static_cast<SocketIoLength>(total), host_flags); + } else { + sockaddr_storage host_addr {}; + SocketLength host_addrlen = 0; + if (ConvertGuestSockaddr(guest->msg_name, guest->msg_namelen, &host_addr, + &host_addrlen) != 0) { + return -1; + } + result = ::sendto(socket, payload, static_cast<SocketIoLength>(total), host_flags, + reinterpret_cast<const sockaddr*>(&host_addr), host_addrlen); + } + if (result < 0) { + return SetHostSocketError(); + } + + return result; +} + +int64_t KYTY_SYSV_ABI Recvmsg(int s, void* msg, int flags) { + PRINT_NAME(); + + LOGF("\t s = %d\n" + "\t msg = 0x%016" PRIx64 "\n" + "\t flags = 0x%08" PRIx32 "\n", + s, reinterpret_cast<uint64_t>(msg), static_cast<uint32_t>(flags)); + + auto* guest = static_cast<GuestMsghdr*>(msg); + if (guest == nullptr) { + return SetGuestSocketError(Posix::POSIX_EFAULT); + } + + NativeSocket socket = INVALID_NATIVE_SOCKET; + std::shared_ptr<SocketTransport> transport; + if (!GetSocketBackend(s, &socket, nullptr, &transport)) { + return -1; + } + + uint64_t total = 0; + if (GuestMsgGatherSize(*guest, &total) != 0) { + return -1; + } + const int host_flags = ConvertMessageFlags(flags); + if (host_flags < 0) { + return -1; + } + if (guest->msg_control != nullptr) { + // Ancillary control data is not produced by the socket backend. + return SetGuestSocketError(Posix::POSIX_EOPNOTSUPP); + } + + std::vector<char> buffer(static_cast<size_t>(total)); + char* payload = total != 0 ? buffer.data() : nullptr; + + const int recv_flags = + transport->type == SOCK_STREAM ? host_flags : (host_flags & ~MSG_WAITALL); + + sockaddr_storage host_addr {}; + SocketLength host_addrlen = sizeof(host_addr); + int64_t result = 0; + +#if defined(_WIN32) + if (transport->type == SOCK_STREAM) { + if (guest->msg_name != nullptr && + ::getpeername(socket, reinterpret_cast<sockaddr*>(&host_addr), &host_addrlen) != 0) { + return SetHostSocketError(); + } + result = ReceiveStream(*transport, payload, static_cast<int>(total), host_flags, + (flags & 0x80) != 0); + if (result < 0) { + return result; + } + } else +#endif + { + transport.reset(); + if (guest->msg_name == nullptr) { + result = ::recv(socket, payload, static_cast<SocketIoLength>(total), recv_flags); + } else { + result = ::recvfrom(socket, payload, static_cast<SocketIoLength>(total), recv_flags, + reinterpret_cast<sockaddr*>(&host_addr), &host_addrlen); ``` <!-- coderabbit-ai-generated:v1 --> **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/major-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Major** · **Stability & Availability** · **Heavy lift** **Honor `MSG_DONTWAIT` for Windows datagram receives.** On Windows, `ConvertMessageFlags` removes guest `MSG_DONTWAIT` without producing a host flag. Only the stream branch handles the flag separately. If a blocking UDP socket has no queued datagram, these native calls therefore wait instead of returning `EWOULDBLOCK`. Implement per-call nonblocking behavior for this branch without changing the socket mode observed by concurrent callers. Winsock documents that an empty blocking receive waits for data. ([learn.microsoft.com](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-recv)) <!-- fingerprinting:phantom:medusa:wombat61 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:efea3d37e0538398631e01e5 --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-13 04:39 UTC · original
On src/libs/network.cpp line 2817 (outdated):

@@ -2582,6 +2659,166 @@ int64_t KYTY_SYSV_ABI Recvfrom(int s, void* buf, uint64_t len, int flags, void*
 	return result;
 }
 
+int64_t KYTY_SYSV_ABI Sendmsg(int s, const void* msg, int flags) {
+	PRINT_NAME();
+
+	LOGF("\t s     = %d\n"
+	     "\t msg   = 0x%016" PRIx64 "\n"
+	     "\t flags = 0x%08" PRIx32 "\n",
+	     s, reinterpret_cast<uint64_t>(msg), static_cast<uint32_t>(flags));
+
+	NativeSocket socket = INVALID_NATIVE_SOCKET;
+	if (msg == nullptr) {
+		return SetGuestSocketError(Posix::POSIX_EFAULT);
+	}
+	// UDPP2P requires protocol framing; the native-only lookup rejects virtual-port
+	// sockets (same behavior as sendto).
+	if (!GetSocketBackend(s, &socket)) {
+		return -1;
+	}
+
+	const auto* guest  = static_cast<const GuestMsghdr*>(msg);
+	uint64_t    total  = 0;
+	if (GuestMsgGatherSize(*guest, &total) != 0) {
+		return -1;
+	}
+	const int host_flags = ConvertMessageFlags(flags);
+	if (host_flags < 0) {
+		return -1;
+	}
+	if (guest->msg_control != nullptr) {
+		// Ancillary control data is not carried by the socket backend.
+		return SetGuestSocketError(Posix::POSIX_EOPNOTSUPP);
+	}
+
+	std::vector<char> buffer(static_cast<size_t>(total));
+	const char*       payload = total != 0 ? buffer.data() : "";
+	uint64_t          written = 0;
+	for (int32_t i = 0; i < guest->msg_iovlen; i++) {
+		if (guest->msg_iov[i].iov_len != 0) {
+			std::memcpy(buffer.data() + written, guest->msg_iov[i].iov_base,
+			            static_cast<size_t>(guest->msg_iov[i].iov_len));
+		}
+		written += guest->msg_iov[i].iov_len;
+	}
+
+	int64_t result = 0;
+	if (guest->msg_name == nullptr) {
+		result = ::send(socket, payload, static_cast<SocketIoLength>(total), host_flags);
+	} else {
+		sockaddr_storage host_addr {};
+		SocketLength     host_addrlen = 0;
+		if (ConvertGuestSockaddr(guest->msg_name, guest->msg_namelen, &host_addr,
+		                         &host_addrlen) != 0) {
+			return -1;
+		}
+		result = ::sendto(socket, payload, static_cast<SocketIoLength>(total), host_flags,
+		                  reinterpret_cast<const sockaddr*>(&host_addr), host_addrlen);
+	}
+	if (result < 0) {
+		return SetHostSocketError();
+	}
+
+	return result;
+}
+
+int64_t KYTY_SYSV_ABI Recvmsg(int s, void* msg, int flags) {
+	PRINT_NAME();
+
+	LOGF("\t s     = %d\n"
+	     "\t msg   = 0x%016" PRIx64 "\n"
+	     "\t flags = 0x%08" PRIx32 "\n",
+	     s, reinterpret_cast<uint64_t>(msg), static_cast<uint32_t>(flags));
+
+	auto* guest = static_cast<GuestMsghdr*>(msg);
+	if (guest == nullptr) {
+		return SetGuestSocketError(Posix::POSIX_EFAULT);
+	}
+
+	NativeSocket                    socket = INVALID_NATIVE_SOCKET;
+	std::shared_ptr<SocketTransport> transport;
+	if (!GetSocketBackend(s, &socket, nullptr, &transport)) {
+		return -1;
+	}
+
+	uint64_t total = 0;
+	if (GuestMsgGatherSize(*guest, &total) != 0) {
+		return -1;
+	}
+	const int host_flags = ConvertMessageFlags(flags);
+	if (host_flags < 0) {
+		return -1;
+	}
+	if (guest->msg_control != nullptr) {
+		// Ancillary control data is not produced by the socket backend.
+		return SetGuestSocketError(Posix::POSIX_EOPNOTSUPP);
+	}
+
+	std::vector<char> buffer(static_cast<size_t>(total));
+	char*             payload = total != 0 ? buffer.data() : nullptr;
+
+	const int recv_flags =
+	    transport->type == SOCK_STREAM ? host_flags : (host_flags & ~MSG_WAITALL);
+
+	sockaddr_storage host_addr {};
+	SocketLength     host_addrlen = sizeof(host_addr);
+	int64_t          result       = 0;
+
+#if defined(_WIN32)
+	if (transport->type == SOCK_STREAM) {
+		if (guest->msg_name != nullptr &&
+		    ::getpeername(socket, reinterpret_cast<sockaddr*>(&host_addr), &host_addrlen) != 0) {
+			return SetHostSocketError();
+		}
+		result = ReceiveStream(*transport, payload, static_cast<int>(total), host_flags,
+		                       (flags & 0x80) != 0);
+		if (result < 0) {
+			return result;
+		}
+	} else
+#endif
+	{
+		transport.reset();
+		if (guest->msg_name == nullptr) {
+			result = ::recv(socket, payload, static_cast<SocketIoLength>(total), recv_flags);
+		} else {
+			result = ::recvfrom(socket, payload, static_cast<SocketIoLength>(total), recv_flags,
+			                    reinterpret_cast<sockaddr*>(&host_addr), &host_addrlen);
+		}
+	}
+#if defined(_WIN32)
+	if (result < 0 && WSAGetLastError() == WSAEMSGSIZE) {
+		// Winsock copied the datagram prefix; POSIX reports its length as success.
+		result = static_cast<int64_t>(total);
+	}
+#endif
+	if (result < 0) {
+		return SetHostSocketError();
+	}
+
+	// Scatter the received bytes across the guest iovecs.
+	uint64_t remaining = static_cast<uint64_t>(result);
+	for (int32_t i = 0; i < guest->msg_iovlen && remaining != 0; i++) {
+		const uint64_t take = std::min<uint64_t>(remaining, guest->msg_iov[i].iov_len);
+		if (take != 0) {
+			std::memcpy(guest->msg_iov[i].iov_base,
+			            buffer.data() + (static_cast<uint64_t>(result) - remaining),
+			            static_cast<size_t>(take));
+		}
+		remaining -= take;
+	}
+
+	if (guest->msg_name != nullptr) {
+		if (ConvertHostSockaddr(&host_addr, host_addrlen, guest->msg_name,
+		                         &guest->msg_namelen) != 0) {
+			return -1;
+		}
+	}
+	guest->msg_flags = 0;

Major · Data Integrity & Integration · Heavy lift

Report truncated datagrams through msg_flags.

If a datagram exceeds the total iovec capacity, this function returns its prefix and sets msg_flags to zero. The guest cannot distinguish that prefix from a complete datagram. The BSD recvmsg contract requires MSG_TRUNC when trailing datagram data is discarded. Preserve that information on Windows when handling WSAEMSGSIZE; use a receive API that exposes truncation on other hosts. (raw.githubusercontent.com)

**@⁠coderabbitai[bot]** on GitHub · 2026-11-13 04:39 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2213#discussion_r4559714450) On `src/libs/network.cpp` line 2817 (outdated): ```diff @@ -2582,6 +2659,166 @@ int64_t KYTY_SYSV_ABI Recvfrom(int s, void* buf, uint64_t len, int flags, void* return result; } +int64_t KYTY_SYSV_ABI Sendmsg(int s, const void* msg, int flags) { + PRINT_NAME(); + + LOGF("\t s = %d\n" + "\t msg = 0x%016" PRIx64 "\n" + "\t flags = 0x%08" PRIx32 "\n", + s, reinterpret_cast<uint64_t>(msg), static_cast<uint32_t>(flags)); + + NativeSocket socket = INVALID_NATIVE_SOCKET; + if (msg == nullptr) { + return SetGuestSocketError(Posix::POSIX_EFAULT); + } + // UDPP2P requires protocol framing; the native-only lookup rejects virtual-port + // sockets (same behavior as sendto). + if (!GetSocketBackend(s, &socket)) { + return -1; + } + + const auto* guest = static_cast<const GuestMsghdr*>(msg); + uint64_t total = 0; + if (GuestMsgGatherSize(*guest, &total) != 0) { + return -1; + } + const int host_flags = ConvertMessageFlags(flags); + if (host_flags < 0) { + return -1; + } + if (guest->msg_control != nullptr) { + // Ancillary control data is not carried by the socket backend. + return SetGuestSocketError(Posix::POSIX_EOPNOTSUPP); + } + + std::vector<char> buffer(static_cast<size_t>(total)); + const char* payload = total != 0 ? buffer.data() : ""; + uint64_t written = 0; + for (int32_t i = 0; i < guest->msg_iovlen; i++) { + if (guest->msg_iov[i].iov_len != 0) { + std::memcpy(buffer.data() + written, guest->msg_iov[i].iov_base, + static_cast<size_t>(guest->msg_iov[i].iov_len)); + } + written += guest->msg_iov[i].iov_len; + } + + int64_t result = 0; + if (guest->msg_name == nullptr) { + result = ::send(socket, payload, static_cast<SocketIoLength>(total), host_flags); + } else { + sockaddr_storage host_addr {}; + SocketLength host_addrlen = 0; + if (ConvertGuestSockaddr(guest->msg_name, guest->msg_namelen, &host_addr, + &host_addrlen) != 0) { + return -1; + } + result = ::sendto(socket, payload, static_cast<SocketIoLength>(total), host_flags, + reinterpret_cast<const sockaddr*>(&host_addr), host_addrlen); + } + if (result < 0) { + return SetHostSocketError(); + } + + return result; +} + +int64_t KYTY_SYSV_ABI Recvmsg(int s, void* msg, int flags) { + PRINT_NAME(); + + LOGF("\t s = %d\n" + "\t msg = 0x%016" PRIx64 "\n" + "\t flags = 0x%08" PRIx32 "\n", + s, reinterpret_cast<uint64_t>(msg), static_cast<uint32_t>(flags)); + + auto* guest = static_cast<GuestMsghdr*>(msg); + if (guest == nullptr) { + return SetGuestSocketError(Posix::POSIX_EFAULT); + } + + NativeSocket socket = INVALID_NATIVE_SOCKET; + std::shared_ptr<SocketTransport> transport; + if (!GetSocketBackend(s, &socket, nullptr, &transport)) { + return -1; + } + + uint64_t total = 0; + if (GuestMsgGatherSize(*guest, &total) != 0) { + return -1; + } + const int host_flags = ConvertMessageFlags(flags); + if (host_flags < 0) { + return -1; + } + if (guest->msg_control != nullptr) { + // Ancillary control data is not produced by the socket backend. + return SetGuestSocketError(Posix::POSIX_EOPNOTSUPP); + } + + std::vector<char> buffer(static_cast<size_t>(total)); + char* payload = total != 0 ? buffer.data() : nullptr; + + const int recv_flags = + transport->type == SOCK_STREAM ? host_flags : (host_flags & ~MSG_WAITALL); + + sockaddr_storage host_addr {}; + SocketLength host_addrlen = sizeof(host_addr); + int64_t result = 0; + +#if defined(_WIN32) + if (transport->type == SOCK_STREAM) { + if (guest->msg_name != nullptr && + ::getpeername(socket, reinterpret_cast<sockaddr*>(&host_addr), &host_addrlen) != 0) { + return SetHostSocketError(); + } + result = ReceiveStream(*transport, payload, static_cast<int>(total), host_flags, + (flags & 0x80) != 0); + if (result < 0) { + return result; + } + } else +#endif + { + transport.reset(); + if (guest->msg_name == nullptr) { + result = ::recv(socket, payload, static_cast<SocketIoLength>(total), recv_flags); + } else { + result = ::recvfrom(socket, payload, static_cast<SocketIoLength>(total), recv_flags, + reinterpret_cast<sockaddr*>(&host_addr), &host_addrlen); + } + } +#if defined(_WIN32) + if (result < 0 && WSAGetLastError() == WSAEMSGSIZE) { + // Winsock copied the datagram prefix; POSIX reports its length as success. + result = static_cast<int64_t>(total); + } +#endif + if (result < 0) { + return SetHostSocketError(); + } + + // Scatter the received bytes across the guest iovecs. + uint64_t remaining = static_cast<uint64_t>(result); + for (int32_t i = 0; i < guest->msg_iovlen && remaining != 0; i++) { + const uint64_t take = std::min<uint64_t>(remaining, guest->msg_iov[i].iov_len); + if (take != 0) { + std::memcpy(guest->msg_iov[i].iov_base, + buffer.data() + (static_cast<uint64_t>(result) - remaining), + static_cast<size_t>(take)); + } + remaining -= take; + } + + if (guest->msg_name != nullptr) { + if (ConvertHostSockaddr(&host_addr, host_addrlen, guest->msg_name, + &guest->msg_namelen) != 0) { + return -1; + } + } + guest->msg_flags = 0; ``` <!-- coderabbit-ai-generated:v1 --> **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/major-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Major** · **Data Integrity & Integration** · **Heavy lift** **Report truncated datagrams through `msg_flags`.** If a datagram exceeds the total iovec capacity, this function returns its prefix and sets `msg_flags` to zero. The guest cannot distinguish that prefix from a complete datagram. The BSD `recvmsg` contract requires `MSG_TRUNC` when trailing datagram data is discarded. Preserve that information on Windows when handling `WSAEMSGSIZE`; use a receive API that exposes truncation on other hosts. ([raw.githubusercontent.com](https://raw.githubusercontent.com/freebsd/freebsd-src/releng/11.4/lib/libc/sys/recv.2)) <!-- fingerprinting:phantom:medusa:wombat61 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:0b075450ac5f9327d37eac88 --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-13 04:39 UTC · original
On tests/ResourceTrackingTests.cpp line 8449 (outdated):

@@ -8765,39 +8424,98 @@ void TestGuardedScalarDescriptorReads() {
       if (!shared) {
         memory.data.words[7] = 0;
         memory.data.words[0x40 / 4] = 0;
-        Check(MaterializeResources(plan, runtime, snapshot, specialization) && memory.null_reads == 1 &&
+        Check(MaterializeResources(plan, runtime, snapshot, specialization) && memory.null_reads == active_reads &&
                   std::ranges::all_of(snapshot.flattened_srt, [](auto word) { return word == 0; }),
               "cached plan retained reads after the feature was disabled");
       }
     }
   }
 }
 
+// A block that is certain to run and has a single successor passes its certainty on: nothing is
+// left to the wave, so a failed read in the successor must fail the refresh instead of being skipped.
+void TestSingleSuccessorKeepsCertainty() {
+  namespace CFG = Libs::Graphics::ShaderRecompiler::CFG;
+  Fixture fixture;
+  auto *entry = fixture.block;
+  auto *optional = fixture.AddBlock();
+  auto *done = fixture.AddBlock();
+  entry->AddBranch(optional);
+  entry->AddBranch(done);
+  optional->AddBranch(done);
+  fixture.program.block_info[0].terminator = {
+      .kind = CFG::TerminatorKind::ConditionalBranch, .true_block = 1, .false_block = 2};
+  fixture.program.block_info[1].terminator = {.kind = CFG::TerminatorKind::Branch, .true_block = 2};
+  fixture.program.block_info[2].terminator.kind = CFG::TerminatorKind::Return;

Major · Functional Correctness · Quick win

Replace block_info with the block pointers the fixture uses.

Program has no block_info member. The declaration at ShaderIR.h:711-737 contains only block_storage and blocks, and no other declaration in src or tests defines it. These writes therefore fail to compile in tests/ResourceTrackingTests.cpp. Fixture::PlanAndTrack also reads conditions from program.blocks, so terminators and conditions must be set on the block objects.

Set them on the entry, optional, and done blocks, as the surrounding test and existing fixtures do:

Suggested fix

-  fixture.program.block_info[0].terminator = {
-      .kind = CFG::TerminatorKind::ConditionalBranch, .true_block = 1, .false_block = 2};
-  fixture.program.block_info[1].terminator = {.kind = CFG::TerminatorKind::Branch, .true_block = 2};
-  fixture.program.block_info[2].terminator.kind = CFG::TerminatorKind::Return;
+  entry->terminator = {
+      .kind = CFG::TerminatorKind::ConditionalBranch, .true_block = optional, .false_block = done};
+  optional->terminator = {.kind = CFG::TerminatorKind::Branch, .true_block = done};
+  done->terminator.kind = CFG::TerminatorKind::Return;
-  fixture.program.block_info[0].condition = fixture.Emit(ValueOpcode::INotEqual32, {flag, Value(0u)});
+  entry->condition = fixture.Emit(ValueOpcode::INotEqual32, {flag, Value(0u)});
**@⁠coderabbitai[bot]** on GitHub · 2026-11-13 04:39 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2213#discussion_r4559714458) On `tests/ResourceTrackingTests.cpp` line 8449 (outdated): ```diff @@ -8765,39 +8424,98 @@ void TestGuardedScalarDescriptorReads() { if (!shared) { memory.data.words[7] = 0; memory.data.words[0x40 / 4] = 0; - Check(MaterializeResources(plan, runtime, snapshot, specialization) && memory.null_reads == 1 && + Check(MaterializeResources(plan, runtime, snapshot, specialization) && memory.null_reads == active_reads && std::ranges::all_of(snapshot.flattened_srt, [](auto word) { return word == 0; }), "cached plan retained reads after the feature was disabled"); } } } } +// A block that is certain to run and has a single successor passes its certainty on: nothing is +// left to the wave, so a failed read in the successor must fail the refresh instead of being skipped. +void TestSingleSuccessorKeepsCertainty() { + namespace CFG = Libs::Graphics::ShaderRecompiler::CFG; + Fixture fixture; + auto *entry = fixture.block; + auto *optional = fixture.AddBlock(); + auto *done = fixture.AddBlock(); + entry->AddBranch(optional); + entry->AddBranch(done); + optional->AddBranch(done); + fixture.program.block_info[0].terminator = { + .kind = CFG::TerminatorKind::ConditionalBranch, .true_block = 1, .false_block = 2}; + fixture.program.block_info[1].terminator = {.kind = CFG::TerminatorKind::Branch, .true_block = 2}; + fixture.program.block_info[2].terminator.kind = CFG::TerminatorKind::Return; ``` <!-- coderabbit-ai-generated:v1 --> **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/major-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Major** · **Functional Correctness** · **Quick win** **Replace `block_info` with the block pointers the fixture uses.** `Program` has no `block_info` member. The declaration at `ShaderIR.h:711-737` contains only `block_storage` and `blocks`, and no other declaration in `src` or `tests` defines it. These writes therefore fail to compile in `tests/ResourceTrackingTests.cpp`. `Fixture::PlanAndTrack` also reads conditions from `program.blocks`, so terminators and conditions must be set on the block objects. Set them on the `entry`, `optional`, and `done` blocks, as the surrounding test and existing fixtures do: <details> <summary>Suggested fix</summary> <dl> <dd> <br> ```diff - fixture.program.block_info[0].terminator = { - .kind = CFG::TerminatorKind::ConditionalBranch, .true_block = 1, .false_block = 2}; - fixture.program.block_info[1].terminator = {.kind = CFG::TerminatorKind::Branch, .true_block = 2}; - fixture.program.block_info[2].terminator.kind = CFG::TerminatorKind::Return; + entry->terminator = { + .kind = CFG::TerminatorKind::ConditionalBranch, .true_block = optional, .false_block = done}; + optional->terminator = {.kind = CFG::TerminatorKind::Branch, .true_block = done}; + done->terminator.kind = CFG::TerminatorKind::Return; ``` ```diff - fixture.program.block_info[0].condition = fixture.Emit(ValueOpcode::INotEqual32, {flag, Value(0u)}); + entry->condition = fixture.Emit(ValueOpcode::INotEqual32, {flag, Value(0u)}); ``` </dd> </dl> </details> <!-- fingerprinting:phantom:poseidon:wombat61 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:ce04f891628981ed913ce5dc --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-13 04:39 UTC · original · reviewed

Actionable comments posted: 15

Note

Due to the large number of review comments, Critical, Major severity comments were prioritized as inline comments.

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

Critical · Update KernelFsync for the shared-pointer return type. · fileSystem.cpp:1388

src/kernel/fileSystem.cpp:1388
Critical · Functional Correctness · Quick win

Update KernelFsync for the shared-pointer return type.

FileDescriptors::GetFile now returns std::shared_ptr<File>. auto* cannot deduce a pointer from that result. This prevents fileSystem.cpp from compiling and blocks the emulator and full-emulator tests. Change this declaration to auto file = g_files->GetFile(d);.

Minor comments: 12

src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp: 1

865-865: Minor · Performance & Scalability · Quick win

Keep the static feedback key zero on dynamic-state hosts.

When otherwise identical draws alternate between feedback and non-feedback layouts, this assignment creates two cache entries and two pipelines. The assignment does not check dynamic-state support. (raw.githubusercontent.com)

When eAttachmentFeedbackLoopEnableEXT is dynamic, Vulkan ignores the static feedback flag. The second pipeline therefore adds creation work and retained resources without changing behavior. (docs.vulkan.org)

Set this field only when depth_feedback_loop is true and attachment_feedback_loop_dynamic_state_enabled is false.

Proposed fix

-	rendering.depth_stencil_feedback_loop = depth_feedback_loop ? 1u : 0u;
+	rendering.depth_stencil_feedback_loop =
+	    depth_feedback_loop && !m_graphics.attachment_feedback_loop_dynamic_state_enabled ? 1u : 0u;
tests/ShaderRecompilerComputeTests.cpp: 1

17666-17668: Minor · Functional Correctness · Quick win

Run the static test when dynamic state is unavailable.

When attachment-feedback-loop layout is enabled but dynamic state is unavailable, this guard skips the exact configuration that the static path must support. --depth-feedback-static-only then returns success without running the check.

Require layout support only. Save the original dynamic-state flag, disable it for the check, and restore its original value afterward.

src/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cpp: 1

288-289: Minor · Functional Correctness · Quick win

Mask the scalar base to 48 bits in the residency address.

RefreshGpuScalarReads computes the range without the 48-bit mask that SrtWalker applies to scalar bases. A high word with bits above bit 15 produces an address above the 48-bit scalar range. The tracked range can then differ from the address that the walker and ReadScalarTable read. ReadScalarTable already masks the base, so this change matches the existing scalar path.

Suggested fix

-		const auto address = ((uint64_t {terms[1]} << 32u) | (terms[0] & ~3u)) + (terms[2] & ~3u) +
+		const auto address = (((uint64_t {terms[1]} << 32u) | (terms[0] & ~3u)) & AddressMask) +
+		                     (terms[2] & ~3u) +
 		                     static_cast<uint64_t>(int64_t {immediate});
CMakeLists.txt: 1

678-678: Minor · Functional Correctness · Quick win

Add stub_import_coverage_tests to the kyty_tests dependency list.

stub_import_coverage_tests is built with EXCLUDE_FROM_ALL. Nothing in the inspected CMake files adds it to kyty_tests. A clean kyty_tests build does not produce this executable. Its stub_import_coverage CTest entry then fails because the binary is missing. The other tests registered in this block are listed in kyty_tests.

Suggested fix

 		save_data_dialog_tests
 		http_uri_parse_tests
+		stub_import_coverage_tests
 	)
src/graphics/presentation/systemOverlay.cpp: 1

1423-1424: Minor · Functional Correctness · Quick win

Reserve footer height before creating the browser page child.

The page child requests the full remaining content height. The separator and Close button are submitted after it in the same fixed-size window. ImGui can place the footer below the visible area, so mouse users may not see Close until they scroll. Gamepad and Escape still close the dialog.

Suggested fix

-		ImGui::BeginChild("##browser_page", ImGui::GetContentRegionAvail(),
-		                  ImGuiChildFlags_None);
+		const ImVec2 page_avail = ImGui::GetContentRegionAvail();
+		const float  footer_height = 40.0f * scale + 2.0f * ImGui::GetStyle().ItemSpacing.y + 1.0f;
+		ImGui::BeginChild("##browser_page",
+		                  {page_avail.x, std::max(page_avail.y - footer_height, 0.0f)},
+		                  ImGuiChildFlags_None);
src/launcher/src/main.cpp: 2

16-18: Minor · Functional Correctness · Quick win

Load the same preference that the checkbox saves.

When the user enables “Skip the boot splash on startup,” MainDialogPrivate::WriteSettings saves MainDialog/skip_boot_splash at Line 556 of src/launcher/src/mainDialog.cpp. This startup read instead requests Launcher/skip_boot_splash, so it defaults to false and shows the splash again. It also ignores platform-scoped settings when Kyty.ini does not exist.

Use the existing settings storage selection and the MainDialog group before testing SkipBootSplash().


38-38: Minor · Functional Correctness · Quick win

Preserve the restored window state when showing the launcher.

If the user saves a normal-sized launcher window, MainDialogPrivate::Setup restores that geometry at Line 203 of src/launcher/src/mainDialog.cpp. Both startup paths then call showMaximized(), which overrides the restored normal state. Qt documents that this call displays the widget maximized. (doc.qt.io)

Use w.show() in both paths so startup preserves the saved window state.

Also applies to: 46-46

src/launcher/styles/launcher.qss: 1

1-1: Minor · Functional Correctness · Quick win

Use QSS block comments for the header.

Qt 6.8 recognizes /* ... */ comments, but tokenizes // as slashes. The first slash stops parsing before any style rule loads. This disables the entire application stylesheet, including the existing toolbar and editor styles. Replace all three header comments with one block comment. (raw.githubusercontent.com)

tests/stubImportBaseline.txt: 1

360-361: Minor · Functional Correctness · Quick win

Remove the implemented truncate imports from the baseline.

src/libs/libKernel.cpp, Lines 3189-3190, registers VW3TVZiM4-E as KernelFtruncate and WlyEA-sLDf0 as KernelTruncate. Keeping these pairs in the unresolved baseline exempts both registrations from regression detection. If either registration disappears, RunCoverage still passes because baseline.contains(key) suppresses the gap.

Remove these two entries so the test detects that regression.

src/loader/symbolDatabase.cpp: 1

91-91: Minor · Functional Correctness · Quick win

Restrict the match to the library field.

NID[Other_v1][Net_v1.0][Func] satisfies a lookup for library Net, although its library is Other. GenerateName permits this record because library and module are separate fields. The coverage test then counts an import under the wrong library as resolved.

Match the library marker immediately after prefix, not anywhere in symbol.name.

docs/agc-nid-research.md: 2

148-149: Minor · Functional Correctness · Quick win

Correct the registration claim.

src/libs/libAgcDriver.cpp registers several listed NIDs under Graphics5, including 7Wa3aeJgeVU and DwICrVxerkY. The scan therefore cannot show that none is registered under any guest-visible identity. State the specific PS5 identities that lack registrations instead. (raw.githubusercontent.com)


32-33: Minor · Data Integrity & Integration · Quick win

Do not describe the aliases as exact until their ABIs match.

A matching NID shows only that the symbol names match. It does not show that the argument types, buffer sizes, or command-buffer layouts match. The Kyty implementations in src/libs/agc.cpp take caller-supplied buffers and sizes, and some write packet words into those buffers. A mismatched guest signature could pass wrong sizes or layouts into these functions. The note should not present the alias as a safe, behavior-neutral fix until each guest signature is compared with the Kyty implementation.

📝 Suggested wording

-- Cheapest concrete unblock: re-register Kyty's six existing `Gen5` functions under the guest's
-  `Agc_v1][Agc_v1.1` identity — exact alias, no new behavior needed.
+- Candidate unblock: re-register Kyty's six existing `Gen5` functions under the guest's
+  `Agc_v1][Agc_v1.1` identity. Matching NIDs do not establish ABI compatibility. Compare each
+  captured guest call signature and buffer layout with the Kyty implementation before treating
+  these as exact aliases.
Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 0aa25f98665982c2ae181d03b55bfb00eb9f6575 and da94befdaf3550fe361b74b52f7d61e4bc4c69f1.

Files selected for processing: 63

  • CMakeLists.txt
  • README.md
  • docs/agc-nid-research.md
  • src/common/abi.h
  • src/common/platform/sysLinuxFileIO.cpp
  • src/common/platform/sysWindowsFileIO.cpp
  • src/graphics/host_gpu/graphicContext.h
  • src/graphics/host_gpu/renderer/cache/bufferCache.cpp
  • src/graphics/host_gpu/renderer/masterSemaphore.cpp
  • src/graphics/host_gpu/renderer/pipeline/descriptors.cpp
  • src/graphics/host_gpu/renderer/pipeline/descriptors.h
  • src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp
  • src/graphics/host_gpu/renderer/pipeline/pipelineCache.h
  • src/graphics/host_gpu/renderer/pipeline/shaders.cpp
  • src/graphics/host_gpu/renderer/render.h
  • src/graphics/host_gpu/renderer/renderContext.cpp
  • src/graphics/host_gpu/renderer/renderContext.h
  • src/graphics/host_gpu/renderer/renderDraw.cpp
  • src/graphics/presentation/systemOverlay.cpp
  • src/graphics/presentation/window/vulkanWindow.cpp
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterAlu.cpp
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterAluHelpers.cpp
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterInstructions.h
  • src/graphics/shader/recompiler/frontend/translate/Compare.cpp
  • src/graphics/shader/recompiler/frontend/translate/Translator.h
  • src/graphics/shader/recompiler/frontend/translate/Vector.cpp
  • src/graphics/shader/recompiler/ir/ResourceSnapshot.h
  • src/graphics/shader/recompiler/ir/ShaderIR.h
  • src/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cpp
  • src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp
  • src/graphics/shader/recompiler/ir/passes/SrtWalker.cpp
  • src/kernel/fileSystem.cpp
  • src/kernel/memory.cpp
  • src/kernel/semaphore.cpp
  • src/launcher/forms/configuration_list_widget.ui
  • src/launcher/forms/main_dialog.ui
  • src/launcher/include/bootSplash.h
  • src/launcher/include/mainDialog.h
  • src/launcher/src/bootSplash.cpp
  • src/launcher/src/launcherTheme.cpp
  • src/launcher/src/main.cpp
  • src/launcher/src/mainDialog.cpp
  • src/launcher/styles/launcher.qss
  • src/libs/dialog.cpp
  • src/libs/dialog.h
  • src/libs/libKernel.cpp
  • src/libs/libNet.cpp
  • src/libs/libSystemService.cpp
  • src/libs/libWebBrowserDialog.cpp
  • src/libs/network.cpp
  • src/libs/network.h
  • src/libs/systemService.h
  • src/loader/symbolDatabase.cpp
  • src/loader/symbolDatabase.h
  • tests/KernelFileSystemTests.cpp
  • tests/ResourceMaterializationTests.cpp
  • tests/ResourceTrackingTests.cpp
  • tests/ShaderRecompilerComputeTests.cpp
  • tests/StubImportCoverageTests.cpp
  • tests/VirtualMemoryAllocationTests.cpp
  • tests/WindowsFileReadTests.cpp
  • tests/shaderCfgTests.cpp
  • tests/stubImportBaseline.txt

Included 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-11-13 04:39 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2213#pullrequestreview-5886187348) · **reviewed** <!-- coderabbit-ai-generated:v1 --> **Actionable comments posted: 15** > [!NOTE] > Due to the large number of review comments, Critical, Major severity comments were prioritized as inline comments. > [!CAUTION] > Some comments are outside the diff and can’t be posted inline due to GitHub limitations. > > **⚠️ Outside diff range comments (1)** > > <details> > <summary><strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/critical-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Critical</strong> · Update <code>KernelFsync</code> for the shared-pointer return type. · <code>fileSystem.cpp:1388</code></summary><blockquote> > <dl> > <dd> > <br> > > `src/kernel/fileSystem.cpp:1388` > **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/critical-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Critical** · **Functional Correctness** · **Quick win** > > **Update `KernelFsync` for the shared-pointer return type.** > > `FileDescriptors::GetFile` now returns `std::shared_ptr<File>`. `auto*` cannot deduce a pointer from that result. This prevents `fileSystem.cpp` from compiling and blocks the emulator and full-emulator tests. Change this declaration to `auto file = g_files->GetFile(d);`. > > <!-- cr-comment:v1:ee841bd6451148c4562c3e1f --> > > </dd> > </dl> > </blockquote></details> <details> <summary><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/amber-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minor comments: 12</summary><blockquote> <dl> <dd> <br> <details> <summary>src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp: 1</summary><blockquote> <dl> <dd> <br> `865-865`: **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/amber-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minor** · **Performance & Scalability** · **Quick win** **Keep the static feedback key zero on dynamic-state hosts.** When otherwise identical draws alternate between feedback and non-feedback layouts, this assignment creates two cache entries and two pipelines. The assignment does not check dynamic-state support. ([raw.githubusercontent.com](https://raw.githubusercontent.com/KytyPS5/KytyPS5/da94befdaf3550fe361b74b52f7d61e4bc4c69f1/src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp)) When `eAttachmentFeedbackLoopEnableEXT` is dynamic, Vulkan ignores the static feedback flag. The second pipeline therefore adds creation work and retained resources without changing behavior. ([docs.vulkan.org](https://docs.vulkan.org/refpages/latest/refpages/source/VkPipelineCreateFlagBits.html?utm_source=openai)) Set this field only when `depth_feedback_loop` is true and `attachment_feedback_loop_dynamic_state_enabled` is false. <details> <summary>Proposed fix</summary> <dl> <dd> <br> ```diff - rendering.depth_stencil_feedback_loop = depth_feedback_loop ? 1u : 0u; + rendering.depth_stencil_feedback_loop = + depth_feedback_loop && !m_graphics.attachment_feedback_loop_dynamic_state_enabled ? 1u : 0u; ``` </dd> </dl> </details> <!-- cr-comment:v1:261cfce44d4444c1c8cca562 --> </dd> </dl> </blockquote></details> <details> <summary>tests/ShaderRecompilerComputeTests.cpp: 1</summary><blockquote> <dl> <dd> <br> `17666-17668`: **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/amber-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minor** · **Functional Correctness** · **Quick win** **Run the static test when dynamic state is unavailable.** When attachment-feedback-loop layout is enabled but dynamic state is unavailable, this guard skips the exact configuration that the static path must support. `--depth-feedback-static-only` then returns success without running the check. Require layout support only. Save the original dynamic-state flag, disable it for the check, and restore its original value afterward. <!-- cr-comment:v1:7b6ed7c0ccc69b1b8c6195f2 --> </dd> </dl> </blockquote></details> <details> <summary>src/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cpp: 1</summary><blockquote> <dl> <dd> <br> `288-289`: **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/amber-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minor** · **Functional Correctness** · **Quick win** **Mask the scalar base to 48 bits in the residency address.** `RefreshGpuScalarReads` computes the range without the 48-bit mask that `SrtWalker` applies to scalar bases. A high word with bits above bit 15 produces an address above the 48-bit scalar range. The tracked range can then differ from the address that the walker and `ReadScalarTable` read. `ReadScalarTable` already masks the base, so this change matches the existing scalar path. <details> <summary>Suggested fix</summary> <dl> <dd> <br> ```diff - const auto address = ((uint64_t {terms[1]} << 32u) | (terms[0] & ~3u)) + (terms[2] & ~3u) + + const auto address = (((uint64_t {terms[1]} << 32u) | (terms[0] & ~3u)) & AddressMask) + + (terms[2] & ~3u) + static_cast<uint64_t>(int64_t {immediate}); ``` </dd> </dl> </details> <!-- cr-comment:v1:c3ab6db7666a2dad963b61a8 --> </dd> </dl> </blockquote></details> <details> <summary>CMakeLists.txt: 1</summary><blockquote> <dl> <dd> <br> `678-678`: **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/amber-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minor** · **Functional Correctness** · **Quick win** **Add `stub_import_coverage_tests` to the `kyty_tests` dependency list.** `stub_import_coverage_tests` is built with `EXCLUDE_FROM_ALL`. Nothing in the inspected CMake files adds it to `kyty_tests`. A clean `kyty_tests` build does not produce this executable. Its `stub_import_coverage` CTest entry then fails because the binary is missing. The other tests registered in this block are listed in `kyty_tests`. <details> <summary>Suggested fix</summary> <dl> <dd> <br> ```diff save_data_dialog_tests http_uri_parse_tests + stub_import_coverage_tests ) ``` </dd> </dl> </details> <!-- cr-comment:v1:875e38958643ea9a259ec6e1 --> </dd> </dl> </blockquote></details> <details> <summary>src/graphics/presentation/systemOverlay.cpp: 1</summary><blockquote> <dl> <dd> <br> `1423-1424`: **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/amber-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minor** · **Functional Correctness** · **Quick win** **Reserve footer height before creating the browser page child.** The page child requests the full remaining content height. The separator and Close button are submitted after it in the same fixed-size window. ImGui can place the footer below the visible area, so mouse users may not see Close until they scroll. Gamepad and Escape still close the dialog. <details> <summary>Suggested fix</summary> <dl> <dd> <br> ```diff - ImGui::BeginChild("##browser_page", ImGui::GetContentRegionAvail(), - ImGuiChildFlags_None); + const ImVec2 page_avail = ImGui::GetContentRegionAvail(); + const float footer_height = 40.0f * scale + 2.0f * ImGui::GetStyle().ItemSpacing.y + 1.0f; + ImGui::BeginChild("##browser_page", + {page_avail.x, std::max(page_avail.y - footer_height, 0.0f)}, + ImGuiChildFlags_None); ``` </dd> </dl> </details> <!-- cr-comment:v1:31908da8ce2c4f11c2cde2c2 --> </dd> </dl> </blockquote></details> <details> <summary>src/launcher/src/main.cpp: 2</summary><blockquote> <dl> <dd> <br> `16-18`: **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/amber-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minor** · **Functional Correctness** · **Quick win** **Load the same preference that the checkbox saves.** When the user enables “Skip the boot splash on startup,” `MainDialogPrivate::WriteSettings` saves `MainDialog/skip_boot_splash` at Line 556 of `src/launcher/src/mainDialog.cpp`. This startup read instead requests `Launcher/skip_boot_splash`, so it defaults to `false` and shows the splash again. It also ignores platform-scoped settings when `Kyty.ini` does not exist. Use the existing settings storage selection and the `MainDialog` group before testing `SkipBootSplash()`. <!-- cr-comment:v1:e45aac8b7fb192da7421e70d --> --- `38-38`: **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/amber-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minor** · **Functional Correctness** · **Quick win** **Preserve the restored window state when showing the launcher.** If the user saves a normal-sized launcher window, `MainDialogPrivate::Setup` restores that geometry at Line 203 of `src/launcher/src/mainDialog.cpp`. Both startup paths then call `showMaximized()`, which overrides the restored normal state. Qt documents that this call displays the widget maximized. ([doc.qt.io](https://doc.qt.io/qt-6.8/qwidget.html)) Use `w.show()` in both paths so startup preserves the saved window state. Also applies to: 46-46 <!-- cr-comment:v1:a376097ffd1198f5749bd5b6 --> </dd> </dl> </blockquote></details> <details> <summary>src/launcher/styles/launcher.qss: 1</summary><blockquote> <dl> <dd> <br> `1-1`: **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/amber-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minor** · **Functional Correctness** · **Quick win** **Use QSS block comments for the header.** Qt 6.8 recognizes `/* ... */` comments, but tokenizes `//` as slashes. The first slash stops parsing before any style rule loads. This disables the entire application stylesheet, including the existing toolbar and editor styles. Replace all three header comments with one block comment. ([raw.githubusercontent.com](https://raw.githubusercontent.com/qt/qtbase/v6.8.0/src/gui/text/qcssscanner.cpp)) <!-- cr-comment:v1:f0a21f40ebc89a038a2eaa7f --> </dd> </dl> </blockquote></details> <details> <summary>tests/stubImportBaseline.txt: 1</summary><blockquote> <dl> <dd> <br> `360-361`: **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/amber-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minor** · **Functional Correctness** · **Quick win** **Remove the implemented truncate imports from the baseline.** `src/libs/libKernel.cpp`, Lines 3189-3190, registers `VW3TVZiM4-E` as `KernelFtruncate` and `WlyEA-sLDf0` as `KernelTruncate`. Keeping these pairs in the unresolved baseline exempts both registrations from regression detection. If either registration disappears, `RunCoverage` still passes because `baseline.contains(key)` suppresses the gap. Remove these two entries so the test detects that regression. <!-- cr-comment:v1:2a7bfaa31727ccd6a6937e12 --> </dd> </dl> </blockquote></details> <details> <summary>src/loader/symbolDatabase.cpp: 1</summary><blockquote> <dl> <dd> <br> `91-91`: **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/amber-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minor** · **Functional Correctness** · **Quick win** **Restrict the match to the library field.** `NID[Other_v1][Net_v1.0][Func]` satisfies a lookup for library `Net`, although its library is `Other`. `GenerateName` permits this record because library and module are separate fields. The coverage test then counts an import under the wrong library as resolved. Match the library marker immediately after `prefix`, not anywhere in `symbol.name`. <!-- cr-comment:v1:5f5a1ae739594cb526386041 --> </dd> </dl> </blockquote></details> <details> <summary>docs/agc-nid-research.md: 2</summary><blockquote> <dl> <dd> <br> `148-149`: **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/amber-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minor** · **Functional Correctness** · **Quick win** **Correct the registration claim.** `src/libs/libAgcDriver.cpp` registers several listed NIDs under `Graphics5`, including `7Wa3aeJgeVU` and `DwICrVxerkY`. The scan therefore cannot show that none is registered under *any* guest-visible identity. State the specific PS5 identities that lack registrations instead. ([raw.githubusercontent.com](https://raw.githubusercontent.com/KytyPS5/KytyPS5/da94befdaf3550fe361b74b52f7d61e4bc4c69f1/src/libs/libAgcDriver.cpp)) <!-- cr-comment:v1:1fb765c643ca0a57d2b8987d --> --- `32-33`: **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/amber-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minor** · **Data Integrity & Integration** · **Quick win** **Do not describe the aliases as exact until their ABIs match.** A matching NID shows only that the symbol names match. It does not show that the argument types, buffer sizes, or command-buffer layouts match. The Kyty implementations in `src/libs/agc.cpp` take caller-supplied buffers and sizes, and some write packet words into those buffers. A mismatched guest signature could pass wrong sizes or layouts into these functions. The note should not present the alias as a safe, behavior-neutral fix until each guest signature is compared with the Kyty implementation. <details> <summary>📝 Suggested wording</summary> <dl> <dd> <br> ```diff -- Cheapest concrete unblock: re-register Kyty's six existing `Gen5` functions under the guest's - `Agc_v1][Agc_v1.1` identity — exact alias, no new behavior needed. +- Candidate unblock: re-register Kyty's six existing `Gen5` functions under the guest's + `Agc_v1][Agc_v1.1` identity. Matching NIDs do not establish ABI compatibility. Compare each + captured guest call signature and buffer layout with the Kyty implementation before treating + these as exact aliases. ``` </dd> </dl> </details> <!-- cr-comment:v1:6d353c239f14f9915961b885 --> </dd> </dl> </blockquote></details> </dd> </dl> </blockquote></details> <h6> <details> <summary><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/info.svg" width="12" height="12" align="absmiddle" alt=""></picture> Review info</summary> <dl> <dd> <br> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog.svg" width="16" height="16" align="absmiddle" alt=""></picture> Run configuration</summary> <dl> <dd> <br> - **Source mode**: Auto - **Repository**: [KytyPS5/KytyPS5](<https://github.com/KytyPS5/KytyPS5>) - **Branch**: [main](<https://github.com/KytyPS5/KytyPS5/tree/main>) - **File**: [.coderabbit.yaml](<https://github.com/KytyPS5/KytyPS5/blob/58ca8d1d7fd621196a60c0a2bda664f4672815d7/.coderabbit.yaml>) - **Commit**: [58ca8d1](<https://github.com/KytyPS5/KytyPS5/commit/58ca8d1d7fd621196a60c0a2bda664f4672815d7>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `24568a0d-d1a1-473e-8420-7beb1d8a21ef` </dd> </dl> </details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal.svg" width="16" height="16" align="absmiddle" alt=""></picture> Commits</summary> <dl> <dd> <br> Reviewing files that changed from the base of the PR and between 0aa25f98665982c2ae181d03b55bfb00eb9f6575 and da94befdaf3550fe361b74b52f7d61e4bc4c69f1. </dd> </dl> </details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner.svg" width="16" height="16" align="absmiddle" alt=""></picture> Files selected for processing: 63</summary> <dl> <dd> <br> * `CMakeLists.txt` * `README.md` * `docs/agc-nid-research.md` * `src/common/abi.h` * `src/common/platform/sysLinuxFileIO.cpp` * `src/common/platform/sysWindowsFileIO.cpp` * `src/graphics/host_gpu/graphicContext.h` * `src/graphics/host_gpu/renderer/cache/bufferCache.cpp` * `src/graphics/host_gpu/renderer/masterSemaphore.cpp` * `src/graphics/host_gpu/renderer/pipeline/descriptors.cpp` * `src/graphics/host_gpu/renderer/pipeline/descriptors.h` * `src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp` * `src/graphics/host_gpu/renderer/pipeline/pipelineCache.h` * `src/graphics/host_gpu/renderer/pipeline/shaders.cpp` * `src/graphics/host_gpu/renderer/render.h` * `src/graphics/host_gpu/renderer/renderContext.cpp` * `src/graphics/host_gpu/renderer/renderContext.h` * `src/graphics/host_gpu/renderer/renderDraw.cpp` * `src/graphics/presentation/systemOverlay.cpp` * `src/graphics/presentation/window/vulkanWindow.cpp` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterAlu.cpp` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterAluHelpers.cpp` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterInstructions.h` * `src/graphics/shader/recompiler/frontend/translate/Compare.cpp` * `src/graphics/shader/recompiler/frontend/translate/Translator.h` * `src/graphics/shader/recompiler/frontend/translate/Vector.cpp` * `src/graphics/shader/recompiler/ir/ResourceSnapshot.h` * `src/graphics/shader/recompiler/ir/ShaderIR.h` * `src/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cpp` * `src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp` * `src/graphics/shader/recompiler/ir/passes/SrtWalker.cpp` * `src/kernel/fileSystem.cpp` * `src/kernel/memory.cpp` * `src/kernel/semaphore.cpp` * `src/launcher/forms/configuration_list_widget.ui` * `src/launcher/forms/main_dialog.ui` * `src/launcher/include/bootSplash.h` * `src/launcher/include/mainDialog.h` * `src/launcher/src/bootSplash.cpp` * `src/launcher/src/launcherTheme.cpp` * `src/launcher/src/main.cpp` * `src/launcher/src/mainDialog.cpp` * `src/launcher/styles/launcher.qss` * `src/libs/dialog.cpp` * `src/libs/dialog.h` * `src/libs/libKernel.cpp` * `src/libs/libNet.cpp` * `src/libs/libSystemService.cpp` * `src/libs/libWebBrowserDialog.cpp` * `src/libs/network.cpp` * `src/libs/network.h` * `src/libs/systemService.h` * `src/loader/symbolDatabase.cpp` * `src/loader/symbolDatabase.h` * `tests/KernelFileSystemTests.cpp` * `tests/ResourceMaterializationTests.cpp` * `tests/ResourceTrackingTests.cpp` * `tests/ShaderRecompilerComputeTests.cpp` * `tests/StubImportCoverageTests.cpp` * `tests/VirtualMemoryAllocationTests.cpp` * `tests/WindowsFileReadTests.cpp` * `tests/shaderCfgTests.cpp` * `tests/stubImportBaseline.txt` </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. </dd> </dl> </details> </h6> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=bc7330aa-e97b-4183-9ea0-64c2d88bdba5 attempt=ec1319ca-3727-46c5-85ac-34adb4c65ca2 batch=1/1 -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-13 04:51 UTC · original · reviewed

Actionable comments posted: 1

Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between da94befdaf3550fe361b74b52f7d61e4bc4c69f1 and 1ebdce1dce.

Files selected for processing: 8

  • src/graphics/host_gpu/graphicContext.h
  • src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp
  • src/graphics/host_gpu/renderer/pipeline/pipelineCache.h
  • src/graphics/host_gpu/renderer/pipeline/pipelineSerialization.cpp
  • src/graphics/host_gpu/renderer/pipeline/shaders.cpp
  • src/graphics/host_gpu/renderer/renderDraw.cpp
  • src/graphics/presentation/window/vulkanWindow.cpp
  • tests/ShaderRecompilerComputeTests.cpp

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

**@⁠coderabbitai[bot]** on GitHub · 2026-11-13 04:51 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2213#pullrequestreview-5886317028) · **reviewed** <!-- coderabbit-ai-generated:v1 --> **Actionable comments posted: 1** <h6> <details> <summary><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/info.svg" width="12" height="12" align="absmiddle" alt=""></picture> Review info</summary> <dl> <dd> <br> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog.svg" width="16" height="16" align="absmiddle" alt=""></picture> Run configuration</summary> <dl> <dd> <br> - **Source mode**: Auto - **Repository**: [KytyPS5/KytyPS5](<https://github.com/KytyPS5/KytyPS5>) - **Branch**: [main](<https://github.com/KytyPS5/KytyPS5/tree/main>) - **File**: [.coderabbit.yaml](<https://github.com/KytyPS5/KytyPS5/blob/58ca8d1d7fd621196a60c0a2bda664f4672815d7/.coderabbit.yaml>) - **Commit**: [58ca8d1](<https://github.com/KytyPS5/KytyPS5/commit/58ca8d1d7fd621196a60c0a2bda664f4672815d7>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `98a8adf7-6055-4d6b-9b08-e1064a6ee389` </dd> </dl> </details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal.svg" width="16" height="16" align="absmiddle" alt=""></picture> Commits</summary> <dl> <dd> <br> Reviewing files that changed from the base of the PR and between da94befdaf3550fe361b74b52f7d61e4bc4c69f1 and 1ebdce1dce402dde033e4eb655d9d28e5964e1a2. </dd> </dl> </details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner.svg" width="16" height="16" align="absmiddle" alt=""></picture> Files selected for processing: 8</summary> <dl> <dd> <br> * `src/graphics/host_gpu/graphicContext.h` * `src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp` * `src/graphics/host_gpu/renderer/pipeline/pipelineCache.h` * `src/graphics/host_gpu/renderer/pipeline/pipelineSerialization.cpp` * `src/graphics/host_gpu/renderer/pipeline/shaders.cpp` * `src/graphics/host_gpu/renderer/renderDraw.cpp` * `src/graphics/presentation/window/vulkanWindow.cpp` * `tests/ShaderRecompilerComputeTests.cpp` </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review. </dd> </dl> </details> </h6> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=bff97ff9-13a6-4107-aad2-f284dd16836b attempt=d9359dd6-01c0-45f6-80c8-c4f9b50085e8 batch=1/1 -->
@ -23933,4 +23993,3 @@
VK_EXT_SHADER_IMAGE_ATOMIC_INT64_EXTENSION_NAME,
VK_EXT_ROBUSTNESS_2_EXTENSION_NAME,
VK_EXT_PIPELINE_ROBUSTNESS_EXTENSION_NAME,
VK_KHR_MAINTENANCE_8_EXTENSION_NAME,
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-13 04:51 UTC · original · edited 2026-11-13 20:49 UTC

Major · Functional Correctness · Quick win

Restore the required robustness extensions.

Both profiles still request robustness2.nullDescriptor. The strict profile also requests pipeline_robustness.pipelineRobustness. However, the extension list now reaches vkCreateDevice without either robustness extension. (raw.githubusercontent.com)

Device-level extension functionality requires extension enablement. VK_EXT_robustness2 is not core functionality, and pipeline robustness became core only in Vulkan 1.4. Removing these names therefore leaves null-descriptor use unsupported by the enabled extensions and breaks strict-profile robustness on Vulkan 1.3 devices. (docs.vulkan.org)

Restore VK_EXT_ROBUSTNESS_2_EXTENSION_NAME for both profiles. Enable VK_EXT_PIPELINE_ROBUSTNESS_EXTENSION_NAME when RequiresRobustAccess() is true unless the harness explicitly uses its core equivalent.

✅ Addressed in commits 9a9bfbe to ec55b70

**@⁠coderabbitai[bot]** on GitHub · 2026-11-13 04:51 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2213#discussion_r4559780153) · edited 2026-11-13 20:49 UTC <!-- coderabbit-ai-generated:v1 --> **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/major-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Major** · **Functional Correctness** · **Quick win** **Restore the required robustness extensions.** Both profiles still request `robustness2.nullDescriptor`. The strict profile also requests `pipeline_robustness.pipelineRobustness`. However, the extension list now reaches `vkCreateDevice` without either robustness extension. ([raw.githubusercontent.com](https://raw.githubusercontent.com/KytyPS5/KytyPS5/1ebdce1dce402dde033e4eb655d9d28e5964e1a2/tests/ShaderRecompilerComputeTests.cpp)) Device-level extension functionality requires extension enablement. `VK_EXT_robustness2` is not core functionality, and pipeline robustness became core only in Vulkan 1.4. Removing these names therefore leaves null-descriptor use unsupported by the enabled extensions and breaks strict-profile robustness on Vulkan 1.3 devices. ([docs.vulkan.org](https://docs.vulkan.org/spec/latest/chapters/fundamentals.html)) Restore `VK_EXT_ROBUSTNESS_2_EXTENSION_NAME` for both profiles. Enable `VK_EXT_PIPELINE_ROBUSTNESS_EXTENSION_NAME` when `RequiresRobustAccess()` is true unless the harness explicitly uses its core equivalent. <!-- fingerprinting:phantom:poseidon:wombat61 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:a554e1464b33685f060867c7 --> <!-- This is an auto-generated comment by CodeRabbit --> ✅ Addressed in commits 9a9bfbe to ec55b70
Author
Owner

@⁠theantipopau on GitHub · 2026-11-13 20:40 UTC · original

Status: rebased onto current main. Local --depth-feedback-static-only selector passes, and Windows/macOS/Linux CI is green. The PR is CLEAN/MERGEABLE. The fork account cannot merge it (GitHub rejects MergePullRequest for lack of permission), so a maintainer needs to merge.

**@⁠theantipopau** on GitHub · 2026-11-13 20:40 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2213#issuecomment-6864375476) Status: rebased onto current `main`. Local `--depth-feedback-static-only` selector passes, and Windows/macOS/Linux CI is green. The PR is CLEAN/MERGEABLE. The fork account cannot merge it (GitHub rejects `MergePullRequest` for lack of permission), so a maintainer needs to merge.

Pull request closed

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