Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1797,6 +1797,16 @@ if(TARGET Vulkan::Headers)
add_test(NAME d3d12_close_parity COMMAND d3d12_close_parity_test)
set_tests_properties(d3d12_close_parity PROPERTIES SKIP_RETURN_CODE 77)

# ExecuteIndirect recording-time Close() parity against live WARP and hardware D3D12, plus GPU dispatch sanity.
add_executable(d3d12_execute_indirect_validation_test test/d3d12_execute_indirect_validation_test.cpp)
target_link_libraries(d3d12_execute_indirect_validation_test PRIVATE gta6rt_d3d12_com d3d12 dxgi)
target_compile_definitions(d3d12_execute_indirect_validation_test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX)
target_compile_options(d3d12_execute_indirect_validation_test PRIVATE /W4 /permissive- /utf-8)
add_test(NAME d3d12_execute_indirect_validation COMMAND d3d12_execute_indirect_validation_test)
set_tests_properties(d3d12_execute_indirect_validation PROPERTIES
SKIP_RETURN_CODE 77
FAIL_REGULAR_EXPRESSION "Validation Error;VUID-")

# Differential regression: run explicitly (requires Vulkan hardware and Windows WARP).
add_executable(d3d12_clear_test test/d3d12_clear_test.cpp)
target_link_libraries(d3d12_clear_test PRIVATE gta6rt_d3d12_com d3d12 dxgi)
Expand Down
23 changes: 23 additions & 0 deletions runtime/shims/d3d12_com.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,29 @@ class GraphicsCommandList final
UINT stride = 0;
if (!command_signature_info(signature, kind, stride) || !argument_buffer)
return check(false);
const auto arg_desc = argument_buffer->GetDesc();
if (arg_desc.Dimension != D3D12_RESOURCE_DIMENSION_BUFFER || argument_buffer_offset % 4 != 0)
return check(false);
if (count_buffer) {
const auto count_desc = count_buffer->GetDesc();
if (count_desc.Dimension != D3D12_RESOURCE_DIMENSION_BUFFER || count_buffer_offset % 4 != 0 ||
count_desc.Width < sizeof(UINT) || count_buffer_offset > count_desc.Width - sizeof(UINT))
return check(false);
} else if (count_buffer_offset != 0) {
return check(false);
}
if (max_command_count) {
const UINT64 record_size =
kind == leonida::IndirectKind::draw ? sizeof(D3D12_DRAW_ARGUMENTS)
: kind == leonida::IndirectKind::draw_indexed ? sizeof(D3D12_DRAW_INDEXED_ARGUMENTS)
: kind == leonida::IndirectKind::dispatch ? sizeof(D3D12_DISPATCH_ARGUMENTS)
: 0;
if (!record_size || stride < record_size || stride % 4 != 0)
return check(false);
const UINT64 required = UINT64(max_command_count - 1) * stride + record_size;
if (argument_buffer_offset > arg_desc.Width || arg_desc.Width - argument_buffer_offset < required)
return check(false);
}
leonida::ExecuteIndirect cmd{};
cmd.kind = kind;
cmd.stride = stride;
Expand Down
5 changes: 4 additions & 1 deletion runtime/src/command_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,10 @@ class CommandList {
}

bool execute_indirect(const ExecuteIndirect& indirect) {
if (!indirect.argument_buffer || !indirect.stride) return false;
if (!indirect.argument_buffer || !indirect.stride || indirect.stride % 4) return false;
if (indirect.argument_offset % 4) return false;
if (!indirect.count_buffer && indirect.count_offset) return false;
if (indirect.count_buffer && indirect.count_offset % 4) return false;
if (!indirect.max_count) return !closed_; // the PC runtime takes MaxCommandCount 0 as a no-op
return append(indirect);
}
Expand Down
Loading