[draft] Atelier Yumia: boot fixes, audio output, tessellation and pipeline cache determinism #1744

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

@⁠MrBigBritches on GitHub · 2026-10-20 01:31 UTC · original
MrBigBritches:yumia-fixes → main · +682 −82 · 25 files · 8 commits · closed without merging

[draft]
Depends on PR #1683, #1684, #1687

Gets Atelier Yumia (PPSA25468) past the logos into gameplay, with audio, at ~60 fps once the pipeline cache is warm.

Shader decoding

  • Trap temporaries TTMP0–15 use operand codes 108–123 on GFX9+/RDNA (the GFX8 layout was 112–123); widen the trap register file to 16.
  • Decode S_SETREG_IMM32_B32 (SOPK 0x15) with its trailing literal; translate as a control no-op like S_SETREG_B32.
  • Unimplemented opcodes now report their full encoded length, so a trailing literal/DPP/SDWA dword is no longer decoded as the next instruction.
  • The unknown-encoding error includes the preceding words.

Audio (NGS2)

  • Custom mastering racks (0x4003) now reach the output. Ngs2SystemRender only mixed standard mastering voices, so games mastering through custom racks were silent. The setup (input channels) and output (output id) controls are now handled.
  • Side-chain inputs (input > 0) on custom racks are dropped from the audible mix with a one-time warning; the compressor modules they drive aren't emulated.
  • Looping waveform blocks and the loop-break control work on custom sampler racks.

Clipping

  • PA_CL_UCP_* writes are stored rather than rejected (PA_CL_CLIP_CNTL can be written after them).
  • ClipCheck accepts UCP_ENA planes backed by exported clip distances, only rejects modifiers that apply to the current state, and prints the clip state when it rejects.
  • Register-only user clip planes are emulated in the vertex shader as ClipDistance, with plane equations passed in push constants so plane changes don't recompile shaders.

Tessellation

  • Stride analysis follows more address arithmetic: mov, add, add3, mul_lo, subrev, exact or/and/shift forms, the patch ordinal via v_and_b32 0xff, and constants moved into SGPRs/VCC.
  • Forward branches are handled by merging register state at joins.
  • 64/96/128-bit and paired 64-bit LDS accesses count as LS outputs and HS control-point inputs.
  • DS per-patch reads are supported; the HS per-patch range (base and end) is reflected and shared so HS outputs and DS inputs match. The base is the lowest per-patch store, since per-patch data follows every patch's control points in the threadgroup.
  • Analysis results are cached per LS/HS code and control-point count instead of being recomputed on every draw.
  • The LS/HS program is dumped when analysis fails.

Pipeline cache and diagnostics

  • SPIR-V for wave64 dispatcher shaders on 32-wide hosts is now deterministic. High-half spill IDs were allocated in pointer-keyed map order, so these shaders produced different SPIR-V every run and never hit the driver cache (~150 s compiles each launch). With a warm cache they now load in under 10 ms.
  • Log a SPIR-V hash per shader and driver compile time per pipeline.
  • Checkpoint the driver pipeline cache every minute, since fatal errors skip the exit-time save.
  • A failed GPU wait reports the tick and the Vulkan result instead of a bare check.

Testing

  • Played Atelier Yumia on an RTX 5090 (Windows): logos, title and gameplay with audio. With a warm cache, frame time is a 17 ms median (33 ms at the 90th percentile) and no pipeline compile is over 1 s.
  • Determinism: across two runs, all 319 shaders produced identical SPIR-V; before the fix, 4 large compute shaders changed every run.
  • New and updated tests in tests/shaderCfgTests.cpp: trap temporaries at code 0x6f and a trailing-dword length test. The new decoder cases were run in a standalone harness; please run the full test suite in CI.

Known limitations

  • NGS2 effect modules (0x10, 0x13, 0x19, …) still pass audio through unprocessed, and side-chain ducking isn't applied.
  • User clip planes are not emulated for mesh or tessellation pipelines (they stop with "not implemented").
  • Tessellation analysis doesn't support loops (backward branches).
  • First-time compiles of the largest compute shaders still take ~2.5 minutes each on NVIDIA; afterwards they come from the cache.
  • An intermittent lost-GPU-device crash was seen once in three runs; the new GPU wait error will identify it if it recurs.
