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: |
Mark Lobodzinski | 7234629 | 2015-07-02 16:49:40 -0600 | [diff] [blame] | 69 | explicit PhysicalGpu(VkPhysicalDevice gpu) : gpu_(gpu) |
| 70 | { |
| 71 | memory_properties_ = memory_properties(); |
| 72 | } |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 73 | |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 74 | const VkPhysicalDevice &obj() const { return gpu_; } |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 75 | |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 76 | VkPhysicalDeviceProperties properties() const; |
| 77 | VkPhysicalDevicePerformance performance() const; |
| 78 | VkPhysicalDeviceMemoryProperties memory_properties() const; |
| 79 | std::vector<VkPhysicalDeviceQueueProperties> queue_properties() const; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 80 | |
Mark Lobodzinski | 7234629 | 2015-07-02 16:49:40 -0600 | [diff] [blame] | 81 | VkResult set_memory_type(const uint32_t type_bits, VkMemoryAllocInfo *info, const VkMemoryPropertyFlags properties) const; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 82 | |
Tony Barbour | 426b905 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 83 | // vkGetGlobalExtensionProperties() |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 84 | std::vector<VkExtensionProperties> extensions() const; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 85 | |
| 86 | // vkEnumerateLayers() |
| 87 | std::vector<const char *> layers(std::vector<char> &buf) const; |
| 88 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 89 | private: |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 90 | void add_extension_dependencies(uint32_t dependency_count, |
| 91 | VkExtensionProperties *depencency_props, |
| 92 | std::vector<VkExtensionProperties> &ext_list); |
Mark Lobodzinski | 7234629 | 2015-07-02 16:49:40 -0600 | [diff] [blame] | 93 | VkPhysicalDeviceMemoryProperties memory_properties_; |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 94 | VkPhysicalDevice gpu_; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 95 | }; |
| 96 | |
| 97 | class BaseObject { |
| 98 | public: |
Mike Stroyan | 230e625 | 2015-04-17 12:36:38 -0600 | [diff] [blame] | 99 | const VkObject &obj() const { return obj_; } |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 100 | VkObjectType type() const { return object_type_; } |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 101 | bool initialized() const { return (obj_ != VK_NULL_HANDLE); } |
| 102 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 103 | protected: |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 104 | explicit BaseObject() : |
| 105 | object_type_((VkObjectType) 0), obj_(VK_NULL_HANDLE), own_obj_(false){} |
| 106 | explicit BaseObject(VkObject obj, VkObjectType object_type) : |
| 107 | object_type_(object_type), obj_(obj), own_obj_(false){} |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 108 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 109 | void init(VkObject obj, VkObjectType object_type, bool own); |
| 110 | void init(VkObject obj, VkObjectType object_type) { init(obj, object_type, true); } |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 111 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 112 | void reinit(VkObject obj, VkObjectType object_type, bool own); |
| 113 | void reinit(VkObject obj, VkObjectType object_type) { reinit(obj, object_type, true); } |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 114 | |
| 115 | bool own() const { return own_obj_; } |
| 116 | |
| 117 | private: |
| 118 | // base objects are non-copyable |
| 119 | BaseObject(const BaseObject &); |
| 120 | BaseObject &operator=(const BaseObject &); |
| 121 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 122 | VkObjectType object_type_; |
Mike Stroyan | 230e625 | 2015-04-17 12:36:38 -0600 | [diff] [blame] | 123 | VkObject obj_; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 124 | bool own_obj_; |
| 125 | }; |
| 126 | |
| 127 | class Object : public BaseObject { |
| 128 | public: |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 129 | const VkObject &obj() const { return reinterpret_cast<const VkObject &>(BaseObject::obj()); } |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 130 | |
Tony Barbour | 426b905 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 131 | // vkGetObjectMemoryRequirements() |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 132 | uint32_t memory_allocation_count() const; |
| 133 | std::vector<VkMemoryRequirements> memory_requirements() const; |
| 134 | |
Mark Lobodzinski | fb9f564 | 2015-05-11 17:21:15 -0500 | [diff] [blame] | 135 | // vkBindObjectMemory() |
Mark Lobodzinski | 2318261 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 136 | void bind_memory(const GpuMemory &mem, VkDeviceSize mem_offset); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 137 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 138 | // Unless an object is initialized with init_no_mem(), memories are |
Courtney Goeltzenleuchter | ac83452 | 2015-05-01 17:56:13 -0600 | [diff] [blame] | 139 | // automatically allocated and bound. These methods can be used to |
| 140 | // map/unmap the primary memory. |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 141 | std::vector<VkDeviceMemory> memories() const; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 142 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 143 | const void *map(VkFlags flags) const; |
| 144 | void *map(VkFlags flags); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 145 | const void *map() const { return map(0); } |
| 146 | void *map() { return map(0); } |
| 147 | |
| 148 | void unmap() const; |
Mark Lobodzinski | cf26e07 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 149 | const Device* dev_; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 150 | |
| 151 | protected: |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 152 | explicit Object() : |
| 153 | mem_alloc_count_(0), internal_mems_(NULL), |
| 154 | primary_mem_(NULL), bound(false) {} |
| 155 | explicit Object(const Device &dev, VkObject obj, VkObjectType object_type) : |
| 156 | dev_(&dev), |
| 157 | mem_alloc_count_(0), internal_mems_(NULL), |
Chris Forbes | 952124d | 2015-05-25 11:13:03 +1200 | [diff] [blame] | 158 | primary_mem_(NULL), bound(false) { init(obj, object_type); } |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 159 | ~Object() { cleanup(); } |
| 160 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 161 | void init(VkObject obj, VkObjectType object_type, bool own); |
| 162 | void init(VkObject obj, VkObjectType object_type) { init(obj, object_type, true); } |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 163 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 164 | void reinit(VkObject obj, VkObjectType object_type, bool own); |
| 165 | void reinit(VkObject obj, VkObjectType object_type) { init(obj, object_type, true); } |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 166 | |
| 167 | // allocate and bind internal memories |
Courtney Goeltzenleuchter | 9c6d94f | 2015-04-22 10:02:41 -0600 | [diff] [blame] | 168 | void alloc_memory(); |
Tony Barbour | 9431056 | 2015-04-22 15:10:33 -0600 | [diff] [blame] | 169 | void alloc_memory(VkMemoryPropertyFlags &reqs); |
Courtney Goeltzenleuchter | 9c6d94f | 2015-04-22 10:02:41 -0600 | [diff] [blame] | 170 | void alloc_memory(const std::vector<VkDeviceMemory> &mems); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 171 | |
| 172 | private: |
| 173 | void cleanup(); |
| 174 | |
| 175 | uint32_t mem_alloc_count_; |
| 176 | GpuMemory *internal_mems_; |
| 177 | GpuMemory *primary_mem_; |
Tony Barbour | 2b5fb34 | 2015-04-09 16:00:18 -0600 | [diff] [blame] | 178 | bool bound; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 179 | }; |
| 180 | |
| 181 | class DynamicStateObject : public Object { |
| 182 | public: |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 183 | const VkDynamicStateObject &obj() const { return reinterpret_cast<const VkDynamicStateObject &>(Object::obj()); } |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 184 | |
| 185 | protected: |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 186 | explicit DynamicStateObject() : Object() {} |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 187 | }; |
| 188 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 189 | template<typename T, class C, VkObjectType V> |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 190 | class DerivedObject : public C { |
| 191 | public: |
| 192 | const T &obj() const { return reinterpret_cast<const T &>(C::obj()); } |
| 193 | |
| 194 | protected: |
| 195 | typedef T obj_type; |
| 196 | typedef C base_type; |
| 197 | |
| 198 | explicit DerivedObject() {} |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 199 | explicit DerivedObject(T obj) : C(obj, V) {} |
| 200 | explicit DerivedObject(const Device &dev, T obj) : C(dev, obj, V) {} |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 201 | }; |
| 202 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 203 | class Device : public DerivedObject<VkDevice, BaseObject, VK_OBJECT_TYPE_DEVICE> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 204 | public: |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 205 | explicit Device(VkPhysicalDevice gpu) : gpu_(gpu) {} |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 206 | ~Device(); |
| 207 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 208 | VkDevice device() const { return obj(); } |
| 209 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 210 | // vkCreateDevice() |
Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 211 | void init(const VkDeviceCreateInfo &info); |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 212 | void init(std::vector<VkExtensionProperties> extensions); // all queues, all extensions, etc |
| 213 | void init() { std::vector<VkExtensionProperties> extensions; init(extensions); }; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 214 | |
| 215 | const PhysicalGpu &gpu() const { return gpu_; } |
| 216 | |
Jon Ashburn | 1245cec | 2015-05-18 13:20:15 -0600 | [diff] [blame] | 217 | // vkGetDeviceProcAddr() |
| 218 | void *get_proc(const char *name) const { return vkGetDeviceProcAddr(obj(), name); } |
| 219 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 220 | // vkGetDeviceQueue() |
Mark Lobodzinski | cf26e07 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 221 | const std::vector<Queue *> &graphics_queues() const { return queues_[GRAPHICS]; } |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 222 | const std::vector<Queue *> &compute_queues() { return queues_[COMPUTE]; } |
| 223 | const std::vector<Queue *> &dma_queues() { return queues_[DMA]; } |
| 224 | uint32_t graphics_queue_node_index_; |
| 225 | |
| 226 | struct Format { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 227 | VkFormat format; |
| 228 | VkImageTiling tiling; |
| 229 | VkFlags features; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 230 | }; |
| 231 | // vkGetFormatInfo() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 232 | VkFormatProperties format_properties(VkFormat format); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 233 | const std::vector<Format> &formats() const { return formats_; } |
| 234 | |
| 235 | // vkDeviceWaitIdle() |
| 236 | void wait(); |
| 237 | |
| 238 | // vkWaitForFences() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 239 | VkResult wait(const std::vector<const Fence *> &fences, bool wait_all, uint64_t timeout); |
| 240 | VkResult wait(const Fence &fence) { return wait(std::vector<const Fence *>(1, &fence), true, (uint64_t) -1); } |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 241 | |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 242 | // vkUpdateDescriptorSets() |
| 243 | VkResult update_descriptor_sets(const std::vector<VkWriteDescriptorSet> &writes, const std::vector<VkCopyDescriptorSet> &copies); |
| 244 | VkResult update_descriptor_sets(const std::vector<VkWriteDescriptorSet> &writes) { return update_descriptor_sets(writes, std::vector<VkCopyDescriptorSet>()); } |
| 245 | |
| 246 | static VkWriteDescriptorSet write_descriptor_set(const DescriptorSet &set, uint32_t binding, uint32_t array_element, |
| 247 | VkDescriptorType type, uint32_t count, const VkDescriptorInfo *descriptors); |
| 248 | static VkWriteDescriptorSet write_descriptor_set(const DescriptorSet &set, uint32_t binding, uint32_t array_element, |
| 249 | VkDescriptorType type, const std::vector<VkDescriptorInfo> &descriptors); |
| 250 | |
| 251 | static VkCopyDescriptorSet copy_descriptor_set(const DescriptorSet &src_set, uint32_t src_binding, uint32_t src_array_element, |
| 252 | const DescriptorSet &dst_set, uint32_t dst_binding, uint32_t dst_array_element, |
| 253 | uint32_t count); |
| 254 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 255 | private: |
| 256 | enum QueueIndex { |
| 257 | GRAPHICS, |
| 258 | COMPUTE, |
| 259 | DMA, |
| 260 | QUEUE_COUNT, |
| 261 | }; |
| 262 | |
| 263 | void init_queues(); |
| 264 | void init_formats(); |
| 265 | |
| 266 | PhysicalGpu gpu_; |
| 267 | |
| 268 | std::vector<Queue *> queues_[QUEUE_COUNT]; |
| 269 | std::vector<Format> formats_; |
| 270 | }; |
| 271 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 272 | class Queue : public DerivedObject<VkQueue, BaseObject, VK_OBJECT_TYPE_QUEUE> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 273 | public: |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 274 | explicit Queue(VkQueue queue) : DerivedObject(queue) {} |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 275 | |
| 276 | // vkQueueSubmit() |
| 277 | void submit(const std::vector<const CmdBuffer *> &cmds, Fence &fence); |
| 278 | void submit(const CmdBuffer &cmd, Fence &fence); |
| 279 | void submit(const CmdBuffer &cmd); |
| 280 | |
Courtney Goeltzenleuchter | 4696294 | 2015-04-16 13:38:46 -0600 | [diff] [blame] | 281 | // vkQueueAddMemReferences() |
| 282 | // vkQueueRemoveMemReferences() |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 283 | void add_mem_references(const std::vector<VkDeviceMemory> &mem_refs); |
| 284 | void remove_mem_references(const std::vector<VkDeviceMemory> &mem_refs); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 285 | |
| 286 | // vkQueueWaitIdle() |
| 287 | void wait(); |
| 288 | |
| 289 | // vkQueueSignalSemaphore() |
| 290 | // vkQueueWaitSemaphore() |
| 291 | void signal_semaphore(Semaphore &sem); |
| 292 | void wait_semaphore(Semaphore &sem); |
| 293 | }; |
| 294 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 295 | /* Note: This needs to be BaseObject so that we don't try to destroy |
| 296 | * the object when the object is device memory. |
| 297 | */ |
| 298 | class GpuMemory : public DerivedObject<VkDeviceMemory, BaseObject, VK_OBJECT_TYPE_DEVICE_MEMORY> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 299 | public: |
| 300 | ~GpuMemory(); |
| 301 | |
| 302 | // vkAllocMemory() |
Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 303 | void init(const Device &dev, const VkMemoryAllocInfo &info); |
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 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 306 | // vkMapMemory() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 307 | const void *map(VkFlags flags) const; |
| 308 | void *map(VkFlags flags); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 309 | const void *map() const { return map(0); } |
| 310 | void *map() { return map(0); } |
| 311 | |
| 312 | // vkUnmapMemory() |
| 313 | void unmap() const; |
| 314 | |
Mark Lobodzinski | 7234629 | 2015-07-02 16:49:40 -0600 | [diff] [blame] | 315 | static VkMemoryAllocInfo alloc_info(const VkMemoryRequirements &reqs, |
| 316 | const VkMemoryAllocInfo *next_info); |
| 317 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 318 | private: |
| 319 | const Device* dev_; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 320 | }; |
| 321 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 322 | class Fence : public DerivedObject<VkFence, Object, VK_OBJECT_TYPE_FENCE> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 323 | public: |
| 324 | // vkCreateFence() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 325 | void init(const Device &dev, const VkFenceCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 326 | |
| 327 | // vkGetFenceStatus() |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 328 | VkResult status() const { return vkGetFenceStatus(dev_->obj(), obj()); } |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 329 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 330 | static VkFenceCreateInfo create_info(VkFenceCreateFlags flags); |
| 331 | static VkFenceCreateInfo create_info(); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 332 | }; |
| 333 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 334 | class Semaphore : public DerivedObject<VkSemaphore, Object, VK_OBJECT_TYPE_SEMAPHORE> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 335 | public: |
| 336 | // vkCreateSemaphore() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 337 | void init(const Device &dev, const VkSemaphoreCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 338 | |
Tony Barbour | 864fd38 | 2015-06-26 12:56:09 -0600 | [diff] [blame] | 339 | static VkSemaphoreCreateInfo create_info(VkFlags flags); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 340 | }; |
| 341 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 342 | class Event : public DerivedObject<VkEvent, Object, VK_OBJECT_TYPE_EVENT> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 343 | public: |
| 344 | // vkCreateEvent() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 345 | void init(const Device &dev, const VkEventCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 346 | |
| 347 | // vkGetEventStatus() |
| 348 | // vkSetEvent() |
| 349 | // vkResetEvent() |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 350 | VkResult status() const { return vkGetEventStatus(dev_->obj(), obj()); } |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 351 | void set(); |
| 352 | void reset(); |
| 353 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 354 | static VkEventCreateInfo create_info(VkFlags flags); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 355 | }; |
| 356 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 357 | class QueryPool : public DerivedObject<VkQueryPool, Object, VK_OBJECT_TYPE_QUERY_POOL> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 358 | public: |
| 359 | // vkCreateQueryPool() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 360 | void init(const Device &dev, const VkQueryPoolCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 361 | |
| 362 | // vkGetQueryPoolResults() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 363 | 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] | 364 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 365 | static VkQueryPoolCreateInfo create_info(VkQueryType type, uint32_t slot_count); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 366 | }; |
| 367 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 368 | class Buffer : public DerivedObject<VkBuffer, Object, VK_OBJECT_TYPE_BUFFER> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 369 | public: |
| 370 | explicit Buffer() {} |
Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 371 | explicit Buffer(const Device &dev, const VkBufferCreateInfo &info) { init(dev, info); } |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 372 | explicit Buffer(const Device &dev, VkDeviceSize size) { init(dev, size); } |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 373 | |
| 374 | // vkCreateBuffer() |
Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 375 | void init(const Device &dev, const VkBufferCreateInfo &info); |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 376 | void init(const Device &dev, VkDeviceSize size) { init(dev, create_info(size, 0)); } |
Cody Northrop | 257fe6e | 2015-06-17 08:29:35 -0600 | [diff] [blame] | 377 | void init(const Device &dev, VkDeviceSize size, VkMemoryPropertyFlags &reqs) { init(dev, create_info(size, VK_BUFFER_USAGE_TRANSFER_SOURCE_BIT), reqs); } |
Tony Barbour | 9431056 | 2015-04-22 15:10:33 -0600 | [diff] [blame] | 378 | void init(const Device &dev, const VkBufferCreateInfo &info, VkMemoryPropertyFlags &reqs); |
Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 379 | void init_no_mem(const Device &dev, const VkBufferCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 380 | |
Mark Lobodzinski | fb9f564 | 2015-05-11 17:21:15 -0500 | [diff] [blame] | 381 | // vkQueueBindSparseBufferMemory() |
Mark Lobodzinski | 2318261 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 382 | void bind_memory(VkDeviceSize offset, VkDeviceSize size, |
Mark Lobodzinski | fb9f564 | 2015-05-11 17:21:15 -0500 | [diff] [blame] | 383 | const GpuMemory &mem, VkDeviceSize mem_offset); |
| 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 | |
Mark Lobodzinski | fb9f564 | 2015-05-11 17:21:15 -0500 | [diff] [blame] | 419 | // vkQueueBindSparseImageMemory() |
Mark Lobodzinski | 2318261 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 420 | void bind_memory(const Device &dev, const VkImageMemoryBindInfo &info, |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 421 | const GpuMemory &mem, VkDeviceSize mem_offset); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 422 | |
Tony Barbour | 426b905 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 423 | // vkGetImageSubresourceLayout() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 424 | VkSubresourceLayout subresource_layout(const VkImageSubresource &subres) const; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 425 | |
| 426 | bool transparent() const; |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 427 | bool copyable() const { return (format_features_ & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT); } |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 428 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 429 | VkImageSubresourceRange subresource_range(VkImageAspect aspect) const { return subresource_range(create_info_, aspect); } |
| 430 | VkExtent3D extent() const { return create_info_.extent; } |
| 431 | VkExtent3D extent(uint32_t mip_level) const { return extent(create_info_.extent, mip_level); } |
| 432 | VkFormat format() const {return create_info_.format;} |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 433 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 434 | VkImageMemoryBarrier image_memory_barrier(VkFlags output_mask, VkFlags input_mask, |
| 435 | VkImageLayout old_layout, |
| 436 | VkImageLayout new_layout, |
| 437 | const VkImageSubresourceRange &range) const |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 438 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 439 | VkImageMemoryBarrier barrier = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 440 | barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| 441 | barrier.outputMask = output_mask; |
| 442 | barrier.inputMask = input_mask; |
| 443 | barrier.oldLayout = old_layout; |
| 444 | barrier.newLayout = new_layout; |
| 445 | barrier.image = obj(); |
| 446 | barrier.subresourceRange = range; |
| 447 | return barrier; |
| 448 | } |
| 449 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 450 | static VkImageCreateInfo create_info(); |
| 451 | static VkImageSubresource subresource(VkImageAspect aspect, uint32_t mip_level, uint32_t array_slice); |
| 452 | static VkImageSubresource subresource(const VkImageSubresourceRange &range, uint32_t mip_level, uint32_t array_slice); |
| 453 | 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] | 454 | uint32_t base_array_slice, uint32_t array_size); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 455 | static VkImageSubresourceRange subresource_range(const VkImageCreateInfo &info, VkImageAspect aspect); |
| 456 | static VkImageSubresourceRange subresource_range(const VkImageSubresource &subres); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 457 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 458 | static VkExtent2D extent(int32_t width, int32_t height); |
| 459 | static VkExtent2D extent(const VkExtent2D &extent, uint32_t mip_level); |
| 460 | static VkExtent2D extent(const VkExtent3D &extent); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 461 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 462 | static VkExtent3D extent(int32_t width, int32_t height, int32_t depth); |
| 463 | static VkExtent3D extent(const VkExtent3D &extent, uint32_t mip_level); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 464 | |
| 465 | private: |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 466 | void init_info(const Device &dev, const VkImageCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 467 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 468 | VkImageCreateInfo create_info_; |
| 469 | VkFlags format_features_; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 470 | }; |
| 471 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 472 | class ImageView : public DerivedObject<VkImageView, Object, VK_OBJECT_TYPE_IMAGE_VIEW> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 473 | public: |
| 474 | // vkCreateImageView() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 475 | void init(const Device &dev, const VkImageViewCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 476 | }; |
| 477 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 478 | class ColorAttachmentView : public DerivedObject<VkColorAttachmentView, Object, VK_OBJECT_TYPE_COLOR_ATTACHMENT_VIEW> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 479 | public: |
| 480 | // vkCreateColorAttachmentView() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 481 | void init(const Device &dev, const VkColorAttachmentViewCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 482 | }; |
| 483 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 484 | class DepthStencilView : public DerivedObject<VkDepthStencilView, Object, VK_OBJECT_TYPE_DEPTH_STENCIL_VIEW> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 485 | public: |
| 486 | // vkCreateDepthStencilView() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 487 | void init(const Device &dev, const VkDepthStencilViewCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 488 | }; |
| 489 | |
Courtney Goeltzenleuchter | 2d034fd | 2015-06-28 13:01:17 -0600 | [diff] [blame] | 490 | class ShaderModule : public DerivedObject<VkShaderModule, Object, VK_OBJECT_TYPE_SHADER_MODULE> { |
| 491 | public: |
| 492 | // vkCreateShaderModule() |
| 493 | void init(const Device &dev, const VkShaderModuleCreateInfo &info); |
| 494 | VkResult init_try(const Device &dev, const VkShaderModuleCreateInfo &info); |
| 495 | |
| 496 | static VkShaderModuleCreateInfo create_info(size_t code_size, const void *code, VkFlags flags); |
| 497 | }; |
| 498 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 499 | class Shader : public DerivedObject<VkShader, Object, VK_OBJECT_TYPE_SHADER> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 500 | public: |
| 501 | // vkCreateShader() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 502 | void init(const Device &dev, const VkShaderCreateInfo &info); |
| 503 | VkResult init_try(const Device &dev, const VkShaderCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 504 | |
Courtney Goeltzenleuchter | 2d034fd | 2015-06-28 13:01:17 -0600 | [diff] [blame] | 505 | static VkShaderCreateInfo create_info(VkShaderModule module, const char *pName, VkFlags flags); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 506 | }; |
| 507 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 508 | class Pipeline : public DerivedObject<VkPipeline, Object, VK_OBJECT_TYPE_PIPELINE> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 509 | public: |
| 510 | // vkCreateGraphicsPipeline() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 511 | void init(const Device &dev, const VkGraphicsPipelineCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 512 | // vkCreateGraphicsPipelineDerivative() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 513 | void init(const Device &dev, const VkGraphicsPipelineCreateInfo &info, const VkPipeline basePipeline); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 514 | // vkCreateComputePipeline() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 515 | void init(const Device &dev, const VkComputePipelineCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 516 | // vkLoadPipeline() |
| 517 | void init(const Device&dev, size_t size, const void *data); |
| 518 | // vkLoadPipelineDerivative() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 519 | 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] | 520 | |
Chris Forbes | dc2188c | 2015-05-25 11:13:26 +1200 | [diff] [blame] | 521 | // vkCreateGraphicsPipeline with error return |
| 522 | VkResult init_try(const Device &dev, const VkGraphicsPipelineCreateInfo &info); |
| 523 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 524 | // vkStorePipeline() |
| 525 | size_t store(size_t size, void *data); |
| 526 | }; |
| 527 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 528 | class Sampler : public DerivedObject<VkSampler, Object, VK_OBJECT_TYPE_SAMPLER> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 529 | public: |
| 530 | // vkCreateSampler() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 531 | void init(const Device &dev, const VkSamplerCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 532 | }; |
| 533 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 534 | class DescriptorSetLayout : public DerivedObject<VkDescriptorSetLayout, Object, VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 535 | public: |
| 536 | // vkCreateDescriptorSetLayout() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 537 | void init(const Device &dev, const VkDescriptorSetLayoutCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 538 | }; |
| 539 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 540 | class PipelineLayout : public DerivedObject<VkPipelineLayout, Object, VK_OBJECT_TYPE_PIPELINE_LAYOUT> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 541 | public: |
Mark Lobodzinski | 556f721 | 2015-04-17 14:11:39 -0500 | [diff] [blame] | 542 | // vCreatePipelineLayout() |
| 543 | 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] | 544 | }; |
| 545 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 546 | class DescriptorPool : public DerivedObject<VkDescriptorPool, Object, VK_OBJECT_TYPE_DESCRIPTOR_POOL> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 547 | public: |
| 548 | // vkCreateDescriptorPool() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 549 | void init(const Device &dev, VkDescriptorPoolUsage usage, |
| 550 | uint32_t max_sets, const VkDescriptorPoolCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 551 | |
| 552 | // vkResetDescriptorPool() |
| 553 | void reset(); |
| 554 | |
| 555 | // vkAllocDescriptorSets() |
Mark Lobodzinski | cf26e07 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 556 | std::vector<DescriptorSet *> alloc_sets(const Device &dev, VkDescriptorSetUsage usage, const std::vector<const DescriptorSetLayout *> &layouts); |
| 557 | std::vector<DescriptorSet *> alloc_sets(const Device &dev, VkDescriptorSetUsage usage, const DescriptorSetLayout &layout, uint32_t count); |
| 558 | DescriptorSet *alloc_sets(const Device &dev, VkDescriptorSetUsage usage, const DescriptorSetLayout &layout); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 559 | }; |
| 560 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 561 | class DescriptorSet : public DerivedObject<VkDescriptorSet, Object, VK_OBJECT_TYPE_DESCRIPTOR_SET> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 562 | public: |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 563 | explicit DescriptorSet() : DerivedObject() {} |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 564 | explicit DescriptorSet(const Device &dev, VkDescriptorSet set) : DerivedObject(dev, set) {} |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 565 | }; |
| 566 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 567 | class DynamicVpStateObject : public DerivedObject<VkDynamicVpState, DynamicStateObject, VK_OBJECT_TYPE_DYNAMIC_VP_STATE> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 568 | public: |
| 569 | // vkCreateDynamicViewportState() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 570 | void init(const Device &dev, const VkDynamicVpStateCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 571 | }; |
| 572 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 573 | class DynamicRsStateObject : public DerivedObject<VkDynamicRsState, DynamicStateObject, VK_OBJECT_TYPE_DYNAMIC_RS_STATE> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 574 | public: |
| 575 | // vkCreateDynamicRasterState() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 576 | void init(const Device &dev, const VkDynamicRsStateCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 577 | }; |
| 578 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 579 | class DynamicCbStateObject : public DerivedObject<VkDynamicCbState, DynamicStateObject, VK_OBJECT_TYPE_DYNAMIC_CB_STATE> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 580 | public: |
| 581 | // vkCreateDynamicColorBlendState() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 582 | void init(const Device &dev, const VkDynamicCbStateCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 583 | }; |
| 584 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 585 | class DynamicDsStateObject : public DerivedObject<VkDynamicDsState, DynamicStateObject, VK_OBJECT_TYPE_DYNAMIC_DS_STATE> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 586 | public: |
| 587 | // vkCreateDynamicDepthStencilState() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 588 | void init(const Device &dev, const VkDynamicDsStateCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 589 | }; |
| 590 | |
Courtney Goeltzenleuchter | 6d55b9c | 2015-04-19 19:07:33 -0600 | [diff] [blame] | 591 | class CmdBuffer : public DerivedObject<VkCmdBuffer, Object, VK_OBJECT_TYPE_COMMAND_BUFFER> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 592 | public: |
| 593 | explicit CmdBuffer() {} |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 594 | explicit CmdBuffer(const Device &dev, const VkCmdBufferCreateInfo &info) { init(dev, info); } |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 595 | |
| 596 | // vkCreateCommandBuffer() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 597 | void init(const Device &dev, const VkCmdBufferCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 598 | |
| 599 | // vkBeginCommandBuffer() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 600 | void begin(const VkCmdBufferBeginInfo *info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 601 | void begin(); |
| 602 | |
| 603 | // vkEndCommandBuffer() |
| 604 | // vkResetCommandBuffer() |
| 605 | void end(); |
| 606 | void reset(); |
| 607 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 608 | static VkCmdBufferCreateInfo create_info(uint32_t queueNodeIndex); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 609 | }; |
| 610 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 611 | inline const void *Object::map(VkFlags flags) const |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 612 | { |
| 613 | return (primary_mem_) ? primary_mem_->map(flags) : NULL; |
| 614 | } |
| 615 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 616 | inline void *Object::map(VkFlags flags) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 617 | { |
| 618 | return (primary_mem_) ? primary_mem_->map(flags) : NULL; |
| 619 | } |
| 620 | |
| 621 | inline void Object::unmap() const |
| 622 | { |
| 623 | if (primary_mem_) |
| 624 | primary_mem_->unmap(); |
| 625 | } |
| 626 | |
Mark Lobodzinski | 7234629 | 2015-07-02 16:49:40 -0600 | [diff] [blame] | 627 | inline VkMemoryAllocInfo GpuMemory::alloc_info(const VkMemoryRequirements &reqs, |
| 628 | const VkMemoryAllocInfo *next_info) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 629 | { |
Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 630 | VkMemoryAllocInfo info = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 631 | info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 632 | if (next_info != NULL) |
| 633 | info.pNext = (void *) next_info; |
| 634 | |
Mark Lobodzinski | 7234629 | 2015-07-02 16:49:40 -0600 | [diff] [blame] | 635 | info.allocationSize = reqs.size; |
| 636 | info.memoryTypeIndex = 0; |
| 637 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 638 | return info; |
| 639 | } |
| 640 | |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 641 | inline VkBufferCreateInfo Buffer::create_info(VkDeviceSize size, VkFlags usage) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 642 | { |
Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 643 | VkBufferCreateInfo info = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 644 | info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 645 | info.size = size; |
| 646 | info.usage = usage; |
| 647 | return info; |
| 648 | } |
| 649 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 650 | inline VkFenceCreateInfo Fence::create_info(VkFenceCreateFlags flags) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 651 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 652 | VkFenceCreateInfo info = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 653 | info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 654 | info.flags = flags; |
| 655 | return info; |
| 656 | } |
| 657 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 658 | inline VkFenceCreateInfo Fence::create_info() |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 659 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 660 | VkFenceCreateInfo info = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 661 | info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 662 | return info; |
| 663 | } |
| 664 | |
Tony Barbour | 864fd38 | 2015-06-26 12:56:09 -0600 | [diff] [blame] | 665 | inline VkSemaphoreCreateInfo Semaphore::create_info(VkFlags flags) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 666 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 667 | VkSemaphoreCreateInfo info = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 668 | info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 669 | info.flags = flags; |
| 670 | return info; |
| 671 | } |
| 672 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 673 | inline VkEventCreateInfo Event::create_info(VkFlags flags) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 674 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 675 | VkEventCreateInfo info = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 676 | info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 677 | info.flags = flags; |
| 678 | return info; |
| 679 | } |
| 680 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 681 | inline VkQueryPoolCreateInfo QueryPool::create_info(VkQueryType type, uint32_t slot_count) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 682 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 683 | VkQueryPoolCreateInfo info = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 684 | info.sType = VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO; |
| 685 | info.queryType = type; |
| 686 | info.slots = slot_count; |
| 687 | return info; |
| 688 | } |
| 689 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 690 | inline VkImageCreateInfo Image::create_info() |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 691 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 692 | VkImageCreateInfo info = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 693 | info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 694 | info.extent.width = 1; |
| 695 | info.extent.height = 1; |
| 696 | info.extent.depth = 1; |
| 697 | info.mipLevels = 1; |
| 698 | info.arraySize = 1; |
| 699 | info.samples = 1; |
| 700 | return info; |
| 701 | } |
| 702 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 703 | 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] | 704 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 705 | VkImageSubresource subres = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 706 | subres.aspect = aspect; |
| 707 | subres.mipLevel = mip_level; |
| 708 | subres.arraySlice = array_slice; |
| 709 | return subres; |
| 710 | } |
| 711 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 712 | 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] | 713 | { |
| 714 | return subresource(range.aspect, range.baseMipLevel + mip_level, range.baseArraySlice + array_slice); |
| 715 | } |
| 716 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 717 | 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] | 718 | uint32_t base_array_slice, uint32_t array_size) |
| 719 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 720 | VkImageSubresourceRange range = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 721 | range.aspect = aspect; |
| 722 | range.baseMipLevel = base_mip_level; |
| 723 | range.mipLevels = mip_levels; |
| 724 | range.baseArraySlice = base_array_slice; |
| 725 | range.arraySize = array_size; |
| 726 | return range; |
| 727 | } |
| 728 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 729 | inline VkImageSubresourceRange Image::subresource_range(const VkImageCreateInfo &info, VkImageAspect aspect) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 730 | { |
| 731 | return subresource_range(aspect, 0, info.mipLevels, 0, info.arraySize); |
| 732 | } |
| 733 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 734 | inline VkImageSubresourceRange Image::subresource_range(const VkImageSubresource &subres) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 735 | { |
| 736 | return subresource_range(subres.aspect, subres.mipLevel, 1, subres.arraySlice, 1); |
| 737 | } |
| 738 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 739 | inline VkExtent2D Image::extent(int32_t width, int32_t height) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 740 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 741 | VkExtent2D extent = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 742 | extent.width = width; |
| 743 | extent.height = height; |
| 744 | return extent; |
| 745 | } |
| 746 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 747 | inline VkExtent2D Image::extent(const VkExtent2D &extent, uint32_t mip_level) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 748 | { |
| 749 | const int32_t width = (extent.width >> mip_level) ? extent.width >> mip_level : 1; |
| 750 | const int32_t height = (extent.height >> mip_level) ? extent.height >> mip_level : 1; |
| 751 | return Image::extent(width, height); |
| 752 | } |
| 753 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 754 | inline VkExtent2D Image::extent(const VkExtent3D &extent) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 755 | { |
| 756 | return Image::extent(extent.width, extent.height); |
| 757 | } |
| 758 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 759 | 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] | 760 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 761 | VkExtent3D extent = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 762 | extent.width = width; |
| 763 | extent.height = height; |
| 764 | extent.depth = depth; |
| 765 | return extent; |
| 766 | } |
| 767 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 768 | inline VkExtent3D Image::extent(const VkExtent3D &extent, uint32_t mip_level) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 769 | { |
| 770 | const int32_t width = (extent.width >> mip_level) ? extent.width >> mip_level : 1; |
| 771 | const int32_t height = (extent.height >> mip_level) ? extent.height >> mip_level : 1; |
| 772 | const int32_t depth = (extent.depth >> mip_level) ? extent.depth >> mip_level : 1; |
| 773 | return Image::extent(width, height, depth); |
| 774 | } |
| 775 | |
Courtney Goeltzenleuchter | 2d034fd | 2015-06-28 13:01:17 -0600 | [diff] [blame] | 776 | inline VkShaderModuleCreateInfo ShaderModule::create_info(size_t code_size, const void *code, VkFlags flags) |
| 777 | { |
| 778 | VkShaderModuleCreateInfo info = {}; |
| 779 | info.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 780 | info.codeSize = code_size; |
| 781 | info.pCode = code; |
| 782 | info.flags = flags; |
| 783 | return info; |
| 784 | } |
| 785 | |
| 786 | inline VkShaderCreateInfo Shader::create_info(VkShaderModule module, const char *pName, VkFlags flags) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 787 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 788 | VkShaderCreateInfo info = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 789 | info.sType = VK_STRUCTURE_TYPE_SHADER_CREATE_INFO; |
Courtney Goeltzenleuchter | 2d034fd | 2015-06-28 13:01:17 -0600 | [diff] [blame] | 790 | info.module = module; |
| 791 | info.pName = pName; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 792 | info.flags = flags; |
| 793 | return info; |
| 794 | } |
| 795 | |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 796 | inline VkWriteDescriptorSet Device::write_descriptor_set(const DescriptorSet &set, uint32_t binding, uint32_t array_element, |
| 797 | VkDescriptorType type, uint32_t count, const VkDescriptorInfo *descriptors) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 798 | { |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 799 | VkWriteDescriptorSet write = {}; |
| 800 | write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 801 | write.destSet = set.obj(); |
| 802 | write.destBinding = binding; |
| 803 | write.destArrayElement = array_element; |
| 804 | write.count = count; |
| 805 | write.descriptorType = type; |
| 806 | write.pDescriptors = descriptors; |
| 807 | return write; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 808 | } |
| 809 | |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 810 | inline VkWriteDescriptorSet Device::write_descriptor_set(const DescriptorSet &set, uint32_t binding, uint32_t array_element, |
| 811 | VkDescriptorType type, const std::vector<VkDescriptorInfo> &descriptors) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 812 | { |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 813 | return write_descriptor_set(set, binding, array_element, type, descriptors.size(), &descriptors[0]); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 814 | } |
| 815 | |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 816 | inline VkCopyDescriptorSet Device::copy_descriptor_set(const DescriptorSet &src_set, uint32_t src_binding, uint32_t src_array_element, |
| 817 | const DescriptorSet &dst_set, uint32_t dst_binding, uint32_t dst_array_element, |
| 818 | uint32_t count) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 819 | { |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 820 | VkCopyDescriptorSet copy = {}; |
| 821 | copy.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 822 | copy.srcSet = src_set.obj(); |
| 823 | copy.srcBinding = src_binding; |
| 824 | copy.srcArrayElement = src_array_element; |
| 825 | copy.destSet = dst_set.obj(); |
| 826 | copy.destBinding = dst_binding; |
| 827 | copy.destArrayElement = dst_array_element; |
| 828 | copy.count = count; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 829 | |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 830 | return copy; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 831 | } |
| 832 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 833 | inline VkCmdBufferCreateInfo CmdBuffer::create_info(uint32_t queueNodeIndex) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 834 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 835 | VkCmdBufferCreateInfo info = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 836 | info.sType = VK_STRUCTURE_TYPE_CMD_BUFFER_CREATE_INFO; |
| 837 | info.queueNodeIndex = queueNodeIndex; |
| 838 | return info; |
| 839 | } |
| 840 | |
| 841 | }; // namespace vk_testing |
| 842 | |
| 843 | #endif // VKTESTBINDING_H |