diff --git a/Engine/gapi/directx12/dxcommandbuffer.cpp b/Engine/gapi/directx12/dxcommandbuffer.cpp index 27f3d8e5..1de8b138 100644 --- a/Engine/gapi/directx12/dxcommandbuffer.cpp +++ b/Engine/gapi/directx12/dxcommandbuffer.cpp @@ -490,7 +490,7 @@ void DxCommandBuffer::beginRendering(const AttachmentDesc* desc, size_t descSize impl->RSSetScissorRects(1, &sr); } -void Tempest::Detail::DxCommandBuffer::endRendering() { +void DxCommandBuffer::endRendering() { impl->EndRenderPass(); } @@ -683,6 +683,16 @@ void DxCommandBuffer::dispatchMesh(size_t x, size_t y, size_t z) { impl->DispatchMesh(UINT(x),UINT(y),UINT(z)); } +void DxCommandBuffer::dispatchMeshIndirect(const AbstractGraphicsApi::Buffer& indirect, size_t offset) { + const DxBuffer& ind = reinterpret_cast(indirect); + auto& sign = dev.drawMeshIndirectSgn.get(); + + // block future writers + resState.onUavUsage(ind.nonUniqId, NonUniqResId::I_None, PipelineStage::S_Graphics); + + impl->ExecuteIndirect(sign, 1, ind.impl.get(), UINT64(offset), nullptr, 0); + } + void DxCommandBuffer::copy(AbstractGraphicsApi::Buffer& dstBuf, size_t offsetDest, const AbstractGraphicsApi::Buffer& srcBuf, size_t offsetSrc, size_t size) { auto& dst = reinterpret_cast(dstBuf); auto& src = reinterpret_cast(srcBuf); diff --git a/Engine/gapi/directx12/dxcommandbuffer.h b/Engine/gapi/directx12/dxcommandbuffer.h index d5f40658..88c8eb4e 100644 --- a/Engine/gapi/directx12/dxcommandbuffer.h +++ b/Engine/gapi/directx12/dxcommandbuffer.h @@ -68,6 +68,8 @@ class DxCommandBuffer:public AbstractGraphicsApi::CommandBuffer { void drawIndirect(const AbstractGraphicsApi::Buffer& indirect, size_t offset) override; void dispatchMesh(size_t x, size_t y, size_t z) override; + void dispatchMeshIndirect(const AbstractGraphicsApi::Buffer& indirect, size_t offset) override; + void dispatch (size_t x, size_t y, size_t z) override; void barrier (const AbstractGraphicsApi::BarrierDesc* desc, size_t cnt) override; diff --git a/Engine/gapi/directx12/dxdevice.cpp b/Engine/gapi/directx12/dxdevice.cpp index 38b9393f..fcfc388c 100644 --- a/Engine/gapi/directx12/dxdevice.cpp +++ b/Engine/gapi/directx12/dxdevice.cpp @@ -53,15 +53,17 @@ DxDevice::DxDevice(IDXGIAdapter1& adapter, const ApiEntry& dllApi) dxAssert(device->CreateCommandQueue(&queueDesc, uuid(), reinterpret_cast(&cmdQueue))); { - D3D12_INDIRECT_ARGUMENT_DESC args[1] = {}; - args[0].Type = D3D12_INDIRECT_ARGUMENT_TYPE_DRAW; + D3D12_INDIRECT_ARGUMENT_DESC arg = {}; + D3D12_COMMAND_SIGNATURE_DESC desc = {}; + desc.ByteStride = sizeof(D3D12_DRAW_ARGUMENTS); + desc.NumArgumentDescs = 1; + desc.pArgumentDescs = &arg; - D3D12_COMMAND_SIGNATURE_DESC desc = {}; - desc.ByteStride = sizeof(D3D12_DRAW_ARGUMENTS); - desc.NumArgumentDescs = 1; - desc.pArgumentDescs = args; + arg.Type = D3D12_INDIRECT_ARGUMENT_TYPE_DRAW; + dxAssert(device->CreateCommandSignature(&desc, nullptr, uuid(), reinterpret_cast(&drawIndirectSgn))); - dxAssert(device->CreateCommandSignature(&desc, nullptr, uuid(), reinterpret_cast(&drawIndirectSgn))); + arg.Type = D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH_MESH; + dxAssert(device->CreateCommandSignature(&desc, nullptr, uuid(), reinterpret_cast(&drawMeshIndirectSgn))); } allocator.setDevice(*this); diff --git a/Engine/gapi/directx12/dxdevice.h b/Engine/gapi/directx12/dxdevice.h index 82ac3825..8d4f48e1 100644 --- a/Engine/gapi/directx12/dxdevice.h +++ b/Engine/gapi/directx12/dxdevice.h @@ -334,6 +334,7 @@ class DxDevice : public AbstractGraphicsApi::Device { ComPtr cmdQueue; ComPtr drawIndirectSgn; + ComPtr drawMeshIndirectSgn; DxAllocator allocator; DxDescriptorAllocator descAlloc; diff --git a/Engine/gapi/directx12/guid.h b/Engine/gapi/directx12/guid.h index aacf4c07..129e703e 100644 --- a/Engine/gapi/directx12/guid.h +++ b/Engine/gapi/directx12/guid.h @@ -95,6 +95,11 @@ inline GUID uuid(){ return GUID{0xC3827890, 0xE548, 0x4CFA, {0x96,0xcf,0x56,0x89,0xa9,0x37,0x0f,0x80}}; } +template<> +inline GUID uuid(){ + return GUID{0xDD171223, 0x8B61, 0x4769, {0x90,0xe3,0x16,0x0c,0xcd,0xe4,0xe2,0xc1}}; + } + template<> inline GUID uuid(){ return GUID{0x8EFB471D, 0x616C, 0x4F49, {0x90,0xf7,0x12,0x7b,0xb7,0x63,0xfa,0x51}};