**@⁠MrBigBritches** on GitHub · 2026-10-20 01:31 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1744) `MrBigBritches:yumia-fixes` → `main` · +682 −82 · 25 files · 8 commits · closed without merging [draft] Depends on PR https://git.gtahub.st/github/KytyPS5--KytyPS5/pulls/1683, https://git.gtahub.st/github/KytyPS5--KytyPS5/pulls/1684, https://git.gtahub.st/github/KytyPS5--KytyPS5/pulls/1687 Gets Atelier Yumia (PPSA25468) past the logos into gameplay, with audio, at ~60 fps once the pipeline cache is warm. ### Shader decoding - Trap temporaries TTMP0–15 use operand codes 108–123 on GFX9+/RDNA (the GFX8 layout was 112–123); widen the trap register file to 16. - Decode `S_SETREG_IMM32_B32` (SOPK 0x15) with its trailing literal; translate as a control no-op like `S_SETREG_B32`. - Unimplemented opcodes now report their full encoded length, so a trailing literal/DPP/SDWA dword is no longer decoded as the next instruction. - The unknown-encoding error includes the preceding words. ### Audio (NGS2) - **Custom mastering racks (0x4003) now reach the output.** `Ngs2SystemRender` only mixed standard mastering voices, so games mastering through custom racks were silent. The setup (input channels) and output (output id) controls are now handled. - Side-chain inputs (input > 0) on custom racks are dropped from the audible mix with a one-time warning; the compressor modules they drive aren't emulated. - Looping waveform blocks and the loop-break control work on custom sampler racks. ### Clipping - `PA_CL_UCP_*` writes are stored rather than rejected (`PA_CL_CLIP_CNTL` can be written after them). - `ClipCheck` accepts `UCP_ENA` planes backed by exported clip distances, only rejects modifiers that apply to the current state, and prints the clip state when it rejects. - Register-only user clip planes are emulated in the vertex shader as `ClipDistance`, with plane equations passed in push constants so plane changes don't recompile shaders. ### Tessellation - Stride analysis follows more address arithmetic: `mov`, `add`, `add3`, `mul_lo`, `subrev`, exact `or`/`and`/shift forms, the patch ordinal via `v_and_b32 0xff`, and constants moved into SGPRs/VCC. - Forward branches are handled by merging register state at joins. - 64/96/128-bit and paired 64-bit LDS accesses count as LS outputs and HS control-point inputs. - DS per-patch reads are supported; the HS per-patch range (base and end) is reflected and shared so HS outputs and DS inputs match. The base is the lowest per-patch store, since per-patch data follows every patch's control points in the threadgroup. - Analysis results are cached per LS/HS code and control-point count instead of being recomputed on every draw. - The LS/HS program is dumped when analysis fails. ### Pipeline cache and diagnostics - **SPIR-V for wave64 dispatcher shaders on 32-wide hosts is now deterministic.** High-half spill IDs were allocated in pointer-keyed map order, so these shaders produced different SPIR-V every run and never hit the driver cache (~150 s compiles each launch). With a warm cache they now load in under 10 ms. - Log a SPIR-V hash per shader and driver compile time per pipeline. - Checkpoint the driver pipeline cache every minute, since fatal errors skip the exit-time save. - A failed GPU wait reports the tick and the Vulkan result instead of a bare check. ### Testing - Played Atelier Yumia on an RTX 5090 (Windows): logos, title and gameplay with audio. With a warm cache, frame time is a 17 ms median (33 ms at the 90th percentile) and no pipeline compile is over 1 s. - Determinism: across two runs, all 319 shaders produced identical SPIR-V; before the fix, 4 large compute shaders changed every run. - New and updated tests in `tests/shaderCfgTests.cpp`: trap temporaries at code 0x6f and a trailing-dword length test. The new decoder cases were run in a standalone harness; please run the full test suite in CI. ### Known limitations - NGS2 effect modules (`0x10`, `0x13`, `0x19`, …) still pass audio through unprocessed, and side-chain ducking isn't applied. - User clip planes are not emulated for mesh or tessellation pipelines (they stop with "not implemented"). - Tessellation analysis doesn't support loops (backward branches). - First-time compiles of the largest compute shaders still take ~2.5 minutes each on NVIDIA; afterwards they come from the cache. - An intermittent lost-GPU-device crash was seen once in three runs; the new GPU wait error will identify it if it recurs.
- Decode trap temporaries TTMP0-15 as scalar registers past the SGPR file
  instead of aborting. GFX9+/RDNA uses operand codes 108-123 (the GFX8
  layout used 112-123); Atelier Yumia reads TTMP3 (0x6f). The s105+1 VCC
  crossover for plain SGPRs is preserved.
- Decode S_SETREG_IMM32_B32 (SOPK 0x15) with its trailing literal and
  translate it as a control no-op like S_SETREG_B32.
- Give unimplemented opcodes their full encoded length so a trailing
  literal, DPP or SDWA dword is not decoded as the next instruction.
- Include the preceding words in the unknown-encoding error.
- Add trap temporary and trailing-dword length tests.

Trap temporary decoding is based on PR #1687.

Co-Authored-By: Matthew Hurley <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Inputs above 0 on custom racks feed extra buffers such as a
  side-chain compressor key; the modules are not emulated, so drop that
  signal from the audible mix with a one-time warning.
- Accept repeating waveform blocks and the loop-break control on custom
  sampler racks, which share the standard sampler block path.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Store PA_CL_UCP_* coefficients instead of rejecting non-zero writes;
  PA_CL_CLIP_CNTL may be written after them.
- Draw-time ClipCheck accepts UCP_ENA planes backed by exported clip
  distances, only rejects modifiers that apply to the current state, and
  prints the clip state when it does reject.
- Emulate register-only planes in the vertex shader as ClipDistance
  computed from push data, so plane changes do not recompile shaders.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Follow more address arithmetic when reflecting LS/HS strides (mov,
  add, add3, mul_lo, subrev, and provably exact or/and/shift forms),
  including the patch ordinal taken with v_and_b32 0xff.
- Handle forward branches by merging register state at joins.
- Dump the LS/HS program, one instruction per line, when analysis fails.
- Reflect the HS per-patch output range and share it with the DS, which
  can now read per-patch data as a matching PatchInput interface.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Allocate the high-half dispatcher spill IDs in spill creation order
  instead of pointer-keyed map order. The SPIR-V of wave64 dispatcher
  shaders on 32-wide hosts differed between runs, so the driver pipeline
  cache never hit for them (~150 s compiles every launch).
- Log a SPIR-V hash per shader and driver compile times per pipeline.
- Checkpoint the driver pipeline cache every minute, since fatal errors
  skip the exit-time save.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Ngs2SystemRender only mixed voices on standard mastering racks into the
output buffers, so titles that master through custom racks (0x4003),
such as Atelier Yumia, produced silence.

- Handle the custom mastering setup (0x40030000: input channel count)
  and output (0x40030001: output id) controls, logging the values once.
- Mix custom mastering voices into the output buffers like standard
  mastering voices.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Per-patch outputs follow the control points of every patch in the
  threadgroup, so reflect the lowest per-patch store as patch_begin and
  use it as the shared HS/DS interface base instead of hs_stride *
  output_control_points (which produced ~2000-entry interfaces).
- Track constants moved into SGPRs/VCC so strides loaded with
  s_movk_i32 can be followed.
