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