diff --git a/src/d3d11/d3d11_context.cpp b/src/d3d11/d3d11_context.cpp index 72206278..fe7bf4d9 100644 --- a/src/d3d11/d3d11_context.cpp +++ b/src/d3d11/d3d11_context.cpp @@ -3892,49 +3892,19 @@ namespace dxvk { m_state.ps.shader = nullptr; m_state.cs.shader = nullptr; + // Reset render state + m_state.id.reset(); + m_state.ia.reset(); + m_state.om.reset(); + m_state.rs.reset(); + m_state.so.reset(); + m_state.pr.reset(); + // Reset resource bindings m_state.cbv.reset(); m_state.srv.reset(); m_state.uav.reset(); m_state.samplers.reset(); - m_state.om.reset(); - - // Default ID state - m_state.id.argBuffer = nullptr; - - // Default IA state - m_state.ia.inputLayout = nullptr; - m_state.ia.primitiveTopology = D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED; - - for (uint32_t i = 0; i < D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT; i++) { - m_state.ia.vertexBuffers[i].buffer = nullptr; - m_state.ia.vertexBuffers[i].offset = 0; - m_state.ia.vertexBuffers[i].stride = 0; - } - - m_state.ia.indexBuffer.buffer = nullptr; - m_state.ia.indexBuffer.offset = 0; - m_state.ia.indexBuffer.format = DXGI_FORMAT_UNKNOWN; - - // Default RS state - m_state.rs.state = nullptr; - m_state.rs.numViewports = 0; - m_state.rs.numScissors = 0; - - for (uint32_t i = 0; i < D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE; i++) { - m_state.rs.viewports[i] = D3D11_VIEWPORT { }; - m_state.rs.scissors [i] = D3D11_RECT { }; - } - - // Default SO state - for (uint32_t i = 0; i < D3D11_SO_BUFFER_SLOT_COUNT; i++) { - m_state.so.targets[i].buffer = nullptr; - m_state.so.targets[i].offset = 0; - } - - // Default predication - m_state.pr.predicateObject = nullptr; - m_state.pr.predicateValue = FALSE; } diff --git a/src/d3d11/d3d11_context_state.h b/src/d3d11/d3d11_context_state.h index e13e557f..46ffd287 100644 --- a/src/d3d11/d3d11_context_state.h +++ b/src/d3d11/d3d11_context_state.h @@ -154,33 +154,41 @@ namespace dxvk { Com shader = nullptr; }; - + /** + * \brief Input assembly state + * + * Stores vertex buffers, the index buffer, the + * input layout, and the dynamic primitive topology. + */ struct D3D11VertexBufferBinding { Com buffer = nullptr; UINT offset = 0; UINT stride = 0; }; - struct D3D11IndexBufferBinding { Com buffer = nullptr; UINT offset = 0; DXGI_FORMAT format = DXGI_FORMAT_UNKNOWN; }; - - struct D3D11ContextStateID { - Com argBuffer = nullptr; - Com cntBuffer = nullptr; - }; - - struct D3D11ContextStateIA { Com inputLayout = nullptr; D3D11_PRIMITIVE_TOPOLOGY primitiveTopology = D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED; std::array vertexBuffers = { }; D3D11IndexBufferBinding indexBuffer = { }; + + void reset() { + inputLayout = nullptr; + + primitiveTopology = D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED; + + for (uint32_t i = 0; i < vertexBuffers.size(); i++) + vertexBuffers[i] = D3D11VertexBufferBinding(); + + indexBuffer = D3D11IndexBufferBinding(); + } }; /** @@ -231,7 +239,27 @@ namespace dxvk { } }; - + /** + * \brief Indirect draw state + * + * Stores the current indirct draw + * argument and draw count buffer. + */ + struct D3D11ContextStateID { + Com argBuffer = nullptr; + Com cntBuffer = nullptr; + + void reset() { + argBuffer = nullptr; + cntBuffer = nullptr; + } + }; + + /** + * \brief Rasterizer state + * + * Stores viewport info and the rasterizer state object. + */ struct D3D11ContextStateRS { uint32_t numViewports = 0; uint32_t numScissors = 0; @@ -240,26 +268,55 @@ namespace dxvk { std::array scissors = { }; D3D11RasterizerState* state = nullptr; + + void reset() { + for (uint32_t i = 0; i < numViewports; i++) + viewports[i] = D3D11_VIEWPORT(); + + for (uint32_t i = 0; i < numScissors; i++) + scissors[i] = D3D11_RECT(); + + numViewports = 0; + numScissors = 0; + + state = nullptr; + } }; - + /** + * \brief Stream output binding + * + * Stores stream output buffers with offset. + */ struct D3D11ContextSoTarget { Com buffer = nullptr; UINT offset = 0; }; - struct D3D11ContextStateSO { std::array targets = { }; + + void reset() { + for (uint32_t i = 0; i < targets.size(); i++) + targets[i] = D3D11ContextSoTarget(); + } }; - + /** + * \brief Predication state + * + * Stores predication info. + */ struct D3D11ContextStatePR { Com predicateObject = nullptr; - BOOL predicateValue = FALSE; + BOOL predicateValue = false; + + void reset() { + predicateObject = nullptr; + predicateValue = false; + } }; - /** * \brief Context state */