mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-19 05:52:11 +01:00
[dxvk] Refactor DxvkSampler::getBorderColor
This commit is contained in:
parent
7b81db2c75
commit
0648314451
@ -30,7 +30,7 @@ namespace dxvk {
|
|||||||
if (samplerInfo.addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER
|
if (samplerInfo.addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER
|
||||||
|| samplerInfo.addressModeV == 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.addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)
|
||||||
samplerInfo.borderColor = getBorderColor(info.compareToDepth, info.borderColor);
|
samplerInfo.borderColor = getBorderColor(device, info);
|
||||||
|
|
||||||
if (m_vkd->vkCreateSampler(m_vkd->device(),
|
if (m_vkd->vkCreateSampler(m_vkd->device(),
|
||||||
&samplerInfo, nullptr, &m_sampler) != VK_SUCCESS)
|
&samplerInfo, nullptr, &m_sampler) != VK_SUCCESS)
|
||||||
@ -44,29 +44,27 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VkBorderColor DxvkSampler::getBorderColor(bool depthCompare, VkClearColorValue borderColor) const {
|
VkBorderColor DxvkSampler::getBorderColor(const Rc<DxvkDevice>& device, const DxvkSamplerCreateInfo& info) {
|
||||||
static const std::array<std::pair<VkClearColorValue, VkBorderColor>, 3> s_borderColors = {{
|
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, 0.0f } }, VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK },
|
||||||
{ { { 0.0f, 0.0f, 0.0f, 1.0f } }, VK_BORDER_COLOR_FLOAT_OPAQUE_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 },
|
{ { { 1.0f, 1.0f, 1.0f, 1.0f } }, VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE },
|
||||||
}};
|
}};
|
||||||
|
|
||||||
if (depthCompare) {
|
// Ignore G/B/A components for shadow samplers
|
||||||
// If we are a depth compare sampler:
|
size_t size = !info.compareToDepth
|
||||||
// Replicate the first index, only R matters.
|
? sizeof(VkClearColorValue)
|
||||||
for (uint32_t i = 1; i < 4; i++)
|
: sizeof(float);
|
||||||
borderColor.float32[i] = borderColor.float32[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const auto& e : s_borderColors) {
|
for (const auto& e : s_borderColors) {
|
||||||
if (!std::memcmp(&e.first, &borderColor, sizeof(VkClearColorValue)))
|
if (!std::memcmp(&e.first, &info.borderColor, size))
|
||||||
return e.second;
|
return e.second;
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::warn(str::format(
|
Logger::warn(str::format(
|
||||||
"DXVK: No matching border color found for (",
|
"DXVK: No matching border color found for (",
|
||||||
borderColor.float32[0], ",", borderColor.float32[1], ",",
|
info.borderColor.float32[0], ",", info.borderColor.float32[1], ",",
|
||||||
borderColor.float32[2], ",", borderColor.float32[3], ")"));
|
info.borderColor.float32[2], ",", info.borderColor.float32[3], ")"));
|
||||||
return VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK;
|
return VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +70,9 @@ namespace dxvk {
|
|||||||
Rc<vk::DeviceFn> m_vkd;
|
Rc<vk::DeviceFn> m_vkd;
|
||||||
VkSampler m_sampler = VK_NULL_HANDLE;
|
VkSampler m_sampler = VK_NULL_HANDLE;
|
||||||
|
|
||||||
VkBorderColor getBorderColor(bool depthCompare, VkClearColorValue borderColor) const;
|
static VkBorderColor getBorderColor(
|
||||||
|
const Rc<DxvkDevice>& device,
|
||||||
|
const DxvkSamplerCreateInfo& info);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user