- Recognise 64/96/128-bit and paired 64-bit LDS stores and reads as LS
  outputs and HS control-point inputs.
- Dump the program when no per-control-point stride is found.
- Cache the analysis per LS/HS code and control point counts instead of
  decoding both programs on every tessellated draw.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The timeline semaphore wait aborted with a bare not-implemented check;
print the tick and the Vulkan result so device loss can be told apart
from other failures.

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

@⁠MrBigBritches on GitHub · 2026-10-20 01:33 UTC · original

#1627

**@⁠MrBigBritches** on GitHub · 2026-10-20 01:33 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1744#issuecomment-6281235356) https://git.gtahub.st/github/KytyPS5--KytyPS5/issues/1627
Author
Owner

@⁠theantipopau on GitHub · 2026-10-20 01:36 UTC · original

Huge result — logos to gameplay with audio at 60fps! Some coordination notes since this stacks on my PRs:

  • The TTMP hunks here (108–123 window, NumTrapRegs=16, ttmp disassembly) duplicate #1687 exactly, which is expected since you built on it. Cleanest path: land #1683/#1684/#1687 first, then rebase this to drop those hunks — it shrinks an already large review surface (+682) and avoids double-landing the same mapping.
  • Same for the base: main moved under this (VR #1726, the LDS sizing fix, and the #1741 test-link fix that un-breaks CI). A rebase past current main should turn the pending builds green.
  • Happy to review the rest in chunks; the natural splits look like (1) S_SETREG_IMM32 + error-length reporting, (2) NGS2 custom-mastering output, (3) clipping/UCP, (4) tessellation stride + branches, (5) cache determinism. Say the word on which is most load-bearing and I'll start there.
**@⁠theantipopau** on GitHub · 2026-10-20 01:36 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1744#issuecomment-6281277803) Huge result — logos to gameplay with audio at 60fps! Some coordination notes since this stacks on my PRs: - The TTMP hunks here (108–123 window, NumTrapRegs=16, ttmp disassembly) duplicate #1687 exactly, which is expected since you built on it. Cleanest path: land #1683/#1684/#1687 first, then rebase this to drop those hunks — it shrinks an already large review surface (+682) and avoids double-landing the same mapping. - Same for the base: main moved under this (VR #1726, the LDS sizing fix, and the #1741 test-link fix that un-breaks CI). A rebase past current main should turn the pending builds green. - Happy to review the rest in chunks; the natural splits look like (1) S_SETREG_IMM32 + error-length reporting, (2) NGS2 custom-mastering output, (3) clipping/UCP, (4) tessellation stride + branches, (5) cache determinism. Say the word on which is most load-bearing and I'll start there.
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-20 01:38 UTC · original

Review in Change Stack →

📝 Walkthrough

The changes add user clip-plane handling across guest register storage, graphics draw data, and SPIR-V output. Tessellation analysis and interfaces now track per-patch data. Shader decoding adds trap-temporary registers and an immediate register-setting opcode. Custom audio rack rendering and controls change. Renderer diagnostics, cache checkpoints, compilation logs, and spill allocation also change.

Suggested reviewers: nmzik, senaxx, shadowbeat070

Priority: ➖ Normal

Change: Bug fix

Merge Risk: 🟡 Moderate · up to b4f3d

The new NGS2 custom-rack support still aborts when a title connects a side-chain input. Custom mastering setup can also abort for valid rack options. Fix these before relying on the audio path, because they can stop the game's audio initialization or rendering. A narrower tessellation-analysis edge case can also reject valid shaders.

Pre-merge checks: Passed 4 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Docstring Coverage Inconclusive Docstring coverage is 15.79% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 57 functions across 23 files. (2 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly summarizes the main changes: Atelier Yumia boot fixes, audio output, tessellation support, and pipeline-cache determinism.
Description check Passed The description is directly related to the changeset and provides detailed coverage of shader decoding, audio, clipping, tessellation, diagnostics, testing, and limitations.
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: Docstring Coverage

Explanation

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

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

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

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-20 01:38 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1744#issuecomment-6281301738) <!-- 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/1744?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-in-coderabbit-ui-dark.svg?v=3"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3" alt="Review in Change Stack →" height="32"></picture></a> <!-- review_stack_entry_end --> <!-- walkthrough_start --> <details> <summary><strong>📝 Walkthrough</strong></summary> <dl> <dd> The changes add user clip-plane handling across guest register storage, graphics draw data, and SPIR-V output. Tessellation analysis and interfaces now track per-patch data. Shader decoding adds trap-temporary registers and an immediate register-setting opcode. Custom audio rack rendering and controls change. Renderer diagnostics, cache checkpoints, compilation logs, and spill allocation also change. **Suggested reviewers:** `nmzik`, `senaxx`, `shadowbeat070` </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ➖ Normal <!-- change_assessment_commit:"b4f3dc1ec81c260ce42752580c9fdd8060e816c1" --> **Change:** Bug fix <!-- change_assessment_end --> <details> <summary><strong>Merge Risk:</strong> <strong>🟡 Moderate</strong> · up to <code>b4f3d</code></summary> <dl> <dd> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **🟡 Moderate** · up to `b4f3d` --> <!-- final_review_risk_coverage:{"sourceCommitId":"b4f3dc1ec81c260ce42752580c9fdd8060e816c1","coveredCommitId":"b4f3dc1ec81c260ce42752580c9fdd8060e816c1","kind":"reviewed"} --> The new NGS2 custom-rack support still aborts when a title connects a side-chain input. Custom mastering setup can also abort for valid rack options. Fix these before relying on the audio path, because they can stop the game's audio initialization or rendering. A narrower tessellation-analysis edge case can also reject valid shaders. <!-- 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 · <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-inconclusive-14-v2.svg" width="14" height="14" align="middle" alt="Inconclusive" title="Inconclusive"></picture></sup> 1</strong></summary> <dl> <dd> <strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> Failed checks: 1 inconclusive</strong> | Check name | Status | Explanation | Resolution | | :---------------- | :--------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ![Inconclusive](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-inconclusive.svg) | Docstring coverage is 15.79% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 57 functions across 23 files. (2 skipped:… | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary><strong><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> Passed checks: 4 passed</strong></summary> <dl> <dd> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title clearly summarizes the main changes: Atelier Yumia boot fixes, audio output, tessellation support, and pipeline-cache determinism. | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description is directly related to the changeset and provides detailed coverage of shader decoding, audio, clipping, tessellation, diagnostics, testing, and limitations. | | 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. | </dd> </dl> </details> <details> <summary><strong>Full details: Docstring Coverage</strong></summary> <dl> <dd> **Explanation** Docstring coverage is 15.79% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 57 functions across 23 files. (2 skipped: 2 too large.) **Resolution** Write docstrings for the functions missing them to satisfy the coverage threshold. </dd> </dl> </details> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- autopilot:start --> - [ ] <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autofix</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts <!-- autopilot:end --> <!-- tips_start --> Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=1744)! 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> - [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> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
@ -88,0 +208,4 @@
}
if (!reachable) {
continue;
}
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-20 01:38 UTC · original

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Mark code after S_ENDPGM as unreachable before the forward-branch join.

The new reachability tracking sets reachable = false only after S_BRANCH. The analysis keeps reachable == true after S_ENDPGM. Assume a forward branch target follows a path that ends with S_ENDPGM. At that target, Line 177 merges the terminated fall-through state with the branch state. Line 178 then sets to Kind::Unknown every VGPR whose value differs between the two paths. The same rule applies to SGPR constants at Line 179. The terminated path cannot reach the join. If such a register forms a later HS/LS ring address, Line 228 gets a non-affine value. Line 230 then stops with "tessellation address is not affine", but the address is affine on every live path.

A typical trigger is a shader that ends one branch with an early s_endpgm and puts the other branch after it:

s_cbranch_scc1 L1
v_mov_b32 v2, 0x40
s_endpgm
L1:
v_mov_b32 v2, 0x80
...store using v2...

If IsDirectBranch already covers S_ENDPGM, this issue does not apply.

🐛 Proposed fix
--- "a/src/graphics/shader/recompiler/Tessellation.cpp"
+++ "b/src/graphics/shader/recompiler/Tessellation.cpp"
@@ -206,9 +206,14 @@
 			}
 			continue;
 		}
 		if (!reachable) {
 			continue;
 		}
