startup-runtime: decode colour-blend registers into the desktop blend state #1209

Open
opened 2026-11-24 04:01:46 +00:00 by denn0x · 9 comments
denn0x commented 2026-11-24 04:01:46 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by denn0x on 2026-11-24T04:01:46Z.


Problem

The startup draw path creates every translated pipeline without a blend state. find_blend in src/startup_stubs/d3d12_draw.inl looks for a desktop D3D12_BLEND_DESC in the captured pipeline description, but the executable's pipeline state blocks hold console colour-blend register values instead. Nothing matches, bound.has_blend stays false, and the pipeline is opaque.

The visible effect is that alpha-tested or alpha-blended UI (A8 glyph quads, fades, translucent panels) draws as solid rectangles. See #1150.

Evidence

  • Locally, an env-gated fallback (X2W_DRAW_DEFAULT_BLEND: SRC_ALPHA / INV_SRC_ALPHA, ONE / INV_SRC_ALPHA for alpha, only when no blend was decoded) removes the solid boxes on the setup and legal pages.
  • This is a guess, not a decode. Additive, premultiplied or write-masked pipelines are wrong with it. It is not proposed for merge.

What is needed

  1. Find where the colour-blend control registers sit in the captured state block (per render target: colour source/destination factor, colour function, alpha source/destination factor, alpha function, separate-alpha and enable bits; plus the target write mask). The field layout is in AMD's public RDNA register documentation. The block layout around it is not documented and needs measuring.
  2. Translate factors and functions to D3D12_BLEND / D3D12_BLEND_OP, and the write mask to RenderTargetWriteMask.
  3. A source-built fixture: a captured block with known register values, converted to the expected D3D12_RENDER_TARGET_BLEND_DESC, with a negative control (blend disabled stays disabled).

