startup: src_scc is refused as an unknown scalar operand (1 of the remaining loading-screen shader refusals) #1813

Closed
opened 2026-11-24 19:14:06 +00:00 by triggered02 · 2 comments
triggered02 commented 2026-11-24 19:14:06 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-24T19:14:06Z.


Found in the refusal census (#870). 1 refused shader:

s_mul_i32 s28, 1.0, src_scc    -> REFUSED: operand 'src_scc'

Problem

Scalar source code 253 (src_scc) reads the SCC bit as the integer value 0 or 1. The translator refused it as an unknown operand, because Stage.u() only understood registers, inline constants and m0.

Fix

The generated shader already carries SCC as a bool scc (initialised, and updated by the scalar instructions that set it), so the source lowers to a conditional:

if tok == 'src_scc':
    # Source code 253 reads the SCC bit as the integer value 0 or 1 (used by e.g. s_mul_i32).
    return '(scc ? 1u : 0u)'

Measured on main at 813045b3:

form before after
s_mul_i32 s28, 1.0, src_scc refused s28 = 0x3f800000u * (scc ? 1u : 0u);
s_and_b32 s28, src_scc, s5 refused s28 = (scc ? 1u : 0u) & s5; scc = s28 != 0;

The census form multiplies the raw bits of the inline float 1.0 (0x3f800000) by the SCC bit — that is what the scalar integer multiply does, and it is why the constant is not emitted as 1u.

Test

startup_gfx2hlsl_src_scc builds SOP2 encodings from the checked-in decoder's layout ([31:30] == 0b10, opcode w0[29:23], destination w0[22:16], src1 w0[15:8], src0 w0[7:0]), decodes them, then translates. Five checks: the census form decodes and lowers, src_scc works in the first source position as well, a bitwise op still updates SCC, and a definition followed by a use emits both statements (scc = s28 != 0; then s29 = 0x3f800000u * (scc ? 1u : 0u);).

dev:     19/21 - the 2 failures are pre-existing (below)
release: startup_gfx2hlsl_src_scc Passed 0.14 s

Fail-first, both caught:

refuse src_scc again          -> Unsupported: operand 'src_scc'
lower it as the constant 0u   -> "a defined SCC is read back by the next instruction" FAIL

Pre-existing failures, not from this PR

startup_gfx2hlsl_mad_preserve_{warp,hardware} fail in this dev tree with Unknown GPU operation or invalid arguments: --raw-uav-dump-sm62 — the built offscreen_check is stale. Confirmed identical on origin/main with the same binary. A rebuild fixes it; this branch does not touch that tool.

What this does not establish

  • That the emitted HLSL compiles or computes the right value — the test compares text; DXC/WARP were not run here.
  • The s_cselect-style conditional uses of SCC (cond operand) are separate and already handled.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6589456613 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1820). Originally posted by [triggered02](https://github.com/triggered02) on 2026-11-24T19:14:06Z. --- Found in the refusal census (#870). **1** refused shader: ``` s_mul_i32 s28, 1.0, src_scc -> REFUSED: operand 'src_scc' ``` ## Problem Scalar source code 253 (`src_scc`) reads the SCC bit as the integer value 0 or 1. The translator refused it as an unknown operand, because `Stage.u()` only understood registers, inline constants and `m0`. ## Fix The generated shader already carries SCC as a `bool scc` (initialised, and updated by the scalar instructions that set it), so the source lowers to a conditional: ```python if tok == 'src_scc': # Source code 253 reads the SCC bit as the integer value 0 or 1 (used by e.g. s_mul_i32). return '(scc ? 1u : 0u)' ``` Measured on `main` at `813045b3`: | form | before | after | |---|---|---| | `s_mul_i32 s28, 1.0, src_scc` | refused | `s28 = 0x3f800000u * (scc ? 1u : 0u);` | | `s_and_b32 s28, src_scc, s5` | refused | `s28 = (scc ? 1u : 0u) & s5; scc = s28 != 0;` | The census form multiplies the **raw bits** of the inline float `1.0` (`0x3f800000`) by the SCC bit — that is what the scalar integer multiply does, and it is why the constant is not emitted as `1u`. ## Test `startup_gfx2hlsl_src_scc` builds SOP2 encodings from the checked-in decoder's layout (`[31:30] == 0b10`, opcode `w0[29:23]`, destination `w0[22:16]`, src1 `w0[15:8]`, src0 `w0[7:0]`), decodes them, then translates. Five checks: the census form decodes and lowers, `src_scc` works in the first source position as well, a bitwise op still updates SCC, and a definition followed by a use emits both statements (`scc = s28 != 0;` then `s29 = 0x3f800000u * (scc ? 1u : 0u);`). ``` dev: 19/21 - the 2 failures are pre-existing (below) release: startup_gfx2hlsl_src_scc Passed 0.14 s ``` Fail-first, both caught: ``` refuse src_scc again -> Unsupported: operand 'src_scc' lower it as the constant 0u -> "a defined SCC is read back by the next instruction" FAIL ``` ## Pre-existing failures, not from this PR `startup_gfx2hlsl_mad_preserve_{warp,hardware}` fail in this dev tree with `Unknown GPU operation or invalid arguments: --raw-uav-dump-sm62` — the built `offscreen_check` is stale. **Confirmed identical on `origin/main`** with the same binary. A rebuild fixes it; this branch does not touch that tool. ## What this does not establish - That the emitted HLSL compiles or computes the right value — the test compares text; DXC/WARP were not run here. - The `s_cselect`-style conditional uses of SCC (`cond` operand) are separate and already handled. AI-assisted (Claude Code).
ChazY11 commented 2026-11-24 21:01:22 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T20:24:06Z.


Taking this one, with the approach the issue describes: u('src_scc') → (scc ? 1u : 0u), the two census forms as the positive cases, and a device-free check that builds the SOP2 words from the decoder layout, decodes, and translates. If you already have a branch for it, say so and I will drop mine.

I will report the fail-first runs (guard removed, both forms) and the startup_gfx2hlsl_* neighbours in the PR.

  • AI-assisted.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7143490421 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1820#issuecomment-7143490421). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T20:24:06Z. --- Taking this one, with the approach the issue describes: `u('src_scc')` → `(scc ? 1u : 0u)`, the two census forms as the positive cases, and a device-free check that builds the SOP2 words from the decoder layout, decodes, and translates. If you already have a branch for it, say so and I will drop mine. I will report the fail-first runs (guard removed, both forms) and the `startup_gfx2hlsl_*` neighbours in the PR. - AI-assisted.
ChazY11 commented 2026-11-24 21:27:39 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T21:05:18Z.


Withdrawing my #1896: #1821 by @triggered02 implements the same Stage.u() branch and was opened 73 minutes earlier, so
theirs is the one to merge. I claimed the issue without noticing the branch already open on it — that was my miss.

The two things I verified and that #1821 should keep: the census form has to preserve the raw bits of the inline float
(s28 = 0x3f800000u * (scc ? 1u : 0u);), and returning 1u instead of (scc ? 1u : 0u) is the mutation a fixture on this
path should catch. Details are in the closed PR.

  • AI-assisted.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7144458429 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1820#issuecomment-7144458429). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T21:05:18Z. --- Withdrawing my #1896: #1821 by @triggered02 implements the same `Stage.u()` branch and was opened 73 minutes earlier, so theirs is the one to merge. I claimed the issue without noticing the branch already open on it — that was my miss. The two things I verified and that #1821 should keep: the census form has to preserve the raw bits of the inline float (`s28 = 0x3f800000u * (scc ? 1u : 0u);`), and returning `1u` instead of `(scc ? 1u : 0u)` is the mutation a fixture on this path should catch. Details are in the closed PR. - AI-assisted.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows#1813
No description provided.