shader: store 16-bit float components of formatted buffer stores like the hardware #1588

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

@⁠Nawid3333 on GitHub · 2026-10-17 08:47 UTC · original
Nawid3333:shader/packed-float-buffer-stores → main · +68 −9 · 3 files · 5 commits · closed without merging

Merged with main. Since 59d8256b main encodes the 11- and 10-bit float components of formatted buffer stores itself, so I dropped this PR's 11/10-bit encoder; it now only changes the 16-bit components.

These still go through PackHalf2x16, so the stored value depends on the host's driver: AMD's compiles it to a round-toward-zero pack (my comment in #1575). BufferStoreFormatXyzwFloat16ConvertsComponents expects the round-to-nearest word 0xc0003c04 for 0x3f807e63; on the RX 9070 XT and the Ryzen 7600X iGPU main stores 0xc0003c03, so the test fails there.

Change: the 16-bit branch of EncodeFormattedStoreComponent uses your EmitF32BitsToF16RtzBits (9f88043e, renamed in 59d8256b) for everything except NaNs. Native rgba16f stores on the RX 9070 XT (RDNA4) and the iGPU (RDNA2) keep a NaN's top 10 mantissa bits (1 if those are 0) and do not quiet signaling NaNs, while the helper sets the quiet bit, so NaNs get their own select.

Tests

  • New BufferStoreFormatXyzwFloat16RoundsTowardZero (BUFFER_STORE_FORMAT_XYZW) stores 32 inputs (zeros of both signs, rounding midpoints, the largest values and beyond, infinities, quiet and signaling NaNs, denormals) and expects the words native stores wrote on both GPUs.
  • BufferStoreFormatXyzwFloat16ConvertsComponents now expects 0xc0003c03, the word both GPUs store natively, and forbids PackHalf2x16 instead of requiring it. GpuSelectedFormattedRgba16Store (in CheckGpuSelectedFormattedRecordStore) stores the same input and now expects 0xc0003c03 too; it passes on both GPUs in wave32 and wave64.
  • Both tests pass on both GPUs. With the NaN select removed (your helper alone, a local mutant), the new test fails on both GPUs in exactly its two NaN words (0x7c6e comes out as 0x7e6e, 0x7c01 and 0xfc01 as 0x7e00 and 0xfe00).
  • A GLSL copy of this encoding against native rgba16f stores, for all 2^32 f32 inputs and their negations: 0 differences on both GPUs. A copy of your helper alone differs in exactly the 8,388,606 signaling NaNs.
  • RX 9070 XT, compared with main: all other entries of the compute suite keep their status, with native subgroups and with the harness forced to 32-wide subgroups (a local switch).
  • shader_cfg_tests (not run by CI): its formatted half-float store check required PackHalf2x16; it now requires its absence and the f16 infinity constant. The binary passes.
  • CI (build and tests on Windows, Linux and macOS) passes on ba079bbc.

If you'd like this done differently, tell me and I'll change it.

Written with Claude Code (AI): it wrote the change and ran the tests and measurements on my PC (drivers 26.10.1 and 25.10.42, Windows 11).

🤖 Generated with Claude Code

**@⁠Nawid3333** on GitHub · 2026-10-17 08:47 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1588) `Nawid3333:shader/packed-float-buffer-stores` → `main` · +68 −9 · 3 files · 5 commits · closed without merging Merged with main. Since 59d8256b main encodes the 11- and 10-bit float components of formatted buffer stores itself, so I dropped this PR's 11/10-bit encoder; it now only changes the 16-bit components. These still go through `PackHalf2x16`, so the stored value depends on the host's driver: AMD's compiles it to a round-toward-zero pack (my comment in #1575). `BufferStoreFormatXyzwFloat16ConvertsComponents` expects the round-to-nearest word `0xc0003c04` for `0x3f807e63`; on the RX 9070 XT and the Ryzen 7600X iGPU main stores `0xc0003c03`, so the test fails there. **Change:** the 16-bit branch of `EncodeFormattedStoreComponent` uses your `EmitF32BitsToF16RtzBits` (9f88043e, renamed in 59d8256b) for everything except NaNs. Native `rgba16f` stores on the RX 9070 XT (RDNA4) and the iGPU (RDNA2) keep a NaN's top 10 mantissa bits (1 if those are 0) and do not quiet signaling NaNs, while the helper sets the quiet bit, so NaNs get their own select. **Tests** - New `BufferStoreFormatXyzwFloat16RoundsTowardZero` (BUFFER_STORE_FORMAT_XYZW) stores 32 inputs (zeros of both signs, rounding midpoints, the largest values and beyond, infinities, quiet and signaling NaNs, denormals) and expects the words native stores wrote on both GPUs. - `BufferStoreFormatXyzwFloat16ConvertsComponents` now expects `0xc0003c03`, the word both GPUs store natively, and forbids `PackHalf2x16` instead of requiring it. `GpuSelectedFormattedRgba16Store` (in `CheckGpuSelectedFormattedRecordStore`) stores the same input and now expects `0xc0003c03` too; it passes on both GPUs in wave32 and wave64. - Both tests pass on both GPUs. With the NaN select removed (your helper alone, a local mutant), the new test fails on both GPUs in exactly its two NaN words (`0x7c6e` comes out as `0x7e6e`, `0x7c01` and `0xfc01` as `0x7e00` and `0xfe00`). - A GLSL copy of this encoding against native `rgba16f` stores, for all 2^32 f32 inputs and their negations: 0 differences on both GPUs. A copy of your helper alone differs in exactly the 8,388,606 signaling NaNs. - RX 9070 XT, compared with main: all other entries of the compute suite keep their status, with native subgroups and with the harness forced to 32-wide subgroups (a local switch). - `shader_cfg_tests` (not run by CI): its formatted half-float store check required `PackHalf2x16`; it now requires its absence and the f16 infinity constant. The binary passes. - CI (build and tests on Windows, Linux and macOS) passes on ba079bbc. If you'd like this done differently, tell me and I'll change it. Written with Claude Code (AI): it wrote the change and ran the tests and measurements on my PC (drivers 26.10.1 and 25.10.42, Windows 11). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Formatted stores in the 11_11_10 and 10_11_11 float formats wrote the low
bits of the f32 value, so 1.0 was stored as 0. Encode them as the hardware
does for native r11f_g11f_b10f stores on RDNA2 and RDNA4: round toward
zero, clamp finite values to the largest finite one, store negative values
as 0 and keep NaN.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Native 16-bit float buffer stores on RDNA2 and RDNA4 round toward zero, clamp finite values to the
largest finite one and keep NaN payloads, like the 11- and 10-bit float stores. Encode them with
the same integer encoder instead of PackHalf2x16, whose rounding depends on the host.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The 11- and 10-bit float store cases run with --buffer-format-store-only.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Main encodes 11/10-bit float stores itself since 59d8256b, so this drops the
PR's own encoder (EmitF32ToUFloatBits) and its 11/10-bit test. The 16-bit
float store now uses main's EmitF32BitsToF16RtzBits instead of PackHalf2x16,
whose rounding depends on the host, and keeps a NaN's payload unquieted as
native stores do.

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

