Prevent crash with OMSetRenderTargets in D3D12

This commit is contained in:
Steve Karolewics
2020-03-07 21:08:32 +00:00
committed by Baldur Karlsson
parent c6a1a23adb
commit 9b43481234
2 changed files with 6 additions and 1 deletions
@@ -1502,7 +1502,8 @@ void WrappedID3D12GraphicsCommandList::OMSetRenderTargets(
m_ListRecord->AddChunk(scope.Get());
if(RTsSingleHandleToDescriptorRange)
{
D3D12Descriptor *desc = GetWrapped(pRenderTargetDescriptors[0]);
D3D12Descriptor *desc =
(NumRenderTargetDescriptors == 0) ? NULL : GetWrapped(pRenderTargetDescriptors[0]);
for(UINT i = 0; i < NumRenderTargetDescriptors; i++)
{
m_ListRecord->MarkResourceFrameReferenced(desc->GetHeapResourceId(), eFrameRef_Read);
@@ -123,6 +123,10 @@ void main(out float4 out1 : SV_Target0, out float4 out2 : SV_Target1)
Reset(cmd);
// Set null render targets to ensure that these work properly when attached
cmd->OMSetRenderTargets(0, NULL, FALSE, NULL);
cmd->OMSetRenderTargets(0, NULL, TRUE, NULL);
ID3D12ResourcePtr bb = StartUsingBackbuffer(cmd, D3D12_RESOURCE_STATE_RENDER_TARGET);
D3D12_CPU_DESCRIPTOR_HANDLE bbrtv =