diff options
| author | azhirnov <zh1dron@gmail.com> | 2020-08-19 16:02:51 +0000 |
|---|---|---|
| committer | azhirnov <zh1dron@gmail.com> | 2020-08-19 16:02:51 +0000 |
| commit | 21bbe1048df82015c28ff22a1a7250daa48f397c (patch) | |
| tree | ff044781909ed7cb43f3f72911ce60978431bf4e /Graphics/GraphicsEngineD3D12 | |
| parent | Added tests for mesh and amplification shaders (diff) | |
| download | DiligentCore-21bbe1048df82015c28ff22a1a7250daa48f397c.tar.gz DiligentCore-21bbe1048df82015c28ff22a1a7250daa48f397c.zip | |
Cache pointers to ID3D12GraphicsCommandList6 and ID3D12Device2
Diffstat (limited to 'Graphics/GraphicsEngineD3D12')
4 files changed, 33 insertions, 10 deletions
diff --git a/Graphics/GraphicsEngineD3D12/include/CommandContext.hpp b/Graphics/GraphicsEngineD3D12/include/CommandContext.hpp index 5723979e..a405ea80 100644 --- a/Graphics/GraphicsEngineD3D12/include/CommandContext.hpp +++ b/Graphics/GraphicsEngineD3D12/include/CommandContext.hpp @@ -227,6 +227,10 @@ protected: String m_ID; D3D12_PRIMITIVE_TOPOLOGY m_PrimitiveTopology = D3D_PRIMITIVE_TOPOLOGY_UNDEFINED; + +#ifdef D12_H_HAS_MESH_SHADER + CComPtr<ID3D12GraphicsCommandList6> m_pCommandList6; +#endif }; @@ -363,9 +367,14 @@ public: { #ifdef D12_H_HAS_MESH_SHADER FlushResourceBarriers(); - CComPtr<ID3D12GraphicsCommandList6> CmdList; - if (SUCCEEDED(m_pCommandList->QueryInterface(__uuidof(CmdList), reinterpret_cast<void**>(&CmdList)))) - CmdList->DispatchMesh(ThreadGroupCountX, ThreadGroupCountY, ThreadGroupCountZ); + + if (!m_pCommandList6) + { + CHECK_D3D_RESULT_THROW(m_pCommandList->QueryInterface(IID_PPV_ARGS(&m_pCommandList6)), + "Failed to get ID3D12GraphicsCommandList6, can't call DrawMesh()"); + } + + m_pCommandList6->DispatchMesh(ThreadGroupCountX, ThreadGroupCountY, ThreadGroupCountZ); #else UNSUPPORTED("DrawMesh is not supported in current D3D12 header"); #endif diff --git a/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.hpp b/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.hpp index 59089ffb..b6cd4280 100644 --- a/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.hpp +++ b/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.hpp @@ -151,6 +151,10 @@ public: const GenerateMipsHelper& GetMipsGenerator() const { return m_MipsGenerator; } QueryManagerD3D12& GetQueryManager() { return m_QueryMgr; } +#ifdef D12_H_HAS_MESH_SHADER + ID3D12Device2* GetD3D12Device2(); +#endif + D3D_SHADER_MODEL GetShaderModel() const; D3D_FEATURE_LEVEL GetD3DFeatureLevel() const; @@ -160,6 +164,10 @@ private: CComPtr<ID3D12Device> m_pd3d12Device; +#ifdef D12_H_HAS_MESH_SHADER + CComPtr<ID3D12Device2> m_pd3d12Device2; +#endif + EngineD3D12CreateInfo m_EngineAttribs; CPUDescriptorHeap m_CPUDescriptorHeaps[D3D12_DESCRIPTOR_HEAP_TYPE_NUM_TYPES]; diff --git a/Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp index dc75131e..481027c0 100644 --- a/Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp @@ -390,14 +390,9 @@ PipelineStateD3D12Impl::PipelineStateD3D12Impl(IReferenceCounters* pR streamDesc.SizeInBytes = sizeof(d3d12PSODesc); streamDesc.pPipelineStateSubobjectStream = &d3d12PSODesc; - CComPtr<ID3D12Device2> device2; - HRESULT hr = pd3d12Device->QueryInterface(IID_PPV_ARGS(&device2)); - if (FAILED(hr)) - LOG_ERROR_AND_THROW("Failed to get ID3D12Device2"); + auto* device2 = pDeviceD3D12->GetD3D12Device2(); - hr = device2->CreatePipelineState(&streamDesc, IID_PPV_ARGS(&m_pd3d12PSO)); - if (FAILED(hr)) - LOG_ERROR_AND_THROW("Failed to create pipeline state"); + CHECK_D3D_RESULT_THROW(device2->CreatePipelineState(&streamDesc, IID_PPV_ARGS(&m_pd3d12PSO)), "Failed to create pipeline state"); break; } #endif // D12_H_HAS_MESH_SHADER diff --git a/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp index 8b0b05eb..445458e2 100644 --- a/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp @@ -109,6 +109,17 @@ D3D_FEATURE_LEVEL RenderDeviceD3D12Impl::GetD3DFeatureLevel() const return FeatureLevelsData.MaxSupportedFeatureLevel; } +#ifdef D12_H_HAS_MESH_SHADER +ID3D12Device2* RenderDeviceD3D12Impl::GetD3D12Device2() +{ + if (!m_pd3d12Device2) + { + CHECK_D3D_RESULT_THROW(m_pd3d12Device->QueryInterface(IID_PPV_ARGS(&m_pd3d12Device2)), "Failed to get ID3D12Device2"); + } + return m_pd3d12Device2; +} +#endif + RenderDeviceD3D12Impl::RenderDeviceD3D12Impl(IReferenceCounters* pRefCounters, IMemoryAllocator& RawMemAllocator, IEngineFactory* pEngineFactory, |
