?This is my wrapper around DX descriptor heap.
DXDescriptorHeapDesc::DXDescriptorHeapDesc(D3D12_DESCRIPTOR_HEAP_TYPE type, UINT numDescriptors, bool shaderVisible)
{
Type = type;
NumDescriptors = numDescriptors;
Flags = shaderVisible ? D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE : D3D12_DESCRIPTOR_HEAP_FLAG_NONE;
NodeMask = 0;
}
DXDescriptorHeap::DXDescriptorHeap(DXDevice* pDevice, const DXDescriptorHeapDesc* pDesc, LPCWSTR pName)
{
DXVerify(pDevice->GetDXObject()->CreateDescriptorHeap(pDesc, IID_PPV_ARGS(GetDXObjectAddress())));
mHeapStartCPUDescriptor = GetDXObject()->GetCPUDescriptorHandleForHeapStart();
if (pDesc->Flags & D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE)
mHeapStartGPUDescriptor = GetDXObject()->GetGPUDescriptorHandleForHeapStart();
else
mHeapStartGPUDescriptor.ptr = 0;
mDescriptorIncrementSize = pDevice->GetDXObject()->GetDescriptorHandleIncrementSize(pDesc->Type);
#ifdef _DEBUG
SetName(pName);
#endif
}
D3D12_CPU_DESCRIPTOR_HANDLE DXDescriptorHeap::GetCPUDescriptor(UINT index)
{
D3D12_CPU_DESCRIPTOR_HANDLE descriptor;
descriptor.ptr = mHeapStartCPUDescriptor.ptr + index * mDescriptorIncrementSize;
return descriptor;
}
D3D12_GPU_DESCRIPTOR_HANDLE DXDescriptorHeap::GetGPUDescriptor(UINT index)
{
D3D12_GPU_DESCRIPTOR_HANDLE descriptor;
descriptor.ptr = mHeapStartGPUDescriptor.ptr + index * mDescriptorIncrementSize;
return descriptor;
}
Creating descriptor heap for UAV and UAV
DXDescriptorHeapDesc uavHeapDesc(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, 1, true);
mpUAVHeap = new DXDescriptorHeap(mpDevice, &uavHeapDesc, L"mpUAVHeap");
// And other init stuff
mpDevice->CreateUnorderedAccessView(mpBlendTexture, nullptr, &uavDesc, mpUAVHeap->GetCPUDescriptor(kRootParamBlendTexture));
Calling clear operation
const FLOAT clearValue[4] = {0.4f, 0.4f, 0.4f, 1.0f};
D3D12_GPU_DESCRIPTOR_HANDLE gpuHandle = mpUAVHeap->GetGPUDescriptor(kRootParamBlendTexture);
D3D12_CPU_DESCRIPTOR_HANDLE cpuHandle = mpUAVHeap->GetCPUDescriptor(kRootParamBlendTexture);
mpCommandList->ClearUnorderedAccessViewFloat(gpuHandle, cpuHandle, mpBlendTexture, clearValue);
MSDN documentation (https://msdn.microsoft.com/en-us/library/windows/desktop/dn903849(v=vs.85).aspx) states that cpu handle "Describes the CPU descriptor handle that represents the start of the heap for the render target to clear."
Initially, I thought that it is a typo as they mention render target here but after getting this error I am not sure.
Do you have any idea why I might be getting the error? Is it really a typo with the render target? Or they refer to UAV as render target in general not RTV specifically?
Many thanks indeed!
?