mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-08-23 15:06:32 +00:00
Add CBV support to D3D12ViewCreator
This commit is contained in:
committed by
Baldur Karlsson
parent
fe30fa91fb
commit
ad69e791ad
@@ -385,7 +385,12 @@ D3D12ViewCreator::D3D12ViewCreator(D3D12GraphicsTest *test, ID3D12DescriptorHeap
|
||||
|
||||
Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
|
||||
|
||||
if(dim == D3D12_RESOURCE_DIMENSION_BUFFER)
|
||||
if(m_Type == ViewType::CBV)
|
||||
{
|
||||
desc.cbv.BufferLocation = m_Res->GetGPUVirtualAddress();
|
||||
desc.cbv.SizeInBytes = 0;
|
||||
}
|
||||
else if(dim == D3D12_RESOURCE_DIMENSION_BUFFER)
|
||||
{
|
||||
SetupDescriptors(viewType, ResourceType::Buffer);
|
||||
}
|
||||
@@ -665,6 +670,24 @@ D3D12ViewCreator &D3D12ViewCreator::Format(DXGI_FORMAT f)
|
||||
return *this;
|
||||
}
|
||||
|
||||
D3D12ViewCreator &D3D12ViewCreator::Offset(UINT offset)
|
||||
{
|
||||
if(m_Type == ViewType::CBV)
|
||||
desc.cbv.BufferLocation += offset;
|
||||
else
|
||||
TEST_ERROR("This view & resource doesn't support SizeBytes");
|
||||
return *this;
|
||||
}
|
||||
|
||||
D3D12ViewCreator &D3D12ViewCreator::SizeBytes(UINT size)
|
||||
{
|
||||
if(m_Type == ViewType::CBV)
|
||||
desc.cbv.SizeInBytes = size;
|
||||
else
|
||||
TEST_ERROR("This view & resource doesn't support SizeBytes");
|
||||
return *this;
|
||||
}
|
||||
|
||||
D3D12ViewCreator &D3D12ViewCreator::FirstElement(UINT el)
|
||||
{
|
||||
if(firstElement)
|
||||
@@ -780,6 +803,11 @@ D3D12_CPU_DESCRIPTOR_HANDLE D3D12ViewCreator::CreateCPU(ID3D12DescriptorHeap *he
|
||||
cpu.ptr += increment[D3D12_DESCRIPTOR_HEAP_TYPE_RTV] * descriptor;
|
||||
m_Test->dev->CreateRenderTargetView(m_Res, &desc.rtv, cpu);
|
||||
}
|
||||
else if(m_Type == ViewType::CBV)
|
||||
{
|
||||
cpu.ptr += increment[D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV] * descriptor;
|
||||
m_Test->dev->CreateConstantBufferView(&desc.cbv, cpu);
|
||||
}
|
||||
else if(m_Type == ViewType::SRV)
|
||||
{
|
||||
if(desc.uav.ViewDimension == D3D12_SRV_DIMENSION_BUFFER)
|
||||
|
||||
@@ -178,6 +178,10 @@ public:
|
||||
// common params
|
||||
D3D12ViewCreator &Format(DXGI_FORMAT format);
|
||||
|
||||
// cbv params
|
||||
D3D12ViewCreator &Offset(UINT offset);
|
||||
D3D12ViewCreator &SizeBytes(UINT size);
|
||||
|
||||
// buffer params
|
||||
D3D12ViewCreator &FirstElement(UINT el);
|
||||
D3D12ViewCreator &NumElements(UINT num);
|
||||
@@ -232,6 +236,7 @@ private:
|
||||
// resource type
|
||||
union
|
||||
{
|
||||
D3D12_CONSTANT_BUFFER_VIEW_DESC cbv;
|
||||
D3D12_SHADER_RESOURCE_VIEW_DESC srv;
|
||||
D3D12_RENDER_TARGET_VIEW_DESC rtv;
|
||||
D3D12_DEPTH_STENCIL_VIEW_DESC dsv;
|
||||
|
||||
@@ -104,6 +104,11 @@ struct D3D12GraphicsTest : public GraphicsTest
|
||||
return D3D12TextureCreator(this, format, width, height, depth);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
D3D12ViewCreator MakeCBV(T res)
|
||||
{
|
||||
return D3D12ViewCreator(this, m_CBVUAVSRV, NULL, ViewType::CBV, res);
|
||||
}
|
||||
template <typename T>
|
||||
D3D12ViewCreator MakeSRV(T res)
|
||||
{
|
||||
|
||||
@@ -65,4 +65,5 @@ enum class ViewType
|
||||
RTV,
|
||||
DSV,
|
||||
UAV,
|
||||
CBV,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user