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