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