Skip to content

Commit 31159d9

Browse files
committed
wip
1 parent 6f640c5 commit 31159d9

File tree

6 files changed

+17
-3
lines changed

6 files changed

+17
-3
lines changed

HelloVulkan/Header/Vulkan/VulkanContext.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ struct ContextConfig
4444

4545
bool supportBindlessRendering_ = true;
4646

47+
bool supportAnisotropicFilterting = false;
48+
4749
// TODO Set validation layer as optional
4850
};
4951

HelloVulkan/Header/Vulkan/VulkanImage.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ class VulkanImage
7272
float maxLod = 0.f,
7373
VkFilter minFilter = VK_FILTER_LINEAR,
7474
VkFilter maxFilter = VK_FILTER_LINEAR,
75+
VkBool32 anisoptropy = VK_FALSE,
7576
VkSamplerAddressMode addressMode = VK_SAMPLER_ADDRESS_MODE_REPEAT);
7677

7778
void CreateDefaultSampler(
@@ -80,6 +81,7 @@ class VulkanImage
8081
float maxLod = 0.f,
8182
VkFilter minFilter = VK_FILTER_LINEAR,
8283
VkFilter maxFilter = VK_FILTER_LINEAR,
84+
VkBool32 anisoptropy = VK_FALSE,
8385
VkSamplerAddressMode addressMode = VK_SAMPLER_ADDRESS_MODE_REPEAT);
8486

8587
void CreateImage(

HelloVulkan/Source/Apps/AppPBRShadow.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,8 @@ void AppPBRShadow::MainLoop()
214214
{
215215
InitVulkan({
216216
.supportRaytracing_ = false,
217-
.supportMSAA_ = true
217+
.supportMSAA_ = true,
218+
.supportAnisotropicFilterting = true
218219
});
219220
Init();
220221

HelloVulkan/Source/Resources/ResourcesShadow.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ void ResourcesShadow::CreateSingleShadowMap(VulkanContext& ctx)
4343
1.f,
4444
VK_FILTER_LINEAR,
4545
VK_FILTER_LINEAR,
46+
VK_TRUE,
4647
VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE);
4748
shadowMap_.SetDebugName(ctx, "Single_Layer_Shadow_Map");
4849

@@ -80,6 +81,7 @@ void ResourcesShadow::CreateCascadeShadowMap(VulkanContext& ctx)
8081
1.f,
8182
VK_FILTER_LINEAR,
8283
VK_FILTER_LINEAR,
84+
VK_TRUE,
8385
VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE);
8486
shadowMap_.SetDebugName(ctx, "Cascade_Shadow_Map");
8587

HelloVulkan/Source/Vulkan/VulkanContext.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,10 @@ void VulkanContext::ChainFeatures()
196196
features_.drawIndirectFirstInstance = VK_TRUE;
197197
features_.shaderSampledImageArrayDynamicIndexing = VK_TRUE;
198198
}
199+
if (config_.supportAnisotropicFilterting)
200+
{
201+
features_.samplerAnisotropy = VK_TRUE;
202+
}
199203

200204
// NOTE features2_ and features13_ are always created
201205
features13_ =

HelloVulkan/Source/Vulkan/VulkanImage.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ void VulkanImage::CreateDefaultSampler(
359359
float maxLod,
360360
VkFilter minFilter,
361361
VkFilter maxFilter,
362+
VkBool32 anisoptropy,
362363
VkSamplerAddressMode addressMode)
363364
{
364365
CreateSampler(
@@ -368,6 +369,7 @@ void VulkanImage::CreateDefaultSampler(
368369
maxLod,
369370
minFilter,
370371
maxFilter,
372+
anisoptropy,
371373
addressMode
372374
);
373375
}
@@ -379,6 +381,7 @@ void VulkanImage::CreateSampler(
379381
float maxLod,
380382
VkFilter minFilter,
381383
VkFilter maxFilter,
384+
VkBool32 anisoptropy,
382385
VkSamplerAddressMode addressMode)
383386
{
384387
const VkSamplerCreateInfo samplerInfo = {
@@ -392,13 +395,13 @@ void VulkanImage::CreateSampler(
392395
.addressModeV = addressMode,
393396
.addressModeW = addressMode,
394397
.mipLodBias = 0.0f,
395-
.anisotropyEnable = VK_FALSE,
398+
.anisotropyEnable = anisoptropy,
396399
.maxAnisotropy = 1.0f,
397400
.compareEnable = VK_FALSE,
398401
.compareOp = VK_COMPARE_OP_ALWAYS,
399402
.minLod = minLod,
400403
.maxLod = maxLod,
401-
.borderColor = VK_BORDER_COLOR_INT_OPAQUE_BLACK,
404+
.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE,
402405
.unnormalizedCoordinates = VK_FALSE
403406
};
404407
VK_CHECK(vkCreateSampler(ctx.GetDevice(), &samplerInfo, nullptr, &sampler));

0 commit comments

Comments
 (0)