Repository navigation
d3d12: the deferred path reads console streams with the console's numbering (CONSOLE-STREAM-ON-DEMAND-REREAD) #2292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15331,13 +15331,52 @@ class Device final | |
| return shared_native_graphics(pc, mesh, containers, iid, out); | ||
| }); | ||
| } | ||
| // parse_pipeline_stream, plus the console re-read: a stream the PC reading refuses, or leaves with an AS and no MS | ||
| // (no valid PC stream), is read again with the console's numbering, and that reading is taken when it holds a mesh | ||
| // shader (its 24) and no AS. A stream the PC reading accepts as valid is never read differently. | ||
| // LEONIDA_XS_STREAM_ENUM=pc keeps the PC reading alone (such PSOs are then refused, as before). The eager path and | ||
| // the deferred one below both read through here: the deferred path is handed console-numbered streams, and used to | ||
| // parse them as PC ones alone, which refused every console PSO while a device prepared PSOs on bind. | ||
| HRESULT parse_console_or_pc_stream(const D3D12_PIPELINE_STATE_STREAM_DESC& source, PipelineStream& stream, | ||
| bool console_first = false) { | ||
| // The console entry points (Xbox CreatePipelineState, slot 86) are handed console-numbered streams: read those | ||
| // with the console's numbering first, and only fall back to the PC reading when that does not hold a mesh. | ||
| if (console_first && console_stream_enum_enabled()) { | ||
| PipelineStream console; | ||
| if (SUCCEEDED(parse_pipeline_stream(source, console, true)) && !console.as.pShaderBytecode && | ||
| is_mesh_container(console.ms)) { | ||
| log_once("console pipeline stream: type 24 contains a mesh shader; DXIL kind", 13); | ||
| d3d12_xs::used_console_stream = true; | ||
| d3d12_trace::stream_refusal = nullptr; | ||
| stream = console; | ||
| return S_OK; | ||
| } | ||
| } | ||
| const HRESULT parsed = parse_pipeline_stream(source, stream); | ||
| if (!(FAILED(parsed) || (stream.as.pShaderBytecode && !stream.ms.pShaderBytecode)) || | ||
| !console_stream_enum_enabled()) | ||
| return parsed; | ||
| const char* pc_reason = d3d12_trace::stream_refusal; | ||
| PipelineStream console; | ||
| if (SUCCEEDED(parse_pipeline_stream(source, console, true)) && !console.as.pShaderBytecode && | ||
| is_mesh_container(console.ms)) { | ||
| log_once("console pipeline stream: type 24 contains a mesh shader; DXIL kind", 13); | ||
| d3d12_xs::used_console_stream = true; | ||
| d3d12_trace::stream_refusal = nullptr; | ||
| stream = console; | ||
| return S_OK; | ||
| } | ||
| d3d12_trace::stream_refusal = pc_reason; | ||
| return parsed; | ||
| } | ||
|
|
||
| // A fresh public PSO has its own COM identity, private data and name. Equal native descriptions can | ||
| // hold one compiled backend PSO while either public object lives. The device only holds weak references. | ||
| HRESULT prepare_console_stream(const D3D12_PIPELINE_STATE_STREAM_DESC& source, REFIID iid, void** out, | ||
| std::unique_ptr<rt::d3d12_xs::PsoStreamRecord> record) { | ||
| if (!out)return E_POINTER;*out=nullptr; | ||
| PipelineStream stream{}; | ||
| if(const auto hr=parse_pipeline_stream(source,stream);FAILED(hr))return hr; | ||
| if(const auto hr=parse_console_or_pc_stream(source,stream,true);FAILED(hr))return hr; | ||
| const auto* library=state_.library();if(!library)return E_FAIL; | ||
| const auto verify=[&](const char* name,const D3D12_SHADER_BYTECODE& code) { | ||
| if(!code.BytecodeLength)return true; | ||
|
|
@@ -15359,9 +15398,10 @@ class Device final | |
| const auto& g=stream.graphics; | ||
| if(stream.as.BytecodeLength || g.HS.BytecodeLength || g.DS.BytecodeLength)return E_NOTIMPL; | ||
| if((bool(g.VS.BytecodeLength)==bool(stream.ms.BytecodeLength)) || g.NumRenderTargets>8 || | ||
| !verify("vs",g.VS)||!verify("gs",g.GS)||!verify("ms",stream.ms)||!verify("ps",g.PS))return E_INVALIDARG; | ||
| !verify("vs",g.VS)||!verify("gs",g.GS)||!verify("ms",stream.ms)||!verify("ps",g.PS)) | ||
| 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); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
On the next PC-numbered stream with Resetting |
||
| if(!record)return E_INVALIDARG; | ||
| auto* pipeline=new PipelineState(state_); | ||
| pipeline->attach_device(identity()); | ||
|
|
@@ -17580,26 +17620,7 @@ class Device final | |
| *out = nullptr; | ||
| if (!desc) return finish(E_INVALIDARG); | ||
| PipelineStream stream; | ||
| HRESULT parsed = parse_pipeline_stream(*desc, stream); | ||
| // A stream the PC reading refuses, or leaves with an AS and no MS (no valid PC stream), is read again with the | ||
| // console's numbering (parse_pipeline_stream), and that reading is taken when it holds a mesh shader (its 24) | ||
| // and no AS. A stream the PC reading accepts as valid is never read differently. LEONIDA_XS_STREAM_ENUM=pc | ||
| // keeps the PC reading alone (such PSOs are then refused, as before). | ||
| if ((FAILED(parsed) || (stream.as.pShaderBytecode && !stream.ms.pShaderBytecode)) && | ||
| console_stream_enum_enabled()) { | ||
| const char* pc_reason = d3d12_trace::stream_refusal; | ||
| PipelineStream console; | ||
| if (SUCCEEDED(parse_pipeline_stream(*desc, console, true)) && !console.as.pShaderBytecode && | ||
| is_mesh_container(console.ms)) { | ||
| log_once("console pipeline stream: type 24 contains a mesh shader; DXIL kind", 13); | ||
| d3d12_xs::used_console_stream = true; | ||
| d3d12_trace::stream_refusal = nullptr; | ||
| stream = console; | ||
| parsed = S_OK; | ||
| } else { | ||
| d3d12_trace::stream_refusal = pc_reason; | ||
| } | ||
| } | ||
| const HRESULT parsed = parse_console_or_pc_stream(*desc, stream); | ||
| if (FAILED(parsed)) return finish(parsed); | ||
| auto* pipeline = new PipelineState(state_); | ||
| pipeline->attach_device(identity()); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 sameparse_pipeline_stream(source, console, true)a second time. Guarding this fallback block withif (console_first || ...)/ skipping it whenconsole_firstis alreadytrue(and clearingd3d12_trace::stream_refusal = nullptr;before the PC parse at line 46 so a failedconsole_firstprobe cannot leave a stale refusal string on a successful PC parse) would keep both paths tidy.