From 1328e869a94d03e46d1d87f100499bb6bd4c3361 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Tue, 2 Jul 2024 00:54:17 +0200 Subject: [PATCH] Fix crash in D3D12 when constant buffer was binded but not updated before the draw --- .../GraphicsDevice/DirectX/DX12/GPUContextDX12.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Source/Engine/GraphicsDevice/DirectX/DX12/GPUContextDX12.cpp b/Source/Engine/GraphicsDevice/DirectX/DX12/GPUContextDX12.cpp index 970e55ce5..45d3e3777 100644 --- a/Source/Engine/GraphicsDevice/DirectX/DX12/GPUContextDX12.cpp +++ b/Source/Engine/GraphicsDevice/DirectX/DX12/GPUContextDX12.cpp @@ -459,8 +459,10 @@ void GPUContextDX12::flushCBs() const auto cb = _cbHandles[i]; if (cb) { - ASSERT(cb->GPUAddress != 0); - _commandList->SetGraphicsRootConstantBufferView(DX12_ROOT_SIGNATURE_CB + i, cb->GPUAddress); + if (cb->GPUAddress != 0) + _commandList->SetGraphicsRootConstantBufferView(DX12_ROOT_SIGNATURE_CB + i, cb->GPUAddress); + else + _cbGraphicsDirtyFlag = true; // CB was binded but not yet assigned so stay in dirty state } } } @@ -472,8 +474,10 @@ void GPUContextDX12::flushCBs() const auto cb = _cbHandles[i]; if (cb) { - ASSERT(cb->GPUAddress != 0); - _commandList->SetComputeRootConstantBufferView(DX12_ROOT_SIGNATURE_CB + i, cb->GPUAddress); + if (cb->GPUAddress != 0) + _commandList->SetComputeRootConstantBufferView(DX12_ROOT_SIGNATURE_CB + i, cb->GPUAddress); + else + _cbComputeDirtyFlag = true; // CB was binded but not yet assigned so stay in dirty state } } }