+		if (inst.opcode == Opcode::S_ENDPGM) {
+			// Only a recorded forward-branch target can reach the code that follows.
+			reachable = false;
+			continue;
+		}
 		const bool local_store =
 		    inst.opcode == Opcode::DS_WRITE_B32 || inst.opcode == Opcode::DS_WRITE2_B32 ||
 		    inst.opcode == Opcode::DS_WRITE_B64 || inst.opcode == Opcode::DS_WRITE2_B64 ||
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

		if (!reachable) {
			continue;
		}
		if (inst.opcode == Opcode::S_ENDPGM) {
			// Only a recorded forward-branch target can reach the code that follows.
			reachable = false;
			continue;
		}
**@⁠coderabbitai[bot]** on GitHub · 2026-10-20 01:38 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1744#discussion_r4320624428) **🎯 Functional Correctness** | **🟡 Minor** | **⚡ Quick win** **Mark code after `S_ENDPGM` as unreachable before the forward-branch join.** The new reachability tracking sets `reachable = false` only after `S_BRANCH`. The analysis keeps `reachable == true` after `S_ENDPGM`. Assume a forward branch target follows a path that ends with `S_ENDPGM`. At that target, Line 177 merges the terminated fall-through state with the branch state. Line 178 then sets to `Kind::Unknown` every VGPR whose value differs between the two paths. The same rule applies to SGPR constants at Line 179. The terminated path cannot reach the join. If such a register forms a later HS/LS ring address, Line 228 gets a non-affine value. Line 230 then stops with "tessellation address is not affine", but the address is affine on every live path. A typical trigger is a shader that ends one branch with an early `s_endpgm` and puts the other branch after it: ``` s_cbranch_scc1 L1 v_mov_b32 v2, 0x40 s_endpgm L1: v_mov_b32 v2, 0x80 ...store using v2... ``` If `IsDirectBranch` already covers `S_ENDPGM`, this issue does not apply. <details> <summary>🐛 Proposed fix</summary> ```diff --- "a/src/graphics/shader/recompiler/Tessellation.cpp" +++ "b/src/graphics/shader/recompiler/Tessellation.cpp" @@ -206,9 +206,14 @@ } continue; } if (!reachable) { continue; } + if (inst.opcode == Opcode::S_ENDPGM) { + // Only a recorded forward-branch target can reach the code that follows. + reachable = false; + continue; + } const bool local_store = inst.opcode == Opcode::DS_WRITE_B32 || inst.opcode == Opcode::DS_WRITE2_B32 || inst.opcode == Opcode::DS_WRITE_B64 || inst.opcode == Opcode::DS_WRITE2_B64 || ``` </details> <!-- suggestion_start --> <details> <summary>📝 Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. ```suggestion if (!reachable) { continue; } if (inst.opcode == Opcode::S_ENDPGM) { // Only a recorded forward-branch target can reach the code that follows. reachable = false; continue; } ``` </details> <!-- suggestion_end --> <!-- fingerprinting:phantom:medusa:pangolin --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:05c87c24651d58bee6456a73 --> <!-- This is an auto-generated comment by CodeRabbit -->
@ -1782,0 +1797,4 @@
port.sidechain_warned = true;
}
continue;
}
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-20 01:38 UTC · original

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

