Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1 | // VK tests |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 2 | // |
| 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 Goeltzenleuchter | 992fb4f | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 25 | #include <assert.h> |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 26 | #include "vktestbinding.h" |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 27 | |
| 28 | namespace { |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 29 | |
Courtney Goeltzenleuchter | 992fb4f | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 30 | #define DERIVED_OBJECT_TYPE_INIT(create_func, dev, vk_object_type, ...) \ |
| 31 | do { \ |
| 32 | obj_type obj; \ |
| 33 | dev_ = &dev; \ |
| 34 | if (EXPECT(create_func(dev.obj(), __VA_ARGS__, &obj) == VK_SUCCESS)) \ |
| 35 | base_type::init(obj, vk_object_type); \ |
Mike Stroyan | b050c68 | 2015-04-17 12:36:38 -0600 | [diff] [blame] | 36 | } while (0) |
| 37 | |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 38 | #define STRINGIFY(x) #x |
| 39 | #define EXPECT(expr) ((expr) ? true : expect_failure(STRINGIFY(expr), __FILE__, __LINE__, __FUNCTION__)) |
Mark Lobodzinski | 40f7f40 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 40 | |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 41 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 42 | vk_testing::ErrorCallback error_callback; |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 43 | |
| 44 | bool expect_failure(const char *expr, const char *file, unsigned int line, const char *function) |
| 45 | { |
| 46 | if (error_callback) { |
| 47 | error_callback(expr, file, line, function); |
| 48 | } else { |
| 49 | std::cerr << file << ":" << line << ": " << function << |
| 50 | ": Expectation `" << expr << "' failed.\n"; |
| 51 | } |
| 52 | |
| 53 | return false; |
| 54 | } |
| 55 | |
| 56 | template<class T, class S> |
| 57 | std::vector<T> make_objects(const std::vector<S> &v) |
| 58 | { |
| 59 | std::vector<T> objs; |
| 60 | objs.reserve(v.size()); |
| 61 | for (typename std::vector<S>::const_iterator it = v.begin(); it != v.end(); it++) |
| 62 | objs.push_back((*it)->obj()); |
| 63 | return objs; |
| 64 | } |
| 65 | |
| 66 | template<typename T> |
Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 67 | std::vector<T> get_memory_reqs(VkDevice device, VkObjectType obj_type, VkObject obj, size_t min_elems) |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 68 | { |
| 69 | std::vector<T> info; |
Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 70 | |
| 71 | info.resize((min_elems > 0)?min_elems:1); |
| 72 | if (!EXPECT(vkGetObjectMemoryRequirements(device, obj_type, obj, &info[0]) == VK_SUCCESS)) |
| 73 | info.clear(); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 74 | |
| 75 | if (info.size() < min_elems) |
| 76 | info.resize(min_elems); |
| 77 | |
| 78 | return info; |
| 79 | } |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 80 | } // namespace |
| 81 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 82 | namespace vk_testing { |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 83 | |
| 84 | void set_error_callback(ErrorCallback callback) |
| 85 | { |
| 86 | error_callback = callback; |
| 87 | } |
| 88 | |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 89 | VkPhysicalDeviceProperties PhysicalGpu::properties() const |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 90 | { |
Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 91 | VkPhysicalDeviceProperties info; |
| 92 | |
| 93 | EXPECT(vkGetPhysicalDeviceProperties(gpu_, &info) == VK_SUCCESS); |
| 94 | |
| 95 | return info; |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 96 | } |
| 97 | |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 98 | VkPhysicalDevicePerformance PhysicalGpu::performance() const |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 99 | { |
Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 100 | VkPhysicalDevicePerformance info; |
| 101 | |
| 102 | EXPECT(vkGetPhysicalDevicePerformance(gpu_, &info) == VK_SUCCESS); |
| 103 | |
| 104 | return info; |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 105 | } |
| 106 | |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 107 | std::vector<VkPhysicalDeviceQueueProperties> PhysicalGpu::queue_properties() const |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 108 | { |
Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 109 | std::vector<VkPhysicalDeviceQueueProperties> info; |
| 110 | uint32_t count; |
| 111 | |
| 112 | if (EXPECT(vkGetPhysicalDeviceQueueCount(gpu_, &count) == VK_SUCCESS)) { |
| 113 | info.resize(count); |
| 114 | if (!EXPECT(vkGetPhysicalDeviceQueueProperties(gpu_, count, &info[0]) == VK_SUCCESS)) |
| 115 | info.clear(); |
| 116 | } |
| 117 | |
| 118 | return info; |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 119 | } |
| 120 | |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 121 | VkPhysicalDeviceMemoryProperties PhysicalGpu::memory_properties() const |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 122 | { |
Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 123 | VkPhysicalDeviceMemoryProperties info; |
| 124 | |
| 125 | EXPECT(vkGetPhysicalDeviceMemoryProperties(gpu_, &info) == VK_SUCCESS); |
| 126 | |
Mark Lobodzinski | b3fbcd9 | 2015-07-02 16:49:40 -0600 | [diff] [blame] | 127 | |
Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 128 | return info; |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 129 | } |
| 130 | |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 131 | /* |
| 132 | * Return list of Global layers available |
| 133 | */ |
| 134 | std::vector<VkLayerProperties> GetGlobalLayers() |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 135 | { |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 136 | VkResult err; |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 137 | std::vector<VkLayerProperties> layers; |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 138 | uint32_t layer_count; |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 139 | |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 140 | do { |
| 141 | layer_count = 0; |
| 142 | err = vkGetGlobalLayerProperties(&layer_count, NULL); |
| 143 | |
| 144 | if (err == VK_SUCCESS) { |
| 145 | layers.reserve(layer_count); |
| 146 | err = vkGetGlobalLayerProperties(&layer_count, &layers[0]); |
| 147 | } |
| 148 | } while (err == VK_INCOMPLETE); |
| 149 | |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 150 | assert(err == VK_SUCCESS); |
| 151 | |
| 152 | return layers; |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 153 | } |
| 154 | |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 155 | /* |
| 156 | * Return list of Global extensions provided by the ICD / Loader |
| 157 | */ |
| 158 | std::vector<VkExtensionProperties> GetGlobalExtensions() |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 159 | { |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 160 | return GetGlobalExtensions(NULL); |
| 161 | } |
| 162 | |
| 163 | /* |
| 164 | * Return list of Global extensions provided by the specified layer |
| 165 | * If pLayerName is NULL, will return extensions implemented by the loader / ICDs |
| 166 | */ |
| 167 | std::vector<VkExtensionProperties> GetGlobalExtensions(const char *pLayerName) |
| 168 | { |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 169 | std::vector<VkExtensionProperties> exts; |
| 170 | uint32_t ext_count; |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 171 | VkResult err; |
| 172 | |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 173 | do { |
| 174 | ext_count = 0; |
| 175 | err = vkGetGlobalExtensionProperties(pLayerName, &ext_count, NULL); |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 176 | |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 177 | if (err == VK_SUCCESS) { |
Courtney Goeltzenleuchter | 381f3a2 | 2015-07-06 15:45:58 -0600 | [diff] [blame] | 178 | exts.resize(ext_count); |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 179 | err = vkGetGlobalExtensionProperties(pLayerName, &ext_count, &exts[0]); |
| 180 | } |
| 181 | } while (err == VK_INCOMPLETE); |
| 182 | |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 183 | assert(err == VK_SUCCESS); |
| 184 | |
| 185 | return exts; |
| 186 | } |
| 187 | |
| 188 | /* |
| 189 | * Return list of PhysicalDevice extensions provided by the ICD / Loader |
| 190 | */ |
| 191 | std::vector<VkExtensionProperties> PhysicalGpu::extensions() const |
| 192 | { |
| 193 | return extensions(NULL); |
| 194 | } |
| 195 | |
| 196 | /* |
| 197 | * Return list of PhysicalDevice extensions provided by the specified layer |
| 198 | * If pLayerName is NULL, will return extensions for ICD / loader. |
| 199 | */ |
| 200 | std::vector<VkExtensionProperties> PhysicalGpu::extensions(const char *pLayerName) const |
| 201 | { |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 202 | std::vector<VkExtensionProperties> exts; |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 203 | VkResult err; |
| 204 | |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 205 | do { |
| 206 | uint32_t extCount = 0; |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 207 | err = vkGetPhysicalDeviceExtensionProperties(obj(), pLayerName, &extCount, NULL); |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 208 | |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 209 | if (err == VK_SUCCESS) { |
| 210 | exts.reserve(extCount); |
| 211 | err = vkGetPhysicalDeviceExtensionProperties(obj(), pLayerName, &extCount, &exts[0]); |
| 212 | } |
| 213 | } while (err == VK_INCOMPLETE); |
| 214 | |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 215 | assert(err == VK_SUCCESS); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 216 | |
| 217 | return exts; |
| 218 | } |
| 219 | |
Mark Lobodzinski | b3fbcd9 | 2015-07-02 16:49:40 -0600 | [diff] [blame] | 220 | VkResult PhysicalGpu::set_memory_type(const uint32_t type_bits, VkMemoryAllocInfo *info, const VkFlags properties) const |
| 221 | { |
| 222 | uint32_t type_mask = type_bits; |
| 223 | // Search memtypes to find first index with those properties |
| 224 | for (uint32_t i = 0; i < 32; i++) { |
| 225 | if ((type_mask & 1) == 1) { |
| 226 | // Type is available, does it match user properties? |
| 227 | if ((memory_properties_.memoryTypes[i].propertyFlags & properties) == properties) { |
| 228 | info->memoryTypeIndex = i; |
| 229 | return VK_SUCCESS; |
| 230 | } |
| 231 | } |
| 232 | type_mask >>= 1; |
| 233 | } |
| 234 | // No memory types matched, return failure |
| 235 | return VK_UNSUPPORTED; |
| 236 | } |
| 237 | |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 238 | /* |
| 239 | * Return list of PhysicalDevice layers |
| 240 | */ |
| 241 | std::vector<VkLayerProperties> PhysicalGpu::layers() const |
| 242 | { |
| 243 | std::vector<VkLayerProperties> layer_props; |
| 244 | VkResult err; |
| 245 | |
| 246 | do { |
| 247 | uint32_t layer_count = 0; |
| 248 | err = vkGetPhysicalDeviceLayerProperties(obj(), &layer_count, NULL); |
| 249 | |
| 250 | if (err == VK_SUCCESS) { |
| 251 | layer_props.reserve(layer_count); |
| 252 | err = vkGetPhysicalDeviceLayerProperties(obj(), &layer_count, &layer_props[0]); |
| 253 | } |
| 254 | } while (err == VK_INCOMPLETE); |
| 255 | |
| 256 | assert(err == VK_SUCCESS); |
| 257 | |
| 258 | return layer_props; |
| 259 | } |
| 260 | |
Courtney Goeltzenleuchter | 992fb4f | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 261 | void BaseObject::init(VkObject obj, VkObjectType type, bool own) |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 262 | { |
| 263 | EXPECT(!initialized()); |
Courtney Goeltzenleuchter | 992fb4f | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 264 | reinit(obj, type, own); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 265 | } |
| 266 | |
Courtney Goeltzenleuchter | 992fb4f | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 267 | void BaseObject::reinit(VkObject obj, VkObjectType type, bool own) |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 268 | { |
| 269 | obj_ = obj; |
Courtney Goeltzenleuchter | 992fb4f | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 270 | object_type_ = type; |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 271 | own_obj_ = own; |
| 272 | } |
| 273 | |
Courtney Goeltzenleuchter | 992fb4f | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 274 | uint32_t Object::memory_allocation_count() const |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 275 | { |
Mark Lobodzinski | 2306535 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 276 | return 1; |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 277 | } |
| 278 | |
Courtney Goeltzenleuchter | 992fb4f | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 279 | std::vector<VkMemoryRequirements> Object::memory_requirements() const |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 280 | { |
Mark Lobodzinski | 2306535 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 281 | uint32_t num_allocations = 1; |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 282 | std::vector<VkMemoryRequirements> info = |
Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 283 | get_memory_reqs<VkMemoryRequirements>(dev_->obj(), type(), obj(), 0); |
Jon Ashburn | 7e78195 | 2015-01-16 09:37:43 -0700 | [diff] [blame] | 284 | EXPECT(info.size() == num_allocations); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 285 | if (info.size() == 1 && !info[0].size) |
| 286 | info.clear(); |
| 287 | |
| 288 | return info; |
| 289 | } |
| 290 | |
Courtney Goeltzenleuchter | 992fb4f | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 291 | void Object::init(VkObject obj, VkObjectType object_type, bool own) |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 292 | { |
Courtney Goeltzenleuchter | 992fb4f | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 293 | BaseObject::init(obj, object_type, own); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 294 | mem_alloc_count_ = memory_allocation_count(); |
| 295 | } |
| 296 | |
Courtney Goeltzenleuchter | 992fb4f | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 297 | void Object::reinit(VkObject obj, VkObjectType object_type, bool own) |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 298 | { |
| 299 | cleanup(); |
Courtney Goeltzenleuchter | 992fb4f | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 300 | BaseObject::reinit(obj, object_type, own); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 301 | mem_alloc_count_ = memory_allocation_count(); |
| 302 | } |
| 303 | |
| 304 | void Object::cleanup() |
| 305 | { |
| 306 | if (!initialized()) |
| 307 | return; |
| 308 | |
Courtney Goeltzenleuchter | de69c41 | 2015-06-14 21:31:09 -0600 | [diff] [blame] | 309 | if (own()) |
| 310 | EXPECT(vkDestroyObject(dev_->obj(), type(), obj()) == VK_SUCCESS); |
| 311 | |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 312 | if (internal_mems_) { |
| 313 | delete[] internal_mems_; |
| 314 | internal_mems_ = NULL; |
| 315 | primary_mem_ = NULL; |
| 316 | } |
| 317 | |
| 318 | mem_alloc_count_ = 0; |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 319 | } |
| 320 | |
Mark Lobodzinski | 2306535 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 321 | void Object::bind_memory(const GpuMemory &mem, VkDeviceSize mem_offset) |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 322 | { |
Tony Barbour | 44bb3ab | 2015-04-09 16:00:18 -0600 | [diff] [blame] | 323 | bound = true; |
Mark Lobodzinski | 2306535 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 324 | EXPECT(vkBindObjectMemory(dev_->obj(), type(), obj(), mem.obj(), mem_offset) == VK_SUCCESS); |
Chia-I Wu | 1a28fe0 | 2015-01-01 07:55:04 +0800 | [diff] [blame] | 325 | } |
| 326 | |
Courtney Goeltzenleuchter | 30a3945 | 2015-04-22 10:02:41 -0600 | [diff] [blame] | 327 | void Object::alloc_memory() |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 328 | { |
| 329 | if (!EXPECT(!internal_mems_) || !mem_alloc_count_) |
| 330 | return; |
| 331 | |
| 332 | internal_mems_ = new GpuMemory[mem_alloc_count_]; |
| 333 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 334 | const std::vector<VkMemoryRequirements> mem_reqs = memory_requirements(); |
Courtney Goeltzenleuchter | 95487bc | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 335 | VkMemoryAllocInfo info, *next_info = NULL; |
Jon Ashburn | 8a5da75 | 2015-01-19 15:00:26 -0700 | [diff] [blame] | 336 | |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 337 | for (int i = 0; i < mem_reqs.size(); i++) { |
Jon Ashburn | 25bbe46 | 2015-01-20 08:50:12 -0700 | [diff] [blame] | 338 | info = GpuMemory::alloc_info(mem_reqs[i], next_info); |
Mark Lobodzinski | b3fbcd9 | 2015-07-02 16:49:40 -0600 | [diff] [blame] | 339 | dev_->gpu().set_memory_type(mem_reqs[i].memoryTypeBits, &info, 0); |
Mark Lobodzinski | e39f695 | 2015-04-16 08:52:00 -0500 | [diff] [blame] | 340 | primary_mem_ = &internal_mems_[i]; |
Courtney Goeltzenleuchter | 30a3945 | 2015-04-22 10:02:41 -0600 | [diff] [blame] | 341 | internal_mems_[i].init(*dev_, info); |
Mark Lobodzinski | 2306535 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 342 | bind_memory(internal_mems_[i], 0); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 343 | } |
| 344 | } |
| 345 | |
Tony Barbour | 4c97d7a | 2015-04-22 15:10:33 -0600 | [diff] [blame] | 346 | void Object::alloc_memory(VkMemoryPropertyFlags &reqs) |
| 347 | { |
| 348 | if (!EXPECT(!internal_mems_) || !mem_alloc_count_) |
| 349 | return; |
| 350 | |
| 351 | internal_mems_ = new GpuMemory[mem_alloc_count_]; |
| 352 | |
| 353 | std::vector<VkMemoryRequirements> mem_reqs = memory_requirements(); |
| 354 | VkMemoryAllocInfo info, *next_info = NULL; |
| 355 | |
| 356 | for (int i = 0; i < mem_reqs.size(); i++) { |
Tony Barbour | 4c97d7a | 2015-04-22 15:10:33 -0600 | [diff] [blame] | 357 | info = GpuMemory::alloc_info(mem_reqs[i], next_info); |
Mark Lobodzinski | b3fbcd9 | 2015-07-02 16:49:40 -0600 | [diff] [blame] | 358 | dev_->gpu().set_memory_type(mem_reqs[i].memoryTypeBits, &info, reqs); |
Tony Barbour | 4c97d7a | 2015-04-22 15:10:33 -0600 | [diff] [blame] | 359 | primary_mem_ = &internal_mems_[i]; |
| 360 | internal_mems_[i].init(*dev_, info); |
Mark Lobodzinski | 2306535 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 361 | bind_memory(internal_mems_[i], 0); |
Tony Barbour | 4c97d7a | 2015-04-22 15:10:33 -0600 | [diff] [blame] | 362 | } |
| 363 | } |
| 364 | |
Courtney Goeltzenleuchter | 30a3945 | 2015-04-22 10:02:41 -0600 | [diff] [blame] | 365 | void Object::alloc_memory(const std::vector<VkDeviceMemory> &mems) |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 366 | { |
| 367 | if (!EXPECT(!internal_mems_) || !mem_alloc_count_) |
| 368 | return; |
| 369 | |
| 370 | internal_mems_ = new GpuMemory[mem_alloc_count_]; |
| 371 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 372 | const std::vector<VkMemoryRequirements> mem_reqs = memory_requirements(); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 373 | if (!EXPECT(mem_reqs.size() == mems.size())) |
| 374 | return; |
| 375 | |
| 376 | for (int i = 0; i < mem_reqs.size(); i++) { |
| 377 | primary_mem_ = &internal_mems_[i]; |
| 378 | |
Courtney Goeltzenleuchter | 30a3945 | 2015-04-22 10:02:41 -0600 | [diff] [blame] | 379 | internal_mems_[i].init(*dev_, mems[i]); |
Mark Lobodzinski | 2306535 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 380 | bind_memory(internal_mems_[i], 0); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 381 | } |
| 382 | } |
| 383 | |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 384 | std::vector<VkDeviceMemory> Object::memories() const |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 385 | { |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 386 | std::vector<VkDeviceMemory> mems; |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 387 | if (internal_mems_) { |
| 388 | mems.reserve(mem_alloc_count_); |
| 389 | for (uint32_t i = 0; i < mem_alloc_count_; i++) |
| 390 | mems.push_back(internal_mems_[i].obj()); |
| 391 | } |
| 392 | |
| 393 | return mems; |
| 394 | } |
| 395 | |
| 396 | Device::~Device() |
| 397 | { |
| 398 | if (!initialized()) |
| 399 | return; |
| 400 | |
| 401 | for (int i = 0; i < QUEUE_COUNT; i++) { |
| 402 | for (std::vector<Queue *>::iterator it = queues_[i].begin(); it != queues_[i].end(); it++) |
| 403 | delete *it; |
| 404 | queues_[i].clear(); |
| 405 | } |
| 406 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 407 | EXPECT(vkDestroyDevice(obj()) == VK_SUCCESS); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 408 | } |
| 409 | |
Courtney Goeltzenleuchter | 5bac609 | 2015-07-07 11:47:33 -0600 | [diff] [blame] | 410 | void Device::init(std::vector<const char *> &layers, std::vector<const char *> &extensions) |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 411 | { |
| 412 | // request all queues |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 413 | const std::vector<VkPhysicalDeviceQueueProperties> queue_props = gpu_.queue_properties(); |
Courtney Goeltzenleuchter | 95487bc | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 414 | std::vector<VkDeviceQueueCreateInfo> queue_info; |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 415 | queue_info.reserve(queue_props.size()); |
| 416 | for (int i = 0; i < queue_props.size(); i++) { |
Courtney Goeltzenleuchter | 95487bc | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 417 | VkDeviceQueueCreateInfo qi = {}; |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 418 | qi.queueNodeIndex = i; |
| 419 | qi.queueCount = queue_props[i].queueCount; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 420 | if (queue_props[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) { |
Courtney Goeltzenleuchter | 18248e6 | 2015-03-05 18:09:39 -0700 | [diff] [blame] | 421 | graphics_queue_node_index_ = i; |
| 422 | } |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 423 | queue_info.push_back(qi); |
| 424 | } |
| 425 | |
Courtney Goeltzenleuchter | 95487bc | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 426 | VkDeviceCreateInfo dev_info = {}; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 427 | dev_info.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO; |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 428 | dev_info.pNext = NULL; |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 429 | dev_info.queueRecordCount = queue_info.size(); |
| 430 | dev_info.pRequestedQueues = &queue_info[0]; |
Courtney Goeltzenleuchter | 5bac609 | 2015-07-07 11:47:33 -0600 | [diff] [blame] | 431 | dev_info.layerCount = layers.size(); |
| 432 | dev_info.ppEnabledLayerNames = &layers[0]; |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 433 | dev_info.extensionCount = extensions.size(); |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 434 | dev_info.ppEnabledExtensionNames = &extensions[0]; |
Jon Ashburn | 9fc13ba | 2015-05-18 09:06:15 -0600 | [diff] [blame] | 435 | dev_info.flags = 0; |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 436 | |
| 437 | init(dev_info); |
| 438 | } |
| 439 | |
Courtney Goeltzenleuchter | 95487bc | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 440 | void Device::init(const VkDeviceCreateInfo &info) |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 441 | { |
Courtney Goeltzenleuchter | 992fb4f | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 442 | VkDevice obj; |
| 443 | if (EXPECT(vkCreateDevice(gpu_.obj(), &info, &obj) == VK_SUCCESS)) { |
| 444 | base_type::init(obj, VK_OBJECT_TYPE_DEVICE); |
| 445 | } |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 446 | |
| 447 | init_queues(); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 448 | init_formats(); |
| 449 | } |
| 450 | |
| 451 | void Device::init_queues() |
| 452 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 453 | VkResult err; |
Courtney Goeltzenleuchter | 18248e6 | 2015-03-05 18:09:39 -0700 | [diff] [blame] | 454 | uint32_t queue_node_count; |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 455 | |
Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 456 | err = vkGetPhysicalDeviceQueueCount(gpu_.obj(), &queue_node_count); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 457 | EXPECT(err == VK_SUCCESS); |
Courtney Goeltzenleuchter | 18248e6 | 2015-03-05 18:09:39 -0700 | [diff] [blame] | 458 | EXPECT(queue_node_count >= 1); |
| 459 | |
Tony Barbour | 3d69c9e | 2015-05-20 16:53:31 -0600 | [diff] [blame] | 460 | VkPhysicalDeviceQueueProperties* queue_props = new VkPhysicalDeviceQueueProperties[queue_node_count]; |
Courtney Goeltzenleuchter | 18248e6 | 2015-03-05 18:09:39 -0700 | [diff] [blame] | 461 | |
Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 462 | err = vkGetPhysicalDeviceQueueProperties(gpu_.obj(), queue_node_count, queue_props); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 463 | EXPECT(err == VK_SUCCESS); |
Courtney Goeltzenleuchter | 18248e6 | 2015-03-05 18:09:39 -0700 | [diff] [blame] | 464 | |
Tony Barbour | 7ea6aa2 | 2015-05-22 09:44:58 -0600 | [diff] [blame] | 465 | for (uint32_t i = 0; i < queue_node_count; i++) { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 466 | VkQueue queue; |
Courtney Goeltzenleuchter | 18248e6 | 2015-03-05 18:09:39 -0700 | [diff] [blame] | 467 | |
Tony Barbour | 7ea6aa2 | 2015-05-22 09:44:58 -0600 | [diff] [blame] | 468 | for (uint32_t j = 0; j < queue_props[i].queueCount; j++) { |
Mark Lobodzinski | 40f7f40 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 469 | // TODO: Need to add support for separate MEMMGR and work queues, including synchronization |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 470 | err = vkGetDeviceQueue(obj(), i, j, &queue); |
| 471 | EXPECT(err == VK_SUCCESS); |
Courtney Goeltzenleuchter | 18248e6 | 2015-03-05 18:09:39 -0700 | [diff] [blame] | 472 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 473 | if (queue_props[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) { |
Courtney Goeltzenleuchter | 18248e6 | 2015-03-05 18:09:39 -0700 | [diff] [blame] | 474 | queues_[GRAPHICS].push_back(new Queue(queue)); |
| 475 | } |
| 476 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 477 | if (queue_props[i].queueFlags & VK_QUEUE_COMPUTE_BIT) { |
Courtney Goeltzenleuchter | 18248e6 | 2015-03-05 18:09:39 -0700 | [diff] [blame] | 478 | queues_[COMPUTE].push_back(new Queue(queue)); |
| 479 | } |
| 480 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 481 | if (queue_props[i].queueFlags & VK_QUEUE_DMA_BIT) { |
Courtney Goeltzenleuchter | 18248e6 | 2015-03-05 18:09:39 -0700 | [diff] [blame] | 482 | queues_[DMA].push_back(new Queue(queue)); |
| 483 | } |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 484 | } |
| 485 | } |
| 486 | |
Chris Forbes | 0203879 | 2015-06-04 10:49:27 +1200 | [diff] [blame] | 487 | delete[] queue_props; |
Tony Barbour | 3d69c9e | 2015-05-20 16:53:31 -0600 | [diff] [blame] | 488 | |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 489 | EXPECT(!queues_[GRAPHICS].empty() || !queues_[COMPUTE].empty()); |
| 490 | } |
| 491 | |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 492 | void Device::init_formats() |
| 493 | { |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 494 | for (int f = VK_FORMAT_BEGIN_RANGE; f <= VK_FORMAT_END_RANGE; f++) { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 495 | const VkFormat fmt = static_cast<VkFormat>(f); |
| 496 | const VkFormatProperties props = format_properties(fmt); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 497 | |
Jeremy Hayes | a058eee | 2015-01-23 08:51:43 -0700 | [diff] [blame] | 498 | if (props.linearTilingFeatures) { |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 499 | const Format tmp = { fmt, VK_IMAGE_TILING_LINEAR, props.linearTilingFeatures }; |
Jeremy Hayes | a058eee | 2015-01-23 08:51:43 -0700 | [diff] [blame] | 500 | formats_.push_back(tmp); |
| 501 | } |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 502 | |
Jeremy Hayes | a058eee | 2015-01-23 08:51:43 -0700 | [diff] [blame] | 503 | if (props.optimalTilingFeatures) { |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 504 | const Format tmp = { fmt, VK_IMAGE_TILING_OPTIMAL, props.optimalTilingFeatures }; |
Jeremy Hayes | a058eee | 2015-01-23 08:51:43 -0700 | [diff] [blame] | 505 | formats_.push_back(tmp); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 506 | } |
| 507 | } |
| 508 | |
| 509 | EXPECT(!formats_.empty()); |
| 510 | } |
| 511 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 512 | VkFormatProperties Device::format_properties(VkFormat format) |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 513 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 514 | VkFormatProperties data; |
Chris Forbes | bc0bb77 | 2015-06-21 22:55:02 +1200 | [diff] [blame] | 515 | if (!EXPECT(vkGetPhysicalDeviceFormatInfo(gpu().obj(), format, &data) == VK_SUCCESS)) |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 516 | memset(&data, 0, sizeof(data)); |
| 517 | |
| 518 | return data; |
| 519 | } |
| 520 | |
| 521 | void Device::wait() |
| 522 | { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 523 | EXPECT(vkDeviceWaitIdle(obj()) == VK_SUCCESS); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 524 | } |
| 525 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 526 | VkResult Device::wait(const std::vector<const Fence *> &fences, bool wait_all, uint64_t timeout) |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 527 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 528 | const std::vector<VkFence> fence_objs = make_objects<VkFence>(fences); |
| 529 | VkResult err = vkWaitForFences(obj(), fence_objs.size(), &fence_objs[0], wait_all, timeout); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 530 | EXPECT(err == VK_SUCCESS || err == VK_TIMEOUT); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 531 | |
| 532 | return err; |
| 533 | } |
| 534 | |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 535 | VkResult Device::update_descriptor_sets(const std::vector<VkWriteDescriptorSet> &writes, const std::vector<VkCopyDescriptorSet> &copies) |
| 536 | { |
| 537 | return vkUpdateDescriptorSets(obj(), writes.size(), &writes[0], copies.size(), &copies[0]); |
| 538 | } |
| 539 | |
Courtney Goeltzenleuchter | 97b7523 | 2015-04-07 17:13:38 -0600 | [diff] [blame] | 540 | void Queue::submit(const std::vector<const CmdBuffer *> &cmds, Fence &fence) |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 541 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 542 | const std::vector<VkCmdBuffer> cmd_objs = make_objects<VkCmdBuffer>(cmds); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 543 | EXPECT(vkQueueSubmit(obj(), cmd_objs.size(), &cmd_objs[0], fence.obj()) == VK_SUCCESS); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 544 | } |
| 545 | |
Courtney Goeltzenleuchter | 97b7523 | 2015-04-07 17:13:38 -0600 | [diff] [blame] | 546 | void Queue::submit(const CmdBuffer &cmd, Fence &fence) |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 547 | { |
Courtney Goeltzenleuchter | 97b7523 | 2015-04-07 17:13:38 -0600 | [diff] [blame] | 548 | submit(std::vector<const CmdBuffer*>(1, &cmd), fence); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 549 | } |
| 550 | |
Courtney Goeltzenleuchter | 97b7523 | 2015-04-07 17:13:38 -0600 | [diff] [blame] | 551 | void Queue::submit(const CmdBuffer &cmd) |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 552 | { |
| 553 | Fence fence; |
Courtney Goeltzenleuchter | 97b7523 | 2015-04-07 17:13:38 -0600 | [diff] [blame] | 554 | submit(cmd, fence); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 555 | } |
| 556 | |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 557 | void Queue::wait() |
| 558 | { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 559 | EXPECT(vkQueueWaitIdle(obj()) == VK_SUCCESS); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 560 | } |
| 561 | |
Courtney Goeltzenleuchter | ebb9584 | 2015-03-25 17:14:29 -0600 | [diff] [blame] | 562 | void Queue::signal_semaphore(Semaphore &sem) |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 563 | { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 564 | EXPECT(vkQueueSignalSemaphore(obj(), sem.obj()) == VK_SUCCESS); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 565 | } |
| 566 | |
Courtney Goeltzenleuchter | ebb9584 | 2015-03-25 17:14:29 -0600 | [diff] [blame] | 567 | void Queue::wait_semaphore(Semaphore &sem) |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 568 | { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 569 | EXPECT(vkQueueWaitSemaphore(obj(), sem.obj()) == VK_SUCCESS); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 570 | } |
| 571 | |
| 572 | GpuMemory::~GpuMemory() |
| 573 | { |
| 574 | if (initialized() && own()) |
Courtney Goeltzenleuchter | 992fb4f | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 575 | EXPECT(vkFreeMemory(dev_->obj(), obj()) == VK_SUCCESS); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 576 | } |
| 577 | |
Courtney Goeltzenleuchter | 95487bc | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 578 | void GpuMemory::init(const Device &dev, const VkMemoryAllocInfo &info) |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 579 | { |
Courtney Goeltzenleuchter | 992fb4f | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 580 | DERIVED_OBJECT_TYPE_INIT(vkAllocMemory, dev, VK_OBJECT_TYPE_DEVICE_MEMORY, &info); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 581 | } |
| 582 | |
Courtney Goeltzenleuchter | 992fb4f | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 583 | void GpuMemory::init(const Device &dev, VkDeviceMemory mem) |
| 584 | { |
| 585 | dev_ = &dev; |
| 586 | BaseObject::init(mem, VK_OBJECT_TYPE_DEVICE_MEMORY, false); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 587 | } |
| 588 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 589 | const void *GpuMemory::map(VkFlags flags) const |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 590 | { |
| 591 | void *data; |
Courtney Goeltzenleuchter | 992fb4f | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 592 | if (!EXPECT(vkMapMemory(dev_->obj(), obj(), 0 ,0, flags, &data) == VK_SUCCESS)) |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 593 | data = NULL; |
| 594 | |
| 595 | return data; |
| 596 | } |
| 597 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 598 | void *GpuMemory::map(VkFlags flags) |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 599 | { |
| 600 | void *data; |
Courtney Goeltzenleuchter | 992fb4f | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 601 | if (!EXPECT(vkMapMemory(dev_->obj(), obj(), 0, 0, flags, &data) == VK_SUCCESS)) |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 602 | data = NULL; |
| 603 | |
| 604 | return data; |
| 605 | } |
| 606 | |
| 607 | void GpuMemory::unmap() const |
| 608 | { |
Courtney Goeltzenleuchter | 992fb4f | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 609 | EXPECT(vkUnmapMemory(dev_->obj(), obj()) == VK_SUCCESS); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 610 | } |
| 611 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 612 | void Fence::init(const Device &dev, const VkFenceCreateInfo &info) |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 613 | { |
Courtney Goeltzenleuchter | 992fb4f | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 614 | DERIVED_OBJECT_TYPE_INIT(vkCreateFence, dev, VK_OBJECT_TYPE_FENCE, &info); |
Courtney Goeltzenleuchter | 30a3945 | 2015-04-22 10:02:41 -0600 | [diff] [blame] | 615 | alloc_memory(); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 616 | } |
| 617 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 618 | void Semaphore::init(const Device &dev, const VkSemaphoreCreateInfo &info) |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 619 | { |
Courtney Goeltzenleuchter | 992fb4f | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 620 | DERIVED_OBJECT_TYPE_INIT(vkCreateSemaphore, dev, VK_OBJECT_TYPE_SEMAPHORE, &info); |
Courtney Goeltzenleuchter | 30a3945 | 2015-04-22 10:02:41 -0600 | [diff] [blame] | 621 | alloc_memory(); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 622 | } |
| 623 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 624 | void Event::init(const Device &dev, const VkEventCreateInfo &info) |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 625 | { |
Courtney Goeltzenleuchter | 992fb4f | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 626 | DERIVED_OBJECT_TYPE_INIT(vkCreateEvent, dev, VK_OBJECT_TYPE_EVENT, &info); |
Courtney Goeltzenleuchter | 30a3945 | 2015-04-22 10:02:41 -0600 | [diff] [blame] | 627 | alloc_memory(); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 628 | } |
| 629 | |
| 630 | void Event::set() |
| 631 | { |
Courtney Goeltzenleuchter | 992fb4f | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 632 | EXPECT(vkSetEvent(dev_->obj(), obj()) == VK_SUCCESS); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 633 | } |
| 634 | |
| 635 | void Event::reset() |
| 636 | { |
Courtney Goeltzenleuchter | 992fb4f | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 637 | EXPECT(vkResetEvent(dev_->obj(), obj()) == VK_SUCCESS); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 638 | } |
| 639 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 640 | void QueryPool::init(const Device &dev, const VkQueryPoolCreateInfo &info) |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 641 | { |
Courtney Goeltzenleuchter | 992fb4f | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 642 | DERIVED_OBJECT_TYPE_INIT(vkCreateQueryPool, dev, VK_OBJECT_TYPE_QUERY_POOL, &info); |
Courtney Goeltzenleuchter | 30a3945 | 2015-04-22 10:02:41 -0600 | [diff] [blame] | 643 | alloc_memory(); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 644 | } |
| 645 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 646 | VkResult QueryPool::results(uint32_t start, uint32_t count, size_t size, void *data) |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 647 | { |
| 648 | size_t tmp = size; |
Courtney Goeltzenleuchter | 992fb4f | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 649 | VkResult err = vkGetQueryPoolResults(dev_->obj(), obj(), start, count, &tmp, data, 0); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 650 | if (err == VK_SUCCESS) { |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 651 | if (!EXPECT(tmp == size)) |
| 652 | memset(data, 0, size); |
| 653 | } else { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 654 | EXPECT(err == VK_NOT_READY); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 655 | } |
| 656 | |
| 657 | return err; |
| 658 | } |
| 659 | |
Courtney Goeltzenleuchter | 95487bc | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 660 | void Buffer::init(const Device &dev, const VkBufferCreateInfo &info) |
Chia-I Wu | 1a28fe0 | 2015-01-01 07:55:04 +0800 | [diff] [blame] | 661 | { |
| 662 | init_no_mem(dev, info); |
Courtney Goeltzenleuchter | 30a3945 | 2015-04-22 10:02:41 -0600 | [diff] [blame] | 663 | alloc_memory(); |
Chia-I Wu | 1a28fe0 | 2015-01-01 07:55:04 +0800 | [diff] [blame] | 664 | } |
| 665 | |
Tony Barbour | 4c97d7a | 2015-04-22 15:10:33 -0600 | [diff] [blame] | 666 | void Buffer::init(const Device &dev, const VkBufferCreateInfo &info, VkMemoryPropertyFlags &reqs) |
| 667 | { |
| 668 | init_no_mem(dev, info); |
| 669 | alloc_memory(reqs); |
| 670 | } |
| 671 | |
Courtney Goeltzenleuchter | 95487bc | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 672 | void Buffer::init_no_mem(const Device &dev, const VkBufferCreateInfo &info) |
Chia-I Wu | 1a28fe0 | 2015-01-01 07:55:04 +0800 | [diff] [blame] | 673 | { |
Courtney Goeltzenleuchter | 992fb4f | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 674 | DERIVED_OBJECT_TYPE_INIT(vkCreateBuffer, dev, VK_OBJECT_TYPE_BUFFER, &info); |
Chia-I Wu | 1a28fe0 | 2015-01-01 07:55:04 +0800 | [diff] [blame] | 675 | create_info_ = info; |
| 676 | } |
| 677 | |
Mark Lobodzinski | 2306535 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 678 | void Buffer::bind_memory(VkDeviceSize offset, VkDeviceSize size, |
Mark Lobodzinski | 942b172 | 2015-05-11 17:21:15 -0500 | [diff] [blame] | 679 | const GpuMemory &mem, VkDeviceSize mem_offset) |
| 680 | { |
| 681 | VkQueue queue = dev_->graphics_queues()[0]->obj(); |
Mark Lobodzinski | 16e8bef | 2015-07-03 15:58:09 -0600 | [diff] [blame] | 682 | VkSparseMemoryBindInfo bindInfo; |
| 683 | memset(&bindInfo, 0, sizeof(VkSparseMemoryBindInfo)); |
| 684 | bindInfo.offset = offset; |
| 685 | bindInfo.memOffset = mem_offset; |
| 686 | bindInfo.mem = mem.obj(); |
| 687 | EXPECT(vkQueueBindSparseBufferMemory(queue, obj(), 1, &bindInfo) == VK_SUCCESS); |
Mark Lobodzinski | 942b172 | 2015-05-11 17:21:15 -0500 | [diff] [blame] | 688 | } |
| 689 | |
Courtney Goeltzenleuchter | 95487bc | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 690 | void BufferView::init(const Device &dev, const VkBufferViewCreateInfo &info) |
Chia-I Wu | 1a28fe0 | 2015-01-01 07:55:04 +0800 | [diff] [blame] | 691 | { |
Courtney Goeltzenleuchter | 992fb4f | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 692 | DERIVED_OBJECT_TYPE_INIT(vkCreateBufferView, dev, VK_OBJECT_TYPE_BUFFER_VIEW, &info); |
Courtney Goeltzenleuchter | 30a3945 | 2015-04-22 10:02:41 -0600 | [diff] [blame] | 693 | alloc_memory(); |
Chia-I Wu | 1a28fe0 | 2015-01-01 07:55:04 +0800 | [diff] [blame] | 694 | } |
| 695 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 696 | void Image::init(const Device &dev, const VkImageCreateInfo &info) |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 697 | { |
| 698 | init_no_mem(dev, info); |
Courtney Goeltzenleuchter | 30a3945 | 2015-04-22 10:02:41 -0600 | [diff] [blame] | 699 | alloc_memory(); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 700 | } |
| 701 | |
Tony Barbour | 4c97d7a | 2015-04-22 15:10:33 -0600 | [diff] [blame] | 702 | void Image::init(const Device &dev, const VkImageCreateInfo &info, VkMemoryPropertyFlags &reqs) |
| 703 | { |
| 704 | init_no_mem(dev, info); |
| 705 | alloc_memory(reqs); |
| 706 | } |
| 707 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 708 | void Image::init_no_mem(const Device &dev, const VkImageCreateInfo &info) |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 709 | { |
Courtney Goeltzenleuchter | 992fb4f | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 710 | DERIVED_OBJECT_TYPE_INIT(vkCreateImage, dev, VK_OBJECT_TYPE_IMAGE, &info); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 711 | init_info(dev, info); |
| 712 | } |
| 713 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 714 | void Image::init_info(const Device &dev, const VkImageCreateInfo &info) |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 715 | { |
| 716 | create_info_ = info; |
| 717 | |
| 718 | for (std::vector<Device::Format>::const_iterator it = dev.formats().begin(); it != dev.formats().end(); it++) { |
| 719 | if (memcmp(&it->format, &create_info_.format, sizeof(it->format)) == 0 && it->tiling == create_info_.tiling) { |
| 720 | format_features_ = it->features; |
| 721 | break; |
| 722 | } |
| 723 | } |
| 724 | } |
| 725 | |
Mark Lobodzinski | 16e8bef | 2015-07-03 15:58:09 -0600 | [diff] [blame] | 726 | void Image::bind_memory(const Device &dev, const VkSparseImageMemoryBindInfo &info, |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 727 | const GpuMemory &mem, VkDeviceSize mem_offset) |
Chia-I Wu | 1a28fe0 | 2015-01-01 07:55:04 +0800 | [diff] [blame] | 728 | { |
Mark Lobodzinski | 40f7f40 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 729 | VkQueue queue = dev.graphics_queues()[0]->obj(); |
Mark Lobodzinski | 16e8bef | 2015-07-03 15:58:09 -0600 | [diff] [blame] | 730 | EXPECT(vkQueueBindSparseImageMemory(queue, obj(), 1, &info) == VK_SUCCESS); |
Chia-I Wu | 1a28fe0 | 2015-01-01 07:55:04 +0800 | [diff] [blame] | 731 | } |
| 732 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 733 | VkSubresourceLayout Image::subresource_layout(const VkImageSubresource &subres) const |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 734 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 735 | VkSubresourceLayout data; |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 736 | size_t size = sizeof(data); |
Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 737 | if (!EXPECT(vkGetImageSubresourceLayout(dev_->obj(), obj(), &subres, &data) == VK_SUCCESS && size == sizeof(data))) |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 738 | memset(&data, 0, sizeof(data)); |
| 739 | |
| 740 | return data; |
| 741 | } |
| 742 | |
| 743 | bool Image::transparent() const |
| 744 | { |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 745 | return (create_info_.tiling == VK_IMAGE_TILING_LINEAR && |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 746 | create_info_.samples == 1 && |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 747 | !(create_info_.usage & (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 748 | VK_IMAGE_USAGE_DEPTH_STENCIL_BIT))); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 749 | } |
| 750 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 751 | void ImageView::init(const Device &dev, const VkImageViewCreateInfo &info) |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 752 | { |
Courtney Goeltzenleuchter | 992fb4f | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 753 | DERIVED_OBJECT_TYPE_INIT(vkCreateImageView, dev, VK_OBJECT_TYPE_IMAGE_VIEW, &info); |
Courtney Goeltzenleuchter | 30a3945 | 2015-04-22 10:02:41 -0600 | [diff] [blame] | 754 | alloc_memory(); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 755 | } |
| 756 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame^] | 757 | void AttachmentView::init(const Device &dev, const VkAttachmentViewCreateInfo &info) |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 758 | { |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame^] | 759 | DERIVED_OBJECT_TYPE_INIT(vkCreateAttachmentView, dev, VK_OBJECT_TYPE_ATTACHMENT_VIEW, &info); |
Courtney Goeltzenleuchter | 30a3945 | 2015-04-22 10:02:41 -0600 | [diff] [blame] | 760 | alloc_memory(); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 761 | } |
| 762 | |
Courtney Goeltzenleuchter | ee4027d | 2015-06-28 13:01:17 -0600 | [diff] [blame] | 763 | void ShaderModule::init(const Device &dev, const VkShaderModuleCreateInfo &info) |
| 764 | { |
| 765 | DERIVED_OBJECT_TYPE_INIT(vkCreateShaderModule, dev, VK_OBJECT_TYPE_SHADER_MODULE, &info); |
| 766 | } |
| 767 | |
| 768 | VkResult ShaderModule::init_try(const Device &dev, const VkShaderModuleCreateInfo &info) |
| 769 | { |
| 770 | /* |
| 771 | * Note: Cannot use DERIVED_OBJECT_TYPE_INIT as we need the |
| 772 | * return code. |
| 773 | */ |
| 774 | VkShaderModule sh; |
| 775 | dev_ = &dev; |
| 776 | VkResult err = vkCreateShaderModule(dev.obj(), &info, &sh); |
| 777 | if (err == VK_SUCCESS) |
| 778 | Object::init(sh, VK_OBJECT_TYPE_SHADER_MODULE); |
| 779 | |
| 780 | return err; |
| 781 | } |
| 782 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 783 | void Shader::init(const Device &dev, const VkShaderCreateInfo &info) |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 784 | { |
Courtney Goeltzenleuchter | 992fb4f | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 785 | DERIVED_OBJECT_TYPE_INIT(vkCreateShader, dev, VK_OBJECT_TYPE_SHADER, &info); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 786 | } |
| 787 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 788 | VkResult Shader::init_try(const Device &dev, const VkShaderCreateInfo &info) |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 789 | { |
Courtney Goeltzenleuchter | 992fb4f | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 790 | /* |
| 791 | * Note: Cannot use DERIVED_OBJECT_TYPE_INIT as we need the |
| 792 | * return code. |
| 793 | */ |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 794 | VkShader sh; |
Courtney Goeltzenleuchter | 992fb4f | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 795 | dev_ = &dev; |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 796 | VkResult err = vkCreateShader(dev.obj(), &info, &sh); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 797 | if (err == VK_SUCCESS) |
Courtney Goeltzenleuchter | 992fb4f | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 798 | Object::init(sh, VK_OBJECT_TYPE_SHADER); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 799 | |
| 800 | return err; |
| 801 | } |
| 802 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 803 | void Pipeline::init(const Device &dev, const VkGraphicsPipelineCreateInfo &info) |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 804 | { |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 805 | VkPipelineCache cache; |
| 806 | VkPipelineCacheCreateInfo ci; |
| 807 | memset((void *) &ci, 0, sizeof(VkPipelineCacheCreateInfo)); |
| 808 | ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 809 | VkResult err = vkCreatePipelineCache(dev.obj(), &ci, &cache); |
| 810 | if (err == VK_SUCCESS) { |
| 811 | DERIVED_OBJECT_TYPE_INIT(vkCreateGraphicsPipelines, dev, VK_OBJECT_TYPE_PIPELINE, cache, 1, &info); |
| 812 | alloc_memory(); |
| 813 | vkDestroyPipelineCache(dev.obj(), cache); |
| 814 | } |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 815 | } |
| 816 | |
Chris Forbes | 95292b1 | 2015-05-25 11:13:26 +1200 | [diff] [blame] | 817 | VkResult Pipeline::init_try(const Device &dev, const VkGraphicsPipelineCreateInfo &info) |
| 818 | { |
| 819 | VkPipeline pipe; |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 820 | VkPipelineCache cache; |
| 821 | VkPipelineCacheCreateInfo ci; |
Chris Forbes | 95292b1 | 2015-05-25 11:13:26 +1200 | [diff] [blame] | 822 | dev_ = &dev; |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 823 | memset((void *) &ci, 0, sizeof(VkPipelineCacheCreateInfo)); |
| 824 | ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 825 | VkResult err = vkCreatePipelineCache(dev.obj(), &ci, &cache); |
Chris Forbes | 95292b1 | 2015-05-25 11:13:26 +1200 | [diff] [blame] | 826 | if (err == VK_SUCCESS) { |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 827 | err = vkCreateGraphicsPipelines(dev.obj(), cache, 1, &info, &pipe); |
| 828 | if (err == VK_SUCCESS) { |
| 829 | Object::init(pipe, VK_OBJECT_TYPE_PIPELINE); |
| 830 | alloc_memory(); |
| 831 | vkDestroyPipelineCache(dev.obj(), cache); |
| 832 | } |
Chris Forbes | 95292b1 | 2015-05-25 11:13:26 +1200 | [diff] [blame] | 833 | } |
| 834 | |
| 835 | return err; |
| 836 | } |
| 837 | |
Courtney Goeltzenleuchter | 0d40f15 | 2015-03-25 15:37:49 -0600 | [diff] [blame] | 838 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 839 | void Pipeline::init(const Device &dev, const VkComputePipelineCreateInfo &info) |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 840 | { |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 841 | VkPipelineCache cache; |
| 842 | VkPipelineCacheCreateInfo ci; |
| 843 | memset((void *) &ci, 0, sizeof(VkPipelineCacheCreateInfo)); |
| 844 | ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 845 | VkResult err = vkCreatePipelineCache(dev.obj(), &ci, &cache); |
| 846 | if (err == VK_SUCCESS) { |
| 847 | DERIVED_OBJECT_TYPE_INIT(vkCreateComputePipelines, dev, VK_OBJECT_TYPE_PIPELINE, cache, 1, &info); |
| 848 | alloc_memory(); |
| 849 | vkDestroyPipelineCache(dev.obj(), cache); |
| 850 | } |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 851 | } |
| 852 | |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 853 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 854 | void Sampler::init(const Device &dev, const VkSamplerCreateInfo &info) |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 855 | { |
Courtney Goeltzenleuchter | 992fb4f | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 856 | DERIVED_OBJECT_TYPE_INIT(vkCreateSampler, dev, VK_OBJECT_TYPE_SAMPLER, &info); |
Courtney Goeltzenleuchter | 30a3945 | 2015-04-22 10:02:41 -0600 | [diff] [blame] | 857 | alloc_memory(); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 858 | } |
| 859 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 860 | void DescriptorSetLayout::init(const Device &dev, const VkDescriptorSetLayoutCreateInfo &info) |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 861 | { |
Courtney Goeltzenleuchter | 992fb4f | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 862 | DERIVED_OBJECT_TYPE_INIT(vkCreateDescriptorSetLayout, dev, VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT, &info); |
Courtney Goeltzenleuchter | 30a3945 | 2015-04-22 10:02:41 -0600 | [diff] [blame] | 863 | alloc_memory(); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 864 | } |
| 865 | |
Mark Lobodzinski | 0fadf5f | 2015-04-17 14:11:39 -0500 | [diff] [blame] | 866 | void PipelineLayout::init(const Device &dev, VkPipelineLayoutCreateInfo &info, const std::vector<const DescriptorSetLayout *> &layouts) |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 867 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 868 | const std::vector<VkDescriptorSetLayout> layout_objs = make_objects<VkDescriptorSetLayout>(layouts); |
Mark Lobodzinski | 0fadf5f | 2015-04-17 14:11:39 -0500 | [diff] [blame] | 869 | info.pSetLayouts = &layout_objs[0]; |
Chia-I Wu | 41126e5 | 2015-03-26 15:27:55 +0800 | [diff] [blame] | 870 | |
Courtney Goeltzenleuchter | 992fb4f | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 871 | DERIVED_OBJECT_TYPE_INIT(vkCreatePipelineLayout, dev, VK_OBJECT_TYPE_PIPELINE_LAYOUT, &info); |
Courtney Goeltzenleuchter | 30a3945 | 2015-04-22 10:02:41 -0600 | [diff] [blame] | 872 | alloc_memory(); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 873 | } |
| 874 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 875 | void DescriptorPool::init(const Device &dev, VkDescriptorPoolUsage usage, |
| 876 | uint32_t max_sets, const VkDescriptorPoolCreateInfo &info) |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 877 | { |
Courtney Goeltzenleuchter | 992fb4f | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 878 | DERIVED_OBJECT_TYPE_INIT(vkCreateDescriptorPool, dev, VK_OBJECT_TYPE_DESCRIPTOR_POOL, usage, max_sets, &info); |
Courtney Goeltzenleuchter | 30a3945 | 2015-04-22 10:02:41 -0600 | [diff] [blame] | 879 | alloc_memory(); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 880 | } |
| 881 | |
Chia-I Wu | fae40bc | 2015-03-26 15:23:52 +0800 | [diff] [blame] | 882 | void DescriptorPool::reset() |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 883 | { |
Courtney Goeltzenleuchter | 992fb4f | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 884 | EXPECT(vkResetDescriptorPool(dev_->obj(), obj()) == VK_SUCCESS); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 885 | } |
| 886 | |
Mark Lobodzinski | 40f7f40 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 887 | std::vector<DescriptorSet *> DescriptorPool::alloc_sets(const Device &dev, VkDescriptorSetUsage usage, const std::vector<const DescriptorSetLayout *> &layouts) |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 888 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 889 | const std::vector<VkDescriptorSetLayout> layout_objs = make_objects<VkDescriptorSetLayout>(layouts); |
Chia-I Wu | 11078b0 | 2015-01-04 16:27:24 +0800 | [diff] [blame] | 890 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 891 | std::vector<VkDescriptorSet> set_objs; |
Chia-I Wu | 11078b0 | 2015-01-04 16:27:24 +0800 | [diff] [blame] | 892 | set_objs.resize(layout_objs.size()); |
| 893 | |
| 894 | uint32_t set_count; |
Courtney Goeltzenleuchter | 992fb4f | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 895 | VkResult err = vkAllocDescriptorSets(dev_->obj(), obj(), usage, layout_objs.size(), &layout_objs[0], &set_objs[0], &set_count); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 896 | if (err == VK_SUCCESS) |
Chia-I Wu | 11078b0 | 2015-01-04 16:27:24 +0800 | [diff] [blame] | 897 | EXPECT(set_count == set_objs.size()); |
| 898 | set_objs.resize(set_count); |
| 899 | |
| 900 | std::vector<DescriptorSet *> sets; |
| 901 | sets.reserve(set_count); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 902 | for (std::vector<VkDescriptorSet>::const_iterator it = set_objs.begin(); it != set_objs.end(); it++) { |
Chia-I Wu | 11078b0 | 2015-01-04 16:27:24 +0800 | [diff] [blame] | 903 | // do descriptor sets need memories bound? |
Courtney Goeltzenleuchter | 992fb4f | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 904 | DescriptorSet *descriptorSet = new DescriptorSet(dev, *it); |
Mark Lobodzinski | 40f7f40 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 905 | sets.push_back(descriptorSet); |
Chia-I Wu | 11078b0 | 2015-01-04 16:27:24 +0800 | [diff] [blame] | 906 | } |
Chia-I Wu | 11078b0 | 2015-01-04 16:27:24 +0800 | [diff] [blame] | 907 | return sets; |
| 908 | } |
| 909 | |
Mark Lobodzinski | 40f7f40 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 910 | std::vector<DescriptorSet *> DescriptorPool::alloc_sets(const Device &dev, VkDescriptorSetUsage usage, const DescriptorSetLayout &layout, uint32_t count) |
Chia-I Wu | 11078b0 | 2015-01-04 16:27:24 +0800 | [diff] [blame] | 911 | { |
Mark Lobodzinski | 40f7f40 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 912 | return alloc_sets(dev, usage, std::vector<const DescriptorSetLayout *>(count, &layout)); |
Chia-I Wu | 11078b0 | 2015-01-04 16:27:24 +0800 | [diff] [blame] | 913 | } |
| 914 | |
Mark Lobodzinski | 40f7f40 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 915 | DescriptorSet *DescriptorPool::alloc_sets(const Device &dev, VkDescriptorSetUsage usage, const DescriptorSetLayout &layout) |
Chia-I Wu | 11078b0 | 2015-01-04 16:27:24 +0800 | [diff] [blame] | 916 | { |
Mark Lobodzinski | 40f7f40 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 917 | std::vector<DescriptorSet *> set = alloc_sets(dev, usage, layout, 1); |
Chia-I Wu | 11078b0 | 2015-01-04 16:27:24 +0800 | [diff] [blame] | 918 | return (set.empty()) ? NULL : set[0]; |
| 919 | } |
| 920 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 921 | void DynamicVpStateObject::init(const Device &dev, const VkDynamicVpStateCreateInfo &info) |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 922 | { |
Courtney Goeltzenleuchter | 992fb4f | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 923 | DERIVED_OBJECT_TYPE_INIT(vkCreateDynamicViewportState, dev, VK_OBJECT_TYPE_DYNAMIC_VP_STATE, &info); |
Courtney Goeltzenleuchter | 30a3945 | 2015-04-22 10:02:41 -0600 | [diff] [blame] | 924 | alloc_memory(); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 925 | } |
| 926 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 927 | void DynamicRsStateObject::init(const Device &dev, const VkDynamicRsStateCreateInfo &info) |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 928 | { |
Courtney Goeltzenleuchter | 992fb4f | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 929 | DERIVED_OBJECT_TYPE_INIT(vkCreateDynamicRasterState, dev, VK_OBJECT_TYPE_DYNAMIC_RS_STATE, &info); |
Courtney Goeltzenleuchter | 30a3945 | 2015-04-22 10:02:41 -0600 | [diff] [blame] | 930 | alloc_memory(); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 931 | } |
| 932 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 933 | void DynamicCbStateObject::init(const Device &dev, const VkDynamicCbStateCreateInfo &info) |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 934 | { |
Courtney Goeltzenleuchter | 992fb4f | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 935 | DERIVED_OBJECT_TYPE_INIT(vkCreateDynamicColorBlendState, dev, VK_OBJECT_TYPE_DYNAMIC_CB_STATE, &info); |
Courtney Goeltzenleuchter | 30a3945 | 2015-04-22 10:02:41 -0600 | [diff] [blame] | 936 | alloc_memory(); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 937 | } |
| 938 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 939 | void DynamicDsStateObject::init(const Device &dev, const VkDynamicDsStateCreateInfo &info) |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 940 | { |
Courtney Goeltzenleuchter | 992fb4f | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 941 | DERIVED_OBJECT_TYPE_INIT(vkCreateDynamicDepthStencilState, dev, VK_OBJECT_TYPE_DYNAMIC_DS_STATE, &info); |
Courtney Goeltzenleuchter | 30a3945 | 2015-04-22 10:02:41 -0600 | [diff] [blame] | 942 | alloc_memory(); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 943 | } |
| 944 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 945 | void CmdBuffer::init(const Device &dev, const VkCmdBufferCreateInfo &info) |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 946 | { |
Courtney Goeltzenleuchter | 992fb4f | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 947 | DERIVED_OBJECT_TYPE_INIT(vkCreateCommandBuffer, dev, VK_OBJECT_TYPE_COMMAND_BUFFER, &info); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 948 | } |
| 949 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 950 | void CmdBuffer::begin(const VkCmdBufferBeginInfo *info) |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 951 | { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 952 | EXPECT(vkBeginCommandBuffer(obj(), info) == VK_SUCCESS); |
Jeremy Hayes | d65ae08 | 2015-01-14 16:17:08 -0700 | [diff] [blame] | 953 | } |
| 954 | |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 955 | void CmdBuffer::begin() |
| 956 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 957 | VkCmdBufferBeginInfo info = {}; |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 958 | info.flags = VK_CMD_BUFFER_OPTIMIZE_SMALL_BATCH_BIT | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 959 | VK_CMD_BUFFER_OPTIMIZE_ONE_TIME_SUBMIT_BIT; |
| 960 | info.sType = VK_STRUCTURE_TYPE_CMD_BUFFER_BEGIN_INFO; |
Jeremy Hayes | d65ae08 | 2015-01-14 16:17:08 -0700 | [diff] [blame] | 961 | |
| 962 | begin(&info); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 963 | } |
| 964 | |
| 965 | void CmdBuffer::end() |
| 966 | { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 967 | EXPECT(vkEndCommandBuffer(obj()) == VK_SUCCESS); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 968 | } |
| 969 | |
| 970 | void CmdBuffer::reset() |
| 971 | { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 972 | EXPECT(vkResetCommandBuffer(obj()) == VK_SUCCESS); |
Chia-I Wu | f1e2e99 | 2014-12-27 14:12:52 +0800 | [diff] [blame] | 973 | } |
| 974 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 975 | }; // namespace vk_testing |