blob: d9cdc9b23a5f57fcb65ebe046668293dfbaf10b8 [file] [log] [blame]
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001// VK tests
Chia-I Wu82bff272014-12-27 14:12:52 +08002//
3// Copyright (C) 2014 LunarG, Inc.
4//
5// Permission is hereby granted, free of charge, to any person obtaining a
6// copy of this software and associated documentation files (the "Software"),
7// to deal in the Software without restriction, including without limitation
8// the rights to use, copy, modify, merge, publish, distribute, sublicense,
9// and/or sell copies of the Software, and to permit persons to whom the
10// Software is furnished to do so, subject to the following conditions:
11//
12// The above copyright notice and this permission notice shall be included
13// in all copies or substantial portions of the Software.
14//
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21// DEALINGS IN THE SOFTWARE.
22
23#include <iostream>
24#include <string.h> // memset(), memcmp()
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060025#include "vktestbinding.h"
Chia-I Wu82bff272014-12-27 14:12:52 +080026
27namespace {
Chia-I Wu82bff272014-12-27 14:12:52 +080028#define DERIVED_OBJECT_INIT(create_func, ...) \
29 do { \
30 obj_type obj; \
Mark Lobodzinskicf26e072015-04-16 11:44:05 -050031 if (EXPECT(create_func(__VA_ARGS__, &obj) == VK_SUCCESS)) \
Chia-I Wu82bff272014-12-27 14:12:52 +080032 base_type::init(obj); \
33 } while (0)
34
35#define STRINGIFY(x) #x
36#define EXPECT(expr) ((expr) ? true : expect_failure(STRINGIFY(expr), __FILE__, __LINE__, __FUNCTION__))
Mark Lobodzinskicf26e072015-04-16 11:44:05 -050037#define DEV_INIT(device) dev_ = &device;
38
39
Chia-I Wu82bff272014-12-27 14:12:52 +080040
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060041vk_testing::ErrorCallback error_callback;
Chia-I Wu82bff272014-12-27 14:12:52 +080042
43bool expect_failure(const char *expr, const char *file, unsigned int line, const char *function)
44{
45 if (error_callback) {
46 error_callback(expr, file, line, function);
47 } else {
48 std::cerr << file << ":" << line << ": " << function <<
49 ": Expectation `" << expr << "' failed.\n";
50 }
51
52 return false;
53}
54
55template<class T, class S>
56std::vector<T> make_objects(const std::vector<S> &v)
57{
58 std::vector<T> objs;
59 objs.reserve(v.size());
60 for (typename std::vector<S>::const_iterator it = v.begin(); it != v.end(); it++)
61 objs.push_back((*it)->obj());
62 return objs;
63}
64
65template<typename T>
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060066std::vector<T> get_info(VkPhysicalGpu gpu, VkPhysicalGpuInfoType type, size_t min_elems)
Chia-I Wu82bff272014-12-27 14:12:52 +080067{
68 std::vector<T> info;
Jon Ashburn23bd3822015-02-11 09:36:41 -070069 size_t size;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060070 if (EXPECT(vkGetGpuInfo(gpu, type, &size, NULL) == VK_SUCCESS && size % sizeof(T) == 0)) {
Chia-I Wu82bff272014-12-27 14:12:52 +080071 info.resize(size / sizeof(T));
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060072 if (!EXPECT(vkGetGpuInfo(gpu, type, &size, &info[0]) == VK_SUCCESS && size == info.size() * sizeof(T)))
Chia-I Wu82bff272014-12-27 14:12:52 +080073 info.clear();
74 }
75
76 if (info.size() < min_elems)
77 info.resize(min_elems);
78
79 return info;
80}
81
82template<typename T>
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060083std::vector<T> get_info(VkBaseObject obj, VkObjectInfoType type, size_t min_elems)
Chia-I Wu82bff272014-12-27 14:12:52 +080084{
85 std::vector<T> info;
Jon Ashburn23bd3822015-02-11 09:36:41 -070086 size_t size;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060087 if (EXPECT(vkGetObjectInfo(obj, type, &size, NULL) == VK_SUCCESS && size % sizeof(T) == 0)) {
Chia-I Wu82bff272014-12-27 14:12:52 +080088 info.resize(size / sizeof(T));
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060089 if (!EXPECT(vkGetObjectInfo(obj, type, &size, &info[0]) == VK_SUCCESS && size == info.size() * sizeof(T)))
Chia-I Wu82bff272014-12-27 14:12:52 +080090 info.clear();
91 }
92
93 if (info.size() < min_elems)
94 info.resize(min_elems);
95
96 return info;
97}
98
99} // namespace
100
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600101namespace vk_testing {
Chia-I Wu82bff272014-12-27 14:12:52 +0800102
103void set_error_callback(ErrorCallback callback)
104{
105 error_callback = callback;
106}
107
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600108VkPhysicalGpuProperties PhysicalGpu::properties() const
Chia-I Wu82bff272014-12-27 14:12:52 +0800109{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600110 return get_info<VkPhysicalGpuProperties>(gpu_, VK_INFO_TYPE_PHYSICAL_GPU_PROPERTIES, 1)[0];
Chia-I Wu82bff272014-12-27 14:12:52 +0800111}
112
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600113VkPhysicalGpuPerformance PhysicalGpu::performance() const
Chia-I Wu82bff272014-12-27 14:12:52 +0800114{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600115 return get_info<VkPhysicalGpuPerformance>(gpu_, VK_INFO_TYPE_PHYSICAL_GPU_PERFORMANCE, 1)[0];
Chia-I Wu82bff272014-12-27 14:12:52 +0800116}
117
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600118std::vector<VkPhysicalGpuQueueProperties> PhysicalGpu::queue_properties() const
Chia-I Wu82bff272014-12-27 14:12:52 +0800119{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600120 return get_info<VkPhysicalGpuQueueProperties>(gpu_, VK_INFO_TYPE_PHYSICAL_GPU_QUEUE_PROPERTIES, 0);
Chia-I Wu82bff272014-12-27 14:12:52 +0800121}
122
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600123VkPhysicalGpuMemoryProperties PhysicalGpu::memory_properties() const
Chia-I Wu82bff272014-12-27 14:12:52 +0800124{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600125 return get_info<VkPhysicalGpuMemoryProperties>(gpu_, VK_INFO_TYPE_PHYSICAL_GPU_MEMORY_PROPERTIES, 1)[0];
Chia-I Wu82bff272014-12-27 14:12:52 +0800126}
127
128std::vector<const char *> PhysicalGpu::layers(std::vector<char> &buf) const
129{
130 const size_t max_layer_count = 16;
131 const size_t max_string_size = 256;
132
133 buf.resize(max_layer_count * max_string_size);
134
135 std::vector<const char *> layers;
136 layers.reserve(max_layer_count);
137 for (size_t i = 0; i < max_layer_count; i++)
138 layers.push_back(&buf[0] + max_string_size * i);
139
140 char * const *out = const_cast<char * const *>(&layers[0]);
141 size_t count;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600142 if (!EXPECT(vkEnumerateLayers(gpu_, max_layer_count, max_string_size, &count, out, NULL) == VK_SUCCESS))
Chia-I Wu82bff272014-12-27 14:12:52 +0800143 count = 0;
144 layers.resize(count);
145
146 return layers;
147}
148
149std::vector<const char *> PhysicalGpu::extensions() const
150{
Tobin Ehlisf6cc4e72015-04-16 10:13:25 -0600151 // TODO : Should fill this out using GetGlobalExtensionInfo to query count
152 // Then fill in extensions based on that count
Chia-I Wu82bff272014-12-27 14:12:52 +0800153 static const char *known_exts[] = {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600154 "VK_WSI_X11",
Chia-I Wu82bff272014-12-27 14:12:52 +0800155 };
156
157 std::vector<const char *> exts;
158 for (int i = 0; i < sizeof(known_exts) / sizeof(known_exts[0]); i++) {
Tobin Ehlisf6cc4e72015-04-16 10:13:25 -0600159// VkResult err = vkGetExtensionSupport(gpu_, known_exts[i]);
160// if (err == VK_SUCCESS)
161 exts.push_back(known_exts[i]);
Chia-I Wu82bff272014-12-27 14:12:52 +0800162 }
163
164 return exts;
165}
166
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600167VkGpuCompatibilityInfo PhysicalGpu::compatibility(const PhysicalGpu &other) const
Chia-I Wu82bff272014-12-27 14:12:52 +0800168{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600169 VkGpuCompatibilityInfo data;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600170 if (!EXPECT(vkGetMultiGpuCompatibility(gpu_, other.gpu_, &data) == VK_SUCCESS))
Chia-I Wu82bff272014-12-27 14:12:52 +0800171 memset(&data, 0, sizeof(data));
172
173 return data;
174}
175
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600176void BaseObject::init(VkBaseObject obj, bool own)
Chia-I Wu82bff272014-12-27 14:12:52 +0800177{
178 EXPECT(!initialized());
179 reinit(obj, own);
180}
181
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600182void BaseObject::reinit(VkBaseObject obj, bool own)
Chia-I Wu82bff272014-12-27 14:12:52 +0800183{
184 obj_ = obj;
185 own_obj_ = own;
186}
187
188uint32_t BaseObject::memory_allocation_count() const
189{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600190 return get_info<uint32_t>(obj_, VK_INFO_TYPE_MEMORY_ALLOCATION_COUNT, 1)[0];
Chia-I Wu82bff272014-12-27 14:12:52 +0800191}
192
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600193std::vector<VkMemoryRequirements> BaseObject::memory_requirements() const
Chia-I Wu82bff272014-12-27 14:12:52 +0800194{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600195 VkResult err;
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -0600196 uint32_t num_allocations = 0;
197 size_t num_alloc_size = sizeof(num_allocations);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600198 err = vkGetObjectInfo(obj_, VK_INFO_TYPE_MEMORY_ALLOCATION_COUNT,
Jon Ashburna9ae3832015-01-16 09:37:43 -0700199 &num_alloc_size, &num_allocations);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600200 EXPECT(err == VK_SUCCESS && num_alloc_size == sizeof(num_allocations));
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600201 std::vector<VkMemoryRequirements> info =
202 get_info<VkMemoryRequirements>(obj_, VK_INFO_TYPE_MEMORY_REQUIREMENTS, 0);
Jon Ashburna9ae3832015-01-16 09:37:43 -0700203 EXPECT(info.size() == num_allocations);
Chia-I Wu82bff272014-12-27 14:12:52 +0800204 if (info.size() == 1 && !info[0].size)
205 info.clear();
206
207 return info;
208}
209
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600210void Object::init(VkObject obj, bool own)
Chia-I Wu82bff272014-12-27 14:12:52 +0800211{
212 BaseObject::init(obj, own);
213 mem_alloc_count_ = memory_allocation_count();
214}
215
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600216void Object::reinit(VkObject obj, bool own)
Chia-I Wu82bff272014-12-27 14:12:52 +0800217{
218 cleanup();
219 BaseObject::reinit(obj, own);
220 mem_alloc_count_ = memory_allocation_count();
221}
222
223void Object::cleanup()
224{
225 if (!initialized())
226 return;
227
Tony Barbour2b5fb342015-04-09 16:00:18 -0600228 if(bound) {
Mark Lobodzinskicf26e072015-04-16 11:44:05 -0500229 unbind_memory(*dev_);
Tony Barbour2b5fb342015-04-09 16:00:18 -0600230 }
Chia-I Wu82bff272014-12-27 14:12:52 +0800231
232 if (internal_mems_) {
233 delete[] internal_mems_;
234 internal_mems_ = NULL;
235 primary_mem_ = NULL;
236 }
237
238 mem_alloc_count_ = 0;
239
240 if (own())
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600241 EXPECT(vkDestroyObject(obj()) == VK_SUCCESS);
Chia-I Wu82bff272014-12-27 14:12:52 +0800242}
243
Mark Lobodzinskicf26e072015-04-16 11:44:05 -0500244void Object::bind_memory(const Device &dev, uint32_t alloc_idx, const GpuMemory &mem, VkGpuSize mem_offset)
Chia-I Wu82bff272014-12-27 14:12:52 +0800245{
Tony Barbour2b5fb342015-04-09 16:00:18 -0600246 bound = true;
Mark Lobodzinskicf26e072015-04-16 11:44:05 -0500247 VkQueue queue = dev.graphics_queues()[0]->obj();
248 EXPECT(vkQueueBindObjectMemory(queue, obj(), alloc_idx, mem.obj(), mem_offset) == VK_SUCCESS);
Chia-I Wu82bff272014-12-27 14:12:52 +0800249}
250
Mark Lobodzinskicf26e072015-04-16 11:44:05 -0500251void Object::bind_memory(const Device &dev, uint32_t alloc_idx, VkGpuSize offset, VkGpuSize size,
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600252 const GpuMemory &mem, VkGpuSize mem_offset)
Chia-I Wu714df452015-01-01 07:55:04 +0800253{
Tony Barbour2b5fb342015-04-09 16:00:18 -0600254 bound = true;
Mark Lobodzinskicf26e072015-04-16 11:44:05 -0500255 VkQueue queue = dev.graphics_queues()[0]->obj();
256 EXPECT(!alloc_idx && vkQueueBindObjectMemoryRange(queue, obj(), 0, offset, size, mem.obj(), mem_offset) == VK_SUCCESS);
Chia-I Wu714df452015-01-01 07:55:04 +0800257}
258
Mark Lobodzinskicf26e072015-04-16 11:44:05 -0500259void Object::unbind_memory(const Device &dev, uint32_t alloc_idx)
Chia-I Wu82bff272014-12-27 14:12:52 +0800260{
Mark Lobodzinskicf26e072015-04-16 11:44:05 -0500261 VkQueue queue = dev.graphics_queues()[0]->obj();
262 EXPECT(vkQueueBindObjectMemory(queue, obj(), alloc_idx, VK_NULL_HANDLE, 0) == VK_SUCCESS);
Chia-I Wu82bff272014-12-27 14:12:52 +0800263}
264
Mark Lobodzinskicf26e072015-04-16 11:44:05 -0500265void Object::unbind_memory(const Device &dev)
Chia-I Wu82bff272014-12-27 14:12:52 +0800266{
267 for (uint32_t i = 0; i < mem_alloc_count_; i++)
Mark Lobodzinskicf26e072015-04-16 11:44:05 -0500268 unbind_memory(dev, i);
Chia-I Wu82bff272014-12-27 14:12:52 +0800269}
270
Mark Lobodzinski97dcd042015-04-16 08:52:00 -0500271void Object::alloc_memory(const Device &dev)
Chia-I Wu82bff272014-12-27 14:12:52 +0800272{
273 if (!EXPECT(!internal_mems_) || !mem_alloc_count_)
274 return;
275
276 internal_mems_ = new GpuMemory[mem_alloc_count_];
277
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600278 const std::vector<VkMemoryRequirements> mem_reqs = memory_requirements();
Courtney Goeltzenleuchterddcb6192015-04-14 18:48:46 -0600279 VkMemoryAllocInfo info, *next_info = NULL;
Jon Ashburnc6ae13d2015-01-19 15:00:26 -0700280
Chia-I Wu82bff272014-12-27 14:12:52 +0800281 for (int i = 0; i < mem_reqs.size(); i++) {
Jon Ashburn5567c812015-01-20 08:50:12 -0700282 info = GpuMemory::alloc_info(mem_reqs[i], next_info);
Mark Lobodzinski97dcd042015-04-16 08:52:00 -0500283 primary_mem_ = &internal_mems_[i];
Chia-I Wu82bff272014-12-27 14:12:52 +0800284 internal_mems_[i].init(dev, info);
Mark Lobodzinskicf26e072015-04-16 11:44:05 -0500285 bind_memory(dev, i, internal_mems_[i], 0);
Chia-I Wu82bff272014-12-27 14:12:52 +0800286 }
287}
288
Mark Lobodzinskicf26e072015-04-16 11:44:05 -0500289void Object::alloc_memory(const Device &dev, const std::vector<VkGpuMemory> &mems)
Chia-I Wu82bff272014-12-27 14:12:52 +0800290{
291 if (!EXPECT(!internal_mems_) || !mem_alloc_count_)
292 return;
293
294 internal_mems_ = new GpuMemory[mem_alloc_count_];
295
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600296 const std::vector<VkMemoryRequirements> mem_reqs = memory_requirements();
Chia-I Wu82bff272014-12-27 14:12:52 +0800297 if (!EXPECT(mem_reqs.size() == mems.size()))
298 return;
299
300 for (int i = 0; i < mem_reqs.size(); i++) {
301 primary_mem_ = &internal_mems_[i];
302
303 internal_mems_[i].init(mems[i]);
Mark Lobodzinskicf26e072015-04-16 11:44:05 -0500304 bind_memory(dev, i, internal_mems_[i], 0);
Chia-I Wu82bff272014-12-27 14:12:52 +0800305 }
306}
307
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600308std::vector<VkGpuMemory> Object::memories() const
Chia-I Wu82bff272014-12-27 14:12:52 +0800309{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600310 std::vector<VkGpuMemory> mems;
Chia-I Wu82bff272014-12-27 14:12:52 +0800311 if (internal_mems_) {
312 mems.reserve(mem_alloc_count_);
313 for (uint32_t i = 0; i < mem_alloc_count_; i++)
314 mems.push_back(internal_mems_[i].obj());
315 }
316
317 return mems;
318}
319
320Device::~Device()
321{
322 if (!initialized())
323 return;
324
325 for (int i = 0; i < QUEUE_COUNT; i++) {
326 for (std::vector<Queue *>::iterator it = queues_[i].begin(); it != queues_[i].end(); it++)
327 delete *it;
328 queues_[i].clear();
329 }
330
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600331 EXPECT(vkDestroyDevice(obj()) == VK_SUCCESS);
Chia-I Wu82bff272014-12-27 14:12:52 +0800332}
333
Chia-I Wu6c099222015-01-06 10:40:45 +0800334void Device::init(bool enable_layers)
Chia-I Wu82bff272014-12-27 14:12:52 +0800335{
336 // request all queues
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600337 const std::vector<VkPhysicalGpuQueueProperties> queue_props = gpu_.queue_properties();
Courtney Goeltzenleuchterddcb6192015-04-14 18:48:46 -0600338 std::vector<VkDeviceQueueCreateInfo> queue_info;
Chia-I Wu82bff272014-12-27 14:12:52 +0800339 queue_info.reserve(queue_props.size());
340 for (int i = 0; i < queue_props.size(); i++) {
Courtney Goeltzenleuchterddcb6192015-04-14 18:48:46 -0600341 VkDeviceQueueCreateInfo qi = {};
Chia-I Wu82bff272014-12-27 14:12:52 +0800342 qi.queueNodeIndex = i;
343 qi.queueCount = queue_props[i].queueCount;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600344 if (queue_props[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) {
Courtney Goeltzenleuchterf3168062015-03-05 18:09:39 -0700345 graphics_queue_node_index_ = i;
346 }
Chia-I Wu82bff272014-12-27 14:12:52 +0800347 queue_info.push_back(qi);
348 }
349
Courtney Goeltzenleuchterddcb6192015-04-14 18:48:46 -0600350 VkLayerCreateInfo layer_info = {};
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600351 layer_info.sType = VK_STRUCTURE_TYPE_LAYER_CREATE_INFO;
Chia-I Wu6c099222015-01-06 10:40:45 +0800352
353 std::vector<const char *> layers;
354 std::vector<char> layer_buf;
355 // request all layers
356 if (enable_layers) {
357 layers = gpu_.layers(layer_buf);
358 layer_info.layerCount = layers.size();
359 layer_info.ppActiveLayerNames = &layers[0];
360 }
Chia-I Wu82bff272014-12-27 14:12:52 +0800361
362 const std::vector<const char *> exts = gpu_.extensions();
363
Courtney Goeltzenleuchterddcb6192015-04-14 18:48:46 -0600364 VkDeviceCreateInfo dev_info = {};
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600365 dev_info.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
Jon Ashburnca930582015-01-22 13:33:15 -0700366 dev_info.pNext = (enable_layers) ? static_cast<void *>(&layer_info) : NULL;
Chia-I Wu82bff272014-12-27 14:12:52 +0800367 dev_info.queueRecordCount = queue_info.size();
368 dev_info.pRequestedQueues = &queue_info[0];
369 dev_info.extensionCount = exts.size();
370 dev_info.ppEnabledExtensionNames = &exts[0];
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600371 dev_info.flags = VK_DEVICE_CREATE_VALIDATION_BIT;
Chia-I Wu82bff272014-12-27 14:12:52 +0800372
373 init(dev_info);
374}
375
Courtney Goeltzenleuchterddcb6192015-04-14 18:48:46 -0600376void Device::init(const VkDeviceCreateInfo &info)
Chia-I Wu82bff272014-12-27 14:12:52 +0800377{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600378 DERIVED_OBJECT_INIT(vkCreateDevice, gpu_.obj(), &info);
Chia-I Wu82bff272014-12-27 14:12:52 +0800379
380 init_queues();
Chia-I Wu82bff272014-12-27 14:12:52 +0800381 init_formats();
382}
383
384void Device::init_queues()
385{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600386 VkResult err;
Courtney Goeltzenleuchterf3168062015-03-05 18:09:39 -0700387 size_t data_size;
388 uint32_t queue_node_count;
Chia-I Wu82bff272014-12-27 14:12:52 +0800389
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600390 err = vkGetGpuInfo(gpu_.obj(), VK_INFO_TYPE_PHYSICAL_GPU_QUEUE_PROPERTIES,
Courtney Goeltzenleuchterf3168062015-03-05 18:09:39 -0700391 &data_size, NULL);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600392 EXPECT(err == VK_SUCCESS);
Chia-I Wu82bff272014-12-27 14:12:52 +0800393
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600394 queue_node_count = data_size / sizeof(VkPhysicalGpuQueueProperties);
Courtney Goeltzenleuchterf3168062015-03-05 18:09:39 -0700395 EXPECT(queue_node_count >= 1);
396
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600397 VkPhysicalGpuQueueProperties queue_props[queue_node_count];
Courtney Goeltzenleuchterf3168062015-03-05 18:09:39 -0700398
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600399 err = vkGetGpuInfo(gpu_.obj(), VK_INFO_TYPE_PHYSICAL_GPU_QUEUE_PROPERTIES,
Courtney Goeltzenleuchterf3168062015-03-05 18:09:39 -0700400 &data_size, queue_props);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600401 EXPECT(err == VK_SUCCESS);
Courtney Goeltzenleuchterf3168062015-03-05 18:09:39 -0700402
403 for (int i = 0; i < queue_node_count; i++) {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600404 VkQueue queue;
Courtney Goeltzenleuchterf3168062015-03-05 18:09:39 -0700405
406 for (int j = 0; j < queue_props[i].queueCount; j++) {
Mark Lobodzinskicf26e072015-04-16 11:44:05 -0500407 // TODO: Need to add support for separate MEMMGR and work queues, including synchronization
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600408 err = vkGetDeviceQueue(obj(), i, j, &queue);
409 EXPECT(err == VK_SUCCESS);
Courtney Goeltzenleuchterf3168062015-03-05 18:09:39 -0700410
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600411 if (queue_props[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) {
Courtney Goeltzenleuchterf3168062015-03-05 18:09:39 -0700412 queues_[GRAPHICS].push_back(new Queue(queue));
413 }
414
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600415 if (queue_props[i].queueFlags & VK_QUEUE_COMPUTE_BIT) {
Courtney Goeltzenleuchterf3168062015-03-05 18:09:39 -0700416 queues_[COMPUTE].push_back(new Queue(queue));
417 }
418
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600419 if (queue_props[i].queueFlags & VK_QUEUE_DMA_BIT) {
Courtney Goeltzenleuchterf3168062015-03-05 18:09:39 -0700420 queues_[DMA].push_back(new Queue(queue));
421 }
Chia-I Wu82bff272014-12-27 14:12:52 +0800422 }
423 }
424
425 EXPECT(!queues_[GRAPHICS].empty() || !queues_[COMPUTE].empty());
426}
427
Chia-I Wu82bff272014-12-27 14:12:52 +0800428void Device::init_formats()
429{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600430 for (int f = VK_FMT_BEGIN_RANGE; f <= VK_FMT_END_RANGE; f++) {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600431 const VkFormat fmt = static_cast<VkFormat>(f);
432 const VkFormatProperties props = format_properties(fmt);
Chia-I Wu82bff272014-12-27 14:12:52 +0800433
Jeremy Hayes2b7e88a2015-01-23 08:51:43 -0700434 if (props.linearTilingFeatures) {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600435 const Format tmp = { fmt, VK_LINEAR_TILING, props.linearTilingFeatures };
Jeremy Hayes2b7e88a2015-01-23 08:51:43 -0700436 formats_.push_back(tmp);
437 }
Chia-I Wu82bff272014-12-27 14:12:52 +0800438
Jeremy Hayes2b7e88a2015-01-23 08:51:43 -0700439 if (props.optimalTilingFeatures) {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600440 const Format tmp = { fmt, VK_OPTIMAL_TILING, props.optimalTilingFeatures };
Jeremy Hayes2b7e88a2015-01-23 08:51:43 -0700441 formats_.push_back(tmp);
Chia-I Wu82bff272014-12-27 14:12:52 +0800442 }
443 }
444
445 EXPECT(!formats_.empty());
446}
447
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600448VkFormatProperties Device::format_properties(VkFormat format)
Chia-I Wu82bff272014-12-27 14:12:52 +0800449{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600450 const VkFormatInfoType type = VK_INFO_TYPE_FORMAT_PROPERTIES;
451 VkFormatProperties data;
Chia-I Wu82bff272014-12-27 14:12:52 +0800452 size_t size = sizeof(data);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600453 if (!EXPECT(vkGetFormatInfo(obj(), format, type, &size, &data) == VK_SUCCESS && size == sizeof(data)))
Chia-I Wu82bff272014-12-27 14:12:52 +0800454 memset(&data, 0, sizeof(data));
455
456 return data;
457}
458
459void Device::wait()
460{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600461 EXPECT(vkDeviceWaitIdle(obj()) == VK_SUCCESS);
Chia-I Wu82bff272014-12-27 14:12:52 +0800462}
463
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600464VkResult Device::wait(const std::vector<const Fence *> &fences, bool wait_all, uint64_t timeout)
Chia-I Wu82bff272014-12-27 14:12:52 +0800465{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600466 const std::vector<VkFence> fence_objs = make_objects<VkFence>(fences);
467 VkResult err = vkWaitForFences(obj(), fence_objs.size(), &fence_objs[0], wait_all, timeout);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600468 EXPECT(err == VK_SUCCESS || err == VK_TIMEOUT);
Chia-I Wu82bff272014-12-27 14:12:52 +0800469
470 return err;
471}
472
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600473void Device::begin_descriptor_pool_update(VkDescriptorUpdateMode mode)
Chia-I Wuf8385062015-01-04 16:27:24 +0800474{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600475 EXPECT(vkBeginDescriptorPoolUpdate(obj(), mode) == VK_SUCCESS);
Chia-I Wuf8385062015-01-04 16:27:24 +0800476}
477
Chia-I Wu8d24b3b2015-03-26 13:14:16 +0800478void Device::end_descriptor_pool_update(CmdBuffer &cmd)
Chia-I Wuf8385062015-01-04 16:27:24 +0800479{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600480 EXPECT(vkEndDescriptorPoolUpdate(obj(), cmd.obj()) == VK_SUCCESS);
Chia-I Wuf8385062015-01-04 16:27:24 +0800481}
482
Courtney Goeltzenleuchter8d49dbd2015-04-07 17:13:38 -0600483void Queue::submit(const std::vector<const CmdBuffer *> &cmds, Fence &fence)
Chia-I Wu82bff272014-12-27 14:12:52 +0800484{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600485 const std::vector<VkCmdBuffer> cmd_objs = make_objects<VkCmdBuffer>(cmds);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600486 EXPECT(vkQueueSubmit(obj(), cmd_objs.size(), &cmd_objs[0], fence.obj()) == VK_SUCCESS);
Chia-I Wu82bff272014-12-27 14:12:52 +0800487}
488
Courtney Goeltzenleuchter8d49dbd2015-04-07 17:13:38 -0600489void Queue::submit(const CmdBuffer &cmd, Fence &fence)
Chia-I Wu82bff272014-12-27 14:12:52 +0800490{
Courtney Goeltzenleuchter8d49dbd2015-04-07 17:13:38 -0600491 submit(std::vector<const CmdBuffer*>(1, &cmd), fence);
Chia-I Wu82bff272014-12-27 14:12:52 +0800492}
493
Courtney Goeltzenleuchter8d49dbd2015-04-07 17:13:38 -0600494void Queue::submit(const CmdBuffer &cmd)
Chia-I Wu82bff272014-12-27 14:12:52 +0800495{
496 Fence fence;
Courtney Goeltzenleuchter8d49dbd2015-04-07 17:13:38 -0600497 submit(cmd, fence);
Chia-I Wu82bff272014-12-27 14:12:52 +0800498}
499
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600500void Queue::add_mem_references(const std::vector<VkGpuMemory> &mem_refs)
Courtney Goeltzenleuchter8d49dbd2015-04-07 17:13:38 -0600501{
Courtney Goeltzenleuchter46962942015-04-16 13:38:46 -0600502 EXPECT(vkQueueAddMemReferences(obj(), mem_refs.size(), &mem_refs[0]) == VK_SUCCESS);
Courtney Goeltzenleuchter8d49dbd2015-04-07 17:13:38 -0600503}
504
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600505void Queue::remove_mem_references(const std::vector<VkGpuMemory> &mem_refs)
Courtney Goeltzenleuchter8d49dbd2015-04-07 17:13:38 -0600506{
Courtney Goeltzenleuchter46962942015-04-16 13:38:46 -0600507 EXPECT(vkQueueRemoveMemReferences(obj(), mem_refs.size(), &mem_refs[0]) == VK_SUCCESS);
Courtney Goeltzenleuchter8d49dbd2015-04-07 17:13:38 -0600508}
Chia-I Wu82bff272014-12-27 14:12:52 +0800509
510void Queue::wait()
511{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600512 EXPECT(vkQueueWaitIdle(obj()) == VK_SUCCESS);
Chia-I Wu82bff272014-12-27 14:12:52 +0800513}
514
Courtney Goeltzenleuchter0d2efef2015-03-25 17:14:29 -0600515void Queue::signal_semaphore(Semaphore &sem)
Chia-I Wu82bff272014-12-27 14:12:52 +0800516{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600517 EXPECT(vkQueueSignalSemaphore(obj(), sem.obj()) == VK_SUCCESS);
Chia-I Wu82bff272014-12-27 14:12:52 +0800518}
519
Courtney Goeltzenleuchter0d2efef2015-03-25 17:14:29 -0600520void Queue::wait_semaphore(Semaphore &sem)
Chia-I Wu82bff272014-12-27 14:12:52 +0800521{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600522 EXPECT(vkQueueWaitSemaphore(obj(), sem.obj()) == VK_SUCCESS);
Chia-I Wu82bff272014-12-27 14:12:52 +0800523}
524
525GpuMemory::~GpuMemory()
526{
527 if (initialized() && own())
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600528 EXPECT(vkFreeMemory(obj()) == VK_SUCCESS);
Chia-I Wu82bff272014-12-27 14:12:52 +0800529}
530
Courtney Goeltzenleuchterddcb6192015-04-14 18:48:46 -0600531void GpuMemory::init(const Device &dev, const VkMemoryAllocInfo &info)
Chia-I Wu82bff272014-12-27 14:12:52 +0800532{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600533 DERIVED_OBJECT_INIT(vkAllocMemory, dev.obj(), &info);
Chia-I Wu82bff272014-12-27 14:12:52 +0800534}
535
Chia-I Wu82bff272014-12-27 14:12:52 +0800536void GpuMemory::init(const Device &dev, size_t size, const void *data)
537{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600538 DERIVED_OBJECT_INIT(vkPinSystemMemory, dev.obj(), data, size);
Chia-I Wu82bff272014-12-27 14:12:52 +0800539}
540
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600541void GpuMemory::init(const Device &dev, const VkMemoryOpenInfo &info)
Chia-I Wu82bff272014-12-27 14:12:52 +0800542{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600543 DERIVED_OBJECT_INIT(vkOpenSharedMemory, dev.obj(), &info);
Chia-I Wu82bff272014-12-27 14:12:52 +0800544}
545
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600546void GpuMemory::init(const Device &dev, const VkPeerMemoryOpenInfo &info)
Chia-I Wu82bff272014-12-27 14:12:52 +0800547{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600548 DERIVED_OBJECT_INIT(vkOpenPeerMemory, dev.obj(), &info);
Chia-I Wu82bff272014-12-27 14:12:52 +0800549}
550
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600551void GpuMemory::set_priority(VkMemoryPriority priority)
Chia-I Wu82bff272014-12-27 14:12:52 +0800552{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600553 EXPECT(vkSetMemoryPriority(obj(), priority) == VK_SUCCESS);
Chia-I Wu82bff272014-12-27 14:12:52 +0800554}
555
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600556const void *GpuMemory::map(VkFlags flags) const
Chia-I Wu82bff272014-12-27 14:12:52 +0800557{
558 void *data;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600559 if (!EXPECT(vkMapMemory(obj(), flags, &data) == VK_SUCCESS))
Chia-I Wu82bff272014-12-27 14:12:52 +0800560 data = NULL;
561
562 return data;
563}
564
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600565void *GpuMemory::map(VkFlags flags)
Chia-I Wu82bff272014-12-27 14:12:52 +0800566{
567 void *data;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600568 if (!EXPECT(vkMapMemory(obj(), flags, &data) == VK_SUCCESS))
Chia-I Wu82bff272014-12-27 14:12:52 +0800569 data = NULL;
570
571 return data;
572}
573
574void GpuMemory::unmap() const
575{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600576 EXPECT(vkUnmapMemory(obj()) == VK_SUCCESS);
Chia-I Wu82bff272014-12-27 14:12:52 +0800577}
578
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600579void Fence::init(const Device &dev, const VkFenceCreateInfo &info)
Chia-I Wu82bff272014-12-27 14:12:52 +0800580{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600581 DERIVED_OBJECT_INIT(vkCreateFence, dev.obj(), &info);
Chia-I Wu82bff272014-12-27 14:12:52 +0800582 alloc_memory(dev);
583}
584
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600585void Semaphore::init(const Device &dev, const VkSemaphoreCreateInfo &info)
Chia-I Wu82bff272014-12-27 14:12:52 +0800586{
Mark Lobodzinskicf26e072015-04-16 11:44:05 -0500587 DEV_INIT(dev);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600588 DERIVED_OBJECT_INIT(vkCreateSemaphore, dev.obj(), &info);
Chia-I Wu82bff272014-12-27 14:12:52 +0800589 alloc_memory(dev);
590}
591
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600592void Semaphore::init(const Device &dev, const VkSemaphoreOpenInfo &info)
Chia-I Wu82bff272014-12-27 14:12:52 +0800593{
Mark Lobodzinskicf26e072015-04-16 11:44:05 -0500594 DEV_INIT(dev);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600595 DERIVED_OBJECT_INIT(vkOpenSharedSemaphore, dev.obj(), &info);
Chia-I Wu82bff272014-12-27 14:12:52 +0800596}
597
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600598void Event::init(const Device &dev, const VkEventCreateInfo &info)
Chia-I Wu82bff272014-12-27 14:12:52 +0800599{
Mark Lobodzinskicf26e072015-04-16 11:44:05 -0500600 DEV_INIT(dev);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600601 DERIVED_OBJECT_INIT(vkCreateEvent, dev.obj(), &info);
Chia-I Wu82bff272014-12-27 14:12:52 +0800602 alloc_memory(dev);
603}
604
605void Event::set()
606{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600607 EXPECT(vkSetEvent(obj()) == VK_SUCCESS);
Chia-I Wu82bff272014-12-27 14:12:52 +0800608}
609
610void Event::reset()
611{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600612 EXPECT(vkResetEvent(obj()) == VK_SUCCESS);
Chia-I Wu82bff272014-12-27 14:12:52 +0800613}
614
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600615void QueryPool::init(const Device &dev, const VkQueryPoolCreateInfo &info)
Chia-I Wu82bff272014-12-27 14:12:52 +0800616{
Mark Lobodzinskicf26e072015-04-16 11:44:05 -0500617 DEV_INIT(dev);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600618 DERIVED_OBJECT_INIT(vkCreateQueryPool, dev.obj(), &info);
Chia-I Wu82bff272014-12-27 14:12:52 +0800619 alloc_memory(dev);
620}
621
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600622VkResult QueryPool::results(uint32_t start, uint32_t count, size_t size, void *data)
Chia-I Wu82bff272014-12-27 14:12:52 +0800623{
624 size_t tmp = size;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600625 VkResult err = vkGetQueryPoolResults(obj(), start, count, &tmp, data);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600626 if (err == VK_SUCCESS) {
Chia-I Wu82bff272014-12-27 14:12:52 +0800627 if (!EXPECT(tmp == size))
628 memset(data, 0, size);
629 } else {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600630 EXPECT(err == VK_NOT_READY);
Chia-I Wu82bff272014-12-27 14:12:52 +0800631 }
632
633 return err;
634}
635
Courtney Goeltzenleuchterddcb6192015-04-14 18:48:46 -0600636void Buffer::init(const Device &dev, const VkBufferCreateInfo &info)
Chia-I Wu714df452015-01-01 07:55:04 +0800637{
638 init_no_mem(dev, info);
Mark Lobodzinski97dcd042015-04-16 08:52:00 -0500639 alloc_memory(dev);
Chia-I Wu714df452015-01-01 07:55:04 +0800640}
641
Courtney Goeltzenleuchterddcb6192015-04-14 18:48:46 -0600642void Buffer::init_no_mem(const Device &dev, const VkBufferCreateInfo &info)
Chia-I Wu714df452015-01-01 07:55:04 +0800643{
Mark Lobodzinskicf26e072015-04-16 11:44:05 -0500644 DEV_INIT(dev);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600645 DERIVED_OBJECT_INIT(vkCreateBuffer, dev.obj(), &info);
Chia-I Wu714df452015-01-01 07:55:04 +0800646 create_info_ = info;
647}
648
Courtney Goeltzenleuchterddcb6192015-04-14 18:48:46 -0600649void BufferView::init(const Device &dev, const VkBufferViewCreateInfo &info)
Chia-I Wu714df452015-01-01 07:55:04 +0800650{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600651 DERIVED_OBJECT_INIT(vkCreateBufferView, dev.obj(), &info);
Chia-I Wu714df452015-01-01 07:55:04 +0800652 alloc_memory(dev);
653}
654
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600655void Image::init(const Device &dev, const VkImageCreateInfo &info)
Chia-I Wu82bff272014-12-27 14:12:52 +0800656{
657 init_no_mem(dev, info);
Mark Lobodzinski97dcd042015-04-16 08:52:00 -0500658 alloc_memory(dev);
Chia-I Wu82bff272014-12-27 14:12:52 +0800659}
660
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600661void Image::init_no_mem(const Device &dev, const VkImageCreateInfo &info)
Chia-I Wu82bff272014-12-27 14:12:52 +0800662{
Mark Lobodzinskicf26e072015-04-16 11:44:05 -0500663 DEV_INIT(dev);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600664 DERIVED_OBJECT_INIT(vkCreateImage, dev.obj(), &info);
Chia-I Wu82bff272014-12-27 14:12:52 +0800665 init_info(dev, info);
666}
667
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600668void Image::init(const Device &dev, const VkPeerImageOpenInfo &info, const VkImageCreateInfo &original_info)
Chia-I Wu82bff272014-12-27 14:12:52 +0800669{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600670 VkImage img;
671 VkGpuMemory mem;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600672 EXPECT(vkOpenPeerImage(dev.obj(), &info, &img, &mem) == VK_SUCCESS);
Chia-I Wu82bff272014-12-27 14:12:52 +0800673 Object::init(img);
674
675 init_info(dev, original_info);
Mark Lobodzinskicf26e072015-04-16 11:44:05 -0500676 alloc_memory(dev, std::vector<VkGpuMemory>(1, mem));
Chia-I Wu82bff272014-12-27 14:12:52 +0800677}
678
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600679void Image::init_info(const Device &dev, const VkImageCreateInfo &info)
Chia-I Wu82bff272014-12-27 14:12:52 +0800680{
681 create_info_ = info;
682
683 for (std::vector<Device::Format>::const_iterator it = dev.formats().begin(); it != dev.formats().end(); it++) {
684 if (memcmp(&it->format, &create_info_.format, sizeof(it->format)) == 0 && it->tiling == create_info_.tiling) {
685 format_features_ = it->features;
686 break;
687 }
688 }
689}
690
Mark Lobodzinskicf26e072015-04-16 11:44:05 -0500691void Image::bind_memory(const Device &dev, uint32_t alloc_idx, const VkImageMemoryBindInfo &info,
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600692 const GpuMemory &mem, VkGpuSize mem_offset)
Chia-I Wu714df452015-01-01 07:55:04 +0800693{
Mark Lobodzinskicf26e072015-04-16 11:44:05 -0500694 VkQueue queue = dev.graphics_queues()[0]->obj();
695 EXPECT(!alloc_idx && vkQueueBindImageMemoryRange(queue, obj(), 0, &info, mem.obj(), mem_offset) == VK_SUCCESS);
Chia-I Wu714df452015-01-01 07:55:04 +0800696}
697
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600698VkSubresourceLayout Image::subresource_layout(const VkImageSubresource &subres) const
Chia-I Wu82bff272014-12-27 14:12:52 +0800699{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600700 const VkSubresourceInfoType type = VK_INFO_TYPE_SUBRESOURCE_LAYOUT;
701 VkSubresourceLayout data;
Chia-I Wu82bff272014-12-27 14:12:52 +0800702 size_t size = sizeof(data);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600703 if (!EXPECT(vkGetImageSubresourceInfo(obj(), &subres, type, &size, &data) == VK_SUCCESS && size == sizeof(data)))
Chia-I Wu82bff272014-12-27 14:12:52 +0800704 memset(&data, 0, sizeof(data));
705
706 return data;
707}
708
709bool Image::transparent() const
710{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600711 return (create_info_.tiling == VK_LINEAR_TILING &&
Chia-I Wu82bff272014-12-27 14:12:52 +0800712 create_info_.samples == 1 &&
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600713 !(create_info_.usage & (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT |
714 VK_IMAGE_USAGE_DEPTH_STENCIL_BIT)));
Chia-I Wu82bff272014-12-27 14:12:52 +0800715}
716
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600717void ImageView::init(const Device &dev, const VkImageViewCreateInfo &info)
Chia-I Wu82bff272014-12-27 14:12:52 +0800718{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600719 DERIVED_OBJECT_INIT(vkCreateImageView, dev.obj(), &info);
Chia-I Wu82bff272014-12-27 14:12:52 +0800720 alloc_memory(dev);
721}
722
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600723void ColorAttachmentView::init(const Device &dev, const VkColorAttachmentViewCreateInfo &info)
Chia-I Wu82bff272014-12-27 14:12:52 +0800724{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600725 DERIVED_OBJECT_INIT(vkCreateColorAttachmentView, dev.obj(), &info);
Chia-I Wu82bff272014-12-27 14:12:52 +0800726 alloc_memory(dev);
727}
728
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600729void DepthStencilView::init(const Device &dev, const VkDepthStencilViewCreateInfo &info)
Chia-I Wu82bff272014-12-27 14:12:52 +0800730{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600731 DERIVED_OBJECT_INIT(vkCreateDepthStencilView, dev.obj(), &info);
Chia-I Wu82bff272014-12-27 14:12:52 +0800732 alloc_memory(dev);
733}
734
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600735void Shader::init(const Device &dev, const VkShaderCreateInfo &info)
Chia-I Wu82bff272014-12-27 14:12:52 +0800736{
Mark Lobodzinskicf26e072015-04-16 11:44:05 -0500737 DEV_INIT(dev);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600738 DERIVED_OBJECT_INIT(vkCreateShader, dev.obj(), &info);
Chia-I Wu82bff272014-12-27 14:12:52 +0800739}
740
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600741VkResult Shader::init_try(const Device &dev, const VkShaderCreateInfo &info)
Chia-I Wu82bff272014-12-27 14:12:52 +0800742{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600743 VkShader sh;
744 VkResult err = vkCreateShader(dev.obj(), &info, &sh);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600745 if (err == VK_SUCCESS)
Chia-I Wu82bff272014-12-27 14:12:52 +0800746 Object::init(sh);
747
748 return err;
749}
750
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600751void Pipeline::init(const Device &dev, const VkGraphicsPipelineCreateInfo &info)
Chia-I Wu82bff272014-12-27 14:12:52 +0800752{
Mark Lobodzinskicf26e072015-04-16 11:44:05 -0500753 DEV_INIT(dev);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600754 DERIVED_OBJECT_INIT(vkCreateGraphicsPipeline, dev.obj(), &info);
Chia-I Wu82bff272014-12-27 14:12:52 +0800755 alloc_memory(dev);
756}
757
Courtney Goeltzenleuchter32876a12015-03-25 15:37:49 -0600758void Pipeline::init(
759 const Device &dev,
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600760 const VkGraphicsPipelineCreateInfo &info,
761 const VkPipeline basePipeline)
Courtney Goeltzenleuchter32876a12015-03-25 15:37:49 -0600762{
Mark Lobodzinskicf26e072015-04-16 11:44:05 -0500763 DEV_INIT(dev);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600764 DERIVED_OBJECT_INIT(vkCreateGraphicsPipelineDerivative, dev.obj(), &info, basePipeline);
Courtney Goeltzenleuchter32876a12015-03-25 15:37:49 -0600765 alloc_memory(dev);
766}
767
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600768void Pipeline::init(const Device &dev, const VkComputePipelineCreateInfo &info)
Chia-I Wu82bff272014-12-27 14:12:52 +0800769{
Mark Lobodzinskicf26e072015-04-16 11:44:05 -0500770 DEV_INIT(dev);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600771 DERIVED_OBJECT_INIT(vkCreateComputePipeline, dev.obj(), &info);
Chia-I Wu82bff272014-12-27 14:12:52 +0800772 alloc_memory(dev);
773}
774
775void Pipeline::init(const Device&dev, size_t size, const void *data)
776{
Mark Lobodzinskicf26e072015-04-16 11:44:05 -0500777 DEV_INIT(dev);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600778 DERIVED_OBJECT_INIT(vkLoadPipeline, dev.obj(), size, data);
Chia-I Wu82bff272014-12-27 14:12:52 +0800779 alloc_memory(dev);
780}
781
Courtney Goeltzenleuchter32876a12015-03-25 15:37:49 -0600782void Pipeline::init(
783 const Device&dev,
784 size_t size,
785 const void *data,
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600786 const VkPipeline basePipeline)
Courtney Goeltzenleuchter32876a12015-03-25 15:37:49 -0600787{
Mark Lobodzinskicf26e072015-04-16 11:44:05 -0500788 DEV_INIT(dev);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600789 DERIVED_OBJECT_INIT(vkLoadPipelineDerivative, dev.obj(), size, data, basePipeline);
Courtney Goeltzenleuchter32876a12015-03-25 15:37:49 -0600790 alloc_memory(dev);
791}
792
Chia-I Wu82bff272014-12-27 14:12:52 +0800793size_t Pipeline::store(size_t size, void *data)
794{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600795 if (!EXPECT(vkStorePipeline(obj(), &size, data) == VK_SUCCESS))
Chia-I Wu82bff272014-12-27 14:12:52 +0800796 size = 0;
797
798 return size;
799}
800
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600801void Sampler::init(const Device &dev, const VkSamplerCreateInfo &info)
Chia-I Wu82bff272014-12-27 14:12:52 +0800802{
Mark Lobodzinskicf26e072015-04-16 11:44:05 -0500803 DEV_INIT(dev);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600804 DERIVED_OBJECT_INIT(vkCreateSampler, dev.obj(), &info);
Chia-I Wu82bff272014-12-27 14:12:52 +0800805 alloc_memory(dev);
806}
807
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600808void DescriptorSetLayout::init(const Device &dev, const VkDescriptorSetLayoutCreateInfo &info)
Chia-I Wu82bff272014-12-27 14:12:52 +0800809{
Mark Lobodzinskicf26e072015-04-16 11:44:05 -0500810 DEV_INIT(dev);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600811 DERIVED_OBJECT_INIT(vkCreateDescriptorSetLayout, dev.obj(), &info);
Chia-I Wuf8385062015-01-04 16:27:24 +0800812 alloc_memory(dev);
Chia-I Wu82bff272014-12-27 14:12:52 +0800813}
814
Chia-I Wu7732cb22015-03-26 15:27:55 +0800815void DescriptorSetLayoutChain::init(const Device &dev, const std::vector<const DescriptorSetLayout *> &layouts)
Chia-I Wu82bff272014-12-27 14:12:52 +0800816{
Mark Lobodzinskicf26e072015-04-16 11:44:05 -0500817 DEV_INIT(dev);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600818 const std::vector<VkDescriptorSetLayout> layout_objs = make_objects<VkDescriptorSetLayout>(layouts);
Chia-I Wu7732cb22015-03-26 15:27:55 +0800819
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600820 DERIVED_OBJECT_INIT(vkCreateDescriptorSetLayoutChain, dev.obj(), layout_objs.size(), &layout_objs[0]);
Chia-I Wu7732cb22015-03-26 15:27:55 +0800821 alloc_memory(dev);
Chia-I Wu82bff272014-12-27 14:12:52 +0800822}
823
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600824void DescriptorPool::init(const Device &dev, VkDescriptorPoolUsage usage,
825 uint32_t max_sets, const VkDescriptorPoolCreateInfo &info)
Chia-I Wu82bff272014-12-27 14:12:52 +0800826{
Mark Lobodzinskicf26e072015-04-16 11:44:05 -0500827 DEV_INIT(dev);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600828 DERIVED_OBJECT_INIT(vkCreateDescriptorPool, dev.obj(), usage, max_sets, &info);
Chia-I Wuf8385062015-01-04 16:27:24 +0800829 alloc_memory(dev);
Chia-I Wu82bff272014-12-27 14:12:52 +0800830}
831
Chia-I Wudee95612015-03-26 15:23:52 +0800832void DescriptorPool::reset()
Chia-I Wu82bff272014-12-27 14:12:52 +0800833{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600834 EXPECT(vkResetDescriptorPool(obj()) == VK_SUCCESS);
Chia-I Wu82bff272014-12-27 14:12:52 +0800835}
836
Mark Lobodzinskicf26e072015-04-16 11:44:05 -0500837std::vector<DescriptorSet *> DescriptorPool::alloc_sets(const Device &dev, VkDescriptorSetUsage usage, const std::vector<const DescriptorSetLayout *> &layouts)
Chia-I Wu82bff272014-12-27 14:12:52 +0800838{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600839 const std::vector<VkDescriptorSetLayout> layout_objs = make_objects<VkDescriptorSetLayout>(layouts);
Chia-I Wuf8385062015-01-04 16:27:24 +0800840
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600841 std::vector<VkDescriptorSet> set_objs;
Chia-I Wuf8385062015-01-04 16:27:24 +0800842 set_objs.resize(layout_objs.size());
843
844 uint32_t set_count;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600845 VkResult err = vkAllocDescriptorSets(obj(), usage, layout_objs.size(), &layout_objs[0], &set_objs[0], &set_count);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600846 if (err == VK_SUCCESS)
Chia-I Wuf8385062015-01-04 16:27:24 +0800847 EXPECT(set_count == set_objs.size());
848 set_objs.resize(set_count);
849
850 std::vector<DescriptorSet *> sets;
851 sets.reserve(set_count);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600852 for (std::vector<VkDescriptorSet>::const_iterator it = set_objs.begin(); it != set_objs.end(); it++) {
Chia-I Wuf8385062015-01-04 16:27:24 +0800853 // do descriptor sets need memories bound?
Mark Lobodzinskicf26e072015-04-16 11:44:05 -0500854 DescriptorSet *descriptorSet = new DescriptorSet(*it);
855 descriptorSet->dev_ = &dev;
856 sets.push_back(descriptorSet);
Chia-I Wuf8385062015-01-04 16:27:24 +0800857 }
Chia-I Wuf8385062015-01-04 16:27:24 +0800858 return sets;
859}
860
Mark Lobodzinskicf26e072015-04-16 11:44:05 -0500861std::vector<DescriptorSet *> DescriptorPool::alloc_sets(const Device &dev, VkDescriptorSetUsage usage, const DescriptorSetLayout &layout, uint32_t count)
Chia-I Wuf8385062015-01-04 16:27:24 +0800862{
Mark Lobodzinskicf26e072015-04-16 11:44:05 -0500863 return alloc_sets(dev, usage, std::vector<const DescriptorSetLayout *>(count, &layout));
Chia-I Wuf8385062015-01-04 16:27:24 +0800864}
865
Mark Lobodzinskicf26e072015-04-16 11:44:05 -0500866DescriptorSet *DescriptorPool::alloc_sets(const Device &dev, VkDescriptorSetUsage usage, const DescriptorSetLayout &layout)
Chia-I Wuf8385062015-01-04 16:27:24 +0800867{
Mark Lobodzinskicf26e072015-04-16 11:44:05 -0500868 std::vector<DescriptorSet *> set = alloc_sets(dev, usage, layout, 1);
Chia-I Wuf8385062015-01-04 16:27:24 +0800869 return (set.empty()) ? NULL : set[0];
870}
871
Chia-I Wu8d24b3b2015-03-26 13:14:16 +0800872void DescriptorPool::clear_sets(const std::vector<DescriptorSet *> &sets)
Chia-I Wuf8385062015-01-04 16:27:24 +0800873{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600874 const std::vector<VkDescriptorSet> set_objs = make_objects<VkDescriptorSet>(sets);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600875 vkClearDescriptorSets(obj(), set_objs.size(), &set_objs[0]);
Chia-I Wuf8385062015-01-04 16:27:24 +0800876}
877
Chia-I Wu7732cb22015-03-26 15:27:55 +0800878void DescriptorSet::update(const std::vector<const void *> &update_array)
Chia-I Wuf8385062015-01-04 16:27:24 +0800879{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600880 vkUpdateDescriptors(obj(), update_array.size(), const_cast<const void **>(&update_array[0]));
Chia-I Wu82bff272014-12-27 14:12:52 +0800881}
882
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600883void DynamicVpStateObject::init(const Device &dev, const VkDynamicVpStateCreateInfo &info)
Chia-I Wu82bff272014-12-27 14:12:52 +0800884{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600885 DERIVED_OBJECT_INIT(vkCreateDynamicViewportState, dev.obj(), &info);
Chia-I Wu82bff272014-12-27 14:12:52 +0800886 alloc_memory(dev);
887}
888
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600889void DynamicRsStateObject::init(const Device &dev, const VkDynamicRsStateCreateInfo &info)
Chia-I Wu82bff272014-12-27 14:12:52 +0800890{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600891 DERIVED_OBJECT_INIT(vkCreateDynamicRasterState, dev.obj(), &info);
Chia-I Wu82bff272014-12-27 14:12:52 +0800892 alloc_memory(dev);
893}
894
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600895void DynamicCbStateObject::init(const Device &dev, const VkDynamicCbStateCreateInfo &info)
Chia-I Wu82bff272014-12-27 14:12:52 +0800896{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600897 DERIVED_OBJECT_INIT(vkCreateDynamicColorBlendState, dev.obj(), &info);
Chia-I Wu82bff272014-12-27 14:12:52 +0800898 alloc_memory(dev);
899}
900
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600901void DynamicDsStateObject::init(const Device &dev, const VkDynamicDsStateCreateInfo &info)
Chia-I Wu82bff272014-12-27 14:12:52 +0800902{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600903 DERIVED_OBJECT_INIT(vkCreateDynamicDepthStencilState, dev.obj(), &info);
Chia-I Wu82bff272014-12-27 14:12:52 +0800904 alloc_memory(dev);
905}
906
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600907void CmdBuffer::init(const Device &dev, const VkCmdBufferCreateInfo &info)
Chia-I Wu82bff272014-12-27 14:12:52 +0800908{
Mark Lobodzinskicf26e072015-04-16 11:44:05 -0500909 DEV_INIT(dev);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600910 DERIVED_OBJECT_INIT(vkCreateCommandBuffer, dev.obj(), &info);
Chia-I Wu82bff272014-12-27 14:12:52 +0800911}
912
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600913void CmdBuffer::begin(const VkCmdBufferBeginInfo *info)
Chia-I Wu82bff272014-12-27 14:12:52 +0800914{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600915 EXPECT(vkBeginCommandBuffer(obj(), info) == VK_SUCCESS);
Jeremy Hayese0c3b222015-01-14 16:17:08 -0700916}
917
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600918void CmdBuffer::begin(VkRenderPass renderpass_obj, VkFramebuffer framebuffer_obj)
Jeremy Hayese0c3b222015-01-14 16:17:08 -0700919{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600920 VkCmdBufferBeginInfo info = {};
921 VkCmdBufferGraphicsBeginInfo graphics_cmd_buf_info = {};
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600922 graphics_cmd_buf_info.sType = VK_STRUCTURE_TYPE_CMD_BUFFER_GRAPHICS_BEGIN_INFO;
Tony Barbour901f3bc2015-04-01 17:10:07 -0600923 graphics_cmd_buf_info.pNext = NULL;
Courtney Goeltzenleuchtere3b0f3a2015-04-03 15:25:24 -0600924 graphics_cmd_buf_info.renderPassContinue.renderPass = renderpass_obj;
925 graphics_cmd_buf_info.renderPassContinue.framebuffer = framebuffer_obj;
Tony Barbour901f3bc2015-04-01 17:10:07 -0600926
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600927 info.flags = VK_CMD_BUFFER_OPTIMIZE_GPU_SMALL_BATCH_BIT |
928 VK_CMD_BUFFER_OPTIMIZE_ONE_TIME_SUBMIT_BIT;
929 info.sType = VK_STRUCTURE_TYPE_CMD_BUFFER_BEGIN_INFO;
Jeremy Hayese0c3b222015-01-14 16:17:08 -0700930 info.pNext = &graphics_cmd_buf_info;
931
932 begin(&info);
Chia-I Wu82bff272014-12-27 14:12:52 +0800933}
934
935void CmdBuffer::begin()
936{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600937 VkCmdBufferBeginInfo info = {};
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600938 info.flags = VK_CMD_BUFFER_OPTIMIZE_GPU_SMALL_BATCH_BIT |
939 VK_CMD_BUFFER_OPTIMIZE_ONE_TIME_SUBMIT_BIT;
940 info.sType = VK_STRUCTURE_TYPE_CMD_BUFFER_BEGIN_INFO;
Jeremy Hayese0c3b222015-01-14 16:17:08 -0700941
942 begin(&info);
Chia-I Wu82bff272014-12-27 14:12:52 +0800943}
944
945void CmdBuffer::end()
946{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600947 EXPECT(vkEndCommandBuffer(obj()) == VK_SUCCESS);
Chia-I Wu82bff272014-12-27 14:12:52 +0800948}
949
950void CmdBuffer::reset()
951{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600952 EXPECT(vkResetCommandBuffer(obj()) == VK_SUCCESS);
Chia-I Wu82bff272014-12-27 14:12:52 +0800953}
954
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600955}; // namespace vk_testing