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> |
Chia-I Wu | a10be9d | 2015-07-03 10:13:26 +0800 | [diff] [blame] | 27 | #include <assert.h> |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 28 | |
| 29 | #include "vulkan.h" |
| 30 | |
| 31 | namespace vk_testing { |
| 32 | |
| 33 | typedef void (*ErrorCallback)(const char *expr, const char *file, unsigned int line, const char *function); |
| 34 | void set_error_callback(ErrorCallback callback); |
| 35 | |
Chia-I Wu | f5fb109 | 2015-07-03 10:32:05 +0800 | [diff] [blame] | 36 | class PhysicalDevice; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 37 | class Device; |
| 38 | class Queue; |
Chia-I Wu | ba0836f | 2015-07-03 10:58:57 +0800 | [diff] [blame] | 39 | class DeviceMemory; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 40 | class Fence; |
| 41 | class Semaphore; |
| 42 | class Event; |
| 43 | class QueryPool; |
| 44 | class Buffer; |
| 45 | class BufferView; |
| 46 | class Image; |
| 47 | class ImageView; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 48 | class DepthStencilView; |
| 49 | class Shader; |
| 50 | class Pipeline; |
| 51 | class PipelineDelta; |
| 52 | class Sampler; |
| 53 | class DescriptorSetLayout; |
Mark Lobodzinski | 556f721 | 2015-04-17 14:11:39 -0500 | [diff] [blame] | 54 | class PipelineLayout; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 55 | class DescriptorSetPool; |
| 56 | class DescriptorSet; |
Chia-I Wu | 6b11e60 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 57 | class DynamicViewportState; |
Cody Northrop | e4bc694 | 2015-08-26 10:01:32 -0600 | [diff] [blame] | 58 | class DynamicLineWidthState; |
| 59 | class DynamicDepthBiasState; |
| 60 | class DynamicBlendState; |
| 61 | class DynamicDepthBoundsState; |
Cody Northrop | 2605cb0 | 2015-08-18 15:21:16 -0600 | [diff] [blame] | 62 | class DynamicStencilState; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 63 | class CmdBuffer; |
Courtney Goeltzenleuchter | 902d081 | 2015-07-10 19:50:17 -0600 | [diff] [blame] | 64 | class CmdPool; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 65 | |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 66 | std::vector<VkLayerProperties> GetGlobalLayers(); |
| 67 | std::vector<VkExtensionProperties> GetGlobalExtensions(); |
| 68 | std::vector<VkExtensionProperties> GetGlobalExtensions(const char *pLayerName); |
| 69 | |
Chia-I Wu | a10be9d | 2015-07-03 10:13:26 +0800 | [diff] [blame] | 70 | namespace internal { |
| 71 | |
| 72 | template<typename T> |
| 73 | class Handle { |
| 74 | public: |
| 75 | const T &handle() const { return handle_; } |
| 76 | bool initialized() const { return (handle_ != VK_NULL_HANDLE); } |
| 77 | |
| 78 | protected: |
| 79 | typedef T handle_type; |
| 80 | |
| 81 | explicit Handle() : handle_(VK_NULL_HANDLE) {} |
| 82 | explicit Handle(T handle) : handle_(handle) {} |
| 83 | |
| 84 | void init(T handle) |
| 85 | { |
| 86 | assert(!initialized()); |
| 87 | handle_ = handle; |
| 88 | } |
| 89 | |
| 90 | private: |
| 91 | // handles are non-copyable |
| 92 | Handle(const Handle &); |
| 93 | Handle &operator=(const Handle &); |
| 94 | |
| 95 | T handle_; |
| 96 | }; |
| 97 | |
| 98 | |
| 99 | template<typename T> |
| 100 | class NonDispHandle : public Handle<T> { |
| 101 | protected: |
| 102 | explicit NonDispHandle() : Handle<T>(), dev_handle_(VK_NULL_HANDLE) {} |
| 103 | explicit NonDispHandle(VkDevice dev, T handle) : Handle<T>(handle), dev_handle_(dev) {} |
| 104 | |
| 105 | const VkDevice &device() const { return dev_handle_; } |
| 106 | |
| 107 | void init(VkDevice dev, T handle) |
| 108 | { |
| 109 | assert(!Handle<T>::initialized() && dev_handle_ == VK_NULL_HANDLE); |
| 110 | Handle<T>::init(handle); |
| 111 | dev_handle_ = dev; |
| 112 | } |
| 113 | |
| 114 | private: |
| 115 | VkDevice dev_handle_; |
| 116 | }; |
| 117 | |
| 118 | } // namespace internal |
| 119 | |
Chia-I Wu | f5fb109 | 2015-07-03 10:32:05 +0800 | [diff] [blame] | 120 | class PhysicalDevice : public internal::Handle<VkPhysicalDevice> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 121 | public: |
Chia-I Wu | f5fb109 | 2015-07-03 10:32:05 +0800 | [diff] [blame] | 122 | explicit PhysicalDevice(VkPhysicalDevice phy) : Handle(phy) |
Mark Lobodzinski | 7234629 | 2015-07-02 16:49:40 -0600 | [diff] [blame] | 123 | { |
| 124 | memory_properties_ = memory_properties(); |
| 125 | } |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 126 | |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 127 | VkPhysicalDeviceProperties properties() const; |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 128 | VkPhysicalDeviceMemoryProperties memory_properties() const; |
Cody Northrop | ef72e2a | 2015-08-03 17:04:53 -0600 | [diff] [blame] | 129 | std::vector<VkQueueFamilyProperties> queue_properties() const; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 130 | |
Mike Stroyan | d72da75 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 131 | VkResult set_memory_type(const uint32_t type_bits, VkMemoryAllocInfo *info, const VkMemoryPropertyFlags properties, |
| 132 | const VkMemoryPropertyFlags forbid = 0) const; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 133 | |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 134 | // vkGetPhysicalDeviceExtensionProperties() |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 135 | std::vector<VkExtensionProperties> extensions() const; |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 136 | std::vector<VkExtensionProperties> extensions(const char * pLayerName) const; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 137 | |
| 138 | // vkEnumerateLayers() |
Courtney Goeltzenleuchter | f5c6195 | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 139 | std::vector<VkLayerProperties> layers() const; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 140 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 141 | private: |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 142 | void add_extension_dependencies(uint32_t dependency_count, |
| 143 | VkExtensionProperties *depencency_props, |
| 144 | std::vector<VkExtensionProperties> &ext_list); |
Chia-I Wu | f5fb109 | 2015-07-03 10:32:05 +0800 | [diff] [blame] | 145 | |
Mark Lobodzinski | 7234629 | 2015-07-02 16:49:40 -0600 | [diff] [blame] | 146 | VkPhysicalDeviceMemoryProperties memory_properties_; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 147 | }; |
| 148 | |
Chia-I Wu | a263629 | 2015-07-03 10:41:20 +0800 | [diff] [blame] | 149 | class Device : public internal::Handle<VkDevice> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 150 | public: |
Chia-I Wu | f5fb109 | 2015-07-03 10:32:05 +0800 | [diff] [blame] | 151 | explicit Device(VkPhysicalDevice phy) : phy_(phy) {} |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 152 | ~Device(); |
| 153 | |
| 154 | // vkCreateDevice() |
Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 155 | void init(const VkDeviceCreateInfo &info); |
Courtney Goeltzenleuchter | 61414de | 2015-07-07 11:47:33 -0600 | [diff] [blame] | 156 | void init(std::vector<const char*> &layers, std::vector<const char *> &extensions); // all queues, all extensions, etc |
| 157 | void init() { std::vector<const char *> layers; std::vector<const char *> extensions; init(layers, extensions); }; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 158 | |
Chia-I Wu | f5fb109 | 2015-07-03 10:32:05 +0800 | [diff] [blame] | 159 | const PhysicalDevice &phy() const { return phy_; } |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 160 | |
Jon Ashburn | 1245cec | 2015-05-18 13:20:15 -0600 | [diff] [blame] | 161 | // vkGetDeviceProcAddr() |
Courtney Goeltzenleuchter | a4c8c71 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 162 | PFN_vkVoidFunction get_proc(const char *name) const { return vkGetDeviceProcAddr(handle(), name); } |
Jon Ashburn | 1245cec | 2015-05-18 13:20:15 -0600 | [diff] [blame] | 163 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 164 | // vkGetDeviceQueue() |
Mark Lobodzinski | cf26e07 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 165 | const std::vector<Queue *> &graphics_queues() const { return queues_[GRAPHICS]; } |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 166 | const std::vector<Queue *> &compute_queues() { return queues_[COMPUTE]; } |
| 167 | const std::vector<Queue *> &dma_queues() { return queues_[DMA]; } |
| 168 | uint32_t graphics_queue_node_index_; |
| 169 | |
| 170 | struct Format { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 171 | VkFormat format; |
| 172 | VkImageTiling tiling; |
| 173 | VkFlags features; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 174 | }; |
| 175 | // vkGetFormatInfo() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 176 | VkFormatProperties format_properties(VkFormat format); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 177 | const std::vector<Format> &formats() const { return formats_; } |
| 178 | |
| 179 | // vkDeviceWaitIdle() |
| 180 | void wait(); |
| 181 | |
| 182 | // vkWaitForFences() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 183 | VkResult wait(const std::vector<const Fence *> &fences, bool wait_all, uint64_t timeout); |
| 184 | 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] | 185 | |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 186 | // vkUpdateDescriptorSets() |
Mark Lobodzinski | 67b42b7 | 2015-09-07 13:59:43 -0600 | [diff] [blame] | 187 | void update_descriptor_sets(const std::vector<VkWriteDescriptorSet> &writes, const std::vector<VkCopyDescriptorSet> &copies); |
| 188 | void update_descriptor_sets(const std::vector<VkWriteDescriptorSet> &writes) { return update_descriptor_sets(writes, std::vector<VkCopyDescriptorSet>()); } |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 189 | |
| 190 | static VkWriteDescriptorSet write_descriptor_set(const DescriptorSet &set, uint32_t binding, uint32_t array_element, |
| 191 | VkDescriptorType type, uint32_t count, const VkDescriptorInfo *descriptors); |
| 192 | static VkWriteDescriptorSet write_descriptor_set(const DescriptorSet &set, uint32_t binding, uint32_t array_element, |
| 193 | VkDescriptorType type, const std::vector<VkDescriptorInfo> &descriptors); |
| 194 | |
| 195 | static VkCopyDescriptorSet copy_descriptor_set(const DescriptorSet &src_set, uint32_t src_binding, uint32_t src_array_element, |
| 196 | const DescriptorSet &dst_set, uint32_t dst_binding, uint32_t dst_array_element, |
| 197 | uint32_t count); |
| 198 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 199 | private: |
| 200 | enum QueueIndex { |
| 201 | GRAPHICS, |
| 202 | COMPUTE, |
| 203 | DMA, |
| 204 | QUEUE_COUNT, |
| 205 | }; |
| 206 | |
| 207 | void init_queues(); |
| 208 | void init_formats(); |
| 209 | |
Chia-I Wu | f5fb109 | 2015-07-03 10:32:05 +0800 | [diff] [blame] | 210 | PhysicalDevice phy_; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 211 | |
| 212 | std::vector<Queue *> queues_[QUEUE_COUNT]; |
| 213 | std::vector<Format> formats_; |
| 214 | }; |
| 215 | |
Chia-I Wu | f2862c7 | 2015-07-03 10:53:18 +0800 | [diff] [blame] | 216 | class Queue : public internal::Handle<VkQueue> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 217 | public: |
Tony Barbour | 0caa94f | 2015-07-23 10:35:30 -0600 | [diff] [blame] | 218 | explicit Queue(VkQueue queue, int index) : Handle(queue) {family_index_ = index;} |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 219 | |
| 220 | // vkQueueSubmit() |
| 221 | void submit(const std::vector<const CmdBuffer *> &cmds, Fence &fence); |
| 222 | void submit(const CmdBuffer &cmd, Fence &fence); |
| 223 | void submit(const CmdBuffer &cmd); |
| 224 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 225 | // vkQueueWaitIdle() |
| 226 | void wait(); |
| 227 | |
| 228 | // vkQueueSignalSemaphore() |
| 229 | // vkQueueWaitSemaphore() |
| 230 | void signal_semaphore(Semaphore &sem); |
| 231 | void wait_semaphore(Semaphore &sem); |
Tony Barbour | 0caa94f | 2015-07-23 10:35:30 -0600 | [diff] [blame] | 232 | |
| 233 | int get_family_index() {return family_index_;} |
| 234 | |
| 235 | private: |
| 236 | int family_index_; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 237 | }; |
| 238 | |
Chia-I Wu | ba0836f | 2015-07-03 10:58:57 +0800 | [diff] [blame] | 239 | class DeviceMemory : public internal::NonDispHandle<VkDeviceMemory> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 240 | public: |
Chia-I Wu | ba0836f | 2015-07-03 10:58:57 +0800 | [diff] [blame] | 241 | ~DeviceMemory(); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 242 | |
| 243 | // vkAllocMemory() |
Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 244 | void init(const Device &dev, const VkMemoryAllocInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 245 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 246 | // vkMapMemory() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 247 | const void *map(VkFlags flags) const; |
| 248 | void *map(VkFlags flags); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 249 | const void *map() const { return map(0); } |
| 250 | void *map() { return map(0); } |
| 251 | |
| 252 | // vkUnmapMemory() |
| 253 | void unmap() const; |
| 254 | |
Chia-I Wu | ba0836f | 2015-07-03 10:58:57 +0800 | [diff] [blame] | 255 | static VkMemoryAllocInfo alloc_info(VkDeviceSize size, uint32_t memory_type_index); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 256 | }; |
| 257 | |
Chia-I Wu | a499234 | 2015-07-03 11:45:55 +0800 | [diff] [blame] | 258 | class Fence : public internal::NonDispHandle<VkFence> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 259 | public: |
Chia-I Wu | a499234 | 2015-07-03 11:45:55 +0800 | [diff] [blame] | 260 | ~Fence(); |
| 261 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 262 | // vkCreateFence() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 263 | void init(const Device &dev, const VkFenceCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 264 | |
| 265 | // vkGetFenceStatus() |
Chia-I Wu | a499234 | 2015-07-03 11:45:55 +0800 | [diff] [blame] | 266 | VkResult status() const { return vkGetFenceStatus(device(), handle()); } |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 267 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 268 | static VkFenceCreateInfo create_info(VkFenceCreateFlags flags); |
| 269 | static VkFenceCreateInfo create_info(); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 270 | }; |
| 271 | |
Chia-I Wu | 2454b92 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 272 | class Semaphore : public internal::NonDispHandle<VkSemaphore> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 273 | public: |
Chia-I Wu | 2454b92 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 274 | ~Semaphore(); |
| 275 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 276 | // vkCreateSemaphore() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 277 | void init(const Device &dev, const VkSemaphoreCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 278 | |
Tony Barbour | 864fd38 | 2015-06-26 12:56:09 -0600 | [diff] [blame] | 279 | static VkSemaphoreCreateInfo create_info(VkFlags flags); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 280 | }; |
| 281 | |
Chia-I Wu | 9b6db1d | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 282 | class Event : public internal::NonDispHandle<VkEvent> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 283 | public: |
Chia-I Wu | 9b6db1d | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 284 | ~Event(); |
| 285 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 286 | // vkCreateEvent() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 287 | void init(const Device &dev, const VkEventCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 288 | |
| 289 | // vkGetEventStatus() |
| 290 | // vkSetEvent() |
| 291 | // vkResetEvent() |
Chia-I Wu | 9b6db1d | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 292 | VkResult status() const { return vkGetEventStatus(device(), handle()); } |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 293 | void set(); |
| 294 | void reset(); |
| 295 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 296 | static VkEventCreateInfo create_info(VkFlags flags); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 297 | }; |
| 298 | |
Chia-I Wu | fd0ce99 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 299 | class QueryPool : public internal::NonDispHandle<VkQueryPool> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 300 | public: |
Chia-I Wu | fd0ce99 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 301 | ~QueryPool(); |
| 302 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 303 | // vkCreateQueryPool() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 304 | void init(const Device &dev, const VkQueryPoolCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 305 | |
| 306 | // vkGetQueryPoolResults() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 307 | 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] | 308 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 309 | static VkQueryPoolCreateInfo create_info(VkQueryType type, uint32_t slot_count); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 310 | }; |
| 311 | |
Chia-I Wu | f4aed6c | 2015-07-03 13:44:34 +0800 | [diff] [blame] | 312 | class Buffer : public internal::NonDispHandle<VkBuffer> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 313 | public: |
Chia-I Wu | f4aed6c | 2015-07-03 13:44:34 +0800 | [diff] [blame] | 314 | explicit Buffer() : NonDispHandle() {} |
Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 315 | explicit Buffer(const Device &dev, const VkBufferCreateInfo &info) { init(dev, info); } |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 316 | explicit Buffer(const Device &dev, VkDeviceSize size) { init(dev, size); } |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 317 | |
Chia-I Wu | f4aed6c | 2015-07-03 13:44:34 +0800 | [diff] [blame] | 318 | ~Buffer(); |
| 319 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 320 | // vkCreateBuffer() |
Chia-I Wu | f4aed6c | 2015-07-03 13:44:34 +0800 | [diff] [blame] | 321 | void init(const Device &dev, const VkBufferCreateInfo &info, VkMemoryPropertyFlags mem_props); |
| 322 | void init(const Device &dev, const VkBufferCreateInfo &info) { init(dev, info, 0); } |
| 323 | void init(const Device &dev, VkDeviceSize size, VkMemoryPropertyFlags mem_props) { init(dev, create_info(size, 0), mem_props); } |
| 324 | void init(const Device &dev, VkDeviceSize size) { init(dev, size, 0); } |
Cody Northrop | d0e7d22 | 2015-06-22 14:56:14 -0600 | [diff] [blame] | 325 | void init_as_src(const Device &dev, VkDeviceSize size, VkMemoryPropertyFlags &reqs) { init(dev, create_info(size, VK_BUFFER_USAGE_TRANSFER_SOURCE_BIT), reqs); } |
| 326 | void init_as_dst(const Device &dev, VkDeviceSize size, VkMemoryPropertyFlags &reqs) { init(dev, create_info(size, VK_BUFFER_USAGE_TRANSFER_DESTINATION_BIT), reqs); } |
| 327 | 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); } |
Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 328 | void init_no_mem(const Device &dev, const VkBufferCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 329 | |
Chia-I Wu | f4aed6c | 2015-07-03 13:44:34 +0800 | [diff] [blame] | 330 | // get the internal memory |
| 331 | const DeviceMemory &memory() const { return internal_mem_; } |
| 332 | DeviceMemory &memory() { return internal_mem_; } |
| 333 | |
| 334 | // vkGetObjectMemoryRequirements() |
| 335 | VkMemoryRequirements memory_requirements() const; |
| 336 | |
| 337 | // vkBindObjectMemory() |
| 338 | void bind_memory(const DeviceMemory &mem, VkDeviceSize mem_offset); |
Mark Lobodzinski | fb9f564 | 2015-05-11 17:21:15 -0500 | [diff] [blame] | 339 | |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 340 | static VkBufferCreateInfo create_info(VkDeviceSize size, VkFlags usage); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 341 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 342 | VkBufferMemoryBarrier buffer_memory_barrier(VkFlags output_mask, VkFlags input_mask, |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 343 | VkDeviceSize offset, VkDeviceSize size) const |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 344 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 345 | VkBufferMemoryBarrier barrier = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 346 | barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
Chia-I Wu | f4aed6c | 2015-07-03 13:44:34 +0800 | [diff] [blame] | 347 | barrier.buffer = handle(); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 348 | barrier.outputMask = output_mask; |
| 349 | barrier.inputMask = input_mask; |
| 350 | barrier.offset = offset; |
| 351 | barrier.size = size; |
| 352 | return barrier; |
| 353 | } |
Chia-I Wu | f4aed6c | 2015-07-03 13:44:34 +0800 | [diff] [blame] | 354 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 355 | private: |
Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 356 | VkBufferCreateInfo create_info_; |
Chia-I Wu | f4aed6c | 2015-07-03 13:44:34 +0800 | [diff] [blame] | 357 | |
| 358 | DeviceMemory internal_mem_; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 359 | }; |
| 360 | |
Chia-I Wu | 76ab1ff | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 361 | class BufferView : public internal::NonDispHandle<VkBufferView> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 362 | public: |
Chia-I Wu | 76ab1ff | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 363 | ~BufferView(); |
| 364 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 365 | // vkCreateBufferView() |
Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 366 | void init(const Device &dev, const VkBufferViewCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 367 | }; |
| 368 | |
Chia-I Wu | f4aed6c | 2015-07-03 13:44:34 +0800 | [diff] [blame] | 369 | class Image : public internal::NonDispHandle<VkImage> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 370 | public: |
Chia-I Wu | f4aed6c | 2015-07-03 13:44:34 +0800 | [diff] [blame] | 371 | explicit Image() : NonDispHandle(), format_features_(0) {} |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 372 | 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] | 373 | |
Chia-I Wu | f4aed6c | 2015-07-03 13:44:34 +0800 | [diff] [blame] | 374 | ~Image(); |
| 375 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 376 | // vkCreateImage() |
Chia-I Wu | f4aed6c | 2015-07-03 13:44:34 +0800 | [diff] [blame] | 377 | void init(const Device &dev, const VkImageCreateInfo &info, VkMemoryPropertyFlags mem_props); |
| 378 | void init(const Device &dev, const VkImageCreateInfo &info) { init(dev, info, 0); } |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 379 | void init_no_mem(const Device &dev, const VkImageCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 380 | |
Chia-I Wu | f4aed6c | 2015-07-03 13:44:34 +0800 | [diff] [blame] | 381 | // get the internal memory |
| 382 | const DeviceMemory &memory() const { return internal_mem_; } |
| 383 | DeviceMemory &memory() { return internal_mem_; } |
| 384 | |
| 385 | // vkGetObjectMemoryRequirements() |
| 386 | VkMemoryRequirements memory_requirements() const; |
| 387 | |
| 388 | // vkBindObjectMemory() |
| 389 | void bind_memory(const DeviceMemory &mem, VkDeviceSize mem_offset); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 390 | |
Tony Barbour | 426b905 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 391 | // vkGetImageSubresourceLayout() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 392 | VkSubresourceLayout subresource_layout(const VkImageSubresource &subres) const; |
Courtney Goeltzenleuchter | bd7f592 | 2015-09-10 16:41:13 -0600 | [diff] [blame] | 393 | VkSubresourceLayout subresource_layout(const VkImageSubresourceCopy &subres) const; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 394 | |
| 395 | bool transparent() const; |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 396 | bool copyable() const { return (format_features_ & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT); } |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 397 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 398 | VkImageSubresourceRange subresource_range(VkImageAspect aspect) const { return subresource_range(create_info_, aspect); } |
| 399 | VkExtent3D extent() const { return create_info_.extent; } |
| 400 | VkExtent3D extent(uint32_t mip_level) const { return extent(create_info_.extent, mip_level); } |
| 401 | VkFormat format() const {return create_info_.format;} |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 402 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 403 | VkImageMemoryBarrier image_memory_barrier(VkFlags output_mask, VkFlags input_mask, |
| 404 | VkImageLayout old_layout, |
| 405 | VkImageLayout new_layout, |
| 406 | const VkImageSubresourceRange &range) const |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 407 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 408 | VkImageMemoryBarrier barrier = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 409 | barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| 410 | barrier.outputMask = output_mask; |
| 411 | barrier.inputMask = input_mask; |
| 412 | barrier.oldLayout = old_layout; |
| 413 | barrier.newLayout = new_layout; |
Chia-I Wu | f4aed6c | 2015-07-03 13:44:34 +0800 | [diff] [blame] | 414 | barrier.image = handle(); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 415 | barrier.subresourceRange = range; |
| 416 | return barrier; |
| 417 | } |
| 418 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 419 | static VkImageCreateInfo create_info(); |
Courtney Goeltzenleuchter | aeffeae | 2015-09-10 17:58:54 -0600 | [diff] [blame] | 420 | static VkImageAspect image_aspect(VkImageAspectFlags flags); |
Courtney Goeltzenleuchter | 3dee808 | 2015-09-10 16:38:41 -0600 | [diff] [blame] | 421 | static VkImageSubresource subresource(VkImageAspect aspect, uint32_t mip_level, uint32_t array_layer); |
| 422 | static VkImageSubresource subresource(const VkImageSubresourceRange &range, uint32_t mip_level, uint32_t array_layer); |
Courtney Goeltzenleuchter | bd7f592 | 2015-09-10 16:41:13 -0600 | [diff] [blame] | 423 | static VkImageSubresourceCopy subresource(VkImageAspect aspect, uint32_t mip_level, uint32_t array_layer, uint32_t array_size); |
| 424 | static VkImageSubresourceCopy subresource(const VkImageSubresourceRange &range, uint32_t mip_level, uint32_t array_layer, uint32_t array_size); |
Courtney Goeltzenleuchter | aeffeae | 2015-09-10 17:58:54 -0600 | [diff] [blame] | 425 | static VkImageSubresourceRange subresource_range(VkImageAspectFlags aspect_mask, uint32_t base_mip_level, uint32_t mip_levels, |
Courtney Goeltzenleuchter | 3dee808 | 2015-09-10 16:38:41 -0600 | [diff] [blame] | 426 | uint32_t base_array_layer, uint32_t array_size); |
Courtney Goeltzenleuchter | aeffeae | 2015-09-10 17:58:54 -0600 | [diff] [blame] | 427 | static VkImageSubresourceRange subresource_range(const VkImageCreateInfo &info, VkImageAspectFlags aspect_mask); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 428 | static VkImageSubresourceRange subresource_range(const VkImageSubresource &subres); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 429 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 430 | static VkExtent2D extent(int32_t width, int32_t height); |
| 431 | static VkExtent2D extent(const VkExtent2D &extent, uint32_t mip_level); |
| 432 | static VkExtent2D extent(const VkExtent3D &extent); |
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 | static VkExtent3D extent(int32_t width, int32_t height, int32_t depth); |
| 435 | static VkExtent3D extent(const VkExtent3D &extent, uint32_t mip_level); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 436 | |
| 437 | private: |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 438 | void init_info(const Device &dev, const VkImageCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 439 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 440 | VkImageCreateInfo create_info_; |
| 441 | VkFlags format_features_; |
Chia-I Wu | f4aed6c | 2015-07-03 13:44:34 +0800 | [diff] [blame] | 442 | |
| 443 | DeviceMemory internal_mem_; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 444 | }; |
| 445 | |
Chia-I Wu | 76ab1ff | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 446 | class ImageView : public internal::NonDispHandle<VkImageView> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 447 | public: |
Chia-I Wu | 76ab1ff | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 448 | ~ImageView(); |
| 449 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 450 | // vkCreateImageView() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 451 | void init(const Device &dev, const VkImageViewCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 452 | }; |
| 453 | |
Chia-I Wu | b48eddb | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 454 | class ShaderModule : public internal::NonDispHandle<VkShaderModule> { |
Courtney Goeltzenleuchter | 2d034fd | 2015-06-28 13:01:17 -0600 | [diff] [blame] | 455 | public: |
Chia-I Wu | b48eddb | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 456 | ~ShaderModule(); |
| 457 | |
Courtney Goeltzenleuchter | 2d034fd | 2015-06-28 13:01:17 -0600 | [diff] [blame] | 458 | // vkCreateShaderModule() |
| 459 | void init(const Device &dev, const VkShaderModuleCreateInfo &info); |
| 460 | VkResult init_try(const Device &dev, const VkShaderModuleCreateInfo &info); |
| 461 | |
| 462 | static VkShaderModuleCreateInfo create_info(size_t code_size, const void *code, VkFlags flags); |
| 463 | }; |
| 464 | |
Chia-I Wu | b48eddb | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 465 | class Shader : public internal::NonDispHandle<VkShader> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 466 | public: |
Chia-I Wu | b48eddb | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 467 | ~Shader(); |
| 468 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 469 | // vkCreateShader() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 470 | void init(const Device &dev, const VkShaderCreateInfo &info); |
| 471 | VkResult init_try(const Device &dev, const VkShaderCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 472 | |
Cody Northrop | 87ae5e1 | 2015-08-24 15:11:10 -0600 | [diff] [blame] | 473 | static VkShaderCreateInfo create_info(VkShaderModule module, const char *pName, VkFlags flags, VkShaderStage stage); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 474 | }; |
| 475 | |
Chia-I Wu | 2b1d4d0 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 476 | class Pipeline : public internal::NonDispHandle<VkPipeline> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 477 | public: |
Chia-I Wu | 2b1d4d0 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 478 | ~Pipeline(); |
| 479 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 480 | // vkCreateGraphicsPipeline() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 481 | void init(const Device &dev, const VkGraphicsPipelineCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 482 | // vkCreateGraphicsPipelineDerivative() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 483 | void init(const Device &dev, const VkGraphicsPipelineCreateInfo &info, const VkPipeline basePipeline); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 484 | // vkCreateComputePipeline() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 485 | void init(const Device &dev, const VkComputePipelineCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 486 | // vkLoadPipeline() |
| 487 | void init(const Device&dev, size_t size, const void *data); |
| 488 | // vkLoadPipelineDerivative() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 489 | 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] | 490 | |
Chris Forbes | dc2188c | 2015-05-25 11:13:26 +1200 | [diff] [blame] | 491 | // vkCreateGraphicsPipeline with error return |
| 492 | VkResult init_try(const Device &dev, const VkGraphicsPipelineCreateInfo &info); |
| 493 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 494 | // vkStorePipeline() |
| 495 | size_t store(size_t size, void *data); |
| 496 | }; |
| 497 | |
Chia-I Wu | deb9913 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 498 | class PipelineLayout : public internal::NonDispHandle<VkPipelineLayout> { |
| 499 | public: |
| 500 | ~PipelineLayout(); |
| 501 | |
| 502 | // vCreatePipelineLayout() |
| 503 | void init(const Device &dev, VkPipelineLayoutCreateInfo &info, const std::vector<const DescriptorSetLayout *> &layouts); |
| 504 | }; |
| 505 | |
Chia-I Wu | 6abe35d | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 506 | class Sampler : public internal::NonDispHandle<VkSampler> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 507 | public: |
Chia-I Wu | 6abe35d | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 508 | ~Sampler(); |
| 509 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 510 | // vkCreateSampler() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 511 | void init(const Device &dev, const VkSamplerCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 512 | }; |
| 513 | |
Chia-I Wu | 55a871f | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 514 | class DescriptorSetLayout : public internal::NonDispHandle<VkDescriptorSetLayout> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 515 | public: |
Chia-I Wu | 55a871f | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 516 | ~DescriptorSetLayout(); |
| 517 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 518 | // vkCreateDescriptorSetLayout() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 519 | void init(const Device &dev, const VkDescriptorSetLayoutCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 520 | }; |
| 521 | |
Chia-I Wu | 55a871f | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 522 | class DescriptorPool : public internal::NonDispHandle<VkDescriptorPool> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 523 | public: |
Chia-I Wu | 55a871f | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 524 | ~DescriptorPool(); |
| 525 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 526 | // vkCreateDescriptorPool() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 527 | void init(const Device &dev, VkDescriptorPoolUsage usage, |
| 528 | uint32_t max_sets, const VkDescriptorPoolCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 529 | |
| 530 | // vkResetDescriptorPool() |
| 531 | void reset(); |
| 532 | |
| 533 | // vkAllocDescriptorSets() |
Mark Lobodzinski | cf26e07 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 534 | std::vector<DescriptorSet *> alloc_sets(const Device &dev, VkDescriptorSetUsage usage, const std::vector<const DescriptorSetLayout *> &layouts); |
| 535 | std::vector<DescriptorSet *> alloc_sets(const Device &dev, VkDescriptorSetUsage usage, const DescriptorSetLayout &layout, uint32_t count); |
| 536 | DescriptorSet *alloc_sets(const Device &dev, VkDescriptorSetUsage usage, const DescriptorSetLayout &layout); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 537 | }; |
| 538 | |
Chia-I Wu | 55a871f | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 539 | class DescriptorSet : public internal::NonDispHandle<VkDescriptorSet> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 540 | public: |
Chia-I Wu | 55a871f | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 541 | ~DescriptorSet(); |
| 542 | |
| 543 | explicit DescriptorSet() : NonDispHandle() {} |
Tony Barbour | e84a8d6 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 544 | explicit DescriptorSet(const Device &dev, VkDescriptorPool pool, VkDescriptorSet set) : NonDispHandle(dev.handle(), set) { pool_ = pool;} |
| 545 | |
| 546 | private: |
| 547 | VkDescriptorPool pool_; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 548 | }; |
| 549 | |
Tony Barbour | de4124d | 2015-07-03 10:33:54 -0600 | [diff] [blame] | 550 | class DynamicViewportState : public internal::NonDispHandle<VkDynamicViewportState> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 551 | public: |
Chia-I Wu | 6b11e60 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 552 | ~DynamicViewportState(); |
| 553 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 554 | // vkCreateDynamicViewportState() |
Tony Barbour | de4124d | 2015-07-03 10:33:54 -0600 | [diff] [blame] | 555 | void init(const Device &dev, const VkDynamicViewportStateCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 556 | }; |
| 557 | |
Cody Northrop | e4bc694 | 2015-08-26 10:01:32 -0600 | [diff] [blame] | 558 | class DynamicLineWidthState : public internal::NonDispHandle<VkDynamicLineWidthState> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 559 | public: |
Cody Northrop | e4bc694 | 2015-08-26 10:01:32 -0600 | [diff] [blame] | 560 | ~DynamicLineWidthState(); |
Chia-I Wu | 6b11e60 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 561 | |
Cody Northrop | e4bc694 | 2015-08-26 10:01:32 -0600 | [diff] [blame] | 562 | // vkCreateDynamicLineWidthState() |
| 563 | void init(const Device &dev, const VkDynamicLineWidthStateCreateInfo &info); |
Cody Northrop | f5bd225 | 2015-08-17 11:10:49 -0600 | [diff] [blame] | 564 | }; |
| 565 | |
Cody Northrop | e4bc694 | 2015-08-26 10:01:32 -0600 | [diff] [blame] | 566 | class DynamicDepthBiasState : public internal::NonDispHandle<VkDynamicDepthBiasState> { |
Cody Northrop | f5bd225 | 2015-08-17 11:10:49 -0600 | [diff] [blame] | 567 | public: |
Cody Northrop | e4bc694 | 2015-08-26 10:01:32 -0600 | [diff] [blame] | 568 | ~DynamicDepthBiasState(); |
Cody Northrop | f5bd225 | 2015-08-17 11:10:49 -0600 | [diff] [blame] | 569 | |
Cody Northrop | e4bc694 | 2015-08-26 10:01:32 -0600 | [diff] [blame] | 570 | // vkCreateDynamicDepthBiasState() |
| 571 | void init(const Device &dev, const VkDynamicDepthBiasStateCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 572 | }; |
| 573 | |
Cody Northrop | e4bc694 | 2015-08-26 10:01:32 -0600 | [diff] [blame] | 574 | class DynamicBlendState : public internal::NonDispHandle<VkDynamicBlendState> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 575 | public: |
Cody Northrop | e4bc694 | 2015-08-26 10:01:32 -0600 | [diff] [blame] | 576 | ~DynamicBlendState(); |
Chia-I Wu | 6b11e60 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 577 | |
Cody Northrop | e4bc694 | 2015-08-26 10:01:32 -0600 | [diff] [blame] | 578 | // vkCreateDynamicBlendState() |
| 579 | void init(const Device &dev, const VkDynamicBlendStateCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 580 | }; |
| 581 | |
Cody Northrop | e4bc694 | 2015-08-26 10:01:32 -0600 | [diff] [blame] | 582 | class DynamicDepthBoundsState : public internal::NonDispHandle<VkDynamicDepthBoundsState> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 583 | public: |
Cody Northrop | e4bc694 | 2015-08-26 10:01:32 -0600 | [diff] [blame] | 584 | ~DynamicDepthBoundsState(); |
Chia-I Wu | 6b11e60 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 585 | |
Cody Northrop | e4bc694 | 2015-08-26 10:01:32 -0600 | [diff] [blame] | 586 | // vkCreateDynamicDepthBoundsState() |
| 587 | void init(const Device &dev, const VkDynamicDepthBoundsStateCreateInfo &info); |
Cody Northrop | 2605cb0 | 2015-08-18 15:21:16 -0600 | [diff] [blame] | 588 | }; |
| 589 | |
| 590 | class DynamicStencilState : public internal::NonDispHandle<VkDynamicStencilState> { |
| 591 | public: |
| 592 | ~DynamicStencilState(); |
| 593 | |
| 594 | // vkCreateDynamicStencilState() |
| 595 | void init(const Device &dev, const VkDynamicStencilStateCreateInfo &frontInfo, const VkDynamicStencilStateCreateInfo &backInfo); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 596 | }; |
| 597 | |
Courtney Goeltzenleuchter | 902d081 | 2015-07-10 19:50:17 -0600 | [diff] [blame] | 598 | class CmdPool : public internal::NonDispHandle<VkCmdPool> { |
| 599 | public: |
| 600 | ~CmdPool(); |
| 601 | |
| 602 | explicit CmdPool() : NonDispHandle() {} |
| 603 | explicit CmdPool(const Device &dev, const VkCmdPoolCreateInfo &info) { init(dev, info); } |
| 604 | |
Courtney Goeltzenleuchter | 902d081 | 2015-07-10 19:50:17 -0600 | [diff] [blame] | 605 | void init(const Device &dev, const VkCmdPoolCreateInfo &info); |
| 606 | |
| 607 | static VkCmdPoolCreateInfo create_info(uint32_t queue_family_index); |
| 608 | }; |
| 609 | |
| 610 | inline VkCmdPoolCreateInfo CmdPool::create_info(uint32_t queue_family_index) |
| 611 | { |
| 612 | VkCmdPoolCreateInfo info = {}; |
Tony Barbour | 73c22f4 | 2015-07-27 09:36:24 -0600 | [diff] [blame] | 613 | info.sType = VK_STRUCTURE_TYPE_CMD_POOL_CREATE_INFO; |
Courtney Goeltzenleuchter | 902d081 | 2015-07-10 19:50:17 -0600 | [diff] [blame] | 614 | info.queueFamilyIndex = queue_family_index; |
| 615 | return info; |
| 616 | } |
| 617 | |
Chia-I Wu | 78c2a35 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 618 | class CmdBuffer : public internal::Handle<VkCmdBuffer> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 619 | public: |
Chia-I Wu | 78c2a35 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 620 | ~CmdBuffer(); |
| 621 | |
| 622 | explicit CmdBuffer() : Handle() {} |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 623 | explicit CmdBuffer(const Device &dev, const VkCmdBufferCreateInfo &info) { init(dev, info); } |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 624 | |
| 625 | // vkCreateCommandBuffer() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 626 | void init(const Device &dev, const VkCmdBufferCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 627 | |
| 628 | // vkBeginCommandBuffer() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 629 | void begin(const VkCmdBufferBeginInfo *info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 630 | void begin(); |
| 631 | |
| 632 | // vkEndCommandBuffer() |
| 633 | // vkResetCommandBuffer() |
| 634 | void end(); |
Cody Northrop | f02f9f8 | 2015-07-09 18:08:05 -0600 | [diff] [blame] | 635 | void reset(VkCmdBufferResetFlags flags); |
| 636 | void reset() { reset(VK_CMD_BUFFER_RESET_RELEASE_RESOURCES); } |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 637 | |
Courtney Goeltzenleuchter | 902d081 | 2015-07-10 19:50:17 -0600 | [diff] [blame] | 638 | static VkCmdBufferCreateInfo create_info(VkCmdPool const &pool); |
Chia-I Wu | 78c2a35 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 639 | |
| 640 | private: |
| 641 | VkDevice dev_handle_; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 642 | }; |
| 643 | |
Chia-I Wu | ba0836f | 2015-07-03 10:58:57 +0800 | [diff] [blame] | 644 | inline VkMemoryAllocInfo DeviceMemory::alloc_info(VkDeviceSize size, uint32_t memory_type_index) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 645 | { |
Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 646 | VkMemoryAllocInfo info = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 647 | info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
Chia-I Wu | ba0836f | 2015-07-03 10:58:57 +0800 | [diff] [blame] | 648 | info.allocationSize = size; |
| 649 | info.memoryTypeIndex = memory_type_index; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 650 | return info; |
| 651 | } |
| 652 | |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 653 | inline VkBufferCreateInfo Buffer::create_info(VkDeviceSize size, VkFlags usage) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 654 | { |
Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 655 | VkBufferCreateInfo info = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 656 | info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 657 | info.size = size; |
| 658 | info.usage = usage; |
| 659 | return info; |
| 660 | } |
| 661 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 662 | inline VkFenceCreateInfo Fence::create_info(VkFenceCreateFlags flags) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 663 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 664 | VkFenceCreateInfo info = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 665 | info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 666 | info.flags = flags; |
| 667 | return info; |
| 668 | } |
| 669 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 670 | inline VkFenceCreateInfo Fence::create_info() |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 671 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 672 | VkFenceCreateInfo info = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 673 | info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 674 | return info; |
| 675 | } |
| 676 | |
Tony Barbour | 864fd38 | 2015-06-26 12:56:09 -0600 | [diff] [blame] | 677 | inline VkSemaphoreCreateInfo Semaphore::create_info(VkFlags flags) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 678 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 679 | VkSemaphoreCreateInfo info = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 680 | info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 681 | info.flags = flags; |
| 682 | return info; |
| 683 | } |
| 684 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 685 | inline VkEventCreateInfo Event::create_info(VkFlags flags) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 686 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 687 | VkEventCreateInfo info = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 688 | info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 689 | info.flags = flags; |
| 690 | return info; |
| 691 | } |
| 692 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 693 | inline VkQueryPoolCreateInfo QueryPool::create_info(VkQueryType type, uint32_t slot_count) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 694 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 695 | VkQueryPoolCreateInfo info = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 696 | info.sType = VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO; |
| 697 | info.queryType = type; |
| 698 | info.slots = slot_count; |
| 699 | return info; |
| 700 | } |
| 701 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 702 | inline VkImageCreateInfo Image::create_info() |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 703 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 704 | VkImageCreateInfo info = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 705 | info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 706 | info.extent.width = 1; |
| 707 | info.extent.height = 1; |
| 708 | info.extent.depth = 1; |
| 709 | info.mipLevels = 1; |
| 710 | info.arraySize = 1; |
| 711 | info.samples = 1; |
| 712 | return info; |
| 713 | } |
| 714 | |
Courtney Goeltzenleuchter | 3dee808 | 2015-09-10 16:38:41 -0600 | [diff] [blame] | 715 | inline VkImageSubresource Image::subresource(VkImageAspect aspect, uint32_t mip_level, uint32_t array_layer) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 716 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 717 | VkImageSubresource subres = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 718 | subres.aspect = aspect; |
| 719 | subres.mipLevel = mip_level; |
Courtney Goeltzenleuchter | 3dee808 | 2015-09-10 16:38:41 -0600 | [diff] [blame] | 720 | subres.arrayLayer = array_layer; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 721 | return subres; |
| 722 | } |
| 723 | |
Courtney Goeltzenleuchter | 3dee808 | 2015-09-10 16:38:41 -0600 | [diff] [blame] | 724 | inline VkImageSubresource Image::subresource(const VkImageSubresourceRange &range, uint32_t mip_level, uint32_t array_layer) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 725 | { |
Courtney Goeltzenleuchter | aeffeae | 2015-09-10 17:58:54 -0600 | [diff] [blame] | 726 | return subresource(image_aspect(range.aspectMask), range.baseMipLevel + mip_level, range.baseArrayLayer + array_layer); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 727 | } |
| 728 | |
Courtney Goeltzenleuchter | bd7f592 | 2015-09-10 16:41:13 -0600 | [diff] [blame] | 729 | inline VkImageSubresourceCopy Image::subresource(VkImageAspect aspect, uint32_t mip_level, uint32_t array_layer, uint32_t array_size) |
| 730 | { |
| 731 | VkImageSubresourceCopy subres = {}; |
| 732 | subres.aspect = aspect; |
| 733 | subres.mipLevel = mip_level; |
| 734 | subres.arrayLayer = array_layer; |
| 735 | subres.arraySize = array_size; |
| 736 | return subres; |
| 737 | } |
| 738 | |
Courtney Goeltzenleuchter | aeffeae | 2015-09-10 17:58:54 -0600 | [diff] [blame] | 739 | inline VkImageAspect Image::image_aspect(VkImageAspectFlags flags) |
Courtney Goeltzenleuchter | bd7f592 | 2015-09-10 16:41:13 -0600 | [diff] [blame] | 740 | { |
Courtney Goeltzenleuchter | aeffeae | 2015-09-10 17:58:54 -0600 | [diff] [blame] | 741 | /* |
| 742 | * This will map VkImageAspectFlags into a single VkImageAspect. |
| 743 | * If there is more than one bit defined we'll get an assertion. |
| 744 | */ |
| 745 | switch (flags) { |
| 746 | case VK_IMAGE_ASPECT_COLOR_BIT: |
| 747 | return VK_IMAGE_ASPECT_COLOR; |
| 748 | case VK_IMAGE_ASPECT_DEPTH_BIT: |
| 749 | return VK_IMAGE_ASPECT_DEPTH; |
| 750 | case VK_IMAGE_ASPECT_STENCIL_BIT: |
| 751 | return VK_IMAGE_ASPECT_STENCIL; |
| 752 | case VK_IMAGE_ASPECT_METADATA_BIT: |
| 753 | return VK_IMAGE_ASPECT_METADATA; |
| 754 | default: |
| 755 | assert(!"Invalid VkImageAspect"); |
| 756 | } |
| 757 | return VK_IMAGE_ASPECT_COLOR; |
Courtney Goeltzenleuchter | bd7f592 | 2015-09-10 16:41:13 -0600 | [diff] [blame] | 758 | } |
| 759 | |
Courtney Goeltzenleuchter | aeffeae | 2015-09-10 17:58:54 -0600 | [diff] [blame] | 760 | inline VkImageSubresourceCopy Image::subresource(const VkImageSubresourceRange &range, uint32_t mip_level, uint32_t array_layer, uint32_t array_size) |
| 761 | { |
| 762 | return subresource(image_aspect(range.aspectMask), range.baseMipLevel + mip_level, range.baseArrayLayer + array_layer, array_size); |
| 763 | } |
| 764 | |
| 765 | inline VkImageSubresourceRange Image::subresource_range(VkImageAspectFlags aspect_mask, uint32_t base_mip_level, uint32_t mip_levels, |
Courtney Goeltzenleuchter | 3dee808 | 2015-09-10 16:38:41 -0600 | [diff] [blame] | 766 | uint32_t base_array_layer, uint32_t array_size) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 767 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 768 | VkImageSubresourceRange range = {}; |
Courtney Goeltzenleuchter | aeffeae | 2015-09-10 17:58:54 -0600 | [diff] [blame] | 769 | range.aspectMask = aspect_mask; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 770 | range.baseMipLevel = base_mip_level; |
| 771 | range.mipLevels = mip_levels; |
Courtney Goeltzenleuchter | 3dee808 | 2015-09-10 16:38:41 -0600 | [diff] [blame] | 772 | range.baseArrayLayer = base_array_layer; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 773 | range.arraySize = array_size; |
| 774 | return range; |
| 775 | } |
| 776 | |
Courtney Goeltzenleuchter | aeffeae | 2015-09-10 17:58:54 -0600 | [diff] [blame] | 777 | inline VkImageSubresourceRange Image::subresource_range(const VkImageCreateInfo &info, VkImageAspectFlags aspect_mask) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 778 | { |
Courtney Goeltzenleuchter | aeffeae | 2015-09-10 17:58:54 -0600 | [diff] [blame] | 779 | return subresource_range(aspect_mask, 0, info.mipLevels, 0, info.arraySize); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 780 | } |
| 781 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 782 | inline VkImageSubresourceRange Image::subresource_range(const VkImageSubresource &subres) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 783 | { |
Courtney Goeltzenleuchter | 3dee808 | 2015-09-10 16:38:41 -0600 | [diff] [blame] | 784 | return subresource_range(subres.aspect, subres.mipLevel, 1, subres.arrayLayer, 1); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 785 | } |
| 786 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 787 | inline VkExtent2D Image::extent(int32_t width, int32_t height) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 788 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 789 | VkExtent2D extent = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 790 | extent.width = width; |
| 791 | extent.height = height; |
| 792 | return extent; |
| 793 | } |
| 794 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 795 | inline VkExtent2D Image::extent(const VkExtent2D &extent, uint32_t mip_level) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 796 | { |
| 797 | const int32_t width = (extent.width >> mip_level) ? extent.width >> mip_level : 1; |
| 798 | const int32_t height = (extent.height >> mip_level) ? extent.height >> mip_level : 1; |
| 799 | return Image::extent(width, height); |
| 800 | } |
| 801 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 802 | inline VkExtent2D Image::extent(const VkExtent3D &extent) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 803 | { |
| 804 | return Image::extent(extent.width, extent.height); |
| 805 | } |
| 806 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 807 | 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] | 808 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 809 | VkExtent3D extent = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 810 | extent.width = width; |
| 811 | extent.height = height; |
| 812 | extent.depth = depth; |
| 813 | return extent; |
| 814 | } |
| 815 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 816 | inline VkExtent3D Image::extent(const VkExtent3D &extent, uint32_t mip_level) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 817 | { |
| 818 | const int32_t width = (extent.width >> mip_level) ? extent.width >> mip_level : 1; |
| 819 | const int32_t height = (extent.height >> mip_level) ? extent.height >> mip_level : 1; |
| 820 | const int32_t depth = (extent.depth >> mip_level) ? extent.depth >> mip_level : 1; |
| 821 | return Image::extent(width, height, depth); |
| 822 | } |
| 823 | |
Courtney Goeltzenleuchter | 2d034fd | 2015-06-28 13:01:17 -0600 | [diff] [blame] | 824 | inline VkShaderModuleCreateInfo ShaderModule::create_info(size_t code_size, const void *code, VkFlags flags) |
| 825 | { |
| 826 | VkShaderModuleCreateInfo info = {}; |
| 827 | info.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 828 | info.codeSize = code_size; |
| 829 | info.pCode = code; |
| 830 | info.flags = flags; |
| 831 | return info; |
| 832 | } |
| 833 | |
Cody Northrop | 87ae5e1 | 2015-08-24 15:11:10 -0600 | [diff] [blame] | 834 | inline VkShaderCreateInfo Shader::create_info(VkShaderModule module, const char *pName, VkFlags flags, VkShaderStage stage) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 835 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 836 | VkShaderCreateInfo info = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 837 | info.sType = VK_STRUCTURE_TYPE_SHADER_CREATE_INFO; |
Courtney Goeltzenleuchter | 2d034fd | 2015-06-28 13:01:17 -0600 | [diff] [blame] | 838 | info.module = module; |
| 839 | info.pName = pName; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 840 | info.flags = flags; |
Cody Northrop | 87ae5e1 | 2015-08-24 15:11:10 -0600 | [diff] [blame] | 841 | info.stage = stage; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 842 | return info; |
| 843 | } |
| 844 | |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 845 | inline VkWriteDescriptorSet Device::write_descriptor_set(const DescriptorSet &set, uint32_t binding, uint32_t array_element, |
| 846 | VkDescriptorType type, uint32_t count, const VkDescriptorInfo *descriptors) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 847 | { |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 848 | VkWriteDescriptorSet write = {}; |
| 849 | write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 55a871f | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 850 | write.destSet = set.handle(); |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 851 | write.destBinding = binding; |
| 852 | write.destArrayElement = array_element; |
| 853 | write.count = count; |
| 854 | write.descriptorType = type; |
| 855 | write.pDescriptors = descriptors; |
| 856 | return write; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 857 | } |
| 858 | |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 859 | inline VkWriteDescriptorSet Device::write_descriptor_set(const DescriptorSet &set, uint32_t binding, uint32_t array_element, |
| 860 | VkDescriptorType type, const std::vector<VkDescriptorInfo> &descriptors) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 861 | { |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 862 | 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] | 863 | } |
| 864 | |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 865 | inline VkCopyDescriptorSet Device::copy_descriptor_set(const DescriptorSet &src_set, uint32_t src_binding, uint32_t src_array_element, |
| 866 | const DescriptorSet &dst_set, uint32_t dst_binding, uint32_t dst_array_element, |
| 867 | uint32_t count) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 868 | { |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 869 | VkCopyDescriptorSet copy = {}; |
| 870 | copy.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
Chia-I Wu | 55a871f | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 871 | copy.srcSet = src_set.handle(); |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 872 | copy.srcBinding = src_binding; |
| 873 | copy.srcArrayElement = src_array_element; |
Chia-I Wu | 55a871f | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 874 | copy.destSet = dst_set.handle(); |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 875 | copy.destBinding = dst_binding; |
| 876 | copy.destArrayElement = dst_array_element; |
| 877 | copy.count = count; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 878 | |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 879 | return copy; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 880 | } |
| 881 | |
Courtney Goeltzenleuchter | 902d081 | 2015-07-10 19:50:17 -0600 | [diff] [blame] | 882 | inline VkCmdBufferCreateInfo CmdBuffer::create_info(VkCmdPool const &pool) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 883 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 884 | VkCmdBufferCreateInfo info = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 885 | info.sType = VK_STRUCTURE_TYPE_CMD_BUFFER_CREATE_INFO; |
Cody Northrop | f02f9f8 | 2015-07-09 18:08:05 -0600 | [diff] [blame] | 886 | info.cmdPool = pool; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 887 | return info; |
| 888 | } |
| 889 | |
| 890 | }; // namespace vk_testing |
| 891 | |
| 892 | #endif // VKTESTBINDING_H |