d3d12: log the pipeline state stream refusal reason for E_INVALIDARG #1740

Open
github-bot wants to merge 1 commit from github-bot/gh-1740 into main AGit
Owner

@⁠Mby159 on GitHub · 2026-11-25 10:38 UTC · original
Mby159:feat/pso-stream-refusal-reason → main · +42 −19 · 3 files · 1 commits · open

Claimed in the coordination issue as: RT-PSO-STREAM-EINVALIDARG-REASON
(#1608)

Depends on: none

What and why

ID3D12Device2::CreatePipelineState refuses a pipeline state stream with E_INVALIDARG without saying why, so a pipeline that is skipped cannot be seen in the log.

Two places make the refusal silent, both on main 57ba40bd6:

  • runtime/shims/d3d12_vulkan_device.cpp:12127: the finish lambda of the PC CreatePipelineState records a PipelineStream::Refused trace for E_NOTIMPL only, and every E_INVALIDARG from parse_pipeline_stream returns a bare HRESULT, so d3d12_trace::stream_refusal stays null;
  • runtime/shims/d3d12_xs_device.cpp:4729: the LEONIDA_PSO_STREAM_AUDIT gate fires for E_NOTIMPL and E_FAIL only, and audit_pso_stream is called from that console proxy path alone, so the PC path prints no audit line either.

This pull request gives each refusal a reason and prints it once, next to the existing stream_unsupported helper:

  • parse_pipeline_stream: a reason for every E_INVALIDARG — the stream has no subobjects, it ends inside a subobject type or payload, an unknown subobject type, two subobjects of one family, a compute stage with graphics stages, no shader stage;
  • create_graphics: the two mesh cases (a mesh pipeline with a vertex, tessellation or geometry stage; a graphics pipeline with no vertex stage) name their reason too; the remaining graphics-state refusals get one generic reason;
  • the PC CreatePipelineState prints each reason once through log_once (no environment variable needed) and records the E_INVALIDARG refusals in the PipelineStream::Refused trace when tracing is on; the console proxy's LEONIDA_PSO_STREAM_AUDIT gate is widened to E_INVALIDARG, and the audit call site stays console-only;
  • docs/d3d12_vulkan.md describes the refusal reason and the audit.

The HRESULTs do not change: every refusal still returns E_INVALIDARG. What is added is a reason string, one [rt] d3d12: <reason> <type> line per distinct (reason, subobject type) pair, one [d3d12-trace] record per refusal when tracing is on, and the console path's audit line for an E_INVALIDARG refusal when LEONIDA_PSO_STREAM_AUDIT=1 is set.

Tested

  • clang++ -std=c++20 -fsyntax-only (LLVM/Clang 21 from llvm-mingw, -fms-extensions, -ferror-limit=0, -Wall -Wextra) on runtime/shims/d3d12_vulkan_device.cpp and runtime/shims/d3d12_xs_device.cpp: the diagnostic set of this branch and of main 57ba40bd6 is the same (508 lines / 34 distinct messages on the first file, 2 / 2 on the second, identical on both sides), so the change adds none. The five errors in that set are pre-existing on main and come from the stub headers this machine has instead of the Windows SDK; this is a diagnostic-parity check, not a build.
  • Not built, not linked and not run: this machine has no MSVC, no Windows SDK and no GPU, so the runtime test binaries could not be built and no pipeline was created. The repository's Runtime workflow (.github/workflows/runtime.yml) builds the runtime/ tree with MSVC on windows-latest and runs the CPU runtime tests with ctest, and it runs on pull requests whose changed paths include runtime/**, so it covers this change; that build was not run here.

GPUs tested: none — no GPU on this machine, nothing was run on one

AI-assisted: yes

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 applicable: no translator rule is added)
**@⁠Mby159** on GitHub · 2026-11-25 10:38 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1740) `Mby159:feat/pso-stream-refusal-reason` → `main` · +42 −19 · 3 files · 1 commits · open Claimed in the coordination issue as: RT-PSO-STREAM-EINVALIDARG-REASON (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608) Depends on: none ### What and why `ID3D12Device2::CreatePipelineState` refuses a pipeline state stream with `E_INVALIDARG` without saying why, so a pipeline that is skipped cannot be seen in the log. Two places make the refusal silent, both on `main` 57ba40bd6: - `runtime/shims/d3d12_vulkan_device.cpp:12127`: the `finish` lambda of the PC `CreatePipelineState` records a `PipelineStream::Refused` trace for `E_NOTIMPL` only, and every `E_INVALIDARG` from `parse_pipeline_stream` returns a bare HRESULT, so `d3d12_trace::stream_refusal` stays null; - `runtime/shims/d3d12_xs_device.cpp:4729`: the `LEONIDA_PSO_STREAM_AUDIT` gate fires for `E_NOTIMPL` and `E_FAIL` only, and `audit_pso_stream` is called from that console proxy path alone, so the PC path prints no audit line either. This pull request gives each refusal a reason and prints it once, next to the existing `stream_unsupported` helper: - `parse_pipeline_stream`: a reason for every `E_INVALIDARG` — the stream has no subobjects, it ends inside a subobject type or payload, an unknown subobject type, two subobjects of one family, a compute stage with graphics stages, no shader stage; - `create_graphics`: the two mesh cases (a mesh pipeline with a vertex, tessellation or geometry stage; a graphics pipeline with no vertex stage) name their reason too; the remaining graphics-state refusals get one generic reason; - the PC `CreatePipelineState` prints each reason once through `log_once` (no environment variable needed) and records the `E_INVALIDARG` refusals in the `PipelineStream::Refused` trace when tracing is on; the console proxy's `LEONIDA_PSO_STREAM_AUDIT` gate is widened to `E_INVALIDARG`, and the audit call site stays console-only; - `docs/d3d12_vulkan.md` describes the refusal reason and the audit. The HRESULTs do not change: every refusal still returns `E_INVALIDARG`. What is added is a reason string, one `[rt] d3d12: <reason> <type>` line per distinct (reason, subobject type) pair, one `[d3d12-trace]` record per refusal when tracing is on, and the console path's audit line for an `E_INVALIDARG` refusal when `LEONIDA_PSO_STREAM_AUDIT=1` is set. ### Tested - `clang++ -std=c++20 -fsyntax-only` (LLVM/Clang 21 from llvm-mingw, `-fms-extensions`, `-ferror-limit=0`, `-Wall -Wextra`) on `runtime/shims/d3d12_vulkan_device.cpp` and `runtime/shims/d3d12_xs_device.cpp`: the diagnostic set of this branch and of `main` 57ba40bd6 is the same (508 lines / 34 distinct messages on the first file, 2 / 2 on the second, identical on both sides), so the change adds none. The five errors in that set are pre-existing on `main` and come from the stub headers this machine has instead of the Windows SDK; this is a diagnostic-parity check, not a build. - Not built, not linked and not run: this machine has no MSVC, no Windows SDK and no GPU, so the runtime test binaries could not be built and no pipeline was created. The repository's Runtime workflow (`.github/workflows/runtime.yml`) builds the `runtime/` tree with MSVC on `windows-latest` and runs the CPU runtime tests with `ctest`, and it runs on pull requests whose changed paths include `runtime/**`, so it covers this change; that build was not run here. GPUs tested: none — no GPU on this machine, nothing was run on one AI-assisted: yes ### 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 applicable: no translator rule is added)
The PC CreatePipelineState refuses a pipeline state stream with E_INVALIDARG
without saying why: the finish lambda records a PipelineStream::Refused trace for
E_NOTIMPL only, and every E_INVALIDARG from parse_pipeline_stream returns a bare
HRESULT, so d3d12_trace::stream_refusal stays null. The console audit gate fires
for E_NOTIMPL and E_FAIL only, and audit_pso_stream is called from that console
proxy path only, so the PC path prints no audit line either.

