Add tests for drawcall parameters
authorscygan <slawomir.cygan@intel.com>
Thu, 10 Dec 2015 15:19:53 +0000 (16:19 +0100)
committerscygan <slawomir.cygan@intel.com>
Thu, 10 Dec 2015 15:19:53 +0000 (16:19 +0100)
22 files changed:
external/vulkancts/data/draw/VertexFetch.frag [new file with mode: 0644]
external/vulkancts/data/draw/VertexFetch.vert [new file with mode: 0644]
external/vulkancts/data/draw/VertexFetchWithInstance.vert [new file with mode: 0644]
external/vulkancts/modules/vulkan/CMakeLists.txt
external/vulkancts/modules/vulkan/draw/CMakeLists.txt [new file with mode: 0644]
external/vulkancts/modules/vulkan/draw/vktDrawBaseClass.cpp [new file with mode: 0644]
external/vulkancts/modules/vulkan/draw/vktDrawBaseClass.hpp [new file with mode: 0644]
external/vulkancts/modules/vulkan/draw/vktDrawBufferObjectUtil.cpp [new file with mode: 0644]
external/vulkancts/modules/vulkan/draw/vktDrawBufferObjectUtil.hpp [new file with mode: 0644]
external/vulkancts/modules/vulkan/draw/vktDrawCreateInfoUtil.cpp [new file with mode: 0644]
external/vulkancts/modules/vulkan/draw/vktDrawCreateInfoUtil.hpp [new file with mode: 0644]
external/vulkancts/modules/vulkan/draw/vktDrawImageObjectUtil.cpp [new file with mode: 0644]
external/vulkancts/modules/vulkan/draw/vktDrawImageObjectUtil.hpp [new file with mode: 0644]
external/vulkancts/modules/vulkan/draw/vktDrawIndexedTest.cpp [new file with mode: 0644]
external/vulkancts/modules/vulkan/draw/vktDrawIndexedTest.hpp [new file with mode: 0644]
external/vulkancts/modules/vulkan/draw/vktDrawIndirectTest.cpp [new file with mode: 0644]
external/vulkancts/modules/vulkan/draw/vktDrawIndirectTest.hpp [new file with mode: 0644]
external/vulkancts/modules/vulkan/draw/vktDrawSimpleTest.cpp [new file with mode: 0644]
external/vulkancts/modules/vulkan/draw/vktDrawSimpleTest.hpp [new file with mode: 0644]
external/vulkancts/modules/vulkan/draw/vktDrawTestCaseUtil.hpp [new file with mode: 0644]
external/vulkancts/modules/vulkan/draw/vktDrawTests.cpp [new file with mode: 0644]
external/vulkancts/modules/vulkan/draw/vktDrawTests.hpp [new file with mode: 0644]

diff --git a/external/vulkancts/data/draw/VertexFetch.frag b/external/vulkancts/data/draw/VertexFetch.frag
new file mode 100644 (file)
index 0000000..3741885
--- /dev/null
@@ -0,0 +1,7 @@
+#version 400
+in vec4 in_color;
+layout(location = 0) out vec4 out_color;
+void main()
+{
+  out_color = in_color;
+}
\ No newline at end of file
diff --git a/external/vulkancts/data/draw/VertexFetch.vert b/external/vulkancts/data/draw/VertexFetch.vert
new file mode 100644 (file)
index 0000000..30439aa
--- /dev/null
@@ -0,0 +1,11 @@
+#version 430
+       
+layout(location = 0) in vec4 in_position;
+layout(location = 1) in vec4 in_color;
+
+layout(location = 0) out vec4 out_color;
+
+void main() {
+       gl_Position = in_position;
+       out_color = in_color;
+}
\ No newline at end of file
diff --git a/external/vulkancts/data/draw/VertexFetchWithInstance.vert b/external/vulkancts/data/draw/VertexFetchWithInstance.vert
new file mode 100644 (file)
index 0000000..d4cac1d
--- /dev/null
@@ -0,0 +1,14 @@
+#version 430
+       
+layout(location = 0) in vec4 in_position;
+layout(location = 1) in vec4 in_color;
+
+layout(location = 0) out vec4 out_color;
+
+void main() {
+       vec2 perVertex = vec2(in_position.x, in_position.y);
+       vec2 perInstance[6]     = vec2[6](vec2(0.7, -0.7), vec2(-0.75, 0.8), vec2(0.0, 0.0), vec2(0.3, 0.0), vec2(0.0, -0.3),vec2(0.3, -0.3) );
+    
+       gl_Position = vec4(perVertex + perInstance[gl_InstanceID], 0.0, 1.0);
+       out_color = in_color;
+}
\ No newline at end of file
index 7140bbc..f3f1581 100644 (file)
@@ -6,6 +6,7 @@ add_subdirectory(binding_model)
 add_subdirectory(spirv_assembly)
 add_subdirectory(shaderrender)
 add_subdirectory(memory)
