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:
authorIAmNotSiob <273832158+IAmNotSiob@users.noreply.github.com>2026-11-22 17:31:21 +0100
committerIAmNotSiob <273832158+IAmNotSiob@users.noreply.github.com>2026-11-22 17:31:21 +0100
commit9b99a5f030cfd6c8bf96f0af2002dc939aa13b5b (patch)
tree3d2d0bfd501a978d00a12f755c8e5bc6eee12f32 /runtime/shims/d3d12_com.cpp
parentfaa42a61c5ffb24fe4046a5336102bba996872e7 (diff)
parent4eb6155d3ac4f9d3fadb0d095c4ce13e76783615 (diff)
Merge remote-tracking branch 'origin/main' into d3d12-queues-v2
# Conflicts: # runtime/test/vk_test_device.h
Diffstat (limited to 'runtime/shims/d3d12_com.cpp')
-rw-r--r--runtime/shims/d3d12_com.cpp45
1 files changed, 41 insertions, 4 deletions
diff --git a/runtime/shims/d3d12_com.cpp b/runtime/shims/d3d12_com.cpp
index 581bc0fa9..55c6f86a8 100644
--- a/runtime/shims/d3d12_com.cpp
+++ b/runtime/shims/d3d12_com.cpp
@@ -601,12 +601,17 @@ public:
601 cmd.argument_offset = argument_buffer_offset; 601 cmd.argument_offset = argument_buffer_offset;
602 cmd.count_buffer = count_buffer ? resource_id(count_buffer) : 0; 602 cmd.count_buffer = count_buffer ? resource_id(count_buffer) : 0;
603 cmd.count_offset = count_buffer ? count_buffer_offset : 0; 603 cmd.count_offset = count_buffer ? count_buffer_offset : 0;
604 if (kind == leonida::IndirectKind::dispatch && max_command_count) { // the pipeline and root arguments a Dispatch would record
605 if (!compute_pipeline_ || !compute_.layout) return check(false);
606 cmd.pipeline = compute_pipeline_;
607 cmd.user_data = compute_.data;
608 }
604 check(list_.execute_indirect(cmd)); 609 check(list_.execute_indirect(cmd));
605 } 610 }
606 611
607 void STDMETHODCALLTYPE BuildRaytracingAccelerationStructure( 612 void STDMETHODCALLTYPE BuildRaytracingAccelerationStructure(
608 const D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_DESC* desc, UINT, 613 const D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_DESC* desc, UINT postbuild_count,
609 const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC*) override { 614 const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC* postbuild) override {
610 if (type_ == D3D12_COMMAND_LIST_TYPE_BUNDLE || !desc) return check(false); 615 if (type_ == D3D12_COMMAND_LIST_TYPE_BUNDLE || !desc) return check(false);
611 const auto& in = desc->Inputs; 616 const auto& in = desc->Inputs;
612 leonida::BuildAccelerationStructure cmd{}; 617 leonida::BuildAccelerationStructure cmd{};
@@ -660,7 +665,38 @@ public:
660 cmd.triangles.push_back(t); 665 cmd.triangles.push_back(t);
661 } 666 }
662 } 667 }
663 check(list_.build_acceleration_structure(cmd)); 668 const std::uint64_t built = cmd.dst_va;
669 const bool recorded = list_.build_acceleration_structure(std::move(cmd));
670 check(recorded);
671 if (!recorded) return;
672 // The postbuild values of the structure just built, after it (D3D12 orders them after the build).
673 for (UINT i = 0; postbuild && i < postbuild_count; ++i) {
674 leonida::AccelerationStructurePostbuild info{};
675 info.dest_va = postbuild[i].DestBuffer;
676 info.type = static_cast<std::uint32_t>(postbuild[i].InfoType);
677 info.sources = {built};
678 const bool ok = list_.acceleration_structure_postbuild(std::move(info));
679 check(ok);
680 if (!ok) return;
681 }
682 }
683
684 void STDMETHODCALLTYPE EmitRaytracingAccelerationStructurePostbuildInfo(
685 const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC* desc, UINT count,
686 const D3D12_GPU_VIRTUAL_ADDRESS* sources) override {
687 if (type_ == D3D12_COMMAND_LIST_TYPE_BUNDLE || !desc || !count || !sources) return check(false);
688 leonida::AccelerationStructurePostbuild info{};
689 info.dest_va = desc->DestBuffer;
690 info.type = static_cast<std::uint32_t>(desc->InfoType);
691 info.sources.assign(sources, sources + count);
692 check(list_.acceleration_structure_postbuild(std::move(info)));
693 }
694
695 void STDMETHODCALLTYPE CopyRaytracingAccelerationStructure(D3D12_GPU_VIRTUAL_ADDRESS dest,
696 D3D12_GPU_VIRTUAL_ADDRESS source,
697 D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE mode) override {
698 if (type_ == D3D12_COMMAND_LIST_TYPE_BUNDLE) return check(false);
699 check(list_.copy_acceleration_structure({dest, source, static_cast<std::uint32_t>(mode)}));
664 } 700 }
665 701
666 static GraphicsCommandList* from(IUnknown* object) { return Child::from<GraphicsCommandList>(object); } 702 static GraphicsCommandList* from(IUnknown* object) { return Child::from<GraphicsCommandList>(object); }
@@ -1261,7 +1297,8 @@ HRESULT create_command_list(D3D12_COMMAND_LIST_TYPE type, ID3D12CommandAllocator
1261 if (!command_allocator || command_allocator->type() != type) return E_INVALIDARG; 1297 if (!command_allocator || command_allocator->type() != type) return E_INVALIDARG;
1262 // A list is created open, so the allocator must be free: E_INVALIDARG as on the PC runtime (D3D-51). 1298 // A list is created open, so the allocator must be free: E_INVALIDARG as on the PC runtime (D3D-51).
1263 if (command_allocator->recording()) return E_INVALIDARG; 1299 if (command_allocator->recording()) return E_INVALIDARG;
1264 if (type != D3D12_COMMAND_LIST_TYPE_DIRECT && type != D3D12_COMMAND_LIST_TYPE_BUNDLE) 1300 if (type != D3D12_COMMAND_LIST_TYPE_DIRECT && type != D3D12_COMMAND_LIST_TYPE_BUNDLE &&
1301 type != D3D12_COMMAND_LIST_TYPE_COMPUTE && type != D3D12_COMMAND_LIST_TYPE_COPY)
1265 stub("create_command_list(non-direct type)"); 1302 stub("create_command_list(non-direct type)");
1266 auto* object = new GraphicsCommandList(type); // created open, as D3D12 does 1303 auto* object = new GraphicsCommandList(type); // created open, as D3D12 does
1267 object->record_into(command_allocator); 1304 object->record_into(command_allocator);