diff options
| author | Dennis Schöneberg <schoenebergde@gmail.com> | 2026-11-23 18:07:42 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-11-23 11:07:42 -0600 |
| commit | 6adeaf0b25efcf04a275fd7a416865f2bafce89b (patch) | |
| tree | 2c82838ef081894555bc3938e78ac62009dc5d77 /runtime/shims/d3d12_com.cpp | |
| parent | 25e425a16a18269dea96e11b3a2873c34a5f9ed7 (diff) | |
Runtime: guard closed-list IA/OM/PSO state setters and expand D3D12 Close parity tests (#6644)
Squash-merged after diff review of PR #6644
Diffstat (limited to 'runtime/shims/d3d12_com.cpp')
| -rw-r--r-- | runtime/shims/d3d12_com.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/runtime/shims/d3d12_com.cpp b/runtime/shims/d3d12_com.cpp index 58ecb89ee..fa7f37af0 100644 --- a/runtime/shims/d3d12_com.cpp +++ b/runtime/shims/d3d12_com.cpp | |||
| @@ -250,6 +250,7 @@ public: | |||
| 250 | 250 | ||
| 251 | void STDMETHODCALLTYPE ExecuteBundle(ID3D12GraphicsCommandList* command_list) override { | 251 | void STDMETHODCALLTYPE ExecuteBundle(ID3D12GraphicsCommandList* command_list) override { |
| 252 | d3d12_trace::record("ID3D12GraphicsCommandList::ExecuteBundle"); | 252 | d3d12_trace::record("ID3D12GraphicsCommandList::ExecuteBundle"); |
| 253 | if (list_.closed()) return; | ||
| 253 | if (type_ != D3D12_COMMAND_LIST_TYPE_DIRECT) return check(false); | 254 | if (type_ != D3D12_COMMAND_LIST_TYPE_DIRECT) return check(false); |
| 254 | GraphicsCommandList* bundle = from(command_list); | 255 | GraphicsCommandList* bundle = from(command_list); |
| 255 | if (!bundle || bundle->type_ != D3D12_COMMAND_LIST_TYPE_BUNDLE || bundle->invalid_ || | 256 | if (!bundle || bundle->type_ != D3D12_COMMAND_LIST_TYPE_BUNDLE || bundle->invalid_ || |
| @@ -281,6 +282,7 @@ public: | |||
| 281 | 282 | ||
| 282 | void STDMETHODCALLTYPE SetPipelineState(ID3D12PipelineState* state) override { | 283 | void STDMETHODCALLTYPE SetPipelineState(ID3D12PipelineState* state) override { |
| 283 | d3d12_trace::record("ID3D12GraphicsCommandList::SetPipelineState"); | 284 | d3d12_trace::record("ID3D12GraphicsCommandList::SetPipelineState"); |
| 285 | if (list_.closed()) return; | ||
| 284 | if (defer([=](GraphicsCommandList& l) { l.set_pipeline(state); })) return hold(state); | 286 | if (defer([=](GraphicsCommandList& l) { l.set_pipeline(state); })) return hold(state); |
| 285 | set_pipeline(state); | 287 | set_pipeline(state); |
| 286 | } | 288 | } |
| @@ -369,12 +371,14 @@ public: | |||
| 369 | 371 | ||
| 370 | // ClearState returns every piece of list state to its default, as Reset does (stencil references included). | 372 | // ClearState returns every piece of list state to its default, as Reset does (stencil references included). |
| 371 | void STDMETHODCALLTYPE ClearState(ID3D12PipelineState* state) override { | 373 | void STDMETHODCALLTYPE ClearState(ID3D12PipelineState* state) override { |
| 374 | if (list_.closed()) return; | ||
| 372 | if (type_ == D3D12_COMMAND_LIST_TYPE_BUNDLE) return check(false); | 375 | if (type_ == D3D12_COMMAND_LIST_TYPE_BUNDLE) return check(false); |
| 373 | reset_state(state); | 376 | reset_state(state); |
| 374 | } | 377 | } |
| 375 | 378 | ||
| 376 | // Graphics state. Draws record a copy of it (command_list.h, Draw). | 379 | // Graphics state. Draws record a copy of it (command_list.h, Draw). |
| 377 | void STDMETHODCALLTYPE IASetPrimitiveTopology(D3D12_PRIMITIVE_TOPOLOGY topology) override { | 380 | void STDMETHODCALLTYPE IASetPrimitiveTopology(D3D12_PRIMITIVE_TOPOLOGY topology) override { |
| 381 | if (list_.closed()) return; | ||
| 378 | if (defer([=](GraphicsCommandList& l) { l.topology_ = u(topology); })) return; | 382 | if (defer([=](GraphicsCommandList& l) { l.topology_ = u(topology); })) return; |
| 379 | topology_ = u(topology); | 383 | topology_ = u(topology); |
| 380 | } | 384 | } |
| @@ -393,6 +397,7 @@ public: | |||
| 393 | } | 397 | } |
| 394 | 398 | ||
| 395 | void STDMETHODCALLTYPE IASetIndexBuffer(const D3D12_INDEX_BUFFER_VIEW* view) override { | 399 | void STDMETHODCALLTYPE IASetIndexBuffer(const D3D12_INDEX_BUFFER_VIEW* view) override { |
| 400 | if (list_.closed()) return; | ||
| 396 | const std::optional<D3D12_INDEX_BUFFER_VIEW> copy = view ? std::optional(*view) : std::nullopt; | 401 | const std::optional<D3D12_INDEX_BUFFER_VIEW> copy = view ? std::optional(*view) : std::nullopt; |
| 397 | if (defer([=](GraphicsCommandList& l) { l.set_index_buffer(copy ? &*copy : nullptr); })) return; | 402 | if (defer([=](GraphicsCommandList& l) { l.set_index_buffer(copy ? &*copy : nullptr); })) return; |
| 398 | set_index_buffer(view); | 403 | set_index_buffer(view); |
| @@ -440,6 +445,7 @@ public: | |||
| 440 | } | 445 | } |
| 441 | 446 | ||
| 442 | void STDMETHODCALLTYPE OMSetBlendFactor(const FLOAT factor[4]) override { | 447 | void STDMETHODCALLTYPE OMSetBlendFactor(const FLOAT factor[4]) override { |
| 448 | if (list_.closed()) return; | ||
| 443 | const std::array<float, 4> value = factor ? std::array<float, 4>{factor[0], factor[1], factor[2], factor[3]} | 449 | const std::array<float, 4> value = factor ? std::array<float, 4>{factor[0], factor[1], factor[2], factor[3]} |
| 444 | : std::array<float, 4>{1, 1, 1, 1}; // null means { 1, 1, 1, 1 } | 450 | : std::array<float, 4>{1, 1, 1, 1}; // null means { 1, 1, 1, 1 } |
| 445 | if (defer([=](GraphicsCommandList& l) { l.blend_factor_ = value; })) return; | 451 | if (defer([=](GraphicsCommandList& l) { l.blend_factor_ = value; })) return; |
| @@ -447,6 +453,7 @@ public: | |||
| 447 | } | 453 | } |
| 448 | 454 | ||
| 449 | void STDMETHODCALLTYPE OMSetStencilRef(UINT reference) override { | 455 | void STDMETHODCALLTYPE OMSetStencilRef(UINT reference) override { |
| 456 | if (list_.closed()) return; | ||
| 450 | if (defer([=](GraphicsCommandList& l) { l.front_stencil_ref_ = l.back_stencil_ref_ = reference; })) return; | 457 | if (defer([=](GraphicsCommandList& l) { l.front_stencil_ref_ = l.back_stencil_ref_ = reference; })) return; |
| 451 | front_stencil_ref_ = back_stencil_ref_ = reference; | 458 | front_stencil_ref_ = back_stencil_ref_ = reference; |
| 452 | } | 459 | } |