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
get(void) const46 const vk::VkBuffer& get (void) const { return *m_buffer; }
operator *(void) const47 const vk::VkBuffer& operator* (void) const { return get(); }
getAllocation(void) const48 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
get(void) const67 const vk::VkImage& get (void) const { return *m_image; }
operator *(void) const68 const vk::VkImage& operator* (void) const { return get(); }
getAllocation(void) const69 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::Move<vk::VkCommandBuffer> makeCommandBuffer (const vk::DeviceInterface& vk, const vk::VkDevice device, const vk::VkCommandPool commandPool);
80 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);
81 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);
82 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);
83
84 template<typename T>
dataOrNullPtr(const std::vector<T> & v)85 inline const T* dataOrNullPtr(const std::vector<T>& v)
86 {
87 return (v.empty() ? DE_NULL : &v[0]);
88 }
89
90 template<typename T>
dataOrNullPtr(std::vector<T> & v)91 inline T* dataOrNullPtr(std::vector<T>& v)
92 {
93 return (v.empty() ? DE_NULL : &v[0]);
94 }
95
96 } // pipeline
97 } // vkt
98
99 #endif // _VKTPIPELINEMAKEUTIL_HPP
100