Each refusal now names its case and is logged once, next to stream_unsupported:
the stream has no subobjects, ends inside a subobject type or payload, an unknown
subobject type, two subobjects of one family, a compute stage with graphics stages,
no shader stage, a mesh pipeline with a vertex, tessellation or geometry stage, a
graphics pipeline with no vertex stage. The PC path records the E_INVALIDARG
refusals in the trace, LEONIDA_PSO_STREAM_AUDIT=1 prints them, and the remaining
graphics-state refusals keep one generic reason. docs/d3d12_vulkan.md follows.

No game files: a stream is read from the caller's own description.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:03:16 +00:00
Author
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-25 11:02 UTC · original · approved these changes

### Clean-Room & Technical Verification

  • Mergeability: 3-way merge against upstream main (bcaa13dad) is 100% clean with zero merge conflicts.
  • Clean-Room Compliance: 100% clean-room. D3D12 pipeline stream diagnostic logging and parser hardening only; zero retail code, game data, or keys (check_no_game_data.py clean).
  • Technical Rigor & Diagnostic Visibility:
    • Previously, parse_pipeline_stream returned bare E_INVALIDARG without recording a refusal reason into d3d12_trace::stream_refusal or logging reasons, leaving pipeline refusals completely silent.
    • Implements stream_invalid() logging each distinct refusal once via log_once (e.g. stream has no subobjects, ends inside type or payload, duplicate subobject family, invalid stage mixtures, or missing vertex stage) and setting d3d12_trace::stream_refusal.
    • Extends PipelineStream::Refused recording to capture both E_NOTIMPL and E_INVALIDARG, and widens the console proxy audit gate (LEONIDA_PSO_STREAM_AUDIT) to audit E_INVALIDARG refusals.
    • Updates documentation in docs/d3d12_vulkan.md.

