Skip to content

d3d12: name the pipeline state stream refusals (RT-PSO-STREAM-REFUSAL-REASON) - #2918

Open
imShangLi wants to merge 3 commits into
ProjectLeonida:mainfrom
imShangLi:feat/pso-stream-refusal-reason-v2
Open

imShangLi wants to merge 3 commits into
ProjectLeonida:mainfrom
imShangLi:feat/pso-stream-refusal-reason-v2

Conversation

@imShangLi

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: RT-PSO-STREAM-REFUSAL-REASON
(#2570 (comment))

Depends on: none

Continues #1740, which was closed on 28 November only to rotate this account's single open pull request slot
(#2618 has since merged). Its head branch has since been rebased, so this is the same change on the current
main; the review of the first version is in #1740's comments.

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:

  • runtime/shims/d3d12_vulkan_device.cpp: 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: the console proxy's LEONIDA_PSO_STREAM_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, too many render targets, 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, and no description. 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 HRESULT changes.

What is new since the first review

  • the reason the log, the trace and the console audit read is now the same one: the generic reason is left in d3d12_trace::stream_refusal for the audit to print (it used to print -), the console re-read of a stream keeps its own reason out of the log (that reading may be discarded, and a stream that was built must not show a refusal), and the classic CreateGraphicsPipelineState / CreateComputePipelineState paths clear the field so that no reason of one call is left behind for another;
  • docs/d3d12_vulkan.md names the cases the stream's own refusals give, and says that the refusals of the graphics state itself keep one generic reason (there are more than a dozen of those, and they are not named here).

The classic path now logs the reason of a refusal it used to pass over in silence (a graphics pipeline with no vertex stage). That is deliberate: the refusal is the caller's mistake and it is worth seeing. It does not change any HRESULT.

Tested

  • MoonEyes built and ran the first version of this change with MSVC 19.44 on an RTX 4060 (Windows 11, NVIDIA 610.88, RelWithDebInfo): ten test targets, ctest green, and the reasons printed once each.
  • python3 -I -m unittest discover -s tests -p "test_docs_*.py" → 57 tests, OK.
  • python3 -I scripts/check_no_game_data.py runtime/shims/d3d12_vulkan_device.cpp runtime/shims/d3d12_xs_device.cpp docs/d3d12_vulkan.md → exit 0.
  • An independent read-only reviewer agent read the whole diff; its findings are the consistency fixes above.

What was not tested here

  • runtime/ is Windows-only and runtime.yml no longer runs on push or on a pull request (the legacy C++ runtime is deprecated in favour of the Rust runtimes), so no CI job compiles this diff. The Windows build and the ctest run above are the evidence.
  • No Vulkan device and no mesh shader here: the d3d12_mesh_test cases (the E_INVALIDARG set this change touches) were not run.

No game files: a stream is read from the caller's own description.

AI-assisted.

imShangLi and others added 3 commits December 2, 2026 02:03
…(RT-PSO-STREAM-EINVALIDARG-REASON)

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.
…PSO-STREAM-REFUSAL-REASON)

The reasons the pipeline state stream refusals carry are now the ones the log,
the trace and the console audit all read:

- the generic reason (a refusal of the graphics state itself) is left in
  d3d12_trace::stream_refusal, so the console audit prints it instead of "-";
- the console re-read of a stream keeps its reason out of the log: that reading
  may be discarded, and a stream that was built must not show a refusal;
- the classic CreateGraphicsPipelineState and CreateComputePipelineState paths
  clear the field, so no reason of one call is left behind for another;
- docs/d3d12_vulkan.md names the cases the stream's own refusals give and says
  that the graphics state's refusals keep one generic reason.

No HRESULT changes.
@merzleckeier

Copy link
Copy Markdown
Contributor

PSO diagnostic comparison on an RTX 4070 SUPER at 78518489 on main 7fbdf851 (Win64, Wine 11.22, host driver 620.73.04).

  • pso_stream_test passed on both builds. d3d12_mesh_test passed on both builds with and without --pc-stream-only. Each mesh run had nine E_INVALIDARG and two E_NOTIMPL refusal cases, and all 4,096 expected output pixels matched. Both console-numbered streams still created with fallback enabled and were refused in PC-only mode.
  • With LEONIDA_PSO_STREAM_AUDIT=1, the new reasons identified duplicate subobject families, truncated payload and missing shader stage in the stock negative cases. The formerly unlogged PC-only truncated case emitted hr=80070057 types=unwalked reason=the pipeline state stream ends inside a subobject payload.
  • In a small instrumented run, an actual amplification-shader refusal populated the thread-local reason. Null-description calls to the underlying device’s classic compute and graphics methods both still returned E_INVALIDARG. The prior reason remained on main and cleared for both methods on the PR. Both successful console fallback streams left an empty reason on both builds.

MEASURED with the repository’s synthetic fixtures. AI-assisted (Codex).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants