1 /*-------------------------------------------------------------------------
2 * Vulkan CTS Framework
3 * --------------------
4 *
5 * Copyright (c) 2015 Google Inc.
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 *//*!
20 * \file
21 * \brief Vulkan object reference holder utilities.
22 *//*--------------------------------------------------------------------*/
23
24 #include "vkRefUtil.hpp"
25
26 namespace vk
27 {
28
29 #include "vkRefUtilImpl.inl"
30
createGraphicsPipeline(const DeviceInterface & vk,VkDevice device,VkPipelineCache pipelineCache,const VkGraphicsPipelineCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator)31 Move<VkPipeline> createGraphicsPipeline (const DeviceInterface& vk,
32 VkDevice device,
33 VkPipelineCache pipelineCache,
34 const VkGraphicsPipelineCreateInfo* pCreateInfo,
35 const VkAllocationCallbacks* pAllocator)
36 {
37 VkPipeline object = 0;
38 VK_CHECK(vk.createGraphicsPipelines(device, pipelineCache, 1u, pCreateInfo, pAllocator, &object));
39 return Move<VkPipeline>(check<VkPipeline>(object), Deleter<VkPipeline>(vk, device, pAllocator));
40 }
41
createComputePipeline(const DeviceInterface & vk,VkDevice device,VkPipelineCache pipelineCache,const VkComputePipelineCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator)42 Move<VkPipeline> createComputePipeline (const DeviceInterface& vk,
43 VkDevice device,
44 VkPipelineCache pipelineCache,
45 const VkComputePipelineCreateInfo* pCreateInfo,
46 const VkAllocationCallbacks* pAllocator)
47 {
48 VkPipeline object = 0;
49 VK_CHECK(vk.createComputePipelines(device, pipelineCache, 1u, pCreateInfo, pAllocator, &object));
50 return Move<VkPipeline>(check<VkPipeline>(object), Deleter<VkPipeline>(vk, device, pAllocator));
51 }
52
createRayTracingPipelineNV(const DeviceInterface & vk,VkDevice device,VkPipelineCache pipelineCache,const VkRayTracingPipelineCreateInfoNV * pCreateInfo,const VkAllocationCallbacks * pAllocator)53 Move<VkPipeline> createRayTracingPipelineNV (const DeviceInterface& vk,
54 VkDevice device,
55 VkPipelineCache pipelineCache,
56 const VkRayTracingPipelineCreateInfoNV* pCreateInfo,
57 const VkAllocationCallbacks* pAllocator)
58 {
59 VkPipeline object = 0;
60 VK_CHECK(vk.createRayTracingPipelinesNV(device, pipelineCache, 1u, pCreateInfo, pAllocator, &object));
61 return Move<VkPipeline>(check<VkPipeline>(object), Deleter<VkPipeline>(vk, device, pAllocator));
62 }
63
createRayTracingPipelineKHR(const DeviceInterface & vk,VkDevice device,VkDeferredOperationKHR deferredOperation,VkPipelineCache pipelineCache,const VkRayTracingPipelineCreateInfoKHR * pCreateInfo,const VkAllocationCallbacks * pAllocator)64 Move<VkPipeline> createRayTracingPipelineKHR (const DeviceInterface& vk,
65 VkDevice device,
66 VkDeferredOperationKHR deferredOperation,
67 VkPipelineCache pipelineCache,
68 const VkRayTracingPipelineCreateInfoKHR* pCreateInfo,
69 const VkAllocationCallbacks* pAllocator)
70 {
71 VkPipeline object = 0;
72 VK_CHECK(vk.createRayTracingPipelinesKHR(device, deferredOperation, pipelineCache, 1u, pCreateInfo, pAllocator, &object));
73 return Move<VkPipeline>(check<VkPipeline>(object), Deleter<VkPipeline>(vk, device, pAllocator));
74 }
75
allocateCommandBuffer(const DeviceInterface & vk,VkDevice device,const VkCommandBufferAllocateInfo * pAllocateInfo)76 Move<VkCommandBuffer> allocateCommandBuffer (const DeviceInterface& vk, VkDevice device, const VkCommandBufferAllocateInfo* pAllocateInfo)
77 {
78 VkCommandBuffer object = 0;
79 DE_ASSERT(pAllocateInfo->commandBufferCount == 1u);
80 VK_CHECK(vk.allocateCommandBuffers(device, pAllocateInfo, &object));
81 return Move<VkCommandBuffer>(check<VkCommandBuffer>(object), Deleter<VkCommandBuffer>(vk, device, pAllocateInfo->commandPool));
82 }
83
allocateDescriptorSet(const DeviceInterface & vk,VkDevice device,const VkDescriptorSetAllocateInfo * pAllocateInfo)84 Move<VkDescriptorSet> allocateDescriptorSet (const DeviceInterface& vk, VkDevice device, const VkDescriptorSetAllocateInfo* pAllocateInfo)
85 {
86 VkDescriptorSet object = 0;
87 DE_ASSERT(pAllocateInfo->descriptorSetCount == 1u);
88 VK_CHECK(vk.allocateDescriptorSets(device, pAllocateInfo, &object));
89 return Move<VkDescriptorSet>(check<VkDescriptorSet>(object), Deleter<VkDescriptorSet>(vk, device, pAllocateInfo->descriptorPool));
90 }
91
createSemaphore(const DeviceInterface & vk,VkDevice device,VkSemaphoreCreateFlags flags,const VkAllocationCallbacks * pAllocator)92 Move<VkSemaphore> createSemaphore (const DeviceInterface& vk,
93 VkDevice device,
94 VkSemaphoreCreateFlags flags,
95 const VkAllocationCallbacks* pAllocator)
96 {
97 const VkSemaphoreCreateInfo createInfo =
98 {
99 VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO,
100 DE_NULL,
101
102 flags
103 };
104
105 return createSemaphore(vk, device, &createInfo, pAllocator);
106 }
107
createSemaphoreType(const DeviceInterface & vk,VkDevice device,VkSemaphoreType type,VkSemaphoreCreateFlags flags,const deUint64 initialValue,const VkAllocationCallbacks * pAllocator)108 Move<VkSemaphore> createSemaphoreType (const DeviceInterface& vk,
109 VkDevice device,
110 VkSemaphoreType type,
111 VkSemaphoreCreateFlags flags,
112 const deUint64 initialValue,
113 const VkAllocationCallbacks* pAllocator)
114 {
115 const VkSemaphoreTypeCreateInfo createTypeInfo =
116 {
117 VK_STRUCTURE_TYPE_SEMAPHORE_TYPE_CREATE_INFO,
118 DE_NULL,
119
120 type,
121 initialValue,
122 };
123 const VkSemaphoreCreateInfo createInfo =
124 {
125 VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO,
126 &createTypeInfo,
127
128 flags
129 };
130
131 return createSemaphore(vk, device, &createInfo, pAllocator);
132 }
133
createFence(const DeviceInterface & vk,VkDevice device,VkFenceCreateFlags flags,const VkAllocationCallbacks * pAllocator)134 Move<VkFence> createFence (const DeviceInterface& vk,
135 VkDevice device,
136 VkFenceCreateFlags flags,
137 const VkAllocationCallbacks* pAllocator)
138 {
139 const VkFenceCreateInfo createInfo =
140 {
141 VK_STRUCTURE_TYPE_FENCE_CREATE_INFO,
142 DE_NULL,
143
144 flags
145 };
146
147 return createFence(vk, device, &createInfo, pAllocator);
148 }
149
createCommandPool(const DeviceInterface & vk,VkDevice device,VkCommandPoolCreateFlags flags,deUint32 queueFamilyIndex,const VkAllocationCallbacks * pAllocator)150 Move<VkCommandPool> createCommandPool (const DeviceInterface& vk,
151 VkDevice device,
152 VkCommandPoolCreateFlags flags,
153 deUint32 queueFamilyIndex,
154 const VkAllocationCallbacks* pAllocator)
155 {
156 const VkCommandPoolCreateInfo createInfo =
157 {
158 VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,
159 DE_NULL,
160
161 flags,
162 queueFamilyIndex
163 };
164
165 return createCommandPool(vk, device, &createInfo, pAllocator);
166 }
167
allocateCommandBuffer(const DeviceInterface & vk,VkDevice device,VkCommandPool commandPool,VkCommandBufferLevel level)168 Move<VkCommandBuffer> allocateCommandBuffer (const DeviceInterface& vk,
169 VkDevice device,
170 VkCommandPool commandPool,
171 VkCommandBufferLevel level)
172 {
173 const VkCommandBufferAllocateInfo allocInfo =
174 {
175 VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,
176 DE_NULL,
177
178 commandPool,
179 level,
180 1
181 };
182
183 return allocateCommandBuffer(vk, device, &allocInfo);
184 }
185
createEvent(const DeviceInterface & vk,VkDevice device,VkEventCreateFlags flags,const VkAllocationCallbacks * pAllocateInfo)186 Move<VkEvent> createEvent (const DeviceInterface& vk,
187 VkDevice device,
188 VkEventCreateFlags flags,
189 const VkAllocationCallbacks* pAllocateInfo)
190 {
191 const VkEventCreateInfo createInfo =
192 {
193 VK_STRUCTURE_TYPE_EVENT_CREATE_INFO,
194 DE_NULL,
195
196 flags
197 };
198
199 return createEvent(vk, device, &createInfo, pAllocateInfo);
200 }
201
202 } // vk
203