1 #ifndef _VKTCOMPUTETESTSUTIL_HPP
2 #define _VKTCOMPUTETESTSUTIL_HPP
3 /*------------------------------------------------------------------------
4 * Vulkan Conformance Tests
5 * ------------------------
7 * Copyright (c) 2016 The Khronos Group Inc.
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
23 * \brief Compute tests utility classes
24 *//*--------------------------------------------------------------------*/
27 #include "vkMemUtil.hpp"
29 #include "vkRefUtil.hpp"
30 #include "vkPrograms.hpp"
31 #include "vkTypeUtil.hpp"
32 #include "vkImageUtil.hpp"
42 Buffer (const vk::DeviceInterface& vk,
43 const vk::VkDevice device,
44 vk::Allocator& allocator,
45 const vk::VkBufferCreateInfo& bufferCreateInfo,
46 const vk::MemoryRequirement memoryRequirement);
48 const vk::VkBuffer& get (void) const { return *m_buffer; }
49 const vk::VkBuffer& operator* (void) const { return get(); }
50 vk::Allocation& getAllocation (void) const { return *m_allocation; }
53 de::MovePtr<vk::Allocation> m_allocation;
54 vk::Move<vk::VkBuffer> m_buffer;
56 Buffer (const Buffer&); // "deleted"
57 Buffer& operator= (const Buffer&);
63 Image (const vk::DeviceInterface& vk,
64 const vk::VkDevice device,
65 vk::Allocator& allocator,
66 const vk::VkImageCreateInfo& imageCreateInfo,
67 const vk::MemoryRequirement memoryRequirement);
69 const vk::VkImage& get (void) const { return *m_image; }
70 const vk::VkImage& operator* (void) const { return get(); }
71 vk::Allocation& getAllocation (void) const { return *m_allocation; }
74 de::MovePtr<vk::Allocation> m_allocation;
75 vk::Move<vk::VkImage> m_image;
77 Image (const Image&); // "deleted"
78 Image& operator= (const Image&);
81 vk::Move<vk::VkCommandPool> makeCommandPool (const vk::DeviceInterface& vk,
82 const vk::VkDevice device,
83 const deUint32 queueFamilyIndex);
85 vk::Move<vk::VkPipelineLayout> makePipelineLayout (const vk::DeviceInterface& vk,
86 const vk::VkDevice device);
88 vk::Move<vk::VkPipelineLayout> makePipelineLayout (const vk::DeviceInterface& vk,
89 const vk::VkDevice device,
90 const vk::VkDescriptorSetLayout descriptorSetLayout);
92 vk::Move<vk::VkPipeline> makeComputePipeline (const vk::DeviceInterface& vk,
93 const vk::VkDevice device,
94 const vk::VkPipelineLayout pipelineLayout,
95 const vk::VkShaderModule shaderModule);
97 vk::Move<vk::VkBufferView> makeBufferView (const vk::DeviceInterface& vk,
98 const vk::VkDevice device,
99 const vk::VkBuffer buffer,
100 const vk::VkFormat format,
101 const vk::VkDeviceSize offset,
102 const vk::VkDeviceSize size);
104 vk::Move<vk::VkImageView> makeImageView (const vk::DeviceInterface& vk,
105 const vk::VkDevice device,
106 const vk::VkImage image,
107 const vk::VkImageViewType imageViewType,
108 const vk::VkFormat format,
109 const vk::VkImageSubresourceRange subresourceRange);
111 vk::Move<vk::VkDescriptorSet> makeDescriptorSet (const vk::DeviceInterface& vk,
112 const vk::VkDevice device,
113 const vk::VkDescriptorPool descriptorPool,
114 const vk::VkDescriptorSetLayout setLayout);
116 vk::VkBufferCreateInfo makeBufferCreateInfo (const vk::VkDeviceSize bufferSize,
117 const vk::VkBufferUsageFlags usage);
119 vk::VkBufferImageCopy makeBufferImageCopy (const vk::VkExtent3D extent,
120 const deUint32 arraySize);
122 vk::VkBufferMemoryBarrier makeBufferMemoryBarrier (const vk::VkAccessFlags srcAccessMask,
123 const vk::VkAccessFlags dstAccessMask,
124 const vk::VkBuffer buffer,
125 const vk::VkDeviceSize offset,
126 const vk::VkDeviceSize bufferSizeBytes);
128 vk::VkImageMemoryBarrier makeImageMemoryBarrier (const vk::VkAccessFlags srcAccessMask,
129 const vk::VkAccessFlags dstAccessMask,
130 const vk::VkImageLayout oldLayout,
131 const vk::VkImageLayout newLayout,
132 const vk::VkImage image,
133 const vk::VkImageSubresourceRange subresourceRange);
135 void beginCommandBuffer (const vk::DeviceInterface& vk,
136 const vk::VkCommandBuffer cmdBuffer);
138 void endCommandBuffer (const vk::DeviceInterface& vk,
139 const vk::VkCommandBuffer cmdBuffer);
141 void submitCommandsAndWait (const vk::DeviceInterface& vk,
142 const vk::VkDevice device,
143 const vk::VkQueue queue,
144 const vk::VkCommandBuffer cmdBuffer);
146 inline vk::VkExtent3D makeExtent3D (const tcu::IVec3& vec)
148 return vk::makeExtent3D(vec.x(), vec.y(), vec.z());
151 inline vk::VkDeviceSize getImageSizeBytes (const tcu::IVec3& imageSize, const vk::VkFormat format)
153 return tcu::getPixelSize(vk::mapVkFormat(format)) * imageSize.x() * imageSize.y() * imageSize.z();
159 #endif // _VKTCOMPUTETESTSUTIL_HPP