[dxvk] Use dynamic depth clip enable for linked pipelines if supported

This way we won't have to compile any vertex shader pipelines twice.
This commit is contained in:
Philip Rebohle 2022-10-18 11:51:46 +02:00
parent 8e7ea899d2
commit fea86ef116
5 changed files with 37 additions and 12 deletions

View File

@ -434,6 +434,11 @@ namespace dxvk {
enabledFeatures.extDepthClipEnable.depthClipEnable =
m_deviceFeatures.extDepthClipEnable.depthClipEnable;
// Used to make pipeline library stuff less clunky
enabledFeatures.extExtendedDynamicState3.extendedDynamicState3DepthClipEnable =
m_deviceFeatures.extExtendedDynamicState3.extendedDynamicState3DepthClipEnable &&
m_deviceFeatures.extDepthClipEnable.depthClipEnable;
// Used for both pNext shader module info, and fast-linking pipelines provided
// that graphicsPipelineLibraryIndependentInterpolationDecoration is supported
enabledFeatures.extGraphicsPipelineLibrary.graphicsPipelineLibrary =

View File

@ -811,6 +811,12 @@ namespace dxvk {
}
void cmdSetDepthClipState(
VkBool32 depthClipEnable) {
m_vkd->vkCmdSetDepthClipEnableEXT(m_cmd.execBuffer, depthClipEnable);
}
void cmdSetDepthBias(
float depthBiasConstantFactor,
float depthBiasClamp,

View File

@ -5609,6 +5609,11 @@ namespace dxvk {
m_cmd->cmdSetDepthBiasState(
m_state.gp.state.rs.depthBiasEnable());
if (m_device->features().extExtendedDynamicState3.extendedDynamicState3DepthClipEnable) {
m_cmd->cmdSetDepthClipState(
m_state.gp.state.rs.depthClipEnable());
}
}
if (unlikely(m_flags.all(DxvkContextFlag::GpDirtyBlendConstants,

View File

@ -1124,7 +1124,9 @@ namespace dxvk {
DxvkGraphicsPipelineBaseInstanceKey key;
key.viLibrary = m_manager->createVertexInputLibrary(viState);
key.foLibrary = m_manager->createFragmentOutputLibrary(foState);
key.args.depthClipEnable = state.rs.depthClipEnable();
if (!m_device->features().extExtendedDynamicState3.extendedDynamicState3DepthClipEnable)
key.args.depthClipEnable = state.rs.depthClipEnable();
auto entry = m_basePipelines.find(key);
if (entry != m_basePipelines.end())

View File

@ -1077,17 +1077,21 @@ namespace dxvk {
// Set up dynamic state. We do not know any pipeline state
// at this time, so make as much state dynamic as we can.
std::array<VkDynamicState, 6> dynamicStates = {{
VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT,
VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT,
VK_DYNAMIC_STATE_DEPTH_BIAS,
VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE,
VK_DYNAMIC_STATE_CULL_MODE,
VK_DYNAMIC_STATE_FRONT_FACE,
}};
uint32_t dynamicStateCount = 0;
std::array<VkDynamicState, 7> dynamicStates;
dynamicStates[dynamicStateCount++] = VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT;
dynamicStates[dynamicStateCount++] = VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT;
dynamicStates[dynamicStateCount++] = VK_DYNAMIC_STATE_DEPTH_BIAS;
dynamicStates[dynamicStateCount++] = VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE;
dynamicStates[dynamicStateCount++] = VK_DYNAMIC_STATE_CULL_MODE;
dynamicStates[dynamicStateCount++] = VK_DYNAMIC_STATE_FRONT_FACE;
if (m_device->features().extExtendedDynamicState3.extendedDynamicState3DepthClipEnable)
dynamicStates[dynamicStateCount++] = VK_DYNAMIC_STATE_DEPTH_CLIP_ENABLE_EXT;
VkPipelineDynamicStateCreateInfo dyInfo = { VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO };
dyInfo.dynamicStateCount = dynamicStates.size();
dyInfo.dynamicStateCount = dynamicStateCount;
dyInfo.pDynamicStates = dynamicStates.data();
// All viewport state is dynamic, so we do not need to initialize this.
@ -1104,8 +1108,11 @@ namespace dxvk {
rsInfo.lineWidth = 1.0f;
if (m_device->features().extDepthClipEnable.depthClipEnable) {
rsDepthClipInfo.pNext = std::exchange(rsInfo.pNext, &rsDepthClipInfo);
rsDepthClipInfo.depthClipEnable = args.depthClipEnable;
// Only use the fixed depth clip state if we can't make it dynamic
if (!m_device->features().extExtendedDynamicState3.extendedDynamicState3DepthClipEnable) {
rsDepthClipInfo.pNext = std::exchange(rsInfo.pNext, &rsDepthClipInfo);
rsDepthClipInfo.depthClipEnable = args.depthClipEnable;
}
} else {
rsInfo.depthClampEnable = !args.depthClipEnable;
}