Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1 | // VK tests |
| 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 | #ifndef VKTESTBINDING_H |
| 24 | #define VKTESTBINDING_H |
| 25 | |
| 26 | #include <vector> |
| 27 | |
| 28 | #include "vulkan.h" |
| 29 | |
| 30 | namespace vk_testing { |
| 31 | |
| 32 | typedef void (*ErrorCallback)(const char *expr, const char *file, unsigned int line, const char *function); |
| 33 | void set_error_callback(ErrorCallback callback); |
| 34 | |
| 35 | class PhysicalGpu; |
| 36 | class BaseObject; |
| 37 | class Object; |
| 38 | class DynamicStateObject; |
| 39 | class Device; |
| 40 | class Queue; |
| 41 | class GpuMemory; |
| 42 | class Fence; |
| 43 | class Semaphore; |
| 44 | class Event; |
| 45 | class QueryPool; |
| 46 | class Buffer; |
| 47 | class BufferView; |
| 48 | class Image; |
| 49 | class ImageView; |
| 50 | class ColorAttachmentView; |
| 51 | class DepthStencilView; |
| 52 | class Shader; |
| 53 | class Pipeline; |
| 54 | class PipelineDelta; |
| 55 | class Sampler; |
| 56 | class DescriptorSetLayout; |
Mark Lobodzinski | 556f721 | 2015-04-17 14:11:39 -0500 | [diff] [blame] | 57 | class PipelineLayout; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 58 | class DescriptorSetPool; |
| 59 | class DescriptorSet; |
| 60 | class DynamicVpStateObject; |
| 61 | class DynamicRsStateObject; |
| 62 | class DynamicMsaaStateObject; |
| 63 | class DynamicCbStateObject; |
| 64 | class DynamicDsStateObject; |
| 65 | class CmdBuffer; |
| 66 | |
| 67 | class PhysicalGpu { |
| 68 | public: |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 69 | explicit PhysicalGpu(VkPhysicalDevice gpu) : gpu_(gpu) {} |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 70 | |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 71 | const VkPhysicalDevice &obj() const { return gpu_; } |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 72 | |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 73 | // vkGetPhysicalDeviceInfo() |
| 74 | VkPhysicalDeviceProperties properties() const; |
| 75 | VkPhysicalDevicePerformance performance() const; |
| 76 | VkPhysicalDeviceMemoryProperties memory_properties() const; |
| 77 | std::vector<VkPhysicalDeviceQueueProperties> queue_properties() const; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 78 | |
| 79 | // vkGetProcAddr() |
| 80 | void *get_proc(const char *name) const { return vkGetProcAddr(gpu_, name); } |
| 81 | |
Tobin Ehlis | f6cc4e7 | 2015-04-16 10:13:25 -0600 | [diff] [blame] | 82 | // vkGetGlobalExtensionInfo() |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 83 | std::vector<const char *> extensions() const; |
| 84 | |
| 85 | // vkEnumerateLayers() |
| 86 | std::vector<const char *> layers(std::vector<char> &buf) const; |
| 87 | |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 88 | // vkGetMultiDeviceCompatibility() |
| 89 | VkPhysicalDeviceCompatibilityInfo compatibility(const PhysicalGpu &other) const; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 90 | |
| 91 | private: |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 92 | VkPhysicalDevice gpu_; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 93 | }; |
| 94 | |
| 95 | class BaseObject { |
| 96 | public: |
Mike Stroyan | 230e625 | 2015-04-17 12:36:38 -0600 | [diff] [blame] | 97 | const VkObject &obj() const { return obj_; } |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 98 | VkObjectType type() const { return object_type_; } |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 99 | bool initialized() const { return (obj_ != VK_NULL_HANDLE); } |
| 100 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 101 | protected: |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 102 | explicit BaseObject() : |
| 103 | object_type_((VkObjectType) 0), obj_(VK_NULL_HANDLE), own_obj_(false){} |
| 104 | explicit BaseObject(VkObject obj, VkObjectType object_type) : |
| 105 | object_type_(object_type), obj_(obj), own_obj_(false){} |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 106 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 107 | void init(VkObject obj, VkObjectType object_type, bool own); |
| 108 | void init(VkObject obj, VkObjectType object_type) { init(obj, object_type, true); } |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 109 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 110 | void reinit(VkObject obj, VkObjectType object_type, bool own); |
| 111 | void reinit(VkObject obj, VkObjectType object_type) { reinit(obj, object_type, true); } |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 112 | |
| 113 | bool own() const { return own_obj_; } |
| 114 | |
| 115 | private: |
| 116 | // base objects are non-copyable |
| 117 | BaseObject(const BaseObject &); |
| 118 | BaseObject &operator=(const BaseObject &); |
| 119 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 120 | VkObjectType object_type_; |
Mike Stroyan | 230e625 | 2015-04-17 12:36:38 -0600 | [diff] [blame] | 121 | VkObject obj_; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 122 | bool own_obj_; |
| 123 | }; |
| 124 | |
| 125 | class Object : public BaseObject { |
| 126 | public: |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 127 | const VkObject &obj() const { return reinterpret_cast<const VkObject &>(BaseObject::obj()); } |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 128 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 129 | // vkGetObjectInfo() |
| 130 | uint32_t memory_allocation_count() const; |
| 131 | std::vector<VkMemoryRequirements> memory_requirements() const; |
| 132 | |
Mark Lobodzinski | fb9f564 | 2015-05-11 17:21:15 -0500 | [diff] [blame] | 133 | // vkBindObjectMemory() |
Mark Lobodzinski | 2318261 | 2015-05-29 09:32:35 -0500 | [diff] [blame^] | 134 | void bind_memory(const GpuMemory &mem, VkDeviceSize mem_offset); |
Courtney Goeltzenleuchter | 9c6d94f | 2015-04-22 10:02:41 -0600 | [diff] [blame] | 135 | void unbind_memory(); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 136 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 137 | // Unless an object is initialized with init_no_mem(), memories are |
Courtney Goeltzenleuchter | ac83452 | 2015-05-01 17:56:13 -0600 | [diff] [blame] | 138 | // automatically allocated and bound. These methods can be used to |
| 139 | // map/unmap the primary memory. |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 140 | std::vector<VkDeviceMemory> memories() const; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 141 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 142 | const void *map(VkFlags flags) const; |
| 143 | void *map(VkFlags flags); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 144 | const void *map() const { return map(0); } |
| 145 | void *map() { return map(0); } |
| 146 | |
| 147 | void unmap() const; |
Mark Lobodzinski | cf26e07 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 148 | const Device* dev_; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 149 | |
| 150 | protected: |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 151 | explicit Object() : |
| 152 | mem_alloc_count_(0), internal_mems_(NULL), |
| 153 | primary_mem_(NULL), bound(false) {} |
| 154 | explicit Object(const Device &dev, VkObject obj, VkObjectType object_type) : |
| 155 | dev_(&dev), |
| 156 | mem_alloc_count_(0), internal_mems_(NULL), |
| 157 | primary_mem_(NULL) { init(obj, object_type); } |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 158 | ~Object() { cleanup(); } |
| 159 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 160 | void init(VkObject obj, VkObjectType object_type, bool own); |
| 161 | void init(VkObject obj, VkObjectType object_type) { init(obj, object_type, true); } |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 162 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 163 | void reinit(VkObject obj, VkObjectType object_type, bool own); |
| 164 | void reinit(VkObject obj, VkObjectType object_type) { init(obj, object_type, true); } |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 165 | |
| 166 | // allocate and bind internal memories |
Courtney Goeltzenleuchter | 9c6d94f | 2015-04-22 10:02:41 -0600 | [diff] [blame] | 167 | void alloc_memory(); |
Tony Barbour | 9431056 | 2015-04-22 15:10:33 -0600 | [diff] [blame] | 168 | void alloc_memory(VkMemoryPropertyFlags &reqs); |
Courtney Goeltzenleuchter | 9c6d94f | 2015-04-22 10:02:41 -0600 | [diff] [blame] | 169 | void alloc_memory(const std::vector<VkDeviceMemory> &mems); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 170 | |
| 171 | private: |
| 172 | void cleanup(); |
| 173 | |
| 174 | uint32_t mem_alloc_count_; |
| 175 | GpuMemory *internal_mems_; |
| 176 | GpuMemory *primary_mem_; |
Tony Barbour | 2b5fb34 | 2015-04-09 16:00:18 -0600 | [diff] [blame] | 177 | bool bound; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 178 | }; |
| 179 | |
| 180 | class DynamicStateObject : public Object { |
| 181 | public: |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 182 | const VkDynamicStateObject &obj() const { return reinterpret_cast<const VkDynamicStateObject &>(Object::obj()); } |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 183 | |
| 184 | protected: |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 185 | explicit DynamicStateObject() : Object() {} |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 186 | }; |
| 187 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 188 | template<typename T, class C, VkObjectType V> |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 189 | class DerivedObject : public C { |
| 190 | public: |
| 191 | const T &obj() const { return reinterpret_cast<const T &>(C::obj()); } |
| 192 | |
| 193 | protected: |
| 194 | typedef T obj_type; |
| 195 | typedef C base_type; |
| 196 | |
| 197 | explicit DerivedObject() {} |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 198 | explicit DerivedObject(T obj) : C(obj, V) {} |
| 199 | explicit DerivedObject(const Device &dev, T obj) : C(dev, obj, V) {} |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 200 | }; |
| 201 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 202 | class Device : public DerivedObject<VkDevice, BaseObject, VK_OBJECT_TYPE_DEVICE> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 203 | public: |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 204 | explicit Device(VkPhysicalDevice gpu) : gpu_(gpu) {} |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 205 | ~Device(); |
| 206 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 207 | VkDevice device() const { return obj(); } |
| 208 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 209 | // vkCreateDevice() |
Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 210 | void init(const VkDeviceCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 211 | void init(bool enable_layers); // all queues, all extensions, etc |
| 212 | void init() { init(false); }; |
| 213 | |
| 214 | const PhysicalGpu &gpu() const { return gpu_; } |
| 215 | |
| 216 | // vkGetDeviceQueue() |
Mark Lobodzinski | cf26e07 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 217 | const std::vector<Queue *> &graphics_queues() const { return queues_[GRAPHICS]; } |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 218 | const std::vector<Queue *> &compute_queues() { return queues_[COMPUTE]; } |
| 219 | const std::vector<Queue *> &dma_queues() { return queues_[DMA]; } |
| 220 | uint32_t graphics_queue_node_index_; |
| 221 | |
| 222 | struct Format { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 223 | VkFormat format; |
| 224 | VkImageTiling tiling; |
| 225 | VkFlags features; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 226 | }; |
| 227 | // vkGetFormatInfo() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 228 | VkFormatProperties format_properties(VkFormat format); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 229 | const std::vector<Format> &formats() const { return formats_; } |
| 230 | |
| 231 | // vkDeviceWaitIdle() |
| 232 | void wait(); |
| 233 | |
| 234 | // vkWaitForFences() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 235 | VkResult wait(const std::vector<const Fence *> &fences, bool wait_all, uint64_t timeout); |
| 236 | VkResult wait(const Fence &fence) { return wait(std::vector<const Fence *>(1, &fence), true, (uint64_t) -1); } |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 237 | |
| 238 | // vkBeginDescriptorPoolUpdate() |
| 239 | // vkEndDescriptorPoolUpdate() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 240 | void begin_descriptor_pool_update(VkDescriptorUpdateMode mode); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 241 | void end_descriptor_pool_update(CmdBuffer &cmd); |
| 242 | |
| 243 | private: |
| 244 | enum QueueIndex { |
| 245 | GRAPHICS, |
| 246 | COMPUTE, |
| 247 | DMA, |
| 248 | QUEUE_COUNT, |
| 249 | }; |
| 250 | |
| 251 | void init_queues(); |
| 252 | void init_formats(); |
| 253 | |
| 254 | PhysicalGpu gpu_; |
| 255 | |
| 256 | std::vector<Queue *> queues_[QUEUE_COUNT]; |
| 257 | std::vector<Format> formats_; |
| 258 | }; |
| 259 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 260 | class Queue : public DerivedObject<VkQueue, BaseObject, VK_OBJECT_TYPE_QUEUE> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 261 | public: |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 262 | explicit Queue(VkQueue queue) : DerivedObject(queue) {} |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 263 | |
| 264 | // vkQueueSubmit() |
| 265 | void submit(const std::vector<const CmdBuffer *> &cmds, Fence &fence); |
| 266 | void submit(const CmdBuffer &cmd, Fence &fence); |
| 267 | void submit(const CmdBuffer &cmd); |
| 268 | |
Courtney Goeltzenleuchter | 4696294 | 2015-04-16 13:38:46 -0600 | [diff] [blame] | 269 | // vkQueueAddMemReferences() |
| 270 | // vkQueueRemoveMemReferences() |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 271 | void add_mem_references(const std::vector<VkDeviceMemory> &mem_refs); |
| 272 | void remove_mem_references(const std::vector<VkDeviceMemory> &mem_refs); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 273 | |
| 274 | // vkQueueWaitIdle() |
| 275 | void wait(); |
| 276 | |
| 277 | // vkQueueSignalSemaphore() |
| 278 | // vkQueueWaitSemaphore() |
| 279 | void signal_semaphore(Semaphore &sem); |
| 280 | void wait_semaphore(Semaphore &sem); |
| 281 | }; |
| 282 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 283 | /* Note: This needs to be BaseObject so that we don't try to destroy |
| 284 | * the object when the object is device memory. |
| 285 | */ |
| 286 | class GpuMemory : public DerivedObject<VkDeviceMemory, BaseObject, VK_OBJECT_TYPE_DEVICE_MEMORY> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 287 | public: |
| 288 | ~GpuMemory(); |
| 289 | |
| 290 | // vkAllocMemory() |
Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 291 | void init(const Device &dev, const VkMemoryAllocInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 292 | // vkPinSystemMemory() |
| 293 | void init(const Device &dev, size_t size, const void *data); |
| 294 | // vkOpenSharedMemory() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 295 | void init(const Device &dev, const VkMemoryOpenInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 296 | // vkOpenPeerMemory() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 297 | void init(const Device &dev, const VkPeerMemoryOpenInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 298 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 299 | void init(const Device &dev, VkDeviceMemory mem); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 300 | |
| 301 | // vkSetMemoryPriority() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 302 | void set_priority(VkMemoryPriority priority); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 303 | |
| 304 | // vkMapMemory() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 305 | const void *map(VkFlags flags) const; |
| 306 | void *map(VkFlags flags); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 307 | const void *map() const { return map(0); } |
| 308 | void *map() { return map(0); } |
| 309 | |
| 310 | // vkUnmapMemory() |
| 311 | void unmap() const; |
| 312 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 313 | static VkMemoryAllocInfo alloc_info(const VkMemoryRequirements &reqs, |
Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 314 | const VkMemoryAllocInfo *next_info); |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 315 | private: |
| 316 | const Device* dev_; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 317 | }; |
| 318 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 319 | class Fence : public DerivedObject<VkFence, Object, VK_OBJECT_TYPE_FENCE> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 320 | public: |
| 321 | // vkCreateFence() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 322 | void init(const Device &dev, const VkFenceCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 323 | |
| 324 | // vkGetFenceStatus() |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 325 | VkResult status() const { return vkGetFenceStatus(dev_->obj(), obj()); } |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 326 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 327 | static VkFenceCreateInfo create_info(VkFenceCreateFlags flags); |
| 328 | static VkFenceCreateInfo create_info(); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 329 | }; |
| 330 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 331 | class Semaphore : public DerivedObject<VkSemaphore, Object, VK_OBJECT_TYPE_SEMAPHORE> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 332 | public: |
| 333 | // vkCreateSemaphore() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 334 | void init(const Device &dev, const VkSemaphoreCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 335 | // vkOpenSharedSemaphore() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 336 | void init(const Device &dev, const VkSemaphoreOpenInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 337 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 338 | static VkSemaphoreCreateInfo create_info(uint32_t init_count, VkFlags flags); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 339 | }; |
| 340 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 341 | class Event : public DerivedObject<VkEvent, Object, VK_OBJECT_TYPE_EVENT> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 342 | public: |
| 343 | // vkCreateEvent() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 344 | void init(const Device &dev, const VkEventCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 345 | |
| 346 | // vkGetEventStatus() |
| 347 | // vkSetEvent() |
| 348 | // vkResetEvent() |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 349 | VkResult status() const { return vkGetEventStatus(dev_->obj(), obj()); } |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 350 | void set(); |
| 351 | void reset(); |
| 352 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 353 | static VkEventCreateInfo create_info(VkFlags flags); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 354 | }; |
| 355 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 356 | class QueryPool : public DerivedObject<VkQueryPool, Object, VK_OBJECT_TYPE_QUERY_POOL> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 357 | public: |
| 358 | // vkCreateQueryPool() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 359 | void init(const Device &dev, const VkQueryPoolCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 360 | |
| 361 | // vkGetQueryPoolResults() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 362 | VkResult results(uint32_t start, uint32_t count, size_t size, void *data); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 363 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 364 | static VkQueryPoolCreateInfo create_info(VkQueryType type, uint32_t slot_count); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 365 | }; |
| 366 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 367 | class Buffer : public DerivedObject<VkBuffer, Object, VK_OBJECT_TYPE_BUFFER> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 368 | public: |
| 369 | explicit Buffer() {} |
Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 370 | explicit Buffer(const Device &dev, const VkBufferCreateInfo &info) { init(dev, info); } |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 371 | explicit Buffer(const Device &dev, VkDeviceSize size) { init(dev, size); } |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 372 | |
| 373 | // vkCreateBuffer() |
Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 374 | void init(const Device &dev, const VkBufferCreateInfo &info); |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 375 | void init(const Device &dev, VkDeviceSize size) { init(dev, create_info(size, 0)); } |
Tony Barbour | 9431056 | 2015-04-22 15:10:33 -0600 | [diff] [blame] | 376 | void init(const Device &dev, VkDeviceSize size, VkMemoryPropertyFlags &reqs) { init(dev, create_info(size, 0), reqs); } |
| 377 | void init(const Device &dev, const VkBufferCreateInfo &info, VkMemoryPropertyFlags &reqs); |
Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 378 | void init_no_mem(const Device &dev, const VkBufferCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 379 | |
Mark Lobodzinski | fb9f564 | 2015-05-11 17:21:15 -0500 | [diff] [blame] | 380 | // vkQueueBindSparseBufferMemory() |
Mark Lobodzinski | 2318261 | 2015-05-29 09:32:35 -0500 | [diff] [blame^] | 381 | void bind_memory(VkDeviceSize offset, VkDeviceSize size, |
Mark Lobodzinski | fb9f564 | 2015-05-11 17:21:15 -0500 | [diff] [blame] | 382 | const GpuMemory &mem, VkDeviceSize mem_offset); |
| 383 | |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 384 | static VkBufferCreateInfo create_info(VkDeviceSize size, VkFlags usage); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 385 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 386 | VkBufferMemoryBarrier buffer_memory_barrier(VkFlags output_mask, VkFlags input_mask, |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 387 | VkDeviceSize offset, VkDeviceSize size) const |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 388 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 389 | VkBufferMemoryBarrier barrier = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 390 | barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
| 391 | barrier.buffer = obj(); |
| 392 | barrier.outputMask = output_mask; |
| 393 | barrier.inputMask = input_mask; |
| 394 | barrier.offset = offset; |
| 395 | barrier.size = size; |
| 396 | return barrier; |
| 397 | } |
| 398 | private: |
Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 399 | VkBufferCreateInfo create_info_; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 400 | }; |
| 401 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 402 | class BufferView : public DerivedObject<VkBufferView, Object, VK_OBJECT_TYPE_BUFFER_VIEW> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 403 | public: |
| 404 | // vkCreateBufferView() |
Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 405 | void init(const Device &dev, const VkBufferViewCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 406 | }; |
| 407 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 408 | class Image : public DerivedObject<VkImage, Object, VK_OBJECT_TYPE_IMAGE> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 409 | public: |
| 410 | explicit Image() : format_features_(0) {} |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 411 | explicit Image(const Device &dev, const VkImageCreateInfo &info) : format_features_(0) { init(dev, info); } |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 412 | |
| 413 | // vkCreateImage() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 414 | void init(const Device &dev, const VkImageCreateInfo &info); |
Tony Barbour | 9431056 | 2015-04-22 15:10:33 -0600 | [diff] [blame] | 415 | void init(const Device &dev, const VkImageCreateInfo &info, VkMemoryPropertyFlags &reqs); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 416 | void init_no_mem(const Device &dev, const VkImageCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 417 | // vkOpenPeerImage() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 418 | void init(const Device &dev, const VkPeerImageOpenInfo &info, const VkImageCreateInfo &original_info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 419 | |
Mark Lobodzinski | fb9f564 | 2015-05-11 17:21:15 -0500 | [diff] [blame] | 420 | // vkQueueBindSparseImageMemory() |
Mark Lobodzinski | 2318261 | 2015-05-29 09:32:35 -0500 | [diff] [blame^] | 421 | void bind_memory(const Device &dev, const VkImageMemoryBindInfo &info, |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 422 | const GpuMemory &mem, VkDeviceSize mem_offset); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 423 | |
| 424 | // vkGetImageSubresourceInfo() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 425 | VkSubresourceLayout subresource_layout(const VkImageSubresource &subres) const; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 426 | |
| 427 | bool transparent() const; |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 428 | bool copyable() const { return (format_features_ & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT); } |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 429 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 430 | VkImageSubresourceRange subresource_range(VkImageAspect aspect) const { return subresource_range(create_info_, aspect); } |
| 431 | VkExtent3D extent() const { return create_info_.extent; } |
| 432 | VkExtent3D extent(uint32_t mip_level) const { return extent(create_info_.extent, mip_level); } |
| 433 | VkFormat format() const {return create_info_.format;} |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 434 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 435 | VkImageMemoryBarrier image_memory_barrier(VkFlags output_mask, VkFlags input_mask, |
| 436 | VkImageLayout old_layout, |
| 437 | VkImageLayout new_layout, |
| 438 | const VkImageSubresourceRange &range) const |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 439 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 440 | VkImageMemoryBarrier barrier = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 441 | barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| 442 | barrier.outputMask = output_mask; |
| 443 | barrier.inputMask = input_mask; |
| 444 | barrier.oldLayout = old_layout; |
| 445 | barrier.newLayout = new_layout; |
| 446 | barrier.image = obj(); |
| 447 | barrier.subresourceRange = range; |
| 448 | return barrier; |
| 449 | } |
| 450 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 451 | static VkImageCreateInfo create_info(); |
| 452 | static VkImageSubresource subresource(VkImageAspect aspect, uint32_t mip_level, uint32_t array_slice); |
| 453 | static VkImageSubresource subresource(const VkImageSubresourceRange &range, uint32_t mip_level, uint32_t array_slice); |
| 454 | static VkImageSubresourceRange subresource_range(VkImageAspect aspect, uint32_t base_mip_level, uint32_t mip_levels, |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 455 | uint32_t base_array_slice, uint32_t array_size); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 456 | static VkImageSubresourceRange subresource_range(const VkImageCreateInfo &info, VkImageAspect aspect); |
| 457 | static VkImageSubresourceRange subresource_range(const VkImageSubresource &subres); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 458 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 459 | static VkExtent2D extent(int32_t width, int32_t height); |
| 460 | static VkExtent2D extent(const VkExtent2D &extent, uint32_t mip_level); |
| 461 | static VkExtent2D extent(const VkExtent3D &extent); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 462 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 463 | static VkExtent3D extent(int32_t width, int32_t height, int32_t depth); |
| 464 | static VkExtent3D extent(const VkExtent3D &extent, uint32_t mip_level); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 465 | |
| 466 | private: |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 467 | void init_info(const Device &dev, const VkImageCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 468 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 469 | VkImageCreateInfo create_info_; |
| 470 | VkFlags format_features_; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 471 | }; |
| 472 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 473 | class ImageView : public DerivedObject<VkImageView, Object, VK_OBJECT_TYPE_IMAGE_VIEW> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 474 | public: |
| 475 | // vkCreateImageView() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 476 | void init(const Device &dev, const VkImageViewCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 477 | }; |
| 478 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 479 | class ColorAttachmentView : public DerivedObject<VkColorAttachmentView, Object, VK_OBJECT_TYPE_COLOR_ATTACHMENT_VIEW> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 480 | public: |
| 481 | // vkCreateColorAttachmentView() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 482 | void init(const Device &dev, const VkColorAttachmentViewCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 483 | }; |
| 484 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 485 | class DepthStencilView : public DerivedObject<VkDepthStencilView, Object, VK_OBJECT_TYPE_DEPTH_STENCIL_VIEW> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 486 | public: |
| 487 | // vkCreateDepthStencilView() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 488 | void init(const Device &dev, const VkDepthStencilViewCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 489 | }; |
| 490 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 491 | class Shader : public DerivedObject<VkShader, Object, VK_OBJECT_TYPE_SHADER> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 492 | public: |
| 493 | // vkCreateShader() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 494 | void init(const Device &dev, const VkShaderCreateInfo &info); |
| 495 | VkResult init_try(const Device &dev, const VkShaderCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 496 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 497 | static VkShaderCreateInfo create_info(size_t code_size, const void *code, VkFlags flags); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 498 | }; |
| 499 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 500 | class Pipeline : public DerivedObject<VkPipeline, Object, VK_OBJECT_TYPE_PIPELINE> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 501 | public: |
| 502 | // vkCreateGraphicsPipeline() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 503 | void init(const Device &dev, const VkGraphicsPipelineCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 504 | // vkCreateGraphicsPipelineDerivative() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 505 | void init(const Device &dev, const VkGraphicsPipelineCreateInfo &info, const VkPipeline basePipeline); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 506 | // vkCreateComputePipeline() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 507 | void init(const Device &dev, const VkComputePipelineCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 508 | // vkLoadPipeline() |
| 509 | void init(const Device&dev, size_t size, const void *data); |
| 510 | // vkLoadPipelineDerivative() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 511 | void init(const Device&dev, size_t size, const void *data, VkPipeline basePipeline); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 512 | |
| 513 | // vkStorePipeline() |
| 514 | size_t store(size_t size, void *data); |
| 515 | }; |
| 516 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 517 | class Sampler : public DerivedObject<VkSampler, Object, VK_OBJECT_TYPE_SAMPLER> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 518 | public: |
| 519 | // vkCreateSampler() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 520 | void init(const Device &dev, const VkSamplerCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 521 | }; |
| 522 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 523 | class DescriptorSetLayout : public DerivedObject<VkDescriptorSetLayout, Object, VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 524 | public: |
| 525 | // vkCreateDescriptorSetLayout() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 526 | void init(const Device &dev, const VkDescriptorSetLayoutCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 527 | }; |
| 528 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 529 | class PipelineLayout : public DerivedObject<VkPipelineLayout, Object, VK_OBJECT_TYPE_PIPELINE_LAYOUT> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 530 | public: |
Mark Lobodzinski | 556f721 | 2015-04-17 14:11:39 -0500 | [diff] [blame] | 531 | // vCreatePipelineLayout() |
| 532 | void init(const Device &dev, VkPipelineLayoutCreateInfo &info, const std::vector<const DescriptorSetLayout *> &layouts); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 533 | }; |
| 534 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 535 | class DescriptorPool : public DerivedObject<VkDescriptorPool, Object, VK_OBJECT_TYPE_DESCRIPTOR_POOL> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 536 | public: |
| 537 | // vkCreateDescriptorPool() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 538 | void init(const Device &dev, VkDescriptorPoolUsage usage, |
| 539 | uint32_t max_sets, const VkDescriptorPoolCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 540 | |
| 541 | // vkResetDescriptorPool() |
| 542 | void reset(); |
| 543 | |
| 544 | // vkAllocDescriptorSets() |
Mark Lobodzinski | cf26e07 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 545 | std::vector<DescriptorSet *> alloc_sets(const Device &dev, VkDescriptorSetUsage usage, const std::vector<const DescriptorSetLayout *> &layouts); |
| 546 | std::vector<DescriptorSet *> alloc_sets(const Device &dev, VkDescriptorSetUsage usage, const DescriptorSetLayout &layout, uint32_t count); |
| 547 | DescriptorSet *alloc_sets(const Device &dev, VkDescriptorSetUsage usage, const DescriptorSetLayout &layout); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 548 | |
| 549 | // vkClearDescriptorSets() |
| 550 | void clear_sets(const std::vector<DescriptorSet *> &sets); |
| 551 | void clear_sets(DescriptorSet &set) { clear_sets(std::vector<DescriptorSet *>(1, &set)); } |
| 552 | }; |
| 553 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 554 | class DescriptorSet : public DerivedObject<VkDescriptorSet, Object, VK_OBJECT_TYPE_DESCRIPTOR_SET> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 555 | public: |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 556 | explicit DescriptorSet(const Device &dev, VkDescriptorSet set) : DerivedObject(dev, set) {} |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 557 | |
| 558 | // vkUpdateDescriptors() |
| 559 | void update(const std::vector<const void *> &update_array); |
| 560 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 561 | static VkUpdateSamplers update(uint32_t binding, uint32_t index, uint32_t count, const VkSampler *samplers); |
| 562 | static VkUpdateSamplers update(uint32_t binding, uint32_t index, const std::vector<VkSampler> &samplers); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 563 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 564 | static VkUpdateSamplerTextures update(uint32_t binding, uint32_t index, uint32_t count, const VkSamplerImageViewInfo *textures); |
| 565 | static VkUpdateSamplerTextures update(uint32_t binding, uint32_t index, const std::vector<VkSamplerImageViewInfo> &textures); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 566 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 567 | static VkUpdateImages update(VkDescriptorType type, uint32_t binding, uint32_t index, uint32_t count, const VkImageViewAttachInfo *views); |
| 568 | static VkUpdateImages update(VkDescriptorType type, uint32_t binding, uint32_t index, const std::vector<VkImageViewAttachInfo> &views); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 569 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 570 | static VkUpdateBuffers update(VkDescriptorType type, uint32_t binding, uint32_t index, uint32_t count, const VkBufferViewAttachInfo *views); |
| 571 | static VkUpdateBuffers update(VkDescriptorType type, uint32_t binding, uint32_t index, const std::vector<VkBufferViewAttachInfo> &views); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 572 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 573 | static VkUpdateAsCopy update(VkDescriptorType type, uint32_t binding, uint32_t index, uint32_t count, const DescriptorSet &set); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 574 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 575 | static VkBufferViewAttachInfo attach_info(const BufferView &view); |
| 576 | static VkImageViewAttachInfo attach_info(const ImageView &view, VkImageLayout layout); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 577 | }; |
| 578 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 579 | class DynamicVpStateObject : public DerivedObject<VkDynamicVpState, DynamicStateObject, VK_OBJECT_TYPE_DYNAMIC_VP_STATE> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 580 | public: |
| 581 | // vkCreateDynamicViewportState() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 582 | void init(const Device &dev, const VkDynamicVpStateCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 583 | }; |
| 584 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 585 | class DynamicRsStateObject : public DerivedObject<VkDynamicRsState, DynamicStateObject, VK_OBJECT_TYPE_DYNAMIC_RS_STATE> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 586 | public: |
| 587 | // vkCreateDynamicRasterState() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 588 | void init(const Device &dev, const VkDynamicRsStateCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 589 | }; |
| 590 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 591 | class DynamicCbStateObject : public DerivedObject<VkDynamicCbState, DynamicStateObject, VK_OBJECT_TYPE_DYNAMIC_CB_STATE> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 592 | public: |
| 593 | // vkCreateDynamicColorBlendState() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 594 | void init(const Device &dev, const VkDynamicCbStateCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 595 | }; |
| 596 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 597 | class DynamicDsStateObject : public DerivedObject<VkDynamicDsState, DynamicStateObject, VK_OBJECT_TYPE_DYNAMIC_DS_STATE> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 598 | public: |
| 599 | // vkCreateDynamicDepthStencilState() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 600 | void init(const Device &dev, const VkDynamicDsStateCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 601 | }; |
| 602 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 603 | class CmdBuffer : public DerivedObject<VkCmdBuffer, Object, VK_OBJECT_TYPE_COMMAND_BUFFER> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 604 | public: |
| 605 | explicit CmdBuffer() {} |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 606 | explicit CmdBuffer(const Device &dev, const VkCmdBufferCreateInfo &info) { init(dev, info); } |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 607 | |
| 608 | // vkCreateCommandBuffer() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 609 | void init(const Device &dev, const VkCmdBufferCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 610 | |
| 611 | // vkBeginCommandBuffer() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 612 | void begin(const VkCmdBufferBeginInfo *info); |
| 613 | void begin(VkRenderPass renderpass_obj, VkFramebuffer framebuffer_obj); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 614 | void begin(); |
| 615 | |
| 616 | // vkEndCommandBuffer() |
| 617 | // vkResetCommandBuffer() |
| 618 | void end(); |
| 619 | void reset(); |
| 620 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 621 | static VkCmdBufferCreateInfo create_info(uint32_t queueNodeIndex); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 622 | }; |
| 623 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 624 | inline const void *Object::map(VkFlags flags) const |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 625 | { |
| 626 | return (primary_mem_) ? primary_mem_->map(flags) : NULL; |
| 627 | } |
| 628 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 629 | inline void *Object::map(VkFlags flags) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 630 | { |
| 631 | return (primary_mem_) ? primary_mem_->map(flags) : NULL; |
| 632 | } |
| 633 | |
| 634 | inline void Object::unmap() const |
| 635 | { |
| 636 | if (primary_mem_) |
| 637 | primary_mem_->unmap(); |
| 638 | } |
| 639 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 640 | inline VkMemoryAllocInfo GpuMemory::alloc_info(const VkMemoryRequirements &reqs, |
Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 641 | const VkMemoryAllocInfo *next_info) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 642 | { |
Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 643 | VkMemoryAllocInfo info = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 644 | info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 645 | if (next_info != NULL) |
| 646 | info.pNext = (void *) next_info; |
| 647 | |
| 648 | info.allocationSize = reqs.size; |
Jeremy Hayes | d02809a | 2015-04-15 14:17:56 -0600 | [diff] [blame] | 649 | info.memProps = reqs.memPropsRequired; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 650 | info.memPriority = VK_MEMORY_PRIORITY_NORMAL; |
| 651 | return info; |
| 652 | } |
| 653 | |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 654 | inline VkBufferCreateInfo Buffer::create_info(VkDeviceSize size, VkFlags usage) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 655 | { |
Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 656 | VkBufferCreateInfo info = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 657 | info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 658 | info.size = size; |
| 659 | info.usage = usage; |
| 660 | return info; |
| 661 | } |
| 662 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 663 | inline VkFenceCreateInfo Fence::create_info(VkFenceCreateFlags flags) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 664 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 665 | VkFenceCreateInfo info = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 666 | info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 667 | info.flags = flags; |
| 668 | return info; |
| 669 | } |
| 670 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 671 | inline VkFenceCreateInfo Fence::create_info() |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 672 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 673 | VkFenceCreateInfo info = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 674 | info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 675 | return info; |
| 676 | } |
| 677 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 678 | inline VkSemaphoreCreateInfo Semaphore::create_info(uint32_t init_count, VkFlags flags) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 679 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 680 | VkSemaphoreCreateInfo info = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 681 | info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 682 | info.initialCount = init_count; |
| 683 | info.flags = flags; |
| 684 | return info; |
| 685 | } |
| 686 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 687 | inline VkEventCreateInfo Event::create_info(VkFlags flags) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 688 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 689 | VkEventCreateInfo info = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 690 | info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 691 | info.flags = flags; |
| 692 | return info; |
| 693 | } |
| 694 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 695 | inline VkQueryPoolCreateInfo QueryPool::create_info(VkQueryType type, uint32_t slot_count) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 696 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 697 | VkQueryPoolCreateInfo info = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 698 | info.sType = VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO; |
| 699 | info.queryType = type; |
| 700 | info.slots = slot_count; |
| 701 | return info; |
| 702 | } |
| 703 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 704 | inline VkImageCreateInfo Image::create_info() |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 705 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 706 | VkImageCreateInfo info = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 707 | info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 708 | info.extent.width = 1; |
| 709 | info.extent.height = 1; |
| 710 | info.extent.depth = 1; |
| 711 | info.mipLevels = 1; |
| 712 | info.arraySize = 1; |
| 713 | info.samples = 1; |
| 714 | return info; |
| 715 | } |
| 716 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 717 | inline VkImageSubresource Image::subresource(VkImageAspect aspect, uint32_t mip_level, uint32_t array_slice) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 718 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 719 | VkImageSubresource subres = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 720 | subres.aspect = aspect; |
| 721 | subres.mipLevel = mip_level; |
| 722 | subres.arraySlice = array_slice; |
| 723 | return subres; |
| 724 | } |
| 725 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 726 | inline VkImageSubresource Image::subresource(const VkImageSubresourceRange &range, uint32_t mip_level, uint32_t array_slice) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 727 | { |
| 728 | return subresource(range.aspect, range.baseMipLevel + mip_level, range.baseArraySlice + array_slice); |
| 729 | } |
| 730 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 731 | inline VkImageSubresourceRange Image::subresource_range(VkImageAspect aspect, uint32_t base_mip_level, uint32_t mip_levels, |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 732 | uint32_t base_array_slice, uint32_t array_size) |
| 733 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 734 | VkImageSubresourceRange range = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 735 | range.aspect = aspect; |
| 736 | range.baseMipLevel = base_mip_level; |
| 737 | range.mipLevels = mip_levels; |
| 738 | range.baseArraySlice = base_array_slice; |
| 739 | range.arraySize = array_size; |
| 740 | return range; |
| 741 | } |
| 742 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 743 | inline VkImageSubresourceRange Image::subresource_range(const VkImageCreateInfo &info, VkImageAspect aspect) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 744 | { |
| 745 | return subresource_range(aspect, 0, info.mipLevels, 0, info.arraySize); |
| 746 | } |
| 747 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 748 | inline VkImageSubresourceRange Image::subresource_range(const VkImageSubresource &subres) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 749 | { |
| 750 | return subresource_range(subres.aspect, subres.mipLevel, 1, subres.arraySlice, 1); |
| 751 | } |
| 752 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 753 | inline VkExtent2D Image::extent(int32_t width, int32_t height) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 754 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 755 | VkExtent2D extent = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 756 | extent.width = width; |
| 757 | extent.height = height; |
| 758 | return extent; |
| 759 | } |
| 760 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 761 | inline VkExtent2D Image::extent(const VkExtent2D &extent, uint32_t mip_level) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 762 | { |
| 763 | const int32_t width = (extent.width >> mip_level) ? extent.width >> mip_level : 1; |
| 764 | const int32_t height = (extent.height >> mip_level) ? extent.height >> mip_level : 1; |
| 765 | return Image::extent(width, height); |
| 766 | } |
| 767 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 768 | inline VkExtent2D Image::extent(const VkExtent3D &extent) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 769 | { |
| 770 | return Image::extent(extent.width, extent.height); |
| 771 | } |
| 772 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 773 | inline VkExtent3D Image::extent(int32_t width, int32_t height, int32_t depth) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 774 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 775 | VkExtent3D extent = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 776 | extent.width = width; |
| 777 | extent.height = height; |
| 778 | extent.depth = depth; |
| 779 | return extent; |
| 780 | } |
| 781 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 782 | inline VkExtent3D Image::extent(const VkExtent3D &extent, uint32_t mip_level) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 783 | { |
| 784 | const int32_t width = (extent.width >> mip_level) ? extent.width >> mip_level : 1; |
| 785 | const int32_t height = (extent.height >> mip_level) ? extent.height >> mip_level : 1; |
| 786 | const int32_t depth = (extent.depth >> mip_level) ? extent.depth >> mip_level : 1; |
| 787 | return Image::extent(width, height, depth); |
| 788 | } |
| 789 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 790 | inline VkShaderCreateInfo Shader::create_info(size_t code_size, const void *code, VkFlags flags) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 791 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 792 | VkShaderCreateInfo info = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 793 | info.sType = VK_STRUCTURE_TYPE_SHADER_CREATE_INFO; |
| 794 | info.codeSize = code_size; |
| 795 | info.pCode = code; |
| 796 | info.flags = flags; |
| 797 | return info; |
| 798 | } |
| 799 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 800 | inline VkBufferViewAttachInfo DescriptorSet::attach_info(const BufferView &view) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 801 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 802 | VkBufferViewAttachInfo info = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 803 | info.sType = VK_STRUCTURE_TYPE_BUFFER_VIEW_ATTACH_INFO; |
| 804 | info.view = view.obj(); |
| 805 | return info; |
| 806 | } |
| 807 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 808 | inline VkImageViewAttachInfo DescriptorSet::attach_info(const ImageView &view, VkImageLayout layout) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 809 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 810 | VkImageViewAttachInfo info = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 811 | info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_ATTACH_INFO; |
| 812 | info.view = view.obj(); |
| 813 | info.layout = layout; |
| 814 | return info; |
| 815 | } |
| 816 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 817 | inline VkUpdateSamplers DescriptorSet::update(uint32_t binding, uint32_t index, uint32_t count, const VkSampler *samplers) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 818 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 819 | VkUpdateSamplers info = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 820 | info.sType = VK_STRUCTURE_TYPE_UPDATE_SAMPLERS; |
| 821 | info.binding = binding; |
| 822 | info.arrayIndex = index; |
| 823 | info.count = count; |
| 824 | info.pSamplers = samplers; |
| 825 | return info; |
| 826 | } |
| 827 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 828 | inline VkUpdateSamplers DescriptorSet::update(uint32_t binding, uint32_t index, const std::vector<VkSampler> &samplers) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 829 | { |
| 830 | return update(binding, index, samplers.size(), &samplers[0]); |
| 831 | } |
| 832 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 833 | inline VkUpdateSamplerTextures DescriptorSet::update(uint32_t binding, uint32_t index, uint32_t count, const VkSamplerImageViewInfo *textures) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 834 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 835 | VkUpdateSamplerTextures info = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 836 | info.sType = VK_STRUCTURE_TYPE_UPDATE_SAMPLER_TEXTURES; |
| 837 | info.binding = binding; |
| 838 | info.arrayIndex = index; |
| 839 | info.count = count; |
| 840 | info.pSamplerImageViews = textures; |
| 841 | return info; |
| 842 | } |
| 843 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 844 | inline VkUpdateSamplerTextures DescriptorSet::update(uint32_t binding, uint32_t index, const std::vector<VkSamplerImageViewInfo> &textures) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 845 | { |
| 846 | return update(binding, index, textures.size(), &textures[0]); |
| 847 | } |
| 848 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 849 | inline VkUpdateImages DescriptorSet::update(VkDescriptorType type, uint32_t binding, uint32_t index, uint32_t count, |
| 850 | const VkImageViewAttachInfo *views) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 851 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 852 | VkUpdateImages info = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 853 | info.sType = VK_STRUCTURE_TYPE_UPDATE_IMAGES; |
| 854 | info.descriptorType = type; |
| 855 | info.binding = binding; |
| 856 | info.arrayIndex = index; |
| 857 | info.count = count; |
| 858 | info.pImageViews = views; |
| 859 | return info; |
| 860 | } |
| 861 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 862 | inline VkUpdateImages DescriptorSet::update(VkDescriptorType type, uint32_t binding, uint32_t index, |
| 863 | const std::vector<VkImageViewAttachInfo> &views) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 864 | { |
| 865 | return update(type, binding, index, views.size(), &views[0]); |
| 866 | } |
| 867 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 868 | inline VkUpdateBuffers DescriptorSet::update(VkDescriptorType type, uint32_t binding, uint32_t index, uint32_t count, |
| 869 | const VkBufferViewAttachInfo *views) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 870 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 871 | VkUpdateBuffers info = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 872 | info.sType = VK_STRUCTURE_TYPE_UPDATE_BUFFERS; |
| 873 | info.descriptorType = type; |
| 874 | info.binding = binding; |
| 875 | info.arrayIndex = index; |
| 876 | info.count = count; |
| 877 | info.pBufferViews = views; |
| 878 | return info; |
| 879 | } |
| 880 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 881 | inline VkUpdateBuffers DescriptorSet::update(VkDescriptorType type, uint32_t binding, uint32_t index, |
| 882 | const std::vector<VkBufferViewAttachInfo> &views) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 883 | { |
| 884 | return update(type, binding, index, views.size(), &views[0]); |
| 885 | } |
| 886 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 887 | inline VkUpdateAsCopy DescriptorSet::update(VkDescriptorType type, uint32_t binding, uint32_t index, uint32_t count, const DescriptorSet &set) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 888 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 889 | VkUpdateAsCopy info = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 890 | info.sType = VK_STRUCTURE_TYPE_UPDATE_AS_COPY; |
| 891 | info.descriptorType = type; |
| 892 | info.binding = binding; |
| 893 | info.arrayElement = index; |
| 894 | info.count = count; |
| 895 | info.descriptorSet = set.obj(); |
| 896 | return info; |
| 897 | } |
| 898 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 899 | inline VkCmdBufferCreateInfo CmdBuffer::create_info(uint32_t queueNodeIndex) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 900 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 901 | VkCmdBufferCreateInfo info = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 902 | info.sType = VK_STRUCTURE_TYPE_CMD_BUFFER_CREATE_INFO; |
| 903 | info.queueNodeIndex = queueNodeIndex; |
| 904 | return info; |
| 905 | } |
| 906 | |
| 907 | }; // namespace vk_testing |
| 908 | |
| 909 | #endif // VKTESTBINDING_H |