Done when

  • UI pipelines get the blend state their registers describe, with no env fallback.
  • The fixture above passes in ctest.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6574318729 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1216). Originally posted by [denn0x](https://github.com/denn0x) on 2026-11-24T04:01:46Z. --- ## Problem The startup draw path creates every translated pipeline without a blend state. `find_blend` in `src/startup_stubs/d3d12_draw.inl` looks for a desktop `D3D12_BLEND_DESC` in the captured pipeline description, but the executable's pipeline state blocks hold console colour-blend register values instead. Nothing matches, `bound.has_blend` stays false, and the pipeline is opaque. The visible effect is that alpha-tested or alpha-blended UI (A8 glyph quads, fades, translucent panels) draws as solid rectangles. See #1150. ## Evidence - Locally, an env-gated fallback (`X2W_DRAW_DEFAULT_BLEND`: `SRC_ALPHA / INV_SRC_ALPHA`, `ONE / INV_SRC_ALPHA` for alpha, only when no blend was decoded) removes the solid boxes on the setup and legal pages. - This is a guess, not a decode. Additive, premultiplied or write-masked pipelines are wrong with it. It is not proposed for merge. ## What is needed 1. Find where the colour-blend control registers sit in the captured state block (per render target: colour source/destination factor, colour function, alpha source/destination factor, alpha function, separate-alpha and enable bits; plus the target write mask). The field layout is in AMD's public RDNA register documentation. The block layout around it is not documented and needs measuring. 2. Translate factors and functions to `D3D12_BLEND` / `D3D12_BLEND_OP`, and the write mask to `RenderTargetWriteMask`. 3. A source-built fixture: a captured block with known register values, converted to the expected `D3D12_RENDER_TARGET_BLEND_DESC`, with a negative control (blend disabled stays disabled). ## Done when - UI pipelines get the blend state their registers describe, with no env fallback. - The fixture above passes in `ctest`.
Jess-Doit commented 2026-11-24 06:50:18 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-24T04:17:50Z.


I'll take the register-decoding half of #1216 (steps 2 and 3). Step 1, finding the registers in the captured state block, needs captures I don't have and stays open.

  • Scope: a pure decoder in the stand-in from CB_BLENDn_CONTROL and the target's CB_TARGET_MASK nibble to D3D12_RENDER_TARGET_BLEND_DESC. The field layout and enums come from Mesa's src/amd/registers/gfx10.json (identical to gfx103.json for these registers).
    • All 21 BlendOp factors, mapped where D3D12 has an equivalent.
    • The five combine functions.
    • SEPARATE_ALPHA_BLEND = 0: alpha uses the colour factors, in their alpha form.
    • ENABLE, and the write mask.
  • Refused, with a named reason: forms with no D3D12 equivalent, such as the legacy BOTH_SRC_ALPHA / BOTH_INV_SRC_ALPHA and the constant-alpha factors on devices without alpha-factor support. The caller then keeps today's opaque pipeline instead of guessing.
  • Evidence: a source-built ctest with register words built from those field definitions:
    • every factor and function;
    • separate versus shared alpha;
    • write masks;
    • the #1150 straight-alpha and premultiplied UI forms.
    • Negative controls: blend disabled stays disabled, and a refused factor is reported, not mapped. A desktop draw on a GTX 1060 and WARP compares the decoded blend state with a CPU reference for the UI forms.
  • Not in this PR: wiring into find_blend. That needs step 1's block offsets, and I'll leave a hook for whoever measures them.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7121888930 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1216#issuecomment-7121888930). Originally posted by [Jess-Doit](https://github.com/Jess-Doit) on 2026-11-24T04:17:50Z. --- I'll take the register-decoding half of #1216 (steps 2 and 3). Step 1, finding the registers in the captured state block, needs captures I don't have and stays open. - **Scope:** a pure decoder in the stand-in from `CB_BLENDn_CONTROL` and the target's `CB_TARGET_MASK` nibble to `D3D12_RENDER_TARGET_BLEND_DESC`. The field layout and enums come from Mesa's `src/amd/registers/gfx10.json` (identical to `gfx103.json` for these registers). - All 21 `BlendOp` factors, mapped where D3D12 has an equivalent. - The five combine functions. - `SEPARATE_ALPHA_BLEND = 0`: alpha uses the colour factors, in their alpha form. - `ENABLE`, and the write mask. - **Refused, with a named reason:** forms with no D3D12 equivalent, such as the legacy `BOTH_SRC_ALPHA` / `BOTH_INV_SRC_ALPHA` and the constant-alpha factors on devices without alpha-factor support. The caller then keeps today's opaque pipeline instead of guessing. - **Evidence:** a source-built ctest with register words built from those field definitions: - every factor and function; - separate versus shared alpha; - write masks; - the #1150 straight-alpha and premultiplied UI forms. - Negative controls: blend disabled stays disabled, and a refused factor is reported, not mapped. A desktop draw on a GTX 1060 and WARP compares the decoded blend state with a CPU reference for the UI forms. - **Not in this PR:** wiring into `find_blend`. That needs step 1's block offsets, and I'll leave a hook for whoever measures them. AI-assisted (Claude Code).
denn0x commented 2026-11-24 06:50:18 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by denn0x on 2026-11-24T04:19:41Z.


Two more symptoms seen with the default-blend fallback and the descriptor fix in place (setup, legal and terms pages):

  • The focused list item has no label. It draws as an empty outlined box. The same item shows its text as soon as focus moves away. The focus style probably fills the box and draws the label in a contrasting colour (or inverted), and with a guessed blend the fill or the label is lost.
  • Checkbox ticks are never drawn. Ticking both boxes enables the Confirm button, so the input reaches the title, but neither box shows a tick, focused or not.

Both are hypotheses for this issue, not verified decodes. They are a good visual check once the blend registers are translated. If they persist after that, they get their own issue.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7121916765 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1216#issuecomment-7121916765). Originally posted by [denn0x](https://github.com/denn0x) on 2026-11-24T04:19:41Z. --- Two more symptoms seen with the default-blend fallback and the descriptor fix in place (setup, legal and terms pages): - **The focused list item has no label.** It draws as an empty outlined box. The same item shows its text as soon as focus moves away. The focus style probably fills the box and draws the label in a contrasting colour (or inverted), and with a guessed blend the fill or the label is lost. - **Checkbox ticks are never drawn.** Ticking both boxes enables the Confirm button, so the input reaches the title, but neither box shows a tick, focused or not. Both are hypotheses for this issue, not verified decodes. They are a good visual check once the blend registers are translated. If they persist after that, they get their own issue.
rasptum commented 2026-11-24 06:50:19 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by rasptum on 2026-11-24T04:25:44Z.


Step 1 measured, for @Jess-Doit's decoder half.

In pipelines created through slot 57, state block A holds the eight CB_BLENDn_CONTROL values at +0xD0, one dword per render target. The offset is the same in every logged block (127 logged blocks across several runs; the same pipelines repeat between runs).

Values seen:

Value Colour (src / dest / op) Alpha (src / dest / op)
0xE5040504 SRC_ALPHA / INV_SRC_ALPHA / ADD SRC_ALPHA / INV_SRC_ALPHA / ADD
0xE5010504 SRC_ALPHA / INV_SRC_ALPHA / ADD ONE / INV_SRC_ALPHA / ADD
0xE5010501 ONE / INV_SRC_ALPHA / ADD (premultiplied) ONE / INV_SRC_ALPHA / ADD
0xE1000104 SRC_ALPHA / ONE / ADD (additive) ZERO / ONE / ADD

All four have ENABLE and SEPARATE_ALPHA_BLEND set, and bit 31 set.

Locally, decoding just these (field layout as in the RDNA docs, unknown factors refused) removes the boxes; text renders correctly on Windows 10. I'm not pushing that decoder since you've claimed it. Happy to share it if useful.

Not located yet: CB_TARGET_MASK. I kept the write mask at ALL.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7122009849 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1216#issuecomment-7122009849). Originally posted by [rasptum](https://github.com/rasptum) on 2026-11-24T04:25:44Z. --- Step 1 measured, for @Jess-Doit's decoder half. In pipelines created through slot 57, **state block A holds the eight `CB_BLENDn_CONTROL` values at +0xD0**, one dword per render target. The offset is the same in every logged block (127 logged blocks across several runs; the same pipelines repeat between runs). Values seen: | Value | Colour (src / dest / op) | Alpha (src / dest / op) | |---|---|---| | `0xE5040504` | SRC_ALPHA / INV_SRC_ALPHA / ADD | SRC_ALPHA / INV_SRC_ALPHA / ADD | | `0xE5010504` | SRC_ALPHA / INV_SRC_ALPHA / ADD | ONE / INV_SRC_ALPHA / ADD | | `0xE5010501` | ONE / INV_SRC_ALPHA / ADD (premultiplied) | ONE / INV_SRC_ALPHA / ADD | | `0xE1000104` | SRC_ALPHA / ONE / ADD (additive) | ZERO / ONE / ADD | All four have ENABLE and SEPARATE_ALPHA_BLEND set, and bit 31 set. Locally, decoding just these (field layout as in the RDNA docs, unknown factors refused) removes the boxes; text renders correctly on Windows 10. I'm not pushing that decoder since you've claimed it. Happy to share it if useful. Not located yet: `CB_TARGET_MASK`. I kept the write mask at ALL. AI-assisted (Claude Code).
Jess-Doit commented 2026-11-24 06:50:20 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-24T04:37:07Z.


Thanks @rasptum, that's the missing piece. The decoder half is up as #1226, and I've added your four words to it in f7ec1944. The table checks their exact translation (bit 31, DISABLE_ROP3, doesn't change it). The draw blends each one on a GTX 1060 and in-box WARP and compares it with a CPU model of the register fields: all four match. A source/destination swap of each fails, as the negative control should.

Since you have the captures to verify it, would you take the wiring? It would sit in d3d12_draw.inl, stacked on #1226:

  • Read the eight dwords at state block A +0xD0.
  • Call x2w_cb_blend::decode(word, 0xF, alpha_factor_supported) per target, keeping the mask at ALL until CB_TARGET_MASK is found.
  • Fall back to today's opaque pipeline, and count the cause, when the decoder refuses a word.

You can check it visually with the focused-list-item and checkbox-tick cases @denn0x listed. I'm happy to review it.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7122184090 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1216#issuecomment-7122184090). Originally posted by [Jess-Doit](https://github.com/Jess-Doit) on 2026-11-24T04:37:07Z. --- Thanks @rasptum, that's the missing piece. The decoder half is up as #1226, and I've added your four words to it in `f7ec1944`. The table checks their exact translation (bit 31, `DISABLE_ROP3`, doesn't change it). The draw blends each one on a GTX 1060 and in-box WARP and compares it with a CPU model of the register fields: all four match. A source/destination swap of each fails, as the negative control should. Since you have the captures to verify it, would you take the wiring? It would sit in `d3d12_draw.inl`, stacked on #1226: - Read the eight dwords at state block A `+0xD0`. - Call `x2w_cb_blend::decode(word, 0xF, alpha_factor_supported)` per target, keeping the mask at ALL until `CB_TARGET_MASK` is found. - Fall back to today's opaque pipeline, and count the cause, when the decoder refuses a word. You can check it visually with the focused-list-item and checkbox-tick cases @denn0x listed. I'm happy to review it. AI-assisted (Claude Code).
R0Y00 commented 2026-11-24 06:50:21 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T04:39:02Z.


@Jess-Doit @rasptum, main development is running a local integration check with Jess's #1226 decoder and the four RT0 words rasptum measured at slot 57, state block A +0xD0. We'll compare the lowercase glyphs on the brightness setup page under the same input sequence, with and without that binding. The run uses the provisional write mask 0xF; CB_TARGET_MASK is still unlocated.

Jess owns the decoder and its GTX 1060/WARP controls. Rasptum's captured layout and the invitation above to wire the production path remain with that work. We'll return the local A/B result here so the production integration can use it once, with both contributions credited.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7122212887 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1216#issuecomment-7122212887). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T04:39:02Z. --- @Jess-Doit @rasptum, main development is running a local integration check with Jess's #1226 decoder and the four RT0 words rasptum measured at slot 57, state block A +0xD0. We'll compare the lowercase glyphs on the brightness setup page under the same input sequence, with and without that binding. The run uses the provisional write mask 0xF; CB_TARGET_MASK is still unlocated. Jess owns the decoder and its GTX 1060/WARP controls. Rasptum's captured layout and the invitation above to wire the production path remain with that work. We'll return the local A/B result here so the production integration can use it once, with both contributions credited.
R0Y00 commented 2026-11-24 06:50:21 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T04:44:42Z.


The decoder is on main via #1226. I reran the normal and swapped-factor draws before merging: 4/4 passed across WARP and an RTX 4060 Laptop in Windows Release. The draw-path hookup and write-mask verification remain open here. Please keep hookup results in this thread and include an independent, source-built draw that distinguishes blended output from the existing opaque path.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7122298214 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1216#issuecomment-7122298214). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T04:44:42Z. --- The decoder is on main via #1226. I reran the normal and swapped-factor draws before merging: 4/4 passed across WARP and an RTX 4060 Laptop in Windows Release. The draw-path hookup and write-mask verification remain open here. Please keep hookup results in this thread and include an independent, source-built draw that distinguishes blended output from the existing opaque path.
R0Y00 commented 2026-11-24 06:50:22 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T04:51:11Z.


RTX 4060 Laptop follow-up to the local integration check. Three swap-chain readbacks from the same run reached these checkpoints:

Capture Visible result
395, Brightness The instruction sentence is readable, including lowercase letters that appeared as boxes in the earlier local run.
423, Finish Setup Both text weights and the inline button prompts are legible.
439, Legal The focused Copyright label is readable.

The local startup build combines the refreshed glyph shader bindings and translation changes with the RT0 draw-path hookup to #1226, using the four measured control words at slot 57, block A +0xD0 and provisional mask 0xF. The earlier run lacked the live hookup. Several changes went into this comparison, so it does not isolate how much the blend change contributed. Checkbox ticks, the legal page’s right-hand body text and the actual CB_TARGET_MASK location still need verification. The post-setup navigation retest is tracked in #870.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7122396844 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1216#issuecomment-7122396844). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T04:51:11Z. --- RTX 4060 Laptop follow-up to the [local integration check](https://github.com/R0Y00/Xbox2Windows/issues/1216#issuecomment-7122212887). Three swap-chain readbacks from the same run reached these checkpoints: | Capture | Visible result | | --- | --- | | 395, Brightness | The instruction sentence is readable, including lowercase letters that appeared as boxes in the earlier local run. | | 423, Finish Setup | Both text weights and the inline button prompts are legible. | | 439, Legal | The focused **Copyright** label is readable. | The local startup build combines the refreshed glyph shader bindings and translation changes with the RT0 draw-path hookup to #1226, using the four measured control words at slot 57, block A +0xD0 and provisional mask 0xF. The earlier run lacked the live hookup. Several changes went into this comparison, so it does not isolate how much the blend change contributed. Checkbox ticks, the legal page’s right-hand body text and the actual `CB_TARGET_MASK` location still need verification. The post-setup navigation retest is tracked in [#870](https://github.com/R0Y00/Xbox2Windows/issues/870#issuecomment-7122326265).
R0Y00 commented 2026-11-24 10:02:38 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T09:07:55Z.


#1294 is on main at c4966c64. The synthetic slot 57 fixture passed in Release on RTX 4060 Laptop and WARP, with seven tests and no skips. It distinguishes the blended draw from the disabled and shifted-word controls and checks the fallback when a secondary target's blend word is refused. CB_TARGET_MASK is still a separate open part of this issue.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7126999453 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1216#issuecomment-7126999453). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T09:07:55Z. --- #1294 is on main at c4966c64. The synthetic slot 57 fixture passed in Release on RTX 4060 Laptop and WARP, with seven tests and no skips. It distinguishes the blended draw from the disabled and shifted-word controls and checks the fallback when a secondary target's blend word is refused. CB_TARGET_MASK is still a separate open part of this issue.
R0Y00 commented 2026-12-02 21:17:00 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-02T21:17:00Z.


The slot 57 register scan is now on main in #3889. The author’s three corpora all identify CB_COLOR_CONTROL at A+0x0D0 as the only offset that matches the tested fields, consistent with the earlier RT0 observation here. The scan still leaves CB_TARGET_MASK unresolved. I independently ran the synthetic corpus with the moved-word, constant-corpus and ambiguous-mask controls. To distinguish CB_TARGET_MASK from CB_SHADER_MASK in a follow-up, the useful evidence is a variant with secondary bound targets that the pixel shader does not export, along with the observed write masks.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7359057543 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1216#issuecomment-7359057543). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-02T21:17:00Z. --- The slot 57 register scan is now on `main` in #3889. The author’s three corpora all identify `CB_COLOR_CONTROL` at A+0x0D0 as the only offset that matches the tested fields, consistent with the earlier RT0 observation here. The scan still leaves `CB_TARGET_MASK` unresolved. I independently ran the synthetic corpus with the moved-word, constant-corpus and ambiguous-mask controls. To distinguish `CB_TARGET_MASK` from `CB_SHADER_MASK` in a follow-up, the useful evidence is a variant with secondary bound targets that the pixel shader does not export, along with the observed write masks.
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#1209
No description provided.