[PR #1671] [MERGED] d3d12_xs: blend state for slot 57 native pipelines from state blob A (RT-SLOT57-BLEND-STATE) #1687

Closed
opened 2026-11-26 20:22:06 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1671
Author: @OreoFR
Created: 11/25/2026
Status: ✅ Merged
Merged: 11/25/2026
Merged by: @aslan2142

Base: main ← Head: rt-slot57-blend-state


📝 Commits (6)

  • 70d3517 d3d12_xs: blend state for slot 57 native pipelines from state blob A (RT-SLOT57-BLEND-STATE)
  • 2f44380 docs: state blob A's colour-target registers, measured over the library (RT-SLOT57-BLEND-STATE)
  • 4e7b764 d3d12_xs: integer render targets keep blending off in slot 57 native PSOs (RT-SLOT57-BLEND-STATE)
  • f557637 d3d12_xs: a native PSO whose blend state the device refuses is built with blending off on its stand-in targets (RT-SLOT57-BLEND-STATE)
  • 81f33de docs: the stand-in-target fallback of RT-SLOT57-BLEND-STATE
  • 668d65b d3d12_xs: slot 57 retries only a pipeline that blends a B4G4R4A4 stand-in (RT-SLOT57-BLEND-STATE review)

📊 Changes

7 files changed (+478 additions, -5 deletions)

View changed files

📝 docs/fspx.md (+45 -2)
📝 runtime/CMakeLists.txt (+7 -0)
📝 runtime/shims/d3d12_xs_native_pso.h (+66 -2)
➕ runtime/shims/d3d12_xs_native_pso_fallback.h (+25 -0)
📝 runtime/src/native_pso.h (+119 -1)
➕ runtime/test/native_pso_blend_test.cpp (+143 -0)
➕ runtime/test/native_pso_fallback_test.cpp (+73 -0)

📄 Description

Claimed in the coordination issue as: RT-SLOT57-BLEND-STATE (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7155828305)

Depends on: #1592

#1592 is a conflict only: both add an #include on the same line of runtime/shims/d3d12_xs_native_pso.h. Everything else merges, and I'll rebase onto whichever lands first. This builds on no other PR. The real-boot test also used #1558 and #1547 to get past the landing screen on NVIDIA; this change doesn't need them.

What and why

Since #939, every graphics pipeline the game creates through device slot 57 goes through the native factory (runtime/shims/d3d12_xs_native_pso.h). The factory built each PSO from a zeroed desc and set only RenderTargetWriteMask, so every target drew with blending off. The record's state blob A, which carries the blend state, was never read (native_pso.h: "blend, raster, depth, not decoded"). That is the cause of the picture regression QemmHD bisected to #939 (https://github.com/ubiquitarianism/leonida/pull/939#issuecomment-7155793736):

  • glyphs drawn as solid blocks;
  • option arrows drawn as white squares;
  • hard-edged artwork;
  • black where a gradient is composited over.

Blob A's shared block holds context register values in the RDNA2 layout. Measured over all 5,680 distinct blobs in the 1.0.2.1 pipeline library (25,471 graphics records):

  • +0xd0..+0xec CB_BLEND0..7_CONTROL: 34 distinct values, all in-range blends.
  • +0x78 CB_TARGET_MASK: it matches blob B's targets in 17,626 records.
  • +0x7c CB_COLOR_CONTROL: ROP3 copy everywhere.
  • Mesh pipelines: the same registers, 84 bytes further on.

The counts and the layout are in docs/fspx.md, "State blob A". Aggregate counts only; no blob bytes are quoted anywhere.

  • runtime/src/native_pso.h:
    • decode_state_a_blend checks the measured shapes and the tag, then reads the registers.
    • d3d12_target_blend and d3d12_blend map them to D3D12 blend values: RDNA2 factor and COMB_FCN to D3D12_BLEND and D3D12_BLEND_OP, alpha taken from the colour fields without SEPARATE_ALPHA_BLEND, and each target's CB_TARGET_MASK nibble as its write mask.
    • plan() fills FixedState::blend.
  • runtime/shims/d3d12_xs_native_pso.h: fill_blend_state builds D3D12_BLEND_DESC from it, with IndependentBlendEnable where targets differ. Both the VS and the mesh paths use it.
  • Kept on today's defaults (blending off, all components written), logged:
    • the 1,937 records that blend with dual-source SRC1 factors, since the translator declares no second pixel-shader output;
    • any blob of another shape;
    • any target with a factor this path doesn't take.
  • Raster and depth state: not decoded here, so the factory's defaults stay. That would be a separate item.
  • runtime/test/native_pso_blend_test.cpp (portable, standard library only): synthetic blobs for both families, the shape and tag checks, the register mapping including the subtract/reverse-subtract order and the non-separate alpha case, the refused forms, and plan().

Tested

  • Real boot, retail 1.0.2.1, native Windows. main + #1558 + #1547 (needed on NVIDIA to get past the landing screen) + this branch, fresh first-run profile, factory on.
    • Before (same build without this change), the first-run pages had solid glyph blocks, square arrows, a flat minimap illustration, and a black background with hard-edged artwork on the legal screens.
    • With this change:
      • "Navigation experience", "Interface size", the legal and photosensitivity screens draw correctly: readable text, round arrow buttons, the translucent minimap frame, the purple gradient behind the legal screens with the faded building art, and the highlighted-row gradient;
      • the loading slideshow draws clean, with its blurred cross-fade.
    • The log shows the dual-source fallback for CB_BLEND0 f1010f01 pipelines, as expected.
  • ctest on Windows: native_pso_blend, xs_proxy_mock and xbox_native_base_draw pass.

GPUs tested: NVIDIA GeForce RTX 4070 Laptop GPU, driver 591.59 (32.0.15.9159), Windows 11

AI-assisted: yes

@QemmHD offered an A/B on a 4070 SUPER with the factory on and off; that would cover a second machine.

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (Not a translator change; the measurement is in docs/fspx.md.)

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1671 **Author:** [@OreoFR](https://github.com/OreoFR) **Created:** 11/25/2026 **Status:** ✅ Merged **Merged:** 11/25/2026 **Merged by:** [@aslan2142](https://github.com/aslan2142) **Base:** `main` ← **Head:** `rt-slot57-blend-state` --- ### 📝 Commits (6) - [`70d3517`](https://github.com/ubiquitarianism/leonida/commit/70d351788924726089efac6344da8a49f8e45d39) d3d12_xs: blend state for slot 57 native pipelines from state blob A (RT-SLOT57-BLEND-STATE) - [`2f44380`](https://github.com/ubiquitarianism/leonida/commit/2f44380590e9471cb44b15818ad2c2c422a2af21) docs: state blob A's colour-target registers, measured over the library (RT-SLOT57-BLEND-STATE) - [`4e7b764`](https://github.com/ubiquitarianism/leonida/commit/4e7b764dbc04fbd5343fb6c99224a8b0bec9ae9c) d3d12_xs: integer render targets keep blending off in slot 57 native PSOs (RT-SLOT57-BLEND-STATE) - [`f557637`](https://github.com/ubiquitarianism/leonida/commit/f5576377d1b2052277b406d2299c3a2692137173) d3d12_xs: a native PSO whose blend state the device refuses is built with blending off on its stand-in targets (RT-SLOT57-BLEND-STATE) - [`81f33de`](https://github.com/ubiquitarianism/leonida/commit/81f33de1cd307ac7cd7365724c55d27999888629) docs: the stand-in-target fallback of RT-SLOT57-BLEND-STATE - [`668d65b`](https://github.com/ubiquitarianism/leonida/commit/668d65b4b9cb74586176edb97a9379231153e4ff) d3d12_xs: slot 57 retries only a pipeline that blends a B4G4R4A4 stand-in (RT-SLOT57-BLEND-STATE review) ### 📊 Changes **7 files changed** (+478 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `docs/fspx.md` (+45 -2) 📝 `runtime/CMakeLists.txt` (+7 -0) 📝 `runtime/shims/d3d12_xs_native_pso.h` (+66 -2) ➕ `runtime/shims/d3d12_xs_native_pso_fallback.h` (+25 -0) 📝 `runtime/src/native_pso.h` (+119 -1) ➕ `runtime/test/native_pso_blend_test.cpp` (+143 -0) ➕ `runtime/test/native_pso_fallback_test.cpp` (+73 -0) </details> ### 📄 Description Claimed in the coordination issue as: RT-SLOT57-BLEND-STATE (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7155828305) Depends on: #1592 #1592 is a conflict only: both add an `#include` on the same line of `runtime/shims/d3d12_xs_native_pso.h`. Everything else merges, and I'll rebase onto whichever lands first. This builds on no other PR. The real-boot test also used #1558 and #1547 to get past the landing screen on NVIDIA; this change doesn't need them. ### What and why Since #939, every graphics pipeline the game creates through device slot 57 goes through the native factory (`runtime/shims/d3d12_xs_native_pso.h`). The factory built each PSO from a zeroed desc and set only `RenderTargetWriteMask`, so every target drew with blending off. The record's state blob A, which carries the blend state, was never read (`native_pso.h`: "blend, raster, depth, not decoded"). That is the cause of the picture regression QemmHD bisected to #939 (https://github.com/ubiquitarianism/leonida/pull/939#issuecomment-7155793736): - glyphs drawn as solid blocks; - option arrows drawn as white squares; - hard-edged artwork; - black where a gradient is composited over. Blob A's shared block holds context register values in the RDNA2 layout. Measured over all 5,680 distinct blobs in the 1.0.2.1 pipeline library (25,471 graphics records): - **`+0xd0..+0xec` `CB_BLEND0..7_CONTROL`:** 34 distinct values, all in-range blends. - **`+0x78` `CB_TARGET_MASK`:** it matches blob B's targets in 17,626 records. - **`+0x7c` `CB_COLOR_CONTROL`:** ROP3 copy everywhere. - **Mesh pipelines:** the same registers, 84 bytes further on. The counts and the layout are in `docs/fspx.md`, "State blob A". Aggregate counts only; no blob bytes are quoted anywhere. - `runtime/src/native_pso.h`: - `decode_state_a_blend` checks the measured shapes and the tag, then reads the registers. - `d3d12_target_blend` and `d3d12_blend` map them to D3D12 blend values: RDNA2 factor and `COMB_FCN` to `D3D12_BLEND` and `D3D12_BLEND_OP`, alpha taken from the colour fields without `SEPARATE_ALPHA_BLEND`, and each target's `CB_TARGET_MASK` nibble as its write mask. - `plan()` fills `FixedState::blend`. - `runtime/shims/d3d12_xs_native_pso.h`: `fill_blend_state` builds `D3D12_BLEND_DESC` from it, with `IndependentBlendEnable` where targets differ. Both the VS and the mesh paths use it. - **Kept on today's defaults** (blending off, all components written), logged: - the 1,937 records that blend with dual-source `SRC1` factors, since the translator declares no second pixel-shader output; - any blob of another shape; - any target with a factor this path doesn't take. - **Raster and depth state:** not decoded here, so the factory's defaults stay. That would be a separate item. - `runtime/test/native_pso_blend_test.cpp` (portable, standard library only): synthetic blobs for both families, the shape and tag checks, the register mapping including the subtract/reverse-subtract order and the non-separate alpha case, the refused forms, and `plan()`. ### Tested - **Real boot, retail 1.0.2.1, native Windows.** `main` + #1558 + #1547 (needed on NVIDIA to get past the landing screen) + this branch, fresh first-run profile, factory on. - **Before** (same build without this change), the first-run pages had solid glyph blocks, square arrows, a flat minimap illustration, and a black background with hard-edged artwork on the legal screens. - **With this change:** - "Navigation experience", "Interface size", the legal and photosensitivity screens draw correctly: readable text, round arrow buttons, the translucent minimap frame, the purple gradient behind the legal screens with the faded building art, and the highlighted-row gradient; - the loading slideshow draws clean, with its blurred cross-fade. - The log shows the dual-source fallback for `CB_BLEND0 f1010f01` pipelines, as expected. - **ctest on Windows:** `native_pso_blend`, `xs_proxy_mock` and `xbox_native_base_draw` pass. GPUs tested: NVIDIA GeForce RTX 4070 Laptop GPU, driver 591.59 (32.0.15.9159), Windows 11 AI-assisted: yes @QemmHD offered an A/B on a 4070 SUPER with the factory on and off; that would cover a second machine. ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (Not a translator change; the measurement is in `docs/fspx.md`.) 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:22:06 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#1687
No description provided.