Skip to content

Commit 9f7db42

Browse files
committed
Anisotropy Feature/Limit added to PhysicalDevice
1 parent ab06cf7 commit 9f7db42

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

include/nbl/video/IPhysicalDevice.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class IPhysicalDevice : public core::Interface, public core::Unmovable
2929
uint32_t UBOAlignment;
3030
uint32_t SSBOAlignment;
3131
uint32_t bufferViewAlignment;
32+
float maxSamplerAnisotropyLog2;
3233

3334
uint32_t maxUBOSize;
3435
uint32_t maxSSBOSize;
@@ -130,6 +131,7 @@ class IPhysicalDevice : public core::Interface, public core::Unmovable
130131
bool shaderSubgroupQuadAllStages = false;
131132
bool drawIndirectCount = false;
132133
bool multiDrawIndirect = false;
134+
bool samplerAnisotropy = false;
133135

134136
// RayQuery
135137
bool rayQuery = false;

src/nbl/video/CVulkanLogicalDevice.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -863,8 +863,9 @@ class CVulkanLogicalDevice final : public ILogicalDevice
863863
vk_createInfo.addressModeV = getVkAddressModeFromTexClamp(static_cast<asset::ISampler::E_TEXTURE_CLAMP>(_params.TextureWrapV));
864864
vk_createInfo.addressModeW = getVkAddressModeFromTexClamp(static_cast<asset::ISampler::E_TEXTURE_CLAMP>(_params.TextureWrapW));
865865
vk_createInfo.mipLodBias = _params.LodBias;
866-
vk_createInfo.maxAnisotropy = std::exp2(_params.AnisotropicFilter); // Todo(achal): Verify
867-
vk_createInfo.anisotropyEnable = VK_FALSE; // vk_createInfo.maxAnisotropy < 1.f ? VK_FALSE : VK_TRUE; // Todo(achal): Verify. Also this needs to take into account if the anistropic sampling feature is enabled
866+
assert(_params.AnisotropicFilter <= m_physicalDevice->getLimits().maxSamplerAnisotropyLog2);
867+
vk_createInfo.maxAnisotropy = std::exp2(_params.AnisotropicFilter);
868+
vk_createInfo.anisotropyEnable = m_physicalDevice->getFeatures().samplerAnisotropy;
868869
vk_createInfo.compareEnable = _params.CompareEnable;
869870
vk_createInfo.compareOp = static_cast<VkCompareOp>(_params.CompareFunc);
870871
vk_createInfo.minLod = _params.MinLod;

src/nbl/video/CVulkanPhysicalDevice.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ class CVulkanPhysicalDevice final : public IPhysicalDevice
4242
m_limits.UBOAlignment = deviceProperties.properties.limits.minUniformBufferOffsetAlignment;
4343
m_limits.SSBOAlignment = deviceProperties.properties.limits.minStorageBufferOffsetAlignment;
4444
m_limits.bufferViewAlignment = deviceProperties.properties.limits.minTexelBufferOffsetAlignment;
45-
45+
m_limits.maxSamplerAnisotropyLog2 = std::log2(deviceProperties.properties.limits.maxSamplerAnisotropy);
46+
4647
m_limits.maxUBOSize = deviceProperties.properties.limits.maxUniformBufferRange;
4748
m_limits.maxSSBOSize = deviceProperties.properties.limits.maxStorageBufferRange;
4849
m_limits.maxBufferViewSizeTexels = deviceProperties.properties.limits.maxTexelBufferElements;
@@ -138,6 +139,7 @@ class CVulkanPhysicalDevice final : public IPhysicalDevice
138139
m_features.imageCubeArray = features.imageCubeArray;
139140
m_features.logicOp = features.logicOp;
140141
m_features.multiDrawIndirect = features.multiDrawIndirect;
142+
m_features.samplerAnisotropy = features.samplerAnisotropy;
141143
m_features.multiViewport = features.multiViewport;
142144
m_features.vertexAttributeDouble = features.shaderFloat64;
143145
m_features.dispatchBase = false; // Todo(achal): Umm.. what is this? Whether you can call VkCmdDispatchBase with non zero base args
@@ -151,7 +153,6 @@ class CVulkanPhysicalDevice final : public IPhysicalDevice
151153
m_features.shaderSubgroupQuad = subgroupProperties.supportedOperations & VK_SUBGROUP_FEATURE_QUAD_BIT;
152154
m_features.shaderSubgroupQuadAllStages = ((subgroupProperties.supportedStages & asset::IShader::E_SHADER_STAGE::ESS_ALL)
153155
== asset::IShader::E_SHADER_STAGE::ESS_ALL);
154-
155156

156157
// RayQuery
157158
if (m_availableFeatureSet.find(VK_KHR_RAY_QUERY_EXTENSION_NAME) != m_availableFeatureSet.end())

0 commit comments

Comments
 (0)