1 #ifndef _VKTCOMPUTETESTSUTIL_HPP
2 #define _VKTCOMPUTETESTSUTIL_HPP
3 /*------------------------------------------------------------------------
4 * Vulkan Conformance Tests
5 * ------------------------
7 * Copyright (c) 2016 The Khronos Group Inc.
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and/or associated documentation files (the
11 * "Materials"), to deal in the Materials without restriction, including
12 * without limitation the rights to use, copy, modify, merge, publish,
13 * distribute, sublicense, and/or sell copies of the Materials, and to
14 * permit persons to whom the Materials are furnished to do so, subject to
15 * the following conditions:
17 * The above copyright notice(s) and this permission notice shall be included
18 * in all copies or substantial portions of the Materials.
20 * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26 * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
30 * \brief Compute tests utility classes
31 *//*--------------------------------------------------------------------*/
34 #include "vkMemUtil.hpp"
36 #include "vkRefUtil.hpp"
37 #include "vkPrograms.hpp"
38 #include "vkTypeUtil.hpp"
39 #include "vkImageUtil.hpp"
49 Buffer (const vk::DeviceInterface& vk,
50 const vk::VkDevice device,
51 vk::Allocator& allocator,
52 const vk::VkBufferCreateInfo& bufferCreateInfo,
53 const vk::MemoryRequirement memoryRequirement);
55 const vk::VkBuffer& get (void) const { return *m_buffer; }
56 const vk::VkBuffer& operator* (void) const { return get(); }
57 vk::Allocation& getAllocation (void) const { return *m_allocation; }
60 de::MovePtr<vk::Allocation> m_allocation;
61 vk::Move<vk::VkBuffer> m_buffer;
63 Buffer (const Buffer&); // "deleted"
64 Buffer& operator= (const Buffer&);
70 Image (const vk::DeviceInterface& vk,
71 const vk::VkDevice device,
72 vk::Allocator& allocator,
73 const vk::VkImageCreateInfo& imageCreateInfo,
74 const vk::MemoryRequirement memoryRequirement);
76 const vk::VkImage& get (void) const { return *m_image; }
77 const vk::VkImage& operator* (void) const { return get(); }
78 vk::Allocation& getAllocation (void) const { return *m_allocation; }
81 de::MovePtr<vk::Allocation> m_allocation;
82 vk::Move<vk::VkImage> m_image;
84 Image (const Image&); // "deleted"
85 Image& operator= (const Image&);
88 vk::Move<vk::VkCommandPool> makeCommandPool (const vk::DeviceInterface& vk,
89 const vk::VkDevice device,
90 const deUint32 queueFamilyIndex);
92 vk::Move<vk::VkCommandBuffer> makeCommandBuffer (const vk::DeviceInterface& vk,
93 const vk::VkDevice device,
94 const vk::VkCommandPool commandPool);
96 vk::Move<vk::VkPipelineLayout> makePipelineLayout (const vk::DeviceInterface& vk,
97 const vk::VkDevice device);
99 vk::Move<vk::VkPipelineLayout> makePipelineLayout (const vk::DeviceInterface& vk,
100 const vk::VkDevice device,
101 const vk::VkDescriptorSetLayout descriptorSetLayout);
103 vk::Move<vk::VkPipeline> makeComputePipeline (const vk::DeviceInterface& vk,
104 const vk::VkDevice device,
105 const vk::VkPipelineLayout pipelineLayout,
106 const vk::VkShaderModule shaderModule);
108 vk::Move<vk::VkBufferView> makeBufferView (const vk::DeviceInterface& vk,
109 const vk::VkDevice device,
110 const vk::VkBuffer buffer,
111 const vk::VkFormat format,
112 const vk::VkDeviceSize offset,
113 const vk::VkDeviceSize size);
115 vk::Move<vk::VkImageView> makeImageView (const vk::DeviceInterface& vk,
116 const vk::VkDevice device,
117 const vk::VkImage image,
118 const vk::VkImageViewType imageViewType,
119 const vk::VkFormat format,
120 const vk::VkImageSubresourceRange subresourceRange);
122 vk::Move<vk::VkDescriptorSet> makeDescriptorSet (const vk::DeviceInterface& vk,
123 const vk::VkDevice device,
124 const vk::VkDescriptorPool descriptorPool,
125 const vk::VkDescriptorSetLayout setLayout);
127 vk::VkBufferCreateInfo makeBufferCreateInfo (const vk::VkDeviceSize bufferSize,
128 const vk::VkBufferUsageFlags usage);
130 vk::VkBufferImageCopy makeBufferImageCopy (const vk::VkExtent3D extent,
131 const deUint32 arraySize);
133 vk::VkBufferMemoryBarrier makeBufferMemoryBarrier (const vk::VkAccessFlags srcAccessMask,
134 const vk::VkAccessFlags dstAccessMask,
135 const vk::VkBuffer buffer,
136 const vk::VkDeviceSize offset,
137 const vk::VkDeviceSize bufferSizeBytes);
139 vk::VkImageMemoryBarrier makeImageMemoryBarrier (const vk::VkAccessFlags srcAccessMask,
140 const vk::VkAccessFlags dstAccessMask,
141 const vk::VkImageLayout oldLayout,
142 const vk::VkImageLayout newLayout,
143 const vk::VkImage image,
144 const vk::VkImageSubresourceRange subresourceRange);
146 void beginCommandBuffer (const vk::DeviceInterface& vk,
147 const vk::VkCommandBuffer cmdBuffer);
149 void endCommandBuffer (const vk::DeviceInterface& vk,
150 const vk::VkCommandBuffer cmdBuffer);
152 void submitCommandsAndWait (const vk::DeviceInterface& vk,
153 const vk::VkDevice device,
154 const vk::VkQueue queue,
155 const vk::VkCommandBuffer cmdBuffer);
157 inline vk::VkExtent3D makeExtent3D (const tcu::IVec3& vec)
159 return vk::makeExtent3D(vec.x(), vec.y(), vec.z());
162 inline vk::VkDeviceSize getImageSizeBytes (const tcu::IVec3& imageSize, const vk::VkFormat format)
164 return tcu::getPixelSize(vk::mapVkFormat(format)) * imageSize.x() * imageSize.y() * imageSize.z();
170 #endif // _VKTCOMPUTETESTSUTIL_HPP