[PR #1779] [CLOSED] d3d12: support console-numbered PSO streams under LEONIDA_PIPELINE_COMPILE=on-demand (RT-ONDEMAND-CONSOLE-STREAM-ENUM) #1792

Closed
opened 2026-11-26 21:18:58 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1779
Author: @IlyassRS3
Created: 11/25/2026
Status: ❌ Closed

Base: main ← Head: fix/rt-ondemand-console-stream-enum


📝 Commits (1)

  • 4045610 d3d12: handle console stream numbering under on-demand pipeline compile

📊 Changes

5 files changed (+172 additions, -55 deletions)

View changed files

📝 runtime/CMakeLists.txt (+3 -0)
📝 runtime/shims/d3d12_vulkan_device.cpp (+85 -49)
📝 runtime/shims/d3d12_xs_device.cpp (+9 -5)
📝 runtime/test/d3d12_mesh_test.cpp (+27 -1)
📝 runtime/test/pso_stream_test.cpp (+48 -0)

📄 Description

Summary

Fixes console-numbered pipeline state streams from Xbox device slot 86 under LEONIDA_PIPELINE_COMPILE=on-demand (--first-run-ui), following up @thiefyzheng's finding in #1608 (#1608#issuecomment-7161103050).

Root cause

When LEONIDA_PIPELINE_COMPILE=on-demand is active (--first-run-ui), set_device_outer registers Device::prepare_console_stream as proxy->prepare_stream, so Xbox device slot 86 (create_pso_from_stream) bypasses Device::CreatePipelineState:

  1. prepare_console_stream called parse_pipeline_stream(source, stream) with PC numbering only, omitting the console subobject numbering retry (type 24 = MS, type 26 = RASTERIZER1). A console mesh stream with raw tag 24 alone parsed as PC AS and returned E_NOTIMPL; with raw tag 26 (RASTERIZER1 read as larger PC DEPTH_STENCIL2) it returned E_INVALIDARG.
  2. prepare_console_stream called PsoStreamRecord::capture(source) without passing used_console, so raw console tag 26 failed walk() (E_INVALIDARG) and raw console tag 24 was never rewritten to canonical PC numbering (25 = MS) for slot-55 derivation (derive_stream) or bind-time realization (PipelineState::resolve_type).
  3. prepare_console_stream did not mirror eager create_graphics's up-front refusals for missing VK_EXT_mesh_shader, StreamOutput, MS+GS, or a mesh shader missing root_window, and create_pso_from_stream skipped LEONIDA_PSO_STREAM_AUDIT on the prepare_stream path.

Changes

  • runtime/shims/d3d12_vulkan_device.cpp:
    • Extract parse_pipeline_stream_any() so Device::CreatePipelineState and Device::prepare_console_stream share the exact same PC-first / console-fallback parser and used_console_stream tracking.
    • Pass used_console to PsoStreamRecord::capture(source, used_console) in prepare_console_stream, mirror eager refusals (AS, HS/DS/StreamOutput, missing VK_EXT_mesh_shader, MS+GS, mesh graphics_root_window), and record PipelineStream::Refused / PipelineStream::Mesh.
  • runtime/shims/d3d12_xs_device.cpp:
    • Run LEONIDA_PSO_STREAM_AUDIT on prepare_stream refusals too and avoid duplicate keep_pso_stream when prepare_stream already captured the record.
  • runtime/test/d3d12_mesh_test.cpp & runtime/CMakeLists.txt:
    • Make d3d12_mesh_test's temporary shader library directory per-process (GetCurrentProcessId()) so d3d12_mesh and d3d12_mesh_on_demand can run concurrently under ctest -j.
    • Exercise slot 86 on missing VK_EXT_mesh_shader (E_NOTIMPL), ms_old without root_window (E_INVALIDARG), and non-mesh DXIL kind 14 in tag 24.
    • Add CTest target d3d12_mesh_on_demand with LEONIDA_PIPELINE_COMPILE=on-demand (exercises slot-86 console streams with/without raw tag 26, slot-55 derivation, bind-time resolve_type, and full DispatchMesh pixel readback).
  • runtime/test/pso_stream_test.cpp:
    • Add test_console_stream_normalization covering raw console tags 24 (MS) and 26 (RASTERIZER1) rejection under console=false, tag normalization (24 -> 25, 26 -> 27) and deep copy under console=true, and subsequent slot-55 derive_stream.

Verification

  • AI-assisted: yes
  • GPUs tested: none (developed on macOS without Windows SDK / Vulkan SDK; d3d12_vulkan_device.cpp, d3d12_xs_device.cpp, d3d12_mesh_test.cpp, and pso_stream_test.cpp are Windows-only and could not be compiled or run locally — relies on Windows CI / Windows GPU verification of pso_stream, d3d12_mesh, and d3d12_mesh_on_demand).
  • Local checks run:
    • python3 -I scripts/check_no_game_data.py runtime/shims/d3d12_vulkan_device.cpp runtime/shims/d3d12_xs_device.cpp runtime/test/d3d12_mesh_test.cpp runtime/test/pso_stream_test.cpp runtime/CMakeLists.txt — pass
    • python3 -I tests/test_text_write_line_endings.py — 3/3 pass

🔄 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/1779 **Author:** [@IlyassRS3](https://github.com/IlyassRS3) **Created:** 11/25/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/rt-ondemand-console-stream-enum` --- ### 📝 Commits (1) - [`4045610`](https://github.com/ubiquitarianism/leonida/commit/4045610f0f87e321eda15d4a479c043e7e156057) d3d12: handle console stream numbering under on-demand pipeline compile ### 📊 Changes **5 files changed** (+172 additions, -55 deletions) <details> <summary>View changed files</summary> 📝 `runtime/CMakeLists.txt` (+3 -0) 📝 `runtime/shims/d3d12_vulkan_device.cpp` (+85 -49) 📝 `runtime/shims/d3d12_xs_device.cpp` (+9 -5) 📝 `runtime/test/d3d12_mesh_test.cpp` (+27 -1) 📝 `runtime/test/pso_stream_test.cpp` (+48 -0) </details> ### 📄 Description ## Summary Fixes console-numbered pipeline state streams from Xbox device slot 86 under `LEONIDA_PIPELINE_COMPILE=on-demand` (`--first-run-ui`), following up @thiefyzheng's finding in #1608 (`#1608#issuecomment-7161103050`). - **Coordination item**: `RT-ONDEMAND-CONSOLE-STREAM-ENUM` - **Claim**: https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7161646143 - **Scope note**: `PipelineState::resolve_type` is intentionally untouched so this stays conflict-free with #1695. ### Root cause When `LEONIDA_PIPELINE_COMPILE=on-demand` is active (`--first-run-ui`), `set_device_outer` registers `Device::prepare_console_stream` as `proxy->prepare_stream`, so Xbox device slot 86 (`create_pso_from_stream`) bypasses `Device::CreatePipelineState`: 1. `prepare_console_stream` called `parse_pipeline_stream(source, stream)` with PC numbering only, omitting the console subobject numbering retry (`type 24` = `MS`, `type 26` = `RASTERIZER1`). A console mesh stream with raw tag `24` alone parsed as PC `AS` and returned `E_NOTIMPL`; with raw tag `26` (`RASTERIZER1` read as larger PC `DEPTH_STENCIL2`) it returned `E_INVALIDARG`. 2. `prepare_console_stream` called `PsoStreamRecord::capture(source)` without passing `used_console`, so raw console tag `26` failed `walk()` (`E_INVALIDARG`) and raw console tag `24` was never rewritten to canonical PC numbering (`25` = `MS`) for slot-55 derivation (`derive_stream`) or bind-time realization (`PipelineState::resolve_type`). 3. `prepare_console_stream` did not mirror eager `create_graphics`'s up-front refusals for missing `VK_EXT_mesh_shader`, `StreamOutput`, `MS`+`GS`, or a mesh shader missing `root_window`, and `create_pso_from_stream` skipped `LEONIDA_PSO_STREAM_AUDIT` on the `prepare_stream` path. ### Changes - [`runtime/shims/d3d12_vulkan_device.cpp`](runtime/shims/d3d12_vulkan_device.cpp): - Extract `parse_pipeline_stream_any()` so `Device::CreatePipelineState` and `Device::prepare_console_stream` share the exact same PC-first / console-fallback parser and `used_console_stream` tracking. - Pass `used_console` to `PsoStreamRecord::capture(source, used_console)` in `prepare_console_stream`, mirror eager refusals (`AS`, `HS`/`DS`/`StreamOutput`, missing `VK_EXT_mesh_shader`, `MS`+`GS`, mesh `graphics_root_window`), and record `PipelineStream::Refused` / `PipelineStream::Mesh`. - [`runtime/shims/d3d12_xs_device.cpp`](runtime/shims/d3d12_xs_device.cpp): - Run `LEONIDA_PSO_STREAM_AUDIT` on `prepare_stream` refusals too and avoid duplicate `keep_pso_stream` when `prepare_stream` already captured the record. - [`runtime/test/d3d12_mesh_test.cpp`](runtime/test/d3d12_mesh_test.cpp) & [`runtime/CMakeLists.txt`](runtime/CMakeLists.txt): - Make `d3d12_mesh_test`'s temporary shader library directory per-process (`GetCurrentProcessId()`) so `d3d12_mesh` and `d3d12_mesh_on_demand` can run concurrently under `ctest -j`. - Exercise slot 86 on missing `VK_EXT_mesh_shader` (`E_NOTIMPL`), `ms_old` without `root_window` (`E_INVALIDARG`), and non-mesh DXIL kind 14 in tag 24. - Add CTest target `d3d12_mesh_on_demand` with `LEONIDA_PIPELINE_COMPILE=on-demand` (exercises slot-86 console streams with/without raw tag `26`, slot-55 derivation, bind-time `resolve_type`, and full `DispatchMesh` pixel readback). - [`runtime/test/pso_stream_test.cpp`](runtime/test/pso_stream_test.cpp): - Add `test_console_stream_normalization` covering raw console tags `24` (`MS`) and `26` (`RASTERIZER1`) rejection under `console=false`, tag normalization (`24 -> 25`, `26 -> 27`) and deep copy under `console=true`, and subsequent slot-55 `derive_stream`. ## Verification - **AI-assisted**: yes - **GPUs tested**: none (developed on macOS without Windows SDK / Vulkan SDK; `d3d12_vulkan_device.cpp`, `d3d12_xs_device.cpp`, `d3d12_mesh_test.cpp`, and `pso_stream_test.cpp` are Windows-only and could not be compiled or run locally — relies on Windows CI / Windows GPU verification of `pso_stream`, `d3d12_mesh`, and `d3d12_mesh_on_demand`). - Local checks run: - `python3 -I scripts/check_no_game_data.py runtime/shims/d3d12_vulkan_device.cpp runtime/shims/d3d12_xs_device.cpp runtime/test/d3d12_mesh_test.cpp runtime/test/pso_stream_test.cpp runtime/CMakeLists.txt` — pass - `python3 -I tests/test_text_write_line_endings.py` — 3/3 pass --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 21:18:58 +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#1792
No description provided.