mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-11-29 19:24:10 +01:00
[dxvk] Apply dynamic state at draw time
Changes to the viewport, stencil reference and blend constants are often coupled with a pipeline state update, so it makes sense to update it later.
This commit is contained in:
parent
e615fc19a9
commit
f77392a264
@ -1383,31 +1383,21 @@ namespace dxvk {
|
||||
}
|
||||
}
|
||||
|
||||
if (m_gpActivePipeline != VK_NULL_HANDLE) {
|
||||
m_cmd->cmdSetViewport(0, viewportCount, m_state.vp.viewports.data());
|
||||
m_cmd->cmdSetScissor (0, viewportCount, m_state.vp.scissorRects.data());
|
||||
}
|
||||
m_flags.set(DxvkContextFlag::GpDirtyViewport);
|
||||
}
|
||||
|
||||
|
||||
void DxvkContext::setBlendConstants(
|
||||
const DxvkBlendConstants& blendConstants) {
|
||||
m_state.om.blendConstants = blendConstants;
|
||||
|
||||
if (m_gpActivePipeline != VK_NULL_HANDLE)
|
||||
m_cmd->cmdSetBlendConstants(&blendConstants.r);
|
||||
m_flags.set(DxvkContextFlag::GpDirtyBlendConstants);
|
||||
}
|
||||
|
||||
|
||||
void DxvkContext::setStencilReference(
|
||||
const uint32_t reference) {
|
||||
m_state.om.stencilReference = reference;
|
||||
|
||||
if (m_gpActivePipeline != VK_NULL_HANDLE) {
|
||||
m_cmd->cmdSetStencilReference(
|
||||
VK_STENCIL_FRONT_AND_BACK,
|
||||
reference);
|
||||
}
|
||||
m_flags.set(DxvkContextFlag::GpDirtyStencilRef);
|
||||
}
|
||||
|
||||
|
||||
@ -1723,17 +1713,12 @@ namespace dxvk {
|
||||
m_cmd->cmdBindPipeline(
|
||||
VK_PIPELINE_BIND_POINT_GRAPHICS,
|
||||
m_gpActivePipeline);
|
||||
|
||||
m_cmd->cmdSetViewport(0, m_state.gp.state.rsViewportCount, m_state.vp.viewports.data());
|
||||
m_cmd->cmdSetScissor (0, m_state.gp.state.rsViewportCount, m_state.vp.scissorRects.data());
|
||||
|
||||
m_cmd->cmdSetBlendConstants(
|
||||
&m_state.om.blendConstants.r);
|
||||
|
||||
m_cmd->cmdSetStencilReference(
|
||||
VK_STENCIL_FRONT_AND_BACK,
|
||||
m_state.om.stencilReference);
|
||||
}
|
||||
|
||||
m_flags.set(
|
||||
DxvkContextFlag::GpDirtyBlendConstants,
|
||||
DxvkContextFlag::GpDirtyStencilRef,
|
||||
DxvkContextFlag::GpDirtyViewport);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2000,6 +1985,29 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
|
||||
void DxvkContext::updateDynamicState() {
|
||||
if (m_gpActivePipeline == VK_NULL_HANDLE)
|
||||
return;
|
||||
|
||||
if (m_flags.test(DxvkContextFlag::GpDirtyViewport)) {
|
||||
uint32_t viewportCount = m_state.gp.state.rsViewportCount;
|
||||
m_cmd->cmdSetViewport(0, viewportCount, m_state.vp.viewports.data());
|
||||
m_cmd->cmdSetScissor (0, viewportCount, m_state.vp.scissorRects.data());
|
||||
}
|
||||
|
||||
if (m_flags.test(DxvkContextFlag::GpDirtyBlendConstants))
|
||||
m_cmd->cmdSetBlendConstants(&m_state.om.blendConstants.r);
|
||||
|
||||
if (m_flags.test(DxvkContextFlag::GpDirtyStencilRef))
|
||||
m_cmd->cmdSetStencilReference(VK_STENCIL_FRONT_AND_BACK, m_state.om.stencilReference);
|
||||
|
||||
m_flags.clr(
|
||||
DxvkContextFlag::GpDirtyBlendConstants,
|
||||
DxvkContextFlag::GpDirtyStencilRef,
|
||||
DxvkContextFlag::GpDirtyViewport);
|
||||
}
|
||||
|
||||
|
||||
bool DxvkContext::validateComputeState() {
|
||||
return m_cpActivePipeline != VK_NULL_HANDLE;
|
||||
}
|
||||
@ -2034,6 +2042,7 @@ namespace dxvk {
|
||||
this->updateGraphicsShaderResources();
|
||||
this->updateGraphicsPipelineState();
|
||||
this->updateGraphicsShaderDescriptors();
|
||||
this->updateDynamicState();
|
||||
}
|
||||
|
||||
|
||||
|
@ -682,6 +682,8 @@ namespace dxvk {
|
||||
void updateIndexBufferBinding();
|
||||
void updateVertexBufferBindings();
|
||||
|
||||
void updateDynamicState();
|
||||
|
||||
bool validateComputeState();
|
||||
bool validateGraphicsState();
|
||||
|
||||
|
@ -29,6 +29,9 @@ namespace dxvk {
|
||||
GpDirtyResources, ///< Graphics pipeline resource bindings are out of date
|
||||
GpDirtyVertexBuffers, ///< Vertex buffer bindings are out of date
|
||||
GpDirtyIndexBuffer, ///< Index buffer binding are out of date
|
||||
GpDirtyBlendConstants, ///< Blend constants have changed
|
||||
GpDirtyStencilRef, ///< Stencil reference has changed
|
||||
GpDirtyViewport, ///< Viewport state has changed
|
||||
|
||||
CpDirtyPipeline, ///< Compute pipeline binding are out of date
|
||||
CpDirtyPipelineState, ///< Compute pipeline needs to be recompiled
|
||||
|
Loading…
Reference in New Issue
Block a user