+add_subdirectory(draw)
 
 include_directories(
        api
@@ -14,6 +15,7 @@ include_directories(
        spirv_assembly
        shaderrender
        memory
+       draw
        )
 
 set(DEQP_VK_COMMON_SRCS
@@ -41,6 +43,7 @@ set(DEQP_VK_COMMON_LIBS
        deqp-vk-spirv-assembly
        deqp-vk-shaderrender
        deqp-vk-memory
+       deqp-vk-draw
        )
 
 if (DE_OS_IS_WIN32 OR DE_OS_IS_UNIX OR DE_OS_IS_OSX)
diff --git a/external/vulkancts/modules/vulkan/draw/CMakeLists.txt b/external/vulkancts/modules/vulkan/draw/CMakeLists.txt
new file mode 100644 (file)
index 0000000..c1f89bf
--- /dev/null
@@ -0,0 +1,30 @@
+include_directories(..)
+
+set(DEQP_VK_DRAW_SRCS
+       vktDrawTests.hpp
+       vktDrawTests.cpp
+       vktDrawIndexedTest.hpp
+       vktDrawIndexedTest.cpp
+       vktDrawIndirectTest.hpp
+       vktDrawIndirectTest.cpp
+       vktDrawSimpleTest.hpp
+       vktDrawSimpleTest.cpp
+       vktDrawBaseClass.hpp
+       vktDrawBaseClass.cpp    
+       vktDrawCreateInfoUtil.hpp
+       vktDrawCreateInfoUtil.cpp
+       vktDrawImageObjectUtil.hpp
+       vktDrawImageObjectUtil.cpp
+       vktDrawBufferObjectUtil.hpp
+       vktDrawBufferObjectUtil.cpp
+       vktDrawTestCaseUtil.hpp
+
+)
+
+set(DEQP_VK_DRAW_LIBS
+       tcutil
+       vkutil
+)
+
+add_library(deqp-vk-draw STATIC ${DEQP_VK_DRAW_SRCS})
+target_link_libraries(deqp-vk-draw ${DEQP_VK_DRAW_LIBS})
diff --git a/external/vulkancts/modules/vulkan/draw/vktDrawBaseClass.cpp b/external/vulkancts/modules/vulkan/draw/vktDrawBaseClass.cpp
new file mode 100644 (file)
index 0000000..be14a06
--- /dev/null
@@ -0,0 +1,224 @@
+/*------------------------------------------------------------------------
+* Vulkan Conformance Tests
+* ------------------------
+*
+* Copyright (c) 2015 The Khronos Group Inc.
+* Copyright (c) 2015 Intel Corporation
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
+* copy of this software and/or associated documentation files (the
+* "Materials"), to deal in the Materials without restriction, including
+* without limitation the rights to use, copy, modify, merge, publish,
+* distribute, sublicense, and/or sell copies of the Materials, and to
+* permit persons to whom the Materials are furnished to do so, subject to
+* the following conditions:
+*
+* The above copyright notice(s) and this permission notice shall be included
+* in all copies or substantial portions of the Materials.
+*
+* The Materials are Confidential Information as defined by the
+* Khronos Membership Agreement until designated non-confidential by Khronos,
+* at which point this condition clause shall be removed.
+*
+* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+* MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*
+*//*!
+* \file
+* \brief Command draw Tests - Base Class
+*//*--------------------------------------------------------------------*/
+
+
+#include "vktDrawBaseClass.hpp"
+
+namespace vkt
+{
+namespace Draw
+{
+
+DrawTestsBaseClass::DrawTestsBaseClass (Context &context, const char* vertexShaderName, const char* fragmentShaderName)
+       : TestInstance                          (context)
+       , m_colorAttachmentFormat       (vk::VK_FORMAT_R8G8B8A8_UNORM)
+       , m_topology                            (vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP)
+       , m_vertexShaderName            (vertexShaderName)
+       , m_fragmentShaderName          (fragmentShaderName)
+       , m_vk                                          (context.getDeviceInterface())
+{
+}
+
+
+
+void DrawTestsBaseClass::initialize (void)
+{
+       tcu::TestLog &log                                               = m_context.getTestContext().getLog();
+       const vk::VkDevice device                               = m_context.getDevice();
+       const deUint32 queueFamilyIndex                 = m_context.getUniversalQueueFamilyIndex();
+
+       const PipelineLayoutCreateInfo pipelineLayoutCreateInfo;
+       m_pipelineLayout                                                = vk::createPipelineLayout(m_vk, device, &pipelineLayoutCreateInfo);
+
+       const vk::VkExtent3D targetImageExtent  = { WIDTH, HEIGHT, 1 };
+       const ImageCreateInfo targetImageCreateInfo(vk::VK_IMAGE_TYPE_2D, m_colorAttachmentFormat, targetImageExtent, 1, 1, vk::VK_SAMPLE_COUNT_1_BIT,
+                                                                                               vk::VK_IMAGE_TILING_OPTIMAL, vk::VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | vk::VK_IMAGE_USAGE_TRANSFER_SRC_BIT);
+
+       m_colorTargetImage                                              = Image::createAndAlloc(m_vk, device, targetImageCreateInfo, m_context.getDefaultAllocator());
+
+       const ImageViewCreateInfo colorTargetViewInfo(m_colorTargetImage->object(), vk::VK_IMAGE_VIEW_TYPE_2D, m_colorAttachmentFormat);
+       m_colorTargetView                                               = vk::createImageView(m_vk, device, &colorTargetViewInfo);
+
+       RenderPassCreateInfo renderPassCreateInfo;
+       renderPassCreateInfo.addAttachment(AttachmentDescription(m_colorAttachmentFormat,
+                                                                                                                        vk::VK_SAMPLE_COUNT_1_BIT,
+                                                                                                                        vk::VK_ATTACHMENT_LOAD_OP_LOAD,
+                                                                                                                        vk::VK_ATTACHMENT_STORE_OP_STORE,
+                                                                                                                        vk::VK_ATTACHMENT_LOAD_OP_DONT_CARE,
+                                                                                                                        vk::VK_ATTACHMENT_STORE_OP_STORE,
+                                                                                                                        vk::VK_IMAGE_LAYOUT_GENERAL,
+                                                                                                                        vk::VK_IMAGE_LAYOUT_GENERAL));
+               
+
+       const vk::VkAttachmentReference colorAttachmentReference =
+       {
+               0,
+               vk::VK_IMAGE_LAYOUT_GENERAL
+       };
+
+       renderPassCreateInfo.addSubpass(SubpassDescription(vk::VK_PIPELINE_BIND_POINT_GRAPHICS,
+                                                                                                          0,
+                                                                                                          0,
+                                                                                                          DE_NULL,
+                                                                                                          1,
+                                                                                                          &colorAttachmentReference,
+                                                                                                          DE_NULL,
+                                                                                                          AttachmentReference(),
+                                                                                                          0,
+                                                                                                          DE_NULL));
+
+       m_renderPass            = vk::createRenderPass(m_vk, device, &renderPassCreateInfo);
+
+       std::vector<vk::VkImageView> colorAttachments(1);
+       colorAttachments[0] = *m_colorTargetView;
+
+       const FramebufferCreateInfo framebufferCreateInfo(*m_renderPass, colorAttachments, WIDTH, HEIGHT, 1);
+
+       m_framebuffer           = vk::createFramebuffer(m_vk, device, &framebufferCreateInfo);
+
+       const vk::VkVertexInputBindingDescription vertexInputBindingDescription =
+       {
+               0,
+               sizeof(tcu::Vec4) * 2,
+               vk::VK_VERTEX_INPUT_RATE_VERTEX,
+       };
+
+       const vk::VkVertexInputAttributeDescription vertexInputAttributeDescriptions[2] =
+       {
+               {
+                       0u,
+                       0u,
+                       vk::VK_FORMAT_R32G32B32A32_SFLOAT,
+                       0u
+               },
+               {
+                       1u,
+                       0u,
+                       vk::VK_FORMAT_R32G32B32A32_SFLOAT,
+                       (deUint32)(sizeof(float)* 4),
+               }
+       };
+
+       m_vertexInputState = PipelineCreateInfo::VertexInputState(1,
+                                                                                                                         &vertexInputBindingDescription,
+                                                                                                                         2,
+                                                                                                                         vertexInputAttributeDescriptions);
+
+       const vk::VkDeviceSize dataSize = m_data.size() * sizeof(Vec4RGBA);
+       m_vertexBuffer = Buffer::createAndAlloc(m_vk, device, BufferCreateInfo(dataSize,
+               vk::VK_BUFFER_USAGE_VERTEX_BUFFER_BIT), m_context.getDefaultAllocator(), vk::MemoryRequirement::HostVisible);
+
+       unsigned char *ptr = reinterpret_cast<unsigned char *>(m_vertexBuffer->getBoundMemory().getHostPtr());
+       deMemcpy(ptr, &m_data[0], dataSize);
+
+       vk::flushMappedMemoryRange(m_vk, 
+                                                          device,
+                                                          m_vertexBuffer->getBoundMemory().getMemory(),
+                                                          m_vertexBuffer->getBoundMemory().getOffset(),
+                                                          dataSize);
+
+       const CmdPoolCreateInfo cmdPoolCreateInfo(queueFamilyIndex);
+       m_cmdPool = vk::createCommandPool(m_vk, device, &cmdPoolCreateInfo);
+
+       const vk::VkCommandBufferAllocateInfo cmdBufferAllocateInfo =
+       {
+               vk::VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,     // VkStructureType                      sType;
+               DE_NULL,                                                                                        // const void*                          pNext;
+               *m_cmdPool,                                                                                     // VkCommandPool                        commandPool;
+               vk::VK_COMMAND_BUFFER_LEVEL_PRIMARY,                            // VkCommandBufferLevel         level;
+               1u,                                                                                                     // deUint32                                     bufferCount;
+       };
+       m_cmdBuffer = vk::allocateCommandBuffer(m_vk, device, &cmdBufferAllocateInfo);
+
+       initPipeline(device);
+}
+
+void DrawTestsBaseClass::initPipeline (const vk::VkDevice device)
+{
+       const vk::Unique<vk::VkShaderModule> vs(createShaderModule(m_vk, device, m_context.getBinaryCollection().get(m_vertexShaderName), 0));
+       const vk::Unique<vk::VkShaderModule> fs(createShaderModule(m_vk, device, m_context.getBinaryCollection().get(m_fragmentShaderName), 0));
+
+       const PipelineCreateInfo::ColorBlendState::Attachment vkCbAttachmentState;
+
+       vk::VkViewport viewport;
+       viewport.x                              = 0;
+       viewport.y                              = 0;
+       viewport.width                  = static_cast<float>(WIDTH);
+       viewport.height                 = static_cast<float>(HEIGHT);
+       viewport.minDepth               = 0.0f;
+       viewport.maxDepth               = 1.0f;
+
+       vk::VkRect2D scissor;
+       scissor.offset.x                = 0;
+       scissor.offset.y                = 0;
+       scissor.extent.width    = WIDTH;
+       scissor.extent.height   = HEIGHT;
+
+       PipelineCreateInfo pipelineCreateInfo(*m_pipelineLayout, *m_renderPass, 0, 0);
+       pipelineCreateInfo.addShader(PipelineCreateInfo::PipelineShaderStage(*vs, "main", vk::VK_SHADER_STAGE_VERTEX_BIT));
+       pipelineCreateInfo.addShader(PipelineCreateInfo::PipelineShaderStage(*fs, "main", vk::VK_SHADER_STAGE_FRAGMENT_BIT));
+       pipelineCreateInfo.addState(PipelineCreateInfo::VertexInputState(m_vertexInputState));
+       pipelineCreateInfo.addState(PipelineCreateInfo::InputAssemblerState(m_topology));
+       pipelineCreateInfo.addState(PipelineCreateInfo::ColorBlendState(1, &vkCbAttachmentState));
+       pipelineCreateInfo.addState(PipelineCreateInfo::ViewportState(1, std::vector<vk::VkViewport>(1, viewport), std::vector<vk::VkRect2D>(1, scissor)));
+       pipelineCreateInfo.addState(PipelineCreateInfo::DepthStencilState());
+       pipelineCreateInfo.addState(PipelineCreateInfo::RasterizerState());
+       pipelineCreateInfo.addState(PipelineCreateInfo::MultiSampleState());
+                       
+       m_pipeline = vk::createGraphicsPipeline(m_vk, device, DE_NULL, &pipelineCreateInfo);
+}
+
+void DrawTestsBaseClass::beginRenderPass (void)
+{
+       const vk::VkClearColorValue clearColor = { { 0.0f, 0.0f, 0.0f, 1.0f } };
+       const CmdBufferBeginInfo beginInfo;
+       
+       m_vk.beginCommandBuffer(*m_cmdBuffer, &beginInfo);
+
+       initialTransitionColor2DImage(m_vk, *m_cmdBuffer, m_colorTargetImage->object(), vk::VK_IMAGE_LAYOUT_GENERAL);
+       
+       const ImageSubresourceRange subresourceRange(vk::VK_IMAGE_ASPECT_COLOR_BIT);
+       m_vk.cmdClearColorImage(*m_cmdBuffer, m_colorTargetImage->object(),
+               vk::VK_IMAGE_LAYOUT_GENERAL, &clearColor, 1, &subresourceRange);
+
+       const vk::VkRect2D renderArea = { { 0, 0 }, { WIDTH, HEIGHT } };
+       const RenderPassBeginInfo renderPassBegin(*m_renderPass, *m_framebuffer, renderArea);
+
+       m_vk.cmdBeginRenderPass(*m_cmdBuffer, &renderPassBegin, vk::VK_SUBPASS_CONTENTS_INLINE);
+
+}
+
+}      //Draw
+}      //vkt
diff --git a/external/vulkancts/modules/vulkan/draw/vktDrawBaseClass.hpp b/external/vulkancts/modules/vulkan/draw/vktDrawBaseClass.hpp
new file mode 100644 (file)
index 0000000..2df8cd8
--- /dev/null
@@ -0,0 +1,135 @@
+#ifndef _VKTDRAWBASECLASS_HPP
+#define _VKTDRAWBASECLASS_HPP
+/*------------------------------------------------------------------------
+* Vulkan Conformance Tests
+* ------------------------
+*
+* Copyright (c) 2015 The Khronos Group Inc.
+* Copyright (c) 2015 Intel Corporation
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
+* copy of this software and/or associated documentation files (the
+* "Materials"), to deal in the Materials without restriction, including
+* without limitation the rights to use, copy, modify, merge, publish,
+* distribute, sublicense, and/or sell copies of the Materials, and to
+* permit persons to whom the Materials are furnished to do so, subject to
+* the following conditions:
+*
+* The above copyright notice(s) and this permission notice shall be included
+* in all copies or substantial portions of the Materials.
+*
+* The Materials are Confidential Information as defined by the
+* Khronos Membership Agreement until designated non-confidential by Khronos,
+* at which point this condition clause shall be removed.
+*
+* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+* MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*
+*//*!
+* \file
+* \brief Command draw Tests - Base Class
+*//*--------------------------------------------------------------------*/
+
+#include "vktTestCase.hpp"
+
+#include "tcuTestLog.hpp"
+#include "tcuResource.hpp"
+#include "tcuImageCompare.hpp"
+#include "tcuCommandLine.hpp"
+
+#include "vkRefUtil.hpp"
+#include "vkImageUtil.hpp"
+
+#include "deSharedPtr.hpp"
+
+#include "vkPrograms.hpp"
+
+#include "vktDrawCreateInfoUtil.hpp"
+#include "vktDrawImageObjectUtil.hpp"
+#include "vktDrawBufferObjectUtil.hpp"
+
+namespace vkt
+{
+namespace Draw
+{
+
+inline tcu::Vec4 vec4Red(void)
+{
+       return tcu::Vec4(1.0f, 0.0f, 0.0f, 1.0f);
+}
+
+inline tcu::Vec4 vec4Green(void)
+{
+       return tcu::Vec4(0.0f, 1.0f, 0.0f, 1.0f);
+}
+
+inline tcu::Vec4 vec4Blue(void)
+{
+       return tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f);
+}
+
+struct Vec4RGBA
+{
+       Vec4RGBA(tcu::Vec4 p, tcu::Vec4 c)
+       : position      (p)
+       , color         (c)
+       {}
+       tcu::Vec4 position;
+       tcu::Vec4 color;
+};
+
+class DrawTestsBaseClass : public TestInstance
+{
+public:
+                                                               DrawTestsBaseClass      (Context &context, const char* vertexShaderName, const char* fragmentShaderName);
+
+protected:
+       void                                            initialize                      (void);
+       virtual void                            initPipeline            (const vk::VkDevice device);
+       void                                            beginRenderPass         (void);
+       virtual tcu::TestStatus         iterate                         (void)                                          { TCU_FAIL("Implement iterate() method!");      }
+
+       enum
+       {
+               WIDTH = 128,
+               HEIGHT = 128
+       };
+
+       vk::VkFormat                                                                    m_colorAttachmentFormat;
+
+       vk::VkPrimitiveTopology                                                 m_topology;
+
+       const vk::DeviceInterface&                                              m_vk;
+
+       vk::Move<vk::VkPipeline>                                                m_pipeline;
+       vk::Move<vk::VkPipelineLayout>                                  m_pipelineLayout;
+       
+       de::SharedPtr<Image>                                                    m_colorTargetImage;
+       vk::Move<vk::VkImageView>                                               m_colorTargetView;
+
+       de::SharedPtr<Buffer>                                                   m_vertexBuffer;
+       PipelineCreateInfo::VertexInputState                    m_vertexInputState;
+
+       vk::Move<vk::VkCommandPool>                                             m_cmdPool;
+       vk::Move<vk::VkCommandBuffer>                                   m_cmdBuffer;
+
+       vk::Move<vk::VkFramebuffer>                                             m_framebuffer;
+       vk::Move<vk::VkRenderPass>                                              m_renderPass;
+
+       const std::string                                                               m_vertexShaderName;
+       const std::string                                                               m_fragmentShaderName;
+
+       std::vector<Vec4RGBA>                                                   m_data;
+       std::vector<deUint32>                                                   m_indexes;
+       de::SharedPtr<Buffer>                                                   m_indexBuffer;
+};
+
+}      //Draw
+}      //vkt
+
+#endif //_VKTDRAWBASECLASS_HPP
diff --git a/external/vulkancts/modules/vulkan/draw/vktDrawBufferObjectUtil.cpp b/external/vulkancts/modules/vulkan/draw/vktDrawBufferObjectUtil.cpp
new file mode 100644 (file)
index 0000000..659635e
--- /dev/null
@@ -0,0 +1,83 @@
+/*------------------------------------------------------------------------
+ * Vulkan Conformance Tests
+ * ------------------------
+ *
+ * Copyright (c) 2015 The Khronos Group Inc.
+ * Copyright (c) 2015 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and/or associated documentation files (the
+ * "Materials"), to deal in the Materials without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Materials, and to
+ * permit persons to whom the Materials are furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice(s) and this permission notice shall be included
+ * in all copies or substantial portions of the Materials.
+ *
+ * The Materials are Confidential Information as defined by the
+ * Khronos Membership Agreement until designated non-confidential by Khronos,
+ * at which point this condition clause shall be removed.
+ *
+ * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ *
+ *//*!
+ * \file
+ * \brief Buffer Object Util
+ *//*--------------------------------------------------------------------*/
+
+#include "vktDrawBufferObjectUtil.hpp"
+
+#include "vkQueryUtil.hpp"
+
+namespace vkt
+{
+namespace Draw
+{
+
+Buffer::Buffer (const vk::DeviceInterface &vk, vk::VkDevice device, vk::Move<vk::VkBuffer> object)
+       : m_object              (object)
+       , m_allocation  (DE_NULL)
+       , m_vk                  (vk)
+       , m_device              (device)
+{
+}
+
+void Buffer::bindMemory (de::MovePtr<vk::Allocation> allocation)
+{
+       DE_ASSERT(allocation);
+       VK_CHECK(m_vk.bindBufferMemory(m_device, *m_object, allocation->getMemory(), allocation->getOffset()));
+
+       DE_ASSERT(!m_allocation);
+       m_allocation = allocation;
+}
+
+de::SharedPtr<Buffer> Buffer::createAndAlloc (const vk::DeviceInterface &vk,
+                                                                                         vk::VkDevice device,
+                                                                                         const vk::VkBufferCreateInfo &createInfo,
+                                                                                         vk::Allocator &allocator,
+                                                                                         vk::MemoryRequirement memoryRequirement)
+{
+       de::SharedPtr<Buffer> ret = create(vk, device, createInfo);
+
+       vk::VkMemoryRequirements bufferRequirements = vk::getBufferMemoryRequirements(vk, device, ret->object());
+       ret->bindMemory(allocator.allocate(bufferRequirements, memoryRequirement));
+       return ret;
+}
+
+de::SharedPtr<Buffer> Buffer::create (const vk::DeviceInterface &vk,
+                                                                         vk::VkDevice device,
+                                                                         const vk::VkBufferCreateInfo &createInfo)
+{
+       return de::SharedPtr<Buffer>(new Buffer(vk, device, vk::createBuffer(vk, device, &createInfo)));
+}
+
+} //Draw
+} //vkt
diff --git a/external/vulkancts/modules/vulkan/draw/vktDrawBufferObjectUtil.hpp b/external/vulkancts/modules/vulkan/draw/vktDrawBufferObjectUtil.hpp
new file mode 100644 (file)
index 0000000..a3b2bfd
--- /dev/null
@@ -0,0 +1,86 @@
+#ifndef _VKTDRAWBUFFEROBJECTUTIL_HPP
+#define _VKTDRAWBUFFEROBJECTUTIL_HPP
+/*------------------------------------------------------------------------
+ * Vulkan Conformance Tests
+ * ------------------------
+ *
+ * Copyright (c) 2015 The Khronos Group Inc.
+ * Copyright (c) 2015 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and/or associated documentation files (the
+ * "Materials"), to deal in the Materials without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Materials, and to
+ * permit persons to whom the Materials are furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice(s) and this permission notice shall be included
+ * in all copies or substantial portions of the Materials.
+ *
+ * The Materials are Confidential Information as defined by the
+ * Khronos Membership Agreement until designated non-confidential by Khronos,
+ * at which point this condition clause shall be removed.
+ *
+ * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ *
+ *//*!
+ * \file
+ * \brief Buffer Object Util
+ *//*--------------------------------------------------------------------*/
+
+#include "vkDefs.hpp"
+#include "vkMemUtil.hpp"
+#include "vkRefUtil.hpp"
+
+#include "deSharedPtr.hpp"
+
+namespace vkt
+{
+namespace Draw
+{
+
+class Buffer
+{
+public:
+
+       static de::SharedPtr<Buffer> create                     (const vk::DeviceInterface& vk, vk::VkDevice device, const vk::VkBufferCreateInfo &createInfo);
+
+       static de::SharedPtr<Buffer> createAndAlloc (const vk::DeviceInterface&         vk,
+                                                                                                vk::VkDevice                                   device,
+                                                                                                const vk::VkBufferCreateInfo&  createInfo,
+                                                                                                vk::Allocator&                                 allocator,
+                                                                                                vk::MemoryRequirement                  allocationMemoryProperties = vk::MemoryRequirement::Any);
+
+                                                               Buffer                  (const vk::DeviceInterface &vk, vk::VkDevice device, vk::Move<vk::VkBuffer> object);
+
+
+       void                                            bindMemory              (de::MovePtr<vk::Allocation> allocation);
+
+
+       vk::VkBuffer                            object                  (void) const                                                            { return *m_object;             }
+       vk::Allocation                          getBoundMemory  (void) const                                                            { return *m_allocation; }
+
+private:
+
+       Buffer                                                                          (const Buffer& other);  // Not allowed!
+       Buffer                                          &operator=              (const Buffer& other);  // Not allowed!
+
+
+       de::MovePtr<vk::Allocation>             m_allocation;
+       vk::Unique<vk::VkBuffer>                m_object;
+
+       const   vk::DeviceInterface &   m_vk;
+                       vk::VkDevice                    m_device;
+};
+
+} //Draw
+} //vkt
+
+#endif // _VKT_DRAWBUFFEROBJECTUTIL_HPP
diff --git a/external/vulkancts/modules/vulkan/draw/vktDrawCreateInfoUtil.cpp b/external/vulkancts/modules/vulkan/draw/vktDrawCreateInfoUtil.cpp
new file mode 100644 (file)
index 0000000..d49c804
--- /dev/null
@@ -0,0 +1,1224 @@
+/*------------------------------------------------------------------------
+ * Vulkan Conformance Tests
+ * ------------------------
+ *
+ * Copyright (c) 2015 The Khronos Group Inc.
+ * Copyright (c) 2015 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and/or associated documentation files (the
+ * "Materials"), to deal in the Materials without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Materials, and to
+ * permit persons to whom the Materials are furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice(s) and this permission notice shall be included
+ * in all copies or substantial portions of the Materials.
+ *
+ * The Materials are Confidential Information as defined by the
+ * Khronos Membership Agreement until designated non-confidential by Khronos,
+ * at which point this condition clause shall be removed.
+ *
+ * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ *
+ *//*!
+ * \file
+ * \brief CreateInfo utilities
+ *//*--------------------------------------------------------------------*/
+
+#include "vktDrawCreateInfoUtil.hpp"
+
+#include "vkImageUtil.hpp"
+
+namespace vkt
+{
+namespace Draw
+{
+
+ImageSubresourceRange::ImageSubresourceRange (vk::VkImageAspectFlags   _aspectMask,
+                                                                                         deUint32                                      _baseMipLevel,
+                                                                                         deUint32                                      _levelCount,
+                                                                                         deUint32                                      _baseArrayLayer,
+                                                                                         deUint32                                      _layerCount)
+{
+       aspectMask              = _aspectMask;
+       baseMipLevel    = _baseMipLevel;
+       levelCount              = _levelCount;
+       baseArrayLayer  = _baseArrayLayer;
+       layerCount              = _layerCount;
+}
+
+ComponentMapping::ComponentMapping (vk::VkComponentSwizzle _r,
+                                                                   vk::VkComponentSwizzle _g,
+                                                                   vk::VkComponentSwizzle _b,
+                                                                   vk::VkComponentSwizzle _a)
+{
+       r = _r;
+       g = _g;
+       b = _b;
+       a = _a;
+}
+
+ImageViewCreateInfo::ImageViewCreateInfo (vk::VkImage                                                  _image,
+                                                                                 vk::VkImageViewType                                   _viewType,
+                                                                                 vk::VkFormat                                                  _format,
+                                                                                 const vk::VkImageSubresourceRange&    _subresourceRange,
+                                                                                 const vk::VkComponentMapping&                 _components,
+                                                                                 vk::VkImageViewCreateFlags                    _flags)
+{
+       sType = vk::VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
+       pNext = DE_NULL;
+       flags                           = 0u;
+       image                           = _image;
+       viewType                        = _viewType;
+       format                          = _format;
+       components.r            = _components.r;
+       components.g            = _components.g;
+       components.b            = _components.b;
+       components.a            = _components.a;
+       subresourceRange        = _subresourceRange;
+       flags                           = _flags;
+}
+
+ImageViewCreateInfo::ImageViewCreateInfo (vk::VkImage                                  _image,
+                                                                                 vk::VkImageViewType                   _viewType,
+                                                                                 vk::VkFormat                                  _format,
+                                                                                 const vk::VkComponentMapping& _components,
+                                                                                 vk::VkImageViewCreateFlags    _flags)
+{
+       sType = vk::VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
+       pNext = DE_NULL;
+       flags                   = 0u;
+       image                   = _image;
+       viewType                = _viewType;
+       format                  = _format;
+       components.r    = _components.r;
+       components.g    = _components.g;
+       components.b    = _components.b;
+       components.a    = _components.a;
+
+       vk::VkImageAspectFlags aspectFlags;
+       const tcu::TextureFormat tcuFormat = vk::mapVkFormat(_format);
+
+       switch (tcuFormat.order)
+       {
+               case tcu::TextureFormat::D:
+                       aspectFlags = vk::VK_IMAGE_ASPECT_DEPTH_BIT;
+                       break;
+               case tcu::TextureFormat::S:
+                       aspectFlags = vk::VK_IMAGE_ASPECT_STENCIL_BIT;
+                       break;
+               case tcu::TextureFormat::DS:
+                       aspectFlags = vk::VK_IMAGE_ASPECT_STENCIL_BIT | vk::VK_IMAGE_ASPECT_DEPTH_BIT;
+                       break;
+               default:
+                       aspectFlags = vk::VK_IMAGE_ASPECT_COLOR_BIT;
+                       break;
+       }
+
+       subresourceRange = ImageSubresourceRange(aspectFlags);;
+       flags = _flags;
+}
+
+BufferViewCreateInfo::BufferViewCreateInfo (vk::VkBuffer       _buffer,
+                                                                                       vk::VkFormat            _format,
+                                                                                       vk::VkDeviceSize _offset,
+                                                                                       vk::VkDeviceSize _range)
+{
+       sType = vk::VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO;
+       pNext = DE_NULL;
+
+       buffer  = _buffer;
+       format  = _format;
+       offset  = _offset;
+       range   = _range;
+}
+
+
+BufferCreateInfo::BufferCreateInfo (vk::VkDeviceSize           _size,
+                                                                       vk::VkBufferUsageFlags  _usage,
+                                                                       vk::VkSharingMode               _sharingMode,
+                                                                       deUint32                                _queueFamilyIndexCount,
+                                                                       const deUint32*                 _pQueueFamilyIndices,
+                                                                       vk::VkBufferCreateFlags _flags)
+{   
+       sType = vk::VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
+       pNext = DE_NULL;
+       size                                    = _size;
+       usage                                   = _usage;
+       flags                                   = _flags;
+       sharingMode                             = _sharingMode;
+       queueFamilyIndexCount   = _queueFamilyIndexCount;
+
+       if (_queueFamilyIndexCount)
+       {
+               m_queueFamilyIndices = std::vector<deUint32>(
+                       _pQueueFamilyIndices, _pQueueFamilyIndices + _queueFamilyIndexCount);
+               pQueueFamilyIndices = &m_queueFamilyIndices[0];
+       }
+       else
+       {
+               pQueueFamilyIndices = _pQueueFamilyIndices;
+       }   
+}
+
+BufferCreateInfo::BufferCreateInfo (const BufferCreateInfo &other)
+{
+       sType                                   = other.sType;
+       pNext                                   = other.pNext;
+       size                                    = other.size;
+       usage                                   = other.usage;
+       flags                                   = other.flags;
+       sharingMode                             = other.sharingMode;
+       queueFamilyIndexCount   = other.queueFamilyIndexCount;
+
+       m_queueFamilyIndices    = other.m_queueFamilyIndices;
+       DE_ASSERT(m_queueFamilyIndices.size() == queueFamilyIndexCount);
+
+       if (m_queueFamilyIndices.size())
+       {
+               pQueueFamilyIndices = &m_queueFamilyIndices[0];
+       }
+       else
+       {
+               pQueueFamilyIndices = DE_NULL;
+       }
+}
+
+BufferCreateInfo & BufferCreateInfo::operator= (const BufferCreateInfo &other)
+{
+       sType                                           = other.sType;
+       pNext                                           = other.pNext;
+       size                                            = other.size;
+       usage                                           = other.usage;
+       flags                                           = other.flags;
+       sharingMode                                     = other.sharingMode;
+       queueFamilyIndexCount           = other.queueFamilyIndexCount;
+
+       m_queueFamilyIndices            = other.m_queueFamilyIndices;
+
+       DE_ASSERT(m_queueFamilyIndices.size() == queueFamilyIndexCount);
+
+       if (m_queueFamilyIndices.size())
+       {
+               pQueueFamilyIndices = &m_queueFamilyIndices[0];
+       }
+       else
+       {
+               pQueueFamilyIndices = DE_NULL;
+       }
+
+       return *this;
+}
+
+ImageCreateInfo::ImageCreateInfo (vk::VkImageType                      _imageType,
+                                                                 vk::VkFormat                          _format,
+                                                                 vk::VkExtent3D                        _extent,
+                                                                 deUint32                                      _mipLevels,
+                                                                 deUint32                                      _arrayLayers,
+                                                                 vk::VkSampleCountFlagBits     _samples,
+                                                                 vk::VkImageTiling                     _tiling,
+                                                                 vk::VkImageUsageFlags         _usage,
+                                                                 vk::VkSharingMode                     _sharingMode,
+                                                                 deUint32                                      _queueFamilyIndexCount,
+                                                                 const deUint32*                       _pQueueFamilyIndices,
+                                                                 vk::VkImageCreateFlags        _flags,
+                                                                 vk::VkImageLayout                     _initialLayout)
+{
+       if (_queueFamilyIndexCount)
+       {
+               m_queueFamilyIndices = std::vector<deUint32>(_pQueueFamilyIndices, _pQueueFamilyIndices + _queueFamilyIndexCount);
+       }
+
+       sType = vk::VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
+       pNext = DE_NULL;
+       flags                                   = _flags;
+       imageType                               = _imageType;
+       format                                  = _format;
+       extent                                  = _extent;
+       mipLevels                               = _mipLevels;
+       arrayLayers                             = _arrayLayers;
+       samples                                 = _samples;
+       tiling                                  = _tiling;
+       usage                                   = _usage;
+       sharingMode                             = _sharingMode;
+       queueFamilyIndexCount   = _queueFamilyIndexCount;
+
+       if (m_queueFamilyIndices.size())
+       {
+               pQueueFamilyIndices = &m_queueFamilyIndices[0];
+       }
+       else
+       {
+               pQueueFamilyIndices = DE_NULL;
+       }
+       initialLayout   = _initialLayout;
+}
+
+FramebufferCreateInfo::FramebufferCreateInfo (vk::VkRenderPass                                         _renderPass,
+                                                                                         const std::vector<vk::VkImageView>&   atachments, 
+                                                                                         deUint32                                                              _width,
+                                                                                         deUint32                                                              _height,
+                                                                                         deUint32                                                              _layers)
+{
+       sType = vk::VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
+       pNext = DE_NULL;
+       flags = 0u;
+
+       renderPass              = _renderPass;
+       attachmentCount = static_cast<deUint32>(atachments.size());
+
+       if (attachmentCount)
+       {
+               pAttachments = const_cast<vk::VkImageView *>(&atachments[0]);
+       }
+
+       width   = _width;
+       height  = _height;
+       layers  = _layers;
+}
+
+RenderPassCreateInfo::RenderPassCreateInfo (const std::vector<vk::VkAttachmentDescription>&    attachments,
+                                                                                       const std::vector<vk::VkSubpassDescription>&    subpasses,
+                                                                                       const std::vector<vk::VkSubpassDependency>&             dependiences)
+
+       : m_attachments                 (attachments.begin(), attachments.end())
+       , m_subpasses                   (subpasses.begin(), subpasses.end())
+       , m_dependiences                (dependiences.begin(), dependiences.end())
+       , m_attachmentsStructs  (m_attachments.begin(), m_attachments.end())
+       , m_subpassesStructs    (m_subpasses.begin(), m_subpasses.end())
+       , m_dependiencesStructs (m_dependiences.begin(), m_dependiences.end())
+{
+       sType = vk::VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
+       pNext = DE_NULL;
+       flags = 0; 
+
+       attachmentCount = static_cast<deUint32>(m_attachments.size());
+       pAttachments    = &m_attachmentsStructs[0];
+       subpassCount    = static_cast<deUint32>(m_subpasses.size());
+       pSubpasses              = &m_subpassesStructs[0];
+       dependencyCount = static_cast<deUint32>(m_dependiences.size());
+       pDependencies   = &m_dependiencesStructs[0];
+}
+
+RenderPassCreateInfo::RenderPassCreateInfo (deUint32                                                   _attachmentCount,
+                                                                                       const vk::VkAttachmentDescription*      _pAttachments,
+                                                                                       deUint32                                                        _subpassCount,
+                                                                                       const vk::VkSubpassDescription*         _pSubpasses,
+                                                                                       deUint32                                                        _dependencyCount,
+                                                                                       const vk::VkSubpassDependency*          _pDependiences)
+{
+
+       m_attachments   = std::vector<AttachmentDescription>(_pAttachments, _pAttachments + _attachmentCount);
+       m_subpasses             = std::vector<SubpassDescription>(_pSubpasses, _pSubpasses + _subpassCount);
+       m_dependiences  = std::vector<SubpassDependency>(_pDependiences, _pDependiences + _dependencyCount);
+
+       m_attachmentsStructs    = std::vector<vk::VkAttachmentDescription>      (m_attachments.begin(),         m_attachments.end());
+       m_subpassesStructs              = std::vector<vk::VkSubpassDescription>         (m_subpasses.begin(),           m_subpasses.end());
+       m_dependiencesStructs   = std::vector<vk::VkSubpassDependency>          (m_dependiences.begin(),        m_dependiences.end());
+
+       sType = vk::VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
+       pNext = DE_NULL;
+       flags = 0;
+
+       attachmentCount = static_cast<deUint32>(m_attachments.size());
+
+       if (attachmentCount) {
+               pAttachments = &m_attachmentsStructs[0];
+       }
+       else
+       {
+               pAttachments = DE_NULL;
+       }
+
+       subpassCount = static_cast<deUint32>(m_subpasses.size());
+
+       if (subpassCount) {
+               pSubpasses = &m_subpassesStructs[0];
+       }
+       else
+       {
+               pSubpasses = DE_NULL;
+       }
+
+       dependencyCount = static_cast<deUint32>(m_dependiences.size());
+
+       if (dependencyCount) {
+               pDependencies = &m_dependiencesStructs[0];
+       }
+       else
+       {
+               pDependencies = DE_NULL;
+       }
+}
+
+void
+RenderPassCreateInfo::addAttachment (vk::VkAttachmentDescription attachment)
+{
+
+       m_attachments.push_back(attachment);
+       m_attachmentsStructs    = std::vector<vk::VkAttachmentDescription>(m_attachments.begin(), m_attachments.end());
+       attachmentCount                 = static_cast<deUint32>(m_attachments.size());
+       pAttachments                    = &m_attachmentsStructs[0];
+}
+
+void
+RenderPassCreateInfo::addSubpass (vk::VkSubpassDescription subpass)
+{
+
+       m_subpasses.push_back(subpass);
+       m_subpassesStructs      = std::vector<vk::VkSubpassDescription>(m_subpasses.begin(), m_subpasses.end());
+       subpassCount            = static_cast<deUint32>(m_subpasses.size());
+       pSubpasses                      = &m_subpassesStructs[0];
+}
+
+void
+RenderPassCreateInfo::addDependency (vk::VkSubpassDependency dependency)
+{
+
+       m_dependiences.push_back(dependency);
+       m_dependiencesStructs   = std::vector<vk::VkSubpassDependency>(m_dependiences.begin(), m_dependiences.end());
+
+       dependencyCount                 = static_cast<deUint32>(m_dependiences.size());
+       pDependencies                   = &m_dependiencesStructs[0];
+}
+
+RenderPassBeginInfo::RenderPassBeginInfo (vk::VkRenderPass                                             _renderPass,
+                                                                                 vk::VkFramebuffer                                             _framebuffer,
+                                                                                 vk::VkRect2D                                                  _renderArea,
+                                                                                 const std::vector<vk::VkClearValue>&  _clearValues)
+{
+
+       m_clearValues   = _clearValues;
+
+       sType                   = vk::VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
+       pNext                   = DE_NULL;
+       renderPass              = _renderPass;
+       framebuffer             = _framebuffer;
+       renderArea              = _renderArea;
+       clearValueCount = static_cast<deUint32>(m_clearValues.size());
+       pClearValues    = m_clearValues.size() ? &m_clearValues[0] : DE_NULL;
+}
+
+CmdPoolCreateInfo::CmdPoolCreateInfo (deUint32 _queueFamilyIndex, unsigned int _flags)
+{
+       sType = vk::VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
+       pNext = DE_NULL;
+
+       queueFamilyIndex = _queueFamilyIndex;
+       flags                           = _flags;
+}
+
+AttachmentDescription::AttachmentDescription (vk::VkFormat                             _format,
+                                                                                         vk::VkSampleCountFlagBits     _samples,
+                                                                                         vk::VkAttachmentLoadOp        _loadOp,
+                                                                                         vk::VkAttachmentStoreOp       _storeOp,
+                                                                                         vk::VkAttachmentLoadOp        _stencilLoadOp,
+                                                                                         vk::VkAttachmentStoreOp       _stencilStoreOp,
+                                                                                         vk::VkImageLayout                     _initialLayout,
+                                                                                         vk::VkImageLayout                     _finalLayout)
+{
+       flags = 0;
+       format                  = _format;
+       samples                 = _samples;
+       loadOp                  = _loadOp;
+       storeOp                 = _storeOp;
+       stencilLoadOp   = _stencilLoadOp;
+       stencilStoreOp  = _stencilStoreOp;
+       initialLayout   = _initialLayout;
+       finalLayout             = _finalLayout;
+}
+
+AttachmentDescription::AttachmentDescription (const vk::VkAttachmentDescription &rhs)
+{
+       flags                   = rhs.flags;
+       format                  = rhs.format;
+       samples                 = rhs.samples;
+       loadOp                  = rhs.loadOp;
+       storeOp                 = rhs.storeOp;
+       stencilLoadOp   = rhs.stencilLoadOp;
+       stencilStoreOp  = rhs.stencilStoreOp;
+       initialLayout   = rhs.initialLayout;
+       finalLayout             = rhs.finalLayout;
+}
+
+AttachmentReference::AttachmentReference (deUint32 _attachment, vk::VkImageLayout _layout)
+{
+       attachment      = _attachment;
+       layout          = _layout;
+}
+
+AttachmentReference::AttachmentReference (void)
+{
+       attachment = vk::VK_ATTACHMENT_UNUSED;
+       layout = vk::VK_IMAGE_LAYOUT_UNDEFINED;
+}
+
+SubpassDescription::SubpassDescription (vk::VkPipelineBindPoint                                _pipelineBindPoint,
+                                                                               vk::VkSubpassDescriptionFlags           _flags,
+                                                                               deUint32                                                        _inputAttachmentCount,
+                                                                               const vk::VkAttachmentReference*        _inputAttachments,
+                                                                               deUint32                                                        _colorAttachmentCount,
+                                                                               const vk::VkAttachmentReference*        _colorAttachments,
+                                                                               const vk::VkAttachmentReference*        _resolveAttachments,
+                                                                               vk::VkAttachmentReference                       depthStencilAttachment,
+                                                                               deUint32                                                        _preserveAttachmentCount,
+                                                                               const vk::VkAttachmentReference*        _preserveAttachments)
+{
+       m_inputAttachments = std::vector<vk::VkAttachmentReference>(_inputAttachments, _inputAttachments + _inputAttachmentCount);
+       m_colorAttachments = std::vector<vk::VkAttachmentReference>(_colorAttachments, _colorAttachments + _colorAttachmentCount);
+
+       if (_resolveAttachments)
+       {
+               m_resolveAttachments = std::vector<vk::VkAttachmentReference>(_resolveAttachments, _resolveAttachments + _colorAttachmentCount);
+       }
+
+       m_preserveAttachments = std::vector<vk::VkAttachmentReference>(_preserveAttachments, _preserveAttachments + _preserveAttachmentCount);
+
+       m_depthStencilAttachment = depthStencilAttachment;
+
+       flags = _flags;
+       pipelineBindPoint               = _pipelineBindPoint;
+       inputAttachmentCount    = _inputAttachmentCount;
+       pInputAttachments               = DE_NULL;
+       colorAttachmentCount    = _colorAttachmentCount;
+       pColorAttachments               = DE_NULL;
+       pResolveAttachments             = DE_NULL;
+       pDepthStencilAttachment = &m_depthStencilAttachment;
+       pPreserveAttachments    = DE_NULL;
+       preserveAttachmentCount = _preserveAttachmentCount;
+
+       if (m_inputAttachments.size()) {
+               pInputAttachments = &m_inputAttachments[0];
+       }
+
+       if (m_colorAttachments.size()) {
+               pColorAttachments = &m_colorAttachments[0];
+       }
+
+       if (m_resolveAttachments.size()) {
+               pResolveAttachments = &m_resolveAttachments[0];
+       }
+
+       if (m_preserveAttachments.size()) {
+               pPreserveAttachments = &m_preserveAttachments[0];
+       }
+}
+
+SubpassDescription::SubpassDescription (const vk::VkSubpassDescription& rhs)
+{
+       *static_cast<vk::VkSubpassDescription*>(this) = rhs;
+
+       m_inputAttachments = std::vector<vk::VkAttachmentReference>(
+               rhs.pInputAttachments, rhs.pInputAttachments + rhs.inputAttachmentCount);
+
+       m_colorAttachments = std::vector<vk::VkAttachmentReference>(
+               rhs.pColorAttachments, rhs.pColorAttachments + rhs.colorAttachmentCount);
+
+       if (rhs.pResolveAttachments) {
+               m_resolveAttachments = std::vector<vk::VkAttachmentReference>(
+                       rhs.pResolveAttachments, rhs.pResolveAttachments + rhs.colorAttachmentCount);
+       }
+       m_preserveAttachments = std::vector<vk::VkAttachmentReference>(
+               rhs.pPreserveAttachments, rhs.pPreserveAttachments + rhs.preserveAttachmentCount);
+
+       if (rhs.pDepthStencilAttachment)
+       {
+               m_depthStencilAttachment = *rhs.pDepthStencilAttachment;
+       }
+
+       if (m_inputAttachments.size()) {
+               pInputAttachments = &m_inputAttachments[0];
+       }
+       if (m_colorAttachments.size()) {
+               pColorAttachments = &m_colorAttachments[0];
+       }
+
+       if (m_resolveAttachments.size()) {
+               pResolveAttachments = &m_resolveAttachments[0];
+       }
+
+       pDepthStencilAttachment = &m_depthStencilAttachment;
+
+       if (m_preserveAttachments.size()) {
+               pPreserveAttachments = &m_preserveAttachments[0];
+       }
+}
+
+SubpassDescription::SubpassDescription (const SubpassDescription& rhs) {
+       *this = rhs;
+}
+
+SubpassDescription& SubpassDescription::operator= (const SubpassDescription& rhs)
+{
+       *static_cast<vk::VkSubpassDescription*>(this) = rhs;
+
+       m_inputAttachments              = rhs.m_inputAttachments;
+       m_colorAttachments              = rhs.m_colorAttachments;
+       m_resolveAttachments    = rhs.m_resolveAttachments;
+       m_preserveAttachments   = rhs.m_preserveAttachments;
+       m_depthStencilAttachment = rhs.m_depthStencilAttachment;
+
+       if (m_inputAttachments.size()) {
+               pInputAttachments = &m_inputAttachments[0];
+       }
+       if (m_colorAttachments.size()) {
+               pColorAttachments = &m_colorAttachments[0];
+       }
+
+       if (m_resolveAttachments.size()) {
+               pResolveAttachments = &m_resolveAttachments[0];
+       }
+
+       pDepthStencilAttachment = &m_depthStencilAttachment;
+
+       if (m_preserveAttachments.size()) {
+               pPreserveAttachments = &m_preserveAttachments[0];
+       }
+
+       return *this;
+}
+
+SubpassDependency::SubpassDependency (deUint32                                 _srcSubpass,
+                                                                         deUint32                                      _dstSubpass,
+                                                                         vk::VkPipelineStageFlags      _srcStageMask,
+                                                                         vk::VkPipelineStageFlags      _dstStageMask,
+                                                                         vk::VkAccessFlags                     _srcAccessMask,
+                                                                         vk::VkAccessFlags                     _dstAccessMask,
+                                                                         vk::VkDependencyFlags         _dependencyFlags)
+{
+       srcSubpass              = _srcSubpass;
+       dstSubpass              = _dstSubpass;
+       srcStageMask    = _srcStageMask;
+       dstStageMask    = _dstStageMask;
+       srcAccessMask   = _srcAccessMask;
+       dstAccessMask   = _dstAccessMask;
+       dependencyFlags = _dependencyFlags;
+}
+
+SubpassDependency::SubpassDependency (const vk::VkSubpassDependency &rhs)
+{
+       srcSubpass              = rhs.srcSubpass;
+       dstSubpass              = rhs.dstSubpass;
+       srcStageMask    = rhs.srcStageMask;
+       dstStageMask    = rhs.dstStageMask;
+       srcAccessMask   = rhs.srcAccessMask;
+       dstAccessMask   = rhs.dstAccessMask;
+       dependencyFlags = rhs.dependencyFlags;
+}
+
+CmdBufferBeginInfo::CmdBufferBeginInfo (vk::VkCommandBufferUsageFlags _flags)
+{
+       sType = vk::VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
+       pNext = DE_NULL;
+       renderPass                              = DE_NULL;
+       subpass                                 = 0;
+       framebuffer                             = DE_NULL;
+       flags                                   = _flags;
+       occlusionQueryEnable    = false;
+       queryFlags                              = 0u;
+       pipelineStatistics              = 0u;
+}
+
+CmdBufferBeginInfo::CmdBufferBeginInfo (vk::VkRenderPass                                       _renderPass,
+                                                                               deUint32                                                        _subpass,
+                                                                               vk::VkFramebuffer                                       _framebuffer,
+                                                                               vk::VkCommandBufferUsageFlags           _flags,
+                                                                               bool                                                            _occlusionQueryEnable,\r
+                                                                               vk::VkQueryControlFlags                         _queryFlags,\r
+                                                                               vk::VkQueryPipelineStatisticFlags       _pipelineStatistics)
+{
+
+       sType = vk::VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
+       pNext = DE_NULL;
+       renderPass                              = _renderPass;
+       subpass                                 = _subpass;
+       framebuffer                             = _framebuffer;
+       flags                                   = _flags;
+       occlusionQueryEnable    = _occlusionQueryEnable;
+       queryFlags                              = _queryFlags;
+       pipelineStatistics              = _pipelineStatistics;
+}
+
+DescriptorPoolCreateInfo::DescriptorPoolCreateInfo (const std::vector<vk::VkDescriptorPoolSize>&       poolSizeCounts,
+                                                                                                       vk::VkDescriptorPoolCreateFlags                                 _flags,
+                                                                                                       deUint32                                                                                _maxSets)
+       : m_poolSizeCounts(poolSizeCounts)
+{
+       sType = vk::VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
+       pNext = DE_NULL;
+       flags                   = _flags;
+       maxSets                 = _maxSets;
+       poolSizeCount   = static_cast<deUint32>(m_poolSizeCounts.size());
+       pPoolSizes              = &m_poolSizeCounts[0];
+}
+
+DescriptorPoolCreateInfo& DescriptorPoolCreateInfo::addDescriptors (vk::VkDescriptorType type, deUint32 count)
+{
+       vk::VkDescriptorPoolSize descriptorTypeCount = { type, count };
+       m_poolSizeCounts.push_back(descriptorTypeCount);
+
+       poolSizeCount   = static_cast<deUint32>(m_poolSizeCounts.size());
+       pPoolSizes              = &m_poolSizeCounts[0];
+
+       return *this;
+}
+
+DescriptorSetLayoutCreateInfo::DescriptorSetLayoutCreateInfo (deUint32 _bindingCount, const vk::VkDescriptorSetLayoutBinding* _pBindings)
+{
+       sType = vk::VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
+       pNext = DE_NULL;
+       flags = 0;
+       bindingCount = _bindingCount;
+       pBinding         = _pBindings;
+}
+
+
+PipelineLayoutCreateInfo::PipelineLayoutCreateInfo (deUint32                                                   _descriptorSetCount,
+                                                                                                       const vk::VkDescriptorSetLayout*        _pSetLayouts,
+                                                                                                       deUint32                                                        _pushConstantRangeCount,
+                                                                                                       const vk::VkPushConstantRange*          _pPushConstantRanges)
+       : m_pushConstantRanges(_pPushConstantRanges, _pPushConstantRanges + _pushConstantRangeCount)
+{
+       for (unsigned int i = 0; i < _descriptorSetCount; i++)
+       {
+               m_setLayouts.push_back(_pSetLayouts[i]);
+       }
+
+       sType = vk::VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
+       pNext = DE_NULL;
+       setLayoutCount                  = static_cast<deUint32>(m_setLayouts.size());
+       pSetLayouts                             = setLayoutCount > 0 ? &m_setLayouts[0] : DE_NULL;
+       pushConstantRangeCount  = static_cast<deUint32>(m_pushConstantRanges.size());
+
+       if (m_pushConstantRanges.size()) {
+               pPushConstantRanges = &m_pushConstantRanges[0];
+       }
+       else
+       {
+               pPushConstantRanges = DE_NULL;
+       }
+}
+
+PipelineLayoutCreateInfo::PipelineLayoutCreateInfo (const std::vector<vk::VkDescriptorSetLayout>&      setLayouts,
+                                                                                                       deUint32                                                                                _pushConstantRangeCount,
+                                                                                                       const vk::VkPushConstantRange*                                  _pPushConstantRanges)
+       : m_setLayouts                  (setLayouts)
+       , m_pushConstantRanges  (_pPushConstantRanges, _pPushConstantRanges + _pushConstantRangeCount)
+{
+       sType = vk::VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
+       pNext = DE_NULL;
+
+       setLayoutCount = static_cast<deUint32>(m_setLayouts.size());
+
+       if (setLayoutCount)
+       {
+               pSetLayouts = &m_setLayouts[0];
+       }
+       else
+       {
+               pSetLayouts = DE_NULL;
+       }
+
+       pushConstantRangeCount = static_cast<deUint32>(m_pushConstantRanges.size());
+       if (pushConstantRangeCount) {
+               pPushConstantRanges = &m_pushConstantRanges[0];
+       }
+       else
+       {
+               pPushConstantRanges = DE_NULL;
+       }
+}
+
+
+PipelineCreateInfo::PipelineShaderStage::PipelineShaderStage (vk::VkShaderModule _module, const char* _pName, vk::VkShaderStageFlagBits _stage)
+{
+       sType = vk::VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
+       pNext = DE_NULL;
+       flags = 0u;
+       stage                           = _stage;
+       module                          = _module;
+       pName                           = _pName;
+       pSpecializationInfo = DE_NULL;
+}
+
+PipelineCreateInfo::VertexInputState::VertexInputState (deUint32                                                                               _vertexBindingDescriptionCount,
+                                                                                                               const vk::VkVertexInputBindingDescription*              _pVertexBindingDescriptions,
+                                                                                                               deUint32                                                                                _vertexAttributeDescriptionCount,
+                                                                                                               const vk::VkVertexInputAttributeDescription*    _pVertexAttributeDescriptions)
+{
+       sType = vk::VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
+       pNext = DE_NULL;
+       flags                                                   = 0u;
+       vertexBindingDescriptionCount   = _vertexBindingDescriptionCount;
+       pVertexBindingDescriptions              = _pVertexBindingDescriptions;
+       vertexAttributeDescriptionCount = _vertexAttributeDescriptionCount;
+       pVertexAttributeDescriptions    = _pVertexAttributeDescriptions;
+}
+
+PipelineCreateInfo::InputAssemblerState::InputAssemblerState (vk::VkPrimitiveTopology  _topology,
+                                                                                                                         vk::VkBool32                          _primitiveRestartEnable)
+{
+       sType = vk::VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
+       pNext = DE_NULL;
+       flags                                   = 0u;
+       topology                                = _topology;
+       primitiveRestartEnable  = _primitiveRestartEnable;
+}
+
+PipelineCreateInfo::TesselationState::TesselationState (deUint32 _patchControlPoints)
+{
+       sType = vk::VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO;
+       pNext = DE_NULL;
+       patchControlPoints = _patchControlPoints;
+}
+
+PipelineCreateInfo::ViewportState::ViewportState (deUint32                                             _viewportCount,
+                                                                                                 std::vector<vk::VkViewport>   _viewports,
+                                                                                                 std::vector<vk::VkRect2D>             _scissors)
+{
+       sType = vk::VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
+       pNext = DE_NULL;
+       flags                   = 0u;
+       viewportCount   = _viewportCount;
+       scissorCount    = _viewportCount;
+       
+       if (!_viewports.size())
+       {
+               m_viewports.resize(viewportCount);
+               deMemset(&m_viewports[0], 0, sizeof(m_viewports[0]) * m_viewports.size());
+       }
+       else
+       {
+               m_viewports = _viewports;
+       }
+
+       if (!_scissors.size())
+       {
+               m_scissors.resize(scissorCount);
+               deMemset(&m_scissors[0], 0, sizeof(m_scissors[0]) * m_scissors.size());
+       }
+       else
+       {
+               m_scissors = _scissors;
+       }
+
+       pViewports      = &m_viewports[0];
+       pScissors       = &m_scissors[0];
+}
+
+PipelineCreateInfo::ViewportState::ViewportState (const ViewportState &other)
+{
+       sType                   = other.sType;
+       pNext                   = other.pNext;
+       viewportCount   = other.viewportCount;
+       scissorCount    = other.scissorCount;
+
+       m_viewports = std::vector<vk::VkViewport>(other.pViewports, other.pViewports + viewportCount);
+       m_scissors      = std::vector<vk::VkRect2D>(other.pScissors, other.pScissors + scissorCount);
+
+       pViewports      = &m_viewports[0];
+       pScissors       = &m_scissors[0];
+}
+
+PipelineCreateInfo::ViewportState & PipelineCreateInfo::ViewportState::operator= (const ViewportState &other)
+{
+       sType                   = other.sType;
+       pNext                   = other.pNext;
+       viewportCount   = other.viewportCount;
+       scissorCount    = other.scissorCount;
+
+       m_viewports             = std::vector<vk::VkViewport>(other.pViewports, other.pViewports + scissorCount);
+       m_scissors              = std::vector<vk::VkRect2D>(other.pScissors, other.pScissors + scissorCount);
+
+       pViewports              = &m_viewports[0];
+       pScissors               = &m_scissors[0];
+       return *this;
+}
+
+PipelineCreateInfo::RasterizerState::RasterizerState (vk::VkBool32                     _depthClampEnable,
+                                                                                                         vk::VkBool32                  _rasterizerDiscardEnable,
+                                                                                                         vk::VkPolygonMode             _polygonMode,
+                                                                                                         vk::VkCullModeFlags   _cullMode,
+                                                                                                         vk::VkFrontFace               _frontFace,
+                                                                                                         vk::VkBool32                  _depthBiasEnable,
+                                                                                                         float                                 _depthBiasConstantFactor,
+                                                                                                         float                                 _depthBiasClamp,
+                                                                                                         float                                 _depthBiasSlopeFactor,
+                                                                                                         float                                 _lineWidth)
+{
+       sType = vk::VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
+       pNext = DE_NULL;
+       flags                                   = 0u;
+       depthClampEnable                = _depthClampEnable;
+       rasterizerDiscardEnable = _rasterizerDiscardEnable;
+       polygonMode                             = _polygonMode;
+       cullMode                                = _cullMode;
+       frontFace                               = _frontFace;
+
+       depthBiasEnable                 = _depthBiasEnable;
+       depthBiasConstantFactor = _depthBiasConstantFactor;
+       depthBiasClamp                  = _depthBiasClamp;
+       depthBiasSlopeFactor    = _depthBiasSlopeFactor;
+       lineWidth                               = _lineWidth;
+}
+
+PipelineCreateInfo::MultiSampleState::MultiSampleState (vk::VkSampleCountFlagBits                              _rasterizationSamples,
+                                                                                                               vk::VkBool32                                                    _sampleShadingEnable,
+                                                                                                               float                                                                   _minSampleShading,
+                                                                                                               const std::vector<vk::VkSampleMask>&    _sampleMask,
+                                                                                                               bool                                                                    _alphaToCoverageEnable, 
+                                                                                                               bool                                                                    _alphaToOneEnable)
+       : m_sampleMask(_sampleMask)
+{
+       sType = vk::VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
+       pNext = DE_NULL;
+       flags                                   = 0u;
+       rasterizationSamples    = _rasterizationSamples;
+       sampleShadingEnable             = _sampleShadingEnable;
+       minSampleShading                = _minSampleShading;
+       pSampleMask                             = &m_sampleMask[0];
+       alphaToCoverageEnable   = _alphaToCoverageEnable;
+       alphaToOneEnable                = _alphaToOneEnable;
+}
+
+PipelineCreateInfo::MultiSampleState::MultiSampleState (const MultiSampleState &other)
+{
+       sType                                   = other.sType;
+       pNext                                   = other.pNext;
+       rasterizationSamples    = other.rasterizationSamples;
+       sampleShadingEnable             = other.sampleShadingEnable;
+       minSampleShading                = other.minSampleShading;
+       
+       const size_t sampleMaskArrayLen = (sizeof(vk::VkSampleMask) * 8 + other.rasterizationSamples) / (sizeof(vk::VkSampleMask) * 8);
+
+       m_sampleMask    = std::vector<vk::VkSampleMask>(other.pSampleMask, other.pSampleMask + sampleMaskArrayLen);
+       pSampleMask             = &m_sampleMask[0];
+}
+
+PipelineCreateInfo::MultiSampleState& PipelineCreateInfo::MultiSampleState::operator= (const MultiSampleState & other)
+{
+       sType = other.sType;
+       pNext = other.pNext;
+       rasterizationSamples    = other.rasterizationSamples;
+       sampleShadingEnable             = other.sampleShadingEnable;
+       minSampleShading                = other.minSampleShading;
+
+       const size_t sampleMaskArrayLen = (sizeof(vk::VkSampleMask) * 8 + other.rasterizationSamples) / (sizeof(vk::VkSampleMask) * 8);
+
+       m_sampleMask    = std::vector<vk::VkSampleMask>(other.pSampleMask, other.pSampleMask + sampleMaskArrayLen);
+       pSampleMask             = &m_sampleMask[0];
+
+       return *this;
+}
+
+PipelineCreateInfo::ColorBlendState::ColorBlendState (const std::vector<vk::VkPipelineColorBlendAttachmentState>&      _attachments,
+                                                                                                         vk::VkBool32                                                                                                  _logicOpEnable,
+                                                                                                         vk::VkLogicOp                                                                                                 _logicOp)
+       : m_attachments(_attachments)
+{
+       sType = vk::VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
+       pNext = DE_NULL; 
+       flags                                   = 0u;
+       logicOpEnable                   = _logicOpEnable;
+       logicOp                                 = _logicOp;
+       attachmentCount                 = static_cast<deUint32>(m_attachments.size());
+       pAttachments                    = &m_attachments[0];
+}
+
+PipelineCreateInfo::ColorBlendState::ColorBlendState (deUint32                                                                                 _attachmentCount,
+                                                                                                         const vk::VkPipelineColorBlendAttachmentState*        _attachments,
+                                                                                                         vk::VkBool32                                                                          _logicOpEnable,
+                                                                                                         vk::VkLogicOp                                                                         _logicOp)
+       : m_attachments(_attachments, _attachments + _attachmentCount)
+{
+       sType = vk::VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
+       pNext   = DE_NULL; 
+       logicOpEnable                   = _logicOpEnable;
+       logicOp                                 = _logicOp;
+       attachmentCount                 = static_cast<deUint32>(m_attachments.size());
+       pAttachments                    = &m_attachments[0];
+}
+
+PipelineCreateInfo::ColorBlendState::ColorBlendState (const vk::VkPipelineColorBlendStateCreateInfo &createInfo)
+       : m_attachments (createInfo.pAttachments, createInfo.pAttachments + createInfo.attachmentCount)
+{
+       sType = createInfo.sType;
+       pNext = createInfo.pNext;
+       logicOpEnable                   = createInfo.logicOpEnable;
+       logicOp                                 = createInfo.logicOp;
+       attachmentCount                 = static_cast<deUint32>(m_attachments.size());
+       pAttachments                    = &m_attachments[0];
+}
+
+PipelineCreateInfo::ColorBlendState::ColorBlendState (const ColorBlendState &createInfo, std::vector<float> _blendConstants)
+       : m_attachments (createInfo.pAttachments, createInfo.pAttachments + createInfo.attachmentCount)
+{
+       sType = createInfo.sType;
+       pNext = createInfo.pNext;
+       logicOpEnable                   = createInfo.logicOpEnable;
+       logicOp                                 = createInfo.logicOp;
+       attachmentCount                 = static_cast<deUint32>(m_attachments.size());
+       pAttachments                    = &m_attachments[0];
+       deMemcpy(blendConstants, &_blendConstants[0], 4 * sizeof(float));
+}
+
+PipelineCreateInfo::ColorBlendState::Attachment::Attachment (vk::VkBool32              _blendEnable,
+                                                                                                                        vk::VkBlendFactor      _srcColorBlendFactor,
+                                                                                                                        vk::VkBlendFactor      _dstColorBlendFactor,
+                                                                                                                        vk::VkBlendOp          _colorBlendOp,
+                                                                                                                        vk::VkBlendFactor      _srcAlphaBlendFactor,
+                                                                                                                        vk::VkBlendFactor      _dstAlphaBlendFactor,
+                                                                                                                        vk::VkBlendOp          _alphaBlendOp,
+                                                                                                                        deUint8                        _colorWriteMask)
+{
+       blendEnable                     = _blendEnable;
+       srcColorBlendFactor     = _srcColorBlendFactor;
+       dstColorBlendFactor     = _dstColorBlendFactor;
+       colorBlendOp            = _colorBlendOp;
+       srcAlphaBlendFactor     = _srcAlphaBlendFactor;
+       dstAlphaBlendFactor     = _dstAlphaBlendFactor;
+       alphaBlendOp            = _alphaBlendOp;
+       colorWriteMask  = _colorWriteMask;
+}
+
+PipelineCreateInfo::DepthStencilState::StencilOpState::StencilOpState (vk::VkStencilOp _failOp,
+                                                                                                                                          vk::VkStencilOp      _passOp,
+                                                                                                                                          vk::VkStencilOp      _depthFailOp,
+                                                                                                                                          vk::VkCompareOp      _compareOp,
+                                                                                                                                          deUint32                     _compareMask,
+                                                                                                                                          deUint32                     _writeMask,
+                                                                                                                                          deUint32                     _reference)
+{
+       failOp          = _failOp;
+       passOp          = _passOp;
+       depthFailOp     = _depthFailOp;
+       compareOp       = _compareOp;
+
+       compareMask     = _compareMask;
+       writeMask       = _writeMask;
+       reference       = _reference;
+}
+
+PipelineCreateInfo::DepthStencilState::DepthStencilState (vk::VkBool32         _depthTestEnable,
+                                                                                                                 vk::VkBool32          _depthWriteEnable,
+                                                                                                                 vk::VkCompareOp       _depthCompareOp,
+                                                                                                                 vk::VkBool32          _depthBoundsTestEnable,
+                                                                                                                 vk::VkBool32          _stencilTestEnable,
+                                                                                                                 StencilOpState        _front,
+                                                                                                                 StencilOpState        _back,
+                                                                                                                 float                         _minDepthBounds,
+                                                                                                                 float                         _maxDepthBounds)
+{
+       sType = vk::VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO;
+       pNext = DE_NULL;
+       flags                                   = 0u;
+       depthTestEnable                 = _depthTestEnable;
+       depthWriteEnable                = _depthWriteEnable;
+       depthCompareOp                  = _depthCompareOp;
+       depthBoundsTestEnable   = _depthBoundsTestEnable;
+       stencilTestEnable               = _stencilTestEnable;
+       front   = _front;
+       back    = _back;
+
+       minDepthBounds = _minDepthBounds;
+       maxDepthBounds = _maxDepthBounds;
+}
+
+PipelineCreateInfo::DynamicState::DynamicState (const std::vector<vk::VkDynamicState>& _dynamicStates)
+{
+       sType = vk::VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO;
+       pNext = DE_NULL;
+
+       if (!_dynamicStates.size())
+       {
+               for (size_t i = 0; i < vk::VK_DYNAMIC_STATE_LAST; ++i)
+               {
+                       m_dynamicStates.push_back(static_cast<vk::VkDynamicState>(i));
+               }
+       }
+       else
+               m_dynamicStates = _dynamicStates;
+
+       dynamicStateCount = static_cast<deUint32>(m_dynamicStates.size());
+       pDynamicStates = &m_dynamicStates[0];
+}
+
+PipelineCreateInfo::DynamicState::DynamicState (const DynamicState &other)
+{
+       sType = other.sType;
+       pNext = other.pNext;
+
+       dynamicStateCount = other.dynamicStateCount;
+
+       m_dynamicStates = std::vector<vk::VkDynamicState>(other.pDynamicStates, other.pDynamicStates + dynamicStateCount);
+       pDynamicStates = &m_dynamicStates[0];
+}
+
+PipelineCreateInfo::DynamicState & PipelineCreateInfo::DynamicState::operator= (const DynamicState &other)
+{
+       sType = other.sType;
+       pNext = other.pNext;
+
+       dynamicStateCount = other.dynamicStateCount;
+
+       m_dynamicStates = std::vector<vk::VkDynamicState>(other.pDynamicStates, other.pDynamicStates + dynamicStateCount);
+       pDynamicStates = &m_dynamicStates[0];
+
+       return *this;
+}
+
+PipelineCreateInfo::PipelineCreateInfo (vk::VkPipelineLayout           _layout,
+                                                                               vk::VkRenderPass                        _renderPass,
+                                                                               int                                                     _subpass,
+                                                                               vk::VkPipelineCreateFlags       _flags)
+{
+       deMemset(static_cast<vk::VkGraphicsPipelineCreateInfo *>(this), 0,
+               sizeof(vk::VkGraphicsPipelineCreateInfo));
+
+       sType = vk::VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
+       pNext = DE_NULL;
+       flags                           = _flags;
+       renderPass                      = _renderPass;
+       subpass                         = _subpass;
+       layout                          = _layout;
+       basePipelineHandle      = DE_NULL;
+       basePipelineIndex       = 0;
+       pDynamicState           = DE_NULL;
+}
+
+PipelineCreateInfo& PipelineCreateInfo::addShader (const vk::VkPipelineShaderStageCreateInfo &shader)
+{
+       m_shaders.push_back(shader);
+
+       stageCount      = static_cast<deUint32>(m_shaders.size());
+       pStages         = &m_shaders[0];
+
+       return *this;
+}
+
+PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineVertexInputStateCreateInfo& state)
+{
+       m_vertexInputState      = state;
+       pVertexInputState       = &m_vertexInputState;
+
+       return *this;
+}
+
+PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineInputAssemblyStateCreateInfo& state)
+{
+       m_inputAssemblyState = state;
+       pInputAssemblyState = &m_inputAssemblyState;
+
+       return *this;
+}
+
+PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineColorBlendStateCreateInfo& state)
+{
+       m_colorBlendStateAttachments    = std::vector<vk::VkPipelineColorBlendAttachmentState>(state.pAttachments, state.pAttachments + state.attachmentCount);
+       m_colorBlendState                               = state;
+       m_colorBlendState.pAttachments  = &m_colorBlendStateAttachments[0];
+       pColorBlendState                                = &m_colorBlendState;
+
+       return *this;
+}
+
+PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineViewportStateCreateInfo& state)
+{
+       m_viewports                                     = std::vector<vk::VkViewport>(state.pViewports, state.pViewports + state.viewportCount);
+       m_scissors                                      = std::vector<vk::VkRect2D>(state.pScissors, state.pScissors + state.scissorCount);
+       m_viewportState                         = state;
+       m_viewportState.pViewports      = &m_viewports[0];
+       m_viewportState.pScissors       = &m_scissors[0];
+       pViewportState                          = &m_viewportState;
+
+       return *this;
+}
+
+PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineDepthStencilStateCreateInfo& state)
+{
+       m_dynamicDepthStencilState      = state;
+       pDepthStencilState                      = &m_dynamicDepthStencilState;
+       return *this;
+}
+
+PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineTessellationStateCreateInfo& state)
+{
+       m_tessState                     = state;
+       pTessellationState      = &m_tessState;
+
+       return *this;
+}
+
+PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineRasterizationStateCreateInfo& state)
+{
+       m_rasterState           = state;
+       pRasterizationState     = &m_rasterState;
+
+       return *this;
+}
+
+PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineMultisampleStateCreateInfo& state)
+{
+
+       const size_t sampleMaskArrayLen = (sizeof(vk::VkSampleMask) * 8 + state.rasterizationSamples) / ( sizeof(vk::VkSampleMask) * 8 );
+       m_multisampleStateSampleMask    = std::vector<vk::VkSampleMask>(state.pSampleMask, state.pSampleMask + sampleMaskArrayLen);
+       m_multisampleState                              = state;
+       m_multisampleState.pSampleMask  = &m_multisampleStateSampleMask[0];
+       pMultisampleState                               = &m_multisampleState;
+
+       return *this;
+}
+PipelineCreateInfo& PipelineCreateInfo::addState (const vk::VkPipelineDynamicStateCreateInfo& state)
+{
+       m_dynamicStates                                 = std::vector<vk::VkDynamicState>(state.pDynamicStates, state.pDynamicStates + state.dynamicStateCount);
+       m_dynamicState                                  = state;
+       m_dynamicState.pDynamicStates   = &m_dynamicStates[0];
+       pDynamicState                                   = &m_dynamicState;
+
+       return *this;
+}
+
+SamplerCreateInfo::SamplerCreateInfo (vk::VkFilter                             _magFilter,
+                                                                        vk::VkFilter                           _minFilter,
+                                                                        vk::VkSamplerMipmapMode        _mipmapMode,
+                                                                        vk::VkSamplerAddressMode       _addressModeU,
+                                                                        vk::VkSamplerAddressMode       _addressModeV,
+                                                                        vk::VkSamplerAddressMode       _addressModeW,
+                                                                        float                                          _mipLodBias,
+                                                                        float                                          _maxAnisotropy,
+                                                                        vk::VkBool32                           _compareEnable,
+                                                                        vk::VkCompareOp                        _compareOp,
+                                                                        float                                          _minLod,
+                                                                        float                                          _maxLod,
+                                                                        vk::VkBorderColor                      _borderColor,
+                                                                        vk::VkBool32                           _unnormalizedCoordinates)
+{
+       sType                                   = vk::VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
+       pNext                                   = DE_NULL;
+       flags                                   = 0u;
+       magFilter                               = _magFilter;
+       minFilter                               = _minFilter;
+       mipmapMode                              = _mipmapMode;
+       addressModeU                    = _addressModeU;
+       addressModeV                    = _addressModeV;
+       addressModeW                    = _addressModeW;
+       mipLodBias                              = _mipLodBias;
+       maxAnisotropy                   = _maxAnisotropy;
+       compareEnable                   = _compareEnable;
+       compareOp                               = _compareOp;
+       minLod                                  = _minLod;
+       maxLod                                  = _maxLod;
+       borderColor                             = _borderColor;
+       unnormalizedCoordinates = _unnormalizedCoordinates;
+}
+
+} // Draw
+} // vkt
diff --git a/external/vulkancts/modules/vulkan/draw/vktDrawCreateInfoUtil.hpp b/external/vulkancts/modules/vulkan/draw/vktDrawCreateInfoUtil.hpp
new file mode 100644 (file)
index 0000000..15ee661
--- /dev/null
@@ -0,0 +1,528 @@
+#ifndef _VKTDRAWCREATEINFO_UTIL_HPP
+#define _VKTDRAWCREATEINFO_UTIL_HPP
+/*------------------------------------------------------------------------
+ * Vulkan Conformance Tests
+ * ------------------------
+ *
+ * Copyright (c) 2015 The Khronos Group Inc.
+ * Copyright (c) 2015 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and/or associated documentation files (the
+ * "Materials"), to deal in the Materials without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Materials, and to
+ * permit persons to whom the Materials are furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice(s) and this permission notice shall be included
+ * in all copies or substantial portions of the Materials.
+ *
+ * The Materials are Confidential Information as defined by the
+ * Khronos Membership Agreement until designated non-confidential by Khronos,
+ * at which point this condition clause shall be removed.
+ *
+ * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ *
+ *//*!
+ * \file
+ * \brief CreateInfo utilities
+ *//*--------------------------------------------------------------------*/
+
+#include "vkDefs.hpp"
+#include "tcuVector.hpp"
+
+#include "deSharedPtr.hpp"
+
+#include <vector>
+
+namespace vkt
+{
+namespace Draw
+{
+
+class ImageSubresourceRange : public vk::VkImageSubresourceRange
+{
+public:
+       ImageSubresourceRange ( vk::VkImageAspectFlags  aspectMask,
+                                                       deUint32                                baseMipLevel    = 0,
+                                                       deUint32                                levelCount              = 1,
+                                                       deUint32                                baseArrayLayer  = 0,
+                                                       deUint32                                layerCount              = 1);
+};
+
+class ComponentMapping : public vk::VkComponentMapping
+{
+public:
+       ComponentMapping (      vk::VkComponentSwizzle r = vk::VK_COMPONENT_SWIZZLE_R,
+                                               vk::VkComponentSwizzle g = vk::VK_COMPONENT_SWIZZLE_G,
+                                               vk::VkComponentSwizzle b = vk::VK_COMPONENT_SWIZZLE_B,
+                                               vk::VkComponentSwizzle a = vk::VK_COMPONENT_SWIZZLE_A);
+};
+
+class ImageViewCreateInfo : public vk::VkImageViewCreateInfo
+{
+public:
+       ImageViewCreateInfo (           vk::VkImage                                             image,
+                                                               vk::VkImageViewType                             viewType,
+                                                               vk::VkFormat                                    format,
+                                               const   vk::VkImageSubresourceRange&    subresourceRange,
+                                               const   vk::VkComponentMapping&                 components                      = ComponentMapping(),
+                                                               vk::VkImageViewCreateFlags              flags                           = 0);
+
+       ImageViewCreateInfo (           vk::VkImage                                             image,
+                                                               vk::VkImageViewType                             viewType,
+                                                               vk::VkFormat                                    format,
+                                               const   vk::VkComponentMapping&                 components                      = ComponentMapping(),
+                                                               vk::VkImageViewCreateFlags              flags                           = 0);
+};
+
+class BufferViewCreateInfo : public vk::VkBufferViewCreateInfo
+{
+public:
+       BufferViewCreateInfo (  vk::VkBuffer            buffer,
+                                                       vk::VkFormat            format,
+                                                       vk::VkDeviceSize        offset,
+                                                       vk::VkDeviceSize        range);
+};
+
+class BufferCreateInfo : public vk::VkBufferCreateInfo
+{
+public:
+       BufferCreateInfo (              vk::VkDeviceSize                        size,
+                                                       vk::VkBufferCreateFlags         usage,
+                                                       vk::VkSharingMode                       sharingMode                             = vk::VK_SHARING_MODE_EXCLUSIVE,
+                                                       deUint32                                        queueFamilyIndexCount   = 0,
+                                                       const   deUint32*                       pQueueFamilyIndices             = DE_NULL, 
+                                                       vk::VkBufferCreateFlags         flags                                   = 0);
+
+       BufferCreateInfo                        (const BufferCreateInfo &other);        
+       BufferCreateInfo &operator=     (const BufferCreateInfo &other);
+
+private:
+       std::vector<deUint32> m_queueFamilyIndices;
+};
+
+
+class ImageCreateInfo : public vk::VkImageCreateInfo
+{
+public:
+       ImageCreateInfo (               vk::VkImageType                         imageType,
+                                                       vk::VkFormat                            format,
+                                                       vk::VkExtent3D                          extent,
+                                                       deUint32                                        mipLevels,
+                                                       deUint32                                        arrayLayers,
+                                                       vk::VkSampleCountFlagBits       samples,
+                                                       vk::VkImageTiling                       tiling,
+                                                       vk::VkImageUsageFlags           usage,
+                                                       vk::VkSharingMode                       sharingMode                             = vk::VK_SHARING_MODE_EXCLUSIVE,
+                                                       deUint32                                        queueFamilyIndexCount   = 0,
+                                       const   deUint32*                                       pQueueFamilyIndices             = DE_NULL,
+                                                       vk::VkImageCreateFlags          flags                                   = 0, 
+                                                       vk::VkImageLayout                       initialLayout                   = vk::VK_IMAGE_LAYOUT_UNDEFINED);
+
+private:
+       ImageCreateInfo                         (const ImageCreateInfo &other);
+       ImageCreateInfo &operator=      (const ImageCreateInfo &other);
+
+       std::vector<deUint32> m_queueFamilyIndices;
+};
+
+class FramebufferCreateInfo : public vk::VkFramebufferCreateInfo
+{
+public:
+       FramebufferCreateInfo (                 vk::VkRenderPass                                renderPass,
+                                                       const   std::vector<vk::VkImageView>&   attachments,
+                                                                       deUint32                                                width,
+                                                                       deUint32                                                height,
+                                                                       deUint32                                                layers);
+};
+
+class AttachmentDescription : public vk::VkAttachmentDescription
+{
+public:
+       AttachmentDescription ( vk::VkFormat                            format,
+                                                       vk::VkSampleCountFlagBits       samples,
+                                                       vk::VkAttachmentLoadOp          loadOp,
+                                                       vk::VkAttachmentStoreOp         storeOp,
+                                                       vk::VkAttachmentLoadOp          stencilLoadOp,
+                                                       vk::VkAttachmentStoreOp         stencilStoreOp,
+                                                       vk::VkImageLayout                       initialLayout,
+                                                       vk::VkImageLayout                       finalLayout);
+
+       AttachmentDescription (const vk::VkAttachmentDescription &);
+};
+
+class AttachmentReference : public vk::VkAttachmentReference
+{
+public:
+       AttachmentReference (deUint32 attachment, vk::VkImageLayout layout);
+       AttachmentReference (void);
+};
+
+class SubpassDescription : public vk::VkSubpassDescription
+{
+public:
+       SubpassDescription (            vk::VkPipelineBindPoint                 pipelineBindPoint,
+                                                               vk::VkSubpassDescriptionFlags   flags,
+                                                               deUint32                                                inputAttachmentCount,
+                                               const   vk::VkAttachmentReference*              inputAttachments,
+                                                               deUint32                                                colorAttachmentCount,
+                                               const   vk::VkAttachmentReference*              colorAttachments,
+                                               const   vk::VkAttachmentReference*              resolveAttachments,
+                                                               vk::VkAttachmentReference               depthStencilAttachment,
+                                                               deUint32                                                preserveAttachmentCount,
+                                               const   vk::VkAttachmentReference*              preserveAttachments);
+
+       SubpassDescription                              (const vk::VkSubpassDescription& other);
+       SubpassDescription                              (const SubpassDescription& other);
+       SubpassDescription& operator=   (const SubpassDescription& other);
+
+private:
+       std::vector<vk::VkAttachmentReference>   m_inputAttachments;
+       std::vector<vk::VkAttachmentReference>   m_colorAttachments;
+       std::vector<vk::VkAttachmentReference>   m_resolveAttachments;
+       std::vector<vk::VkAttachmentReference>   m_preserveAttachments;
+
+       vk::VkAttachmentReference                               m_depthStencilAttachment;
+};
+
+class SubpassDependency : public vk::VkSubpassDependency
+{
+public:
+       SubpassDependency (     deUint32                                        srcSubpass,
+                                               deUint32                                        dstSubpass,
+                                               vk::VkPipelineStageFlags        srcStageMask,
+                                               vk::VkPipelineStageFlags        dstStageMask,
+                                               vk::VkAccessFlags                       srcAccessMask,
+                                               vk::VkAccessFlags                       dstAccessMask,
+                                               vk::VkDependencyFlags           dependencyFlags);
+
+       SubpassDependency (const vk::VkSubpassDependency& other);
+};
+
+class RenderPassCreateInfo : public vk::VkRenderPassCreateInfo
+{
+public:
+       RenderPassCreateInfo (  const std::vector<vk::VkAttachmentDescription>& attachments,
+                                                       const std::vector<vk::VkSubpassDescription>&    subpasses,
+                                                       const std::vector<vk::VkSubpassDependency>&             dependiences            = std::vector<vk::VkSubpassDependency>());
+
+       RenderPassCreateInfo (                  deUint32 attachmentCount                                                = 0,
+                                                       const   vk::VkAttachmentDescription*    pAttachments    = DE_NULL,
+                                                                       deUint32                                                subpassCount    = 0,
+                                                       const   vk::VkSubpassDescription*               pSubpasses              = DE_NULL,
+                                                                       deUint32                                                dependencyCount = 0,
+                                                       const   vk::VkSubpassDependency*                pDependiences   = DE_NULL);
+
+       void addAttachment      (vk::VkAttachmentDescription attachment);
+       void addSubpass         (vk::VkSubpassDescription subpass);
+       void addDependency      (vk::VkSubpassDependency dependency);
+
+private:
+       std::vector<AttachmentDescription>                      m_attachments;
+       std::vector<SubpassDescription>                         m_subpasses;
+       std::vector<SubpassDependency>                          m_dependiences;
+
+       std::vector<vk::VkAttachmentDescription>        m_attachmentsStructs;
+       std::vector<vk::VkSubpassDescription>           m_subpassesStructs;
+       std::vector<vk::VkSubpassDependency>            m_dependiencesStructs;
+
+       RenderPassCreateInfo                    (const RenderPassCreateInfo &other); //Not allowed!
+       RenderPassCreateInfo &operator= (const RenderPassCreateInfo &other); //Not allowed!
+};
+
+class RenderPassBeginInfo : public vk::VkRenderPassBeginInfo
+{
+public:
+       RenderPassBeginInfo (                   vk::VkRenderPass                                renderPass,
+                                                                       vk::VkFramebuffer                               framebuffer,
+                                                                       vk::VkRect2D                                    renderArea,
+                                                       const   std::vector<vk::VkClearValue>&  clearValues = std::vector<vk::VkClearValue>());
+
+private:
+       std::vector<vk::VkClearValue> m_clearValues;
+
+       RenderPassBeginInfo                             (const RenderPassBeginInfo &other); //Not allowed!
+       RenderPassBeginInfo &operator=  (const RenderPassBeginInfo &other); //Not allowed!
+};
+
+class CmdPoolCreateInfo : public vk::VkCommandPoolCreateInfo
+{
+public:
+       CmdPoolCreateInfo (deUint32 queueFamilyIndex,
+               vk::VkCommandPoolCreateFlags flags = vk::VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT);
+};
+
+class CmdBufferBeginInfo : public vk::VkCommandBufferBeginInfo
+{
+public:
+       CmdBufferBeginInfo (vk::VkCommandBufferUsageFlags               flags   = 0);
+       CmdBufferBeginInfo (vk::VkRenderPass                                    renderPass,
+                                               deUint32                                                        subpass,
+                                               vk::VkFramebuffer                                       framebuffer,
+                                               vk::VkCommandBufferUsageFlags           flags                                   = 0, 
+                                               bool                                                            occlusionQueryEnable    = false,
+                                               vk::VkQueryControlFlags                         queryFlags                              = 0u,
+                                               vk::VkQueryPipelineStatisticFlags       pipelineStatistics              = 0u);
+};
+
+
+class DescriptorPoolSize : public vk::VkDescriptorPoolSize
+{
+public:
+       DescriptorPoolSize (vk::VkDescriptorType _type, deUint32 _descriptorCount)
+       {
+               type                    = _type;
+               descriptorCount = _descriptorCount;
+       }
+};
+
+class DescriptorPoolCreateInfo : public vk::VkDescriptorPoolCreateInfo
+{
+public:
+       DescriptorPoolCreateInfo (      const   std::vector<vk::VkDescriptorPoolSize>&  poolSizeCounts,\r
+                                                                               vk::VkDescriptorPoolCreateFlags flags, \r
+                                                                               deUint32 maxSets);
+
+       DescriptorPoolCreateInfo& addDescriptors (vk::VkDescriptorType type, deUint32 count);
+
+private:
+       std::vector<vk::VkDescriptorPoolSize> m_poolSizeCounts;
+};
+
+
+class DescriptorSetLayoutCreateInfo : public vk::VkDescriptorSetLayoutCreateInfo
+{
+public:
+       DescriptorSetLayoutCreateInfo (deUint32 bindingCount, const vk::VkDescriptorSetLayoutBinding* pBindings);
+};
+
+
+class PipelineLayoutCreateInfo : public vk::VkPipelineLayoutCreateInfo
+{
+public:
+       PipelineLayoutCreateInfo (                      deUint32 descriptorSetCount,
+                                                               const   vk::VkDescriptorSetLayout*                              pSetLayouts,
+                                                                               deUint32                                                                pushConstantRangeCount  = 0,
+                                                                               const vk::VkPushConstantRange*                  pPushConstantRanges             = DE_NULL);
+
+       PipelineLayoutCreateInfo (      const   std::vector<vk::VkDescriptorSetLayout>& setLayouts                              = std::vector<vk::VkDescriptorSetLayout>(),
+                                                                               deUint32                                                                pushConstantRangeCount  = 0,
+                                                               const   vk::VkPushConstantRange*                                pPushConstantRanges             = DE_NULL);
+
+private:
+       std::vector<vk::VkDescriptorSetLayout>  m_setLayouts;
+       std::vector<vk::VkPushConstantRange>    m_pushConstantRanges;
+};
+
+class PipelineCreateInfo : public vk::VkGraphicsPipelineCreateInfo
+{
+public:
+       class VertexInputState : public vk::VkPipelineVertexInputStateCreateInfo
+       {
+       public:
+               VertexInputState (                      deUint32                                                                vertexBindingDescriptionCount   = 0,
+                                                       const   vk::VkVertexInputBindingDescription*    pVertexBindingDescriptions              = NULL,
+                                                                       deUint32                                                                vertexAttributeDescriptionCount = 0,
+                                                       const   vk::VkVertexInputAttributeDescription*  pVertexAttributeDescriptions    = NULL);
+       };
+
+       class InputAssemblerState : public vk::VkPipelineInputAssemblyStateCreateInfo
+       {
+       public:
+               InputAssemblerState (vk::VkPrimitiveTopology topology, vk::VkBool32 primitiveRestartEnable = false);
+       };
+
+       class TesselationState : public vk::VkPipelineTessellationStateCreateInfo
+       {
+       public:
+               TesselationState (deUint32 patchControlPoints = 0);
+       };
+
+       class ViewportState : public vk::VkPipelineViewportStateCreateInfo
+       {
+       public:
+               ViewportState ( deUint32                                        viewportCount,
+                                               std::vector<vk::VkViewport> viewports           = std::vector<vk::VkViewport>(0),
+                                               std::vector<vk::VkRect2D>       scissors                = std::vector<vk::VkRect2D>(0));
+
+               ViewportState                           (const ViewportState &other);
+               ViewportState &operator=                (const ViewportState &other);
+
+               std::vector<vk::VkViewport> m_viewports;
+               std::vector<vk::VkRect2D>       m_scissors;
+       };
+
+       class RasterizerState : public vk::VkPipelineRasterizationStateCreateInfo
+       {
+       public:
+               RasterizerState (       vk::VkBool32            depthClampEnable                = false,
+                                                       vk::VkBool32            rasterizerDiscardEnable = false,
+                                                       vk::VkPolygonMode       polygonMode                             = vk::VK_POLYGON_MODE_FILL,
+                                                       vk::VkCullModeFlags     cullMode                                = vk::VK_CULL_MODE_NONE,
+                                                       vk::VkFrontFace         frontFace                               = vk::VK_FRONT_FACE_CLOCKWISE,
+                                                       vk::VkBool32            depthBiasEnable                 = true,\r
+                                                       float                           depthBiasConstantFactor = 0.0f,
+                                                       float                           depthBiasClamp                  = 0.0f,
+                                                       float                           depthBiasSlopeFactor    = 0.0f,
+                                                       float                           lineWidth                               = 1.0f);
+       };
+
+       class MultiSampleState : public vk::VkPipelineMultisampleStateCreateInfo
+       {
+       public:
+               MultiSampleState (                      vk::VkSampleCountFlagBits               rasterizationSamples            = vk::VK_SAMPLE_COUNT_1_BIT,
+                                                                       vk::VkBool32                                    sampleShadingEnable                     = false,
+                                                                       float                                                   minSampleShading                        = 0.0f,
+                                                       const   std::vector<vk::VkSampleMask>&  sampleMask                                      = std::vector<vk::VkSampleMask>(1, 0xffffffff), 
+                                                       bool                                                                    alphaToCoverageEnable           = false,
+                                                       bool                                                                    alphaToOneEnable                        = false);
+
+               MultiSampleState                        (const MultiSampleState &other);
+               MultiSampleState &operator= (const MultiSampleState &other);
+
+       private:
+               std::vector<vk::VkSampleMask> m_sampleMask;
+       };
+
+       class ColorBlendState : public vk::VkPipelineColorBlendStateCreateInfo
+       {
+       public:
+               class Attachment : public vk::VkPipelineColorBlendAttachmentState
+               {
+               public:
+                       Attachment (vk::VkBool32                blendEnable                     = false,
+                                               vk::VkBlendFactor       srcColorBlendFactor     = vk::VK_BLEND_FACTOR_SRC_COLOR,
+                                               vk::VkBlendFactor       dstColorBlendFactor     = vk::VK_BLEND_FACTOR_DST_COLOR,
+                                               vk::VkBlendOp           colorBlendOp            = vk::VK_BLEND_OP_ADD,
+                                               vk::VkBlendFactor       srcAlphaBlendFactor     = vk::VK_BLEND_FACTOR_SRC_COLOR,
+                                               vk::VkBlendFactor       dstAlphaBlendFactor     = vk::VK_BLEND_FACTOR_DST_COLOR,
+                                               vk::VkBlendOp           alphaBlendOp            = vk::VK_BLEND_OP_ADD,
+                                               deUint8                         colorWriteMask  = 0xff);
+               };
+
+               ColorBlendState (       const   std::vector<vk::VkPipelineColorBlendAttachmentState>&   attachments,
+                                                                       vk::VkBool32                                                                                    alphaToCoverageEnable   = false,
+                                                                       vk::VkLogicOp                                                                                   logicOp                                 = vk::VK_LOGIC_OP_COPY);
+
+               ColorBlendState (                       deUint32                                                                                                attachmentCount,
+                                                       const   vk::VkPipelineColorBlendAttachmentState*                                attachments,
+                                                                       vk::VkBool32                                                                                    logicOpEnable                   = false,
+                                                                       vk::VkLogicOp                                                                                   logicOp                                 = vk::VK_LOGIC_OP_COPY);
+
+               ColorBlendState (const vk::VkPipelineColorBlendStateCreateInfo &createInfo);
+               ColorBlendState (const ColorBlendState &createInfo, std::vector<float> blendConstants = std::vector<float>(4));
+
+       private:
+               std::vector<vk::VkPipelineColorBlendAttachmentState> m_attachments;
+       };
+
+       class DepthStencilState : public vk::VkPipelineDepthStencilStateCreateInfo
+       {
+       public:
+               class StencilOpState : public vk::VkStencilOpState
+               {
+               public:
+                       StencilOpState (vk::VkStencilOp failOp          = vk::VK_STENCIL_OP_REPLACE,
+                                                       vk::VkStencilOp passOp          = vk::VK_STENCIL_OP_REPLACE,
+                                                       vk::VkStencilOp depthFailOp     = vk::VK_STENCIL_OP_REPLACE,
+                                                       vk::VkCompareOp compareOp       = vk::VK_COMPARE_OP_ALWAYS,
+                                                       deUint32                compareMask     = 0xffffffffu,\r
+                                                       deUint32                writeMask       = 0xffffffffu,\r
+                                                       deUint32                reference       = 0);
+               };
+
+               DepthStencilState (     vk::VkBool32    depthTestEnable                 = false,
+                                                       vk::VkBool32    depthWriteEnable                = false,
+                                                       vk::VkCompareOp depthCompareOp                  = vk::VK_COMPARE_OP_ALWAYS,
+                                                       vk::VkBool32    depthBoundsTestEnable   = false,
+                                                       vk::VkBool32    stencilTestEnable               = false,
+                                                       StencilOpState  front                                   = StencilOpState(),
+                                                       StencilOpState  back                                    = StencilOpState(),
+                                                       float                   minDepthBounds                  = -1.0f,
+                                                       float                   maxDepthBounds                  = 1.0f);
+       };
+
+       class PipelineShaderStage : public vk::VkPipelineShaderStageCreateInfo
+       {
+       public:
+               PipelineShaderStage (vk::VkShaderModule shaderModule, const char* _pName, vk::VkShaderStageFlagBits stage);
+       };
+
+       class DynamicState : public vk::VkPipelineDynamicStateCreateInfo
+       {
+       public:
+               DynamicState (const std::vector<vk::VkDynamicState>& dynamicStates = std::vector<vk::VkDynamicState>(0));
+
+               DynamicState                    (const DynamicState &other);
+               DynamicState &operator= (const DynamicState &other);
+
+               std::vector<vk::VkDynamicState> m_dynamicStates;
+       };
+
+       PipelineCreateInfo(vk::VkPipelineLayout layout, vk::VkRenderPass renderPass, int subpass, vk::VkPipelineCreateFlags flags);
+
+       PipelineCreateInfo& addShader (const vk::VkPipelineShaderStageCreateInfo&               shader);
+
+       PipelineCreateInfo& addState (const vk::VkPipelineVertexInputStateCreateInfo&   state);
+       PipelineCreateInfo& addState (const vk::VkPipelineInputAssemblyStateCreateInfo& state);
+       PipelineCreateInfo& addState (const vk::VkPipelineColorBlendStateCreateInfo&    state);
+       PipelineCreateInfo& addState (const vk::VkPipelineViewportStateCreateInfo&              state);
+       PipelineCreateInfo& addState (const vk::VkPipelineDepthStencilStateCreateInfo&  state);
+       PipelineCreateInfo& addState (const vk::VkPipelineTessellationStateCreateInfo&  state);
+       PipelineCreateInfo& addState (const vk::VkPipelineRasterizationStateCreateInfo&         state);
+       PipelineCreateInfo& addState (const vk::VkPipelineMultisampleStateCreateInfo&   state);
+       PipelineCreateInfo& addState (const vk::VkPipelineDynamicStateCreateInfo&                               state);
+
+private:
+       std::vector<vk::VkPipelineShaderStageCreateInfo>                m_shaders;
+
+       vk::VkPipelineVertexInputStateCreateInfo                                m_vertexInputState;
+       vk::VkPipelineInputAssemblyStateCreateInfo                              m_inputAssemblyState;
+       std::vector<vk::VkPipelineColorBlendAttachmentState>    m_colorBlendStateAttachments;
+       vk::VkPipelineColorBlendStateCreateInfo                                 m_colorBlendState;
+       vk::VkPipelineViewportStateCreateInfo                                   m_viewportState;
+       vk::VkPipelineDepthStencilStateCreateInfo                               m_dynamicDepthStencilState;
+       vk::VkPipelineTessellationStateCreateInfo                               m_tessState;
+       vk::VkPipelineRasterizationStateCreateInfo                              m_rasterState;
+       vk::VkPipelineMultisampleStateCreateInfo                                m_multisampleState;
+       vk::VkPipelineDynamicStateCreateInfo                                    m_dynamicState;
+
+       std::vector<vk::VkDynamicState> m_dynamicStates;
+
+       std::vector<vk::VkViewport>             m_viewports;
+       std::vector<vk::VkRect2D>               m_scissors;
+
+       std::vector<vk::VkSampleMask>   m_multisampleStateSampleMask;
+};
+
+class SamplerCreateInfo : public vk::VkSamplerCreateInfo
+{
+public:
+       SamplerCreateInfo (     vk::VkFilter                            magFilter                               = vk::VK_FILTER_NEAREST,
+                                               vk::VkFilter                            minFilter                               = vk::VK_FILTER_NEAREST,
+                                               vk::VkSamplerMipmapMode         mipmapMode                              = vk::VK_SAMPLER_MIPMAP_MODE_NEAREST,
+                                               vk::VkSamplerAddressMode        addressU                                = vk::VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT,
+                                               vk::VkSamplerAddressMode        addressV                                = vk::VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT,
+                                               vk::VkSamplerAddressMode        addressW                                = vk::VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT,
+                                               float                                           mipLodBias                              = 0.0f,
+                                               float                                           maxAnisotropy                   = 1.0f,
+                                               vk::VkBool32                            compareEnable                   = false,
+                                               vk::VkCompareOp                         compareOp                               = vk::VK_COMPARE_OP_ALWAYS,
+                                               float                                           minLod                                  = 0.0f,
+                                               float                                           maxLod                                  = 16.0f,
+                                               vk::VkBorderColor                       borderColor                             = vk::VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE, 
+                                               vk::VkBool32                            unnormalizedCoordinates = false);
+};
+
+} // Draw
+} // vkt
+
+#endif // _VKTDRAWCREATEINFO_UTIL_HPP
diff --git a/external/vulkancts/modules/vulkan/draw/vktDrawImageObjectUtil.cpp b/external/vulkancts/modules/vulkan/draw/vktDrawImageObjectUtil.cpp
new file mode 100644 (file)
index 0000000..ee558cd
--- /dev/null
@@ -0,0 +1,937 @@
+/*------------------------------------------------------------------------
+ * Vulkan Conformance Tests
+ * ------------------------
+ *
+ * Copyright (c) 2015 The Khronos Group Inc.
+ * Copyright (c) 2015 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and/or associated documentation files (the
+ * "Materials"), to deal in the Materials without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Materials, and to
+ * permit persons to whom the Materials are furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice(s) and this permission notice shall be included
+ * in all copies or substantial portions of the Materials.
+ *
+ * The Materials are Confidential Information as defined by the
+ * Khronos Membership Agreement until designated non-confidential by Khronos,
+ * at which point this condition clause shall be removed.
+ *
+ * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ *
+ *//*!
+ * \file
+ * \brief Image Object Util
+ *//*--------------------------------------------------------------------*/
+
+#include "vktDrawImageObjectUtil.hpp"
+
+#include "tcuSurface.hpp"
+#include "tcuVectorUtil.hpp"
+
+#include "vkRefUtil.hpp"
+#include "vkQueryUtil.hpp"
+#include "vkImageUtil.hpp"
+#include "vktDrawCreateInfoUtil.hpp"
+#include "vktDrawBufferObjectUtil.hpp"
+
+#include "tcuTextureUtil.hpp"
+
+namespace vkt
+{
+namespace Draw
+{
+
+void MemoryOp::pack (int                               pixelSize,
+                                        int                            width,
+                                        int                            height,
+                                        int                            depth,
+                                        vk::VkDeviceSize       rowPitch,
+                                        vk::VkDeviceSize       depthPitch,
+                                        const void *           srcBuffer,
+                                        void *                         destBuffer)
+{
+       if (rowPitch == 0) 
+               rowPitch = width * pixelSize;
+
+       if (depthPitch == 0) 
+               depthPitch = rowPitch * height;
+
+       const vk::VkDeviceSize size = depthPitch * depth;
+
+       const char *srcRow = reinterpret_cast<const char *>(srcBuffer);
+       const char *srcStart;
+       srcStart = srcRow;
+       char *dstRow = reinterpret_cast<char *>(destBuffer);
+       char *dstStart;
+       dstStart = dstRow;
+
+       if (rowPitch == static_cast<vk::VkDeviceSize>(width * pixelSize) &&
+               depthPitch == static_cast<vk::VkDeviceSize>(rowPitch * height)) 
+       {
+               // fast path
+               deMemcpy(dstRow, srcRow, static_cast<size_t>(size));
+       }
+       else
+       {
+               // slower, per row path
+               for (int d = 0; d < depth; d++)
+               {
+                       vk::VkDeviceSize offsetDepthDst = d * depthPitch;
+                       vk::VkDeviceSize offsetDepthSrc = d * (pixelSize * width * height);
+                       srcRow = srcStart + offsetDepthSrc;
+                       dstRow = dstStart + offsetDepthDst;
+                       for (int r = 0; r < height; ++r) 
+                       {
+                               deMemcpy(dstRow, srcRow, static_cast<size_t>(rowPitch));
+                               srcRow += pixelSize * width;
+                               dstRow += rowPitch;
+                       }
+               }
+       }
+}
+
+void MemoryOp::unpack (int                                     pixelSize,
+                                          int                                  width,
+                                          int                                  height,
+                                          int                                  depth,
+                                          vk::VkDeviceSize             rowPitch,
+                                          vk::VkDeviceSize             depthPitch,
+                                          const void *                 srcBuffer,
+                                          void *                               destBuffer)
+{
+       if (rowPitch == 0)
+               rowPitch = width * pixelSize;
+
+       if (depthPitch == 0) 
+               depthPitch = rowPitch * height;
+
+       const vk::VkDeviceSize size = depthPitch * depth;
+
+       const char *srcRow = reinterpret_cast<const char *>(srcBuffer);
+       const char *srcStart;
+       srcStart = srcRow;
+       char *dstRow = reinterpret_cast<char *>(destBuffer);
+       char *dstStart;
+       dstStart = dstRow;
+
+       if (rowPitch == static_cast<vk::VkDeviceSize>(width * pixelSize) &&
+               depthPitch == static_cast<vk::VkDeviceSize>(rowPitch * height)) 
+       {
+               // fast path
+               deMemcpy(dstRow, srcRow, static_cast<size_t>(size));
+       }
+       else {
+               // slower, per row path
+               for (size_t d = 0; d < (size_t)depth; d++)
+               {
+                       vk::VkDeviceSize offsetDepthDst = d * (pixelSize * width * height);
+                       vk::VkDeviceSize offsetDepthSrc = d * depthPitch;
+                       srcRow = srcStart + offsetDepthSrc;
+                       dstRow = dstStart + offsetDepthDst;
+                       for (int r = 0; r < height; ++r) 
+                       {
+                               deMemcpy(dstRow, srcRow, static_cast<size_t>(pixelSize * width));
+                               srcRow += rowPitch;
+                               dstRow += pixelSize * width;
+                       }
+               }
+       }
+}
+
+Image::Image (const vk::DeviceInterface &vk,
+                         vk::VkDevice                          device,
+                         vk::VkFormat                          format,
+                         const vk::VkExtent3D          &extend,
+                         deUint32                                      levelCount,
+                         deUint32                                      layerCount,
+                         vk::Move<vk::VkImage>         object)
+       : m_allocation          (DE_NULL)
+       , m_object                      (object)
+       , m_format                      (format)
+       , m_extent                      (extend)
+       , m_levelCount          (levelCount)
+       , m_layerCount          (layerCount)
+       , m_vk(vk)
+       , m_device(device)
+{
+}
+
+tcu::ConstPixelBufferAccess Image::readSurface (vk::VkQueue                                    queue,
+                                                                                               vk::Allocator&                          allocator,
+                                                                                               vk::VkImageLayout                       layout,
+                                                                                               vk::VkOffset3D                          offset,
+                                                                                               int                                                     width,
+                                                                                               int                                                     height,
+                                                                                               vk::VkImageAspectFlagBits       aspect,
+                                                                                               unsigned int                            mipLevel,
+                                                                                               unsigned int                            arrayElement)
+{
+       m_pixelAccessData.resize(width * height * vk::mapVkFormat(m_format).getPixelSize());
+       deMemset(m_pixelAccessData.data(), 0, m_pixelAccessData.size());
+       if (aspect == vk::VK_IMAGE_ASPECT_COLOR_BIT)
+       {
+               read(queue, allocator, layout, offset, width, height, 1, mipLevel, arrayElement, aspect, vk::VK_IMAGE_TYPE_2D,
+               m_pixelAccessData.data());
+       }
+       if (aspect == vk::VK_IMAGE_ASPECT_DEPTH_BIT || aspect == vk::VK_IMAGE_ASPECT_STENCIL_BIT)
+       {
+               readUsingBuffer(queue, allocator, layout, offset, width, height, 1, mipLevel, arrayElement, aspect, m_pixelAccessData.data());
+       }
+       return tcu::ConstPixelBufferAccess(vk::mapVkFormat(m_format), width, height, 1, m_pixelAccessData.data());
+}
+
+tcu::ConstPixelBufferAccess Image::readVolume (vk::VkQueue                                     queue,
+                                                                                          vk::Allocator&                               allocator,
+                                                                                          vk::VkImageLayout                    layout,
+                                                                                          vk::VkOffset3D                               offset,
+                                                                                          int                                                  width,
+                                                                                          int                                                  height,
+                                                                                          int                                                  depth,
+                                                                                          vk::VkImageAspectFlagBits    aspect,
+                                                                                          unsigned int                                 mipLevel,
+                                                                                          unsigned int                                 arrayElement)
+{
+       m_pixelAccessData.resize(width * height * depth * vk::mapVkFormat(m_format).getPixelSize());
+       deMemset(m_pixelAccessData.data(), 0, m_pixelAccessData.size());
+       if (aspect == vk::VK_IMAGE_ASPECT_COLOR_BIT)
+       {
+               read(queue, allocator, layout, offset, width, height, depth, mipLevel, arrayElement, aspect, vk::VK_IMAGE_TYPE_3D,
+               m_pixelAccessData.data());
+       }
+       if (aspect == vk::VK_IMAGE_ASPECT_DEPTH_BIT || aspect == vk::VK_IMAGE_ASPECT_STENCIL_BIT)
+       {
+               readUsingBuffer(queue, allocator, layout, offset, width, height, depth, mipLevel, arrayElement, aspect, m_pixelAccessData.data());
+       }
+       return tcu::ConstPixelBufferAccess(vk::mapVkFormat(m_format), width, height, depth, m_pixelAccessData.data());
+}
+
+tcu::ConstPixelBufferAccess Image::readSurface1D(vk::VkQueue                           queue,
+                                                                                                vk::Allocator&                         allocator,
+                                                                                                vk::VkImageLayout                      layout,
+                                                                                                vk::VkOffset3D                         offset,
+                                                                                                int                                            width,
+                                                                                                vk::VkImageAspectFlagBits      aspect,
+                                                                                                unsigned int                           mipLevel,
+                                                                                                unsigned int                           arrayElement)
+{
+       m_pixelAccessData.resize(width * vk::mapVkFormat(m_format).getPixelSize());
+       deMemset(m_pixelAccessData.data(), 0, m_pixelAccessData.size());
+       if (aspect == vk::VK_IMAGE_ASPECT_COLOR_BIT)
+       {
+               read(queue, allocator, layout, offset, width, 1, 1, mipLevel, arrayElement, aspect, vk::VK_IMAGE_TYPE_1D,
+               m_pixelAccessData.data());
+       }
+       if (aspect == vk::VK_IMAGE_ASPECT_DEPTH_BIT || aspect == vk::VK_IMAGE_ASPECT_STENCIL_BIT)
+       {
+               readUsingBuffer(queue, allocator, layout, offset, width, 1, 1, mipLevel, arrayElement, aspect,
+               m_pixelAccessData.data());
+       }
+       return tcu::ConstPixelBufferAccess(vk::mapVkFormat(m_format), width, 1, 1, m_pixelAccessData.data());
+}
+
+void Image::read (vk::VkQueue                                  queue,
+                                 vk::Allocator&                                allocator,
+                                 vk::VkImageLayout                             layout,
+                                 vk::VkOffset3D                                offset,
+                                 int                                                   width,
+                                 int                                                   height,
+                                 int                                                   depth,
+                                 unsigned int                                  mipLevel,
+                                 unsigned int                                  arrayElement,
+                                 vk::VkImageAspectFlagBits             aspect,
+                                 vk::VkImageType                               type,
+                                 void *                                                data)
+{
+       if (layout != vk::VK_IMAGE_LAYOUT_GENERAL && layout != vk::VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL) 
+               TCU_FAIL("Image::uploadFromSurface usage error: this function is not going to change Image layout!");
+
+       de::SharedPtr<Image> stagingResource = copyToLinearImage(queue, allocator, layout, offset, width,
+                                                                                                                        height, depth, mipLevel, arrayElement, aspect, type);
+       const vk::VkOffset3D zeroOffset = {0, 0, 0};
+       stagingResource->readLinear(zeroOffset, width, height, depth, 0, 0, aspect, data);
+}
+
+void Image::readUsingBuffer (vk::VkQueue                               queue,
+                                                        vk::Allocator&                         allocator,
+                                                        vk::VkImageLayout                      layout,
+                                                        vk::VkOffset3D                         offset,
+                                                        int                                            width,
+                                                        int                                            height,
+                                                        int                                            depth,
+                                                        unsigned int                           mipLevel,
+                                                        unsigned int                           arrayElement,
+                                                        vk::VkImageAspectFlagBits      aspect,
+                                                        void *                                         data)
+{
+       if (layout != vk::VK_IMAGE_LAYOUT_GENERAL && layout != vk::VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL) 
+               TCU_FAIL("Image::uploadFromSurface usage error: this function is not going to change Image layout!");
+
+       de::SharedPtr<Buffer> stagingResource;
+
+       bool isCombinedType = isCombinedDepthStencilType(vk::mapVkFormat(m_format).type);
+       vk::VkDeviceSize bufferSize = 0;
+
+       if (!isCombinedType)
+               bufferSize = vk::mapVkFormat(m_format).getPixelSize() * width * height * depth;
+
+       if (isCombinedType)
+       {
+               int pixelSize = 0;
+               switch (m_format)
+               {
+                       case vk::VK_FORMAT_D16_UNORM_S8_UINT:
+                               pixelSize = (aspect == vk::VK_IMAGE_ASPECT_DEPTH_BIT) ? 2 : 1;
+                               break;
+                       case  vk::VK_FORMAT_D32_SFLOAT_S8_UINT:
+                               pixelSize = (aspect == vk::VK_IMAGE_ASPECT_DEPTH_BIT) ? 4 : 1;
+                               break;
+                       case vk::VK_FORMAT_X8_D24_UNORM_PACK32:
+                       case vk::VK_FORMAT_D24_UNORM_S8_UINT:
+                               pixelSize = (aspect == vk::VK_IMAGE_ASPECT_DEPTH_BIT) ? 3 : 1;
+                               break;
+               }
+               bufferSize = pixelSize*width*height*depth;
+       }
+
+       BufferCreateInfo stagingBufferResourceCreateInfo(bufferSize, vk::VK_BUFFER_USAGE_TRANSFER_DST_BIT | vk::VK_BUFFER_USAGE_TRANSFER_SRC_BIT);
+       stagingResource = Buffer::createAndAlloc(m_vk, m_device, stagingBufferResourceCreateInfo, allocator, vk::MemoryRequirement::HostVisible);
+
+       {
+               #pragma message("Get queue family index")
+               CmdPoolCreateInfo copyCmdPoolCreateInfo(0);
+               vk::Unique<vk::VkCommandPool> copyCmdPool(vk::createCommandPool(m_vk, m_device, &copyCmdPoolCreateInfo));
+
+               const vk::VkCommandBufferAllocateInfo cmdBufferAllocateInfo =
+               {
+                       vk::VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,     // VkStructureType                      sType;
+                       DE_NULL,                                                                                        // const void*                          pNext;
+                       *copyCmdPool,                                                                           // VkCommandPool                        commandPool;
+                       vk::VK_COMMAND_BUFFER_LEVEL_PRIMARY,                            // VkCommandBufferLevel         level;
+                       1u,                                                                                                     // deUint32                                     bufferCount;
+               };
+               vk::Unique<vk::VkCommandBuffer> copyCmdBuffer(vk::allocateCommandBuffer(m_vk, m_device, &cmdBufferAllocateInfo));
+
+               CmdBufferBeginInfo beginInfo;
+               VK_CHECK(m_vk.beginCommandBuffer(*copyCmdBuffer, &beginInfo));
+
+               if (layout == vk::VK_IMAGE_LAYOUT_UNDEFINED)
+               {
+                       layout = vk::VK_IMAGE_LAYOUT_GENERAL;
+
+                       vk::VkImageMemoryBarrier barrier;
+                       barrier.sType = vk::VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
+                       barrier.pNext = DE_NULL;
+                       barrier.srcAccessMask = 0;
+                       barrier.dstAccessMask = 0;
+                       barrier.oldLayout = vk::VK_IMAGE_LAYOUT_UNDEFINED;
+                       barrier.newLayout = vk::VK_IMAGE_LAYOUT_GENERAL;
+                       barrier.srcQueueFamilyIndex = vk::VK_QUEUE_FAMILY_IGNORED;
+                       barrier.dstQueueFamilyIndex = vk::VK_QUEUE_FAMILY_IGNORED;
+                       barrier.image = object();
+
+                       barrier.subresourceRange.aspectMask = aspect;
+                       barrier.subresourceRange.baseMipLevel = 0;
+                       barrier.subresourceRange.levelCount = m_levelCount;
+                       barrier.subresourceRange.baseArrayLayer = 0;
+                       barrier.subresourceRange.layerCount = m_layerCount;
+
+                       void* barriers[] = { &barrier };
+
+                       m_vk.cmdPipelineBarrier(*copyCmdBuffer, vk::VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, vk::VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, 
+                               false, DE_LENGTH_OF_ARRAY(barriers), barriers);
+               }
+
+               vk::VkBufferImageCopy region = 
+               {
+                       0, 0, 0,
+                       { aspect, mipLevel, arrayElement, 1 },
+                       offset,
+                       { width, height, depth }
+               };
+
+               m_vk.cmdCopyImageToBuffer(*copyCmdBuffer, object(), layout, stagingResource->object(), 1, &region);
+               VK_CHECK(m_vk.endCommandBuffer(*copyCmdBuffer));
+
+               vk::VkSubmitInfo submitInfo =
+               {
+                       vk::VK_STRUCTURE_TYPE_SUBMIT_INFO,      // VkStructureType                      sType;\r
+                       DE_NULL,                                                        // const void*                          pNext;\r
+                       0,                                                                      // deUint32                                     waitSemaphoreCount;\r
+                       DE_NULL,                                                        // const VkSemaphore*           pWaitSemaphores;\r
+                       1,                                                                      // deUint32                                     commandBufferCount;\r
+                       &copyCmdBuffer.get(),                           // const VkCommandBuffer*       pCommandBuffers;\r
+                       0,                                                                      // deUint32                                     signalSemaphoreCount;\r
+                       DE_NULL                                                         // const VkSemaphore*           pSignalSemaphores;\r
+               };
+               m_vk.queueSubmit(queue, 1, &submitInfo, DE_NULL);
+
+               // TODO: make this less intrusive
+               VK_CHECK(m_vk.queueWaitIdle(queue));
+       }
+
+       char* destPtr = reinterpret_cast<char*>(stagingResource->getBoundMemory().getHostPtr());
+       deMemcpy(data, destPtr, bufferSize);
+}
+
+tcu::ConstPixelBufferAccess Image::readSurfaceLinear (vk::VkOffset3D                           offset,
+                                                                                                         int                                                   width,
+                                                                                                         int                                                   height,
+                                                                                                         int                                                   depth,
+                                                                                                         vk::VkImageAspectFlagBits             aspect,
+                                                                                                         unsigned int                                  mipLevel,
+                                                                                                         unsigned int                                  arrayElement)
+{
+       m_pixelAccessData.resize(width * height * vk::mapVkFormat(m_format).getPixelSize());
+       readLinear(offset, width, height, depth, mipLevel, arrayElement, aspect, m_pixelAccessData.data());
+       return tcu::ConstPixelBufferAccess(vk::mapVkFormat(m_format), width, height, 1, m_pixelAccessData.data());
+}
+
+void Image::readLinear (vk::VkOffset3D                         offset,
+                                               int                                                     width,
+                                               int                                                     height,
+                                               int                                                     depth,
+                                               unsigned int                            mipLevel,
+                                               unsigned int                            arrayElement,
+                                               vk::VkImageAspectFlagBits       aspect,
+                                               void *                                          data)
+{
+       vk::VkImageSubresource imageSubResource = { aspect, mipLevel, arrayElement };
+
+       vk::VkSubresourceLayout imageLayout = {};
+
+       m_vk.getImageSubresourceLayout(m_device, object(), &imageSubResource, &imageLayout);
+
+       const char* srcPtr = reinterpret_cast<const char*>(getBoundMemory().getHostPtr());
+       srcPtr += imageLayout.offset + getPixelOffset(offset, imageLayout.rowPitch, imageLayout.depthPitch, mipLevel, arrayElement);
+
+       MemoryOp::unpack(vk::mapVkFormat(m_format).getPixelSize(), width, height, depth,
+               imageLayout.rowPitch, imageLayout.depthPitch, srcPtr, data);
+}
+
+de::SharedPtr<Image> Image::copyToLinearImage (vk::VkQueue                                     queue,
+                                                                                          vk::Allocator&                               allocator,
+                                                                                          vk::VkImageLayout                    layout,
+                                                                                          vk::VkOffset3D                               offset,
+                                                                                          int                                                  width,
+                                                                                          int                                                  height,
+                                                                                          int                                                  depth,
+                                                                                          unsigned int                                 mipLevel,
+                                                                                          unsigned int                                 arrayElement,
+                                                                                          vk::VkImageAspectFlagBits    aspect,
+                                                                                          vk::VkImageType                              type)
+{
+       de::SharedPtr<Image> stagingResource;
+       {
+               vk::VkExtent3D stagingExtent = {width, height, depth};
+               ImageCreateInfo stagingResourceCreateInfo(
+                       type, m_format, stagingExtent, 1, 1, vk::VK_SAMPLE_COUNT_1_BIT,
+                       vk::VK_IMAGE_TILING_LINEAR, vk::VK_IMAGE_USAGE_TRANSFER_DST_BIT);
+
+               stagingResource = Image::createAndAlloc(m_vk, m_device, stagingResourceCreateInfo, allocator,
+                       vk::MemoryRequirement::HostVisible);
+
+               #pragma message("Get queue family index")
+               CmdPoolCreateInfo copyCmdPoolCreateInfo(0);
+               vk::Unique<vk::VkCommandPool> copyCmdPool(vk::createCommandPool(m_vk, m_device, &copyCmdPoolCreateInfo));
+
+               const vk::VkCommandBufferAllocateInfo cmdBufferAllocateInfo =
+               {
+                       vk::VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,     // VkStructureType                      sType;
+                       DE_NULL,                                                                                        // const void*                          pNext;
+                       *copyCmdPool,                                                                           // VkCommandPool                        commandPool;
+                       vk::VK_COMMAND_BUFFER_LEVEL_PRIMARY,                            // VkCommandBufferLevel         level;
+                       1u,                                                                                                     // deUint32                                     bufferCount;
+               };
+               vk::Unique<vk::VkCommandBuffer> copyCmdBuffer(vk::allocateCommandBuffer(m_vk, m_device, &cmdBufferAllocateInfo));
+
+               CmdBufferBeginInfo beginInfo;
+               VK_CHECK(m_vk.beginCommandBuffer(*copyCmdBuffer, &beginInfo));
+
+               transition2DImage(m_vk, *copyCmdBuffer, stagingResource->object(), aspect, vk::VK_IMAGE_LAYOUT_UNDEFINED, vk::VK_IMAGE_LAYOUT_GENERAL);
+
+               const vk::VkOffset3D zeroOffset = { 0, 0, 0 };
+               vk::VkImageCopy region = { {aspect, mipLevel, arrayElement, 1}, offset, {aspect, 0, 0, 1}, zeroOffset, {width, height, depth} };
+
+               m_vk.cmdCopyImage(*copyCmdBuffer, object(), layout, stagingResource->object(), vk::VK_IMAGE_LAYOUT_GENERAL, 1, &region);
+               VK_CHECK(m_vk.endCommandBuffer(*copyCmdBuffer));
+
+               vk::VkSubmitInfo submitInfo =
+               {
+                       vk::VK_STRUCTURE_TYPE_SUBMIT_INFO,      // VkStructureType                      sType;\r
+                       DE_NULL,                                                        // const void*                          pNext;\r
+                       0,                                                                      // deUint32                                     waitSemaphoreCount;\r
+                       DE_NULL,                                                        // const VkSemaphore*           pWaitSemaphores;\r
+                       1,                                                                      // deUint32                                     commandBufferCount;\r
+                       &copyCmdBuffer.get(),                           // const VkCommandBuffer*       pCommandBuffers;\r
+                       0,                                                                      // deUint32                                     signalSemaphoreCount;\r
+                       DE_NULL                                                         // const VkSemaphore*           pSignalSemaphores;\r
+               };
+               m_vk.queueSubmit(queue, 1, &submitInfo, DE_NULL);
+
+               // TODO: make this less intrusive
+               VK_CHECK(m_vk.queueWaitIdle(queue));
+       }
+       return stagingResource;
+}
+
+void Image::uploadVolume(const tcu::ConstPixelBufferAccess&    access,
+                                                vk::VkQueue                                            queue,
+                                                vk::Allocator&                                                 allocator,
+                                                vk::VkImageLayout                                      layout,
+                                                vk::VkOffset3D                                         offset,
+                                                vk::VkImageAspectFlagBits                      aspect,
+                                                unsigned int                                           mipLevel,
+                                                unsigned int                                           arrayElement)
+{
+       if (aspect == vk::VK_IMAGE_ASPECT_COLOR_BIT)
+       {
+               upload(queue, allocator, layout, offset, access.getWidth(),
+               access.getHeight(), access.getDepth(), mipLevel, arrayElement, aspect, vk::VK_IMAGE_TYPE_3D,
+               access.getDataPtr());
+       }
+       if (aspect == vk::VK_IMAGE_ASPECT_DEPTH_BIT || aspect == vk::VK_IMAGE_ASPECT_STENCIL_BIT)
+       {
+               uploadUsingBuffer(queue, allocator, layout, offset, access.getWidth(),
+               access.getHeight(), access.getDepth(), mipLevel, arrayElement, aspect, access.getDataPtr());
+       }
+}
+
+void Image::uploadSurface (const tcu::ConstPixelBufferAccess&  access,
+                                                  vk::VkQueue                                                  queue,
+                                                  vk::Allocator&                                               allocator,
+                                                  vk::VkImageLayout                                    layout,
+                                                  vk::VkOffset3D                                               offset,
+                                                  vk::VkImageAspectFlagBits                    aspect,
+                                                  unsigned int                                                 mipLevel,
+                                                  unsigned int                                                 arrayElement)
+{
+       if (aspect == vk::VK_IMAGE_ASPECT_COLOR_BIT)
+       {
+               upload(queue, allocator, layout, offset, access.getWidth(),
+                       access.getHeight(), access.getDepth(), mipLevel, arrayElement, aspect, vk::VK_IMAGE_TYPE_2D,
+                       access.getDataPtr());
+       }
+       if (aspect == vk::VK_IMAGE_ASPECT_DEPTH_BIT || aspect == vk::VK_IMAGE_ASPECT_STENCIL_BIT)
+       {
+               uploadUsingBuffer(queue, allocator, layout, offset, access.getWidth(),
+                       access.getHeight(), access.getDepth(), mipLevel, arrayElement, aspect, access.getDataPtr());
+       }
+}
+
+void Image::uploadSurface1D (const tcu::ConstPixelBufferAccess&        access,
+                                                        vk::VkQueue                                            queue,
+                                                        vk::Allocator&                                                 allocator,
+                                                        vk::VkImageLayout                                      layout,
+                                                        vk::VkOffset3D                                         offset,
+                                                        vk::VkImageAspectFlagBits                      aspect,
+                                                        unsigned int                                           mipLevel,
+                                                        unsigned int                                           arrayElement)
+{
+       if (aspect == vk::VK_IMAGE_ASPECT_COLOR_BIT)
+       {
+               upload(queue, allocator, layout, offset, access.getWidth(),
+                       access.getHeight(), access.getDepth(), mipLevel, arrayElement, aspect, vk::VK_IMAGE_TYPE_1D,
+                       access.getDataPtr());
+       }
+       if (aspect == vk::VK_IMAGE_ASPECT_DEPTH_BIT || aspect == vk::VK_IMAGE_ASPECT_STENCIL_BIT)
+       {
+               uploadUsingBuffer(queue, allocator, layout, offset, access.getWidth(),
+                       access.getHeight(), access.getDepth(), mipLevel, arrayElement, aspect, access.getDataPtr());
+       }
+}
+
+void Image::uploadSurfaceLinear (const tcu::ConstPixelBufferAccess&    access,
+                                                                vk::VkOffset3D                                         offset,
+                                                                int                                                            width,
+                                                                int                                                            height,
+                                                                int                                                            depth,
+                                                                vk::VkImageAspectFlagBits                      aspect,
+                                                                unsigned int                                           mipLevel,
+                                                                unsigned int                                           arrayElement)
+{
+       uploadLinear(offset, width, height, depth, mipLevel, arrayElement, aspect, access.getDataPtr());
+}
+
+void Image::upload (vk::VkQueue                                        queue,
+                                       vk::Allocator&                          allocator,
+                                       vk::VkImageLayout                       layout,
+                                       vk::VkOffset3D                          offset,
+                                       int                                                     width,
+                                       int                                                     height,
+                                       int                                                     depth,
+                                       unsigned int                            mipLevel,
+                                       unsigned int                            arrayElement,
+                                       vk::VkImageAspectFlagBits       aspect,
+                                       vk::VkImageType                         type,
+                                       const void *                            data)
+{
+
+       if (layout != vk::VK_IMAGE_LAYOUT_UNDEFINED
+               && layout != vk::VK_IMAGE_LAYOUT_GENERAL
+               && layout != vk::VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL) 
+       {
+               TCU_FAIL("Image::uploadFromRaw usage error: this function is not going to change Image layout!");
+       }
+
+       de::SharedPtr<Image> stagingResource;
+       vk::VkExtent3D extent = {width, height, depth};
+       ImageCreateInfo stagingResourceCreateInfo(
+               type, m_format, extent, 1, 1, vk::VK_SAMPLE_COUNT_1_BIT,
+               vk::VK_IMAGE_TILING_LINEAR, vk::VK_IMAGE_USAGE_TRANSFER_SRC_BIT);
+
+       stagingResource = Image::createAndAlloc(m_vk, m_device, stagingResourceCreateInfo, allocator,
+                                                               vk::MemoryRequirement::HostVisible);
+       
+       const vk::VkOffset3D zeroOffset = { 0, 0, 0 };
+       stagingResource->uploadLinear(zeroOffset, width, height, depth, 0, 0, aspect, data);
+
+       {
+               #pragma message("Get queue family index")
+               CmdPoolCreateInfo copyCmdPoolCreateInfo(0);
+               vk::Unique<vk::VkCommandPool> copyCmdPool(vk::createCommandPool(m_vk, m_device, &copyCmdPoolCreateInfo));
+
+               const vk::VkCommandBufferAllocateInfo cmdBufferAllocateInfo =
+               {
+                       vk::VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,     // VkStructureType                      sType;
+                       DE_NULL,                                                                                        // const void*                          pNext;
+                       *copyCmdPool,                                                                           // VkCommandPool                        commandPool;
+                       vk::VK_COMMAND_BUFFER_LEVEL_PRIMARY,                            // VkCommandBufferLevel         level;
+                       1u,                                                                                                     // deUint32                                     bufferCount;
+               };
+               vk::Unique<vk::VkCommandBuffer> copyCmdBuffer(vk::allocateCommandBuffer(m_vk, m_device, &cmdBufferAllocateInfo));
+
+               CmdBufferBeginInfo beginInfo;
+               VK_CHECK(m_vk.beginCommandBuffer(*copyCmdBuffer, &beginInfo));
+               
+               if (layout == vk::VK_IMAGE_LAYOUT_UNDEFINED)
+               {
+                       layout = vk::VK_IMAGE_LAYOUT_GENERAL;
+
+                       vk::VkImageMemoryBarrier barrier;
+                       barrier.sType = vk::VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
+                       barrier.pNext = DE_NULL;
+                       barrier.srcAccessMask = 0;
+                       barrier.dstAccessMask = 0;
+                       barrier.oldLayout = vk::VK_IMAGE_LAYOUT_UNDEFINED;
+                       barrier.newLayout = vk::VK_IMAGE_LAYOUT_GENERAL;
+                       barrier.srcQueueFamilyIndex = vk::VK_QUEUE_FAMILY_IGNORED;
+                       barrier.dstQueueFamilyIndex = vk::VK_QUEUE_FAMILY_IGNORED;
+                       barrier.image = object();
+
+                       barrier.subresourceRange.aspectMask = aspect;
+                       barrier.subresourceRange.baseMipLevel = 0;
+                       barrier.subresourceRange.levelCount = m_levelCount;
+                       barrier.subresourceRange.baseArrayLayer = 0;
+                       barrier.subresourceRange.layerCount = m_layerCount;
+
+                       void* barriers[] = { &barrier };
+
+                       m_vk.cmdPipelineBarrier(*copyCmdBuffer, vk::VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, vk::VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, false, DE_LENGTH_OF_ARRAY(barriers), barriers);
+               }
+
+               transition2DImage(m_vk, *copyCmdBuffer, stagingResource->object(), aspect, vk::VK_IMAGE_LAYOUT_UNDEFINED, vk::VK_IMAGE_LAYOUT_GENERAL);
+
+               vk::VkImageCopy region = {{aspect, 0, 0, 1},
+                                                                       zeroOffset,
+                                                                       {aspect, mipLevel, arrayElement, 1},
+                                                                       offset,
+                                                                       {width, height, depth}};
+
+               m_vk.cmdCopyImage(*copyCmdBuffer, stagingResource->object(),
+                                                               vk::VK_IMAGE_LAYOUT_GENERAL, object(), layout, 1, &region);
+               VK_CHECK(m_vk.endCommandBuffer(*copyCmdBuffer));
+
+               vk::VkSubmitInfo submitInfo =
+               {
+                       vk::VK_STRUCTURE_TYPE_SUBMIT_INFO,      // VkStructureType                      sType;\r
+                       DE_NULL,                                                        // const void*                          pNext;\r
+                       0,                                                                      // deUint32                                     waitSemaphoreCount;\r
+                       DE_NULL,                                                        // const VkSemaphore*           pWaitSemaphores;\r
+                       1,                                                                      // deUint32                                     commandBufferCount;\r
+                       &copyCmdBuffer.get(),                           // const VkCommandBuffer*       pCommandBuffers;\r
+                       0,                                                                      // deUint32                                     signalSemaphoreCount;\r
+                       DE_NULL                                                         // const VkSemaphore*           pSignalSemaphores;\r
+               };
+               m_vk.queueSubmit(queue, 1, &submitInfo, DE_NULL);
+
+               // TODO: make this less intrusive
+               VK_CHECK(m_vk.queueWaitIdle(queue));
+       }
+}
+
+void Image::uploadUsingBuffer (vk::VkQueue                                     queue,
+                                                          vk::Allocator&                               allocator,
+                                                          vk::VkImageLayout                    layout,
+                                                          vk::VkOffset3D                               offset,
+                                                          int                                                  width,
+                                                          int                                                  height,
+                                                          int                                                  depth,
+                                                          unsigned int                                 mipLevel,
+                                                          unsigned int                                 arrayElement,
+                                                          vk::VkImageAspectFlagBits    aspect,
+                                                          const void *                                 data)
+{
+       if (layout != vk::VK_IMAGE_LAYOUT_UNDEFINED
+               && layout != vk::VK_IMAGE_LAYOUT_GENERAL
+               && layout != vk::VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL) 
+       {
+               TCU_FAIL("Image::uploadFromRaw usage error: this function is not going to change Image layout!");
+       }
+
+       de::SharedPtr<Buffer> stagingResource;
+       bool isCombinedType = isCombinedDepthStencilType(vk::mapVkFormat(m_format).type);
+       vk::VkDeviceSize bufferSize = 0;
+       if (!isCombinedType)
+               bufferSize = vk::mapVkFormat(m_format).getPixelSize() *width*height*depth;
+       if (isCombinedType)
+       {
+               int pixelSize = 0;
+               switch (m_format)
+               {
+                       case vk::VK_FORMAT_D16_UNORM_S8_UINT:
+                               pixelSize = (aspect == vk::VK_IMAGE_ASPECT_DEPTH_BIT) ? 2 : 1;
+                               break;
+                       case  vk::VK_FORMAT_D32_SFLOAT_S8_UINT:
+                               pixelSize = (aspect == vk::VK_IMAGE_ASPECT_DEPTH_BIT) ? 4 : 1;
+                               break;
+                       case vk::VK_FORMAT_X8_D24_UNORM_PACK32:
+                       case vk::VK_FORMAT_D24_UNORM_S8_UINT:
+                               pixelSize = (aspect == vk::VK_IMAGE_ASPECT_DEPTH_BIT) ? 3 : 1;
+                       break;
+               }
+               bufferSize = pixelSize*width*height*depth;
+       }
+       BufferCreateInfo stagingBufferResourceCreateInfo(bufferSize, vk::VK_BUFFER_USAGE_TRANSFER_DST_BIT | vk::VK_BUFFER_USAGE_TRANSFER_SRC_BIT);
+       stagingResource = Buffer::createAndAlloc(m_vk, m_device, stagingBufferResourceCreateInfo, allocator, vk::MemoryRequirement::HostVisible);
+       char* destPtr = reinterpret_cast<char*>(stagingResource->getBoundMemory().getHostPtr());
+       deMemcpy(destPtr, data, bufferSize);
+       vk::flushMappedMemoryRange(m_vk, m_device, stagingResource->getBoundMemory().getMemory(), stagingResource->getBoundMemory().getOffset(), bufferSize);
+       {
+               #pragma message("Get queue family index")
+               CmdPoolCreateInfo copyCmdPoolCreateInfo(0);
+               vk::Unique<vk::VkCommandPool> copyCmdPool(vk::createCommandPool(m_vk, m_device, &copyCmdPoolCreateInfo));
+
+               const vk::VkCommandBufferAllocateInfo cmdBufferAllocateInfo =
+               {
+                       vk::VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,     // VkStructureType                      sType;
+                       DE_NULL,                                                                                        // const void*                          pNext;
+                       *copyCmdPool,                                                                           // VkCommandPool                        commandPool;
+                       vk::VK_COMMAND_BUFFER_LEVEL_PRIMARY,                            // VkCommandBufferLevel         level;
+                       1u,                                                                                                     // deUint32                                     bufferCount;
+               };
+               vk::Unique<vk::VkCommandBuffer> copyCmdBuffer(vk::allocateCommandBuffer(m_vk, m_device, &cmdBufferAllocateInfo));
+
+               CmdBufferBeginInfo beginInfo;
+               VK_CHECK(m_vk.beginCommandBuffer(*copyCmdBuffer, &beginInfo));
+
+               if (layout == vk::VK_IMAGE_LAYOUT_UNDEFINED)
+               {
+                       layout = vk::VK_IMAGE_LAYOUT_GENERAL;
+
+                       vk::VkImageMemoryBarrier barrier;
+                       barrier.sType = vk::VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
+                       barrier.pNext = DE_NULL;
+                       barrier.srcAccessMask = 0;
+                       barrier.dstAccessMask = 0;
+                       barrier.oldLayout = vk::VK_IMAGE_LAYOUT_UNDEFINED;
+                       barrier.newLayout = vk::VK_IMAGE_LAYOUT_GENERAL;
+                       barrier.srcQueueFamilyIndex = vk::VK_QUEUE_FAMILY_IGNORED;
+                       barrier.dstQueueFamilyIndex = vk::VK_QUEUE_FAMILY_IGNORED;
+                       barrier.image = object();
+
+                       barrier.subresourceRange.aspectMask = aspect;
+                       barrier.subresourceRange.baseMipLevel = 0;
+                       barrier.subresourceRange.levelCount = m_levelCount;
+                       barrier.subresourceRange.baseArrayLayer = 0;
+                       barrier.subresourceRange.layerCount = m_layerCount;
+
+                       void* barriers[] = { &barrier };
+
+                       m_vk.cmdPipelineBarrier(*copyCmdBuffer, vk::VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, vk::VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, false, DE_LENGTH_OF_ARRAY(barriers), barriers);
+               }
+
+               vk::VkBufferImageCopy region = {
+                       0, 0, 0,
+                       { aspect, mipLevel, arrayElement, 1 },
+                       offset,
+                       { width, height, depth }
+               };
+
+               m_vk.cmdCopyBufferToImage(*copyCmdBuffer, stagingResource->object(),
+                       object(), layout, 1, &region);
+               VK_CHECK(m_vk.endCommandBuffer(*copyCmdBuffer));
+
+               vk::VkSubmitInfo submitInfo =
+               {
+                       vk::VK_STRUCTURE_TYPE_SUBMIT_INFO,      // VkStructureType                      sType;\r
+                       DE_NULL,                                                        // const void*                          pNext;\r
+                       0,                                                                      // deUint32                                     waitSemaphoreCount;\r
+                       DE_NULL,                                                        // const VkSemaphore*           pWaitSemaphores;\r
+                       1,                                                                      // deUint32                                     commandBufferCount;\r
+                       &copyCmdBuffer.get(),                           // const VkCommandBuffer*       pCommandBuffers;\r
+                       0,                                                                      // deUint32                                     signalSemaphoreCount;\r
+                       DE_NULL                                                         // const VkSemaphore*           pSignalSemaphores;\r
+               };
+               m_vk.queueSubmit(queue, 1, &submitInfo, DE_NULL);
+
+               // TODO: make this less intrusive
+               VK_CHECK(m_vk.queueWaitIdle(queue));
+       }
+}
+
+
+void Image::uploadLinear (vk::VkOffset3D                       offset,
+                                                 int                                           width,
+                                                 int                                           height,
+                                                 int                                           depth,
+                                                 unsigned int                          mipLevel,
+                                                 unsigned int                          arrayElement,
+                                                 vk::VkImageAspectFlagBits     aspect,
+                                                 const void *                          data)
+{
+       vk::VkSubresourceLayout imageLayout;
+
+       vk::VkImageSubresource imageSubResource = {aspect, mipLevel, arrayElement};
+
+       m_vk.getImageSubresourceLayout(m_device, object(), &imageSubResource,
+                                                                                                       &imageLayout);
+
+       char* destPtr = reinterpret_cast<char*>(getBoundMemory().getHostPtr());
+
+       destPtr += imageLayout.offset + getPixelOffset(offset, imageLayout.rowPitch, imageLayout.depthPitch, mipLevel, arrayElement);
+
+       MemoryOp::pack(vk::mapVkFormat(m_format).getPixelSize(), width, height, depth, 
+               imageLayout.rowPitch, imageLayout.depthPitch, data, destPtr);
+}
+
+vk::VkDeviceSize Image::getPixelOffset (vk::VkOffset3D         offset,
+                                                                               vk::VkDeviceSize        rowPitch,
+                                                                               vk::VkDeviceSize        depthPitch,
+                                                                               unsigned int            level,
+                                                                               unsigned int            layer)
+{
+       if (level >= m_levelCount) 
+               TCU_FAIL("mip level too large");
+
+       if (layer >= m_layerCount)
+               TCU_FAIL("array element too large");
+
+       vk::VkDeviceSize mipLevelSizes[32];
+       vk::VkDeviceSize mipLevelRectSizes[32];
+       tcu::IVec3 mipExtend
+       = tcu::IVec3(m_extent.width, m_extent.height, m_extent.depth);
+
+       vk::VkDeviceSize arrayElemSize = 0;
+       for (unsigned int i = 0; i < m_levelCount && (mipExtend[0] > 1 || mipExtend[1] > 1 || mipExtend[2] > 1); ++i)
+       {
+               // Rect size is just a 3D image size;
+               mipLevelSizes[i] = mipExtend[2] * depthPitch;
+
+               arrayElemSize += mipLevelSizes[0];
+
+               mipExtend = tcu::max(mipExtend / 2, tcu::IVec3(1));
+       }
+
+       vk::VkDeviceSize pixelOffset = layer * arrayElemSize;
+       for (size_t i = 0; i < level; ++i) {
+               pixelOffset += mipLevelSizes[i];
+       }
+       pixelOffset += offset.z * mipLevelRectSizes[level];
+       pixelOffset += offset.y * rowPitch;
+       pixelOffset += offset.x;
+
+       return pixelOffset;
+}
+
+void Image::bindMemory (de::MovePtr<vk::Allocation> allocation)
+{
+       DE_ASSERT(allocation);
+       VK_CHECK(m_vk.bindImageMemory(m_device, *m_object, allocation->getMemory(), allocation->getOffset()));
+
+       DE_ASSERT(!m_allocation);
+       m_allocation = allocation;
+}
+
+de::SharedPtr<Image> Image::createAndAlloc(const vk::DeviceInterface&  vk,
+                                                                                  vk::VkDevice                                 device,
+                                                                                  const vk::VkImageCreateInfo& createInfo,
+                                                                                  vk::Allocator&                               allocator,
+                                                                                  vk::MemoryRequirement                memoryRequirement)
+{
+       de::SharedPtr<Image> ret = create(vk, device, createInfo);
+
+       vk::VkMemoryRequirements imageRequirements = vk::getImageMemoryRequirements(vk, device, ret->object());
+       ret->bindMemory(allocator.allocate(imageRequirements, memoryRequirement));
+       return ret;
+}
+
+de::SharedPtr<Image> Image::create(const vk::DeviceInterface&  vk,
+                                                                  vk::VkDevice                                 device,
+                                                                  const vk::VkImageCreateInfo  &createInfo)
+{
+       return de::SharedPtr<Image>(new Image(vk, device, createInfo.format, createInfo.extent,
+                                                               createInfo.mipLevels, createInfo.arrayLayers,
+                                                               vk::createImage(vk, device, &createInfo)));
+}
+
+void transition2DImage (const vk::DeviceInterface&     vk, 
+                                               vk::VkCommandBuffer                             cmdBuffer, 
+                                               vk::VkImage                                     image, 
+                                               vk::VkImageAspectFlags          aspectMask, 
+                                               vk::VkImageLayout                       oldLayout,
+                                               vk::VkImageLayout                       newLayout)
+{
+       vk::VkImageMemoryBarrier barrier; 
+       barrier.sType                                   = vk::VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
+       barrier.pNext                                   = DE_NULL;
+       barrier.srcAccessMask                           = 0;
+       barrier.dstAccessMask                           = 0;
+       barrier.oldLayout                               = oldLayout;
+       barrier.newLayout                               = newLayout;
+       barrier.srcQueueFamilyIndex             = vk::VK_QUEUE_FAMILY_IGNORED;
+       barrier.dstQueueFamilyIndex     = vk::VK_QUEUE_FAMILY_IGNORED;
+       barrier.image                                   = image;
+       barrier.subresourceRange.aspectMask             = aspectMask;
+       barrier.subresourceRange.baseMipLevel   = 0;
+       barrier.subresourceRange.levelCount             = 1;
+       barrier.subresourceRange.baseArrayLayer = 0;
+       barrier.subresourceRange.layerCount             = 1;
+
+       void* barriers[] = { &barrier };
+
+       vk.cmdPipelineBarrier(cmdBuffer, vk::VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, vk::VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, false, DE_LENGTH_OF_ARRAY(barriers), barriers);
+}
+
+
+void initialTransitionColor2DImage (const vk::DeviceInterface &vk, vk::VkCommandBuffer cmdBuffer, vk::VkImage image, vk::VkImageLayout layout)
+{
+       transition2DImage(vk, cmdBuffer, image, vk::VK_IMAGE_ASPECT_COLOR_BIT, vk::VK_IMAGE_LAYOUT_UNDEFINED, layout);
+}
+
+void initialTransitionDepth2DImage (const vk::DeviceInterface &vk, vk::VkCommandBuffer cmdBuffer, vk::VkImage image, vk::VkImageLayout layout)
+{
+       transition2DImage(vk, cmdBuffer, image, vk::VK_IMAGE_ASPECT_DEPTH_BIT, vk::VK_IMAGE_LAYOUT_UNDEFINED, layout);
+}
+
+void initialTransitionStencil2DImage (const vk::DeviceInterface &vk, vk::VkCommandBuffer cmdBuffer, vk::VkImage image, vk::VkImageLayout layout)
+{
+       transition2DImage(vk, cmdBuffer, image, vk::VK_IMAGE_ASPECT_STENCIL_BIT, vk::VK_IMAGE_LAYOUT_UNDEFINED, layout);
+}
+
+void initialTransitionDepthStencil2DImage (const vk::DeviceInterface &vk, vk::VkCommandBuffer cmdBuffer, vk::VkImage image, vk::VkImageLayout layout)
+{
+       transition2DImage(vk, cmdBuffer, image, vk::VK_IMAGE_ASPECT_DEPTH_BIT | vk::VK_IMAGE_ASPECT_STENCIL_BIT, vk::VK_IMAGE_LAYOUT_UNDEFINED, layout);
+}
+
+} //Draw
+} //vkt
diff --git a/external/vulkancts/modules/vulkan/draw/vktDrawImageObjectUtil.hpp b/external/vulkancts/modules/vulkan/draw/vktDrawImageObjectUtil.hpp
new file mode 100644 (file)
index 0000000..d85d014
--- /dev/null
@@ -0,0 +1,290 @@
+#ifndef _VKTDRAWIMAGEOBJECTUTIL_HPP
+#define _VKTDRAWIMAGEOBJECTUTIL_HPP
+/*------------------------------------------------------------------------
+ * Vulkan Conformance Tests
+ * ------------------------
+ *
+ * Copyright (c) 2015 The Khronos Group Inc.
+ * Copyright (c) 2015 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and/or associated documentation files (the
+ * "Materials"), to deal in the Materials without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Materials, and to
+ * permit persons to whom the Materials are furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice(s) and this permission notice shall be included
+ * in all copies or substantial portions of the Materials.
+ *
+ * The Materials are Confidential Information as defined by the
+ * Khronos Membership Agreement until designated non-confidential by Khronos,
+ * at which point this condition clause shall be removed.
+ *
+ * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ *
+ *//*!
+ * \file
+ * \brief Image Object Util
+ *//*--------------------------------------------------------------------*/
+
+#include "vkDefs.hpp"
+#include "vkMemUtil.hpp"
+#include "vkRefUtil.hpp"
+
+#include "deSharedPtr.hpp"
+
+#include "tcuTexture.hpp"
+
+namespace vkt
+{
+namespace Draw
+{
+
+class MemoryOp
+{
+public:
+       static void pack        (int                                    pixelSize,
+                                                int                                    width,
+                                                int                                    height,
+                                                int                                    depth,
+                                                vk::VkDeviceSize               rowPitch,
+                                                vk::VkDeviceSize               depthPitch,
+                                                const void *                   srcBuffer,
+                                                void *                                 destBuffer);
+
+       static void unpack      (int                                    pixelSize,
+                                                int                                    width,
+                                                int                                    height,
+                                                int                                    depth,
+                                                vk::VkDeviceSize               rowPitch,
+                                                vk::VkDeviceSize               depthPitch,
+                                                const void *                   srcBuffer,
+                                                void *                                 destBuffer);
+};
+
+
+class Image
+{
+public:
+       static de::SharedPtr<Image> create                              (const vk::DeviceInterface &vk, vk::VkDevice device, const vk::VkImageCreateInfo &createInfo);
+
+       static de::SharedPtr<Image> createAndAlloc              (const vk::DeviceInterface&                             vk,
+                                                                                                        vk::VkDevice                                                   device,
+                                                                                                        const vk::VkImageCreateInfo&                   createInfo,
+                                                                                                        vk::Allocator&                                                 allocator,
+                                                                                                        vk::MemoryRequirement                                  memoryRequirement = vk::MemoryRequirement::Any);
+
+       tcu::ConstPixelBufferAccess readSurface                 (vk::VkQueue                                                    queue,
+                                                                                                        vk::Allocator&                                                 allocator,
+                                                                                                        vk::VkImageLayout                                              layout,
+                                                                                                        vk::VkOffset3D                                                 offset,
+                                                                                                        int                                                                    width,
+                                                                                                        int                                                                    height,
+                                                                                                        vk::VkImageAspectFlagBits                              aspect,
+                                                                                                        unsigned int                                                   mipLevel = 0,
+                                                                                                        unsigned int                                                   arrayElement = 0);
+
+       tcu::ConstPixelBufferAccess readSurface1D               (vk::VkQueue                                                    queue,
+                                                                                                        vk::Allocator&                                                 allocator,
+                                                                                                        vk::VkImageLayout                                              layout,
+                                                                                                        vk::VkOffset3D                                                 offset,
+                                                                                                        int                                                                    width,
+                                                                                                        vk::VkImageAspectFlagBits                              aspect,
+                                                                                                        unsigned int                                                   mipLevel = 0,
+                                                                                                        unsigned int                                                   arrayElement = 0);
+
+       tcu::ConstPixelBufferAccess readVolume                  (vk::VkQueue                                                    queue,
+                                                                                                        vk::Allocator&                                                 allocator,
+                                                                                                        vk::VkImageLayout                                              layout,
+                                                                                                        vk::VkOffset3D                                                 offset,
+                                                                                                        int                                                                    width,
+                                                                                                        int                                                                    height,
+                                                                                                        int                                                                    depth,
+                                                                                                        vk::VkImageAspectFlagBits                              aspect,
+                                                                                                        unsigned int                                                   mipLevel = 0,
+                                                                                                        unsigned int                                                   arrayElement = 0);
+
+
+       tcu::ConstPixelBufferAccess readSurfaceLinear   (vk::VkOffset3D                                                 offset,
+                                                                                                        int                                                                    width,
+                                                                                                        int                                                                    height,
+                                                                                                        int                                                                    depth,
+                                                                                                        vk::VkImageAspectFlagBits                              aspect,
+                                                                                                        unsigned int                                                   mipLevel = 0,
+                                                                                                        unsigned int                                                   arrayElement = 0);
+
+       void                                            read                            (vk::VkQueue                                                    queue,
+                                                                                                        vk::Allocator&                                                 allocator,
+                                                                                                        vk::VkImageLayout                                              layout,
+                                                                                                        vk::VkOffset3D                                                 offset,
+                                                                                                        int                                                                    width,
+                                                                                                        int                                                                    height,
+                                                                                                        int                                                                    depth,
+                                                                                                        unsigned int                                                   mipLevel,
+                                                                                                        unsigned int                                                   arrayElement,
+                                                                                                        vk::VkImageAspectFlagBits                              aspect,
+                                                                                                        vk::VkImageType                                                type,
+                                                                                                        void *                                                                 data);
+
+       void                                            readUsingBuffer         (vk::VkQueue                                                    queue,
+                                                                                                        vk::Allocator&                                                 allocator,
+                                                                                                        vk::VkImageLayout                                              layout,
+                                                                                                        vk::VkOffset3D                                                 offset,
+                                                                                                        int                                                                    width,
+                                                                                                        int                                                                    height,
+                                                                                                        int                                                                    depth,
+                                                                                                        unsigned int                                                   mipLevel,
+                                                                                                        unsigned int                                                   arrayElement,
+                                                                                                        vk::VkImageAspectFlagBits                              aspect,
+                                                                                                        void *                                                                 data);
+
+       void                                            readLinear                      (vk::VkOffset3D                                                 offset,
+                                                                                                        int                                                                    width,
+                                                                                                        int                                                                    height,
+                                                                                                        int                                                                    depth,
+                                                                                                        unsigned int                                                   mipLevel,
+                                                                                                        unsigned int                                                   arrayElement,
+                                                                                                        vk::VkImageAspectFlagBits                              aspect,
+                                                                                                        void *                                                                 data);
+
+       void                                            uploadVolume            (const tcu::ConstPixelBufferAccess&             access,
+                                                                                                        vk::VkQueue                                                    queue,
+                                                                                                        vk::Allocator&                                                 allocator,
+                                                                                                        vk::VkImageLayout                                              layout,
+                                                                                                        vk::VkOffset3D                                                 offset,
+                                                                                                        vk::VkImageAspectFlagBits                              aspect,
+                                                                                                        unsigned int                                                   mipLevel = 0,
+                                                                                                        unsigned int                                                   arrayElement = 0);
+
+       void                                            uploadSurface            (const tcu::ConstPixelBufferAccess&    access,
+                                                                                                               vk::VkQueue                                                     queue,
+                                                                                                               vk::Allocator&                                          allocator,
+                                                                                                               vk::VkImageLayout                                       layout,
+                                                                                                               vk::VkOffset3D                                          offset,
+                                                                                                               vk::VkImageAspectFlagBits                       aspect,
+                                                                                                               unsigned int                                            mipLevel = 0,
+                                                                                                               unsigned int                                            arrayElement = 0);
+
+       void                                            uploadSurface1D         (const tcu::ConstPixelBufferAccess&             access,
+                                                                                                        vk::VkQueue                                                    queue,
+                                                                                                        vk::Allocator&                                                 allocator,
+                                                                                                        vk::VkImageLayout                                              layout,
+                                                                                                        vk::VkOffset3D                                                 offset,
+                                                                                                        vk::VkImageAspectFlagBits                              aspect,
+                                                                                                        unsigned int                                                   mipLevel = 0,
+                                                                                                        unsigned int                                                   arrayElement = 0);
+
+       void                                            uploadSurfaceLinear     (const tcu::ConstPixelBufferAccess&             access,
+                                                                                                        vk::VkOffset3D                                                 offset,
+                                                                                                        int                                                                    width,
+                                                                                                        int                                                                    height,
+                                                                                                        int                                                                    depth,
+                                                                                                        vk::VkImageAspectFlagBits                              aspect,
+                                                                                                        unsigned int                                                   mipLevel = 0,
+                                                                                                        unsigned int                                                   arrayElement = 0);
+
+       void                                            upload                          (vk::VkQueue                                                    queue,
+                                                                                                        vk::Allocator&                                                 allocator,
+                                                                                                        vk::VkImageLayout                                              layout,
+                                                                                                        vk::VkOffset3D                                                 offset,
+                                                                                                        int                                                                    width,
+                                                                                                        int                                                                    height,
+                                                                                                        int                                                                    depth,
+                                                                                                        unsigned int                                                   mipLevel,
+                                                                                                        unsigned int                                                   arrayElement,
+                                                                                                        vk::VkImageAspectFlagBits                              aspect,
+                                                                                                        vk::VkImageType                                                type,
+                                                                                                        const void *                                                   data);
+
+       void                                            uploadUsingBuffer       (vk::VkQueue                                                    queue,
+                                                                                                        vk::Allocator&                                                 allocator,
+                                                                                                        vk::VkImageLayout                                              layout,
+                                                                                                        vk::VkOffset3D                                                 offset,
+                                                                                                        int                                                                    width,
+                                                                                                        int                                                                    height,
+                                                                                                        int                                                                    depth,
+                                                                                                        unsigned int                                                   mipLevel,
+                                                                                                        unsigned int                                                   arrayElement,
+                                                                                                        vk::VkImageAspectFlagBits                              aspect,
+                                                                                                        const void *                                                   data);
+
+       void                                            uploadLinear            (vk::VkOffset3D                                                 offset,
+                                                                                                        int                                                                    width,
+                                                                                                        int                                                                    height,
+                                                                                                        int                                                                    depth,
+                                                                                                        unsigned int                                                   mipLevel,
+                                                                                                        unsigned int                                                   arrayElement,
+                                                                                                        vk::VkImageAspectFlagBits                              aspect,
+                                                                                                        const void *                                                   data);
+
+       de::SharedPtr<Image>            copyToLinearImage       (vk::VkQueue                                                    queue,
+                                                                                                        vk::Allocator&                                                 allocator,
+                                                                                                        vk::VkImageLayout                                              layout,
+                                                                                                        vk::VkOffset3D                                                 offset,
+                                                                                                        int                                                                    width,
+                                                                                                        int                                                                    height,
+                                                                                                        int                                                                    depth,
+                                                                                                        unsigned int                                                   mipLevel,
+                                                                                                        unsigned int                                                   arrayElement,
+                                                                                                        vk::VkImageAspectFlagBits                              aspect,
+                                                                                                        vk::VkImageType                                                type);
+
+       const vk::VkFormat&                     getFormat                       (void) const                                                                                    { return m_format;              }
+       vk::VkImage                                     object                          (void) const                                                                                    { return *m_object;             }
+       void                                            bindMemory                      (de::MovePtr<vk::Allocation>                    allocation);
+       vk::Allocation                          getBoundMemory          (void) const                                                                                    { return *m_allocation; }
+
+private:
+       vk::VkDeviceSize                        getPixelOffset          (vk::VkOffset3D                                                 offset,
+                                                                                                        vk::VkDeviceSize                                               rowPitch,
+                                                                                                        vk::VkDeviceSize                                               depthPitch,
+                                                                                                        unsigned int                                                   mipLevel,
+                                                                                                        unsigned int                                                   arrayElement);
+
+                                                               Image                           (const vk::DeviceInterface&                             vk,
+                                                                                                        vk::VkDevice                                                   device,
+                                                                                                        vk::VkFormat                                                   format,
+                                                                                                        const vk::VkExtent3D&                                  extend,
+                                                                                                        deUint32                                                               levelCount,
+                                                                                                        deUint32                                                               layerCount,
+                                                                                                        vk::Move<vk::VkImage>                                  object);
+
+       Image                                                                                   (const Image &other);   // Not allowed!
+       Image                                            &operator=                     (const Image &other);   // Not allowed!
+
+       de::MovePtr<vk::Allocation>     m_allocation;    
+       vk::Unique<vk::VkImage>         m_object;
+
+       vk::VkFormat                            m_format;
+       vk::VkExtent3D                          m_extent;
+       deUint32                                        m_levelCount;
+       deUint32                                        m_layerCount;
+
+       std::vector<deUint8>            m_pixelAccessData;
+
+       const vk::DeviceInterface&      m_vk;
+       vk::VkDevice                            m_device;
+};
+
+void transition2DImage (const vk::DeviceInterface &vk, vk::VkCommandBuffer cmdBuffer, vk::VkImage image, vk::VkImageAspectFlags aspectMask, vk::VkImageLayout oldLayout, vk::VkImageLayout newLayout);
+
+void initialTransitionColor2DImage (const vk::DeviceInterface &vk, vk::VkCommandBuffer cmdBuffer, vk::VkImage image, vk::VkImageLayout layout);
+
+void initialTransitionDepth2DImage (const vk::DeviceInterface &vk, vk::VkCommandBuffer cmdBuffer, vk::VkImage image, vk::VkImageLayout layout);
+
+void initialTransitionStencil2DImage (const vk::DeviceInterface &vk, vk::VkCommandBuffer cmdBuffer, vk::VkImage image, vk::VkImageLayout layout);
+
+void initialTransitionDepthStencil2DImage (const vk::DeviceInterface &vk, vk::VkCommandBuffer cmdBuffer, vk::VkImage image, vk::VkImageLayout layout);
+
+} //Draw
+} //vkt
+
+#endif // _VKTDRAWIMAGEOBJECTUTIL_HPP
diff --git a/external/vulkancts/modules/vulkan/draw/vktDrawIndexedTest.cpp b/external/vulkancts/modules/vulkan/draw/vktDrawIndexedTest.cpp
new file mode 100644 (file)
index 0000000..52eddc9
--- /dev/null
@@ -0,0 +1,349 @@
+/*------------------------------------------------------------------------
+* Vulkan Conformance Tests
+* ------------------------
+*
+* Copyright (c) 2015 The Khronos Group Inc.
+* Copyright (c) 2015 Intel Corporation
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
+* copy of this software and/or associated documentation files (the
+* "Materials"), to deal in the Materials without restriction, including
+* without limitation the rights to use, copy, modify, merge, publish,
+* distribute, sublicense, and/or sell copies of the Materials, and to
+* permit persons to whom the Materials are furnished to do so, subject to
+* the following conditions:
+*
+* The above copyright notice(s) and this permission notice shall be included
+* in all copies or substantial portions of the Materials.
+*
+* The Materials are Confidential Information as defined by the
+* Khronos Membership Agreement until designated non-confidential by Khronos,
+* at which point this condition clause shall be removed.
+*
+* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+* MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*
+*//*!
+* \file
+* \brief Draw Indexed Tests
+*//*--------------------------------------------------------------------*/
+
+#include "vktDrawIndexedTest.hpp"
+
+#include "vktTestCaseUtil.hpp"
+#include "vktDrawTestCaseUtil.hpp"
+
+#include "vktDrawBaseClass.hpp"
+
+#include "tcuTestLog.hpp"
+#include "tcuResource.hpp"
+#include "tcuImageCompare.hpp"
+#include "tcuTextureUtil.hpp"
+
+#include "vkDefs.hpp"
+
+namespace vkt
+{
+namespace Draw
+{
+namespace
+{
+class DrawIndexed : public DrawTestsBaseClass
+{
+public:
+                                                               DrawIndexed                             (Context &context, ShaderMap shaders, vk::VkPrimitiveTopology topology);
+       virtual         tcu::TestStatus iterate                                 (void);
+};
+
+class DrawInstancedIndexed : public DrawIndexed
+{
+public:
+                                                               DrawInstancedIndexed    (Context &context, ShaderMap shaders, vk::VkPrimitiveTopology topology);
+       virtual         tcu::TestStatus iterate                                 (void);
+};
+
+DrawIndexed::DrawIndexed (Context &context, ShaderMap shaders, vk::VkPrimitiveTopology topology)
+               : DrawTestsBaseClass(context, shaders[glu::SHADERTYPE_VERTEX], shaders[glu::SHADERTYPE_FRAGMENT])
+{
+       m_topology = topology;
+
+       /*0*/ m_data.push_back(Vec4RGBA(tcu::Vec4(      -0.3f,   0.3f,  1.0f,   1.0f), vec4Blue()));
+       /*1*/ m_data.push_back(Vec4RGBA(tcu::Vec4(      -1.0f,   1.0f,  1.0f,   1.0f), vec4Blue()));
+       /*2*/ m_data.push_back(Vec4RGBA(tcu::Vec4(      -0.3f,  -0.3f,  1.0f,   1.0f), vec4Blue()));
+       /*3*/ m_data.push_back(Vec4RGBA(tcu::Vec4(       1.0f,  -1.0f,  1.0f,   1.0f), vec4Blue()));
+       /*4*/ m_data.push_back(Vec4RGBA(tcu::Vec4(      -0.3f,  -0.3f,  1.0f,   1.0f), vec4Blue()));
+       /*5*/ m_data.push_back(Vec4RGBA(tcu::Vec4(       0.3f,   0.3f,  1.0f,   1.0f), vec4Blue()));
+       /*6*/ m_data.push_back(Vec4RGBA(tcu::Vec4(       0.3f,  -0.3f,  1.0f,   1.0f), vec4Blue()));
+       /*7*/ m_data.push_back(Vec4RGBA(tcu::Vec4(       0.3f,   0.3f,  1.0f,   1.0f), vec4Blue()));
+       /*8*/ m_data.push_back(Vec4RGBA(tcu::Vec4(      -1.0f,   1.0f,  1.0f,   1.0f), vec4Blue()));
+
+       switch (m_topology)
+       {
+               case vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST:
+                       m_indexes.push_back(0);
+                       m_indexes.push_back(0);
+                       m_indexes.push_back(2);
+                       m_indexes.push_back(0);
+                       m_indexes.push_back(6);
+                       m_indexes.push_back(6);
+                       m_indexes.push_back(0);
+                       m_indexes.push_back(7);
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP:
+                       m_indexes.push_back(0);
+                       m_indexes.push_back(0);
+                       m_indexes.push_back(2);
+                       m_indexes.push_back(0);
+                       m_indexes.push_back(6);
+                       m_indexes.push_back(5);
+                       m_indexes.push_back(0);
+                       m_indexes.push_back(7);
+                       break;
+
+               default:
+               ;
+       }
+
+       DrawTestsBaseClass::initialize();
+};
+
+tcu::TestStatus DrawIndexed::iterate (void)
+{
+       tcu::TestLog &log                       = m_context.getTestContext().getLog();
+       const vk::VkQueue queue         = m_context.getUniversalQueue();
+
+       beginRenderPass();
+
+       const vk::VkDeviceSize dataSize = m_indexes.size() * sizeof(deUint32);
+       m_indexBuffer = Buffer::createAndAlloc(m_vk, m_context.getDevice(), BufferCreateInfo(dataSize,
+               vk::VK_BUFFER_USAGE_INDEX_BUFFER_BIT), m_context.getDefaultAllocator(), vk::MemoryRequirement::HostVisible);
+
+       unsigned char *ptr = reinterpret_cast<unsigned char *>(m_indexBuffer->getBoundMemory().getHostPtr());
+       deMemcpy(ptr, &m_indexes[0], dataSize);
+
+       vk::flushMappedMemoryRange(m_vk, m_context.getDevice(),
+                                                          m_vertexBuffer->getBoundMemory().getMemory(),
+                                                          m_vertexBuffer->getBoundMemory().getOffset(),
+                                                          dataSize);
+
+       const vk::VkDeviceSize vertexBufferOffset = 0;
+       const vk::VkBuffer vertexBuffer = m_vertexBuffer->object();
+       const vk::VkBuffer indexBuffer = m_indexBuffer->object();
+       m_vk.cmdBindVertexBuffers(*m_cmdBuffer, 0, 1, &vertexBuffer, &vertexBufferOffset);
+       m_vk.cmdBindIndexBuffer(*m_cmdBuffer, indexBuffer, 0, vk::VK_INDEX_TYPE_UINT32);
+
+       m_vk.cmdBindPipeline(*m_cmdBuffer, vk::VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline);
+
+       m_vk.cmdDrawIndexed(*m_cmdBuffer, 6, 1, 2, 0, 0);
+
+       m_vk.cmdEndRenderPass(*m_cmdBuffer);
+       m_vk.endCommandBuffer(*m_cmdBuffer);
+
+       const vk::VkCommandBuffer cmdBuffer = *m_cmdBuffer;
+
+       vk::VkSubmitInfo submitInfo =
+       {
+               vk::VK_STRUCTURE_TYPE_SUBMIT_INFO,      // VkStructureType                      sType;
+               DE_NULL,                                                        // const void*                          pNext;
+               0,                                                                      // deUint32                                     waitSemaphoreCount;
+               DE_NULL,                                                        // const VkSemaphore*           pWaitSemaphores;
+               1,                                                                      // deUint32                                     commandBufferCount;
+               &m_cmdBuffer.get(),                                     // const VkCommandBuffer*       pCommandBuffers;
+               0,                                                                      // deUint32                                     signalSemaphoreCount;
+               DE_NULL                                                         // const VkSemaphore*           pSignalSemaphores;
+       };
+
+       VK_CHECK(m_vk.queueSubmit(queue, 1, &submitInfo, DE_NULL));
+
+       VK_CHECK(m_vk.queueWaitIdle(queue));
+
+       // Validation
+       tcu::Texture2D referenceFrame(vk::mapVkFormat(m_colorAttachmentFormat), (int)(0.5 + WIDTH), (int)(0.5 + HEIGHT));
+                                                                 referenceFrame.allocLevel(0);
+
+       const deInt32 frameWidth        = referenceFrame.getWidth();
+       const deInt32 frameHeight       = referenceFrame.getHeight();
+
+       tcu::clear(referenceFrame.getLevel(0), tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f));
+
+       for (int y = 0; y < frameHeight; y++)
+       {
+               const float yCoord = (float)(y / (0.5*frameHeight)) - 1.0f;
+
+               for (int x = 0; x < frameWidth; x++)
+               {
+                       const float xCoord = (float)(x / (0.5*frameWidth)) - 1.0f;
+
+                       if ((yCoord >= -0.3f && yCoord <= 0.3f && xCoord >= -0.3f && xCoord <= 0.3f))
+                               referenceFrame.getLevel(0).setPixel(tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f), x, y);
+               }
+       }
+
+       const vk::VkOffset3D zeroOffset = { 0, 0, 0 };
+       const tcu::ConstPixelBufferAccess renderedFrame = m_colorTargetImage->readSurface(queue, m_context.getDefaultAllocator(),
+               vk::VK_IMAGE_LAYOUT_GENERAL, zeroOffset, WIDTH, HEIGHT, vk::VK_IMAGE_ASPECT_COLOR_BIT);
+
+       qpTestResult res = QP_TEST_RESULT_PASS;
+
+       if (!tcu::fuzzyCompare(log, "Result", "Image comparison result",
+               referenceFrame.getLevel(0), renderedFrame, 0.05f,
+               tcu::COMPARE_LOG_RESULT)) {
+               res = QP_TEST_RESULT_FAIL;
+       }
+
+       return tcu::TestStatus(res, qpGetTestResultName(res));
+};
+
+DrawInstancedIndexed::DrawInstancedIndexed (Context &context, ShaderMap shaders, vk::VkPrimitiveTopology topology)
+       : DrawIndexed   (context, shaders, topology)
+{
+}
+
+tcu::TestStatus DrawInstancedIndexed::iterate (void)
+{
+       tcu::TestLog &log               = m_context.getTestContext().getLog();
+       const vk::VkQueue queue = m_context.getUniversalQueue();
+
+       beginRenderPass();
+
+       const vk::VkDeviceSize dataSize = m_indexes.size() * sizeof(deUint32);
+       m_indexBuffer = Buffer::createAndAlloc(m_vk, m_context.getDevice(), BufferCreateInfo(dataSize, vk::VK_BUFFER_USAGE_INDEX_BUFFER_BIT),
+                                                  m_context.getDefaultAllocator(), vk::MemoryRequirement::HostVisible);
+
+       unsigned char *ptr = reinterpret_cast<unsigned char *>(m_indexBuffer->getBoundMemory().getHostPtr());
+       deMemcpy(ptr, &m_indexes[0], dataSize);
+
+       vk::flushMappedMemoryRange(m_vk, m_context.getDevice(),
+                                                          m_vertexBuffer->getBoundMemory().getMemory(),
+                                                          m_vertexBuffer->getBoundMemory().getOffset(),
+                                                          dataSize);
+
+       const vk::VkDeviceSize vertexBufferOffset = 0;
+       const vk::VkBuffer vertexBuffer = m_vertexBuffer->object();
+       const vk::VkBuffer indexBuffer = m_indexBuffer->object();
+       m_vk.cmdBindVertexBuffers(*m_cmdBuffer, 0, 1, &vertexBuffer, &vertexBufferOffset);
+       m_vk.cmdBindIndexBuffer(*m_cmdBuffer, indexBuffer, 0, vk::VK_INDEX_TYPE_UINT32);
+
+       m_vk.cmdBindPipeline(*m_cmdBuffer, vk::VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline);
+
+       switch (m_topology)
+       {
+               case vk::VK_PRIMITIVE_TOPOLOGY_POINT_LIST:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_LINE_LIST:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_LINE_STRIP:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST:
+                       m_vk.cmdDrawIndexed(*m_cmdBuffer, 6, 4, 2, 0, 2);
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP:
+                       m_vk.cmdDrawIndexed(*m_cmdBuffer, 4, 4, 2, 0, 2);
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_PATCH_LIST:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_LAST:
+                       break;
+               default:
+                       break;
+       }
+
+       m_vk.cmdEndRenderPass(*m_cmdBuffer);
+       m_vk.endCommandBuffer(*m_cmdBuffer);
+
+       vk::VkSubmitInfo submitInfo =
+       {
+               vk::VK_STRUCTURE_TYPE_SUBMIT_INFO,      // VkStructureType                      sType;
+               DE_NULL,                                                        // const void*                          pNext;
+               0,                                                                      // deUint32                                     waitSemaphoreCount;
+               DE_NULL,                                                        // const VkSemaphore*           pWaitSemaphores;
+               1,                                                                      // deUint32                                     commandBufferCount;
+               &m_cmdBuffer.get(),                                     // const VkCommandBuffer*       pCommandBuffers;
+               0,                                                                      // deUint32                                     signalSemaphoreCount;
+               DE_NULL                                                         // const VkSemaphore*           pSignalSemaphores;
+       };
+       VK_CHECK(m_vk.queueSubmit(queue, 1, &submitInfo, DE_NULL));
+
+       VK_CHECK(m_vk.queueWaitIdle(queue));
+
+       // Validation
+       VK_CHECK(m_vk.queueWaitIdle(queue));
+
+       tcu::Texture2D referenceFrame(vk::mapVkFormat(m_colorAttachmentFormat), (int)(0.5 + WIDTH), (int)(0.5 + HEIGHT));
+       referenceFrame.allocLevel(0);
+
+       const deInt32 frameWidth = referenceFrame.getWidth();
+       const deInt32 frameHeight = referenceFrame.getHeight();
+
+       tcu::clear(referenceFrame.getLevel(0), tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f));
+
+       for (int y = 0; y < frameHeight; y++)
+       {
+               const float yCoord = (float)(y / (0.5*frameHeight)) - 1.0f;
+
+               for (int x = 0; x < frameWidth; x++)
+               {
+                       const float xCoord = (float)(x / (0.5*frameWidth)) - 1.0f;
+
+                       if ((yCoord >= -0.6f && yCoord <= 0.3f && xCoord >= -0.3f && xCoord <= 0.6f))
+                               referenceFrame.getLevel(0).setPixel(tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f), x, y);
+               }
+       }
+
+       const vk::VkOffset3D zeroOffset = { 0, 0, 0 };
+       const tcu::ConstPixelBufferAccess renderedFrame = m_colorTargetImage->readSurface(queue, m_context.getDefaultAllocator(),
+               vk::VK_IMAGE_LAYOUT_GENERAL, zeroOffset, WIDTH, HEIGHT, vk::VK_IMAGE_ASPECT_COLOR_BIT);
+
+       qpTestResult res = QP_TEST_RESULT_PASS;
+
+       if (!tcu::fuzzyCompare(log, "Result", "Image comparison result",
+               referenceFrame.getLevel(0), renderedFrame, 0.05f,
+               tcu::COMPARE_LOG_RESULT)) {
+               res = QP_TEST_RESULT_FAIL;
+       }
+
+       return tcu::TestStatus(res, qpGetTestResultName(res));
+
+}
+
+}      // anonymous
+
+DrawIndexedTests::DrawIndexedTests (tcu::TestContext &testCtx)
+       : TestCaseGroup (testCtx, "indexed_draw", "drawing indexed geometry")
+{
+       /* Left blank on purpose */
+}
+
+DrawIndexedTests::~DrawIndexedTests (void) {}
+
+void DrawIndexedTests::init (void)
+{
+       ShaderMap shaderPaths;
+       shaderPaths[glu::SHADERTYPE_VERTEX] = "vulkan/draw/VertexFetch.vert";
+       shaderPaths[glu::SHADERTYPE_FRAGMENT] = "vulkan/draw/VertexFetch.frag";
+       addChild(new InstanceFactory<DrawIndexed>(m_testCtx, "draw_indexed_triangle_list", "Draws indexed triangle list", shaderPaths, vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST));
+       addChild(new InstanceFactory<DrawIndexed>(m_testCtx, "draw_indexed_triangle_strip", "Draws indexed triangle strip", shaderPaths, vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP));
+
+       shaderPaths[glu::SHADERTYPE_VERTEX] = "vulkan/draw/VertexFetchWithInstance.vert";
+       shaderPaths[glu::SHADERTYPE_FRAGMENT] = "vulkan/draw/VertexFetch.frag";
+       addChild(new InstanceFactory<DrawIndexed>(m_testCtx, "draw_instanced_indexed_triangle_list", "Draws indexed triangle list", shaderPaths, vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST));
+       addChild(new InstanceFactory<DrawIndexed>(m_testCtx, "draw_instanced_indexed_triangle_strip", "Draws indexed triangle strip", shaderPaths, vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP));
+}
+
+}      // DrawTests
+}      // vkt
\ No newline at end of file
diff --git a/external/vulkancts/modules/vulkan/draw/vktDrawIndexedTest.hpp b/external/vulkancts/modules/vulkan/draw/vktDrawIndexedTest.hpp
new file mode 100644 (file)
index 0000000..ce00305
--- /dev/null
@@ -0,0 +1,59 @@
+#ifndef _VKTDRAWINDEXEDTESTS_HPP
+#define _VKTDRAWINDEXEDTESTS_HPP
+/*------------------------------------------------------------------------
+* Vulkan Conformance Tests
+* ------------------------
+*
+* Copyright (c) 2015 The Khronos Group Inc.
+* Copyright (c) 2015 Intel Corporation
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
+* copy of this software and/or associated documentation files (the
+* "Materials"), to deal in the Materials without restriction, including
+* without limitation the rights to use, copy, modify, merge, publish,
+* distribute, sublicense, and/or sell copies of the Materials, and to
+* permit persons to whom the Materials are furnished to do so, subject to
+* the following conditions:
+*
+* The above copyright notice(s) and this permission notice shall be included
+* in all copies or substantial portions of the Materials.
+*
+* The Materials are Confidential Information as defined by the
+* Khronos Membership Agreement until designated non-confidential by Khronos,
+* at which point this condition clause shall be removed.
+*
+* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+* MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*
+*//*!
+* \file
+* \brief Draw Indexed Test
+*//*--------------------------------------------------------------------*/
+
+#include "vktTestCase.hpp"
+
+namespace vkt
+{
+namespace Draw
+{
+class DrawIndexedTests : public tcu::TestCaseGroup
+{
+public:
+                                       DrawIndexedTests                (tcu::TestContext &testCtx);
+                                       ~DrawIndexedTests               (void);
+       void                    init                                    (void);
+
+private:
+                                       DrawIndexedTests                (const DrawIndexedTests &other);
+                                       DrawIndexedTests&               operator=(const DrawIndexedTests &other);
+
+};
+} //Draw
+} //vkt
+
+#endif // #define _VKTDRAWINDEXEDTESTS_HPP
diff --git a/external/vulkancts/modules/vulkan/draw/vktDrawIndirectTest.cpp b/external/vulkancts/modules/vulkan/draw/vktDrawIndirectTest.cpp
new file mode 100644 (file)
index 0000000..1d5f579
--- /dev/null
@@ -0,0 +1,494 @@
+/*------------------------------------------------------------------------
+* Vulkan Conformance Tests
+* ------------------------
+*
+* Copyright (c) 2015 The Khronos Group Inc.
+* Copyright (c) 2015 Intel Corporation
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
+* copy of this software and/or associated documentation files (the
+* "Materials"), to deal in the Materials without restriction, including
+* without limitation the rights to use, copy, modify, merge, publish,
+* distribute, sublicense, and/or sell copies of the Materials, and to
+* permit persons to whom the Materials are furnished to do so, subject to
+* the following conditions:
+*
+* The above copyright notice(s) and this permission notice shall be included
+* in all copies or substantial portions of the Materials.
+*
+* The Materials are Confidential Information as defined by the
+* Khronos Membership Agreement until designated non-confidential by Khronos,
+* at which point this condition clause shall be removed.
+*
+* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+* MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*
+*//*!
+* \file
+* \brief Draw Indirect Test
+*//*--------------------------------------------------------------------*/
+
+#include "vktDrawIndirectTest.hpp"
+
+#include "vktTestCaseUtil.hpp"
+#include "vktDrawTestCaseUtil.hpp"
+
+#include "vktDrawBaseClass.hpp"
+
+#include "tcuTestLog.hpp"
+#include "tcuResource.hpp"
+#include "tcuImageCompare.hpp"
+#include "tcuTextureUtil.hpp"
+
+#include "vkDefs.hpp"
+
+namespace vkt
+{
+namespace Draw
+{
+namespace
+{
+struct JunkData
+{
+       deUint16 x16 = 16;
+       deUint32 x32 = 32;
+       std::string str = "junk_data";
+};
+
+class IndirectDraw : public DrawTestsBaseClass
+{
+public:
+                                                               IndirectDraw    (Context &context, ShaderMap shaders, vk::VkPrimitiveTopology topology);
+       virtual         tcu::TestStatus iterate                 (void);
+private:
+       de::SharedPtr<Buffer>                                   m_IndirectBuffer;
+       std::vector<vk::VkDrawIndirectCommand>  m_indirectDrawCmd;
+       vk::VkDeviceSize                                                m_offsetInBuffer;
+       deUint32                                                                m_strideInBuffer;
+       deUint32                                                                m_drawCount;
+       JunkData                                                                m_junkData;
+};
+
+class IndirectDrawInstanced : public IndirectDraw
+{
+public:
+                                                               IndirectDrawInstanced   (Context &context, ShaderMap shaders, vk::VkPrimitiveTopology topology);
+       virtual tcu::TestStatus         iterate                                 (void);
+private:
+       de::SharedPtr<Buffer>                                   m_IndirectBuffer;
+       std::vector<vk::VkDrawIndirectCommand>  m_indirectDrawCmd;
+       vk::VkDeviceSize                                                m_offsetInBuffer;
+       deUint32                                                                m_strideInBuffer;
+       deUint32                                                                m_drawCount;
+       JunkData                                                                m_junkData;
+};
+
+IndirectDraw::IndirectDraw (Context &context, ShaderMap shaders, vk::VkPrimitiveTopology topology)
+               : DrawTestsBaseClass(context, shaders[glu::SHADERTYPE_VERTEX], shaders[glu::SHADERTYPE_FRAGMENT])
+       {
+               m_topology = topology;
+
+               switch (m_topology)
+               {
+                       case vk::VK_PRIMITIVE_TOPOLOGY_POINT_LIST:
+                               break;
+                       case vk::VK_PRIMITIVE_TOPOLOGY_LINE_LIST:
+                               break;
+                       case vk::VK_PRIMITIVE_TOPOLOGY_LINE_STRIP:
+                               break;
+                       case vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST:
+                               m_data.push_back(Vec4RGBA(tcu::Vec4(     1.0f,  -1.0f,  1.0f,   1.0f), vec4Blue()));
+                               m_data.push_back(Vec4RGBA(tcu::Vec4(    -1.0f,   1.0f,  1.0f,   1.0f), vec4Blue()));
+                               m_data.push_back(Vec4RGBA(tcu::Vec4(    -0.3f,  -0.3f,  1.0f,   1.0f), vec4Blue()));
+                               m_data.push_back(Vec4RGBA(tcu::Vec4(    -0.3f,   0.3f,  1.0f,   1.0f), vec4Blue()));
+                               m_data.push_back(Vec4RGBA(tcu::Vec4(     0.3f,  -0.3f,  1.0f,   1.0f), vec4Blue()));
+                               m_data.push_back(Vec4RGBA(tcu::Vec4(     0.3f,  -0.3f,  1.0f,   1.0f), vec4Blue()));
+                               m_data.push_back(Vec4RGBA(tcu::Vec4(     0.3f,   0.3f,  1.0f,   1.0f), vec4Blue()));
+                               m_data.push_back(Vec4RGBA(tcu::Vec4(    -0.3f,   0.3f,  1.0f,   1.0f), vec4Blue()));
+                               m_data.push_back(Vec4RGBA(tcu::Vec4(    -1.0f,   1.0f,  1.0f,   1.0f), vec4Blue()));
+                               break;
+                       case vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP:
+                               m_data.push_back(Vec4RGBA(tcu::Vec4( 1.0f,      -1.0f,   1.0f,   1.0f),  vec4Blue()));
+                               m_data.push_back(Vec4RGBA(tcu::Vec4(-1.0f,       1.0f,   1.0f,   1.0f),  vec4Blue()));
+                               m_data.push_back(Vec4RGBA(tcu::Vec4(-0.3f,       0.0f,   1.0f,   1.0f),  vec4Blue()));
+                               m_data.push_back(Vec4RGBA(tcu::Vec4( 0.3f,       0.0f,   1.0f,   1.0f),  vec4Blue()));
+                               m_data.push_back(Vec4RGBA(tcu::Vec4(-0.3f,      -0.3f,   1.0f,   1.0f),  vec4Blue()));
+                               m_data.push_back(Vec4RGBA(tcu::Vec4( 0.3f,      -0.3f,   1.0f,   1.0f),  vec4Blue()));
+                               m_data.push_back(Vec4RGBA(tcu::Vec4(-0.3f,       0.3f,   1.0f,   1.0f),  vec4Blue()));
+                               m_data.push_back(Vec4RGBA(tcu::Vec4( 0.3f,       0.3f,   1.0f,   1.0f),  vec4Blue()));
+                               m_data.push_back(Vec4RGBA(tcu::Vec4(-0.3f,       0.0f,   1.0f,   1.0f),  vec4Blue()));
+                               m_data.push_back(Vec4RGBA(tcu::Vec4( 0.3f,       0.0f,   1.0f,   1.0f),  vec4Blue()));
+                               m_data.push_back(Vec4RGBA(tcu::Vec4(-1.0f,       1.0f,   1.0f,   1.0f),  vec4Blue()));
+                               break;
+                       case vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN:
+                               break;
+                       case vk::VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY:
+                               break;
+                       case vk::VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY:
+                               break;
+                       case vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY:
+                               break;
+                       case vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY:
+                               break;
+                       case vk::VK_PRIMITIVE_TOPOLOGY_PATCH_LIST:
+                               break;
+                       case vk::VK_PRIMITIVE_TOPOLOGY_LAST:
+                               break;
+                       default:
+                               break;
+               }
+
+               DrawTestsBaseClass::initialize();
+       }
+
+tcu::TestStatus IndirectDraw::iterate (void)
+{
+       tcu::TestLog &log = m_context.getTestContext().getLog();
+       const vk::VkQueue queue = m_context.getUniversalQueue();
+
+       switch (m_topology)
+       {
+               case vk::VK_PRIMITIVE_TOPOLOGY_POINT_LIST:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_LINE_LIST:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_LINE_STRIP:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST:
+                       m_indirectDrawCmd.push_back(
+                       {
+                               3,              //vertexCount
+                               1,              //instanceCount
+                               2,              //firstVertex
+                               0               //firstInstance
+                       });
+
+                       // and this is junk data for stride
+                       m_indirectDrawCmd.push_back({ -4, -2, -11, -9 });
+
+                       m_indirectDrawCmd.push_back(
+                       {
+                               3,              //vertexCount
+                               1,              //instanceCount
+                               5,              //firstVertex
+                               0               //firstInstance
+                       });
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP:
+                       m_indirectDrawCmd.push_back(
+                       {
+                               4,              //vertexCount
+                               1,              //instanceCount
+                               2,              //firstVertex
+                               0               //firstInstance
+                       });
+
+                       // and this is junk data for stride
+                       m_indirectDrawCmd.push_back({ -4, -2, -11, -9 });
+
+                       m_indirectDrawCmd.push_back(
+                       {
+                               4,              //vertexCount
+                               1,              //instanceCount
+                               6,              //firstVertex
+                               0               //firstInstance
+                       });
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_PATCH_LIST:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_LAST:
+                       break;
+               default:
+                       break;
+       }
+
+       m_strideInBuffer        = 2 * sizeof(m_indirectDrawCmd[0]);
+       m_drawCount                     = 2;
+       m_offsetInBuffer        = sizeof(m_junkData);
+       
+       beginRenderPass();
+
+       const vk::VkDeviceSize vertexBufferOffset       = 0;
+       const vk::VkBuffer vertexBuffer                         = m_vertexBuffer->object();
+       m_vk.cmdBindVertexBuffers(*m_cmdBuffer, 0, 1, &vertexBuffer, &vertexBufferOffset);
+
+       const vk::VkDeviceSize dataSize = m_indirectDrawCmd.size()*sizeof(m_indirectDrawCmd[0]);
+       m_IndirectBuffer = Buffer::createAndAlloc(m_vk, m_context.getDevice(), BufferCreateInfo(dataSize,
+               vk::VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT), m_context.getDefaultAllocator(), vk::MemoryRequirement::HostVisible);
+
+       unsigned char *ptr = reinterpret_cast<unsigned char *>(m_IndirectBuffer->getBoundMemory().getHostPtr());
+       deMemcpy(ptr, &m_junkData, m_offsetInBuffer);
+       deMemcpy((ptr+m_offsetInBuffer), &m_indirectDrawCmd[0], dataSize);
+
+       vk::flushMappedMemoryRange(m_vk,
+                                                          m_context.getDevice(),
+                                                          m_vertexBuffer->getBoundMemory().getMemory(),
+                                                          m_vertexBuffer->getBoundMemory().getOffset(),
+                                                          dataSize);
+
+       m_vk.cmdBindPipeline(*m_cmdBuffer, vk::VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline);
+       
+       m_vk.cmdDrawIndirect(*m_cmdBuffer, m_IndirectBuffer->object(), m_offsetInBuffer, m_drawCount, m_strideInBuffer);
+
+       m_vk.cmdEndRenderPass(*m_cmdBuffer);
+       m_vk.endCommandBuffer(*m_cmdBuffer);
+
+       vk::VkSubmitInfo submitInfo =
+       {
+               vk::VK_STRUCTURE_TYPE_SUBMIT_INFO,      // VkStructureType                      sType;
+               DE_NULL,                                                        // const void*                          pNext;
+               0,                                                                      // deUint32                                     waitSemaphoreCount;
+               DE_NULL,                                                        // const VkSemaphore*           pWaitSemaphores;
+               1,                                                                      // deUint32                                     commandBufferCount;
+               &m_cmdBuffer.get(),                                     // const VkCommandBuffer*       pCommandBuffers;
+               0,                                                                      // deUint32                                     signalSemaphoreCount;
+               DE_NULL                                                         // const VkSemaphore*           pSignalSemaphores;
+       };
+       VK_CHECK(m_vk.queueSubmit(queue, 1, &submitInfo, DE_NULL));
+       
+       VK_CHECK(m_vk.queueWaitIdle(queue));
+
+       // Validation
+       tcu::Texture2D referenceFrame(vk::mapVkFormat(m_colorAttachmentFormat), (int)(0.5 + WIDTH), (int)(0.5 + HEIGHT));
+       referenceFrame.allocLevel(0);
+
+       const deInt32 frameWidth        = referenceFrame.getWidth();
+       const deInt32 frameHeight       = referenceFrame.getHeight();
+
+       tcu::clear(referenceFrame.getLevel(0), tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f));
+
+       for (int y = 0; y < frameHeight; y++)
+       {
+               const float yCoord = (float)(y / (0.5*frameHeight)) - 1.0f;
+
+               for (int x = 0; x < frameWidth; x++)
+               {
+                       const float xCoord = (float)(x / (0.5*frameWidth)) - 1.0f;
+
+                       if ((yCoord >= -0.3f && yCoord <= 0.3f && xCoord >= -0.3f && xCoord <= 0.3f))                                   
+                               referenceFrame.getLevel(0).setPixel(tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f), x, y);
+               }
+       }
+
+       const vk::VkOffset3D zeroOffset                                 = { 0, 0, 0 };
+       const tcu::ConstPixelBufferAccess renderedFrame = m_colorTargetImage->readSurface(queue, m_context.getDefaultAllocator(),
+               vk::VK_IMAGE_LAYOUT_GENERAL, zeroOffset, WIDTH, HEIGHT, vk::VK_IMAGE_ASPECT_COLOR_BIT);
+
+       qpTestResult res = QP_TEST_RESULT_PASS;
+
+       if (!tcu::fuzzyCompare(log, "Result", "Image comparison result",
+               referenceFrame.getLevel(0), renderedFrame, 0.05f,
+               tcu::COMPARE_LOG_RESULT)) {
+               res = QP_TEST_RESULT_FAIL;
+       }
+
+       return tcu::TestStatus(res, qpGetTestResultName(res));
+
+}
+
+IndirectDrawInstanced::IndirectDrawInstanced (Context &context, ShaderMap shaders, vk::VkPrimitiveTopology topology)
+               : IndirectDraw  (context, shaders, topology)
+{
+}
+
+tcu::TestStatus IndirectDrawInstanced::iterate (void)
+{
+       tcu::TestLog &log = m_context.getTestContext().getLog();
+       const vk::VkQueue queue = m_context.getUniversalQueue();
+
+       switch (m_topology)
+       {
+               case vk::VK_PRIMITIVE_TOPOLOGY_POINT_LIST:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_LINE_LIST:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_LINE_STRIP:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST:
+                       m_indirectDrawCmd.push_back(
+                       {
+                               3,              //vertexCount
+                               4,              //instanceCount
+                               2,              //firstVertex
+                               2               //firstInstance
+                       });
+
+                       // and this is junk data for stride
+                       m_indirectDrawCmd.push_back({ -4, -2, -11, -9 });
+
+                       m_indirectDrawCmd.push_back(
+                       {
+                               3,              //vertexCount
+                               4,              //instanceCount
+                               5,              //firstVertex
+                               2               //firstInstance
+                       });
+
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP:
+                       m_indirectDrawCmd.push_back(
+                       {
+                               4,              //vertexCount
+                               4,              //instanceCount
+                               2,              //firstVertex
+                               2               //firstInstance
+                       });
+
+                       // and this is junk data for stride
+                       m_indirectDrawCmd.push_back({ -4, -2, -11, -9 });
+
+                       m_indirectDrawCmd.push_back(
+                       {
+                               4,              //vertexCount
+                               4,              //instanceCount
+                               6,              //firstVertex
+                               2               //firstInstance
+                       });
+
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_PATCH_LIST:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_LAST:
+                       break;
+               default:
+                       break;
+       }
+
+       m_strideInBuffer        = 2 * sizeof(m_indirectDrawCmd[0]);
+       m_drawCount                     = 2;
+       m_offsetInBuffer        = sizeof(m_junkData);
+
+       beginRenderPass();
+
+       const vk::VkDeviceSize vertexBufferOffset = 0;
+       const vk::VkBuffer vertexBuffer = m_vertexBuffer->object();
+       m_vk.cmdBindVertexBuffers(*m_cmdBuffer, 0, 1, &vertexBuffer, &vertexBufferOffset);
+
+       const vk::VkDeviceSize dataSize = m_indirectDrawCmd.size()*sizeof(m_indirectDrawCmd[0]);
+       m_IndirectBuffer = Buffer::createAndAlloc(m_vk, m_context.getDevice(), BufferCreateInfo(dataSize,
+               vk::VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT), m_context.getDefaultAllocator(), vk::MemoryRequirement::HostVisible);
+
+       unsigned char *ptr = reinterpret_cast<unsigned char *>(m_IndirectBuffer->getBoundMemory().getHostPtr());
+       deMemcpy(ptr, &m_junkData, m_offsetInBuffer);
+       deMemcpy((ptr + m_offsetInBuffer), &m_indirectDrawCmd[0], dataSize);
+
+       vk::flushMappedMemoryRange(m_vk,
+                                                          m_context.getDevice(),
+                                                          m_vertexBuffer->getBoundMemory().getMemory(),
+                                                          m_vertexBuffer->getBoundMemory().getOffset(),
+                                                          dataSize);
+
+       m_vk.cmdBindPipeline(*m_cmdBuffer, vk::VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline);
+       
+       m_vk.cmdDrawIndirect(*m_cmdBuffer, m_IndirectBuffer->object(), m_offsetInBuffer, m_drawCount, m_strideInBuffer);
+
+       m_vk.cmdEndRenderPass(*m_cmdBuffer);
+       m_vk.endCommandBuffer(*m_cmdBuffer);
+
+       vk::VkSubmitInfo submitInfo =
+       {
+               vk::VK_STRUCTURE_TYPE_SUBMIT_INFO,      // VkStructureType                      sType;
+               DE_NULL,                                                        // const void*                          pNext;
+               0,                                                                      // deUint32                                     waitSemaphoreCount;
+               DE_NULL,                                                        // const VkSemaphore*           pWaitSemaphores;
+               1,                                                                      // deUint32                                     commandBufferCount;
+               &m_cmdBuffer.get(),                                     // const VkCommandBuffer*       pCommandBuffers;
+               0,                                                                      // deUint32                                     signalSemaphoreCount;
+               DE_NULL                                                         // const VkSemaphore*           pSignalSemaphores;
+       };
+       VK_CHECK(m_vk.queueSubmit(queue, 1, &submitInfo, DE_NULL));
+       
+       VK_CHECK(m_vk.queueWaitIdle(queue));
+
+       // Validation
+       VK_CHECK(m_vk.queueWaitIdle(queue));
+
+       tcu::Texture2D referenceFrame(vk::mapVkFormat(m_colorAttachmentFormat), (int)(0.5 + WIDTH), (int)(0.5 + HEIGHT));
+       referenceFrame.allocLevel(0);
+
+       const deInt32 frameWidth        = referenceFrame.getWidth();
+       const deInt32 frameHeight       = referenceFrame.getHeight();
+
+       tcu::clear(referenceFrame.getLevel(0), tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f));
+
+       for (int y = 0; y < frameHeight; y++)
+       {
+               const float yCoord = (float)(y / (0.5*frameHeight)) - 1.0f;
+
+               for (int x = 0; x < frameWidth; x++)
+               {
+                       const float xCoord = (float)(x / (0.5*frameWidth)) - 1.0f;
+
+                       if ((yCoord >= -0.6f && yCoord <= 0.3f && xCoord >= -0.3f && xCoord <= 0.6f))
+                               referenceFrame.getLevel(0).setPixel(tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f), x, y);
+               }
+       }
+
+       const vk::VkOffset3D zeroOffset = { 0, 0, 0 };
+       const tcu::ConstPixelBufferAccess renderedFrame = m_colorTargetImage->readSurface(queue, m_context.getDefaultAllocator(),
+               vk::VK_IMAGE_LAYOUT_GENERAL, zeroOffset, WIDTH, HEIGHT, vk::VK_IMAGE_ASPECT_COLOR_BIT);
+
+       qpTestResult res = QP_TEST_RESULT_PASS;
+
+       if (!tcu::fuzzyCompare(log, "Result", "Image comparison result",
+               referenceFrame.getLevel(0), renderedFrame, 0.05f,
+               tcu::COMPARE_LOG_RESULT)) {
+               res = QP_TEST_RESULT_FAIL;
+       }
+
+       return tcu::TestStatus(res, qpGetTestResultName(res));
+
+       }
+
+}      // anonymous
+
+IndirectDrawTests::IndirectDrawTests (tcu::TestContext &testCtx)
+       : TestCaseGroup(testCtx, "indirect_draw", "indirect drawing simple geometry")
+{
+       /* Left blank on purpose */
+}
+
+IndirectDrawTests::~IndirectDrawTests (void) {}
+
+
+void IndirectDrawTests::init (void)
+{
+       ShaderMap shaderPaths;
+       shaderPaths[glu::SHADERTYPE_VERTEX]             = "vulkan/draw/VertexFetch.vert";
+       shaderPaths[glu::SHADERTYPE_FRAGMENT]    = "vulkan/draw/VertexFetch.frag";
+       addChild(new InstanceFactory<IndirectDraw>(m_testCtx, "indirect_draw_triangle_list", "Draws triangle list", shaderPaths, vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST));
+       addChild(new InstanceFactory<IndirectDraw>(m_testCtx, "indirect_draw_triangle_strip", "Draws triangle strip", shaderPaths, vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP));
+
+       shaderPaths[glu::SHADERTYPE_VERTEX]             = "vulkan/draw/VertexFetchWithInstance.vert";
+       shaderPaths[glu::SHADERTYPE_FRAGMENT]   = "vulkan/draw/VertexFetch.frag";
+       addChild(new InstanceFactory<IndirectDrawInstanced>(m_testCtx, "indirect_draw_instanced_triangle_list", "Draws an instanced triangle list", shaderPaths, vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST));
+       addChild(new InstanceFactory<IndirectDrawInstanced>(m_testCtx, "indirect_draw_instanced_triangle_strip", "Draws an instanced triangle strip", shaderPaths, vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP));
+}
+
+}      // DrawTests
+}      // vkt
\ No newline at end of file
diff --git a/external/vulkancts/modules/vulkan/draw/vktDrawIndirectTest.hpp b/external/vulkancts/modules/vulkan/draw/vktDrawIndirectTest.hpp
new file mode 100644 (file)
index 0000000..905ed2f
--- /dev/null
@@ -0,0 +1,59 @@
+#ifndef _VKTDRAWINDIRECTDRAWTESTS_HPP
+#define _VKTDRAWINDIRECTDRAWTESTS_HPP
+/*------------------------------------------------------------------------
+* Vulkan Conformance Tests
+* ------------------------
+*
+* Copyright (c) 2015 The Khronos Group Inc.
+* Copyright (c) 2015 Intel Corporation
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
+* copy of this software and/or associated documentation files (the
+* "Materials"), to deal in the Materials without restriction, including
+* without limitation the rights to use, copy, modify, merge, publish,
+* distribute, sublicense, and/or sell copies of the Materials, and to
+* permit persons to whom the Materials are furnished to do so, subject to
+* the following conditions:
+*
+* The above copyright notice(s) and this permission notice shall be included
+* in all copies or substantial portions of the Materials.
+*
+* The Materials are Confidential Information as defined by the
+* Khronos Membership Agreement until designated non-confidential by Khronos,
+* at which point this condition clause shall be removed.
+*
+* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+* MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*
+*//*!
+* \file
+* \brief Draw Indirect Test
+*//*--------------------------------------------------------------------*/
+
+#include "vktTestCase.hpp"
+
+namespace vkt
+{
+namespace Draw
+{
+class IndirectDrawTests : public tcu::TestCaseGroup
+{
+public:
+                                       IndirectDrawTests               (tcu::TestContext &testCtx);
+                                       ~IndirectDrawTests              (void);
+       void                    init                                    (void);
+
+private:
+                                       IndirectDrawTests               (const IndirectDrawTests &other);
+                                       IndirectDrawTests&              operator=(const IndirectDrawTests &other);
+
+};
+} //Draw
+} //vkt
+
+#endif // #define _VKTDRAWINDIRECTDRAWTESTS_HPP
diff --git a/external/vulkancts/modules/vulkan/draw/vktDrawSimpleTest.cpp b/external/vulkancts/modules/vulkan/draw/vktDrawSimpleTest.cpp
new file mode 100644 (file)
index 0000000..7e27cd8
--- /dev/null
@@ -0,0 +1,356 @@
+/*------------------------------------------------------------------------
+* Vulkan Conformance Tests
+* ------------------------
+*
+* Copyright (c) 2015 The Khronos Group Inc.
+* Copyright (c) 2015 Intel Corporation
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
+* copy of this software and/or associated documentation files (the
+* "Materials"), to deal in the Materials without restriction, including
+* without limitation the rights to use, copy, modify, merge, publish,
+* distribute, sublicense, and/or sell copies of the Materials, and to
+* permit persons to whom the Materials are furnished to do so, subject to
+* the following conditions:
+*
+* The above copyright notice(s) and this permission notice shall be included
+* in all copies or substantial portions of the Materials.
+*
+* The Materials are Confidential Information as defined by the
+* Khronos Membership Agreement until designated non-confidential by Khronos,
+* at which point this condition clause shall be removed.
+*
+* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+* MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*
+*//*!
+* \file
+* \brief Simple Draw Tests
+*//*--------------------------------------------------------------------*/
+
+#include "vktDrawsimpleTest.hpp"
+
+#include "vktTestCaseUtil.hpp"
+#include "vktDrawTestCaseUtil.hpp"
+
+#include "vktDrawBaseClass.hpp"
+
+#include "tcuTestLog.hpp"
+#include "tcuResource.hpp"
+#include "tcuImageCompare.hpp"
+#include "tcuTextureUtil.hpp"
+
+#include "vkDefs.hpp"
+
+namespace vkt
+{
+namespace Draw
+{
+namespace
+{      
+class SimpleDraw : public DrawTestsBaseClass
+{
+public:
+                                                       SimpleDraw      (Context &context, ShaderMap shaders, vk::VkPrimitiveTopology topology);        
+       virtual tcu::TestStatus iterate         (void);
+};
+
+class SimpleDrawInstanced : public SimpleDraw
+{
+public:
+                                               SimpleDrawInstanced                             (Context &context, ShaderMap shaders, vk::VkPrimitiveTopology topology);
+       tcu::TestStatus         SimpleDrawInstanced::iterate    (void);
+};
+
+SimpleDraw::SimpleDraw (Context &context, ShaderMap shaders, vk::VkPrimitiveTopology topology)
+       : DrawTestsBaseClass    (context, shaders[glu::SHADERTYPE_VERTEX], shaders[glu::SHADERTYPE_FRAGMENT])
+{
+       m_topology = topology;
+
+       switch (m_topology)
+       {
+               case vk::VK_PRIMITIVE_TOPOLOGY_POINT_LIST:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_LINE_LIST:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_LINE_STRIP:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST:
+                       m_data.push_back(Vec4RGBA(tcu::Vec4(     1.0f,  -1.0f,  1.0f,   1.0f), vec4Blue()));
+                       m_data.push_back(Vec4RGBA(tcu::Vec4(    -1.0f,   1.0f,  1.0f,   1.0f), vec4Blue()));
+                       m_data.push_back(Vec4RGBA(tcu::Vec4(    -0.3f,  -0.3f,  1.0f,   1.0f), vec4Blue()));
+                       m_data.push_back(Vec4RGBA(tcu::Vec4(    -0.3f,   0.3f,  1.0f,   1.0f), vec4Blue()));
+                       m_data.push_back(Vec4RGBA(tcu::Vec4(     0.3f,  -0.3f,  1.0f,   1.0f), vec4Blue()));
+                       m_data.push_back(Vec4RGBA(tcu::Vec4(     0.3f,  -0.3f,  1.0f,   1.0f), vec4Blue()));
+                       m_data.push_back(Vec4RGBA(tcu::Vec4(     0.3f,   0.3f,  1.0f,   1.0f), vec4Blue()));
+                       m_data.push_back(Vec4RGBA(tcu::Vec4(    -0.3f,   0.3f,  1.0f,   1.0f), vec4Blue()));
+                       m_data.push_back(Vec4RGBA(tcu::Vec4(    -1.0f,   1.0f,  1.0f,   1.0f), vec4Blue()));
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP:
+                       m_data.push_back(Vec4RGBA(tcu::Vec4(     1.0f,  -1.0f,  1.0f,   1.0f), vec4Blue()));
+                       m_data.push_back(Vec4RGBA(tcu::Vec4(    -1.0f,   1.0f,  1.0f,   1.0f), vec4Blue()));
+                       m_data.push_back(Vec4RGBA(tcu::Vec4(    -0.3f,  -0.3f,  1.0f,   1.0f), vec4Blue()));
+                       m_data.push_back(Vec4RGBA(tcu::Vec4(    -0.3f,   0.3f,  1.0f,   1.0f), vec4Blue()));
+                       m_data.push_back(Vec4RGBA(tcu::Vec4(     0.3f,  -0.3f,  1.0f,   1.0f), vec4Blue()));
+                       m_data.push_back(Vec4RGBA(tcu::Vec4(     0.3f,   0.3f,  1.0f,   1.0f), vec4Blue()));
+                       m_data.push_back(Vec4RGBA(tcu::Vec4(    -0.3f,   0.3f,  1.0f,   1.0f), vec4Blue()));
+                       m_data.push_back(Vec4RGBA(tcu::Vec4(    -1.0f,   1.0f,  1.0f,   1.0f), vec4Blue()));
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_PATCH_LIST:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_LAST:
+                       break;
+               default:
+                       break;
+       }
+       DrawTestsBaseClass::initialize();
+}
+
+tcu::TestStatus SimpleDraw::iterate (void)
+{
+       tcu::TestLog &log                                                       = m_context.getTestContext().getLog();
+       const vk::VkQueue queue                                         = m_context.getUniversalQueue();
+
+       beginRenderPass();
+
+       const vk::VkDeviceSize vertexBufferOffset       = 0;
+       const vk::VkBuffer vertexBuffer                         = m_vertexBuffer->object();
+       m_vk.cmdBindVertexBuffers(*m_cmdBuffer, 0, 1, &vertexBuffer, &vertexBufferOffset);
+
+       m_vk.cmdBindPipeline(*m_cmdBuffer, vk::VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline);
+
+       switch (m_topology)
+       {
+               case vk::VK_PRIMITIVE_TOPOLOGY_POINT_LIST:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_LINE_LIST:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_LINE_STRIP:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST:
+                       m_vk.cmdDraw(*m_cmdBuffer, 6, 1, 2, 0);
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP:
+                       m_vk.cmdDraw(*m_cmdBuffer, 4, 1, 2, 0);
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_PATCH_LIST:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_LAST:
+                       break;
+               default:
+                       break;
+       }
+
+       m_vk.cmdEndRenderPass(*m_cmdBuffer);
+       m_vk.endCommandBuffer(*m_cmdBuffer);
+
+       vk::VkSubmitInfo submitInfo =
+       {
+               vk::VK_STRUCTURE_TYPE_SUBMIT_INFO,      // VkStructureType                      sType;
+               DE_NULL,                                                        // const void*                          pNext;
+               0,                                                                      // deUint32                                     waitSemaphoreCount;
+               DE_NULL,                                                        // const VkSemaphore*           pWaitSemaphores;
+               1,                                                                      // deUint32                                     commandBufferCount;
+               &m_cmdBuffer.get(),                                     // const VkCommandBuffer*       pCommandBuffers;
+               0,                                                                      // deUint32                                     signalSemaphoreCount;
+               DE_NULL                                                         // const VkSemaphore*           pSignalSemaphores;
+       };
+       VK_CHECK(m_vk.queueSubmit(queue, 1, &submitInfo, DE_NULL));
+
+       VK_CHECK(m_vk.queueWaitIdle(queue));
+
+       // Validation
+       tcu::Texture2D referenceFrame(vk::mapVkFormat(m_colorAttachmentFormat), (int)(0.5 + WIDTH), (int)(0.5 + HEIGHT));
+       referenceFrame.allocLevel(0);
+
+       const deInt32 frameWidth        = referenceFrame.getWidth();
+       const deInt32 frameHeight       = referenceFrame.getHeight();
+
+       tcu::clear(referenceFrame.getLevel(0), tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f));
+
+       for (int y = 0; y < frameHeight; y++)
+       {
+               const float yCoord = (float)(y / (0.5*frameHeight)) - 1.0f;
+
+               for (int x = 0; x < frameWidth; x++)
+               {
+                       const float xCoord = (float)(x / (0.5*frameWidth)) - 1.0f;
+
+                       if ((yCoord >= -0.3f && yCoord <= 0.3f && xCoord >= -0.3f && xCoord <= 0.3f))
+                               referenceFrame.getLevel(0).setPixel(tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f), x, y);
+               }
+       }
+
+       const vk::VkOffset3D zeroOffset = { 0, 0, 0 };
+       const tcu::ConstPixelBufferAccess renderedFrame = m_colorTargetImage->readSurface(queue, m_context.getDefaultAllocator(),
+               vk::VK_IMAGE_LAYOUT_GENERAL, zeroOffset, WIDTH, HEIGHT, vk::VK_IMAGE_ASPECT_COLOR_BIT);
+
+       qpTestResult res = QP_TEST_RESULT_PASS;
+
+       if (!tcu::fuzzyCompare(log, "Result", "Image comparison result",
+               referenceFrame.getLevel(0), renderedFrame, 0.05f,
+               tcu::COMPARE_LOG_RESULT)) {
+               res = QP_TEST_RESULT_FAIL;
+       }
+
+       return tcu::TestStatus(res, qpGetTestResultName(res));
+
+}
+
+SimpleDrawInstanced::SimpleDrawInstanced (Context &context, ShaderMap shaders, vk::VkPrimitiveTopology topology)
+       : SimpleDraw    (context, shaders, topology) {}
+
+tcu::TestStatus SimpleDrawInstanced::iterate (void)
+{
+       tcu::TestLog &log               = m_context.getTestContext().getLog();
+       const vk::VkQueue queue = m_context.getUniversalQueue();
+
+       beginRenderPass();
+
+       const vk::VkDeviceSize vertexBufferOffset = 0;
+       const vk::VkBuffer vertexBuffer = m_vertexBuffer->object();
+       m_vk.cmdBindVertexBuffers(*m_cmdBuffer, 0, 1, &vertexBuffer, &vertexBufferOffset);
+
+       m_vk.cmdBindPipeline(*m_cmdBuffer, vk::VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline);
+
+       switch (m_topology)
+       {
+               case vk::VK_PRIMITIVE_TOPOLOGY_POINT_LIST:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_LINE_LIST:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_LINE_STRIP:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST:
+                       m_vk.cmdDraw(*m_cmdBuffer, 6, 4, 2, 2);
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP:
+                       m_vk.cmdDraw(*m_cmdBuffer, 4, 4, 2, 2);
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_PATCH_LIST:
+                       break;
+               case vk::VK_PRIMITIVE_TOPOLOGY_LAST:
+                       break;
+               default:
+                       break;
+       }
+
+       m_vk.cmdEndRenderPass(*m_cmdBuffer);
+       m_vk.endCommandBuffer(*m_cmdBuffer);
+
+       vk::VkSubmitInfo submitInfo =
+       {
+               vk::VK_STRUCTURE_TYPE_SUBMIT_INFO,      // VkStructureType                      sType;
+               DE_NULL,                                                        // const void*                          pNext;
+               0,                                                                      // deUint32                                     waitSemaphoreCount;
+               DE_NULL,                                                        // const VkSemaphore*           pWaitSemaphores;
+               1,                                                                      // deUint32                                     commandBufferCount;
+               &m_cmdBuffer.get(),                                     // const VkCommandBuffer*       pCommandBuffers;
+               0,                                                                      // deUint32                                     signalSemaphoreCount;
+               DE_NULL                                                         // const VkSemaphore*           pSignalSemaphores;
+       };
+       VK_CHECK(m_vk.queueSubmit(queue, 1, &submitInfo, DE_NULL));
+
+       VK_CHECK(m_vk.queueWaitIdle(queue));
+
+       // Validation
+       VK_CHECK(m_vk.queueWaitIdle(queue));
+
+       tcu::Texture2D referenceFrame(vk::mapVkFormat(m_colorAttachmentFormat), (int)(0.5 + WIDTH), (int)(0.5 + HEIGHT));
+       referenceFrame.allocLevel(0);
+
+       const deInt32 frameWidth        = referenceFrame.getWidth();
+       const deInt32 frameHeight       = referenceFrame.getHeight();
+
+       tcu::clear(referenceFrame.getLevel(0), tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f));
+
+       for (int y = 0; y < frameHeight; y++)
+       {
+               const float yCoord = (float)(y / (0.5*frameHeight)) - 1.0f;
+
+               for (int x = 0; x < frameWidth; x++)
+               {
+                       const float xCoord = (float)(x / (0.5*frameWidth)) - 1.0f;
+
+                       if ((yCoord >= -0.6f && yCoord <= 0.3f && xCoord >= -0.3f && xCoord <= 0.6f))
+                               referenceFrame.getLevel(0).setPixel(tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f), x, y);
+               }
+       }
+
+       const vk::VkOffset3D zeroOffset = { 0, 0, 0 };
+       const tcu::ConstPixelBufferAccess renderedFrame = m_colorTargetImage->readSurface(queue, m_context.getDefaultAllocator(),
+               vk::VK_IMAGE_LAYOUT_GENERAL, zeroOffset, WIDTH, HEIGHT, vk::VK_IMAGE_ASPECT_COLOR_BIT);
+
+       qpTestResult res = QP_TEST_RESULT_PASS;
+
+       if (!tcu::fuzzyCompare(log, "Result", "Image comparison result",
+               referenceFrame.getLevel(0), renderedFrame, 0.05f,
+               tcu::COMPARE_LOG_RESULT)) {
+               res = QP_TEST_RESULT_FAIL;
+       }
+
+       return tcu::TestStatus(res, qpGetTestResultName(res));
+}
+
+}      // anonymous
+
+SimpleDrawTests::SimpleDrawTests (tcu::TestContext &testCtx)
+: TestCaseGroup        (testCtx, "simple_draw", "drawing simple geometry")
+{
+       /* Left blank on purpose */
+}
+
+SimpleDrawTests::~SimpleDrawTests (void) {}
+
+
+void SimpleDrawTests::init (void)
+{
+       ShaderMap shaderPaths;
+       shaderPaths[glu::SHADERTYPE_VERTEX]             = "vulkan/draw/VertexFetch.vert";
+       shaderPaths[glu::SHADERTYPE_FRAGMENT]   = "vulkan/draw/VertexFetch.frag";
+       addChild(new InstanceFactory<SimpleDraw>(m_testCtx, "simple_draw_triangle_list", "Draws triangle list", shaderPaths, vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST));
+       addChild(new InstanceFactory<SimpleDraw>(m_testCtx, "simple_draw_triangle_strip", "Draws triangle strip", shaderPaths, vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP));
+
+       shaderPaths[glu::SHADERTYPE_VERTEX]             = "vulkan/draw/VertexFetchWithInstance.vert";
+       shaderPaths[glu::SHADERTYPE_FRAGMENT]   = "vulkan/draw/VertexFetch.frag";
+       addChild(new InstanceFactory<SimpleDrawInstanced>(m_testCtx, "simple_draw_instanced_triangle_list", "Draws an instanced triangle list", shaderPaths, vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST));
+       addChild(new InstanceFactory<SimpleDrawInstanced>(m_testCtx, "simple_draw_instanced_triangle_strip", "Draws an instanced triangle strip", shaderPaths, vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP));
+}
+
+}      // DrawTests
+}      // vkt
\ No newline at end of file
diff --git a/external/vulkancts/modules/vulkan/draw/vktDrawSimpleTest.hpp b/external/vulkancts/modules/vulkan/draw/vktDrawSimpleTest.hpp
new file mode 100644 (file)
index 0000000..62eb957
--- /dev/null
@@ -0,0 +1,59 @@
+#ifndef _VKT_SIMPLE_DRAWTESTS_HPP
+#define _VKT_SIMPLE_DRAWTESTS_HPP
+/*------------------------------------------------------------------------
+* Vulkan Conformance Tests
+* ------------------------
+*
+* Copyright (c) 2015 The Khronos Group Inc.
+* Copyright (c) 2015 Intel Corporation
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
+* copy of this software and/or associated documentation files (the
+* "Materials"), to deal in the Materials without restriction, including
+* without limitation the rights to use, copy, modify, merge, publish,
+* distribute, sublicense, and/or sell copies of the Materials, and to
+* permit persons to whom the Materials are furnished to do so, subject to
+* the following conditions:
+*
+* The above copyright notice(s) and this permission notice shall be included
+* in all copies or substantial portions of the Materials.
+*
+* The Materials are Confidential Information as defined by the
+* Khronos Membership Agreement until designated non-confidential by Khronos,
+* at which point this condition clause shall be removed.
+*
+* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+* MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*
+*//*!
+* \file
+* \brief Draw Simple Test
+*//*--------------------------------------------------------------------*/
+
+#include "vktTestCase.hpp"
+
+namespace vkt
+{
+namespace Draw
+{
+class SimpleDrawTests : public tcu::TestCaseGroup
+{
+public:
+                                       SimpleDrawTests                 (tcu::TestContext &testCtx);
+                                       ~SimpleDrawTests                (void);
+       void                    init                                    (void);
+
+private:
+                                       SimpleDrawTests                 (const SimpleDrawTests &other);
+                                       SimpleDrawTests&                operator=(const SimpleDrawTests &other);
+
+};
+} //Draw
+} //vkt
+
+#endif // #define _VKT_SIMPLE_DRAWTESTS_HPP
diff --git a/external/vulkancts/modules/vulkan/draw/vktDrawTestCaseUtil.hpp b/external/vulkancts/modules/vulkan/draw/vktDrawTestCaseUtil.hpp
new file mode 100644 (file)
index 0000000..65d3457
--- /dev/null
@@ -0,0 +1,105 @@
+#ifndef _VKTDRAWTESTS_TESTCASEUTIL_HPP
+#define _VKTDRAWTESTS_TESTCASEUTIL_HPP
+/*------------------------------------------------------------------------
+ * Vulkan Conformance Tests
+ * ------------------------
+ *
+ * Copyright (c) 2015 The Khronos Group Inc.
+ * Copyright (c) 2015 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and/or associated documentation files (the
+ * "Materials"), to deal in the Materials without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Materials, and to
+ * permit persons to whom the Materials are furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice(s) and this permission notice shall be included
+ * in all copies or substantial portions of the Materials.
+ *
+ * The Materials are Confidential Information as defined by the
+ * Khronos Membership Agreement until designated non-confidential by Khronos,
+ * at which point this condition clause shall be removed.
+ *
+ * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ *
+ *//*!
+ * \file
+ * \brief Draw Test Case Utils
+ *//*--------------------------------------------------------------------*/
+
+
+#include "tcuDefs.hpp"
+#include "tcuResource.hpp"
+
+#include "vktTestCase.hpp"
+
+#include "gluShaderUtil.hpp"
+#include "vkPrograms.hpp"
+
+#include <map>
+
+namespace vkt
+{
+namespace Draw
+{
+
+class ShaderSourceProvider 
+{
+public: 
+       static std::string getSource (tcu::Archive& archive, const char* path)
+       {
+               tcu::Resource *resource = archive.getResource(path);
+
+               std::vector<deUint8> readBuffer(resource->getSize() + 1);
+               resource->read(&readBuffer[0], resource->getSize());
+               readBuffer[readBuffer.size() - 1] = 0;
+
+               return reinterpret_cast<const char*>(&readBuffer[0]);
+       }
+};
+
+typedef std::map<glu::ShaderType, const char*> ShaderMap;
+
+template<typename Instance>
+class InstanceFactory : public TestCase
+{
+public:
+       InstanceFactory (tcu::TestContext& testCtx, const std::string& name, const std::string& desc,
+               const std::map<glu::ShaderType, const char*> shaderPaths, const vk::VkPrimitiveTopology topology)
+               : TestCase              (testCtx, name, desc)
+               , m_shaderPaths (shaderPaths)
+               , m_topology    (topology)
+       {
+       }
+
+       TestInstance* createInstance (Context& context) const 
+       { 
+               return new Instance(context, m_shaderPaths, m_topology); 
+       }
+
+       virtual void initPrograms (vk::SourceCollections& programCollection) const
+       {
+               for (ShaderMap::const_iterator i = m_shaderPaths.begin(); i != m_shaderPaths.end(); ++i)
+               {
+                       programCollection.glslSources.add(i->second) <<
+                               glu::ShaderSource(i->first, ShaderSourceProvider::getSource(m_testCtx.getArchive(), i->second));
+               }
+       }
+
+private:
+       const ShaderMap m_shaderPaths;
+       const vk::VkPrimitiveTopology m_topology;
+};
+
+} //Draw
+} //vkt
+
+#endif //_VKTDRAWTESTS_TESTCASEUTIL_HPP
\ No newline at end of file
diff --git a/external/vulkancts/modules/vulkan/draw/vktDrawTests.cpp b/external/vulkancts/modules/vulkan/draw/vktDrawTests.cpp
new file mode 100644 (file)
index 0000000..a6a9f62
--- /dev/null
@@ -0,0 +1,61 @@
+/*------------------------------------------------------------------------
+* Vulkan Conformance Tests
+* ------------------------
+*
+* Copyright (c) 2015 The Khronos Group Inc.
+* Copyright (c) 2015 Intel Corporation
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
+* copy of this software and/or associated documentation files (the
+* "Materials"), to deal in the Materials without restriction, including
+* without limitation the rights to use, copy, modify, merge, publish,
+* distribute, sublicense, and/or sell copies of the Materials, and to
+* permit persons to whom the Materials are furnished to do so, subject to
+* the following conditions:
+*
+* The above copyright notice(s) and this permission notice shall be included
+* in all copies or substantial portions of the Materials.
+*
+* The Materials are Confidential Information as defined by the
+* Khronos Membership Agreement until designated non-confidential by Khronos,
+* at which point this condition clause shall be removed.
+*
+* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+* MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*
+*//*!
+* \file
+* \brief Draw Tests
+*//*--------------------------------------------------------------------*/
+
+#include "vktDrawTests.hpp"
+
+#include "vktDrawSimpleTest.hpp"
+#include "vktDrawIndexedTest.hpp"
+#include "vktDrawIndirectTest.hpp"
+
+#include "deUniquePtr.hpp"
+
+namespace vkt
+{
+namespace Draw
+{
+
+tcu::TestCaseGroup* createTests (tcu::TestContext& testCtx)
+{
+       de::MovePtr<tcu::TestCaseGroup> group(new tcu::TestCaseGroup(testCtx, "draw", "Spimple Draw tests"));
+
+       group->addChild(new SimpleDrawTests(testCtx));
+       group->addChild(new DrawIndexedTests(testCtx));
+       group->addChild(new IndirectDrawTests(testCtx));
+
+       return group.release();
+}
+
+} // Draw
+} // vkt
\ No newline at end of file
diff --git a/external/vulkancts/modules/vulkan/draw/vktDrawTests.hpp b/external/vulkancts/modules/vulkan/draw/vktDrawTests.hpp
new file mode 100644 (file)
index 0000000..a04b575
--- /dev/null
@@ -0,0 +1,50 @@
+#ifndef _VK_DRAWTESTS_HPP
+#define _VK_DRAWTESTS_HPP
+/*------------------------------------------------------------------------
+* Vulkan Conformance Tests
+* ------------------------
+*
+* Copyright (c) 2015 The Khronos Group Inc.
+* Copyright (c) 2015 Intel Corporation
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
+* copy of this software and/or associated documentation files (the
+* "Materials"), to deal in the Materials without restriction, including
+* without limitation the rights to use, copy, modify, merge, publish,
+* distribute, sublicense, and/or sell copies of the Materials, and to
+* permit persons to whom the Materials are furnished to do so, subject to
+* the following conditions:
+*
+* The above copyright notice(s) and this permission notice shall be included
+* in all copies or substantial portions of the Materials.
+*
+* The Materials are Confidential Information as defined by the
+* Khronos Membership Agreement until designated non-confidential by Khronos,
+* at which point this condition clause shall be removed.
+*
+* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+* MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*
+*//*!
+* \file
+* \brief Draw Tests
+*//*--------------------------------------------------------------------*/
+
+#include "tcuDefs.hpp"
+#include "tcuTestCase.hpp"
+
+namespace vkt
+{
+       namespace Draw
+{
+       tcu::TestCaseGroup*             createTests (tcu::TestContext& testCtx);
+
+} //Draw
+} //vkt
+
+#endif // _VK_DRAWTESTS_HPP