@⁠coderabbitai[bot] on GitHub · 2026-10-17 08:52 UTC · original · edited 2026-10-28 20:50 UTC

Review in Change Stack →

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

Formatted 16-bit float stores now convert input bits directly. NaNs retain their sign and top payload bits, with a nonzero payload. Other values use the existing round-toward-zero conversion. Compute tests cover rounding boundaries, finite-value clamping, infinities, NaNs, and subnormals. SPIR-V tests now reject PackHalf2x16 and require %uint_31744.

Suggested reviewers: claxten10

Priority: Normal

Change: Bug fix

Merge Risk: Moderate · up to ba079

D16 formatted stores can write zero instead of float16 data, corrupting buffer or image contents. Fix this before merging.

Pre-merge checks: Passed 4 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Docstring Coverage Inconclusive Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title clearly and concisely describes the main change: making formatted buffer stores encode 16-bit float components like hardware.
Description check Passed The description is directly related to the changeset and explains the 16-bit encoding change, hardware behavior, test updates, and validation results.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 1 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-17 08:52 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1588#issuecomment-6231967122) · edited 2026-10-28 20:50 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/1588?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 --> <!-- 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: ba079bbc7034ce0734adea46ebc6715ccc3bad12 > > 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> Formatted 16-bit float stores now convert input bits directly. NaNs retain their sign and top payload bits, with a nonzero payload. Other values use the existing round-toward-zero conversion. Compute tests cover rounding boundaries, finite-value clamping, infinities, NaNs, and subnormals. SPIR-V tests now reject `PackHalf2x16` and require `%uint_31744`. **Suggested reviewers:** `claxten10` </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> <strong>Priority: <picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/priority-normal-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Normal</strong> <!-- change_assessment_commit:"ba079bbc7034ce0734adea46ebc6715ccc3bad12" --> **Change:** Bug fix <!-- 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-normal-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Moderate</strong> · up to <code>ba079</code></summary> <dl> <dd> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **🟡 Moderate** · up to `ba079` --> <!-- final_review_risk_coverage:{"sourceCommitId":"ba079bbc7034ce0734adea46ebc6715ccc3bad12","coveredCommitId":"ba079bbc7034ce0734adea46ebc6715ccc3bad12","kind":"reviewed"} --> D16 formatted stores can write zero instead of float16 data, corrupting buffer or image contents. Fix this before merging. <!-- 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 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… | 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 | | :------------------------ | :--------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------- | | 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. | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title clearly and concisely describes the main change: making formatted buffer stores encode 16-bit float components like hardware. | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description is directly related to the changeset and explains the 16-bit encoding change, hardware behavior, test updates, and validation results. | </dd> </dl> </details> <details> <summary><strong>Full details: Docstring Coverage</strong></summary> <dl> <dd> **Explanation** Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 1 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=1588)! 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 -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-17 12:51 UTC · original · edited 2026-10-17 13:09 UTC
On tests/ShaderRecompilerComputeTests.cpp line 48350 (outdated):

