Cherry-pick image_format_properties changes from upstream am: 43227ff1db am: 2ede225b...
authorPyry Haulos <phaulos@google.com>
Wed, 12 Oct 2016 17:46:17 +0000 (17:46 +0000)
committerandroid-build-merger <android-build-merger@google.com>
Wed, 12 Oct 2016 17:46:17 +0000 (17:46 +0000)
am: e14b1813e4

Change-Id: I732640c334d399d0a6b02dfb63761fb76d98e9b9

external/vulkancts/modules/vulkan/api/vktApiFeatureInfo.cpp

index 65c077d..4863d05 100644 (file)
@@ -1657,6 +1657,22 @@ VkImageUsageFlags getValidImageUsageFlags (VkFormat, VkFormatFeatureFlags suppor
 
 bool isValidImageUsageFlagCombination (VkImageUsageFlags usage)
 {
+       if ((usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)
+       {
+               const VkImageUsageFlags         allowedFlags    = VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT
+                                                                                                       | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
+                                                                                                       | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT
+                                                                                                       | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT;
+
+               // Only *_ATTACHMENT_BIT flags can be combined with TRANSIENT_ATTACHMENT_BIT
+               if ((usage & ~allowedFlags) != 0)
+                       return false;
+
+               // TRANSIENT_ATTACHMENT_BIT is not valid without COLOR_ or DEPTH_STENCIL_ATTACHMENT_BIT
+               if ((usage & (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT|VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT)) == 0)
+                       return false;
+       }
+
        return usage != 0;
 }
 
@@ -1727,26 +1743,55 @@ VkSampleCountFlags getRequiredOptimalTilingSampleCounts (const VkPhysicalDeviceL
 {
        if (!isCompressedFormat(format))
        {
-               const tcu::TextureFormat                tcuFormat       = mapVkFormat(format);
+               const tcu::TextureFormat                tcuFormat               = mapVkFormat(format);
+               const bool                                              hasDepthComp    = (tcuFormat.order == tcu::TextureFormat::D || tcuFormat.order == tcu::TextureFormat::DS);
+               const bool                                              hasStencilComp  = (tcuFormat.order == tcu::TextureFormat::S || tcuFormat.order == tcu::TextureFormat::DS);
+               const bool                                              isColorFormat   = !hasDepthComp && !hasStencilComp;
+               VkSampleCountFlags                              sampleCounts    = ~(VkSampleCountFlags)0;
 
-               if (usageFlags & VK_IMAGE_USAGE_STORAGE_BIT)
-                       return deviceLimits.storageImageSampleCounts;
-               else if (tcuFormat.order == tcu::TextureFormat::D)
-                       return deviceLimits.sampledImageDepthSampleCounts;
-               else if (tcuFormat.order == tcu::TextureFormat::S)
-                       return deviceLimits.sampledImageStencilSampleCounts;
-               else if (tcuFormat.order == tcu::TextureFormat::DS)
-                       return deviceLimits.sampledImageDepthSampleCounts & deviceLimits.sampledImageStencilSampleCounts;
-               else
+               DE_ASSERT((hasDepthComp || hasStencilComp) != isColorFormat);
+
+               if ((usageFlags & VK_IMAGE_USAGE_STORAGE_BIT) != 0)
+                       sampleCounts &= deviceLimits.storageImageSampleCounts;
+
+               if ((usageFlags & VK_IMAGE_USAGE_SAMPLED_BIT) != 0)
                {
-                       const tcu::TextureChannelClass  chnClass        = tcu::getTextureChannelClass(tcuFormat.type);
+                       if (hasDepthComp)
+                               sampleCounts &= deviceLimits.sampledImageDepthSampleCounts;
 
-                       if (chnClass == tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER ||
-                               chnClass == tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER)
-                               return deviceLimits.sampledImageIntegerSampleCounts;
-                       else
-                               return deviceLimits.sampledImageColorSampleCounts;
+                       if (hasStencilComp)
+                               sampleCounts &= deviceLimits.sampledImageStencilSampleCounts;
+
+                       if (isColorFormat)
+                       {
+                               const tcu::TextureChannelClass  chnClass        = tcu::getTextureChannelClass(tcuFormat.type);
+
+                               if (chnClass == tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER ||
+                                       chnClass == tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER)
+                                       sampleCounts &= deviceLimits.sampledImageIntegerSampleCounts;
+                               else
+                                       sampleCounts &= deviceLimits.sampledImageColorSampleCounts;
+                       }
                }
+
+               if ((usageFlags & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) != 0)
+                       sampleCounts &= deviceLimits.framebufferColorSampleCounts;
+
+               if ((usageFlags & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)
+               {
+                       if (hasDepthComp)
+                               sampleCounts &= deviceLimits.framebufferDepthSampleCounts;
+
+                       if (hasStencilComp)
+                               sampleCounts &= deviceLimits.framebufferStencilSampleCounts;
+               }
+
+               // If there is no usage flag set that would have corresponding device limit,
+               // only VK_SAMPLE_COUNT_1_BIT is required.
+               if (sampleCounts == ~(VkSampleCountFlags)0)
+                       sampleCounts &= VK_SAMPLE_COUNT_1_BIT;
+
+               return sampleCounts;
        }
        else
                return VK_SAMPLE_COUNT_1_BIT;