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