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