Fix validation errors in ycbcr.query.* tests
authorIlkka Saarelainen <ilkka.saarelainen@siru.fi>
Wed, 6 Mar 2019 12:43:05 +0000 (14:43 +0200)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Fri, 22 Mar 2019 12:54:54 +0000 (08:54 -0400)
Query tests were using test images in VK_IMAGE_LAYOUT_UNDEFINED
layout but the command buffer expects them to be in
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL layout.

This CL transitions the test images to the correct layout.

Affects:

dEQP-VK.ycbcr.query.*

Components: Vulkan

VK-GL-CTS issue: 1563

Change-Id: I4b17078d0f06db59206cb46f377b61beaa252c60

external/vulkancts/modules/vulkan/ycbcr/vktYCbCrImageQueryTests.cpp

index e0dc48d..6f40e61 100644 (file)
@@ -2,7 +2,7 @@
  * Vulkan Conformance Tests
  * ------------------------
  *
- * Copyright (c) 2017 Google Inc.
+ * Copyright (c) 2019 Google Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -35,6 +35,8 @@
 #include "vkQueryUtil.hpp"
 #include "vkMemUtil.hpp"
 #include "vkImageUtil.hpp"
+#include "vkCmdUtil.hpp"
+#include "vkBarrierUtil.hpp"
 
 #include "tcuTestLog.hpp"
 #include "tcuVectorUtil.hpp"
@@ -201,7 +203,8 @@ Move<VkImageView> createImageView (const DeviceInterface&   vkd,
 class TestImage
 {
 public:
-                                                               TestImage               (const DeviceInterface&         vkd,
+                                                               TestImage               (const Context&                         context,
+                                                                                                const DeviceInterface&         vkd,
                                                                                                 VkDevice                                       device,
                                                                                                 Allocator&                                     allocator,
                                                                                                 VkFormat                                       format,
@@ -219,7 +222,8 @@ private:
        const Unique<VkImageView>       m_imageView;
 };
 
-TestImage::TestImage (const DeviceInterface&   vkd,
+TestImage::TestImage (const Context&                   context,
+                                         const DeviceInterface&        vkd,
                                          VkDevice                                      device,
                                          Allocator&                            allocator,
                                          VkFormat                                      format,
@@ -231,6 +235,28 @@ TestImage::TestImage (const DeviceInterface&       vkd,
        , m_allocations (allocateAndBindImageMemory(vkd, device, allocator, *m_image, format, createFlags))
        , m_imageView   (createImageView(vkd, device, *m_image, format, conversion))
 {
+       // Transition image layout
+       {
+               Move<VkCommandPool>             cmdPool;
+               Move<VkCommandBuffer>   cmdBuffer;
+               const VkQueue                   queue                           = context.getUniversalQueue();
+               const deUint32                  queueFamilyIndex        = context.getUniversalQueueFamilyIndex();
+
+               cmdPool         = createCommandPool(vkd, device, VK_COMMAND_POOL_CREATE_TRANSIENT_BIT, queueFamilyIndex);
+               cmdBuffer       = allocateCommandBuffer(vkd, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY);
+
+               beginCommandBuffer(vkd, *cmdBuffer);
+
+               VkImageSubresourceRange subresourceRange = { VK_IMAGE_ASPECT_COLOR_BIT, 0u, 1u, 0u, 1u };
+               const VkImageMemoryBarrier imageBarrier = makeImageMemoryBarrier(0u, VK_ACCESS_TRANSFER_WRITE_BIT, VK_IMAGE_LAYOUT_UNDEFINED,
+                               VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, *m_image, subresourceRange);
+
+               vkd.cmdPipelineBarrier(*cmdBuffer, VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0u,
+                       0u, DE_NULL, 0u, DE_NULL, 1u, &imageBarrier);
+
+               endCommandBuffer(vkd, *cmdBuffer);
+               submitCommandsAndWait(vkd, device, queue, *cmdBuffer);
+       }
 }
 
 typedef de::SharedPtr<TestImage> TestImageSp;
@@ -415,10 +441,10 @@ tcu::TestStatus testImageQuery (Context& context, TestParameters params)
                testImages.resize(testSizes.size());
 
                for (size_t ndx = 0; ndx < testSizes.size(); ++ndx)
-                       testImages[ndx] = TestImageSp(new TestImage(vkd, device, context.getDefaultAllocator(), params.format, testSizes[ndx], params.flags, *conversion));
+                       testImages[ndx] = TestImageSp(new TestImage(context, vkd, device, context.getDefaultAllocator(), params.format, testSizes[ndx], params.flags, *conversion));
        }
        else
-               testImages.push_back(TestImageSp(new TestImage(vkd, device, context.getDefaultAllocator(), params.format, UVec2(16, 18), params.flags, *conversion)));
+               testImages.push_back(TestImageSp(new TestImage(context, vkd, device, context.getDefaultAllocator(), params.format, UVec2(16, 18), params.flags, *conversion)));
 
        {
                UniquePtr<ShaderExecutor>       executor        (createExecutor(context, params.shaderType, getShaderSpec(params), *descLayout));
@@ -569,7 +595,7 @@ tcu::TestStatus testImageQueryLod (Context& context, TestParameters params)
                testImages.resize(testSizes.size());
 
                for (size_t ndx = 0; ndx < testSizes.size(); ++ndx)
-                       testImages[ndx] = TestImageSp(new TestImage(vkd, device, context.getDefaultAllocator(), params.format, testSizes[ndx], params.flags, *conversion));
+                       testImages[ndx] = TestImageSp(new TestImage(context, vkd, device, context.getDefaultAllocator(), params.format, testSizes[ndx], params.flags, *conversion));
        }
 
        {