Add a non-shader-visible heap to D3D12ViewCreator for clearing UAVs

This commit is contained in:
Steve Karolewics
2020-02-04 00:48:00 -05:00
committed by Baldur Karlsson
parent da3bd8dbcb
commit bd04112dd4
4 changed files with 19 additions and 9 deletions
+3 -2
View File
@@ -376,8 +376,9 @@ D3D12TextureCreator::operator ID3D12ResourcePtr() const
}
D3D12ViewCreator::D3D12ViewCreator(D3D12GraphicsTest *test, ID3D12DescriptorHeap *heap,
ViewType viewType, ID3D12Resource *res)
: m_Test(test), m_Type(viewType), m_Heap(heap), m_Res(res)
ID3D12DescriptorHeap *clearHeap, ViewType viewType,
ID3D12Resource *res)
: m_Test(test), m_Type(viewType), m_Heap(heap), m_ClearHeap(clearHeap), m_Res(res)
{
D3D12_RESOURCE_DESC resdesc = res->GetDesc();
D3D12_RESOURCE_DIMENSION dim = resdesc.Dimension;
+7 -2
View File
@@ -170,8 +170,8 @@ protected:
class D3D12ViewCreator
{
public:
D3D12ViewCreator(D3D12GraphicsTest *test, ID3D12DescriptorHeap *heap, ViewType viewType,
ID3D12Resource *res);
D3D12ViewCreator(D3D12GraphicsTest *test, ID3D12DescriptorHeap *heap,
ID3D12DescriptorHeap *clearHeap, ViewType viewType, ID3D12Resource *res);
// common params
D3D12ViewCreator &Format(DXGI_FORMAT format);
@@ -209,6 +209,10 @@ public:
{
return CreateGPU(m_Heap, descriptor);
}
D3D12_CPU_DESCRIPTOR_HANDLE CreateClearCPU(uint32_t descriptor)
{
return CreateCPU(m_ClearHeap, descriptor);
}
private:
void SetupDescriptors(ViewType viewType, ResourceType resType);
@@ -216,6 +220,7 @@ private:
D3D12GraphicsTest *m_Test;
ID3D12Resource *m_Res;
ID3D12DescriptorHeap *m_Heap;
ID3D12DescriptorHeap *m_ClearHeap;
ViewType m_Type;
// instead of a huge mess trying to auto populate the actual descriptors from saved values, as
+4
View File
@@ -335,6 +335,10 @@ bool D3D12GraphicsTest::Init()
CHECK_HR(dev->CreateDescriptorHeap(&desc, __uuidof(ID3D12DescriptorHeap), (void **)&m_CBVUAVSRV));
m_CBVUAVSRV->SetName(L"CBV/UAV/SRV heap");
desc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE;
CHECK_HR(dev->CreateDescriptorHeap(&desc, __uuidof(ID3D12DescriptorHeap), (void **)&m_Clear));
m_CBVUAVSRV->SetName(L"UAV clear heap");
}
{
+5 -5
View File
@@ -107,22 +107,22 @@ struct D3D12GraphicsTest : public GraphicsTest
template <typename T>
D3D12ViewCreator MakeSRV(T res)
{
return D3D12ViewCreator(this, m_CBVUAVSRV, ViewType::SRV, res);
return D3D12ViewCreator(this, m_CBVUAVSRV, NULL, ViewType::SRV, res);
}
template <typename T>
D3D12ViewCreator MakeRTV(T res)
{
return D3D12ViewCreator(this, m_RTV, ViewType::RTV, res);
return D3D12ViewCreator(this, m_RTV, NULL, ViewType::RTV, res);
}
template <typename T>
D3D12ViewCreator MakeDSV(T res)
{
return D3D12ViewCreator(this, m_DSV, ViewType::DSV, res);
return D3D12ViewCreator(this, m_DSV, NULL, ViewType::DSV, res);
}
template <typename T>
D3D12ViewCreator MakeUAV(T res)
{
return D3D12ViewCreator(this, m_CBVUAVSRV, ViewType::UAV, res);
return D3D12ViewCreator(this, m_CBVUAVSRV, m_Clear, ViewType::UAV, res);
}
std::vector<byte> GetBufferData(ID3D12ResourcePtr buffer, D3D12_RESOURCE_STATES state,
@@ -201,7 +201,7 @@ struct D3D12GraphicsTest : public GraphicsTest
ID3D12DevicePtr dev;
ID3D12DescriptorHeapPtr m_RTV, m_DSV, m_CBVUAVSRV, m_Sampler;
ID3D12DescriptorHeapPtr m_RTV, m_DSV, m_CBVUAVSRV, m_Clear, m_Sampler;
ID3D12CommandAllocatorPtr m_Alloc;
ID3D12GraphicsCommandListPtr m_DebugList;