Add support for VK_EXT_sampler_filter_minmax extension

This commit is contained in:
baldurk
2018-04-30 10:50:46 +01:00
parent 7e651085cb
commit 7182e0af3a
9 changed files with 73 additions and 6 deletions
+17 -1
View File
@@ -1493,7 +1493,7 @@ static FilterMode MakeFilterMode(VkSamplerMipmapMode f)
}
TextureFilter MakeFilter(VkFilter minFilter, VkFilter magFilter, VkSamplerMipmapMode mipmapMode,
bool anisoEnable, bool compareEnable)
bool anisoEnable, bool compareEnable, VkSamplerReductionModeEXT reduction)
{
TextureFilter ret;
@@ -1509,6 +1509,22 @@ TextureFilter MakeFilter(VkFilter minFilter, VkFilter magFilter, VkSamplerMipmap
}
ret.filter = compareEnable ? FilterFunction::Comparison : FilterFunction::Normal;
if(compareEnable)
{
ret.filter = FilterFunction::Comparison;
}
else
{
switch(reduction)
{
case VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE_EXT:
ret.filter = FilterFunction::Normal;
break;
case VK_SAMPLER_REDUCTION_MODE_MIN_EXT: ret.filter = FilterFunction::Minimum; break;
case VK_SAMPLER_REDUCTION_MODE_MAX_EXT: ret.filter = FilterFunction::Maximum; break;
}
}
return ret;
}
+5 -2
View File
@@ -94,7 +94,7 @@ AddressMode MakeAddressMode(VkSamplerAddressMode addr);
void MakeBorderColor(VkBorderColor border, FloatVector *BorderColor);
CompareFunction MakeCompareFunc(VkCompareOp func);
TextureFilter MakeFilter(VkFilter minFilter, VkFilter magFilter, VkSamplerMipmapMode mipmapMode,
bool anisoEnable, bool compareEnable);
bool anisoEnable, bool compareEnable, VkSamplerReductionModeEXT reduction);
LogicOperation MakeLogicOp(VkLogicOp op);
BlendMultiplier MakeBlendMultiplier(VkBlendFactor blend);
BlendOperation MakeBlendOp(VkBlendOp op);
@@ -627,6 +627,7 @@ DECLARE_REFLECTION_STRUCT(VkInputAttachmentAspectReference);
DECLARE_REFLECTION_STRUCT(VkRenderPassInputAttachmentAspectCreateInfoKHR);
DECLARE_REFLECTION_STRUCT(VkVertexInputBindingDivisorDescriptionEXT);
DECLARE_REFLECTION_STRUCT(VkPipelineVertexInputDivisorStateCreateInfoEXT);
DECLARE_REFLECTION_STRUCT(VkSamplerReductionModeCreateInfoEXT);
DECLARE_DESERIALISE_TYPE(VkDeviceCreateInfo);
DECLARE_DESERIALISE_TYPE(VkBufferCreateInfo);
@@ -671,6 +672,7 @@ DECLARE_DESERIALISE_TYPE(VkPipelineTessellationDomainOriginStateCreateInfoKHR);
DECLARE_DESERIALISE_TYPE(VkImageViewUsageCreateInfoKHR);
DECLARE_DESERIALISE_TYPE(VkRenderPassInputAttachmentAspectCreateInfoKHR);
DECLARE_DESERIALISE_TYPE(VkPipelineVertexInputDivisorStateCreateInfoEXT);
DECLARE_DESERIALISE_TYPE(VkSamplerReductionModeCreateInfoEXT);
DECLARE_REFLECTION_ENUM(VkFlagWithNoBits);
DECLARE_REFLECTION_ENUM(VkQueueFlagBits);
@@ -737,4 +739,5 @@ DECLARE_REFLECTION_ENUM(VkColorSpaceKHR);
DECLARE_REFLECTION_ENUM(VkPresentModeKHR);
DECLARE_REFLECTION_ENUM(VkDescriptorUpdateTemplateType);
DECLARE_REFLECTION_ENUM(VkConservativeRasterizationModeEXT);
DECLARE_REFLECTION_ENUM(VkTessellationDomainOriginKHR);
DECLARE_REFLECTION_ENUM(VkTessellationDomainOriginKHR);
DECLARE_REFLECTION_ENUM(VkSamplerReductionModeEXT);
+3
View File
@@ -555,6 +555,9 @@ static const VkExtensionProperties supportedExtensions[] = {
{
VK_EXT_GLOBAL_PRIORITY_EXTENSION_NAME, VK_EXT_GLOBAL_PRIORITY_SPEC_VERSION,
},
{
VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME, VK_EXT_SAMPLER_FILTER_MINMAX_SPEC_VERSION,
},
{
VK_EXT_SHADER_SUBGROUP_BALLOT_EXTENSION_NAME, VK_EXT_SHADER_SUBGROUP_BALLOT_SPEC_VERSION,
},
+2 -1
View File
@@ -325,7 +325,8 @@
CheckExt(EXT_conservative_rasterization, VKXX); \
CheckExt(EXT_global_priority, VKXX); \
CheckExt(AMD_buffer_marker, VKXX); \
CheckExt(EXT_vertex_attribute_divisor, VKXX);
CheckExt(EXT_vertex_attribute_divisor, VKXX); \
CheckExt(EXT_sampler_filter_minmax, VKXX);
#define HookInitVulkanInstanceExts() \
HookInitExtension(KHR_surface, DestroySurfaceKHR); \
+10
View File
@@ -632,6 +632,16 @@ void VulkanCreationInfo::Sampler::Init(VulkanResourceManager *resourceMan, Vulka
maxLod = pCreateInfo->maxLod;
borderColor = pCreateInfo->borderColor;
unnormalizedCoordinates = pCreateInfo->unnormalizedCoordinates != 0;
reductionMode = VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE_EXT;
const VkSamplerReductionModeCreateInfoEXT *reduction =
(const VkSamplerReductionModeCreateInfoEXT *)FindNextStruct(
pCreateInfo, VK_STRUCTURE_TYPE_SAMPLER_REDUCTION_MODE_CREATE_INFO_EXT);
if(reduction)
{
reductionMode = reduction->reductionMode;
}
}
static TextureSwizzle Convert(VkComponentSwizzle s, int i)
+1
View File
@@ -372,6 +372,7 @@ struct VulkanCreationInfo
float maxLod;
VkBorderColor borderColor;
bool unnormalizedCoordinates;
VkSamplerReductionModeEXT reductionMode;
};
map<ResourceId, Sampler> m_Sampler;
+2 -1
View File
@@ -1307,7 +1307,8 @@ void VulkanReplay::SavePipelineState()
// sampler info
el.filter = MakeFilter(sampl.minFilter, sampl.magFilter, sampl.mipmapMode,
sampl.maxAnisotropy > 1.0f, sampl.compareEnable);
sampl.maxAnisotropy > 1.0f, sampl.compareEnable,
sampl.reductionMode);
el.addressU = MakeAddressMode(sampl.address[0]);
el.addressV = MakeAddressMode(sampl.address[1]);
el.addressW = MakeAddressMode(sampl.address[2]);
+21 -1
View File
@@ -182,7 +182,11 @@ SERIALISE_VK_HANDLES();
\
/* VK_EXT_vertex_attribute_divisor */ \
PNEXT_STRUCT(VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT, \
VkPipelineVertexInputDivisorStateCreateInfoEXT)
VkPipelineVertexInputDivisorStateCreateInfoEXT) \
\
/* VK_EXT_sampler_filter_minmax */ \
PNEXT_STRUCT(VK_STRUCTURE_TYPE_SAMPLER_REDUCTION_MODE_CREATE_INFO_EXT, \
VkSamplerReductionModeCreateInfoEXT)
template <typename SerialiserType>
static void SerialiseNext(SerialiserType &ser, VkStructureType &sType, const void *&pNext)
@@ -2330,6 +2334,21 @@ void Deserialise(const VkPipelineVertexInputDivisorStateCreateInfoEXT &el)
delete[] el.pVertexBindingDivisors;
}
template <typename SerialiserType>
void DoSerialise(SerialiserType &ser, VkSamplerReductionModeCreateInfoEXT &el)
{
RDCASSERT(ser.IsReading() || el.sType == VK_STRUCTURE_TYPE_SAMPLER_REDUCTION_MODE_CREATE_INFO_EXT);
SerialiseNext(ser, el.sType, el.pNext);
SERIALISE_MEMBER(reductionMode);
}
template <>
void Deserialise(const VkSamplerReductionModeCreateInfoEXT &el)
{
DeserialiseNext(el.pNext);
}
INSTANTIATE_SERIALISE_TYPE(VkOffset2D);
INSTANTIATE_SERIALISE_TYPE(VkExtent2D);
INSTANTIATE_SERIALISE_TYPE(VkMemoryType);
@@ -2432,6 +2451,7 @@ INSTANTIATE_SERIALISE_TYPE(VkBindBufferMemoryInfoKHR);
INSTANTIATE_SERIALISE_TYPE(VkBindImageMemoryInfoKHR);
INSTANTIATE_SERIALISE_TYPE(VkPipelineRasterizationConservativeStateCreateInfoEXT);
INSTANTIATE_SERIALISE_TYPE(VkPipelineVertexInputDivisorStateCreateInfoEXT);
INSTANTIATE_SERIALISE_TYPE(VkSamplerReductionModeCreateInfoEXT);
INSTANTIATE_SERIALISE_TYPE(DescriptorSetSlot);
INSTANTIATE_SERIALISE_TYPE(ImageRegionState);
+12
View File
@@ -1712,6 +1712,18 @@ std::string DoStringise(const VkTessellationDomainOriginKHR &el)
END_ENUM_STRINGISE();
}
template <>
std::string DoStringise(const VkSamplerReductionModeEXT &el)
{
BEGIN_ENUM_STRINGISE(VkSamplerReductionModeEXT);
{
STRINGISE_ENUM(VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE_EXT)
STRINGISE_ENUM(VK_SAMPLER_REDUCTION_MODE_MIN_EXT)
STRINGISE_ENUM(VK_SAMPLER_REDUCTION_MODE_MAX_EXT)
}
END_ENUM_STRINGISE();
}
template <>
std::string DoStringise(const VkExtent3D &el)
{