mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-02-18 22:54:15 +01:00
[dxvk] Make depth bias a dynamic state
Works around an issue with some games not setting the D3D11 depth bias state correctly, which can result in an excessive number of pipelines being compiled.
This commit is contained in:
parent
6579b2ad99
commit
8b4852be16
@ -516,6 +516,17 @@ namespace dxvk {
|
||||
m_vkd->vkCmdSetBlendConstants(m_execBuffer, blendConstants);
|
||||
}
|
||||
|
||||
|
||||
void cmdSetDepthBias(
|
||||
float depthBiasConstantFactor,
|
||||
float depthBiasClamp,
|
||||
float depthBiasSlopeFactor) {
|
||||
m_vkd->vkCmdSetDepthBias(m_execBuffer,
|
||||
depthBiasConstantFactor,
|
||||
depthBiasClamp,
|
||||
depthBiasSlopeFactor);
|
||||
}
|
||||
|
||||
|
||||
void cmdSetScissor(
|
||||
uint32_t firstScissor,
|
||||
|
@ -1450,11 +1450,14 @@ namespace dxvk {
|
||||
m_state.gp.state.rsCullMode = rs.cullMode;
|
||||
m_state.gp.state.rsFrontFace = rs.frontFace;
|
||||
m_state.gp.state.rsDepthBiasEnable = rs.depthBiasEnable;
|
||||
m_state.gp.state.rsDepthBiasConstant = rs.depthBiasConstant;
|
||||
m_state.gp.state.rsDepthBiasClamp = rs.depthBiasClamp;
|
||||
m_state.gp.state.rsDepthBiasSlope = rs.depthBiasSlope;
|
||||
|
||||
m_flags.set(DxvkContextFlag::GpDirtyPipelineState);
|
||||
|
||||
m_state.ds.depthBiasConstant = rs.depthBiasConstant;
|
||||
m_state.ds.depthBiasClamp = rs.depthBiasClamp;
|
||||
m_state.ds.depthBiasSlope = rs.depthBiasSlope;
|
||||
|
||||
m_flags.set(
|
||||
DxvkContextFlag::GpDirtyPipelineState,
|
||||
DxvkContextFlag::GpDirtyDepthBias);
|
||||
}
|
||||
|
||||
|
||||
@ -1718,7 +1721,8 @@ namespace dxvk {
|
||||
m_flags.set(
|
||||
DxvkContextFlag::GpDirtyBlendConstants,
|
||||
DxvkContextFlag::GpDirtyStencilRef,
|
||||
DxvkContextFlag::GpDirtyViewport);
|
||||
DxvkContextFlag::GpDirtyViewport,
|
||||
DxvkContextFlag::GpDirtyDepthBias);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2001,10 +2005,18 @@ namespace dxvk {
|
||||
if (m_flags.test(DxvkContextFlag::GpDirtyStencilRef))
|
||||
m_cmd->cmdSetStencilReference(VK_STENCIL_FRONT_AND_BACK, m_state.om.stencilReference);
|
||||
|
||||
if (m_flags.test(DxvkContextFlag::GpDirtyDepthBias)) {
|
||||
m_cmd->cmdSetDepthBias(
|
||||
m_state.ds.depthBiasConstant,
|
||||
m_state.ds.depthBiasClamp,
|
||||
m_state.ds.depthBiasSlope);
|
||||
}
|
||||
|
||||
m_flags.clr(
|
||||
DxvkContextFlag::GpDirtyBlendConstants,
|
||||
DxvkContextFlag::GpDirtyStencilRef,
|
||||
DxvkContextFlag::GpDirtyViewport);
|
||||
DxvkContextFlag::GpDirtyViewport,
|
||||
DxvkContextFlag::GpDirtyDepthBias);
|
||||
}
|
||||
|
||||
|
||||
|
@ -32,6 +32,7 @@ namespace dxvk {
|
||||
GpDirtyBlendConstants, ///< Blend constants have changed
|
||||
GpDirtyStencilRef, ///< Stencil reference has changed
|
||||
GpDirtyViewport, ///< Viewport state has changed
|
||||
GpDirtyDepthBias, ///< Depth bias has changed
|
||||
|
||||
CpDirtyPipeline, ///< Compute pipeline binding are out of date
|
||||
CpDirtyPipelineState, ///< Compute pipeline needs to be recompiled
|
||||
@ -55,6 +56,13 @@ namespace dxvk {
|
||||
std::array<VkViewport, DxvkLimits::MaxNumViewports> viewports = { };
|
||||
std::array<VkRect2D, DxvkLimits::MaxNumViewports> scissorRects = { };
|
||||
};
|
||||
|
||||
|
||||
struct DxvkDynamicDepthState {
|
||||
float depthBiasConstant = 0.0f;
|
||||
float depthBiasClamp = 0.0f;
|
||||
float depthBiasSlope = 0.0f;
|
||||
};
|
||||
|
||||
|
||||
struct DxvkOutputMergerState {
|
||||
@ -103,6 +111,7 @@ namespace dxvk {
|
||||
struct DxvkContextState {
|
||||
DxvkVertexInputState vi;
|
||||
DxvkViewportState vp;
|
||||
DxvkDynamicDepthState ds;
|
||||
DxvkOutputMergerState om;
|
||||
|
||||
DxvkGraphicsPipelineState gp;
|
||||
|
@ -197,9 +197,10 @@ namespace dxvk {
|
||||
this->logPipelineState(LogLevel::Debug, state);
|
||||
}
|
||||
|
||||
std::array<VkDynamicState, 4> dynamicStates = {
|
||||
std::array<VkDynamicState, 5> dynamicStates = {
|
||||
VK_DYNAMIC_STATE_VIEWPORT,
|
||||
VK_DYNAMIC_STATE_SCISSOR,
|
||||
VK_DYNAMIC_STATE_DEPTH_BIAS,
|
||||
VK_DYNAMIC_STATE_BLEND_CONSTANTS,
|
||||
VK_DYNAMIC_STATE_STENCIL_REFERENCE,
|
||||
};
|
||||
@ -290,9 +291,9 @@ namespace dxvk {
|
||||
rsInfo.cullMode = state.rsCullMode;
|
||||
rsInfo.frontFace = state.rsFrontFace;
|
||||
rsInfo.depthBiasEnable = state.rsDepthBiasEnable;
|
||||
rsInfo.depthBiasConstantFactor= state.rsDepthBiasConstant;
|
||||
rsInfo.depthBiasClamp = state.rsDepthBiasClamp;
|
||||
rsInfo.depthBiasSlopeFactor = state.rsDepthBiasSlope;
|
||||
rsInfo.depthBiasConstantFactor= 0.0f;
|
||||
rsInfo.depthBiasClamp = 0.0f;
|
||||
rsInfo.depthBiasSlopeFactor = 0.0f;
|
||||
rsInfo.lineWidth = 1.0f;
|
||||
|
||||
VkPipelineMultisampleStateCreateInfo msInfo;
|
||||
|
@ -53,9 +53,6 @@ namespace dxvk {
|
||||
VkCullModeFlags rsCullMode;
|
||||
VkFrontFace rsFrontFace;
|
||||
VkBool32 rsDepthBiasEnable;
|
||||
float rsDepthBiasConstant;
|
||||
float rsDepthBiasClamp;
|
||||
float rsDepthBiasSlope;
|
||||
uint32_t rsViewportCount;
|
||||
|
||||
VkSampleCountFlagBits msSampleCount;
|
||||
|
Loading…
x
Reference in New Issue
Block a user