Search code examples
c++directx-12

Why am I getting an unhandled exception in KernelBase.dll when I'm trying to call ID3D12Device::CreateCommittedResource method?


I am trying to setup a DX12 renderer and to upload the vertex data to the GPU using the UpdateBufferResource function as mentioned below. In the CreateCommittedResource call it throws unhandled exception message. I can continue through the exception but I don't know what is causing this to pop up. I have built the project using CMake 3.24.0 and VS 2022.

Unhandled exception at 0x00007FFF69654FFC (KernelBase.dll) in Tutorial2.exe: 0x0000087A (parameters: 0x0000000000000002, 0x0000001291FDBED0, 0x0000001291FDDCA0).
void Tutorial2::UpdateBufferResource(
    ComPtr<ID3D12GraphicsCommandList2> commandList,
    ID3D12Resource** pDestinationResource,
    ID3D12Resource** pIntermediateResource,
    size_t numElements, size_t elementSize, const void* bufferData,
    D3D12_RESOURCE_FLAGS flags)
{
    //ID3D12Device2
    auto device = Application::Get().GetDevice();

    size_t bufferSize = numElements * elementSize;

    // Create a committed resource for the GPU resource in a default heap.
    ThrowIfFailed(device->CreateCommittedResource(
        &CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_DEFAULT),
        D3D12_HEAP_FLAG_NONE,
        &CD3DX12_RESOURCE_DESC::Buffer(bufferSize, flags),
        D3D12_RESOURCE_STATE_COPY_DEST,
        nullptr,
        IID_PPV_ARGS(pDestinationResource)));

    // Some more bufferData upload....

}

I am able to continue through the exception but it happens every time CreateCommittedResource is called

Call Stack and Exception

Trying to upload the vertex information to the GPU to render a cube. The HRESULT of the CreateCommittedResource is S_OK as well. But I am not sure what this unhandled exception means and how to resolve it


Solution

  • Per Carsten's comment above, you are likely seeing the following in the Output window:

    D3D12 WARNING: ID3D12Device::CreateCommittedResource: Ignoring InitialState D3D12_RESOURCE_STATE_COPY_DEST. Buffers are effectively created in state D3D12_RESOURCE_STATE_COMMON. [ STATE_CREATION WARNING #1328: CREATERESOURCE_STATE_IGNORED]
    D3D12: **BREAK** enabled for the previous message, which was: [ WARNING STATE_CREATION #1328: CREATERESOURCE_STATE_IGNORED ]
    

    This is triggered by the ID3D12InfoQueue likely created in your Debug build. To prevent this instance from triggering an exception, add the following to the InfoQueue denied IDs, such as:

    D3D12_MESSAGE_ID denyIDs[] = {
        D3D12_MESSAGE_ID_CREATERESOURCE_STATE_IGNORED,                  // This triggers a break exception during the first call to CreateCommittedResource.
    };