From 34ede255a91299d67e581e3804114f6d0fff7f0e Mon Sep 17 00:00:00 2001 From: Bill Hollings Date: Thu, 22 Jun 2017 17:55:57 -0400 Subject: [PATCH] Remove use of unportable fls() function from multisampling.cpp. --- multisampling/multisampling.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/multisampling/multisampling.cpp b/multisampling/multisampling.cpp index bf4da6fe..40875797 100644 --- a/multisampling/multisampling.cpp +++ b/multisampling/multisampling.cpp @@ -8,7 +8,6 @@ #include #include -#include #include #include #include @@ -694,7 +693,7 @@ public: void prepare() { - setSampleCount(); + sampleCount = getMaxUsableSampleCount(); VulkanExampleBase::prepare(); loadAssets(); setupVertexDescriptions(); @@ -736,13 +735,19 @@ public: } } - // Determine the maximum sample count usable by the platform - void setSampleCount() + // Returns the maximum sample count usable by the platform + VkSampleCountFlagBits getMaxUsableSampleCount() { - VkSampleCountFlags flags = std::min(deviceProperties.limits.framebufferColorSampleCounts, + VkSampleCountFlags counts = std::min(deviceProperties.limits.framebufferColorSampleCounts, deviceProperties.limits.framebufferDepthSampleCounts); - // Extract the value of the high-order bit of the flags - sampleCount = (VkSampleCountFlagBits)(flags ? (1 << (fls(flags) - 1)) : 0); + + if (counts & VK_SAMPLE_COUNT_64_BIT) { return VK_SAMPLE_COUNT_64_BIT; } + if (counts & VK_SAMPLE_COUNT_32_BIT) { return VK_SAMPLE_COUNT_32_BIT; } + if (counts & VK_SAMPLE_COUNT_16_BIT) { return VK_SAMPLE_COUNT_16_BIT; } + if (counts & VK_SAMPLE_COUNT_8_BIT) { return VK_SAMPLE_COUNT_8_BIT; } + if (counts & VK_SAMPLE_COUNT_4_BIT) { return VK_SAMPLE_COUNT_4_BIT; } + if (counts & VK_SAMPLE_COUNT_2_BIT) { return VK_SAMPLE_COUNT_2_BIT; } + return VK_SAMPLE_COUNT_1_BIT; } };