LGTM! Approved.

**@⁠abnalstlll-byte** on GitHub · 2026-11-25 11:02 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1740#pullrequestreview-6056384800) · **approved these changes** ### Clean-Room & Technical Verification - **Mergeability**: 3-way merge against upstream `main` (`bcaa13dad`) is 100% clean with zero merge conflicts. - **Clean-Room Compliance**: 100% clean-room. D3D12 pipeline stream diagnostic logging and parser hardening only; zero retail code, game data, or keys (`check_no_game_data.py` clean). - **Technical Rigor & Diagnostic Visibility**: - Previously, `parse_pipeline_stream` returned bare `E_INVALIDARG` without recording a refusal reason into `d3d12_trace::stream_refusal` or logging reasons, leaving pipeline refusals completely silent. - Implements `stream_invalid()` logging each distinct refusal once via `log_once` (e.g. stream has no subobjects, ends inside type or payload, duplicate subobject family, invalid stage mixtures, or missing vertex stage) and setting `d3d12_trace::stream_refusal`. - Extends `PipelineStream::Refused` recording to capture both `E_NOTIMPL` and `E_INVALIDARG`, and widens the console proxy audit gate (`LEONIDA_PSO_STREAM_AUDIT`) to audit `E_INVALIDARG` refusals. - Updates documentation in `docs/d3d12_vulkan.md`. LGTM! Approved.
Author
Owner

@⁠MoonEyes on GitHub · 2026-11-25 18:15 UTC · original

Built and ran #1740 at head 28f9123cc with MSVC and a GPU, since the PR was syntax-checked only.

Config: Windows 11 (26300), RTX 4060 desktop, NVIDIA 610.88, MSVC 19.44, RelWithDebInfo, Vulkan SDK 1.4.363.0. Test targets only, no game files.

  • Builds with MSVC /W4 /permissive-: 10 test targets. Six link both changed files (d3d12_mesh_test, d3d12_pso_validation_test, d3d12_vulkan_device_test, d3d12_com_test, d3d12_draw_test, d3d12_pipeline_library_test); device_proxy_test, root_sig_test and xs_proxy_mock_test link d3d12_xs_device.cpp only; pso_stream_test links neither. 0 errors, no warning on the lines the PR changes.
  • ctest on those 10: all pass.
  • The reasons are printed. d3d12_mesh_test (9 streams refused as invalid) now logs, once each: two subobjects of one family in the pipeline state stream <type> (types 0, 2, 11, 21, 28), unknown pipeline state stream subobject type 23, the pipeline state stream ends inside a subobject payload, a compute stage with graphics stages, no shader stage in the pipeline state stream, a mesh pipeline with a vertex, tessellation or geometry stage, and the generic a pipeline state stream this layer refuses.

Not covered: the full runtime build (gta6rt.exe) and full ctest, the PipelineStream::Refused trace record, and the LEONIDA_PSO_STREAM_AUDIT=1 console path.

AI-assisted: yes (Claude Code ran the tests)

