Hi everybody !
I have a problem with the VS Graphics Debugger and a D3D12 desktop application. When I create my depth stencil resource, I create two descriptor heaps, one with HEAP_TYPE_DSV, and one with HEAP_TYPE_CBV_SRV_UAV (to rebuild position from depth map), both calls to CreateDescriptorHeap succeed. Then I create a shader-resource view, and a depth-stencil view.
Things go well with and without the debugger, but when I use the graphics debugger, the application crashes stating that the CPU descriptor handles does not refer to a location in a descriptor heap when I call either CreateDepthStencilView or CreateShaderResourceView.
Here is my code :
{
D3D12_DESCRIPTOR_HEAP_DESC heap_desc = {};
heap_desc.NumDescriptors = 1;
heap_desc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;
heap_desc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE;
ThrowIfFailed(device->CreateDescriptorHeap(&heap_desc,
IID_PPV_ARGS(&m_SRVDescriptorHeap)));
heap_desc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_DSV;
ThrowIfFailed(device->CreateDescriptorHeap(&heap_desc,
IID_PPV_ARGS(&m_DSVDescriptorHeap)));
}
DXGI_FORMAT depth_format = DXGI_FORMAT_D24_UNORM_S8_UINT;
DXGI_FORMAT depth_format_SRV = DXGI_FORMAT_R24_UNORM_X8_TYPELESS;
D3D12_CLEAR_VALUE depth_clear = {};
depth_clear.Format = depth_format;
depth_clear.DepthStencil.Depth = 1.0f;
depth_clear.DepthStencil.Stencil = 0;
ThrowIfFailed(device->CreateCommittedResource(
&CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_DEFAULT),
D3D12_HEAP_FLAG_NONE,
&CD3DX12_RESOURCE_DESC::Tex2D(
depth_format,
width, height, 1, 0, 1, 0,
D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL),
D3D12_RESOURCE_STATE_DEPTH_WRITE,
&depth_clear,
IID_PPV_ARGS(&m_Resource)
));
{
D3D12_DEPTH_STENCIL_VIEW_DESC dstencil_desc = {};
dstencil_desc.Format = depth_format;
dstencil_desc.ViewDimension = D3D12_DSV_DIMENSION_TEXTURE2D;
dstencil_desc.Flags = D3D12_DSV_FLAG_NONE;
// this call causes a crash
device->CreateDepthStencilView(m_Resource, &dstencil_desc,
m_DSVDescriptorHeap->GetCPUDescriptorHandleForHeapStart());
}
{
D3D12_SHADER_RESOURCE_VIEW_DESC srv_desc = {};
srv_desc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
srv_desc.Format = depth_format_SRV;
srv_desc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D;
srv_desc.Texture2D.MipLevels = 1;
// this call causes a crash
device->CreateShaderResourceView(m_Resource, &srv_desc,
m_SRVDescriptorHeap->GetCPUDescriptorHandleForHeapStart());
}
This is the message I get from the DebugLayer :
D3D12 ERROR: ID3D12Device::CreateShaderResourceView: Specified CPU descriptor handle ptr=0x0000000000008781 does not refer to a location in a descriptor heap. [ EXECUTION ERROR #646: INVALID_DESCRIPTOR_HANDLE]
I have no more information with the GPUBasedValidation.
The only thing different I noticed with the graphics debugger is that the handle has a much smaller ptr (and always the same) than without it, but I suppose it's only due to the fact that the application is run in some kind of environment with the graphics debugger, right ?
PIX gives me the same error (E_PIX_INVALID_DESCRIPTOR_HANDLE).
Can anyone help me understand or give me a clue why I have this problem, please :| ?
Many Thanks