anv/formats: Advertise multisample formats
authorChad Versace <chad.versace@intel.com>
Sat, 23 Jan 2016 01:47:59 +0000 (17:47 -0800)
committerChad Versace <chad.versace@intel.com>
Sat, 23 Jan 2016 01:50:15 +0000 (17:50 -0800)
Teach vkGetPhysicalDeviceImageFormatProperties() to advertise
multisampled formats.

src/vulkan/anv_formats.c

index d480ee7..8d634ca 100644 (file)
@@ -429,6 +429,7 @@ VkResult anv_GetPhysicalDeviceImageFormatProperties(
    VkExtent3D maxExtent;
    uint32_t maxMipLevels;
    uint32_t maxArraySize;
+   VkSampleCountFlags sampleCounts = VK_SAMPLE_COUNT_1_BIT;
 
    anv_physical_device_get_format_properties(physical_device, format,
                                              &format_props);
@@ -453,6 +454,7 @@ VkResult anv_GetPhysicalDeviceImageFormatProperties(
       maxExtent.depth = 1;
       maxMipLevels = 15; /* log2(maxWidth) + 1 */
       maxArraySize = 2048;
+      sampleCounts = VK_SAMPLE_COUNT_1_BIT;
       break;
    case VK_IMAGE_TYPE_2D:
       /* FINISHME: Does this really differ for cube maps? The documentation
@@ -473,6 +475,15 @@ VkResult anv_GetPhysicalDeviceImageFormatProperties(
       break;
    }
 
+   if (tiling == VK_IMAGE_TILING_OPTIMAL &&
+       type == VK_IMAGE_TYPE_2D &&
+       (format_feature_flags & (VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT |
+                                VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT)) &&
+       !(flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) &&
+       !(usage & VK_IMAGE_USAGE_STORAGE_BIT)) {
+      sampleCounts = isl_device_get_sample_counts(&physical_device->isl_dev);
+   }
+
    if (usage & VK_IMAGE_USAGE_TRANSFER_SRC_BIT) {
       /* Meta implements transfers by sampling from the source image. */
       if (!(format_feature_flags & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT)) {
@@ -529,9 +540,7 @@ VkResult anv_GetPhysicalDeviceImageFormatProperties(
       .maxExtent = maxExtent,
       .maxMipLevels = maxMipLevels,
       .maxArrayLayers = maxArraySize,
-
-      /* FINISHME: Support multisampling */
-      .sampleCounts = VK_SAMPLE_COUNT_1_BIT,
+      .sampleCounts = sampleCounts,
 
       /* FINISHME: Accurately calculate
        * VkImageFormatProperties::maxResourceSize.