mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-31 14:52:11 +01:00
[dxvk] Use packed multisample state
This commit is contained in:
parent
09c813c934
commit
a933bec72c
@ -2295,8 +2295,10 @@ namespace dxvk {
|
||||
|
||||
|
||||
void DxvkContext::setMultisampleState(const DxvkMultisampleState& ms) {
|
||||
m_state.gp.state.msSampleMask = ms.sampleMask;
|
||||
m_state.gp.state.msEnableAlphaToCoverage = ms.enableAlphaToCoverage;
|
||||
m_state.gp.state.ms = DxvkMsInfo(
|
||||
m_state.gp.state.ms.sampleCount(),
|
||||
ms.sampleMask,
|
||||
ms.enableAlphaToCoverage);
|
||||
|
||||
m_flags.set(DxvkContextFlag::GpDirtyPipelineState);
|
||||
}
|
||||
@ -3973,7 +3975,7 @@ namespace dxvk {
|
||||
|
||||
auto fb = m_device->createFramebuffer(m_state.om.renderTargets);
|
||||
|
||||
m_state.gp.state.msSampleCount = fb->getSampleCount();
|
||||
m_state.gp.state.ms.setSampleCount(fb->getSampleCount());
|
||||
m_state.om.framebuffer = fb;
|
||||
|
||||
for (uint32_t i = 0; i < MaxNumRenderTargets; i++) {
|
||||
|
@ -158,8 +158,8 @@ namespace dxvk {
|
||||
// Figure out the actual sample count to use
|
||||
VkSampleCountFlagBits sampleCount = VK_SAMPLE_COUNT_1_BIT;
|
||||
|
||||
if (state.msSampleCount)
|
||||
sampleCount = VkSampleCountFlagBits(state.msSampleCount);
|
||||
if (state.ms.sampleCount())
|
||||
sampleCount = VkSampleCountFlagBits(state.ms.sampleCount());
|
||||
else if (state.rs.sampleCount())
|
||||
sampleCount = VkSampleCountFlagBits(state.rs.sampleCount());
|
||||
|
||||
@ -341,6 +341,8 @@ namespace dxvk {
|
||||
rsInfo.depthClampEnable = !state.rs.depthClipEnable();
|
||||
}
|
||||
|
||||
uint32_t sampleMask = state.ms.sampleMask();
|
||||
|
||||
VkPipelineMultisampleStateCreateInfo msInfo;
|
||||
msInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
|
||||
msInfo.pNext = nullptr;
|
||||
@ -348,8 +350,8 @@ namespace dxvk {
|
||||
msInfo.rasterizationSamples = sampleCount;
|
||||
msInfo.sampleShadingEnable = m_common.msSampleShadingEnable;
|
||||
msInfo.minSampleShading = m_common.msSampleShadingFactor;
|
||||
msInfo.pSampleMask = &state.msSampleMask;
|
||||
msInfo.alphaToCoverageEnable = state.msEnableAlphaToCoverage;
|
||||
msInfo.pSampleMask = &sampleMask;
|
||||
msInfo.alphaToCoverageEnable = state.ms.enableAlphaToCoverage();
|
||||
msInfo.alphaToOneEnable = VK_FALSE;
|
||||
|
||||
VkPipelineDepthStencilStateCreateInfo dsInfo;
|
||||
|
@ -282,6 +282,53 @@ namespace dxvk {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* \brief Packed multisample info
|
||||
*
|
||||
* Stores the sample mask, sample count override
|
||||
* and alpha-to-coverage state in four bytes.
|
||||
*/
|
||||
class DxvkMsInfo {
|
||||
|
||||
public:
|
||||
|
||||
DxvkMsInfo() = default;
|
||||
|
||||
DxvkMsInfo(
|
||||
VkSampleCountFlags sampleCount,
|
||||
uint32_t sampleMask,
|
||||
VkBool32 enableAlphaToCoverage)
|
||||
: m_sampleCount (uint16_t(sampleCount)),
|
||||
m_enableAlphaToCoverage (uint16_t(enableAlphaToCoverage)),
|
||||
m_reserved (0),
|
||||
m_sampleMask (uint16_t(sampleMask)) { }
|
||||
|
||||
VkSampleCountFlags sampleCount() const {
|
||||
return VkSampleCountFlags(m_sampleCount);
|
||||
}
|
||||
|
||||
uint32_t sampleMask() const {
|
||||
return m_sampleMask;
|
||||
}
|
||||
|
||||
VkBool32 enableAlphaToCoverage() const {
|
||||
return VkBool32(m_enableAlphaToCoverage);
|
||||
}
|
||||
|
||||
void setSampleCount(VkSampleCountFlags sampleCount) {
|
||||
m_sampleCount = uint16_t(sampleCount);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
uint16_t m_sampleCount : 5;
|
||||
uint16_t m_enableAlphaToCoverage : 1;
|
||||
uint16_t m_reserved : 10;
|
||||
uint16_t m_sampleMask;
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* \brief Packed graphics pipeline state
|
||||
*
|
||||
@ -341,10 +388,7 @@ namespace dxvk {
|
||||
DxvkIaInfo ia;
|
||||
DxvkIlInfo il;
|
||||
DxvkRsInfo rs;
|
||||
|
||||
VkSampleCountFlags msSampleCount;
|
||||
uint32_t msSampleMask;
|
||||
VkBool32 msEnableAlphaToCoverage;
|
||||
DxvkMsInfo ms;
|
||||
|
||||
VkBool32 dsEnableDepthTest;
|
||||
VkBool32 dsEnableDepthWrite;
|
||||
|
Loading…
x
Reference in New Issue
Block a user