* 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.
#include "vkQueryUtil.hpp"
#include "vkMemUtil.hpp"
#include "vkImageUtil.hpp"
+#include "vkCmdUtil.hpp"
+#include "vkBarrierUtil.hpp"
#include "tcuTestLog.hpp"
#include "tcuVectorUtil.hpp"
class TestImage
{
public:
- TestImage (const DeviceInterface& vkd,
+ TestImage (const Context& context,
+ const DeviceInterface& vkd,
VkDevice device,
Allocator& allocator,
VkFormat format,
const Unique<VkImageView> m_imageView;
};
-TestImage::TestImage (const DeviceInterface& vkd,
+TestImage::TestImage (const Context& context,
+ const DeviceInterface& vkd,
VkDevice device,
Allocator& allocator,
VkFormat format,
, 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;
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));
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));
}
{