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

[dxvk] Implement sampler reduction mode

This commit is contained in:
Philip Rebohle 2022-08-25 16:05:15 +02:00
parent 43b19f773c
commit 2329c71b6f
8 changed files with 17 additions and 1 deletions

View File

@ -34,6 +34,8 @@ namespace dxvk {
info.compareToDepth = (filterBits & 0x80) ? VK_TRUE : VK_FALSE; info.compareToDepth = (filterBits & 0x80) ? VK_TRUE : VK_FALSE;
info.compareOp = DecodeCompareOp(desc.ComparisonFunc); info.compareOp = DecodeCompareOp(desc.ComparisonFunc);
info.reductionMode = VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE;
for (uint32_t i = 0; i < 4; i++) for (uint32_t i = 0; i < 4; i++)
info.borderColor.float32[i] = desc.BorderColor[i]; info.borderColor.float32[i] = desc.BorderColor[i];

View File

@ -362,6 +362,7 @@ namespace dxvk {
samplerInfo.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; samplerInfo.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
samplerInfo.compareToDepth = VK_FALSE; samplerInfo.compareToDepth = VK_FALSE;
samplerInfo.compareOp = VK_COMPARE_OP_ALWAYS; samplerInfo.compareOp = VK_COMPARE_OP_ALWAYS;
samplerInfo.reductionMode = VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE;
samplerInfo.borderColor = VkClearColorValue(); samplerInfo.borderColor = VkClearColorValue();
samplerInfo.usePixelCoord = VK_FALSE; samplerInfo.usePixelCoord = VK_FALSE;
samplerInfo.nonSeamless = VK_FALSE; samplerInfo.nonSeamless = VK_FALSE;

View File

@ -5978,6 +5978,7 @@ namespace dxvk {
info.mipmapLodBias = cKey.MipmapLodBias; info.mipmapLodBias = cKey.MipmapLodBias;
info.mipmapLodMin = mipFilter.MipsEnabled ? float(cKey.MaxMipLevel) : 0; info.mipmapLodMin = mipFilter.MipsEnabled ? float(cKey.MaxMipLevel) : 0;
info.mipmapLodMax = mipFilter.MipsEnabled ? FLT_MAX : 0; info.mipmapLodMax = mipFilter.MipsEnabled ? FLT_MAX : 0;
info.reductionMode = VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE;
info.usePixelCoord = VK_FALSE; info.usePixelCoord = VK_FALSE;
info.nonSeamless = m_dxvkDevice->features().extNonSeamlessCubeMap.nonSeamlessCubeMap && !m_d3d9Options.seamlessCubes; info.nonSeamless = m_dxvkDevice->features().extNonSeamlessCubeMap.nonSeamlessCubeMap && !m_d3d9Options.seamlessCubes;

View File

@ -10,6 +10,9 @@ namespace dxvk {
VkSamplerCustomBorderColorCreateInfoEXT borderColorInfo = { VK_STRUCTURE_TYPE_SAMPLER_CUSTOM_BORDER_COLOR_CREATE_INFO_EXT }; VkSamplerCustomBorderColorCreateInfoEXT borderColorInfo = { VK_STRUCTURE_TYPE_SAMPLER_CUSTOM_BORDER_COLOR_CREATE_INFO_EXT };
borderColorInfo.customBorderColor = info.borderColor; borderColorInfo.customBorderColor = info.borderColor;
VkSamplerReductionModeCreateInfo reductionInfo = { VK_STRUCTURE_TYPE_SAMPLER_REDUCTION_MODE_CREATE_INFO };
reductionInfo.reductionMode = info.reductionMode;
VkSamplerCreateInfo samplerInfo = { VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO }; VkSamplerCreateInfo samplerInfo = { VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO };
samplerInfo.flags = info.nonSeamless ? VK_SAMPLER_CREATE_NON_SEAMLESS_CUBE_MAP_BIT_EXT : 0; samplerInfo.flags = info.nonSeamless ? VK_SAMPLER_CREATE_NON_SEAMLESS_CUBE_MAP_BIT_EXT : 0;
samplerInfo.magFilter = info.magFilter; samplerInfo.magFilter = info.magFilter;
@ -39,6 +42,9 @@ namespace dxvk {
if (samplerInfo.borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) if (samplerInfo.borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT)
borderColorInfo.pNext = std::exchange(samplerInfo.pNext, &borderColorInfo); borderColorInfo.pNext = std::exchange(samplerInfo.pNext, &borderColorInfo);
if (reductionInfo.reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE)
reductionInfo.pNext = std::exchange(samplerInfo.pNext, &reductionInfo);
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)
throw DxvkError("DxvkSampler::DxvkSampler: Failed to create sampler"); throw DxvkError("DxvkSampler::DxvkSampler: Failed to create sampler");

View File

@ -33,9 +33,12 @@ namespace dxvk {
VkBool32 compareToDepth; VkBool32 compareToDepth;
VkCompareOp compareOp; VkCompareOp compareOp;
/// Reduction mode for min/max samplers
VkSamplerReductionMode reductionMode;
/// Texture border color /// Texture border color
VkClearColorValue borderColor; VkClearColorValue borderColor;
/// Enables unnormalized coordinates /// Enables unnormalized coordinates
VkBool32 usePixelCoord; VkBool32 usePixelCoord;

View File

@ -301,6 +301,7 @@ namespace dxvk {
samplerInfo.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER; samplerInfo.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER;
samplerInfo.compareToDepth = VK_FALSE; samplerInfo.compareToDepth = VK_FALSE;
samplerInfo.compareOp = VK_COMPARE_OP_ALWAYS; samplerInfo.compareOp = VK_COMPARE_OP_ALWAYS;
samplerInfo.reductionMode = VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE;
samplerInfo.borderColor = VkClearColorValue(); samplerInfo.borderColor = VkClearColorValue();
samplerInfo.usePixelCoord = VK_TRUE; samplerInfo.usePixelCoord = VK_TRUE;
samplerInfo.nonSeamless = VK_FALSE; samplerInfo.nonSeamless = VK_FALSE;

View File

@ -29,6 +29,7 @@ namespace dxvk {
info.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; info.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
info.compareToDepth = VK_FALSE; info.compareToDepth = VK_FALSE;
info.compareOp = VK_COMPARE_OP_NEVER; info.compareOp = VK_COMPARE_OP_NEVER;
info.reductionMode = VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE;
info.borderColor = VkClearColorValue(); info.borderColor = VkClearColorValue();
info.usePixelCoord = VK_FALSE; info.usePixelCoord = VK_FALSE;
info.nonSeamless = VK_FALSE; info.nonSeamless = VK_FALSE;

View File

@ -309,6 +309,7 @@ namespace dxvk::hud {
info.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; info.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
info.compareToDepth = VK_FALSE; info.compareToDepth = VK_FALSE;
info.compareOp = VK_COMPARE_OP_NEVER; info.compareOp = VK_COMPARE_OP_NEVER;
info.reductionMode = VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE;
info.borderColor = VkClearColorValue(); info.borderColor = VkClearColorValue();
info.usePixelCoord = VK_TRUE; info.usePixelCoord = VK_TRUE;
info.nonSeamless = VK_FALSE; info.nonSeamless = VK_FALSE;