diff options
| author | Dennis Schöneberg <schoenebergde@gmail.com> | 2026-11-23 18:16:29 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-11-23 11:16:29 -0600 |
| commit | 4da716493f84018e16b80618cfad9fa45167f464 (patch) | |
| tree | b12ed8c8d9b58936bbd0ca0fea402578a99a2def /runtime/shims/d3d12_com.cpp | |
| parent | 7deb162b04e99271febefb63195835294f325602 (diff) | |
d3d12: reject null arrays and invalid lists in ExecuteCommandLists (#6610)
Squash-merged after diff review of PR #6610
Diffstat (limited to 'runtime/shims/d3d12_com.cpp')
| -rw-r--r-- | runtime/shims/d3d12_com.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/runtime/shims/d3d12_com.cpp b/runtime/shims/d3d12_com.cpp index fa7f37af0..e33769c58 100644 --- a/runtime/shims/d3d12_com.cpp +++ b/runtime/shims/d3d12_com.cpp | |||
| @@ -210,6 +210,7 @@ public: | |||
| 210 | return type_; | 210 | return type_; |
| 211 | } | 211 | } |
| 212 | D3D12_COMMAND_LIST_TYPE type() const { return type_; } | 212 | D3D12_COMMAND_LIST_TYPE type() const { return type_; } |
| 213 | bool invalid() const { return invalid_; } | ||
| 213 | 214 | ||
| 214 | // E_INVALIDARG when a call during recording was invalid, or a query was begun and not ended, as D3D12's Close | 215 | // E_INVALIDARG when a call during recording was invalid, or a query was begun and not ended, as D3D12's Close |
| 215 | // reports it. | 216 | // reports it. |
| @@ -1520,6 +1521,12 @@ public: | |||
| 1520 | void STDMETHODCALLTYPE ExecuteCommandLists(UINT count, ID3D12CommandList* const* lists) override { | 1521 | void STDMETHODCALLTYPE ExecuteCommandLists(UINT count, ID3D12CommandList* const* lists) override { |
| 1521 | constexpr auto method = "ID3D12CommandQueue::ExecuteCommandLists"; | 1522 | constexpr auto method = "ID3D12CommandQueue::ExecuteCommandLists"; |
| 1522 | std::lock_guard lock(mutex_); | 1523 | std::lock_guard lock(mutex_); |
| 1524 | if (count > 0 && !lists) { | ||
| 1525 | note_once("ExecuteCommandLists: null command list array with non-zero count"); | ||
| 1526 | last_result_ = leonida::ReplayResult::unsupported; | ||
| 1527 | d3d12_trace::record(method, "failed"); | ||
| 1528 | return; | ||
| 1529 | } | ||
| 1523 | std::vector<const leonida::CommandList*> recorded; | 1530 | std::vector<const leonida::CommandList*> recorded; |
| 1524 | std::vector<const GraphicsCommandList*> graphics; | 1531 | std::vector<const GraphicsCommandList*> graphics; |
| 1525 | for (UINT i = 0; i < count; ++i) { | 1532 | for (UINT i = 0; i < count; ++i) { |
| @@ -1540,6 +1547,13 @@ public: | |||
| 1540 | d3d12_trace::record(method, "failed"); | 1547 | d3d12_trace::record(method, "failed"); |
| 1541 | return; | 1548 | return; |
| 1542 | } | 1549 | } |
| 1550 | // A list whose recording failed (Close returned E_INVALIDARG) must not replay its earlier commands. | ||
| 1551 | if (list->invalid()) { | ||
| 1552 | std::fprintf(stderr, "[rt] d3d12: ExecuteCommandLists: list %u is invalid; refusing batch\n", i); | ||
| 1553 | last_result_ = leonida::ReplayResult::unsupported; | ||
| 1554 | d3d12_trace::record(method, "failed"); | ||
| 1555 | return; | ||
| 1556 | } | ||
| 1543 | if (!timestamps_fit(*list)) { | 1557 | if (!timestamps_fit(*list)) { |
| 1544 | last_result_ = leonida::ReplayResult::invalid_query; | 1558 | last_result_ = leonida::ReplayResult::invalid_query; |
| 1545 | d3d12_trace::record(method, "failed"); | 1559 | d3d12_trace::record(method, "failed"); |