@@ -150,6 +150,8 @@ class HelloTriangleApplication {
150150 VkSurfaceKHR surface;
151151
152152 VkPhysicalDevice physicalDevice = VK_NULL_HANDLE;
153+ VkPhysicalDeviceProperties physicalDeviceProperties;
154+ VkSampleCountFlagBits msaaSamples = VK_SAMPLE_COUNT_1_BIT;
153155 VkDevice device;
154156
155157 VkQueue graphicsQueue;
@@ -406,6 +408,8 @@ class HelloTriangleApplication {
406408 for (const auto & device : devices) {
407409 if (isDeviceSuitable (device)) {
408410 physicalDevice = device;
411+ vkGetPhysicalDeviceProperties (physicalDevice, &physicalDeviceProperties);
412+ msaaSamples = getMaxUsableSampleCount ();
409413 break ;
410414 }
411415 }
@@ -922,6 +926,17 @@ class HelloTriangleApplication {
922926 endSingleTimeCommands (commandBuffer);
923927 }
924928
929+ VkSampleCountFlagBits getMaxUsableSampleCount () {
930+ VkSampleCountFlags counts = std::min (physicalDeviceProperties.limits .framebufferColorSampleCounts , physicalDeviceProperties.limits .framebufferDepthSampleCounts );
931+ if (counts & VK_SAMPLE_COUNT_64_BIT) { return VK_SAMPLE_COUNT_64_BIT; }
932+ if (counts & VK_SAMPLE_COUNT_32_BIT) { return VK_SAMPLE_COUNT_32_BIT; }
933+ if (counts & VK_SAMPLE_COUNT_16_BIT) { return VK_SAMPLE_COUNT_16_BIT; }
934+ if (counts & VK_SAMPLE_COUNT_8_BIT) { return VK_SAMPLE_COUNT_8_BIT; }
935+ if (counts & VK_SAMPLE_COUNT_4_BIT) { return VK_SAMPLE_COUNT_4_BIT; }
936+ if (counts & VK_SAMPLE_COUNT_2_BIT) { return VK_SAMPLE_COUNT_2_BIT; }
937+ return VK_SAMPLE_COUNT_1_BIT;
938+ }
939+
925940 void createTextureImageView () {
926941 textureImageView = createImageView (textureImage, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_ASPECT_COLOR_BIT, mipLevels);
927942 }
0 commit comments