shader: move coordinates for runtime texel offsets of image samples (NHL 27, #1101) #1446

Closed
github-bot wants to merge 1 commit from gh-pr/1446/head into gh-pr/1446/base
Owner

@⁠overlordxrz-source on GitHub · 2026-10-12 08:52 UTC · original
overlordxrz-source:fix/runtime-texel-offsets → main · +187 −9 · 2 files · 1 commits · closed without merging

Stop: NHL 27 (PPSA34063) on the official e51de54 build crashes right after you pick teams for a quick game. fozter's log on #1101 ends with:

SPIR-V emission failed: hash=0x8ff7afec7c5ab786 stage=4 opcode=ImageSampleRaw reason=has a nonconstant sample texel offset
 in ...\src\graphics\shader\recompiler\backend\spirv\spirvEmitterProgram.cpp:587

Cause: 984cfcebd emits a ConstOffset when the offset DWORD of an IMAGE_SAMPLE*_O is constant in the active lanes. When it isn't constant, it calls ctx.Fail (spirvEmitterImage.cpp, ctx.Fail on the non-constant sample offset path), because Vulkan allows a non-constant Offset image operand only on gathers. The NHL 27 compute shader 0x8ff7afec7c5ab786 (3 blocks) has an offset like that, so the compute pipeline is never built. The log has no disassembly for it, so I can't tell which _O variant it uses, or whether the offset comes from a VGPR or an SGPR.

Change (spirvEmitterImage.cpp, sample path only):

  • Constant offsets work as before: ConstOffset through PackedOffset.
  • Runtime offsets go through the new OffsetSampleCoordinates. It no longer fails: for each spatial component it decodes the signed 6-bit offset at bits [5:0], [13:8] and [21:16] with OpBitFieldSExtract, then adds offset / size to the coordinate. The array layer isn't changed.
  • size comes from OpImageQuerySizeLod at the level the sample reads, rounded to the nearest level and clamped to [0, OpImageQueryLevels - 1]. That level is:
    • _L_O: the explicit LOD.
    • _LZ_O, and implicit samples outside pixel shaders, which this emitter already samples at LOD 0: level 0.
    • _D_O: 0.5 * log2(max(|ddx|², |ddy|²)), with the gradients scaled to texels of the base level.
    • Implicit samples in pixel shaders: OpImageQueryLod (unclamped .y) plus the instruction's bias.
  • Cube maps keep ignoring the offset, as before.
  • Gathers don't change. They already use a runtime Offset with ImageGatherExtended.

The coordinate-shift approach is TheCruZ's from #1220, credited with Co-authored-by. #1220 was written before 984cfcebd and now conflicts with main. This patch keeps main's ConstOffset/exec handling and adds only the runtime path.

Test: ImageSampleRuntimeOffsetsMoveCoordinates in shader_recompiler_compute_tests. It also runs with --image-sample-offset-only. It builds the offset from v0 (v_add_nc_u32 with a literal), so it isn't an IR constant, on a 16×16 image:

  • _LZ_O with (+3, +1)
  • _LZ_O with (-9, +8), outside the guaranteed ConstOffset range
  • _L_O with LOD 3 on a single-level image, which has to clamp to level 0
  • _D_O with one-texel gradients

It expects the four shifted texels, requires OpImageQuerySizeLod/OpImageQueryLevels/OpFDiv, and forbids ConstOffset.

Not verified:

  • I have no GPU here (aarch64 sandbox), so the new test hasn't been run. It compiles (-fsyntax-only, x86_64).
  • I haven't checked NHL 27 on hardware. I don't know if the game gets past team selection with this change. Another stop could follow right after.
  • This is a nearest-level approximation. With trilinear filtering, hardware applies the offset in each of the two levels it blends. Sampler min/max LOD clamps aren't applied to the level used for the size.

Checks:

  • spirvEmitterImage.cpp compiles with zig/clang x86_64-linux-gnu, -std=c++20 -Wall -Wextra: rc=0, 0 warnings.
  • tests/ShaderRecompilerComputeTests.cpp passes -fsyntax-only with 0 errors.
  • clang-format (src/.clang-format) on the changed lines: clean.
  • Applies cleanly to main dad900c (cherry-pick, no conflicts); spirvEmitterImage.cpp recompiled there rc=0 and the tests file passes -fsyntax-only.

Refs #1101 (NHL 27 stop after team selection). Follow-up to #1220 at TheCruZ's request (he asked for it on #1220 and will close #1220 once this is up).

AI-assisted: yes (investigation, code and description; I reviewed it. The coordinate-shift approach is from TheCruZ's #1220).

**@⁠overlordxrz-source** on GitHub · 2026-10-12 08:52 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1446) `overlordxrz-source:fix/runtime-texel-offsets` → `main` · +187 −9 · 2 files · 1 commits · closed without merging **Stop:** NHL 27 (PPSA34063) on the official e51de54 build crashes right after you pick teams for a quick game. fozter's log on #1101 ends with: ``` SPIR-V emission failed: hash=0x8ff7afec7c5ab786 stage=4 opcode=ImageSampleRaw reason=has a nonconstant sample texel offset in ...\src\graphics\shader\recompiler\backend\spirv\spirvEmitterProgram.cpp:587 ``` **Cause:** 984cfcebd emits a `ConstOffset` when the offset DWORD of an `IMAGE_SAMPLE*_O` is constant in the active lanes. When it isn't constant, it calls `ctx.Fail` (spirvEmitterImage.cpp, `ctx.Fail` on the non-constant sample offset path), because Vulkan allows a non-constant `Offset` image operand only on gathers. The NHL 27 compute shader `0x8ff7afec7c5ab786` (3 blocks) has an offset like that, so the compute pipeline is never built. The log has no disassembly for it, so I can't tell which `_O` variant it uses, or whether the offset comes from a VGPR or an SGPR. **Change** (spirvEmitterImage.cpp, sample path only): - Constant offsets work as before: `ConstOffset` through `PackedOffset`. - Runtime offsets go through the new `OffsetSampleCoordinates`. It no longer fails: for each spatial component it decodes the signed 6-bit offset at bits [5:0], [13:8] and [21:16] with `OpBitFieldSExtract`, then adds `offset / size` to the coordinate. The array layer isn't changed. - `size` comes from `OpImageQuerySizeLod` at the level the sample reads, rounded to the nearest level and clamped to `[0, OpImageQueryLevels - 1]`. That level is: - `_L_O`: the explicit LOD. - `_LZ_O`, and implicit samples outside pixel shaders, which this emitter already samples at LOD 0: level 0. - `_D_O`: `0.5 * log2(max(|ddx|², |ddy|²))`, with the gradients scaled to texels of the base level. - Implicit samples in pixel shaders: `OpImageQueryLod` (unclamped `.y`) plus the instruction's bias. - Cube maps keep ignoring the offset, as before. - Gathers don't change. They already use a runtime `Offset` with `ImageGatherExtended`. The coordinate-shift approach is TheCruZ's from #1220, credited with Co-authored-by. #1220 was written before 984cfcebd and now conflicts with main. This patch keeps main's `ConstOffset`/exec handling and adds only the runtime path. **Test:** `ImageSampleRuntimeOffsetsMoveCoordinates` in `shader_recompiler_compute_tests`. It also runs with `--image-sample-offset-only`. It builds the offset from `v0` (`v_add_nc_u32` with a literal), so it isn't an IR constant, on a 16×16 image: - `_LZ_O` with (+3, +1) - `_LZ_O` with (-9, +8), outside the guaranteed `ConstOffset` range - `_L_O` with LOD 3 on a single-level image, which has to clamp to level 0 - `_D_O` with one-texel gradients It expects the four shifted texels, requires `OpImageQuerySizeLod`/`OpImageQueryLevels`/`OpFDiv`, and forbids `ConstOffset`. **Not verified:** - I have no GPU here (aarch64 sandbox), so the new test hasn't been run. It compiles (`-fsyntax-only`, x86_64). - I haven't checked NHL 27 on hardware. I don't know if the game gets past team selection with this change. Another stop could follow right after. - This is a nearest-level approximation. With trilinear filtering, hardware applies the offset in each of the two levels it blends. Sampler min/max LOD clamps aren't applied to the level used for the size. **Checks:** - `spirvEmitterImage.cpp` compiles with zig/clang x86_64-linux-gnu, `-std=c++20 -Wall -Wextra`: rc=0, 0 warnings. - `tests/ShaderRecompilerComputeTests.cpp` passes `-fsyntax-only` with 0 errors. - clang-format (src/.clang-format) on the changed lines: clean. - Applies cleanly to main dad900c (cherry-pick, no conflicts); spirvEmitterImage.cpp recompiled there rc=0 and the tests file passes `-fsyntax-only`. Refs #1101 (NHL 27 stop after team selection). Follow-up to #1220 at TheCruZ's request (he asked for it on #1220 and will close #1220 once this is up). AI-assisted: yes (investigation, code and description; I reviewed it. The coordinate-shift approach is from TheCruZ's #1220).
Vulkan accepts a non-constant Offset image operand only on gathers, so
984cfcebd fails SPIR-V emission when the offset DWORD of an
IMAGE_SAMPLE*_O is not constant in the active lanes. NHL 27's compute
shader 0x8ff7afec7c5ab786 stops there (#1101).

Shift the coordinates by offset / size of the sampled level instead,
per spatial component, with the array layer untouched. The level is the
explicit LOD, the LOD of the gradients for derivative samples, or the
queried LOD plus bias for implicit samples in pixel shaders, rounded to
the nearest level and clamped to the view. Constant offsets keep the
ConstOffset path.

The coordinate shift follows TheCruZ's #1220.

Co-authored-by: TheCruZ <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:56:55 +00:00
github-bot closed this pull request 2026-11-26 09:56:55 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-12 08:57 UTC · original

Review in Change Stack →

📝 Walkthrough

Walkthrough

SPIR-V emission now adjusts non-cube image coordinates for runtime sample offsets, using the selected mip extent. It derives the mip from explicit LOD, gradients, or an implicit pixel-shader LOD query with sampler bias. Immediate offsets remain image operands, and cube candidates skip runtime adjustment. A compute test covers four sampling forms and checks the generated SPIR-V.

Suggested reviewers: nmzik, claxten10, popcoder565


Priority: ⬇️ Low

Change: Bug fix · Severity of issue fixed: Low

Merge Risk: 🔵 Low · up to 5b302

The change is mergeable with a follow-up test using distinct mip levels. The current test cannot catch incorrect offset scaling across levels.

Pre-merge checks | Passed 4 | Inconclusive 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage Inconclusive Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 1 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check Passed The description clearly explains the NHL 27 failure, the runtime-offset implementation, affected image-sample paths, limitations, and validation status.
Title check Passed The title clearly and concisely identifies the main change: moving coordinates for runtime texel offsets in image samples. The NHL 27 and issue references provide relevant context.
Linked Issues check Passed The PR addresses the active directly linked issue [#1220]. It preserves the existing ConstOffset path for constant offsets. It adds runtime coordinate shifts for non-constant IMAGE_SAMPLE*_O offse…
Out of Scope Changes check Passed The changed files are spirvEmitterImage.cpp and ShaderRecompilerComputeTests.cpp. The emitter changes implement runtime texel offsets from [#1220] and address the NHL 27 failure described in [#110…

Full details: Docstring Coverage

Explanation

Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 1 files. (1 skipped: 1 too large.)


  • 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-12 08:57 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1446#issuecomment-6121004806) <!-- 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/1446?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> ## Walkthrough SPIR-V emission now adjusts non-cube image coordinates for runtime sample offsets, using the selected mip extent. It derives the mip from explicit LOD, gradients, or an implicit pixel-shader LOD query with sampler bias. Immediate offsets remain image operands, and cube candidates skip runtime adjustment. A compute test covers four sampling forms and checks the generated SPIR-V. **Suggested reviewers:** `nmzik`, `claxten10`, `popcoder565` <hr> </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ⬇️ Low <!-- change_assessment_commit:"5b30248f5e708f00067a4cd75a71963969adc470" --> **Change:** Bug fix · **Severity of issue fixed:** Low <!-- change_assessment_end --> <!-- final_review_risk_start --> **Merge Risk:** **🔵 Low** · up to `5b302` <!-- final_review_risk_coverage:{"sourceCommitId":"5b30248f5e708f00067a4cd75a71963969adc470","coveredCommitId":"5b30248f5e708f00067a4cd75a71963969adc470","kind":"reviewed"} --> The change is mergeable with a follow-up test using distinct mip levels. The current test cannot catch incorrect offset scaling across levels. <!-- final_review_risk_end --> <!-- 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-v1.svg" width="14" height="17" 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-v1.svg" width="14" height="17" align="middle" alt="Inconclusive" title="Inconclusive"></picture></sup> 1</strong></summary> <dl> <dd> ### ❌ Failed checks (1 inconclusive) | Check name | Status | Explanation | Resolution | | :---------------- | :--------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ![Inconclusive](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-inconclusive.svg) | Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 1 files. (1 skipped: 1… | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary><strong>✅ Passed checks (4 passed)</strong></summary> <dl> <dd> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description clearly explains the NHL 27 failure, the runtime-offset implementation, affected image-sample paths, limitations, and validation status. | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title clearly and concisely identifies the main change: moving coordinates for runtime texel offsets in image samples. The NHL 27 and issue references provide relevant context. | | Linked Issues check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The PR addresses the active directly linked issue [`#1220`]. It preserves the existing `ConstOffset` path for constant offsets. It adds runtime coordinate shifts for non-constant `IMAGE_SAMPLE*_O` offse… | | Out of Scope Changes check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The changed files are `spirvEmitterImage.cpp` and `ShaderRecompilerComputeTests.cpp`. The emitter changes implement runtime texel offsets from [`#1220`] and address the NHL 27 failure described in [`#110`… | <hr> </dd> </dl> </details> <details> <summary><strong>Full details: Docstring Coverage</strong></summary> <dl> <dd> **Explanation** Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 1 files. (1 skipped: 1 too large.) </dd> </dl> </details> <hr> </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=1446)! 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) <hr> </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-12 08:57 UTC · original · reviewed

🧹 Nitpick comments (1)
tests/ShaderRecompilerComputeTests.cpp (1)

35225-35225: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use distinct mip levels in ImageSampleRuntimeOffsetsMoveCoordinates.

The fixture has only mip 0. Therefore, the LOD=3 and gradient samples cannot detect use of the wrong mip extent for offset scaling. Add a second mip with distinct texels, make the gradient sample select mip 1, and keep the out-of-range LOD as a separate clamp check. This is a test-coverage improvement, not a production defect.


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5d8cdb8d-e290-456b-8226-d548cbc6d0bb
📥 Commits

Reviewing files that changed from the base of the PR and between dad900c61d and 5b30248f5e.

📒 Files selected for processing (2)
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterImage.cpp
  • tests/ShaderRecompilerComputeTests.cpp

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

**@⁠coderabbitai[bot]** on GitHub · 2026-10-12 08:57 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1446#pullrequestreview-5488472898) · **reviewed** <details> <summary>🧹 Nitpick comments (1)</summary><blockquote> <details> <summary>tests/ShaderRecompilerComputeTests.cpp (1)</summary><blockquote> `35225-35225`: **📐 Maintainability & Code Quality** | **🔵 Trivial** | **⚡ Quick win** **Use distinct mip levels in `ImageSampleRuntimeOffsetsMoveCoordinates`.** The fixture has only mip 0. Therefore, the LOD=3 and gradient samples cannot detect use of the wrong mip extent for offset scaling. Add a second mip with distinct texels, make the gradient sample select mip 1, and keep the out-of-range LOD as a separate clamp check. This is a test-coverage improvement, not a production defect. <!-- cr-comment:v1:62a25820800cd212069276bc --> </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**: `5d8cdb8d-e290-456b-8226-d548cbc6d0bb` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between dad900c61d6c7ff8aefc9e666ca7c3de4bbf4176 and 5b30248f5e708f00067a4cd75a71963969adc470. </details> <details> <summary>📒 Files selected for processing (2)</summary> * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterImage.cpp` * `tests/ShaderRecompilerComputeTests.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=fc5bfef3-c192-41ad-b138-532d0e7cfd59 attempt=b17ccfda-fde3-4aa7-976e-d7d4c0450884 batch=1/1 -->
Author
Owner

@⁠theantipopau on GitHub · 2026-10-12 10:22 UTC · original · approved these changes

Verified the change is confined to the sample path (EmitSample/OverflowSampleCoordinates in spirvEmitterImage.cpp):

  • Gather keeps the old contract: it still converts layout.offset through the standard PackedOffset into the OpImageGather Offset image operand at spirvEmitterImage.cpp:838, which is the one Vulkan place a non-constant offset is legal — no behavior change.
  • Atomics don't accept offsets.
  • Constant offsets keep the fast path: ConstOffset operand with a zero-extended three-bit offset per component, unchanged.
  • OverflowSampleCoordinates decodes the signed six-bit offset from RDNA2 low bits of each byte ([5:0]/[13:8]/[21:16]) with OpBitFieldSExtract — same bit layout as the constant path's PackedOffset decode at line 340 — then biases the coordinate by offset/extent of the mip-level dims. The queried level is: explicit LOD for _L_O, LOD 0 for _LZ_O/compute stages, the OTW computation from gradients for _D_O (0.5*log2(|ddx|^2+|ddy|^2)), and a pixel-shader OpImageQueryLod (plus bias) for implicit. It clamps into OpImageQueryLevels with OpUMin32(level, levels-1) and NMax(…, 0), and rdna2 folds ImageQueryLod on a multi-view-restricted range, which matches how the sampler wraps huge LODs.
  • Left unchanged: array layer is not offset, so 2DArray/cube unaffected dims behave exactly as the preexisting coordinate streams.
  • test.image_width/height 16×16 with every written pixel pattern matches the expected +3/+1, -9/+8, +1/+2 cases map to (7,10)/(3,11)/(9,4); the positive and negative assertions around OpImageQuerySizeLod/OpBitFieldSExtract keep this honest since this exact path also validates with a shader only the real Vulkan driver supports (SPIR-V validates, checked in CI on all three OSes including the Linux NVIDIA test).

One small note, not blocking: when a cube maps arrive at this path candidate.cube gets clamped instead of dropping the offset silently, so a fallback offset of 0/0/0 for cube is fine as the operand never existed.

This is the first convergence of IMAGE_SAMPLE*_O to spirvEmitterProgram.cpp:587 in BuildComputeRuntime. CI (5 checks green) means NHL 27's 0x8ff7afec7c5ab786 compute dispatch should now emit rather than fail.

**@⁠theantipopau** on GitHub · 2026-10-12 10:22 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1446#pullrequestreview-5489403105) · **approved these changes** Verified the change is confined to the sample path (`EmitSample`/`OverflowSampleCoordinates` in spirvEmitterImage.cpp): - Gather keeps the old contract: it still converts `layout.offset` through the standard `PackedOffset` into the `OpImageGather` `Offset` image operand at spirvEmitterImage.cpp:838, which is the one Vulkan place a non-constant offset is legal — no behavior change. - Atomics don't accept offsets. - Constant offsets keep the fast path: `ConstOffset` operand with a zero-extended three-bit offset per component, unchanged. - `OverflowSampleCoordinates` decodes the signed six-bit offset from RDNA2 low bits of each byte ([5:0]/[13:8]/[21:16]) with `OpBitFieldSExtract` — same bit layout as the constant path's `PackedOffset` decode at line 340 — then biases the coordinate by offset/extent of the mip-level dims. The queried level is: explicit LOD for `_L_O`, LOD 0 for `_LZ_O`/compute stages, the OTW computation from gradients for `_D_O` (`0.5*log2(|ddx|^2+|ddy|^2)`), and a pixel-shader `OpImageQueryLod` (plus bias) for implicit. It clamps into `OpImageQueryLevels` with `OpUMin32(level, levels-1)` and `NMax(…, 0)`, and rdna2 folds `ImageQueryLod` on a multi-view-restricted range, which matches how the sampler wraps huge LODs. - Left unchanged: array layer is not offset, so `2DArray`/cube unaffected dims behave exactly as the preexisting coordinate streams. - `test.image_width/height` 16×16 with every written pixel pattern matches the expected `+3/+1`, `-9/+8`, `+1/+2` cases map to (7,10)/(3,11)/(9,4); the positive and negative assertions around `OpImageQuerySizeLod`/`OpBitFieldSExtract` keep this honest since this exact path also validates with a shader only the real Vulkan driver supports (SPIR-V validates, checked in CI on all three OSes including the Linux NVIDIA test). One small note, not blocking: when a cube maps arrive at this path `candidate.cube` gets clamped instead of dropping the offset silently, so a fallback offset of 0/0/0 for cube is fine as the operand never existed. This is the first convergence of `IMAGE_SAMPLE*_O` to `spirvEmitterProgram.cpp:587` in `BuildComputeRuntime`. CI (5 checks green) means NHL 27's `0x8ff7afec7c5ab786` compute dispatch should now emit rather than fail.
Author
Owner

@⁠theantipopau on GitHub · 2026-10-12 10:22 UTC · original

Correction to my review above (two mistakes to avoid misleading you when merging):

  1. The helper is OffsetSampleCoordinates (I wrote "Overflow…").
  2. Cube behavior: the runtime-offset branch is gated on !candidate.cube, so cube samples with a runtime offset simply keep their coordinates untouched — identical to the old code path before the crash, not "clamped". That matches the "Cube maps take no texel offsets" comment you wrote.

Everything else stands: gathers/atomics untouched, constant offsets unchanged, level selection (_L_O explicit LOD / _LZ_O+compute LOD 0 / _D_O from gradients / implicit pixel-shader query+bias), NMax-to-zero for non-finite LODs, OpUMin32 against OpImageQueryLevels - 1, and the 16×16 execution test covering Signed/Unsigned + LOD past the last level.

**@⁠theantipopau** on GitHub · 2026-10-12 10:22 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1446#issuecomment-6122333929) Correction to my review above (two mistakes to avoid misleading you when merging): 1. The helper is `OffsetSampleCoordinates` (I wrote "Overflow…"). 2. Cube behavior: the runtime-offset branch is gated on `!candidate.cube`, so cube samples with a runtime offset simply keep their coordinates untouched — identical to the old code path before the crash, not "clamped". That matches the "Cube maps take no texel offsets" comment you wrote. Everything else stands: gathers/atomics untouched, constant offsets unchanged, level selection (`_L_O` explicit LOD / `_LZ_O`+compute LOD 0 / `_D_O` from gradients / implicit pixel-shader query+bias), NMax-to-zero for non-finite LODs, OpUMin32 against `OpImageQueryLevels - 1`, and the 16×16 execution test covering Signed/Unsigned + LOD past the last level.
Author
Owner

@⁠overlordxrz-source on GitHub · 2026-10-12 19:16 UTC · original

Game confirmation from fozter on #1101: with this PR's CI build, NHL 27 (#1101) no longer stops at SPIR-V emission failed: hash=0x8ff7afec7c5ab786 ... has a nonconstant sample texel offset (still present on main df5b9b9). It now reaches Start Game and stops later at an unrelated shader CFG issue (unsupported dynamic S_SETPC_B64, CS 0xad738baf31b6e28b), which I'll handle separately.

**@⁠overlordxrz-source** on GitHub · 2026-10-12 19:16 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1446#issuecomment-6130958669) Game confirmation from fozter on #1101: with this PR's CI build, NHL 27 (#1101) no longer stops at `SPIR-V emission failed: hash=0x8ff7afec7c5ab786 ... has a nonconstant sample texel offset` (still present on main df5b9b9). It now reaches Start Game and stops later at an unrelated shader CFG issue (`unsupported dynamic S_SETPC_B64`, CS 0xad738baf31b6e28b), which I'll handle separately.
Author
Owner

@⁠overlordxrz-source on GitHub · 2026-10-16 18:52 UTC · original

Closing: 460a196fc now emits dynamic sample texel offsets natively with maintenance8, which covers the NHL 27 shader this targeted.

**@⁠overlordxrz-source** on GitHub · 2026-10-16 18:52 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1446#issuecomment-6222512981) Closing: 460a196fc now emits dynamic sample texel offsets natively with maintenance8, which covers the NHL 27 shader this targeted.

Pull request closed

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