diff options
Diffstat (limited to 'runtime/shims/d3d12_com.cpp')
| -rw-r--r-- | runtime/shims/d3d12_com.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/runtime/shims/d3d12_com.cpp b/runtime/shims/d3d12_com.cpp index d66e6803c..4dd766b31 100644 --- a/runtime/shims/d3d12_com.cpp +++ b/runtime/shims/d3d12_com.cpp | |||
| @@ -764,6 +764,29 @@ public: | |||
| 764 | UINT stride = 0; | 764 | UINT stride = 0; |
| 765 | if (!command_signature_info(signature, kind, stride) || !argument_buffer) | 765 | if (!command_signature_info(signature, kind, stride) || !argument_buffer) |
| 766 | return check(false); | 766 | return check(false); |
| 767 | const auto arg_desc = argument_buffer->GetDesc(); | ||
| 768 | if (arg_desc.Dimension != D3D12_RESOURCE_DIMENSION_BUFFER || argument_buffer_offset % 4 != 0) | ||
| 769 | return check(false); | ||
| 770 | if (count_buffer) { | ||
| 771 | const auto count_desc = count_buffer->GetDesc(); | ||
| 772 | if (count_desc.Dimension != D3D12_RESOURCE_DIMENSION_BUFFER || count_buffer_offset % 4 != 0 || | ||
| 773 | count_desc.Width < sizeof(UINT) || count_buffer_offset > count_desc.Width - sizeof(UINT)) | ||
| 774 | return check(false); | ||
| 775 | } else if (count_buffer_offset != 0) { | ||
| 776 | return check(false); | ||
| 777 | } | ||
| 778 | if (max_command_count) { | ||
| 779 | const UINT64 record_size = | ||
| 780 | kind == leonida::IndirectKind::draw ? sizeof(D3D12_DRAW_ARGUMENTS) | ||
| 781 | : kind == leonida::IndirectKind::draw_indexed ? sizeof(D3D12_DRAW_INDEXED_ARGUMENTS) | ||
| 782 | : kind == leonida::IndirectKind::dispatch ? sizeof(D3D12_DISPATCH_ARGUMENTS) | ||
| 783 | : 0; | ||
| 784 | if (!record_size || stride < record_size || stride % 4 != 0) | ||
| 785 | return check(false); | ||
| 786 | const UINT64 required = UINT64(max_command_count - 1) * stride + record_size; | ||
| 787 | if (argument_buffer_offset > arg_desc.Width || arg_desc.Width - argument_buffer_offset < required) | ||
| 788 | return check(false); | ||
| 789 | } | ||
| 767 | leonida::ExecuteIndirect cmd{}; | 790 | leonida::ExecuteIndirect cmd{}; |
| 768 | cmd.kind = kind; | 791 | cmd.kind = kind; |
| 769 | cmd.stride = stride; | 792 | cmd.stride = stride; |