diff --git a/src/d3d11/d3d11_rasterizer.cpp b/src/d3d11/d3d11_rasterizer.cpp index 502572aa..2b35c700 100644 --- a/src/d3d11/d3d11_rasterizer.cpp +++ b/src/d3d11/d3d11_rasterizer.cpp @@ -47,12 +47,10 @@ namespace dxvk { m_state.depthBiasClamp = desc.DepthBiasClamp; m_state.depthBiasSlope = desc.SlopeScaledDepthBias; m_state.depthClampEnable = desc.DepthClipEnable ? VK_FALSE : VK_TRUE; + m_state.sampleCount = VkSampleCountFlags(desc.ForcedSampleCount); if (desc.AntialiasedLineEnable) Logger::err("D3D11RasterizerState: Antialiased lines not supported"); - - if (desc.ForcedSampleCount) - Logger::err("D3D11RasterizerState: Forced sample count not supported"); } diff --git a/src/dxvk/dxvk_constant_state.h b/src/dxvk/dxvk_constant_state.h index 13da894c..70e76e1e 100644 --- a/src/dxvk/dxvk_constant_state.h +++ b/src/dxvk/dxvk_constant_state.h @@ -48,6 +48,7 @@ namespace dxvk { float depthBiasConstant; float depthBiasClamp; float depthBiasSlope; + VkSampleCountFlags sampleCount; }; diff --git a/src/dxvk/dxvk_context.cpp b/src/dxvk/dxvk_context.cpp index 7c37a131..726109f8 100644 --- a/src/dxvk/dxvk_context.cpp +++ b/src/dxvk/dxvk_context.cpp @@ -1562,6 +1562,7 @@ namespace dxvk { m_state.gp.state.rsPolygonMode = rs.polygonMode; m_state.gp.state.rsCullMode = rs.cullMode; m_state.gp.state.rsFrontFace = rs.frontFace; + m_state.gp.state.rsSampleCount = rs.sampleCount; m_state.ds.depthBiasConstant = rs.depthBiasConstant; m_state.ds.depthBiasClamp = rs.depthBiasClamp; diff --git a/src/dxvk/dxvk_framebuffer.h b/src/dxvk/dxvk_framebuffer.h index 40499239..e25cdd6d 100644 --- a/src/dxvk/dxvk_framebuffer.h +++ b/src/dxvk/dxvk_framebuffer.h @@ -79,11 +79,17 @@ namespace dxvk { } /** - * \brief Sample count + * \brief Framebuffer sample count + * + * Returns the sample count of the color + * and depth-stencil attachments, or 0 if + * there are no attachments. * \returns Sample count */ - VkSampleCountFlagBits getSampleCount() const { - return m_renderPass->getSampleCount(); + VkSampleCountFlags getSampleCount() const { + return m_attachmentCount != 0 + ? m_renderPass->getSampleCount() + : 0; } /** diff --git a/src/dxvk/dxvk_graphics.cpp b/src/dxvk/dxvk_graphics.cpp index 855e81bb..2b251140 100644 --- a/src/dxvk/dxvk_graphics.cpp +++ b/src/dxvk/dxvk_graphics.cpp @@ -160,9 +160,18 @@ namespace dxvk { VK_DYNAMIC_STATE_BLEND_CONSTANTS, VK_DYNAMIC_STATE_STENCIL_REFERENCE, }; + + // Figure out the actual sample count to use + VkSampleCountFlagBits sampleCount = VK_SAMPLE_COUNT_1_BIT; + + if (state.msSampleCount) + sampleCount = VkSampleCountFlagBits(state.msSampleCount); + else if (state.rsSampleCount) + sampleCount = VkSampleCountFlagBits(state.rsSampleCount); + // Set up some specialization constants DxvkSpecConstantData specData; - specData.rasterizerSampleCount = uint32_t(state.msSampleCount); + specData.rasterizerSampleCount = uint32_t(sampleCount); for (uint32_t i = 0; i < MaxNumActiveBindings; i++) specData.activeBindings[i] = state.bsBindingMask.isBound(i) ? VK_TRUE : VK_FALSE; @@ -272,7 +281,7 @@ namespace dxvk { msInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; msInfo.pNext = nullptr; msInfo.flags = 0; - msInfo.rasterizationSamples = state.msSampleCount; + msInfo.rasterizationSamples = sampleCount; msInfo.sampleShadingEnable = m_common.msSampleShadingEnable; msInfo.minSampleShading = m_common.msSampleShadingFactor; msInfo.pSampleMask = &state.msSampleMask; diff --git a/src/dxvk/dxvk_graphics.h b/src/dxvk/dxvk_graphics.h index aec66bda..fc332c6c 100644 --- a/src/dxvk/dxvk_graphics.h +++ b/src/dxvk/dxvk_graphics.h @@ -52,8 +52,9 @@ namespace dxvk { VkCullModeFlags rsCullMode; VkFrontFace rsFrontFace; uint32_t rsViewportCount; + VkSampleCountFlags rsSampleCount; - VkSampleCountFlagBits msSampleCount; + VkSampleCountFlags msSampleCount; uint32_t msSampleMask; VkBool32 msEnableAlphaToCoverage; VkBool32 msEnableAlphaToOne;