The calling code corresponding to the error in the title is:
this->directCommandList.Get()->CopyResource(
this->srvBuffer.Get(),
this->stagingWriteBuffer.Get());
srvBuffer is a smart pointer to an ID3D12Resource. My first real interaction with it is here:
DC12::CreateShaderResourceView(
this->device.Get(),
this->srvDescriptor.Get(),
0,
shaderResourceViewCount,
this->srvBuffer.GetAddressOf());
After which I do nothing with srvBuffer until the attempt to copy into it. This suggests to me that I must have made at least one mistake in my CreateShaderResourceView function, which I have included here:
static inline void CreateShaderResourceView(
_In_ ID3D12Device* pDevice,
_In_opt_ ID3D12DescriptorHeap* pDescriptorHeap,
uint32_t index, // descriptor index
uint32_t count,
_COM_Outptr_ ID3D12Resource** ppBuffer)
{
D3D12_HEAP_PROPERTIES heapProperties =
{
D3D12_HEAP_TYPE_DEFAULT, // Type
D3D12_CPU_PAGE_PROPERTY_UNKNOWN, // CPUPageProperty
D3D12_MEMORY_POOL_UNKNOWN, // MemoryPoolPreference
0, // CreationNodeMask
0, // VisibleNodeMask
};
D3D12_RESOURCE_DESC resourceDesc =
{
D3D12_RESOURCE_DIMENSION_BUFFER, // Dimension
D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT, // Alignment
count * STRUCTURE_BYTE_STRIDE, // Width
1, // Height
1, // DepthOrArraySize
1, // MipLevels
DXGI_FORMAT_UNKNOWN, // Format
{
1, // Count
0, // Quality
}, // SampleDesc
D3D12_TEXTURE_LAYOUT_ROW_MAJOR, // Layout
D3D12_RESOURCE_FLAG_NONE, // Flags
};
CHR(pDevice->CreateCommittedResource(
&heapProperties,
D3D12_HEAP_FLAG_NONE,
&resourceDesc,
D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE,
nullptr,
IID_PPV_ARGS(ppBuffer)));
if (pDescriptorHeap != nullptr)
{
D3D12_SHADER_RESOURCE_VIEW_DESC desc =
{
DXGI_FORMAT_UNKNOWN, // Format
D3D12_SRV_DIMENSION_BUFFER, // ViewDimension
D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING,
{
0, // FirstElement
count, // NumElements
STRUCTURE_BYTE_STRIDE, // StructurebyteStride,
D3D12_BUFFER_SRV_FLAG_NONE // Flags
}, // Buffer
};
D3D12_CPU_DESCRIPTOR_HANDLE cpuDescriptor =
pDescriptorHeap->GetCPUDescriptorHandleForHeapStart();
size_t offset = pDevice->GetDescriptorHandleIncrementSize(
D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
offset *= index;
cpuDescriptor.ptr += offset;
pDevice->CreateShaderResourceView(
*ppBuffer,
&desc,
cpuDescriptor);
}
}
I did also check that the final pDevice->CreateShaderResourceView is being hit by putting a breakpoint there, and it is. I'm hoping there's a simple answer to this.
Edit: A problem I've found is that prior to my attempt at copying to srvBuffer, I get another error with my Resource Transition Barrier: "D3D12 ERROR: ID3D12CommandList::ResourceBarrier: NULL pointer specified." It turns out that this->srvBuffer.Get() returns a null pointer, which suggests to me that I've a failure in CreateCommittedResource, which I'm trying to figure out. This problem would likely explain the original error, though.