1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-03-21 13:29:26 +01:00

[dxvk] Add conservative rasterization mode to rasterizer state

This commit is contained in:
Philip Rebohle 2021-03-13 19:45:00 +01:00
parent a77c80f08a
commit e3b92bcfac
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
10 changed files with 36 additions and 11 deletions

View File

@ -4264,6 +4264,7 @@ namespace dxvk {
pRsState->frontFace = VK_FRONT_FACE_CLOCKWISE; pRsState->frontFace = VK_FRONT_FACE_CLOCKWISE;
pRsState->depthClipEnable = VK_TRUE; pRsState->depthClipEnable = VK_TRUE;
pRsState->depthBiasEnable = VK_FALSE; pRsState->depthBiasEnable = VK_FALSE;
pRsState->conservativeMode = VK_CONSERVATIVE_RASTERIZATION_MODE_DISABLED_EXT;
pRsState->sampleCount = 0; pRsState->sampleCount = 0;
} }

View File

@ -35,6 +35,7 @@ namespace dxvk {
// we do not need to enable it in case the parameters are both 0. // we do not need to enable it in case the parameters are both 0.
m_state.depthBiasEnable = desc.DepthBias != 0 || desc.SlopeScaledDepthBias != 0.0f; m_state.depthBiasEnable = desc.DepthBias != 0 || desc.SlopeScaledDepthBias != 0.0f;
m_state.depthClipEnable = desc.DepthClipEnable; m_state.depthClipEnable = desc.DepthClipEnable;
m_state.conservativeMode = VK_CONSERVATIVE_RASTERIZATION_MODE_DISABLED_EXT;
m_state.sampleCount = VkSampleCountFlags(desc.ForcedSampleCount); m_state.sampleCount = VkSampleCountFlags(desc.ForcedSampleCount);
m_depthBias.depthBiasConstant = float(desc.DepthBias); m_depthBias.depthBiasConstant = float(desc.DepthBias);

View File

@ -5486,6 +5486,7 @@ namespace dxvk {
state.depthClipEnable = true; state.depthClipEnable = true;
state.frontFace = VK_FRONT_FACE_CLOCKWISE; state.frontFace = VK_FRONT_FACE_CLOCKWISE;
state.polygonMode = DecodeFillMode(D3DFILLMODE(rs[D3DRS_FILLMODE])); state.polygonMode = DecodeFillMode(D3DFILLMODE(rs[D3DRS_FILLMODE]));
state.conservativeMode = VK_CONSERVATIVE_RASTERIZATION_MODE_DISABLED_EXT;
state.sampleCount = 0; state.sampleCount = 0;
EmitCs([ EmitCs([

View File

@ -103,6 +103,7 @@ namespace dxvk {
VkFrontFace frontFace; VkFrontFace frontFace;
VkBool32 depthClipEnable; VkBool32 depthClipEnable;
VkBool32 depthBiasEnable; VkBool32 depthBiasEnable;
VkConservativeRasterizationModeEXT conservativeMode;
VkSampleCountFlags sampleCount; VkSampleCountFlags sampleCount;
}; };

View File

@ -2358,7 +2358,8 @@ namespace dxvk {
rs.cullMode, rs.cullMode,
rs.frontFace, rs.frontFace,
m_state.gp.state.rs.viewportCount(), m_state.gp.state.rs.viewportCount(),
rs.sampleCount); rs.sampleCount,
rs.conservativeMode);
m_flags.set(DxvkContextFlag::GpDirtyPipelineState); m_flags.set(DxvkContextFlag::GpDirtyPipelineState);
} }

View File

@ -288,6 +288,13 @@ namespace dxvk {
vpInfo.scissorCount = state.rs.viewportCount(); vpInfo.scissorCount = state.rs.viewportCount();
vpInfo.pScissors = nullptr; vpInfo.pScissors = nullptr;
VkPipelineRasterizationConservativeStateCreateInfoEXT conservativeInfo;
conservativeInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_CONSERVATIVE_STATE_CREATE_INFO_EXT;
conservativeInfo.pNext = nullptr;
conservativeInfo.flags = 0;
conservativeInfo.conservativeRasterizationMode = state.rs.conservativeMode();
conservativeInfo.extraPrimitiveOverestimationSize = 0.0f;
VkPipelineRasterizationStateStreamCreateInfoEXT xfbStreamInfo; VkPipelineRasterizationStateStreamCreateInfoEXT xfbStreamInfo;
xfbStreamInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_STREAM_CREATE_INFO_EXT; xfbStreamInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_STREAM_CREATE_INFO_EXT;
xfbStreamInfo.pNext = nullptr; xfbStreamInfo.pNext = nullptr;
@ -302,7 +309,7 @@ namespace dxvk {
VkPipelineRasterizationStateCreateInfo rsInfo; VkPipelineRasterizationStateCreateInfo rsInfo;
rsInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; rsInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
rsInfo.pNext = &rsDepthClipInfo; rsInfo.pNext = nullptr;
rsInfo.flags = 0; rsInfo.flags = 0;
rsInfo.depthClampEnable = VK_TRUE; rsInfo.depthClampEnable = VK_TRUE;
rsInfo.rasterizerDiscardEnable = rasterizedStream < 0; rsInfo.rasterizerDiscardEnable = rasterizedStream < 0;
@ -316,12 +323,15 @@ namespace dxvk {
rsInfo.lineWidth = 1.0f; rsInfo.lineWidth = 1.0f;
if (rasterizedStream > 0) if (rasterizedStream > 0)
rsDepthClipInfo.pNext = &xfbStreamInfo; xfbStreamInfo.pNext = std::exchange(rsInfo.pNext, &xfbStreamInfo);
if (!m_pipeMgr->m_device->features().extDepthClipEnable.depthClipEnable) { if (conservativeInfo.conservativeRasterizationMode != VK_CONSERVATIVE_RASTERIZATION_MODE_DISABLED_EXT)
rsInfo.pNext = rsDepthClipInfo.pNext; conservativeInfo.pNext = std::exchange(rsInfo.pNext, &conservativeInfo);
rsInfo.depthClampEnable = !state.rs.depthClipEnable();
} if (m_pipeMgr->m_device->features().extDepthClipEnable.depthClipEnable)
rsDepthClipInfo.pNext = std::exchange(rsInfo.pNext, &rsDepthClipInfo);
else
rsInfo.depthClampEnable = !state.rs.depthClipEnable();
uint32_t sampleMask = state.ms.sampleMask(); uint32_t sampleMask = state.ms.sampleMask();

View File

@ -224,7 +224,8 @@ namespace dxvk {
VkCullModeFlags cullMode, VkCullModeFlags cullMode,
VkFrontFace frontFace, VkFrontFace frontFace,
uint32_t viewportCount, uint32_t viewportCount,
VkSampleCountFlags sampleCount) VkSampleCountFlags sampleCount,
VkConservativeRasterizationModeEXT conservativeMode)
: m_depthClipEnable (uint32_t(depthClipEnable)), : m_depthClipEnable (uint32_t(depthClipEnable)),
m_depthBiasEnable (uint32_t(depthBiasEnable)), m_depthBiasEnable (uint32_t(depthBiasEnable)),
m_polygonMode (uint32_t(polygonMode)), m_polygonMode (uint32_t(polygonMode)),
@ -232,6 +233,7 @@ namespace dxvk {
m_frontFace (uint32_t(frontFace)), m_frontFace (uint32_t(frontFace)),
m_viewportCount (uint32_t(viewportCount)), m_viewportCount (uint32_t(viewportCount)),
m_sampleCount (uint32_t(sampleCount)), m_sampleCount (uint32_t(sampleCount)),
m_conservativeMode(uint32_t(conservativeMode)),
m_reserved (0) { } m_reserved (0) { }
VkBool32 depthClipEnable() const { VkBool32 depthClipEnable() const {
@ -262,6 +264,10 @@ namespace dxvk {
return VkSampleCountFlags(m_sampleCount); return VkSampleCountFlags(m_sampleCount);
} }
VkConservativeRasterizationModeEXT conservativeMode() const {
return VkConservativeRasterizationModeEXT(m_conservativeMode);
}
void setViewportCount(uint32_t viewportCount) { void setViewportCount(uint32_t viewportCount) {
m_viewportCount = viewportCount; m_viewportCount = viewportCount;
} }
@ -275,7 +281,8 @@ namespace dxvk {
uint32_t m_frontFace : 1; uint32_t m_frontFace : 1;
uint32_t m_viewportCount : 5; uint32_t m_viewportCount : 5;
uint32_t m_sampleCount : 5; uint32_t m_sampleCount : 5;
uint32_t m_reserved : 15; uint32_t m_conservativeMode : 2;
uint32_t m_reserved : 13;
}; };

View File

@ -863,7 +863,8 @@ namespace dxvk {
in.gpState.rsCullMode, in.gpState.rsCullMode,
in.gpState.rsFrontFace, in.gpState.rsFrontFace,
in.gpState.rsViewportCount, in.gpState.rsViewportCount,
in.gpState.rsSampleCount); in.gpState.rsSampleCount,
VK_CONSERVATIVE_RASTERIZATION_MODE_DISABLED_EXT);
out.gpState.ms = DxvkMsInfo( out.gpState.ms = DxvkMsInfo(
in.gpState.msSampleCount, in.gpState.msSampleCount,

View File

@ -102,6 +102,7 @@ namespace dxvk {
rsState.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; rsState.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE;
rsState.depthClipEnable = VK_FALSE; rsState.depthClipEnable = VK_FALSE;
rsState.depthBiasEnable = VK_FALSE; rsState.depthBiasEnable = VK_FALSE;
rsState.conservativeMode = VK_CONSERVATIVE_RASTERIZATION_MODE_DISABLED_EXT;
rsState.sampleCount = VK_SAMPLE_COUNT_1_BIT; rsState.sampleCount = VK_SAMPLE_COUNT_1_BIT;
ctx->setRasterizerState(rsState); ctx->setRasterizerState(rsState);

View File

@ -20,6 +20,7 @@ namespace dxvk::hud {
m_rsState.frontFace = VK_FRONT_FACE_CLOCKWISE; m_rsState.frontFace = VK_FRONT_FACE_CLOCKWISE;
m_rsState.depthClipEnable = VK_FALSE; m_rsState.depthClipEnable = VK_FALSE;
m_rsState.depthBiasEnable = VK_FALSE; m_rsState.depthBiasEnable = VK_FALSE;
m_rsState.conservativeMode = VK_CONSERVATIVE_RASTERIZATION_MODE_DISABLED_EXT;
m_rsState.sampleCount = VK_SAMPLE_COUNT_1_BIT; m_rsState.sampleCount = VK_SAMPLE_COUNT_1_BIT;
m_blendMode.enableBlending = VK_TRUE; m_blendMode.enableBlending = VK_TRUE;