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

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

@⁠IlyassRS3 on GitHub · 2026-11-25 11:56 UTC · original
IlyassRS3:fix/rt-ondemand-console-stream-enum → main · +172 −55 · 5 files · 1 commits · closed without merging

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: #1608
  • 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:
    • 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
**@⁠IlyassRS3** on GitHub · 2026-11-25 11:56 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1779) `IlyassRS3:fix/rt-ondemand-console-stream-enum` → `main` · +172 −55 · 5 files · 1 commits · closed without merging ## 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://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608 - **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
Under LEONIDA_PIPELINE_COMPILE=on-demand (set by --first-run-ui), device
slot 86 routes to Device::prepare_console_stream instead of eager
ID3D12Device2::CreatePipelineState. prepare_console_stream previously
parsed only with PC subobject numbering and called
PsoStreamRecord::capture(source) without the console flag, rejecting
console-numbered mesh streams (type 24 = MS, type 26 = RASTERIZER1) and
leaving captured tags unnormalized for slot 55 derivation and bind-time
resolve_type.

Extract parse_pipeline_stream_any shared by CreatePipelineState and
prepare_console_stream, pass used_console to PsoStreamRecord::capture,
reject unsupported stages and missing VK_EXT_mesh_shader / mesh
root_window up front in prepare_console_stream, run
LEONIDA_PSO_STREAM_AUDIT consistently across both paths in
create_pso_from_stream, make d3d12_mesh_test's temp folder per-process,
and register d3d12_mesh_on_demand in CTest.

Item: RT-ONDEMAND-CONSOLE-STREAM-ENUM
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:04:47 +00:00
github-bot closed this pull request 2026-11-26 10:04:47 +00:00
Author
Owner

@⁠copilot-pull-request-reviewer[bot] on GitHub · 2026-11-25 11:56 UTC · original · reviewed

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

**@⁠copilot-pull-request-reviewer[bot]** on GitHub · 2026-11-25 11:56 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1779#pullrequestreview-6057154566) · **reviewed** Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
Author
Owner

@⁠IlyassRS3 on GitHub · 2026-11-25 11:57 UTC · original

Closing in favor of @⁠JesusACD, who claimed RT-ONDEMAND-CONSOLE-STREAM 73 seconds earlier in #1608 (#1608) while I was reading the files. Feel free to reuse any pieces if helpful (especially making d3d12_mesh_test's temp dir per-process so d3d12_mesh and an on-demand CTest don't race under ctest -j).

**@⁠IlyassRS3** on GitHub · 2026-11-25 11:57 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1779#issuecomment-7161735410) Closing in favor of @⁠JesusACD, who claimed `RT-ONDEMAND-CONSOLE-STREAM` 73 seconds earlier in #1608 (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608) while I was reading the files. Feel free to reuse any pieces if helpful (especially making `d3d12_mesh_test`'s temp dir per-process so `d3d12_mesh` and an on-demand CTest don't race under `ctest -j`).

Pull request closed

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