Merge "Merge "Try to determine renderable format in lifetime tests am: c0a5dc217f...
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / modules / vulkan / pipeline / vktPipelineMakeUtil.hpp
1 #ifndef _VKTPIPELINEMAKEUTIL_HPP
2 #define _VKTPIPELINEMAKEUTIL_HPP
3 /*------------------------------------------------------------------------
4  * Vulkan Conformance Tests
5  * ------------------------
6  *
7  * Copyright (c) 2016 The Khronos Group Inc.
8  *
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
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
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.
20  *
21  *//*!
22  * \file
23  * \brief Object creation utilities
24  *//*--------------------------------------------------------------------*/
25
26 #include "vkDefs.hpp"
27 #include "vkRef.hpp"
28 #include "vkMemUtil.hpp"
29 #include "deUniquePtr.hpp"
30 #include "tcuVector.hpp"
31
32 namespace vkt
33 {
34 namespace pipeline
35 {
36
37 class Buffer
38 {
39 public:
40                                                                                 Buffer                  (const vk::DeviceInterface&             vk,
41                                                                                                                  const vk::VkDevice                             device,
42                                                                                                                  vk::Allocator&                                 allocator,
43                                                                                                                  const vk::VkBufferCreateInfo&  bufferCreateInfo,
44                                                                                                                  const vk::MemoryRequirement    memoryRequirement);
45
46         const vk::VkBuffer&                                     get                             (void) const { return *m_buffer; }
47         const vk::VkBuffer&                                     operator*               (void) const { return get(); }
48         vk::Allocation&                                         getAllocation   (void) const { return *m_allocation; }
49
50 private:
51         const vk::Unique<vk::VkBuffer>          m_buffer;
52         const de::UniquePtr<vk::Allocation>     m_allocation;
53
54                                                                                 Buffer                  (const Buffer&);        // "deleted"
55         Buffer&                                                         operator=               (const Buffer&);
56 };
57
58 class Image
59 {
60 public:
61                                                                                 Image                   (const vk::DeviceInterface&             vk,
62                                                                                                                  const vk::VkDevice                             device,
63                                                                                                                  vk::Allocator&                                 allocator,
64                                                                                                                  const vk::VkImageCreateInfo&   imageCreateInfo,
65                                                                                                                  const vk::MemoryRequirement    memoryRequirement);
66
67         const vk::VkImage&                                      get                             (void) const { return *m_image; }
68         const vk::VkImage&                                      operator*               (void) const { return get(); }
69         vk::Allocation&                                         getAllocation   (void) const { return *m_allocation; }
70
71 private:
72         const vk::Unique<vk::VkImage>           m_image;
73         const de::UniquePtr<vk::Allocation>     m_allocation;
74
75                                                                                 Image                   (const Image&);         // "deleted"
76         Image&                                                          operator=               (const Image&);
77 };
78
79 vk::VkBufferCreateInfo                  makeBufferCreateInfo    (const vk::VkDeviceSize bufferSize, const vk::VkBufferUsageFlags usage);
80 vk::Move<vk::VkCommandBuffer>   makeCommandBuffer               (const vk::DeviceInterface& vk, const vk::VkDevice device, const vk::VkCommandPool commandPool);
81 vk::Move<vk::VkDescriptorSet>   makeDescriptorSet               (const vk::DeviceInterface& vk, const vk::VkDevice device, const vk::VkDescriptorPool descriptorPool, const vk::VkDescriptorSetLayout setLayout);
82 vk::Move<vk::VkPipelineLayout>  makePipelineLayout              (const vk::DeviceInterface& vk, const vk::VkDevice device);
83 vk::Move<vk::VkPipelineLayout>  makePipelineLayout              (const vk::DeviceInterface& vk, const vk::VkDevice device, const vk::VkDescriptorSetLayout descriptorSetLayout);
84 vk::Move<vk::VkPipeline>                makeComputePipeline             (const vk::DeviceInterface& vk, const vk::VkDevice device, const vk::VkPipelineLayout pipelineLayout, const vk::VkShaderModule shaderModule, const vk::VkSpecializationInfo* specInfo);
85 vk::Move<vk::VkFramebuffer>             makeFramebuffer                 (const vk::DeviceInterface& vk, const vk::VkDevice device, const vk::VkRenderPass renderPass, const deUint32 attachmentCount, const vk::VkImageView* pAttachments, const deUint32 width, const deUint32 height, const deUint32 layers = 1u);
86 vk::Move<vk::VkImageView>               makeImageView                   (const vk::DeviceInterface& vk, const vk::VkDevice vkDevice, const vk::VkImage image, const vk::VkImageViewType viewType, const vk::VkFormat format, const vk::VkImageSubresourceRange subresourceRange);
87 vk::VkBufferMemoryBarrier               makeBufferMemoryBarrier (const vk::VkAccessFlags srcAccessMask, const vk::VkAccessFlags dstAccessMask, const vk::VkBuffer buffer, const vk::VkDeviceSize offset, const vk::VkDeviceSize bufferSizeBytes);
88 vk::VkImageMemoryBarrier                makeImageMemoryBarrier  (const vk::VkAccessFlags srcAccessMask, const vk::VkAccessFlags dstAccessMask, const vk::VkImageLayout oldLayout, const vk::VkImageLayout newLayout, const vk::VkImage image, const vk::VkImageSubresourceRange subresourceRange);
89 de::MovePtr<vk::Allocation>             bindImage                               (const vk::DeviceInterface& vk, const vk::VkDevice device, vk::Allocator& allocator, const vk::VkImage image, const vk::MemoryRequirement requirement);
90 de::MovePtr<vk::Allocation>             bindBuffer                              (const vk::DeviceInterface& vk, const vk::VkDevice device, vk::Allocator& allocator, const vk::VkBuffer buffer, const vk::MemoryRequirement requirement);
91 de::MovePtr<vk::Allocation>             bindImageDedicated              (const vk::InstanceInterface& vki, const vk::DeviceInterface& vkd, const vk::VkPhysicalDevice physDevice, const vk::VkDevice device, const vk::VkImage image, const vk::MemoryRequirement requirement);
92 de::MovePtr<vk::Allocation>             bindBufferDedicated             (const vk::InstanceInterface& vki, const vk::DeviceInterface& vkd, const vk::VkPhysicalDevice physDevice, const vk::VkDevice device, const vk::VkBuffer buffer, const vk::MemoryRequirement requirement);
93 void                                                    beginCommandBuffer              (const vk::DeviceInterface& vk, const vk::VkCommandBuffer commandBuffer);
94 void                                                    submitCommandsAndWait   (const vk::DeviceInterface& vk, const vk::VkDevice device, const vk::VkQueue queue, const vk::VkCommandBuffer commandBuffer);
95
96 } // pipeline
97 } // vkt
98
99 #endif // _VKTPIPELINEMAKEUTIL_HPP