Implement Maxwell3D Common/Independent Color Write Mask

Maxwell3D supports both independent and common color write masks like color blending but for common color write masks rather than having register state specifically for it, the state from RT 0 is extended to all RTs. It should be noted that color write masks are included in blending state for Vulkan while being entirely independent from each other for Maxwell, it forces us to use the `independentBlend` feature even when we are doing common blending unless the color write mask is common as well but to simplify all this logic the feature was made required as it supported by effectively all targeted devices.
This commit is contained in:
PixelyIon
2021-11-15 23:55:32 +05:30
parent 92809f8a78
commit 48d0b41f16
4 changed files with 48 additions and 6 deletions

View File

@ -721,6 +721,22 @@ namespace skyline::gpu::interconnect {
independentRtBlendState[index].dstAlphaBlendFactor = ConvertBlendFactor(factor);
}
void SetColorWriteMask(u32 index, maxwell3d::ColorWriteMask mask) {
vk::ColorComponentFlags colorWriteMask{};
if (mask.red)
colorWriteMask |= vk::ColorComponentFlagBits::eR;
if (mask.green)
colorWriteMask |= vk::ColorComponentFlagBits::eG;
if (mask.blue)
colorWriteMask |= vk::ColorComponentFlagBits::eB;
if (mask.alpha)
colorWriteMask |= vk::ColorComponentFlagBits::eA;
// While blending state might include the color write mask on Vulkan, they are separate on Maxwell and this results in even `commonRtBlendState` requiring the `independentBlend` feature in certain circumstances where blending state might be the same but with independent color write masks
independentRtBlendState[index].colorWriteMask = colorWriteMask;
commonRtBlendState[index].colorWriteMask = colorWriteMask;
}
void SetColorBlendConstant(u32 index, float constant) {
blendState.blendConstants[index] = constant;
}