Repository navigation
d3d12: the deferred path reads console streams with the console's numbering (CONSOLE-STREAM-ON-DEMAND-REREAD) - #2292
Conversation
…bering (CONSOLE-STREAM-ON-DEMAND-REREAD) With LEONIDA_PIPELINE_COMPILE=on-demand every PSO from a console-numbered stream was refused with E_NOTIMPL: prepare_console_stream parsed the stream with PC numbering and returned before the console re-read CreatePipelineState does, so a console type 24 arrived as an AS. The record capture that follows had the same fault - it walked the stream as a PC one, found no console subobject and gave E_INVALIDARG, which is what the rasterizer subobject case hit. Both parsers now share one helper. It reads console-first where the stream is known to be the console's (the deferred entry point, which is handed console streams by Xbox CreatePipelineState) and keeps the PC-first rule elsewhere, so a PC stream is never read differently. The record is captured with the numbering that was actually taken, which is what slot 55 needs to derive from these PSOs. Test: the console-stream step of d3d12_mesh_test now runs under LEONIDA_PIPELINE_COMPILE=on-demand as its own ctest (d3d12_mesh_on_demand); on main it stops there with the refusal above.
74cad38 to
7d23021
Compare
lixonik
left a comment
There was a problem hiding this comment.
Reviewed and locally tested at 7d23021d6 (merged cleanly onto main ec91d695c).
Verification
- Environment: Windows 11, MSVC 19.44, NVIDIA GeForce RTX 5070 (driver 610.88, Vulkan 1.4.341;
VK_LAYER_KHRONOS_validationnot installed locally). ctest:pso_stream,d3d12_mesh,d3d12_mesh_on_demand, andd3d12_mesh_heavy_cacheall passed (4/4).scripts/check_no_game_data.pyandgit diff --check: clean.
Findings
- Found one thread-local state bug on the deferred (
prepare_console_stream) path:d3d12_xs::used_console_streamis not reset tofalsebeforeparse_console_or_pc_stream, so preparing a PC-numbered stream on the same thread after a console-numbered mesh PSO passes staleconsole = truetoPsoStreamRecord::capture()(details inline). Also noted a redundant console re-parse whenconsole_first == true.
AI-assisted.
| return E_INVALIDARG; | ||
| } | ||
| if(!record) record=rt::d3d12_xs::PsoStreamRecord::capture(source); | ||
| if(!record) record=rt::d3d12_xs::PsoStreamRecord::capture(source, d3d12_xs::used_console_stream); |
There was a problem hiding this comment.
d3d12_xs::used_console_stream is a thread_local bool (d3d12_xs_pso_stream.h:30), and in create_pso_from_stream() (d3d12_xs_device.cpp:6113-6116) the self->prepare_stream path returns before used_console_stream = false;. Because neither prepare_console_stream() nor parse_console_or_pc_stream() resets d3d12_xs::used_console_stream = false; on entry, once a thread prepares a console-numbered mesh PSO, used_console_stream stays true for subsequent PC-numbered PSOs on that thread.
On the next PC-numbered stream with record == nullptr, PsoStreamRecord::capture(source, true) shifts tags >= 23 via pc_stream_type(raw, true) (MS 25 --> DEPTH_STENCIL2 26, DEPTH_STENCIL2 26 --> RASTERIZER1 27, RASTERIZER1 27 --> RASTERIZER2 28, RASTERIZER2 28 --> unknown 29), causing PsoStreamRecord::walk() to fail and prepare_console_stream() to return E_INVALIDARG for a valid PC stream. d3d12_mesh_on_demand currently misses this because all valid PC-numbered streams in d3d12_mesh_test.cpp are created before the console-numbered loop.
Resetting d3d12_xs::used_console_stream = false; at the start of parse_console_or_pc_stream() (and adding a PC-numbered mesh/RASTERIZER2 creation check after the console loop in d3d12_mesh_test.cpp) would fix and cover this.
| } | ||
| } | ||
| const HRESULT parsed = parse_pipeline_stream(source, stream); | ||
| if (!(FAILED(parsed) || (stream.as.pShaderBytecode && !stream.ms.pShaderBytecode)) || |
There was a problem hiding this comment.
Minor: when console_first == true, if the initial console parse above did not match a console mesh stream and the fallback PC parse fails (or yields AS without MS), this block runs the exact same parse_pipeline_stream(source, console, true) a second time. Guarding this fallback block with if (console_first || ...) / skipping it when console_first is already true (and clearing d3d12_trace::stream_refusal = nullptr; before the PC parse at line 46 so a failed console_first probe cannot leave a stale refusal string on a successful PC parse) would keep both paths tidy.
With
LEONIDA_PIPELINE_COMPILE=on-demandevery PSO from a console-numbered stream is refused, and this is the switch a title with console PSOs needs.prepare_console_stream— the deferred entry point XboxCreatePipelineStateuses when a device prepares PSOs on bind — parsed the stream with PC numbering and returned before the console re-read that the eager path does, so a console type 24 arrived as an AS and answeredE_NOTIMPL. The record capture right after had the same fault one level down: it walked the stream as a PC one, found no console subobject and gaveE_INVALIDARG— the case the rasterizer subobject ind3d12_mesh_testhits.What changes:
parse_console_or_pc_stream, used by both entry points. The deferred one is handed console streams, so it reads console-first and falls back to the PC reading; the eager one keeps its existing PC-first rule, so a stream the PC reading accepts is never read differently.Out of scope but worth knowing:
on-demandalso exercises the depth-bounds extras path, so this and #2234 meet.Test — the existing console-stream step of
d3d12_mesh_testnow also runs under the switch, asd3d12_mesh_on_demand(new ctest). Onmainit stops atSUCCEEDED(console_hr)with the refusal; with this it passes, both console streams created, and the derived PSO through slot 55 still works.Run:
d3d12_meshandd3d12_mesh_on_demandboth pass here; the wider group (write_back,title_va,geometry_views,compute) passes.Item: CONSOLE-STREAM-ON-DEMAND-REREAD, claimed in #1608.