@@ -48239,6 +48345,9 @@ int main(int argc, char **argv) {
   if (argc == 2 && std::strcmp(argv[1], "--buffer-float16-store-only") == 0) {
     VulkanHarness vulkan;
     RunCase(&vulkan, BufferStoreFormatXyzwFloat16ConvertsComponents());
+    RunCase(&vulkan, BufferStoreFormatXyzwFloat16RoundsTowardZero());
+    RunCase(&vulkan, BufferStoreFormatXyzPackedFloat(false));
+    RunCase(&vulkan, BufferStoreFormatXyzPackedFloat(true));

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Keep the float16-only selector limited to float16 stores.

If a developer runs --buffer-float16-store-only, these lines also run the 11/11/10 and 10/11/11 packed-float cases. A packed-float failure can then interrupt a focused float16 check. Remove these two calls from this selector; the cases remain available through --buffer-format-store-only and MakeCases().

✅ Confirmed as addressed by @⁠Nawid3333

**@⁠coderabbitai[bot]** on GitHub · 2026-10-17 12:51 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1588#discussion_r4302714954) · edited 2026-10-17 13:09 UTC On `tests/ShaderRecompilerComputeTests.cpp` line 48350 (outdated): ```diff @@ -48239,6 +48345,9 @@ int main(int argc, char **argv) { if (argc == 2 && std::strcmp(argv[1], "--buffer-float16-store-only") == 0) { VulkanHarness vulkan; RunCase(&vulkan, BufferStoreFormatXyzwFloat16ConvertsComponents()); + RunCase(&vulkan, BufferStoreFormatXyzwFloat16RoundsTowardZero()); + RunCase(&vulkan, BufferStoreFormatXyzPackedFloat(false)); + RunCase(&vulkan, BufferStoreFormatXyzPackedFloat(true)); ``` **🎯 Functional Correctness** | **🟡 Minor** | **⚡ Quick win** **Keep the float16-only selector limited to float16 stores.** If a developer runs `--buffer-float16-store-only`, these lines also run the 11/11/10 and 10/11/11 packed-float cases. A packed-float failure can then interrupt a focused float16 check. Remove these two calls from this selector; the cases remain available through `--buffer-format-store-only` and `MakeCases()`. <!-- fingerprinting:phantom:poseidon:wombat --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:2a648717cc4e760c3c82010f --> <!-- This is an auto-generated reply by CodeRabbit --> ✅ Confirmed as addressed by @⁠Nawid3333 <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-17 12:51 UTC · original · reviewed

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8b4ba350-fd51-41e6-a971-f1e81a27fa66
📥 Commits

Reviewing files that changed from the base of the PR and between 10ce2846db6dc2c8412e442302f0d58181ac9e17 and b8d4b3c272.

📒 Files selected for processing: 4
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterInternal.h
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemoryHelpers.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; 5 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-17 12:51 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1588#pullrequestreview-5557834426) · **reviewed** **Actionable comments posted: 1** --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `8b4ba350-fd51-41e6-a971-f1e81a27fa66` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 10ce2846db6dc2c8412e442302f0d58181ac9e17 and b8d4b3c272dd0f89e1a34f3fbe28f81d20d23134. </details> <details> <summary>📒 Files selected for processing: 4</summary> * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterInternal.h` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemoryHelpers.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; 5 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=c47af8b2-8954-4750-bc0b-db4d852c7f0d attempt=21f95211-8fdf-4d83-bc19-8b2285a7c40f batch=1/1 -->
Author
Owner

@⁠Nawid3333 on GitHub · 2026-10-17 13:09 UTC · original
On tests/ShaderRecompilerComputeTests.cpp line 48350 (outdated):

@@ -48239,6 +48345,9 @@ int main(int argc, char **argv) {
   if (argc == 2 && std::strcmp(argv[1], "--buffer-float16-store-only") == 0) {
     VulkanHarness vulkan;
     RunCase(&vulkan, BufferStoreFormatXyzwFloat16ConvertsComponents());
+    RunCase(&vulkan, BufferStoreFormatXyzwFloat16RoundsTowardZero());
+    RunCase(&vulkan, BufferStoreFormatXyzPackedFloat(false));
+    RunCase(&vulkan, BufferStoreFormatXyzPackedFloat(true));

Agreed, done in e18c0e2f: --buffer-float16-store-only now runs only the two 16-bit float cases, and the 11- and 10-bit cases stay in --buffer-format-store-only.

**@⁠Nawid3333** on GitHub · 2026-10-17 13:09 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1588#discussion_r4302762892) On `tests/ShaderRecompilerComputeTests.cpp` line 48350 (outdated): ```diff @@ -48239,6 +48345,9 @@ int main(int argc, char **argv) { if (argc == 2 && std::strcmp(argv[1], "--buffer-float16-store-only") == 0) { VulkanHarness vulkan; RunCase(&vulkan, BufferStoreFormatXyzwFloat16ConvertsComponents()); + RunCase(&vulkan, BufferStoreFormatXyzwFloat16RoundsTowardZero()); + RunCase(&vulkan, BufferStoreFormatXyzPackedFloat(false)); + RunCase(&vulkan, BufferStoreFormatXyzPackedFloat(true)); ``` Agreed, done in e18c0e2f: `--buffer-float16-store-only` now runs only the two 16-bit float cases, and the 11- and 10-bit cases stay in `--buffer-format-store-only`.
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-17 13:09 UTC · original
On tests/ShaderRecompilerComputeTests.cpp line 48350 (outdated):

@@ -48239,6 +48345,9 @@ int main(int argc, char **argv) {
   if (argc == 2 && std::strcmp(argv[1], "--buffer-float16-store-only") == 0) {
     VulkanHarness vulkan;
     RunCase(&vulkan, BufferStoreFormatXyzwFloat16ConvertsComponents());
+    RunCase(&vulkan, BufferStoreFormatXyzwFloat16RoundsTowardZero());
+    RunCase(&vulkan, BufferStoreFormatXyzPackedFloat(false));
+    RunCase(&vulkan, BufferStoreFormatXyzPackedFloat(true));

@⁠Nawid3333 Thanks for the fix in e18c0e2f. The selector split addresses this finding.


If you found this review helpful, would you consider giving us a shout-out on X?

Thank you for using CodeRabbit!

✅ Review thread resolved.

You are interacting with an AI system.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-17 13:09 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1588#discussion_r4302764000) On `tests/ShaderRecompilerComputeTests.cpp` line 48350 (outdated): ```diff @@ -48239,6 +48345,9 @@ int main(int argc, char **argv) { if (argc == 2 && std::strcmp(argv[1], "--buffer-float16-store-only") == 0) { VulkanHarness vulkan; RunCase(&vulkan, BufferStoreFormatXyzwFloat16ConvertsComponents()); + RunCase(&vulkan, BufferStoreFormatXyzwFloat16RoundsTowardZero()); + RunCase(&vulkan, BufferStoreFormatXyzPackedFloat(false)); + RunCase(&vulkan, BufferStoreFormatXyzPackedFloat(true)); ``` @⁠Nawid3333 Thanks for the fix in `e18c0e2f`. The selector split addresses this finding. --- <!-- This is an auto-generated comment: tweet message by coderabbit.ai --> If you found this review helpful, would you consider giving us a shout-out on [X](https://twitter.com/intent/tweet?related=CodeRabbitAI&text=Keep%20%60--buffer-float16-store-only%60%20focused%20on%20float16%3B%20leave%20packed-float%20cases%20to%20the%20format%20selector.%20Cleaner%2C%20targeted%20tests%E2%80%94try%20%40coderabbitai%20%F0%9F%A7%AA&url=https%3A%2F%2Fgithub.com%2FKytyPS5%2FKytyPS5%2Fpull%2F1588%23discussion_r4302714954)? Thank you for using CodeRabbit! <!-- end of auto-generated comment: tweet message by coderabbit.ai --> ✅ Review thread resolved. _You are interacting with an AI system._ <!-- This is an auto-generated reply by CodeRabbit -->
Author
Owner

@⁠NeySlim on GitHub · 2026-10-17 23:09 UTC · original

RADV data point: Radeon 8060S (RDNA 3.5), Mesa 26.2.4, against 763d3be3. On main the 11- and 10-bit tests fail here too (26 words each). The 16-bit side differs from your GPUs: the inputs of BufferStoreFormatXyzwFloat16RoundsTowardZero and ConvertsComponents are literals, Mesa folds the PackHalf2x16 at compile time (no f16 convert in the ISA) and rounds to nearest, so on main ConvertsComponents passes with the old 0xc0003c04 and RoundsTowardZero gets e.g. 0x3c013c04 instead of 0x3c003c03. With the PR all four pass and the rest of the suite is unchanged.

**@⁠NeySlim** on GitHub · 2026-10-17 23:09 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1588#issuecomment-6242863841) RADV data point: Radeon 8060S (RDNA 3.5), Mesa 26.2.4, against 763d3be3. On main the 11- and 10-bit tests fail here too (26 words each). The 16-bit side differs from your GPUs: the inputs of `BufferStoreFormatXyzwFloat16RoundsTowardZero` and `ConvertsComponents` are literals, Mesa folds the `PackHalf2x16` at compile time (no f16 convert in the ISA) and rounds to nearest, so on main `ConvertsComponents` passes with the old `0xc0003c04` and `RoundsTowardZero` gets e.g. `0x3c013c04` instead of `0x3c003c03`. With the PR all four pass and the rest of the suite is unchanged.
Author
Owner

@⁠Nawid3333 on GitHub · 2026-10-18 04:15 UTC · original

I pushed one more commit, a test fix I had missed: GpuSelectedFormattedRgba16Store (in CheckGpuSelectedFormattedRecordStore, part of the full test run) stores the same input 0x3f807e63 as BufferStoreFormatXyzwFloat16ConvertsComponents and still expected the round-to-nearest half 0x3c04. With this PR the store rounds toward zero, so it now expects 0x3c03, like ConvertsComponents. My per-case test runner didn't cover that check before. On my RX 9070 XT and Ryzen 7600X iGPU it passes in both subgroup modes with this fix together with #1603; without #1603 it still fails there for a different reason, two words written past the end of the buffer, which #1603 fixes.

Written with Claude Code (AI): it found the missed expectation and ran the check on my PC; I read this comment before posting it.

**@⁠Nawid3333** on GitHub · 2026-10-18 04:15 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1588#issuecomment-6245555952) I pushed one more commit, a test fix I had missed: `GpuSelectedFormattedRgba16Store` (in `CheckGpuSelectedFormattedRecordStore`, part of the full test run) stores the same input `0x3f807e63` as `BufferStoreFormatXyzwFloat16ConvertsComponents` and still expected the round-to-nearest half `0x3c04`. With this PR the store rounds toward zero, so it now expects `0x3c03`, like `ConvertsComponents`. My per-case test runner didn't cover that check before. On my RX 9070 XT and Ryzen 7600X iGPU it passes in both subgroup modes with this fix together with #1603; without #1603 it still fails there for a different reason, two words written past the end of the buffer, which #1603 fixes. Written with Claude Code (AI): it found the missed expectation and ran the check on my PC; I read this comment before posting it.
Author
Owner

@⁠NeySlim on GitHub · 2026-10-18 10:53 UTC · original

Checked on RADV against 37df7f32. With this PR alone the four tests pass and GpuSelectedFormattedRgba16Store now gets the expected 0xc0003c03, but it still fails because the record right after the range is written (0xc0003c03 0x34003800 over the neighboring words), which is the #1595 issue. With #1603 merged on top it passes along with the four tests, and the rest of the suite matches #1603 alone.

**@⁠NeySlim** on GitHub · 2026-10-18 10:53 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1588#issuecomment-6248972542) Checked on RADV against 37df7f32. With this PR alone the four tests pass and `GpuSelectedFormattedRgba16Store` now gets the expected `0xc0003c03`, but it still fails because the record right after the range is written (`0xc0003c03 0x34003800` over the neighboring words), which is the #1595 issue. With #1603 merged on top it passes along with the four tests, and the rest of the suite matches #1603 alone.
@ -544,3 +556,4 @@
EmitF32BitsToF16RtzBits(state, data));
}
return data;
}
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-28 19:27 UTC · original · edited 2026-10-28 19:50 UTC

Major · Data Integrity & Integration · Quick win

Supported by static analysis

Script executed:

rg -n 'EncodeFormattedStoreComponent|EmitF32BitsToF16RtzBits|store_format_d16|StoreFormatD16' src/graphics/shader
git diff 6c0140186250a9ac7ed50786b2426271750a7a20 ba079bbc7034ce0734adea46ebc6715ccc3bad12 -- src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemoryHelpers.cpp

Repository: KytyPS5/KytyPS5

Length of output: 3823


Script executed:

set -o pipefail
printf '%s\n' '--- helper ---'
nl -ba src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemoryHelpers.cpp | sed -n '450,580p'
printf '%s\n' '--- buffer formatted-store caller ---'
nl -ba src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cpp | sed -n '790,880p'
printf '%s\n' '--- image formatted-store caller ---'
nl -ba src/graphics/shader/recompiler/backend/spirv/spirvEmitterImage.cpp | sed -n '620,690p'
printf '%s\n' '--- declarations and conversion helper ---'
nl -ba src/graphics/shader/recompiler/backend/spirv/spirvEmitterInternal.h | sed -n '450,550p'
nl -ba src/graphics/shader/recompiler/backend/spirv/spirvEmitterAlu.cpp | sed -n '60,105p'
printf '%s\n' '--- formatted-store and D16 references ---'
rg -n -i --glob '*.{cpp,h,hpp}' -e 'formatted.*store' -e 'store.*formatted' -e '\bD16\b' -e 'D16' src/graphics/shader/recompiler src/graphics/shader | sed -n '1,240p'

Repository: KytyPS5/KytyPS5

Length of output: 42883


Script executed:

set -o pipefail
nl -ba src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemoryHelpers.cpp | sed -n '450,580p'
nl -ba src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cpp | sed -n '790,880p'
nl -ba src/graphics/shader/recompiler/backend/spirv/spirvEmitterImage.cpp | sed -n '620,690p'
nl -ba src/graphics/shader/recompiler/backend/spirv/spirvEmitterInternal.h | sed -n '450,550p'
nl -ba src/graphics/shader/recompiler/backend/spirv/spirvEmitterAlu.cpp | sed -n '60,105p'
rg -n -i --glob '*.{cpp,h,hpp}' -e 'formatted.*store' -e 'store.*formatted' -e '\bD16\b' src/graphics/shader/recompiler src/graphics/shader | sed -n '1,240p'

Repository: KytyPS5/KytyPS5

Length of output: 32778


Script executed:

set -o pipefail
printf '%s\n' '--- formatted-store translation ---'
nl -ba src/graphics/shader/recompiler/frontend/translate/Memory.cpp | sed -n '150,270p'
nl -ba src/graphics/shader/recompiler/frontend/translate/Memory.cpp | sed -n '420,500p'
nl -ba src/graphics/shader/recompiler/frontend/translate/Memory.cpp | sed -n '1140,1195p'
printf '%s\n' '--- memory metadata definitions and decoder records ---'
rg -n -F -- 'struct MemoryInfo' src/graphics/shader/recompiler
rg -n -F -- 'data_bits' src/graphics/shader/recompiler/frontend/decode/MemoryOps.cpp src/graphics/shader/recompiler/frontend/decode/ImageOps.cpp src/graphics/shader/recompiler/ir/ShaderIR.h
nl -ba src/graphics/shader/recompiler/frontend/decode/MemoryOps.cpp | sed -n '1,95p'
nl -ba src/graphics/shader/recompiler/frontend/decode/ImageOps.cpp | sed -n '345,430p'
printf '%s\n' '--- formatted float format definitions/usages ---'
rg -n -i --glob '*.{cpp,h,hpp}' -e 'RGBA16Float' -e 'R16Float' -e '16.*Float' src/graphics/shader | sed -n '1,220p'

Repository: KytyPS5/KytyPS5

Length of output: 30963


Widen D16 float sources before encoding.

When a D16 formatted store uses a 16-bit float component, data contains raw f16 bits. The new 16-bit float branch runs before the existing f16-to-f32 conversion and passes those bits to EmitF32BitsToF16RtzBits, which interprets them as f32 bits. For example, f16 1.0 (0x3c00) is treated as an f32 bit pattern and can encode as zero instead of 0x3c00.

Suggested fix
 	if (bits == 16u && info.type == Format::ComponentType::Float) {
+		if (data_bits == 16u) {
+			data = EmitBitCastU32F32(state, EmitF16BitsToF32(state, data));
+		}
 		// Native 16-bit float stores round toward zero as EmitF32BitsToF16RtzBits does, but keep a
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.

		return is_signed ? Unary(state, spv::OpBitcast, TypeU32(state), value) : value;
	}
	if (bits == 16u && info.type == Format::ComponentType::Float) {
		if (data_bits == 16u) {
			data = EmitBitCastU32F32(state, EmitF16BitsToF32(state, data));
		}
		// Native 16-bit float stores round toward zero as EmitF32BitsToF16RtzBits does, but keep a
		// NaN's top mantissa bits (1 if those are 0) without quieting it.
		const auto magnitude = EmitAndConstant(state, data, 0x7fffffffu);
		const auto sign      = EmitAndConstant(
		    state, EmitBinaryU32(state, spv::OpShiftRightLogical, data, ConstantU32(state, 16u)),
		    0x8000u);
		const auto payload = EmitUMax32(state,
		                                EmitBinaryU32(state, spv::OpShiftRightLogical,
		                                              EmitAndConstant(state, data, 0x7fffffu),
		                                              ConstantU32(state, 13u)),
		                                ConstantU32(state, 1u));
		return Select(
		    state, TypeU32(state),
		    EmitCompareU32Constant(state, spv::OpUGreaterThan, magnitude, 0x7f800000u),
		    EmitOrU32(state, sign, EmitOrU32(state, payload, ConstantU32(state, 0x7c00u))),
		    EmitF32BitsToF16RtzBits(state, data));
	}
	return data;
}
**@⁠coderabbitai[bot]** on GitHub · 2026-10-28 19:27 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1588#discussion_r4405134685) · edited 2026-10-28 19:50 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** · **Data Integrity & Integration** · **Quick win** <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/review-details-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/review-details.svg" width="16" height="16" align="absmiddle" alt=""></picture> Supported by static analysis</summary> <dl> <dd> Script executed: ```bash rg -n 'EncodeFormattedStoreComponent|EmitF32BitsToF16RtzBits|store_format_d16|StoreFormatD16' src/graphics/shader git diff 6c0140186250a9ac7ed50786b2426271750a7a20 ba079bbc7034ce0734adea46ebc6715ccc3bad12 -- src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemoryHelpers.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 3823 --- Script executed: ```bash set -o pipefail printf '%s\n' '--- helper ---' nl -ba src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemoryHelpers.cpp | sed -n '450,580p' printf '%s\n' '--- buffer formatted-store caller ---' nl -ba src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cpp | sed -n '790,880p' printf '%s\n' '--- image formatted-store caller ---' nl -ba src/graphics/shader/recompiler/backend/spirv/spirvEmitterImage.cpp | sed -n '620,690p' printf '%s\n' '--- declarations and conversion helper ---' nl -ba src/graphics/shader/recompiler/backend/spirv/spirvEmitterInternal.h | sed -n '450,550p' nl -ba src/graphics/shader/recompiler/backend/spirv/spirvEmitterAlu.cpp | sed -n '60,105p' printf '%s\n' '--- formatted-store and D16 references ---' rg -n -i --glob '*.{cpp,h,hpp}' -e 'formatted.*store' -e 'store.*formatted' -e '\bD16\b' -e 'D16' src/graphics/shader/recompiler src/graphics/shader | sed -n '1,240p' ``` Repository: KytyPS5/KytyPS5 Length of output: 42883 --- Script executed: ```bash set -o pipefail nl -ba src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemoryHelpers.cpp | sed -n '450,580p' nl -ba src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cpp | sed -n '790,880p' nl -ba src/graphics/shader/recompiler/backend/spirv/spirvEmitterImage.cpp | sed -n '620,690p' nl -ba src/graphics/shader/recompiler/backend/spirv/spirvEmitterInternal.h | sed -n '450,550p' nl -ba src/graphics/shader/recompiler/backend/spirv/spirvEmitterAlu.cpp | sed -n '60,105p' rg -n -i --glob '*.{cpp,h,hpp}' -e 'formatted.*store' -e 'store.*formatted' -e '\bD16\b' src/graphics/shader/recompiler src/graphics/shader | sed -n '1,240p' ``` Repository: KytyPS5/KytyPS5 Length of output: 32778 --- Script executed: ```bash set -o pipefail printf '%s\n' '--- formatted-store translation ---' nl -ba src/graphics/shader/recompiler/frontend/translate/Memory.cpp | sed -n '150,270p' nl -ba src/graphics/shader/recompiler/frontend/translate/Memory.cpp | sed -n '420,500p' nl -ba src/graphics/shader/recompiler/frontend/translate/Memory.cpp | sed -n '1140,1195p' printf '%s\n' '--- memory metadata definitions and decoder records ---' rg -n -F -- 'struct MemoryInfo' src/graphics/shader/recompiler rg -n -F -- 'data_bits' src/graphics/shader/recompiler/frontend/decode/MemoryOps.cpp src/graphics/shader/recompiler/frontend/decode/ImageOps.cpp src/graphics/shader/recompiler/ir/ShaderIR.h nl -ba src/graphics/shader/recompiler/frontend/decode/MemoryOps.cpp | sed -n '1,95p' nl -ba src/graphics/shader/recompiler/frontend/decode/ImageOps.cpp | sed -n '345,430p' printf '%s\n' '--- formatted float format definitions/usages ---' rg -n -i --glob '*.{cpp,h,hpp}' -e 'RGBA16Float' -e 'R16Float' -e '16.*Float' src/graphics/shader | sed -n '1,220p' ``` Repository: KytyPS5/KytyPS5 Length of output: 30963 --- </dd> </dl> </details> **Widen D16 float sources before encoding.** When a D16 formatted store uses a 16-bit float component, `data` contains raw f16 bits. The new 16-bit float branch runs before the existing f16-to-f32 conversion and passes those bits to `EmitF32BitsToF16RtzBits`, which interprets them as f32 bits. For example, f16 `1.0` (`0x3c00`) is treated as an f32 bit pattern and can encode as zero instead of `0x3c00`. <details><summary>Suggested fix</summary> ```diff if (bits == 16u && info.type == Format::ComponentType::Float) { + if (data_bits == 16u) { + data = EmitBitCastU32F32(state, EmitF16BitsToF32(state, data)); + } // Native 16-bit float stores round toward zero as EmitF32BitsToF16RtzBits does, but keep a ``` </details> <!-- suggestion_start --> <details> <summary>Committable suggestion</summary> <dl> <dd> > <picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-warning.svg" width="20" height="20" align="absmiddle" alt=""></picture> **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 return is_signed ? Unary(state, spv::OpBitcast, TypeU32(state), value) : value; } if (bits == 16u && info.type == Format::ComponentType::Float) { if (data_bits == 16u) { data = EmitBitCastU32F32(state, EmitF16BitsToF32(state, data)); } // Native 16-bit float stores round toward zero as EmitF32BitsToF16RtzBits does, but keep a // NaN's top mantissa bits (1 if those are 0) without quieting it. const auto magnitude = EmitAndConstant(state, data, 0x7fffffffu); const auto sign = EmitAndConstant( state, EmitBinaryU32(state, spv::OpShiftRightLogical, data, ConstantU32(state, 16u)), 0x8000u); const auto payload = EmitUMax32(state, EmitBinaryU32(state, spv::OpShiftRightLogical, EmitAndConstant(state, data, 0x7fffffu), ConstantU32(state, 13u)), ConstantU32(state, 1u)); return Select( state, TypeU32(state), EmitCompareU32Constant(state, spv::OpUGreaterThan, magnitude, 0x7f800000u), EmitOrU32(state, sign, EmitOrU32(state, payload, ConstantU32(state, 0x7c00u))), EmitF32BitsToF16RtzBits(state, data)); } return data; } ``` </dd> </dl> </details> <!-- suggestion_end --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:f4853dc86457d2339cbc4ab6 --> <!-- This is an auto-generated reply by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-28 19:27 UTC · original · reviewed

Actionable comments posted: 1


Review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 6697e56443 and ba079bbc70.

Files selected for processing: 3
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemoryHelpers.cpp
  • tests/ShaderRecompilerComputeTests.cpp
  • tests/shaderCfgTests.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-10-28 19:27 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1588#pullrequestreview-5688498008) · **reviewed** <!-- coderabbit-ai-generated:v1 --> **Actionable comments posted: 1** --- <details> <summary><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/info.svg" width="16" height="16" align="absmiddle" alt=""></picture> Review info</summary> <dl> <dd> <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> - **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/6c0140186250a9ac7ed50786b2426271750a7a20/.coderabbit.yaml>) - **Commit**: [6c01401](<https://github.com/KytyPS5/KytyPS5/commit/6c0140186250a9ac7ed50786b2426271750a7a20>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `6ba9927f-433a-4ae9-bffc-42da8f518fb1` </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> Reviewing files that changed from the base of the PR and between 6697e5644371f9d9f7a697f69c61be4866bf0e47 and ba079bbc7034ce0734adea46ebc6715ccc3bad12. </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: 3</summary> <dl> <dd> * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemoryHelpers.cpp` * `tests/ShaderRecompilerComputeTests.cpp` * `tests/shaderCfgTests.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> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=3430a551-9ba1-4ae5-bf41-63c6fbea2046 attempt=70a6738d-85fd-4ad5-b88f-04470c57f5a2 batch=1/1 -->
@ -544,3 +556,4 @@
EmitF32BitsToF16RtzBits(state, data));
}
return data;
}
Author
Owner

@⁠Nawid3333 on GitHub · 2026-10-28 19:50 UTC · original

D16 data is widened before this branch: the if (data_bits == 16u) block above (line 495) turns 16-bit float data into f32 bits with EmitF16BitsToF32 (line 501), and the 16-bit float branch (line 540) comes after it, as the PackHalf2x16 branch did on main. So EmitF32BitsToF16RtzBits only ever gets f32 bits here. BufferStoreFormatD16XFloat16 and BufferStoreFormatD16HiXFloat16 store f16 -2.0 (0xc000) through this path and pass with this change on the RX 9070 XT, with native and with 32-wide subgroups.

**@⁠Nawid3333** on GitHub · 2026-10-28 19:50 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1588#discussion_r4405369581) D16 data is widened before this branch: the `if (data_bits == 16u)` block above (line 495) turns 16-bit float data into f32 bits with `EmitF16BitsToF32` (line 501), and the 16-bit float branch (line 540) comes after it, as the `PackHalf2x16` branch did on main. So `EmitF32BitsToF16RtzBits` only ever gets f32 bits here. `BufferStoreFormatD16XFloat16` and `BufferStoreFormatD16HiXFloat16` store f16 -2.0 (`0xc000`) through this path and pass with this change on the RX 9070 XT, with native and with 32-wide subgroups.
@ -544,3 +556,4 @@
EmitF32BitsToF16RtzBits(state, data));
}
return data;
}
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-28 19:51 UTC · original

