Skip to content

Commit f7a203d

Browse files
monitored swapchain image count (#477)
1 parent 814a6cf commit f7a203d

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

ZEngine/ZEngine/Hardwares/VulkanDevice.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,8 @@ namespace ZEngine::Hardwares
893893
sampler_create_info.addressModeU = VK_SAMPLER_ADDRESS_MODE_REPEAT;
894894
sampler_create_info.addressModeV = VK_SAMPLER_ADDRESS_MODE_REPEAT;
895895
sampler_create_info.addressModeW = VK_SAMPLER_ADDRESS_MODE_REPEAT;
896-
sampler_create_info.maxAnisotropy = PhysicalDeviceProperties.limits.maxSamplerAnisotropy;
896+
sampler_create_info.anisotropyEnable = PhysicalDeviceFeature.samplerAnisotropy;
897+
sampler_create_info.maxAnisotropy = PhysicalDeviceFeature.samplerAnisotropy ? PhysicalDeviceProperties.limits.maxSamplerAnisotropy : 1.0f;
897898
sampler_create_info.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE;
898899
sampler_create_info.unnormalizedCoordinates = VK_FALSE;
899900
sampler_create_info.compareEnable = VK_FALSE;
@@ -1095,7 +1096,15 @@ namespace ZEngine::Hardwares
10951096

10961097
ZENGINE_VALIDATE_ASSERT(vkCreateSwapchainKHR(LogicalDevice, &swapchain_create_info, nullptr, &SwapchainHandle) == VK_SUCCESS, "Failed to create Swapchain")
10971098

1098-
ZENGINE_VALIDATE_ASSERT(vkGetSwapchainImagesKHR(LogicalDevice, SwapchainHandle, &SwapchainImageCount, nullptr) == VK_SUCCESS, "Failed to get Images count from Swapchain")
1099+
uint32_t image_count = 0;
1100+
ZENGINE_VALIDATE_ASSERT(vkGetSwapchainImagesKHR(LogicalDevice, SwapchainHandle, &image_count, nullptr) == VK_SUCCESS, "Failed to get Images count from Swapchain")
1101+
1102+
if (image_count < SwapchainImageCount)
1103+
{
1104+
ZENGINE_CORE_WARN("Max Swapchain image count supported is {}, but requested {}", image_count, SwapchainImageCount);
1105+
SwapchainImageCount = image_count;
1106+
ZENGINE_CORE_WARN("Swapchain image count has changed from {} to {}", SwapchainImageCount, image_count);
1107+
}
10991108

11001109
Array<VkImage> SwapchainImages = {};
11011110
SwapchainImages.init(scratch.Arena, SwapchainImageCount, SwapchainImageCount);

0 commit comments

Comments
 (0)