From e5357d51f80dd8a661b5a1a2fc52d11eba3769ef Mon Sep 17 00:00:00 2001 From: baldurk Date: Sun, 8 May 2016 18:41:15 +0200 Subject: [PATCH] Handle NULL RTVs list without crashing --- renderdoc/driver/d3d11/d3d11_context.cpp | 30 +++++++++++++++++------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/renderdoc/driver/d3d11/d3d11_context.cpp b/renderdoc/driver/d3d11/d3d11_context.cpp index 4868aacd0..5d256e6ae 100644 --- a/renderdoc/driver/d3d11/d3d11_context.cpp +++ b/renderdoc/driver/d3d11/d3d11_context.cpp @@ -1598,7 +1598,7 @@ void WrappedID3D11DeviceContext::RecordBlendStats(ID3D11BlendState* Blend, FLOAT blends.sets += (Blend != NULL); blends.nulls += (Blend == NULL); const D3D11RenderState::outmerger* Current = &m_CurrentPipelineState->OM; - bool same = (Current->BlendState == Blend) && (memcmp(Current->BlendFactor, BlendFactor, sizeof(BlendFactor)) == 0) && (Current->SampleMask == SampleMask); + bool same = (Current->BlendState == Blend) && (memcmp(Current->BlendFactor, BlendFactor, sizeof(Current->BlendFactor)) == 0) && (Current->SampleMask == SampleMask); blends.redundants += (uint32_t)same; } @@ -1675,19 +1675,33 @@ void WrappedID3D11DeviceContext::RecordOutputMergerStats(UINT NumRTVs, ID3D11Ren // #mivance is an elaborate redundancy here even useful? //const D3D11RenderState::outmerger* Current = &m_CurrentPipelineState->OM; - for (UINT index = 0; index < NumRTVs; index++ ) + if(RTVs != NULL) { - outputs.sets += (RTVs[index] != NULL); - outputs.nulls += (RTVs[index] == NULL); + for (UINT index = 0; index < NumRTVs; index++ ) + { + outputs.sets += (RTVs[index] != NULL); + outputs.nulls += (RTVs[index] == NULL); + } + } + else if(NumRTVs != D3D11_KEEP_RENDER_TARGETS_AND_DEPTH_STENCIL) + { + outputs.nulls += NumRTVs; } outputs.sets += (DSV != NULL); outputs.nulls += (DSV == NULL); - - for (UINT index = 0; index < NumUAVs; index++ ) + + if(UAVs != NULL) { - outputs.sets += (UAVs[index] != NULL); - outputs.nulls += (UAVs[index] == NULL); + for (UINT index = 0; index < NumUAVs; index++ ) + { + outputs.sets += (UAVs[index] != NULL); + outputs.nulls += (UAVs[index] == NULL); + } + } + else + { + outputs.nulls += NumUAVs; } UINT NumSlots = NumRTVs + NumUAVs;