mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-11-30 04:24:11 +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_flags.set(DxvkContextFlag::GpDirtyViewport);
|
||||||
m_cmd->cmdSetViewport(0, viewportCount, m_state.vp.viewports.data());
|
|
||||||
m_cmd->cmdSetScissor (0, viewportCount, m_state.vp.scissorRects.data());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DxvkContext::setBlendConstants(
|
void DxvkContext::setBlendConstants(
|
||||||
const DxvkBlendConstants& blendConstants) {
|
const DxvkBlendConstants& blendConstants) {
|
||||||
m_state.om.blendConstants = blendConstants;
|
m_state.om.blendConstants = blendConstants;
|
||||||
|
m_flags.set(DxvkContextFlag::GpDirtyBlendConstants);
|
||||||
if (m_gpActivePipeline != VK_NULL_HANDLE)
|
|
||||||
m_cmd->cmdSetBlendConstants(&blendConstants.r);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DxvkContext::setStencilReference(
|
void DxvkContext::setStencilReference(
|
||||||
const uint32_t reference) {
|
const uint32_t reference) {
|
||||||
m_state.om.stencilReference = reference;
|
m_state.om.stencilReference = reference;
|
||||||
|
m_flags.set(DxvkContextFlag::GpDirtyStencilRef);
|
||||||
if (m_gpActivePipeline != VK_NULL_HANDLE) {
|
|
||||||
m_cmd->cmdSetStencilReference(
|
|
||||||
VK_STENCIL_FRONT_AND_BACK,
|
|
||||||
reference);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1723,17 +1713,12 @@ namespace dxvk {
|
|||||||
m_cmd->cmdBindPipeline(
|
m_cmd->cmdBindPipeline(
|
||||||
VK_PIPELINE_BIND_POINT_GRAPHICS,
|
VK_PIPELINE_BIND_POINT_GRAPHICS,
|
||||||
m_gpActivePipeline);
|
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() {
|
bool DxvkContext::validateComputeState() {
|
||||||
return m_cpActivePipeline != VK_NULL_HANDLE;
|
return m_cpActivePipeline != VK_NULL_HANDLE;
|
||||||
}
|
}
|
||||||
@ -2034,6 +2042,7 @@ namespace dxvk {
|
|||||||
this->updateGraphicsShaderResources();
|
this->updateGraphicsShaderResources();
|
||||||
this->updateGraphicsPipelineState();
|
this->updateGraphicsPipelineState();
|
||||||
this->updateGraphicsShaderDescriptors();
|
this->updateGraphicsShaderDescriptors();
|
||||||
|
this->updateDynamicState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -682,6 +682,8 @@ namespace dxvk {
|
|||||||
void updateIndexBufferBinding();
|
void updateIndexBufferBinding();
|
||||||
void updateVertexBufferBindings();
|
void updateVertexBufferBindings();
|
||||||
|
|
||||||
|
void updateDynamicState();
|
||||||
|
|
||||||
bool validateComputeState();
|
bool validateComputeState();
|
||||||
bool validateGraphicsState();
|
bool validateGraphicsState();
|
||||||
|
|
||||||
|
@ -29,6 +29,9 @@ namespace dxvk {
|
|||||||
GpDirtyResources, ///< Graphics pipeline resource bindings are out of date
|
GpDirtyResources, ///< Graphics pipeline resource bindings are out of date
|
||||||
GpDirtyVertexBuffers, ///< Vertex buffer bindings are out of date
|
GpDirtyVertexBuffers, ///< Vertex buffer bindings are out of date
|
||||||
GpDirtyIndexBuffer, ///< Index buffer binding 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
|
CpDirtyPipeline, ///< Compute pipeline binding are out of date
|
||||||
CpDirtyPipelineState, ///< Compute pipeline needs to be recompiled
|
CpDirtyPipelineState, ///< Compute pipeline needs to be recompiled
|
||||||
|
Loading…
Reference in New Issue
Block a user