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; |
| 62 | class DynamicDepthStencilState; |
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() |
| 187 | VkResult update_descriptor_sets(const std::vector<VkWriteDescriptorSet> &writes, const std::vector<VkCopyDescriptorSet> &copies); |
| 188 | VkResult update_descriptor_sets(const std::vector<VkWriteDescriptorSet> &writes) { return update_descriptor_sets(writes, std::vector<VkCopyDescriptorSet>()); } |
| 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 | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 393 | |
| 394 | bool transparent() const; |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 395 | bool copyable() const { return (format_features_ & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT); } |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 396 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 397 | VkImageSubresourceRange subresource_range(VkImageAspect aspect) const { return subresource_range(create_info_, aspect); } |
| 398 | VkExtent3D extent() const { return create_info_.extent; } |
| 399 | VkExtent3D extent(uint32_t mip_level) const { return extent(create_info_.extent, mip_level); } |
| 400 | VkFormat format() const {return create_info_.format;} |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 401 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 402 | VkImageMemoryBarrier image_memory_barrier(VkFlags output_mask, VkFlags input_mask, |
| 403 | VkImageLayout old_layout, |
| 404 | VkImageLayout new_layout, |
| 405 | const VkImageSubresourceRange &range) const |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 406 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 407 | VkImageMemoryBarrier barrier = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 408 | barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| 409 | barrier.outputMask = output_mask; |
| 410 | barrier.inputMask = input_mask; |
| 411 | barrier.oldLayout = old_layout; |
| 412 | barrier.newLayout = new_layout; |
Chia-I Wu | f4aed6c | 2015-07-03 13:44:34 +0800 | [diff] [blame] | 413 | barrier.image = handle(); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 414 | barrier.subresourceRange = range; |
| 415 | return barrier; |
| 416 | } |
| 417 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 418 | static VkImageCreateInfo create_info(); |
| 419 | static VkImageSubresource subresource(VkImageAspect aspect, uint32_t mip_level, uint32_t array_slice); |
| 420 | static VkImageSubresource subresource(const VkImageSubresourceRange &range, uint32_t mip_level, uint32_t array_slice); |
| 421 | 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] | 422 | uint32_t base_array_slice, uint32_t array_size); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 423 | static VkImageSubresourceRange subresource_range(const VkImageCreateInfo &info, VkImageAspect aspect); |
| 424 | static VkImageSubresourceRange subresource_range(const VkImageSubresource &subres); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 425 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 426 | static VkExtent2D extent(int32_t width, int32_t height); |
| 427 | static VkExtent2D extent(const VkExtent2D &extent, uint32_t mip_level); |
| 428 | static VkExtent2D extent(const VkExtent3D &extent); |
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 VkExtent3D extent(int32_t width, int32_t height, int32_t depth); |
| 431 | static VkExtent3D extent(const VkExtent3D &extent, uint32_t mip_level); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 432 | |
| 433 | private: |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 434 | void init_info(const Device &dev, const VkImageCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 435 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 436 | VkImageCreateInfo create_info_; |
| 437 | VkFlags format_features_; |
Chia-I Wu | f4aed6c | 2015-07-03 13:44:34 +0800 | [diff] [blame] | 438 | |
| 439 | DeviceMemory internal_mem_; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 440 | }; |
| 441 | |
Chia-I Wu | 76ab1ff | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 442 | class ImageView : public internal::NonDispHandle<VkImageView> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 443 | public: |
Chia-I Wu | 76ab1ff | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 444 | ~ImageView(); |
| 445 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 446 | // vkCreateImageView() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 447 | void init(const Device &dev, const VkImageViewCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 448 | }; |
| 449 | |
Chia-I Wu | 76ab1ff | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 450 | //class AttachmentView : public DerivedObject<VkAttachmentView, Object, VK_OBJECT_TYPE_ATTACHMENT_VIEW> { |
| 451 | class AttachmentView : public internal::NonDispHandle<VkAttachmentView> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 452 | public: |
Chia-I Wu | 76ab1ff | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 453 | ~AttachmentView(); |
| 454 | |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 455 | // vkCreateAttachmentView() |
| 456 | void init(const Device &dev, const VkAttachmentViewCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 457 | }; |
| 458 | |
Chia-I Wu | b48eddb | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 459 | class ShaderModule : public internal::NonDispHandle<VkShaderModule> { |
Courtney Goeltzenleuchter | 2d034fd | 2015-06-28 13:01:17 -0600 | [diff] [blame] | 460 | public: |
Chia-I Wu | b48eddb | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 461 | ~ShaderModule(); |
| 462 | |
Courtney Goeltzenleuchter | 2d034fd | 2015-06-28 13:01:17 -0600 | [diff] [blame] | 463 | // vkCreateShaderModule() |
| 464 | void init(const Device &dev, const VkShaderModuleCreateInfo &info); |
| 465 | VkResult init_try(const Device &dev, const VkShaderModuleCreateInfo &info); |
| 466 | |
| 467 | static VkShaderModuleCreateInfo create_info(size_t code_size, const void *code, VkFlags flags); |
| 468 | }; |
| 469 | |
Chia-I Wu | b48eddb | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 470 | class Shader : public internal::NonDispHandle<VkShader> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 471 | public: |
Chia-I Wu | b48eddb | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 472 | ~Shader(); |
| 473 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 474 | // vkCreateShader() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 475 | void init(const Device &dev, const VkShaderCreateInfo &info); |
| 476 | VkResult init_try(const Device &dev, const VkShaderCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 477 | |
Courtney Goeltzenleuchter | 2d034fd | 2015-06-28 13:01:17 -0600 | [diff] [blame] | 478 | static VkShaderCreateInfo create_info(VkShaderModule module, const char *pName, VkFlags flags); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 479 | }; |
| 480 | |
Chia-I Wu | 2b1d4d0 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 481 | class Pipeline : public internal::NonDispHandle<VkPipeline> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 482 | public: |
Chia-I Wu | 2b1d4d0 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 483 | ~Pipeline(); |
| 484 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 485 | // vkCreateGraphicsPipeline() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 486 | void init(const Device &dev, const VkGraphicsPipelineCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 487 | // vkCreateGraphicsPipelineDerivative() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 488 | void init(const Device &dev, const VkGraphicsPipelineCreateInfo &info, const VkPipeline basePipeline); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 489 | // vkCreateComputePipeline() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 490 | void init(const Device &dev, const VkComputePipelineCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 491 | // vkLoadPipeline() |
| 492 | void init(const Device&dev, size_t size, const void *data); |
| 493 | // vkLoadPipelineDerivative() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 494 | 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] | 495 | |
Chris Forbes | dc2188c | 2015-05-25 11:13:26 +1200 | [diff] [blame] | 496 | // vkCreateGraphicsPipeline with error return |
| 497 | VkResult init_try(const Device &dev, const VkGraphicsPipelineCreateInfo &info); |
| 498 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 499 | // vkStorePipeline() |
| 500 | size_t store(size_t size, void *data); |
| 501 | }; |
| 502 | |
Chia-I Wu | deb9913 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 503 | class PipelineLayout : public internal::NonDispHandle<VkPipelineLayout> { |
| 504 | public: |
| 505 | ~PipelineLayout(); |
| 506 | |
| 507 | // vCreatePipelineLayout() |
| 508 | void init(const Device &dev, VkPipelineLayoutCreateInfo &info, const std::vector<const DescriptorSetLayout *> &layouts); |
| 509 | }; |
| 510 | |
Chia-I Wu | 6abe35d | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 511 | class Sampler : public internal::NonDispHandle<VkSampler> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 512 | public: |
Chia-I Wu | 6abe35d | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 513 | ~Sampler(); |
| 514 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 515 | // vkCreateSampler() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 516 | void init(const Device &dev, const VkSamplerCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 517 | }; |
| 518 | |
Chia-I Wu | 55a871f | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 519 | class DescriptorSetLayout : public internal::NonDispHandle<VkDescriptorSetLayout> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 520 | public: |
Chia-I Wu | 55a871f | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 521 | ~DescriptorSetLayout(); |
| 522 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 523 | // vkCreateDescriptorSetLayout() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 524 | void init(const Device &dev, const VkDescriptorSetLayoutCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 525 | }; |
| 526 | |
Chia-I Wu | 55a871f | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 527 | class DescriptorPool : public internal::NonDispHandle<VkDescriptorPool> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 528 | public: |
Chia-I Wu | 55a871f | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 529 | ~DescriptorPool(); |
| 530 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 531 | // vkCreateDescriptorPool() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 532 | void init(const Device &dev, VkDescriptorPoolUsage usage, |
| 533 | uint32_t max_sets, const VkDescriptorPoolCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 534 | |
| 535 | // vkResetDescriptorPool() |
| 536 | void reset(); |
| 537 | |
| 538 | // vkAllocDescriptorSets() |
Mark Lobodzinski | cf26e07 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 539 | std::vector<DescriptorSet *> alloc_sets(const Device &dev, VkDescriptorSetUsage usage, const std::vector<const DescriptorSetLayout *> &layouts); |
| 540 | std::vector<DescriptorSet *> alloc_sets(const Device &dev, VkDescriptorSetUsage usage, const DescriptorSetLayout &layout, uint32_t count); |
| 541 | DescriptorSet *alloc_sets(const Device &dev, VkDescriptorSetUsage usage, const DescriptorSetLayout &layout); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 542 | }; |
| 543 | |
Chia-I Wu | 55a871f | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 544 | class DescriptorSet : public internal::NonDispHandle<VkDescriptorSet> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 545 | public: |
Chia-I Wu | 55a871f | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 546 | ~DescriptorSet(); |
| 547 | |
| 548 | explicit DescriptorSet() : NonDispHandle() {} |
Tony Barbour | e84a8d6 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 549 | explicit DescriptorSet(const Device &dev, VkDescriptorPool pool, VkDescriptorSet set) : NonDispHandle(dev.handle(), set) { pool_ = pool;} |
| 550 | |
| 551 | private: |
| 552 | VkDescriptorPool pool_; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 553 | }; |
| 554 | |
Tony Barbour | de4124d | 2015-07-03 10:33:54 -0600 | [diff] [blame] | 555 | class DynamicViewportState : public internal::NonDispHandle<VkDynamicViewportState> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 556 | public: |
Chia-I Wu | 6b11e60 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 557 | ~DynamicViewportState(); |
| 558 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 559 | // vkCreateDynamicViewportState() |
Tony Barbour | de4124d | 2015-07-03 10:33:54 -0600 | [diff] [blame] | 560 | void init(const Device &dev, const VkDynamicViewportStateCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 561 | }; |
| 562 | |
Cody Northrop | f5bd225 | 2015-08-17 11:10:49 -0600 | [diff] [blame] | 563 | class DynamicRasterLineState : public internal::NonDispHandle<VkDynamicRasterLineState> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 564 | public: |
Cody Northrop | f5bd225 | 2015-08-17 11:10:49 -0600 | [diff] [blame] | 565 | ~DynamicRasterLineState(); |
Chia-I Wu | 6b11e60 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 566 | |
Cody Northrop | f5bd225 | 2015-08-17 11:10:49 -0600 | [diff] [blame] | 567 | // vkCreateDynamicRasterLineState() |
| 568 | void init(const Device &dev, const VkDynamicRasterLineStateCreateInfo &info); |
| 569 | }; |
| 570 | |
| 571 | class DynamicRasterDepthBiasState : public internal::NonDispHandle<VkDynamicRasterDepthBiasState> { |
| 572 | public: |
| 573 | ~DynamicRasterDepthBiasState(); |
| 574 | |
| 575 | // vkCreateDynamicRasterDepthBiasState() |
| 576 | void init(const Device &dev, const VkDynamicRasterDepthBiasStateCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 577 | }; |
| 578 | |
Tony Barbour | de4124d | 2015-07-03 10:33:54 -0600 | [diff] [blame] | 579 | class DynamicColorBlendState : public internal::NonDispHandle<VkDynamicColorBlendState> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 580 | public: |
Chia-I Wu | 6b11e60 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 581 | ~DynamicColorBlendState(); |
| 582 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 583 | // vkCreateDynamicColorBlendState() |
Tony Barbour | de4124d | 2015-07-03 10:33:54 -0600 | [diff] [blame] | 584 | void init(const Device &dev, const VkDynamicColorBlendStateCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 585 | }; |
| 586 | |
Tony Barbour | de4124d | 2015-07-03 10:33:54 -0600 | [diff] [blame] | 587 | class DynamicDepthStencilState : public internal::NonDispHandle<VkDynamicDepthStencilState> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 588 | public: |
Chia-I Wu | 6b11e60 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 589 | ~DynamicDepthStencilState(); |
| 590 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 591 | // vkCreateDynamicDepthStencilState() |
Tony Barbour | de4124d | 2015-07-03 10:33:54 -0600 | [diff] [blame] | 592 | void init(const Device &dev, const VkDynamicDepthStencilStateCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 593 | }; |
| 594 | |
Courtney Goeltzenleuchter | 902d081 | 2015-07-10 19:50:17 -0600 | [diff] [blame] | 595 | class CmdPool : public internal::NonDispHandle<VkCmdPool> { |
| 596 | public: |
| 597 | ~CmdPool(); |
| 598 | |
| 599 | explicit CmdPool() : NonDispHandle() {} |
| 600 | explicit CmdPool(const Device &dev, const VkCmdPoolCreateInfo &info) { init(dev, info); } |
| 601 | |
| 602 | // vkCreateDynamicDepthStencilState() |
| 603 | void init(const Device &dev, const VkCmdPoolCreateInfo &info); |
| 604 | |
| 605 | static VkCmdPoolCreateInfo create_info(uint32_t queue_family_index); |
| 606 | }; |
| 607 | |
| 608 | inline VkCmdPoolCreateInfo CmdPool::create_info(uint32_t queue_family_index) |
| 609 | { |
| 610 | VkCmdPoolCreateInfo info = {}; |
Tony Barbour | 73c22f4 | 2015-07-27 09:36:24 -0600 | [diff] [blame] | 611 | info.sType = VK_STRUCTURE_TYPE_CMD_POOL_CREATE_INFO; |
Courtney Goeltzenleuchter | 902d081 | 2015-07-10 19:50:17 -0600 | [diff] [blame] | 612 | info.queueFamilyIndex = queue_family_index; |
| 613 | return info; |
| 614 | } |
| 615 | |
Chia-I Wu | 78c2a35 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 616 | class CmdBuffer : public internal::Handle<VkCmdBuffer> { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 617 | public: |
Chia-I Wu | 78c2a35 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 618 | ~CmdBuffer(); |
| 619 | |
| 620 | explicit CmdBuffer() : Handle() {} |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 621 | explicit CmdBuffer(const Device &dev, const VkCmdBufferCreateInfo &info) { init(dev, info); } |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 622 | |
| 623 | // vkCreateCommandBuffer() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 624 | void init(const Device &dev, const VkCmdBufferCreateInfo &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 625 | |
| 626 | // vkBeginCommandBuffer() |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 627 | void begin(const VkCmdBufferBeginInfo *info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 628 | void begin(); |
| 629 | |
| 630 | // vkEndCommandBuffer() |
| 631 | // vkResetCommandBuffer() |
| 632 | void end(); |
Cody Northrop | f02f9f8 | 2015-07-09 18:08:05 -0600 | [diff] [blame] | 633 | void reset(VkCmdBufferResetFlags flags); |
| 634 | void reset() { reset(VK_CMD_BUFFER_RESET_RELEASE_RESOURCES); } |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 635 | |
Courtney Goeltzenleuchter | 902d081 | 2015-07-10 19:50:17 -0600 | [diff] [blame] | 636 | static VkCmdBufferCreateInfo create_info(VkCmdPool const &pool); |
Chia-I Wu | 78c2a35 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 637 | |
| 638 | private: |
| 639 | VkDevice dev_handle_; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 640 | }; |
| 641 | |
Chia-I Wu | ba0836f | 2015-07-03 10:58:57 +0800 | [diff] [blame] | 642 | inline VkMemoryAllocInfo DeviceMemory::alloc_info(VkDeviceSize size, uint32_t memory_type_index) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 643 | { |
Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 644 | VkMemoryAllocInfo info = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 645 | info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
Chia-I Wu | ba0836f | 2015-07-03 10:58:57 +0800 | [diff] [blame] | 646 | info.allocationSize = size; |
| 647 | info.memoryTypeIndex = memory_type_index; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 648 | return info; |
| 649 | } |
| 650 | |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 651 | inline VkBufferCreateInfo Buffer::create_info(VkDeviceSize size, VkFlags usage) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 652 | { |
Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 653 | VkBufferCreateInfo info = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 654 | info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 655 | info.size = size; |
| 656 | info.usage = usage; |
| 657 | return info; |
| 658 | } |
| 659 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 660 | inline VkFenceCreateInfo Fence::create_info(VkFenceCreateFlags flags) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 661 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 662 | VkFenceCreateInfo info = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 663 | info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 664 | info.flags = flags; |
| 665 | return info; |
| 666 | } |
| 667 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 668 | inline VkFenceCreateInfo Fence::create_info() |
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 | return info; |
| 673 | } |
| 674 | |
Tony Barbour | 864fd38 | 2015-06-26 12:56:09 -0600 | [diff] [blame] | 675 | inline VkSemaphoreCreateInfo Semaphore::create_info(VkFlags flags) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 676 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 677 | VkSemaphoreCreateInfo info = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 678 | info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 679 | info.flags = flags; |
| 680 | return info; |
| 681 | } |
| 682 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 683 | inline VkEventCreateInfo Event::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 | VkEventCreateInfo info = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 686 | info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 687 | info.flags = flags; |
| 688 | return info; |
| 689 | } |
| 690 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 691 | inline VkQueryPoolCreateInfo QueryPool::create_info(VkQueryType type, uint32_t slot_count) |
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 | VkQueryPoolCreateInfo info = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 694 | info.sType = VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO; |
| 695 | info.queryType = type; |
| 696 | info.slots = slot_count; |
| 697 | return info; |
| 698 | } |
| 699 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 700 | inline VkImageCreateInfo Image::create_info() |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 701 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 702 | VkImageCreateInfo info = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 703 | info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 704 | info.extent.width = 1; |
| 705 | info.extent.height = 1; |
| 706 | info.extent.depth = 1; |
| 707 | info.mipLevels = 1; |
| 708 | info.arraySize = 1; |
| 709 | info.samples = 1; |
| 710 | return info; |
| 711 | } |
| 712 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 713 | 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] | 714 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 715 | VkImageSubresource subres = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 716 | subres.aspect = aspect; |
| 717 | subres.mipLevel = mip_level; |
| 718 | subres.arraySlice = array_slice; |
| 719 | return subres; |
| 720 | } |
| 721 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 722 | 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] | 723 | { |
| 724 | return subresource(range.aspect, range.baseMipLevel + mip_level, range.baseArraySlice + array_slice); |
| 725 | } |
| 726 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 727 | 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] | 728 | uint32_t base_array_slice, uint32_t array_size) |
| 729 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 730 | VkImageSubresourceRange range = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 731 | range.aspect = aspect; |
| 732 | range.baseMipLevel = base_mip_level; |
| 733 | range.mipLevels = mip_levels; |
| 734 | range.baseArraySlice = base_array_slice; |
| 735 | range.arraySize = array_size; |
| 736 | return range; |
| 737 | } |
| 738 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 739 | inline VkImageSubresourceRange Image::subresource_range(const VkImageCreateInfo &info, VkImageAspect aspect) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 740 | { |
| 741 | return subresource_range(aspect, 0, info.mipLevels, 0, info.arraySize); |
| 742 | } |
| 743 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 744 | inline VkImageSubresourceRange Image::subresource_range(const VkImageSubresource &subres) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 745 | { |
| 746 | return subresource_range(subres.aspect, subres.mipLevel, 1, subres.arraySlice, 1); |
| 747 | } |
| 748 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 749 | inline VkExtent2D Image::extent(int32_t width, int32_t height) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 750 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 751 | VkExtent2D extent = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 752 | extent.width = width; |
| 753 | extent.height = height; |
| 754 | return extent; |
| 755 | } |
| 756 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 757 | inline VkExtent2D Image::extent(const VkExtent2D &extent, uint32_t mip_level) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 758 | { |
| 759 | const int32_t width = (extent.width >> mip_level) ? extent.width >> mip_level : 1; |
| 760 | const int32_t height = (extent.height >> mip_level) ? extent.height >> mip_level : 1; |
| 761 | return Image::extent(width, height); |
| 762 | } |
| 763 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 764 | inline VkExtent2D Image::extent(const VkExtent3D &extent) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 765 | { |
| 766 | return Image::extent(extent.width, extent.height); |
| 767 | } |
| 768 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 769 | 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] | 770 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 771 | VkExtent3D extent = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 772 | extent.width = width; |
| 773 | extent.height = height; |
| 774 | extent.depth = depth; |
| 775 | return extent; |
| 776 | } |
| 777 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 778 | inline VkExtent3D Image::extent(const VkExtent3D &extent, uint32_t mip_level) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 779 | { |
| 780 | const int32_t width = (extent.width >> mip_level) ? extent.width >> mip_level : 1; |
| 781 | const int32_t height = (extent.height >> mip_level) ? extent.height >> mip_level : 1; |
| 782 | const int32_t depth = (extent.depth >> mip_level) ? extent.depth >> mip_level : 1; |
| 783 | return Image::extent(width, height, depth); |
| 784 | } |
| 785 | |
Courtney Goeltzenleuchter | 2d034fd | 2015-06-28 13:01:17 -0600 | [diff] [blame] | 786 | inline VkShaderModuleCreateInfo ShaderModule::create_info(size_t code_size, const void *code, VkFlags flags) |
| 787 | { |
| 788 | VkShaderModuleCreateInfo info = {}; |
| 789 | info.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 790 | info.codeSize = code_size; |
| 791 | info.pCode = code; |
| 792 | info.flags = flags; |
| 793 | return info; |
| 794 | } |
| 795 | |
| 796 | inline VkShaderCreateInfo Shader::create_info(VkShaderModule module, const char *pName, VkFlags flags) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 797 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 798 | VkShaderCreateInfo info = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 799 | info.sType = VK_STRUCTURE_TYPE_SHADER_CREATE_INFO; |
Courtney Goeltzenleuchter | 2d034fd | 2015-06-28 13:01:17 -0600 | [diff] [blame] | 800 | info.module = module; |
| 801 | info.pName = pName; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 802 | info.flags = flags; |
| 803 | return info; |
| 804 | } |
| 805 | |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 806 | inline VkWriteDescriptorSet Device::write_descriptor_set(const DescriptorSet &set, uint32_t binding, uint32_t array_element, |
| 807 | VkDescriptorType type, uint32_t count, const VkDescriptorInfo *descriptors) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 808 | { |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 809 | VkWriteDescriptorSet write = {}; |
| 810 | write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 55a871f | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 811 | write.destSet = set.handle(); |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 812 | write.destBinding = binding; |
| 813 | write.destArrayElement = array_element; |
| 814 | write.count = count; |
| 815 | write.descriptorType = type; |
| 816 | write.pDescriptors = descriptors; |
| 817 | return write; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 818 | } |
| 819 | |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 820 | inline VkWriteDescriptorSet Device::write_descriptor_set(const DescriptorSet &set, uint32_t binding, uint32_t array_element, |
| 821 | VkDescriptorType type, const std::vector<VkDescriptorInfo> &descriptors) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 822 | { |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 823 | 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] | 824 | } |
| 825 | |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 826 | inline VkCopyDescriptorSet Device::copy_descriptor_set(const DescriptorSet &src_set, uint32_t src_binding, uint32_t src_array_element, |
| 827 | const DescriptorSet &dst_set, uint32_t dst_binding, uint32_t dst_array_element, |
| 828 | uint32_t count) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 829 | { |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 830 | VkCopyDescriptorSet copy = {}; |
| 831 | copy.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
Chia-I Wu | 55a871f | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 832 | copy.srcSet = src_set.handle(); |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 833 | copy.srcBinding = src_binding; |
| 834 | copy.srcArrayElement = src_array_element; |
Chia-I Wu | 55a871f | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 835 | copy.destSet = dst_set.handle(); |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 836 | copy.destBinding = dst_binding; |
| 837 | copy.destArrayElement = dst_array_element; |
| 838 | copy.count = count; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 839 | |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 840 | return copy; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 841 | } |
| 842 | |
Courtney Goeltzenleuchter | 902d081 | 2015-07-10 19:50:17 -0600 | [diff] [blame] | 843 | inline VkCmdBufferCreateInfo CmdBuffer::create_info(VkCmdPool const &pool) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 844 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 845 | VkCmdBufferCreateInfo info = {}; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 846 | info.sType = VK_STRUCTURE_TYPE_CMD_BUFFER_CREATE_INFO; |
Cody Northrop | f02f9f8 | 2015-07-09 18:08:05 -0600 | [diff] [blame] | 847 | info.cmdPool = pool; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 848 | return info; |
| 849 | } |
| 850 | |
| 851 | }; // namespace vk_testing |
| 852 | |
| 853 | #endif // VKTESTBINDING_H |