**@⁠MoonEyes** on GitHub · 2026-11-25 18:15 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1740#issuecomment-7170672268) Built and ran #1740 at head `28f9123cc` with MSVC and a GPU, since the PR was syntax-checked only. Config: Windows 11 (26300), RTX 4060 desktop, NVIDIA 610.88, MSVC 19.44, RelWithDebInfo, Vulkan SDK 1.4.363.0. Test targets only, no game files. - Builds with MSVC `/W4 /permissive-`: 10 test targets. Six link both changed files (`d3d12_mesh_test`, `d3d12_pso_validation_test`, `d3d12_vulkan_device_test`, `d3d12_com_test`, `d3d12_draw_test`, `d3d12_pipeline_library_test`); `device_proxy_test`, `root_sig_test` and `xs_proxy_mock_test` link `d3d12_xs_device.cpp` only; `pso_stream_test` links neither. 0 errors, no warning on the lines the PR changes. - `ctest` on those 10: all pass. - The reasons are printed. `d3d12_mesh_test` (9 streams refused as invalid) now logs, once each: `two subobjects of one family in the pipeline state stream <type>` (types 0, 2, 11, 21, 28), `unknown pipeline state stream subobject type 23`, `the pipeline state stream ends inside a subobject payload`, `a compute stage with graphics stages`, `no shader stage in the pipeline state stream`, `a mesh pipeline with a vertex, tessellation or geometry stage`, and the generic `a pipeline state stream this layer refuses`. Not covered: the full runtime build (`gta6rt.exe`) and full ctest, the `PipelineStream::Refused` trace record, and the `LEONIDA_PSO_STREAM_AUDIT=1` console path. AI-assisted: yes (Claude Code ran the tests)
Author
Owner

@⁠Mby159 on GitHub · 2026-11-26 10:26 UTC · original

Five of the six failing checks below come from a test that fails the same way on a tree that does not contain this change; the sixth (windows) is a test the runner skipped for lack of a Vulkan device and still counted as failed.

The diff is 3 files: docs/d3d12_vulkan.md (+7/-4), runtime/shims/d3d12_vulkan_device.cpp (+34/-14), runtime/shims/d3d12_xs_device.cpp (+1/-1). It adds a reason to the refusals that used to return a bare E_INVALIDARG: a new stream_invalid(reason, type) helper stores the reason in d3d12_trace::stream_refusal, prints it once with log_once and returns E_INVALIDARG; the PC CreatePipelineState finish lambda now records PipelineStream::Refused for E_INVALIDARG as well as E_NOTIMPL; and the console proxy's LEONIDA_PSO_STREAM_AUDIT gate also fires for E_INVALIDARG. No HRESULT changes.

Per check, with the failing test named:

  • macos-python — tests/test_mod_pack_output_alias.py, PackAliasTest::test_alias_preflight_precedes_output_truncation, two subtests, ModsError not raised. The same test fails the same way on #431, which changes only docs/gpu_test_results.md and gpu-test-results/780M.txt.
  • macos and linux-gpu-tools — cs_imgatomic_ext (6 of 64 sint words differ; first word 32: got 0x0badf00d, expected 0x00000101). In the macos leg ps_ssharp and cs_fma_fused fail as well, but those are the two failures that leg declares as expected; cs_imgatomic_ext is the one that turns it red. This is the fixture whose 3D volume T# does not carry the tag vk_store_test expects, which is what open PR #1518 changes. We measured the same failure on a main tree without this change, at fe1553456, and runtime/test/shaders/cs_imgatomic_ext.asm has not changed since. This diff does not touch tools/rdna2spirv.py, the fixtures, or the Vulkan compute path.
  • stdlib-tests-linux — tests/test_runner_calls_all_tests.py::test_every_stdlib_runner_calls_its_test_functions, reporting tests/test_feature_scan.py: test_out_named_like_the_optional_spirv_index() is defined but its __main__ runner never calls it. Reproduced here on this PR's base 57ba40bd6 and on #431's base bcaa13dad; it passes on current main a73a57e1339b.
  • translator-tests — both tests/test_translate.py cases on cs_dpp_cmp.asm: llvm-mc answers error: dpp variant of this instruction is not supported for the two v_cmp_gt_f32_dpp in that fixture. Reproduced here on current main as well, with the same llvm-mc command (-triple=amdgcn--amdpal -mcpu=gfx1013).
  • windows — the CTest list has one failure, vk_xdxr_postbuild_readback, which printed skipped (no Vulkan device with bufferDeviceAddress) and was still counted as failed. It is a Vulkan-backend acceleration-structure readback test; this diff does not touch the Vulkan backend.

