1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-31 14:52:11 +01:00

[dxvk] Replicate R component of border color for depth compare samplers (#1194)

Only the red component matters for these samplers -- this lets us pick the best colour based on that alone, as we could get garbage data that doesn't matter in the other components.
This commit is contained in:
Joshua Ashton 2019-09-17 10:15:09 +01:00 committed by Philip Rebohle
parent 2ef34a055d
commit ebc394218a
2 changed files with 10 additions and 3 deletions

View File

@ -29,7 +29,7 @@ namespace dxvk {
if (samplerInfo.addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER
|| samplerInfo.addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER
|| samplerInfo.addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)
samplerInfo.borderColor = getBorderColor(info.borderColor);
samplerInfo.borderColor = getBorderColor(info.compareToDepth, info.borderColor);
if (m_vkd->vkCreateSampler(m_vkd->device(),
&samplerInfo, nullptr, &m_sampler) != VK_SUCCESS)
@ -43,13 +43,20 @@ namespace dxvk {
}
VkBorderColor DxvkSampler::getBorderColor(VkClearColorValue borderColor) const {
VkBorderColor DxvkSampler::getBorderColor(bool depthCompare, VkClearColorValue borderColor) const {
static const std::array<std::pair<VkClearColorValue, VkBorderColor>, 3> s_borderColors = {{
{ { 0.0f, 0.0f, 0.0f, 0.0f }, VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK },
{ { 0.0f, 0.0f, 0.0f, 1.0f }, VK_BORDER_COLOR_FLOAT_OPAQUE_BLACK },
{ { 1.0f, 1.0f, 1.0f, 1.0f }, VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE },
}};
if (depthCompare) {
// If we are a depth compare sampler:
// Replicate the first index, only R matters.
for (uint32_t i = 1; i < 4; i++)
borderColor.float32[i] = borderColor.float32[0];
}
for (const auto& e : s_borderColors) {
if (!std::memcmp(&e.first, &borderColor, sizeof(VkClearColorValue)))
return e.second;

View File

@ -77,7 +77,7 @@ namespace dxvk {
DxvkSamplerCreateInfo m_info;
VkSampler m_sampler = VK_NULL_HANDLE;
VkBorderColor getBorderColor(VkClearColorValue borderColor) const;
VkBorderColor getBorderColor(bool depthCompare, VkClearColorValue borderColor) const;
};