[d3d11] Implement conservative rasterization

Needed for Nvidia ShadowLibs in Final Fantasy XV.
This commit is contained in:
Philip Rebohle 2021-03-13 20:01:27 +01:00
parent e3b92bcfac
commit 2f553b5b16
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
4 changed files with 29 additions and 6 deletions

View File

@ -1121,7 +1121,11 @@ namespace dxvk {
if (FAILED(D3D11RasterizerState::NormalizeDesc(&desc)))
return E_INVALIDARG;
if (desc.ConservativeRaster != D3D11_CONSERVATIVE_RASTERIZATION_MODE_OFF
&& !m_dxvkDevice->extensions().extConservativeRasterization)
return E_INVALIDARG;
if (!ppRasterizerState)
return S_FALSE;
@ -1682,6 +1686,12 @@ namespace dxvk {
info->TiledResourcesTier = D3D11_TILED_RESOURCES_NOT_SUPPORTED;
info->StandardSwizzle = FALSE;
info->UnifiedMemoryArchitecture = m_dxvkDevice->isUnifiedMemoryArchitecture();
if (m_dxvkDevice->extensions().extConservativeRasterization) {
// We don't have a way to query uncertainty regions, so just check degenerate triangle behaviour
info->ConservativeRasterizationTier = m_dxvkDevice->properties().extConservativeRasterization.degenerateTrianglesRasterized
? D3D11_CONSERVATIVE_RASTERIZATION_TIER_2 : D3D11_CONSERVATIVE_RASTERIZATION_TIER_1;
}
} return S_OK;
case D3D11_FEATURE_D3D11_OPTIONS3: {

View File

@ -35,7 +35,7 @@ namespace dxvk {
// 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.depthClipEnable = desc.DepthClipEnable;
m_state.conservativeMode = VK_CONSERVATIVE_RASTERIZATION_MODE_DISABLED_EXT;
m_state.conservativeMode = DecodeConservativeRasterizationMode(desc.ConservativeRaster);
m_state.sampleCount = VkSampleCountFlags(desc.ForcedSampleCount);
m_depthBias.depthBiasConstant = float(desc.DepthBias);
@ -189,10 +189,6 @@ namespace dxvk {
return E_INVALIDARG;
}
// Conservative rasterization currently not supported
if (pDesc->ConservativeRaster != D3D11_CONSERVATIVE_RASTERIZATION_MODE_OFF)
return E_INVALIDARG;
return S_OK;
}

View File

@ -64,6 +64,20 @@ namespace dxvk {
}
VkConservativeRasterizationModeEXT DecodeConservativeRasterizationMode(
D3D11_CONSERVATIVE_RASTERIZATION_MODE Mode) {
switch (Mode) {
case D3D11_CONSERVATIVE_RASTERIZATION_MODE_OFF:
return VK_CONSERVATIVE_RASTERIZATION_MODE_DISABLED_EXT;
case D3D11_CONSERVATIVE_RASTERIZATION_MODE_ON:
return VK_CONSERVATIVE_RASTERIZATION_MODE_OVERESTIMATE_EXT;
}
Logger::err(str::format("D3D11: Unsupported conservative raster mode: ", Mode));
return VK_CONSERVATIVE_RASTERIZATION_MODE_DISABLED_EXT;
}
VkShaderStageFlagBits GetShaderStage(DxbcProgramType ProgramType) {
switch (ProgramType) {
case DxbcProgramType::VertexShader: return VK_SHADER_STAGE_VERTEX_BIT;

View File

@ -31,6 +31,9 @@ namespace dxvk {
VkCompareOp DecodeCompareOp(
D3D11_COMPARISON_FUNC Mode);
VkConservativeRasterizationModeEXT DecodeConservativeRasterizationMode(
D3D11_CONSERVATIVE_RASTERIZATION_MODE Mode);
VkShaderStageFlagBits GetShaderStage(
DxbcProgramType ProgramType);