The check job was cancelled.

Local reproductions ran on Windows 11 10.0.29712 with CPython 3.13.17, llvm-mc 23.1.6 and SPIRV-Tools on PATH. We did not build this branch here (no MSVC and no Windows SDK on this machine), so this is attribution of the CI results, not a build.

**@⁠Mby159** on GitHub · 2026-11-26 10:26 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1740#issuecomment-7189364143) Five of the six failing checks below come from a test that fails the same way on a tree that does not contain this change; the sixth (`windows`) is a test the runner skipped for lack of a Vulkan device and still counted as failed. The diff is 3 files: `docs/d3d12_vulkan.md` (+7/-4), `runtime/shims/d3d12_vulkan_device.cpp` (+34/-14), `runtime/shims/d3d12_xs_device.cpp` (+1/-1). It adds a reason to the refusals that used to return a bare `E_INVALIDARG`: a new `stream_invalid(reason, type)` helper stores the reason in `d3d12_trace::stream_refusal`, prints it once with `log_once` and returns `E_INVALIDARG`; the PC `CreatePipelineState` `finish` lambda now records `PipelineStream::Refused` for `E_INVALIDARG` as well as `E_NOTIMPL`; and the console proxy's `LEONIDA_PSO_STREAM_AUDIT` gate also fires for `E_INVALIDARG`. No HRESULT changes. Per check, with the failing test named: - **`macos-python`** — `tests/test_mod_pack_output_alias.py`, `PackAliasTest::test_alias_preflight_precedes_output_truncation`, two subtests, `ModsError not raised`. The same test fails the same way on #431, which changes only `docs/gpu_test_results.md` and `gpu-test-results/780M.txt`. - **`macos`** and **`linux-gpu-tools`** — `cs_imgatomic_ext` (`6 of 64 sint words differ; first word 32: got 0x0badf00d, expected 0x00000101`). In the `macos` leg `ps_ssharp` and `cs_fma_fused` fail as well, but those are the two failures that leg declares as expected; `cs_imgatomic_ext` is the one that turns it red. This is the fixture whose 3D volume T# does not carry the tag `vk_store_test` expects, which is what open PR #1518 changes. We measured the same failure on a `main` tree without this change, at `fe1553456`, and `runtime/test/shaders/cs_imgatomic_ext.asm` has not changed since. This diff does not touch `tools/rdna2spirv.py`, the fixtures, or the Vulkan compute path. - **`stdlib-tests-linux`** — `tests/test_runner_calls_all_tests.py::test_every_stdlib_runner_calls_its_test_functions`, reporting `tests/test_feature_scan.py: test_out_named_like_the_optional_spirv_index() is defined but its __main__ runner never calls it`. Reproduced here on this PR's base `57ba40bd6` and on #431's base `bcaa13dad`; it passes on current `main` `a73a57e1339b`. - **`translator-tests`** — both `tests/test_translate.py` cases on `cs_dpp_cmp.asm`: llvm-mc answers `error: dpp variant of this instruction is not supported` for the two `v_cmp_gt_f32_dpp` in that fixture. Reproduced here on current `main` as well, with the same llvm-mc command (`-triple=amdgcn--amdpal -mcpu=gfx1013`). - **`windows`** — the CTest list has one failure, `vk_xdxr_postbuild_readback`, which printed `skipped (no Vulkan device with bufferDeviceAddress)` and was still counted as failed. It is a Vulkan-backend acceleration-structure readback test; this diff does not touch the Vulkan backend. The `check` job was cancelled. Local reproductions ran on Windows 11 10.0.29712 with CPython 3.13.17, llvm-mc 23.1.6 and SPIRV-Tools on PATH. We did not build this branch here (no MSVC and no Windows SDK on this machine), so this is attribution of the CI results, not a build.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1740/head:github-bot/gh-1740'
git switch 'github-bot/gh-1740'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1740'
git switch 'github-bot/gh-1740'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1740'
git switch 'github-bot/gh-1740'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1740'
git switch 'main'
git merge --squash 'github-bot/gh-1740'
git switch 'main'
git merge --ff-only 'github-bot/gh-1740'
git switch 'main'
git merge 'github-bot/gh-1740'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.