Fix 2 issues #162,#163 in pipeline.timestamp tests.
authorRocky Shi <ninshi01@rockyshi-pc.shanghai.arm.com>
Tue, 12 Jan 2016 02:51:50 +0000 (10:51 +0800)
committerRocky Shi <ninshi01@rockyshi-pc.shanghai.arm.com>
Tue, 12 Jan 2016 02:51:50 +0000 (10:51 +0800)
for #162, set aspect flag when clearing images.
for #163, add optimal tiling feature check when creating images.

external/vulkancts/modules/vulkan/pipeline/vktPipelineTimestampTests.cpp

index d2474d5f063478b5bc5e8d09d175efb20a1649f8..974c7a227ad28a5440488cf8838c2fcc9b2c5928 100644 (file)
@@ -905,17 +905,31 @@ Move<VkBuffer> TimestampTestInstance::createBufferAndBindMemory(VkDeviceSize siz
 }
 
 Move<VkImage> TimestampTestInstance::createImage2DAndBindMemory(VkFormat                          format,
-                                                                                                                                 deInt32                           width,
-                                                                                                                                 deInt32                           height,
-                                                                                                                                 VkBufferUsageFlags                usage,
-                                                                                                                                 VkSampleCountFlagBits             sampleCount,
-                                                                                                                                 de::details::MovePtr<Allocation>* pAlloc)
+                                                                                                                               deInt32                           width,
+                                                                                                                               deInt32                           height,
+                                                                                                                               VkImageUsageFlags                 usage,
+                                                                                                                               VkSampleCountFlagBits             sampleCount,
+                                                                                                                               de::details::MovePtr<Allocation>* pAlloc)
 {
        const DeviceInterface&      vk                  = m_context.getDeviceInterface();
        const VkDevice              vkDevice            = m_context.getDevice();
        const deUint32              queueFamilyIndex    = m_context.getUniversalQueueFamilyIndex();
        SimpleAllocator             memAlloc            (vk, vkDevice, getPhysicalDeviceMemoryProperties(m_context.getInstanceInterface(), m_context.getPhysicalDevice()));
 
+       // Optimal tiling feature check
+       VkFormatProperties          formatProperty;
+       m_context.getInstanceInterface().getPhysicalDeviceFormatProperties(m_context.getPhysicalDevice(), format, &formatProperty);
+       if((usage & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) && !(formatProperty.optimalTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT))
+       {
+               // Remove color attachment usage if the optimal tiling feature does not support it
+               usage &= ~VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
+       }
+       if((usage & VK_IMAGE_USAGE_STORAGE_BIT) && !(formatProperty.optimalTilingFeatures & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT))
+       {
+               // Remove storage usage if the optimal tiling feature does not support it
+               usage &= ~VK_IMAGE_USAGE_STORAGE_BIT;
+       }
+       
        const VkImageCreateInfo colorImageParams =
        {
                VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,                                        // VkStructureType      sType;
@@ -1853,7 +1867,7 @@ TransferTestInstance::TransferTestInstance(Context&              context,
        : TimestampTestInstance(context, stages, inRenderPass)
        , m_method(method)
        , m_bufSize(256u)
-       , m_imageFormat(VK_FORMAT_R32G32B32A32_SFLOAT)
+       , m_imageFormat(VK_FORMAT_R8G8B8A8_UNORM)
        , m_imageWidth(4u)
        , m_imageHeight(4u)
        , m_imageSize(256u)
@@ -1876,19 +1890,19 @@ TransferTestInstance::TransferTestInstance(Context&              context,
 
        // Create src/dst/depth image
        m_srcImage   = createImage2DAndBindMemory(m_imageFormat, m_imageWidth, m_imageHeight,
-                                                                                         VK_IMAGE_USAGE_STORAGE_BIT | VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
+                                                                                         VK_IMAGE_USAGE_TRANSFER_SRC_BIT,
                                                                                          VK_SAMPLE_COUNT_1_BIT,
                                                                                          &dummyAlloc);
        m_dstImage   = createImage2DAndBindMemory(m_imageFormat, m_imageWidth, m_imageHeight,
-                                                                                         VK_IMAGE_USAGE_STORAGE_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT,
+                                                                                         VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT,
                                                                                          VK_SAMPLE_COUNT_1_BIT,
                                                                                          &dummyAlloc);
        m_depthImage = createImage2DAndBindMemory(VK_FORMAT_D16_UNORM, m_imageWidth, m_imageHeight,
-                                                                                         VK_IMAGE_USAGE_STORAGE_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT,
+                                                                                         VK_IMAGE_USAGE_TRANSFER_DST_BIT,
                                                                                          VK_SAMPLE_COUNT_1_BIT,
                                                                                          &dummyAlloc);
        m_msImage    = createImage2DAndBindMemory(m_imageFormat, m_imageWidth, m_imageHeight,
-                                                                                         VK_IMAGE_USAGE_STORAGE_BIT | VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
+                                                                                         VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT,
                                                                                          VK_SAMPLE_COUNT_4_BIT,
                                                                                          &dummyAlloc);
 }
@@ -1927,13 +1941,13 @@ void TransferTestInstance::configCommandBuffer(void)
        {
                {0.0f, 0.0f, 0.0f, 0.0f}
        };
-       const struct VkImageSubresourceRange subRange =
+       struct VkImageSubresourceRange subRange =
        {
-               0u,                  // VkImageAspectFlags  aspectMask;
-               0u,                  // deUint32            baseMipLevel;
-               1u,                  // deUint32            mipLevels;
-               0u,                  // deUint32            baseArrayLayer;
-               1u,                  // deUint32            arraySize;
+               VK_IMAGE_ASPECT_COLOR_BIT,     // VkImageAspectFlags  aspectMask;
+               0u,                            // deUint32            baseMipLevel;
+               1u,                            // deUint32            mipLevels;
+               0u,                            // deUint32            baseArrayLayer;
+               1u,                            // deUint32            arraySize;
        };
 
        vk.cmdClearColorImage(*m_cmdBuffer, *m_srcImage, VK_IMAGE_LAYOUT_GENERAL, &srcClearValue, 1u, &subRange);
@@ -2034,6 +2048,7 @@ void TransferTestInstance::configCommandBuffer(void)
                                        1.0f,                                   // float       depth;
                                        0u,                                     // deUint32    stencil;
                                };
+                               subRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT;
                                vk.cmdClearDepthStencilImage(*m_cmdBuffer, *m_depthImage, VK_IMAGE_LAYOUT_GENERAL, &clearDSValue, 1u, &subRange);
                                break;
                        }