From bf480ce6593aae769412dec8958e8ce936d3f51e Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Mon, 16 Mar 2020 18:39:46 +0100 Subject: [PATCH] [d3d11] Initialize all D3D11ContextState members Otherwise, SwapDeviceContextState may swap in some uninitialized data. Closes #1512. Reported-by: Danylo Piliaiev --- src/d3d11/d3d11_context_state.h | 78 ++++++++++++++++----------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/src/d3d11/d3d11_context_state.h b/src/d3d11/d3d11_context_state.h index f0854ac5..eca2a3c9 100644 --- a/src/d3d11/d3d11_context_state.h +++ b/src/d3d11/d3d11_context_state.h @@ -31,8 +31,8 @@ namespace dxvk { struct D3D11ShaderResourceBindings { - std::array, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT> views; - DxvkBindingSet hazardous; + std::array, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT> views = { }; + DxvkBindingSet hazardous = { }; }; @@ -41,52 +41,52 @@ namespace dxvk { struct D3D11ContextStateVS { - Com shader; - D3D11ConstantBufferBindings constantBuffers; - D3D11SamplerBindings samplers; - D3D11ShaderResourceBindings shaderResources; + Com shader = nullptr; + D3D11ConstantBufferBindings constantBuffers = { }; + D3D11SamplerBindings samplers = { }; + D3D11ShaderResourceBindings shaderResources = { }; }; struct D3D11ContextStateHS { - Com shader; - D3D11ConstantBufferBindings constantBuffers; - D3D11SamplerBindings samplers; - D3D11ShaderResourceBindings shaderResources; + Com shader = nullptr; + D3D11ConstantBufferBindings constantBuffers = { }; + D3D11SamplerBindings samplers = { }; + D3D11ShaderResourceBindings shaderResources = { }; }; struct D3D11ContextStateDS { - Com shader; - D3D11ConstantBufferBindings constantBuffers; - D3D11SamplerBindings samplers; - D3D11ShaderResourceBindings shaderResources; + Com shader = nullptr; + D3D11ConstantBufferBindings constantBuffers = { }; + D3D11SamplerBindings samplers = { }; + D3D11ShaderResourceBindings shaderResources = { }; }; struct D3D11ContextStateGS { - Com shader; - D3D11ConstantBufferBindings constantBuffers; - D3D11SamplerBindings samplers; - D3D11ShaderResourceBindings shaderResources; + Com shader = nullptr; + D3D11ConstantBufferBindings constantBuffers = { }; + D3D11SamplerBindings samplers = { }; + D3D11ShaderResourceBindings shaderResources = { }; }; struct D3D11ContextStatePS { - Com shader; - D3D11ConstantBufferBindings constantBuffers; - D3D11SamplerBindings samplers; - D3D11ShaderResourceBindings shaderResources; - D3D11UnorderedAccessBindings unorderedAccessViews; + Com shader = nullptr; + D3D11ConstantBufferBindings constantBuffers = { }; + D3D11SamplerBindings samplers = { }; + D3D11ShaderResourceBindings shaderResources = { }; + D3D11UnorderedAccessBindings unorderedAccessViews = { }; }; struct D3D11ContextStateCS { - Com shader; - D3D11ConstantBufferBindings constantBuffers; - D3D11SamplerBindings samplers; - D3D11ShaderResourceBindings shaderResources; - D3D11UnorderedAccessBindings unorderedAccessViews; + Com shader = nullptr; + D3D11ConstantBufferBindings constantBuffers = { }; + D3D11SamplerBindings samplers = { }; + D3D11ShaderResourceBindings shaderResources = { }; + D3D11UnorderedAccessBindings unorderedAccessViews = { }; DxvkBindingSet uavMask = { }; }; @@ -113,17 +113,17 @@ namespace dxvk { struct D3D11ContextStateIA { - Com inputLayout; + Com inputLayout = nullptr; D3D11_PRIMITIVE_TOPOLOGY primitiveTopology = D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED; - std::array vertexBuffers; - D3D11IndexBufferBinding indexBuffer; + std::array vertexBuffers = { }; + D3D11IndexBufferBinding indexBuffer = { }; }; struct D3D11ContextStateOM { - std::array, D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT> renderTargetViews; - Com depthStencilView; + std::array, D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT> renderTargetViews = { }; + Com depthStencilView = { }; D3D11BlendState* cbState = nullptr; D3D11DepthStencilState* dsState = nullptr; @@ -141,21 +141,21 @@ namespace dxvk { uint32_t numViewports = 0; uint32_t numScissors = 0; - std::array viewports; - std::array scissors; + std::array viewports = { }; + std::array scissors = { }; - D3D11RasterizerState* state; + D3D11RasterizerState* state = nullptr; }; struct D3D11ContextSoTarget { - Com buffer; - UINT offset; + Com buffer = nullptr; + UINT offset = 0; }; struct D3D11ContextStateSO { - std::array targets; + std::array targets = { }; };