summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineD3D12
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2019-02-12 05:26:06 +0000
committerEgor Yusov <egor.yusov@gmail.com>2019-02-12 05:26:06 +0000
commit17182a0e37b3b6a5c0fcca6696d83fb3d8b95ec5 (patch)
treef3c12d1cdf8875059e14a07bf936cc4ca4be432e /Graphics/GraphicsEngineD3D12
parentEnabled folders in main cmake file (diff)
downloadDiligentCore-17182a0e37b3b6a5c0fcca6696d83fb3d8b95ec5.tar.gz
DiligentCore-17182a0e37b3b6a5c0fcca6696d83fb3d8b95ec5.zip
Fixed issue in D3D12 backend: generate mips PSO was released while being used by the GPU
Diffstat (limited to 'Graphics/GraphicsEngineD3D12')
-rw-r--r--Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h3
-rw-r--r--Graphics/GraphicsEngineD3D12/include/GenerateMips.h4
-rw-r--r--Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.h6
-rw-r--r--Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp5
-rw-r--r--Graphics/GraphicsEngineD3D12/src/GenerateMips.cpp3
-rw-r--r--Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp3
6 files changed, 14 insertions, 10 deletions
diff --git a/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h
index 12a5bfa8..dfdfa760 100644
--- a/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h
+++ b/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h
@@ -31,7 +31,6 @@
#include "DeviceContextD3D12.h"
#include "DeviceContextBase.h"
#include "DeviceContextNextGenBase.h"
-#include "GenerateMips.h"
#include "BufferD3D12Impl.h"
#include "TextureD3D12Impl.h"
#include "PipelineStateD3D12Impl.h"
@@ -281,8 +280,6 @@ private:
CComPtr<ID3D12CommandSignature> m_pDrawIndexedIndirectSignature;
CComPtr<ID3D12CommandSignature> m_pDispatchIndirectSignature;
- GenerateMipsHelper m_MipsGenerator;
-
D3D12DynamicHeap m_DynamicHeap;
// Every context must use its own allocator that maintains individual list of retired descriptor heaps to
diff --git a/Graphics/GraphicsEngineD3D12/include/GenerateMips.h b/Graphics/GraphicsEngineD3D12/include/GenerateMips.h
index dc8400b2..8b35373a 100644
--- a/Graphics/GraphicsEngineD3D12/include/GenerateMips.h
+++ b/Graphics/GraphicsEngineD3D12/include/GenerateMips.h
@@ -50,9 +50,9 @@ namespace Diligent
class GenerateMipsHelper
{
public:
- GenerateMipsHelper(ID3D12Device *pd3d12Device);
+ GenerateMipsHelper(ID3D12Device* pd3d12Device);
- void GenerateMips(class RenderDeviceD3D12Impl *pRenderDeviceD3D12, class TextureViewD3D12Impl *pTexView, class CommandContext &Ctx)const;
+ void GenerateMips(ID3D12Device* pd3d12Device, class TextureViewD3D12Impl* pTexView, class CommandContext& Ctx)const;
private:
CComPtr<ID3D12RootSignature> m_pGenerateMipsRS;
diff --git a/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.h
index 3fe6b9f3..7f53cb26 100644
--- a/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.h
+++ b/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.h
@@ -34,6 +34,7 @@
#include "D3D12DynamicHeap.h"
#include "Atomics.h"
#include "CommandQueueD3D12.h"
+#include "GenerateMips.h"
namespace Diligent
{
@@ -98,6 +99,8 @@ public:
VERIFY_EXPR(Type == D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV || Type == D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER);
return m_GPUDescriptorHeaps[Type];
}
+
+ const GenerateMipsHelper& GetMipsGenerator()const {return m_MipsGenerator;}
private:
virtual void TestTextureFormat( TEXTURE_FORMAT TexFormat )override final;
@@ -120,6 +123,9 @@ private:
#endif
D3D12DynamicMemoryManager m_DynamicMemoryManager;
+
+ // Note: mips generator must be released after the device has been idled
+ GenerateMipsHelper m_MipsGenerator;
};
}
diff --git a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp
index 24f39e8d..83f93a83 100644
--- a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp
@@ -87,7 +87,6 @@ namespace Diligent
GetContextObjectName("SAMPLER dynamic descriptor allocator", bIsDeferred, ContextId)
}
},
- m_MipsGenerator(pDeviceD3D12Impl->GetD3D12Device()),
m_CmdListAllocator(GetRawAllocator(), sizeof(CommandListD3D12Impl), 64 )
{
RequestCommandContext(pDeviceD3D12Impl);
@@ -1412,7 +1411,9 @@ namespace Diligent
{
TDeviceContextBase::GenerateMips(pTexView);
auto& Ctx = GetCmdContext();
- m_MipsGenerator.GenerateMips(m_pDevice.RawPtr<RenderDeviceD3D12Impl>(), ValidatedCast<TextureViewD3D12Impl>(pTexView), Ctx);
+ auto& DeviceD3D12Impl = *m_pDevice.RawPtr<RenderDeviceD3D12Impl>();
+ const auto& MipsGenerator = DeviceD3D12Impl.GetMipsGenerator();
+ MipsGenerator.GenerateMips(DeviceD3D12Impl.GetD3D12Device(), ValidatedCast<TextureViewD3D12Impl>(pTexView), Ctx);
++m_State.NumCommands;
}
diff --git a/Graphics/GraphicsEngineD3D12/src/GenerateMips.cpp b/Graphics/GraphicsEngineD3D12/src/GenerateMips.cpp
index 98e1393e..48e9155d 100644
--- a/Graphics/GraphicsEngineD3D12/src/GenerateMips.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/GenerateMips.cpp
@@ -103,7 +103,7 @@ namespace Diligent
CreatePSO(m_pGenerateMipsGammaPSO[3], g_pGenerateMipsGammaOddCS);
}
- void GenerateMipsHelper::GenerateMips(RenderDeviceD3D12Impl* pRenderDeviceD3D12, TextureViewD3D12Impl* pTexView, CommandContext& Ctx)const
+ void GenerateMipsHelper::GenerateMips(ID3D12Device* pd3d12Device, TextureViewD3D12Impl* pTexView, CommandContext& Ctx)const
{
auto& ComputeCtx = Ctx.AsComputeContext();
ComputeCtx.SetRootSignature(m_pGenerateMipsRS);
@@ -120,7 +120,6 @@ namespace Diligent
if (pTexD3D12->IsInKnownState() && !pTexD3D12->CheckState(RESOURCE_STATE_UNORDERED_ACCESS))
Ctx.TransitionResource(pTexD3D12, RESOURCE_STATE_UNORDERED_ACCESS);
- auto* pd3d12Device = pRenderDeviceD3D12->GetD3D12Device();
const auto &ViewDesc = pTexView->GetDesc();
for (uint32_t TopMip = 0; TopMip < TexDesc.MipLevels - 1; )
diff --git a/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp
index 3d73cbdb..202b729a 100644
--- a/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp
@@ -77,7 +77,8 @@ RenderDeviceD3D12Impl :: RenderDeviceD3D12Impl(IReferenceCounters* pRef
{RawMemAllocator, *this, CreationAttribs.GPUDescriptorHeapSize[1], CreationAttribs.GPUDescriptorHeapDynamicSize[1], D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER, D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE}
},
m_ContextPool(STD_ALLOCATOR_RAW_MEM(PooledCommandContext, GetRawAllocator(), "Allocator for vector<PooledCommandContext>")),
- m_DynamicMemoryManager(GetRawAllocator(), *this, CreationAttribs.NumDynamicHeapPagesToReserve, CreationAttribs.DynamicHeapPageSize)
+ m_DynamicMemoryManager(GetRawAllocator(), *this, CreationAttribs.NumDynamicHeapPagesToReserve, CreationAttribs.DynamicHeapPageSize),
+ m_MipsGenerator(pd3d12Device)
{
m_DeviceCaps.DevType = DeviceType::D3D12;
m_DeviceCaps.MajorVersion = 12;