The side-chain drop path cannot run. Every nonzero port.input still aborts.

Ngs2RackCreate calls Ngs2InitModules for every custom rack. Ngs2InitModules has the check EXIT_NOT_IMPLEMENTED(custom.num_buffers != 1) (Line 1195). So any custom rack that exists has num_buffers == 1. A rack with num_buffers > 1 aborts during creation.

Now take a destination port with port.input != 0. The check port.input >= custom.num_buffers is the same as port.input >= 1, which is always true. So EXIT_NOT_IMPLEMENTED fires every time. The warning and the continue never run. The comment on Lines 1786-1788 says side-chain inputs come from num_buffers > 1, and Ngs2InitModules rejects exactly that setup.

To fix this, use one of these options:

  • Relax the num_buffers != 1 check in Ngs2InitModules so it accepts extra buffers. Modules still need source_buffer_id/dest_buffer_id 0; Lines 1833-1834 already enforce that.
  • Validate port.input against a limit that the code does not force to 1.
🐛 Proposed fix (relax the creation check)
 static void Ngs2InitModules(Ngs2RackInternal& rack) {
 	if (!Ngs2RackIsCustom(rack.type)) {
 		return;
 	}
 	const auto& custom = rack.option.custom_sampler.custom_rack_option;
-	EXIT_NOT_IMPLEMENTED(custom.num_buffers != 1);
+	// Buffer 0 is the main signal; extra buffers (e.g. side-chain keys) are not emulated.
+	EXIT_NOT_IMPLEMENTED(custom.num_buffers == 0);
🧰 Tools
🪛 ast-grep (0.45.3)

[error] 1793-1796: Use of an unbounded buffer function that can overflow the destination; use a size-bounded equivalent (fgets, strncpy/strlcpy, strncat/strlcat, snprintf).
Context: fmt::sprintf(
"warning: NGS2 side-chain input %u of a custom rack is not emulated, "
"dropping it\n",
port.input)
Note: [CWE-120] Buffer Copy without Checking Size of Input ('Classic Buffer Overflow').

(dangerous-buffer-functions-cpp)

**@⁠coderabbitai[bot]** on GitHub · 2026-10-20 01:38 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1744#discussion_r4320624441) **🎯 Functional Correctness** | **🟠 Major** | **⚡ Quick win** **The side-chain drop path cannot run. Every nonzero `port.input` still aborts.** `Ngs2RackCreate` calls `Ngs2InitModules` for every custom rack. `Ngs2InitModules` has the check `EXIT_NOT_IMPLEMENTED(custom.num_buffers != 1)` (Line 1195). So any custom rack that exists has `num_buffers == 1`. A rack with `num_buffers > 1` aborts during creation. Now take a destination port with `port.input != 0`. The check `port.input >= custom.num_buffers` is the same as `port.input >= 1`, which is always true. So `EXIT_NOT_IMPLEMENTED` fires every time. The warning and the `continue` never run. The comment on Lines 1786-1788 says side-chain inputs come from `num_buffers > 1`, and `Ngs2InitModules` rejects exactly that setup. To fix this, use one of these options: - Relax the `num_buffers != 1` check in `Ngs2InitModules` so it accepts extra buffers. Modules still need `source_buffer_id`/`dest_buffer_id` 0; Lines 1833-1834 already enforce that. - Validate `port.input` against a limit that the code does not force to 1. <details> <summary>🐛 Proposed fix (relax the creation check)</summary> ```diff static void Ngs2InitModules(Ngs2RackInternal& rack) { if (!Ngs2RackIsCustom(rack.type)) { return; } const auto& custom = rack.option.custom_sampler.custom_rack_option; - EXIT_NOT_IMPLEMENTED(custom.num_buffers != 1); + // Buffer 0 is the main signal; extra buffers (e.g. side-chain keys) are not emulated. + EXIT_NOT_IMPLEMENTED(custom.num_buffers == 0); ``` </details> <details> <summary>🧰 Tools</summary> <details> <summary>🪛 ast-grep (0.45.3)</summary> [error] 1793-1796: Use of an unbounded buffer function that can overflow the destination; use a size-bounded equivalent (fgets, strncpy/strlcpy, strncat/strlcat, snprintf). Context: fmt::sprintf( "warning: NGS2 side-chain input %u of a custom rack is not emulated, " "dropping it\n", port.input) Note: [CWE-120] Buffer Copy without Checking Size of Input ('Classic Buffer Overflow'). (dangerous-buffer-functions-cpp) </details> </details> <!-- fingerprinting:phantom:medusa:pangolin --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:c59369cddebc2f97b0309a76 --> <!-- This is an auto-generated comment by CodeRabbit -->
@ -2488,0 +2513,4 @@
case 0:
EXIT_NOT_IMPLEMENTED(param->size < sizeof(Ngs2VoiceParamHeader) + 8u);
EXIT_NOT_IMPLEMENTED(values[0] == 0 ||
values[0] > voice->rack->option.common.max_voice_channels);
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-20 01:38 UTC · original

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Validate the channel count against custom_mastering.max_channels, not common.max_voice_channels.

Ngs2CustomMasteringRackOption has its own max_channels field. The standard submixer setup validates against option.submixer.max_channels (Line 2381). This code uses rack_option.max_voice_channels instead, which is a different field. A title can set max_channels correctly and leave max_voice_channels at 0. In that case every custom mastering setup call aborts at this check.

🐛 Proposed fix
--- "a/src/libs/ngs2.cpp"
+++ "b/src/libs/ngs2.cpp"
@@ -2512,8 +2512,8 @@
 				switch (param->id & 0xffffu) {
 					case 0:
 						EXIT_NOT_IMPLEMENTED(param->size < sizeof(Ngs2VoiceParamHeader) + 8u);
 						EXIT_NOT_IMPLEMENTED(values[0] == 0 ||
-						                     values[0] > voice->rack->option.common.max_voice_channels);
+						                     values[0] > voice->rack->option.custom_mastering.max_channels);
 						voice->channels = values[0];
 						LOGF("\t custom mastering setup: channels=%u flags=0x%08" PRIx32 "\n",
 						     values[0], values[1]);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

						EXIT_NOT_IMPLEMENTED(values[0] == 0 ||
						                     values[0] > voice->rack->option.custom_mastering.max_channels);
**@⁠coderabbitai[bot]** on GitHub · 2026-10-20 01:38 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1744#discussion_r4320624445) **🎯 Functional Correctness** | **🟡 Minor** | **⚡ Quick win** **Validate the channel count against `custom_mastering.max_channels`, not `common.max_voice_channels`.** `Ngs2CustomMasteringRackOption` has its own `max_channels` field. The standard submixer setup validates against `option.submixer.max_channels` (Line 2381). This code uses `rack_option.max_voice_channels` instead, which is a different field. A title can set `max_channels` correctly and leave `max_voice_channels` at 0. In that case every custom mastering setup call aborts at this check. <details> <summary>🐛 Proposed fix</summary> ```diff --- "a/src/libs/ngs2.cpp" +++ "b/src/libs/ngs2.cpp" @@ -2512,8 +2512,8 @@ switch (param->id & 0xffffu) { case 0: EXIT_NOT_IMPLEMENTED(param->size < sizeof(Ngs2VoiceParamHeader) + 8u); EXIT_NOT_IMPLEMENTED(values[0] == 0 || - values[0] > voice->rack->option.common.max_voice_channels); + values[0] > voice->rack->option.custom_mastering.max_channels); voice->channels = values[0]; LOGF("\t custom mastering setup: channels=%u flags=0x%08" PRIx32 "\n", values[0], values[1]); ``` </details> <!-- suggestion_start --> <details> <summary>📝 Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. ```suggestion EXIT_NOT_IMPLEMENTED(values[0] == 0 || values[0] > voice->rack->option.custom_mastering.max_channels); ``` </details> <!-- suggestion_end --> <!-- fingerprinting:phantom:medusa:pangolin --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:6c2f44ecec8d783b68c250cb --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-20 01:38 UTC · original · reviewed

Actionable comments posted: 3

🧹 Nitpick comments: 1
tests/shaderCfgTests.cpp: 1

2350-2351: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Make the TTMP3 result observable.

The shader does not use s2 after reading TTMP3. The decoded-dump checks can pass even if translation loses the TTMP3 value, and SPIR-V validation does not check that value. Store or export s2, then assert that the translated result retains the expected value.


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 38bbb2c1-dc9c-4655-afa3-b80a951b8ef9
📥 Commits

Reviewing files that changed from the base of the PR and between f186b35706 and b4f3dc1ec8.

📒 Files selected for processing: 25
  • src/graphics/guest_gpu/command_processor/pm4Handlers.cpp
  • src/graphics/guest_gpu/hardwareContext.h
  • src/graphics/host_gpu/renderer/debug.cpp
  • src/graphics/host_gpu/renderer/masterSemaphore.cpp
  • src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp
  • src/graphics/host_gpu/renderer/pipeline/shaders.cpp
  • src/graphics/host_gpu/renderer/renderDraw.cpp
  • src/graphics/shader/recompiler/Tessellation.cpp
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterFlow.cpp
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterInternal.h
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cpp
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterProgram.cpp
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterTessellation.cpp
  • src/graphics/shader/recompiler/frontend/decode/ScalarAluOps.cpp
  • src/graphics/shader/recompiler/frontend/decode/ShaderDecoder.cpp
  • src/graphics/shader/recompiler/frontend/decode/ShaderDecoder.h
  • src/graphics/shader/recompiler/frontend/translate/Scalar.cpp
  • src/graphics/shader/recompiler/frontend/translate/Translate.cpp
  • src/graphics/shader/recompiler/ir/Reg.h
  • src/graphics/shader/recompiler/ir/ShaderIR.h
  • src/graphics/shader/shader.cpp
  • src/graphics/shader/shader.h
  • src/libs/ngs2.cpp
  • tests/ShaderRecompilerComputeTests.cpp
  • tests/shaderCfgTests.cpp

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

**@⁠coderabbitai[bot]** on GitHub · 2026-10-20 01:38 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1744#pullrequestreview-5579805142) · **reviewed** **Actionable comments posted: 3** <details> <summary>🧹 Nitpick comments: 1</summary><blockquote> <details> <summary>tests/shaderCfgTests.cpp: 1</summary><blockquote> `2350-2351`: **🎯 Functional Correctness** | **🔵 Trivial** | **⚡ Quick win** **Make the TTMP3 result observable.** The shader does not use `s2` after reading TTMP3. The decoded-dump checks can pass even if translation loses the TTMP3 value, and SPIR-V validation does not check that value. Store or export `s2`, then assert that the translated result retains the expected value. <!-- cr-comment:v1:fc61d53e4a70bdabaa7b6b10 --> </blockquote></details> </blockquote></details> --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `38bbb2c1-dc9c-4655-afa3-b80a951b8ef9` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between f186b35706ddbc3faf5513f326e2335d224802f7 and b4f3dc1ec81c260ce42752580c9fdd8060e816c1. </details> <details> <summary>📒 Files selected for processing: 25</summary> * `src/graphics/guest_gpu/command_processor/pm4Handlers.cpp` * `src/graphics/guest_gpu/hardwareContext.h` * `src/graphics/host_gpu/renderer/debug.cpp` * `src/graphics/host_gpu/renderer/masterSemaphore.cpp` * `src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp` * `src/graphics/host_gpu/renderer/pipeline/shaders.cpp` * `src/graphics/host_gpu/renderer/renderDraw.cpp` * `src/graphics/shader/recompiler/Tessellation.cpp` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterFlow.cpp` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterInternal.h` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cpp` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterProgram.cpp` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterTessellation.cpp` * `src/graphics/shader/recompiler/frontend/decode/ScalarAluOps.cpp` * `src/graphics/shader/recompiler/frontend/decode/ShaderDecoder.cpp` * `src/graphics/shader/recompiler/frontend/decode/ShaderDecoder.h` * `src/graphics/shader/recompiler/frontend/translate/Scalar.cpp` * `src/graphics/shader/recompiler/frontend/translate/Translate.cpp` * `src/graphics/shader/recompiler/ir/Reg.h` * `src/graphics/shader/recompiler/ir/ShaderIR.h` * `src/graphics/shader/shader.cpp` * `src/graphics/shader/shader.h` * `src/libs/ngs2.cpp` * `tests/ShaderRecompilerComputeTests.cpp` * `tests/shaderCfgTests.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=0a2b3abd-f383-4c0e-8c13-12c6c8bc35d6 attempt=9e9aa18f-d239-4d81-959c-029feeecd5f2 batch=1/1 -->
Author
Owner

@⁠theantipopau on GitHub · 2026-10-20 01:49 UTC · original

Chunk 1 review (decode: S_SETREG_IMM32 + EncodedWordCount) — verified against the ISA layouts, looks right:

  • SOPK fields check out (SDST bits 22:16, OP bits 27:23, SIMM16 bits 15:0): 0x15 is the only 2-word SOPK, SIMM16 is the HWREG selector, trailing dword is the value. Zero-extending the selector (vs S_SETREG_B32's sign-extended imm) is arguably more correct for an unsigned field. dst=Null + control no-op translation matches S_SETREG_B32.
  • Length recovery covers SOP1/SOP2/SOPC literal, VOP1/VOPC/VOP2 literal + MADMK/MAK/FMAK immediates, and VOP3/VOP3P word1 sources at the right bit positions (8:0/17:9/26:18). The in-bounds guard plus only-ever-extend makes overcounting (the dangerous direction) require coincidental bit patterns on already-unknown opcodes — strictly better than the guaranteed cascade before.
  • One question: the comment claims DPP/SDWA trailing dwords, but I only see literal/MADMK evidence — do VOP-DPP and SDWA forms route through these families in a way this catches, or are those still cascade-prone? If the latter, worth a follow-up, not a blocker.
  • The ttmp/OperandToString hunks duplicate #1687 and should fall away on rebase.

I'll take chunk 2 (NGS2 custom mastering) next.

**@⁠theantipopau** on GitHub · 2026-10-20 01:49 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1744#issuecomment-6281439925) Chunk 1 review (decode: S_SETREG_IMM32 + EncodedWordCount) — verified against the ISA layouts, looks right: - SOPK fields check out (SDST bits 22:16, OP bits 27:23, SIMM16 bits 15:0): 0x15 is the only 2-word SOPK, SIMM16 is the HWREG selector, trailing dword is the value. Zero-extending the selector (vs S_SETREG_B32's sign-extended imm) is arguably more correct for an unsigned field. dst=Null + control no-op translation matches S_SETREG_B32. - Length recovery covers SOP1/SOP2/SOPC literal, VOP1/VOPC/VOP2 literal + MADMK/MAK/FMAK immediates, and VOP3/VOP3P word1 sources at the right bit positions (8:0/17:9/26:18). The in-bounds guard plus only-ever-extend makes overcounting (the dangerous direction) require coincidental bit patterns on already-unknown opcodes — strictly better than the guaranteed cascade before. - One question: the comment claims DPP/SDWA trailing dwords, but I only see literal/MADMK evidence — do VOP-DPP and SDWA forms route through these families in a way this catches, or are those still cascade-prone? If the latter, worth a follow-up, not a blocker. - The ttmp/OperandToString hunks duplicate #1687 and should fall away on rebase. I'll take chunk 2 (NGS2 custom mastering) next.
Author
Owner

@⁠theantipopau on GitHub · 2026-10-20 01:50 UTC · original

Chunk 2 review (NGS2 custom mastering) — the direction matches #1683/#1684's degrade-don't-abort philosophy and the headline fix is right (custom mastering voices now reach the mix). Two questions:

  1. Loop-break (control 4): the old gate aborted unless the rack was a Sampler, but the new code drops the type check entirely rather than widening it to CustomSampler — the comment says both sampler types share the queue, yet nothing enforces sampler-ness now. If a non-sampler rack ever sends control 4, we silently iterate its (likely empty) blocks. Suggest keeping an explicit gate (... && type != CustomSampler) so the fail-loud behavior survives for genuinely unexpected racks.
  2. Side-chain path reads voice->rack->option.custom_sampler.custom_rack_option before checking Ngs2RackIsCustom. If option is a union, that's the wrong member for non-custom racks (practically harmless since the EXIT follows immediately, but the read precedes the check). Consider checking the type first, then reading the option.

The rest reads clean: in-range side-chains warn-once-and-drop while out-of-range still aborts, 0x4003 setup/output mirrors standard mastering with channel-count validation, and unknown sub-controls warn-and-ignore.

**@⁠theantipopau** on GitHub · 2026-10-20 01:50 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1744#issuecomment-6281445388) Chunk 2 review (NGS2 custom mastering) — the direction matches #1683/#1684's degrade-don't-abort philosophy and the headline fix is right (custom mastering voices now reach the mix). Two questions: 1. Loop-break (control 4): the old gate aborted unless the rack was a Sampler, but the new code drops the type check entirely rather than widening it to CustomSampler — the comment says both sampler types share the queue, yet nothing enforces sampler-ness now. If a non-sampler rack ever sends control 4, we silently iterate its (likely empty) blocks. Suggest keeping an explicit gate (... && type != CustomSampler) so the fail-loud behavior survives for genuinely unexpected racks. 2. Side-chain path reads voice->rack->option.custom_sampler.custom_rack_option before checking Ngs2RackIsCustom. If option is a union, that's the wrong member for non-custom racks (practically harmless since the EXIT follows immediately, but the read precedes the check). Consider checking the type first, then reading the option. The rest reads clean: in-range side-chains warn-once-and-drop while out-of-range still aborts, 0x4003 setup/output mirrors standard mastering with channel-count validation, and unknown sub-controls warn-and-ignore.
Author
Owner

@⁠theantipopau on GitHub · 2026-10-20 01:51 UTC · original

Chunk 3 review (clipping/UCP) — this is well designed. Verified end to end: coefficients stored at write time (order-independent vs UCP_ENA, fixing the old abort-on-write); emulated mask excludes shader-exported distances and collapses under CLIP_DISABLE; ClipCheck now only aborts on genuinely unemulatable combos (exported-but-not-enabled distances, modifiers on enabled planes, kill/viewport-index exports); push layout reserves UserClipPlaneDword + 4*planes with upload and emitter iterating planes ascending so slots agree; the mask is in the static pipeline key while equations stay dynamic (no recompile on plane changes); ClipDistance budget guarded at 8 with user planes prioritized over the clipping-error guard. GetUserClipPlane is only reached with plane < 6 via the 0x3f-masked loops. No notes.

**@⁠theantipopau** on GitHub · 2026-10-20 01:51 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1744#issuecomment-6281454778) Chunk 3 review (clipping/UCP) — this is well designed. Verified end to end: coefficients stored at write time (order-independent vs UCP_ENA, fixing the old abort-on-write); emulated mask excludes shader-exported distances and collapses under CLIP_DISABLE; ClipCheck now only aborts on genuinely unemulatable combos (exported-but-not-enabled distances, modifiers on enabled planes, kill/viewport-index exports); push layout reserves UserClipPlaneDword + 4*planes with upload and emitter iterating planes ascending so slots agree; the mask is in the static pipeline key while equations stay dynamic (no recompile on plane changes); ClipDistance budget guarded at 8 with user planes prioritized over the clipping-error guard. GetUserClipPlane is only reached with plane < 6 via the 0x3f-masked loops. No notes.
Author
Owner

@⁠theantipopau on GitHub · 2026-10-20 01:51 UTC · original

Chunks 4–5 review (tessellation + diagnostics/misc) — done, and with that I've covered the whole PR:

Tessellation: sound over-approximation throughout. Backward branches fail loud (fixpoint needed — correct), forward joins merge-or-adopt with reachability, disjoint-or/and-masks/shifts all carry exactness side-conditions, scalar kill-set erases self+neighbor (conservative), 64-bit DS ops symmetric on reads/writes, constant-store patch bounds guarded against UINT32 overflow with the empty-set case pinned to [0,0). The VCC scalar keys (0x10000+) can't collide with SGPR numbers. No notes.

Misc: semaphore EXIT now names the tick + result (strictly better message, same abort); 1-minute driver-cache checkpoints trade negligible I/O for surviving early crashes; always-on SPIR-V hash log is cheap (compile-time only) and directly supports the determinism goal; clip-plane push wiring is consistent end to end (mask in key, ascending plane order both sides, draw_data sized to DwordCount, mesh/tess explicitly punted).

The spill_order fix deserves emphasis: pointer-keyed unordered_map iteration made SPIR-V nondeterministic across runs, silently defeating driver pipeline caches — creation-order vector is the right fix.

Summary across all five chunks: chunk 1 verified, chunk 2 has two open questions (loop-break gate removal, union read before type check), chunks 3–5 clean. Biggest remaining item is structural: land #1683/#1684/#1687 first, then rebase this down from +682.

**@⁠theantipopau** on GitHub · 2026-10-20 01:51 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1744#issuecomment-6281465292) Chunks 4–5 review (tessellation + diagnostics/misc) — done, and with that I've covered the whole PR: Tessellation: sound over-approximation throughout. Backward branches fail loud (fixpoint needed — correct), forward joins merge-or-adopt with reachability, disjoint-or/and-masks/shifts all carry exactness side-conditions, scalar kill-set erases self+neighbor (conservative), 64-bit DS ops symmetric on reads/writes, constant-store patch bounds guarded against UINT32 overflow with the empty-set case pinned to [0,0). The VCC scalar keys (0x10000+) can't collide with SGPR numbers. No notes. Misc: semaphore EXIT now names the tick + result (strictly better message, same abort); 1-minute driver-cache checkpoints trade negligible I/O for surviving early crashes; always-on SPIR-V hash log is cheap (compile-time only) and directly supports the determinism goal; clip-plane push wiring is consistent end to end (mask in key, ascending plane order both sides, draw_data sized to DwordCount, mesh/tess explicitly punted). The spill_order fix deserves emphasis: pointer-keyed unordered_map iteration made SPIR-V nondeterministic across runs, silently defeating driver pipeline caches — creation-order vector is the right fix. Summary across all five chunks: chunk 1 verified, chunk 2 has two open questions (loop-break gate removal, union read before type check), chunks 3–5 clean. Biggest remaining item is structural: land #1683/#1684/#1687 first, then rebase this down from +682.
Author
Owner

@⁠Nmzik on GitHub · 2026-10-20 13:43 UTC · original

@⁠MrBigBritches 6b6274fa5a and others. Cherry picked. Sole credited to you Thanks!

**@⁠Nmzik** on GitHub · 2026-10-20 13:43 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1744#issuecomment-6292285497) @⁠MrBigBritches 6b6274fa5a0fcc082d7386c00b72934ba1d272c7 and others. Cherry picked. Sole credited to you Thanks!

Pull request closed

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