@⁠Nawid3333 You are correct. I misread the branch order.

The supplied file confirms that if (data_bits == 16u) widens float data with EmitF16BitsToF32 before the 16-bit float encoding branch. Thus, EmitF32BitsToF16RtzBits receives f32 bits on this path.

My suggested change would convert the data a second time and is incorrect. I withdraw this finding. No code change is needed.


✏️ Learnings added
Learnt from: Nawid3333
Repo: KytyPS5/KytyPS5 PR: 1588
File: src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemoryHelpers.cpp:538-559
Timestamp: 2026-10-28T19:51:17.824Z
Learning: Within repository "KytyPS5/KytyPS5", only for files matching one of ["src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemoryHelpers.cpp"]: When reviewing D16 sources for 16-bit Float components in EncodeFormattedStoreComponent, trace the earlier data_bits == 16u block before alleging that the encoder receives raw f16 bits. That block widens float data with EmitF16BitsToF32 and converts it to f32 bits before the 16-bit Float encoding branch. Do not request another widening conversion unless the upstream conversion no longer covers this path. This rule does not apply to the earlier Float branch for component widths below 16 bits.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

✅ Review thread resolved.

You are interacting with an AI system.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-28 19:51 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1588#discussion_r4405374155) <!-- coderabbit-ai-generated:v1 --> @⁠Nawid3333 You are correct. I misread the branch order. The supplied file confirms that `if (data_bits == 16u)` widens float data with `EmitF16BitsToF32` before the 16-bit float encoding branch. Thus, `EmitF32BitsToF16RtzBits` receives f32 bits on this path. My suggested change would convert the data a second time and is incorrect. I withdraw this finding. No code change is needed. --- <details> <summary>✏️ Learnings added</summary> <dl> <dd> ``` Learnt from: Nawid3333 Repo: KytyPS5/KytyPS5 PR: 1588 File: src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemoryHelpers.cpp:538-559 Timestamp: 2026-10-28T19:51:17.824Z Learning: Within repository "KytyPS5/KytyPS5", only for files matching one of ["src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemoryHelpers.cpp"]: When reviewing D16 sources for 16-bit Float components in EncodeFormattedStoreComponent, trace the earlier data_bits == 16u block before alleging that the encoder receives raw f16 bits. That block widens float data with EmitF16BitsToF32 and converts it to f32 bits before the 16-bit Float encoding branch. Do not request another widening conversion unless the upstream conversion no longer covers this path. This rule does not apply to the earlier Float branch for component widths below 16 bits. ``` > Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure [review instructions](https://docs.coderabbit.ai/guides/review-instructions). You can manage existing learnings in the [app](https://app.coderabbit.ai/learnings). </dd> </dl> </details> <!-- <review_comment_withdrawn> --> ✅ Review thread resolved. <sub><i>You are interacting with an AI system.</i></sub> <!-- This is an auto-generated reply by CodeRabbit -->

Pull request closed

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