1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-11 10:24:10 +01:00

[dxvk] Enable sample rate shading if needed

This commit is contained in:
Philip Rebohle 2018-04-08 21:49:30 +02:00
parent 797d7ec81d
commit 687ef77860
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
7 changed files with 50 additions and 15 deletions

View File

@ -62,8 +62,6 @@ namespace dxvk {
uint32_t sampleMask; uint32_t sampleMask;
VkBool32 enableAlphaToCoverage; VkBool32 enableAlphaToCoverage;
VkBool32 enableAlphaToOne; VkBool32 enableAlphaToOne;
VkBool32 enableSampleShading;
float minSampleShading;
}; };

View File

@ -1277,8 +1277,6 @@ namespace dxvk {
m_state.gp.state.msSampleMask = ms.sampleMask; m_state.gp.state.msSampleMask = ms.sampleMask;
m_state.gp.state.msEnableAlphaToCoverage = ms.enableAlphaToCoverage; m_state.gp.state.msEnableAlphaToCoverage = ms.enableAlphaToCoverage;
m_state.gp.state.msEnableAlphaToOne = ms.enableAlphaToOne; m_state.gp.state.msEnableAlphaToOne = ms.enableAlphaToOne;
m_state.gp.state.msEnableSampleShading = ms.enableSampleShading;
m_state.gp.state.msMinSampleShading = ms.minSampleShading;
m_flags.set(DxvkContextFlag::GpDirtyPipelineState); m_flags.set(DxvkContextFlag::GpDirtyPipelineState);
} }

View File

@ -64,6 +64,9 @@ namespace dxvk {
m_vsIn = vs != nullptr ? vs->interfaceSlots().inputSlots : 0; m_vsIn = vs != nullptr ? vs->interfaceSlots().inputSlots : 0;
m_fsOut = fs != nullptr ? fs->interfaceSlots().outputSlots : 0; m_fsOut = fs != nullptr ? fs->interfaceSlots().outputSlots : 0;
m_common.msSampleShadingEnable = fs != nullptr && fs->hasCapability(spv::CapabilitySampleRateShading);
m_common.msSampleShadingFactor = 1.0f;
} }
@ -183,8 +186,8 @@ namespace dxvk {
msInfo.pNext = nullptr; msInfo.pNext = nullptr;
msInfo.flags = 0; msInfo.flags = 0;
msInfo.rasterizationSamples = state.msSampleCount; msInfo.rasterizationSamples = state.msSampleCount;
msInfo.sampleShadingEnable = state.msEnableSampleShading; msInfo.sampleShadingEnable = m_common.msSampleShadingEnable;
msInfo.minSampleShading = state.msMinSampleShading; msInfo.minSampleShading = m_common.msSampleShadingFactor;
msInfo.pSampleMask = &state.msSampleMask; msInfo.pSampleMask = &state.msSampleMask;
msInfo.alphaToCoverageEnable = state.msEnableAlphaToCoverage; msInfo.alphaToCoverageEnable = state.msEnableAlphaToCoverage;
msInfo.alphaToOneEnable = state.msEnableAlphaToOne; msInfo.alphaToOneEnable = state.msEnableAlphaToOne;

View File

@ -59,8 +59,6 @@ namespace dxvk {
uint32_t msSampleMask; uint32_t msSampleMask;
VkBool32 msEnableAlphaToCoverage; VkBool32 msEnableAlphaToCoverage;
VkBool32 msEnableAlphaToOne; VkBool32 msEnableAlphaToOne;
VkBool32 msEnableSampleShading;
float msMinSampleShading;
VkBool32 dsEnableDepthTest; VkBool32 dsEnableDepthTest;
VkBool32 dsEnableDepthWrite; VkBool32 dsEnableDepthWrite;
@ -79,6 +77,18 @@ namespace dxvk {
}; };
/**
* \brief Common graphics pipeline state
*
* Non-dynamic pipeline state that cannot
* be changed dynamically.
*/
struct DxvkGraphicsCommonPipelineStateInfo {
bool msSampleShadingEnable;
float msSampleShadingFactor;
};
/** /**
* \brief Graphics pipeline * \brief Graphics pipeline
* *
@ -147,6 +157,8 @@ namespace dxvk {
uint32_t m_vsIn = 0; uint32_t m_vsIn = 0;
uint32_t m_fsOut = 0; uint32_t m_fsOut = 0;
DxvkGraphicsCommonPipelineStateInfo m_common;
std::vector<PipelineStruct> m_pipelines; std::vector<PipelineStruct> m_pipelines;
VkPipeline m_basePipeline = VK_NULL_HANDLE; VkPipeline m_basePipeline = VK_NULL_HANDLE;

View File

@ -57,6 +57,20 @@ namespace dxvk {
} }
bool DxvkShader::hasCapability(spv::Capability cap) {
for (auto ins : m_code) {
// OpCapability instructions come first
if (ins.opCode() != spv::OpCapability)
return false;
if (ins.arg(1) == cap)
return true;
}
return false;
}
void DxvkShader::defineResourceSlots( void DxvkShader::defineResourceSlots(
DxvkDescriptorSlotMapping& mapping) const { DxvkDescriptorSlotMapping& mapping) const {
for (const auto& slot : m_slots) for (const auto& slot : m_slots)

View File

@ -98,6 +98,18 @@ namespace dxvk {
~DxvkShader(); ~DxvkShader();
/**
* \brief Checks whether a capability is enabled
*
* If the shader contains an \c OpCapability
* instruction with the given capability, it
* is considered enabled. This may be required
* to correctly set up certain pipeline states.
* \param [in] cap The capability to check
* \returns \c true if \c cap is enabled
*/
bool hasCapability(spv::Capability cap);
/** /**
* \brief Adds resource slots definitions to a mapping * \brief Adds resource slots definitions to a mapping
* *

View File

@ -198,8 +198,6 @@ namespace dxvk::hud {
msState.sampleMask = 0xFFFFFFFF; msState.sampleMask = 0xFFFFFFFF;
msState.enableAlphaToCoverage = VK_FALSE; msState.enableAlphaToCoverage = VK_FALSE;
msState.enableAlphaToOne = VK_FALSE; msState.enableAlphaToOne = VK_FALSE;
msState.enableSampleShading = VK_FALSE;
msState.minSampleShading = 1.0f;
m_context->setMultisampleState(msState); m_context->setMultisampleState(msState);
VkStencilOpState stencilOp; VkStencilOpState stencilOp;