upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/shims/d3d12_com.cpp
diff options
context:
space:
mode:
authorDennis Schöneberg <schoenebergde@gmail.com>2026-11-23 16:53:12 +0100
committerGitHub <noreply@github.com>2026-11-23 09:53:12 -0600
commit9a9ca1ec14523c470fa7e87eea1b8a59f8f9fcea (patch)
tree3f895696a5e6d53e91070b7515bfc545c1d4b055 /runtime/shims/d3d12_com.cpp
parentc3f171d0cbaea1a5deed2e1fa2f9a69346863399 (diff)
d3d12: match Windows recording-time ExecuteIndirect validation (#6830)
Squash-merged after diff review of PR #6830 - d3d12: match Windows recording-time ExecuteIndirect validation
Diffstat (limited to 'runtime/shims/d3d12_com.cpp')
-rw-r--r--runtime/shims/d3d12_com.cpp23
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;