diff options
Diffstat (limited to 'runtime/shims/d3d12_com.cpp')
| -rw-r--r-- | runtime/shims/d3d12_com.cpp | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/runtime/shims/d3d12_com.cpp b/runtime/shims/d3d12_com.cpp index f25168a2a..c89aecc86 100644 --- a/runtime/shims/d3d12_com.cpp +++ b/runtime/shims/d3d12_com.cpp | |||
| @@ -834,18 +834,19 @@ public: | |||
| 834 | } else if (count_buffer_offset != 0) { | 834 | } else if (count_buffer_offset != 0) { |
| 835 | return check(false); | 835 | return check(false); |
| 836 | } | 836 | } |
| 837 | if (max_command_count) { | 837 | // The record size is checked for every call: D3D12 rejects a signature whose stride cannot hold a record |
| 838 | const UINT64 record_size = | 838 | // even when no command runs. The argument span is what the signature can walk, max_command_count * stride: |
| 839 | kind == leonida::IndirectKind::draw ? sizeof(D3D12_DRAW_ARGUMENTS) | 839 | // the host refuses a range that ends past the buffer (`240` with stride `20` in a `256`-byte buffer), and |
| 840 | : kind == leonida::IndirectKind::draw_indexed ? sizeof(D3D12_DRAW_INDEXED_ARGUMENTS) | 840 | // it checks the offset itself when max_command_count is 0, where the required bytes are none. |
| 841 | : kind == leonida::IndirectKind::dispatch ? sizeof(D3D12_DISPATCH_ARGUMENTS) | 841 | const UINT64 record_size = |
| 842 | : 0; | 842 | kind == leonida::IndirectKind::draw ? sizeof(D3D12_DRAW_ARGUMENTS) |
| 843 | if (!record_size || stride < record_size || stride % 4 != 0) | 843 | : kind == leonida::IndirectKind::draw_indexed ? sizeof(D3D12_DRAW_INDEXED_ARGUMENTS) |
| 844 | return check(false); | 844 | : kind == leonida::IndirectKind::dispatch ? sizeof(D3D12_DISPATCH_ARGUMENTS) |
| 845 | const UINT64 required = UINT64(max_command_count - 1) * stride + record_size; | 845 | : 0; |
| 846 | if (argument_buffer_offset > arg_desc.Width || arg_desc.Width - argument_buffer_offset < required) | 846 | if (!record_size || stride < record_size || stride % 4 != 0) return check(false); |
| 847 | return check(false); | 847 | if (argument_buffer_offset > arg_desc.Width || |
| 848 | } | 848 | UINT64(max_command_count) > (arg_desc.Width - argument_buffer_offset) / stride) |
| 849 | return check(false); | ||
| 849 | leonida::ExecuteIndirect cmd{}; | 850 | leonida::ExecuteIndirect cmd{}; |
| 850 | cmd.kind = kind; | 851 | cmd.kind = kind; |
| 851 | cmd.stride = stride; | 852 | cmd.stride = stride; |