Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1 | // VK tests |
| 2 | // |
| 3 | // Copyright (C) 2014 LunarG, Inc. |
| 4 | // |
| 5 | // Permission is hereby granted, free of charge, to any person obtaining a |
| 6 | // copy of this software and associated documentation files (the "Software"), |
| 7 | // to deal in the Software without restriction, including without limitation |
| 8 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 9 | // and/or sell copies of the Software, and to permit persons to whom the |
| 10 | // Software is furnished to do so, subject to the following conditions: |
| 11 | // |
| 12 | // The above copyright notice and this permission notice shall be included |
| 13 | // in all copies or substantial portions of the Software. |
| 14 | // |
| 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 18 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 20 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 21 | // DEALINGS IN THE SOFTWARE. |
| 22 | |
| 23 | #ifndef VKTESTBINDING_H |
| 24 | #define VKTESTBINDING_H |
| 25 | |
| 26 | #include <vector> |
Chia-I Wu | b0ed7d4 | 2015-07-03 10:13:26 +0800 | [diff] [blame] | 27 | #include <assert.h> |
Courtney Goeltzenleuchter | d8e229c | 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 | 999f048 | 2015-07-03 10:32:05 +0800 | [diff] [blame] | 36 | class PhysicalDevice; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 37 | class Device; |
| 38 | class Queue; |
Chia-I Wu | f8f074f | 2015-07-03 10:58:57 +0800 | [diff] [blame] | 39 | class DeviceMemory; |
Courtney Goeltzenleuchter | d8e229c | 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 | 0fadf5f | 2015-04-17 14:11:39 -0500 | [diff] [blame] | 55 | class PipelineLayout; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 56 | class DescriptorSetPool; |
| 57 | class DescriptorSet; |
Chia-I Wu | bc4a554 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 58 | class DynamicViewportState; |
| 59 | class DynamicRasterState; |
| 60 | class DynamicColorBlendState; |
| 61 | class DynamicDepthStencilState; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 62 | class CmdBuffer; |
Courtney Goeltzenleuchter | ee5d80b | 2015-07-10 19:50:17 -0600 | [diff] [blame] | 63 | class CmdPool; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 64 | |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 65 | std::vector<VkLayerProperties> GetGlobalLayers(); |
| 66 | std::vector<VkExtensionProperties> GetGlobalExtensions(); |
| 67 | std::vector<VkExtensionProperties> GetGlobalExtensions(const char *pLayerName); |
| 68 | |
Chia-I Wu | b0ed7d4 | 2015-07-03 10:13:26 +0800 | [diff] [blame] | 69 | namespace internal { |
| 70 | |
| 71 | template<typename T> |
| 72 | class Handle { |
| 73 | public: |
| 74 | const T &handle() const { return handle_; } |
| 75 | bool initialized() const { return (handle_ != VK_NULL_HANDLE); } |
| 76 | |
| 77 | protected: |
| 78 | typedef T handle_type; |
| 79 | |
| 80 | explicit Handle() : handle_(VK_NULL_HANDLE) {} |
| 81 | explicit Handle(T handle) : handle_(handle) {} |
| 82 | |
| 83 | void init(T handle) |
| 84 | { |
| 85 | assert(!initialized()); |
| 86 | handle_ = handle; |
| 87 | } |
| 88 | |
| 89 | private: |
| 90 | // handles are non-copyable |
| 91 | Handle(const Handle &); |
| 92 | Handle &operator=(const Handle &); |
| 93 | |
| 94 | T handle_; |
| 95 | }; |
| 96 | |
| 97 | |
| 98 | template<typename T> |
| 99 | class NonDispHandle : public Handle<T> { |
| 100 | protected: |
| 101 | explicit NonDispHandle() : Handle<T>(), dev_handle_(VK_NULL_HANDLE) {} |
| 102 | explicit NonDispHandle(VkDevice dev, T handle) : Handle<T>(handle), dev_handle_(dev) {} |
| 103 | |
| 104 | const VkDevice &device() const { return dev_handle_; } |
| 105 | |
| 106 | void init(VkDevice dev, T handle) |
| 107 | { |
| 108 | assert(!Handle<T>::initialized() && dev_handle_ == VK_NULL_HANDLE); |
| 109 | Handle<T>::init(handle); |
| 110 | dev_handle_ = dev; |
| 111 | } |
| 112 | |
| 113 | private: |
| 114 | VkDevice dev_handle_; |
| 115 | }; |
| 116 | |
| 117 | } // namespace internal |
| 118 | |
Chia-I Wu | 999f048 | 2015-07-03 10:32:05 +0800 | [diff] [blame] | 119 | class PhysicalDevice : public internal::Handle<VkPhysicalDevice> { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 120 | public: |
Chia-I Wu | 999f048 | 2015-07-03 10:32:05 +0800 | [diff] [blame] | 121 | explicit PhysicalDevice(VkPhysicalDevice phy) : Handle(phy) |
Mark Lobodzinski | b3fbcd9 | 2015-07-02 16:49:40 -0600 | [diff] [blame] | 122 | { |
| 123 | memory_properties_ = memory_properties(); |
| 124 | } |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 125 | |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 126 | VkPhysicalDeviceProperties properties() const; |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 127 | VkPhysicalDeviceMemoryProperties memory_properties() const; |
Cody Northrop | d080288 | 2015-08-03 17:04:53 -0600 | [diff] [blame] | 128 | std::vector<VkQueueFamilyProperties> queue_properties() const; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 129 | |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 130 | VkResult set_memory_type(const uint32_t type_bits, VkMemoryAllocInfo *info, const VkMemoryPropertyFlags properties, |
| 131 | const VkMemoryPropertyFlags forbid = 0) const; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 132 | |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 133 | // vkGetPhysicalDeviceExtensionProperties() |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 134 | std::vector<VkExtensionProperties> extensions() const; |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 135 | std::vector<VkExtensionProperties> extensions(const char * pLayerName) const; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 136 | |
| 137 | // vkEnumerateLayers() |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 138 | std::vector<VkLayerProperties> layers() const; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 139 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 140 | private: |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 141 | void add_extension_dependencies(uint32_t dependency_count, |
| 142 | VkExtensionProperties *depencency_props, |
| 143 | std::vector<VkExtensionProperties> &ext_list); |
Chia-I Wu | 999f048 | 2015-07-03 10:32:05 +0800 | [diff] [blame] | 144 | |
Mark Lobodzinski | b3fbcd9 | 2015-07-02 16:49:40 -0600 | [diff] [blame] | 145 | VkPhysicalDeviceMemoryProperties memory_properties_; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 146 | }; |
| 147 | |
Chia-I Wu | f368b60 | 2015-07-03 10:41:20 +0800 | [diff] [blame] | 148 | class Device : public internal::Handle<VkDevice> { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 149 | public: |
Chia-I Wu | 999f048 | 2015-07-03 10:32:05 +0800 | [diff] [blame] | 150 | explicit Device(VkPhysicalDevice phy) : phy_(phy) {} |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 151 | ~Device(); |
| 152 | |
| 153 | // vkCreateDevice() |
Courtney Goeltzenleuchter | 95487bc | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 154 | void init(const VkDeviceCreateInfo &info); |
Courtney Goeltzenleuchter | 5bac609 | 2015-07-07 11:47:33 -0600 | [diff] [blame] | 155 | void init(std::vector<const char*> &layers, std::vector<const char *> &extensions); // all queues, all extensions, etc |
| 156 | void init() { std::vector<const char *> layers; std::vector<const char *> extensions; init(layers, extensions); }; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 157 | |
Chia-I Wu | 999f048 | 2015-07-03 10:32:05 +0800 | [diff] [blame] | 158 | const PhysicalDevice &phy() const { return phy_; } |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 159 | |
Jon Ashburn | 8d1b0b5 | 2015-05-18 13:20:15 -0600 | [diff] [blame] | 160 | // vkGetDeviceProcAddr() |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 161 | PFN_vkVoidFunction get_proc(const char *name) const { return vkGetDeviceProcAddr(handle(), name); } |
Jon Ashburn | 8d1b0b5 | 2015-05-18 13:20:15 -0600 | [diff] [blame] | 162 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 163 | // vkGetDeviceQueue() |
Mark Lobodzinski | 40f7f40 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 164 | const std::vector<Queue *> &graphics_queues() const { return queues_[GRAPHICS]; } |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 165 | const std::vector<Queue *> &compute_queues() { return queues_[COMPUTE]; } |
| 166 | const std::vector<Queue *> &dma_queues() { return queues_[DMA]; } |
| 167 | uint32_t graphics_queue_node_index_; |
| 168 | |
| 169 | struct Format { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 170 | VkFormat format; |
| 171 | VkImageTiling tiling; |
| 172 | VkFlags features; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 173 | }; |
| 174 | // vkGetFormatInfo() |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 175 | VkFormatProperties format_properties(VkFormat format); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 176 | const std::vector<Format> &formats() const { return formats_; } |
| 177 | |
| 178 | // vkDeviceWaitIdle() |
| 179 | void wait(); |
| 180 | |
| 181 | // vkWaitForFences() |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 182 | VkResult wait(const std::vector<const Fence *> &fences, bool wait_all, uint64_t timeout); |
| 183 | VkResult wait(const Fence &fence) { return wait(std::vector<const Fence *>(1, &fence), true, (uint64_t) -1); } |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 184 | |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 185 | // vkUpdateDescriptorSets() |
| 186 | VkResult update_descriptor_sets(const std::vector<VkWriteDescriptorSet> &writes, const std::vector<VkCopyDescriptorSet> &copies); |
| 187 | VkResult update_descriptor_sets(const std::vector<VkWriteDescriptorSet> &writes) { return update_descriptor_sets(writes, std::vector<VkCopyDescriptorSet>()); } |
| 188 | |
| 189 | static VkWriteDescriptorSet write_descriptor_set(const DescriptorSet &set, uint32_t binding, uint32_t array_element, |
| 190 | VkDescriptorType type, uint32_t count, const VkDescriptorInfo *descriptors); |
| 191 | static VkWriteDescriptorSet write_descriptor_set(const DescriptorSet &set, uint32_t binding, uint32_t array_element, |
| 192 | VkDescriptorType type, const std::vector<VkDescriptorInfo> &descriptors); |
| 193 | |
| 194 | static VkCopyDescriptorSet copy_descriptor_set(const DescriptorSet &src_set, uint32_t src_binding, uint32_t src_array_element, |
| 195 | const DescriptorSet &dst_set, uint32_t dst_binding, uint32_t dst_array_element, |
| 196 | uint32_t count); |
| 197 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 198 | private: |
| 199 | enum QueueIndex { |
| 200 | GRAPHICS, |
| 201 | COMPUTE, |
| 202 | DMA, |
| 203 | QUEUE_COUNT, |
| 204 | }; |
| 205 | |
| 206 | void init_queues(); |
| 207 | void init_formats(); |
| 208 | |
Chia-I Wu | 999f048 | 2015-07-03 10:32:05 +0800 | [diff] [blame] | 209 | PhysicalDevice phy_; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 210 | |
| 211 | std::vector<Queue *> queues_[QUEUE_COUNT]; |
| 212 | std::vector<Format> formats_; |
| 213 | }; |
| 214 | |
Chia-I Wu | df12ffd | 2015-07-03 10:53:18 +0800 | [diff] [blame] | 215 | class Queue : public internal::Handle<VkQueue> { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 216 | public: |
Tony Barbour | fb21ea3 | 2015-07-23 10:35:30 -0600 | [diff] [blame] | 217 | explicit Queue(VkQueue queue, int index) : Handle(queue) {family_index_ = index;} |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 218 | |
| 219 | // vkQueueSubmit() |
| 220 | void submit(const std::vector<const CmdBuffer *> &cmds, Fence &fence); |
| 221 | void submit(const CmdBuffer &cmd, Fence &fence); |
| 222 | void submit(const CmdBuffer &cmd); |
| 223 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 224 | // vkQueueWaitIdle() |
| 225 | void wait(); |
| 226 | |
| 227 | // vkQueueSignalSemaphore() |
| 228 | // vkQueueWaitSemaphore() |
| 229 | void signal_semaphore(Semaphore &sem); |
| 230 | void wait_semaphore(Semaphore &sem); |
Tony Barbour | fb21ea3 | 2015-07-23 10:35:30 -0600 | [diff] [blame] | 231 | |
| 232 | int get_family_index() {return family_index_;} |
| 233 | |
| 234 | private: |
| 235 | int family_index_; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 236 | }; |
| 237 | |
Chia-I Wu | f8f074f | 2015-07-03 10:58:57 +0800 | [diff] [blame] | 238 | class DeviceMemory : public internal::NonDispHandle<VkDeviceMemory> { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 239 | public: |
Chia-I Wu | f8f074f | 2015-07-03 10:58:57 +0800 | [diff] [blame] | 240 | ~DeviceMemory(); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 241 | |
| 242 | // vkAllocMemory() |
Courtney Goeltzenleuchter | 95487bc | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 243 | void init(const Device &dev, const VkMemoryAllocInfo &info); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 244 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 245 | // vkMapMemory() |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 246 | const void *map(VkFlags flags) const; |
| 247 | void *map(VkFlags flags); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 248 | const void *map() const { return map(0); } |
| 249 | void *map() { return map(0); } |
| 250 | |
| 251 | // vkUnmapMemory() |
| 252 | void unmap() const; |
| 253 | |
Chia-I Wu | f8f074f | 2015-07-03 10:58:57 +0800 | [diff] [blame] | 254 | static VkMemoryAllocInfo alloc_info(VkDeviceSize size, uint32_t memory_type_index); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 255 | }; |
| 256 | |
Chia-I Wu | d9e8e82 | 2015-07-03 11:45:55 +0800 | [diff] [blame] | 257 | class Fence : public internal::NonDispHandle<VkFence> { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 258 | public: |
Chia-I Wu | d9e8e82 | 2015-07-03 11:45:55 +0800 | [diff] [blame] | 259 | ~Fence(); |
| 260 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 261 | // vkCreateFence() |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 262 | void init(const Device &dev, const VkFenceCreateInfo &info); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 263 | |
| 264 | // vkGetFenceStatus() |
Chia-I Wu | d9e8e82 | 2015-07-03 11:45:55 +0800 | [diff] [blame] | 265 | VkResult status() const { return vkGetFenceStatus(device(), handle()); } |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 266 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 267 | static VkFenceCreateInfo create_info(VkFenceCreateFlags flags); |
| 268 | static VkFenceCreateInfo create_info(); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 269 | }; |
| 270 | |
Chia-I Wu | 6b1c248 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 271 | class Semaphore : public internal::NonDispHandle<VkSemaphore> { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 272 | public: |
Chia-I Wu | 6b1c248 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 273 | ~Semaphore(); |
| 274 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 275 | // vkCreateSemaphore() |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 276 | void init(const Device &dev, const VkSemaphoreCreateInfo &info); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 277 | |
Tony Barbour | af892a1 | 2015-06-26 12:56:09 -0600 | [diff] [blame] | 278 | static VkSemaphoreCreateInfo create_info(VkFlags flags); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 279 | }; |
| 280 | |
Chia-I Wu | c5c9799 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 281 | class Event : public internal::NonDispHandle<VkEvent> { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 282 | public: |
Chia-I Wu | c5c9799 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 283 | ~Event(); |
| 284 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 285 | // vkCreateEvent() |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 286 | void init(const Device &dev, const VkEventCreateInfo &info); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 287 | |
| 288 | // vkGetEventStatus() |
| 289 | // vkSetEvent() |
| 290 | // vkResetEvent() |
Chia-I Wu | c5c9799 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 291 | VkResult status() const { return vkGetEventStatus(device(), handle()); } |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 292 | void set(); |
| 293 | void reset(); |
| 294 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 295 | static VkEventCreateInfo create_info(VkFlags flags); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 296 | }; |
| 297 | |
Chia-I Wu | 1b7d476 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 298 | class QueryPool : public internal::NonDispHandle<VkQueryPool> { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 299 | public: |
Chia-I Wu | 1b7d476 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 300 | ~QueryPool(); |
| 301 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 302 | // vkCreateQueryPool() |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 303 | void init(const Device &dev, const VkQueryPoolCreateInfo &info); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 304 | |
| 305 | // vkGetQueryPoolResults() |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 306 | VkResult results(uint32_t start, uint32_t count, size_t size, void *data); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 307 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 308 | static VkQueryPoolCreateInfo create_info(VkQueryType type, uint32_t slot_count); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 309 | }; |
| 310 | |
Chia-I Wu | 681d7a0 | 2015-07-03 13:44:34 +0800 | [diff] [blame] | 311 | class Buffer : public internal::NonDispHandle<VkBuffer> { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 312 | public: |
Chia-I Wu | 681d7a0 | 2015-07-03 13:44:34 +0800 | [diff] [blame] | 313 | explicit Buffer() : NonDispHandle() {} |
Courtney Goeltzenleuchter | 95487bc | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 314 | explicit Buffer(const Device &dev, const VkBufferCreateInfo &info) { init(dev, info); } |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 315 | explicit Buffer(const Device &dev, VkDeviceSize size) { init(dev, size); } |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 316 | |
Chia-I Wu | 681d7a0 | 2015-07-03 13:44:34 +0800 | [diff] [blame] | 317 | ~Buffer(); |
| 318 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 319 | // vkCreateBuffer() |
Chia-I Wu | 681d7a0 | 2015-07-03 13:44:34 +0800 | [diff] [blame] | 320 | void init(const Device &dev, const VkBufferCreateInfo &info, VkMemoryPropertyFlags mem_props); |
| 321 | void init(const Device &dev, const VkBufferCreateInfo &info) { init(dev, info, 0); } |
| 322 | void init(const Device &dev, VkDeviceSize size, VkMemoryPropertyFlags mem_props) { init(dev, create_info(size, 0), mem_props); } |
| 323 | void init(const Device &dev, VkDeviceSize size) { init(dev, size, 0); } |
Cody Northrop | 7fb4386 | 2015-06-22 14:56:14 -0600 | [diff] [blame] | 324 | void init_as_src(const Device &dev, VkDeviceSize size, VkMemoryPropertyFlags &reqs) { init(dev, create_info(size, VK_BUFFER_USAGE_TRANSFER_SOURCE_BIT), reqs); } |
| 325 | void init_as_dst(const Device &dev, VkDeviceSize size, VkMemoryPropertyFlags &reqs) { init(dev, create_info(size, VK_BUFFER_USAGE_TRANSFER_DESTINATION_BIT), reqs); } |
| 326 | 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 | 95487bc | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 327 | void init_no_mem(const Device &dev, const VkBufferCreateInfo &info); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 328 | |
Chia-I Wu | 681d7a0 | 2015-07-03 13:44:34 +0800 | [diff] [blame] | 329 | // get the internal memory |
| 330 | const DeviceMemory &memory() const { return internal_mem_; } |
| 331 | DeviceMemory &memory() { return internal_mem_; } |
| 332 | |
| 333 | // vkGetObjectMemoryRequirements() |
| 334 | VkMemoryRequirements memory_requirements() const; |
| 335 | |
| 336 | // vkBindObjectMemory() |
| 337 | void bind_memory(const DeviceMemory &mem, VkDeviceSize mem_offset); |
Mark Lobodzinski | 942b172 | 2015-05-11 17:21:15 -0500 | [diff] [blame] | 338 | |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 339 | static VkBufferCreateInfo create_info(VkDeviceSize size, VkFlags usage); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 340 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 341 | VkBufferMemoryBarrier buffer_memory_barrier(VkFlags output_mask, VkFlags input_mask, |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 342 | VkDeviceSize offset, VkDeviceSize size) const |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 343 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 344 | VkBufferMemoryBarrier barrier = {}; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 345 | barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
Chia-I Wu | 681d7a0 | 2015-07-03 13:44:34 +0800 | [diff] [blame] | 346 | barrier.buffer = handle(); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 347 | barrier.outputMask = output_mask; |
| 348 | barrier.inputMask = input_mask; |
| 349 | barrier.offset = offset; |
| 350 | barrier.size = size; |
| 351 | return barrier; |
| 352 | } |
Chia-I Wu | 681d7a0 | 2015-07-03 13:44:34 +0800 | [diff] [blame] | 353 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 354 | private: |
Courtney Goeltzenleuchter | 95487bc | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 355 | VkBufferCreateInfo create_info_; |
Chia-I Wu | 681d7a0 | 2015-07-03 13:44:34 +0800 | [diff] [blame] | 356 | |
| 357 | DeviceMemory internal_mem_; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 358 | }; |
| 359 | |
Chia-I Wu | 3158bf3 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 360 | class BufferView : public internal::NonDispHandle<VkBufferView> { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 361 | public: |
Chia-I Wu | 3158bf3 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 362 | ~BufferView(); |
| 363 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 364 | // vkCreateBufferView() |
Courtney Goeltzenleuchter | 95487bc | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 365 | void init(const Device &dev, const VkBufferViewCreateInfo &info); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 366 | }; |
| 367 | |
Chia-I Wu | 681d7a0 | 2015-07-03 13:44:34 +0800 | [diff] [blame] | 368 | class Image : public internal::NonDispHandle<VkImage> { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 369 | public: |
Chia-I Wu | 681d7a0 | 2015-07-03 13:44:34 +0800 | [diff] [blame] | 370 | explicit Image() : NonDispHandle(), format_features_(0) {} |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 371 | explicit Image(const Device &dev, const VkImageCreateInfo &info) : format_features_(0) { init(dev, info); } |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 372 | |
Chia-I Wu | 681d7a0 | 2015-07-03 13:44:34 +0800 | [diff] [blame] | 373 | ~Image(); |
| 374 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 375 | // vkCreateImage() |
Chia-I Wu | 681d7a0 | 2015-07-03 13:44:34 +0800 | [diff] [blame] | 376 | void init(const Device &dev, const VkImageCreateInfo &info, VkMemoryPropertyFlags mem_props); |
| 377 | void init(const Device &dev, const VkImageCreateInfo &info) { init(dev, info, 0); } |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 378 | void init_no_mem(const Device &dev, const VkImageCreateInfo &info); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 379 | |
Chia-I Wu | 681d7a0 | 2015-07-03 13:44:34 +0800 | [diff] [blame] | 380 | // get the internal memory |
| 381 | const DeviceMemory &memory() const { return internal_mem_; } |
| 382 | DeviceMemory &memory() { return internal_mem_; } |
| 383 | |
| 384 | // vkGetObjectMemoryRequirements() |
| 385 | VkMemoryRequirements memory_requirements() const; |
| 386 | |
| 387 | // vkBindObjectMemory() |
| 388 | void bind_memory(const DeviceMemory &mem, VkDeviceSize mem_offset); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 389 | |
Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 390 | // vkGetImageSubresourceLayout() |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 391 | VkSubresourceLayout subresource_layout(const VkImageSubresource &subres) const; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 392 | |
| 393 | bool transparent() const; |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 394 | bool copyable() const { return (format_features_ & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT); } |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 395 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 396 | VkImageSubresourceRange subresource_range(VkImageAspect aspect) const { return subresource_range(create_info_, aspect); } |
| 397 | VkExtent3D extent() const { return create_info_.extent; } |
| 398 | VkExtent3D extent(uint32_t mip_level) const { return extent(create_info_.extent, mip_level); } |
| 399 | VkFormat format() const {return create_info_.format;} |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 400 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 401 | VkImageMemoryBarrier image_memory_barrier(VkFlags output_mask, VkFlags input_mask, |
| 402 | VkImageLayout old_layout, |
| 403 | VkImageLayout new_layout, |
| 404 | const VkImageSubresourceRange &range) const |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 405 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 406 | VkImageMemoryBarrier barrier = {}; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 407 | barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| 408 | barrier.outputMask = output_mask; |
| 409 | barrier.inputMask = input_mask; |
| 410 | barrier.oldLayout = old_layout; |
| 411 | barrier.newLayout = new_layout; |
Chia-I Wu | 681d7a0 | 2015-07-03 13:44:34 +0800 | [diff] [blame] | 412 | barrier.image = handle(); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 413 | barrier.subresourceRange = range; |
| 414 | return barrier; |
| 415 | } |
| 416 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 417 | static VkImageCreateInfo create_info(); |
| 418 | static VkImageSubresource subresource(VkImageAspect aspect, uint32_t mip_level, uint32_t array_slice); |
| 419 | static VkImageSubresource subresource(const VkImageSubresourceRange &range, uint32_t mip_level, uint32_t array_slice); |
| 420 | static VkImageSubresourceRange subresource_range(VkImageAspect aspect, uint32_t base_mip_level, uint32_t mip_levels, |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 421 | uint32_t base_array_slice, uint32_t array_size); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 422 | static VkImageSubresourceRange subresource_range(const VkImageCreateInfo &info, VkImageAspect aspect); |
| 423 | static VkImageSubresourceRange subresource_range(const VkImageSubresource &subres); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 424 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 425 | static VkExtent2D extent(int32_t width, int32_t height); |
| 426 | static VkExtent2D extent(const VkExtent2D &extent, uint32_t mip_level); |
| 427 | static VkExtent2D extent(const VkExtent3D &extent); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 428 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 429 | static VkExtent3D extent(int32_t width, int32_t height, int32_t depth); |
| 430 | static VkExtent3D extent(const VkExtent3D &extent, uint32_t mip_level); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 431 | |
| 432 | private: |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 433 | void init_info(const Device &dev, const VkImageCreateInfo &info); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 434 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 435 | VkImageCreateInfo create_info_; |
| 436 | VkFlags format_features_; |
Chia-I Wu | 681d7a0 | 2015-07-03 13:44:34 +0800 | [diff] [blame] | 437 | |
| 438 | DeviceMemory internal_mem_; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 439 | }; |
| 440 | |
Chia-I Wu | 3158bf3 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 441 | class ImageView : public internal::NonDispHandle<VkImageView> { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 442 | public: |
Chia-I Wu | 3158bf3 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 443 | ~ImageView(); |
| 444 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 445 | // vkCreateImageView() |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 446 | void init(const Device &dev, const VkImageViewCreateInfo &info); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 447 | }; |
| 448 | |
Chia-I Wu | 3158bf3 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 449 | //class AttachmentView : public DerivedObject<VkAttachmentView, Object, VK_OBJECT_TYPE_ATTACHMENT_VIEW> { |
| 450 | class AttachmentView : public internal::NonDispHandle<VkAttachmentView> { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 451 | public: |
Chia-I Wu | 3158bf3 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 452 | ~AttachmentView(); |
| 453 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 454 | // vkCreateAttachmentView() |
| 455 | void init(const Device &dev, const VkAttachmentViewCreateInfo &info); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 456 | }; |
| 457 | |
Chia-I Wu | 4d0c792 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 458 | class ShaderModule : public internal::NonDispHandle<VkShaderModule> { |
Courtney Goeltzenleuchter | ee4027d | 2015-06-28 13:01:17 -0600 | [diff] [blame] | 459 | public: |
Chia-I Wu | 4d0c792 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 460 | ~ShaderModule(); |
| 461 | |
Courtney Goeltzenleuchter | ee4027d | 2015-06-28 13:01:17 -0600 | [diff] [blame] | 462 | // vkCreateShaderModule() |
| 463 | void init(const Device &dev, const VkShaderModuleCreateInfo &info); |
| 464 | VkResult init_try(const Device &dev, const VkShaderModuleCreateInfo &info); |
| 465 | |
| 466 | static VkShaderModuleCreateInfo create_info(size_t code_size, const void *code, VkFlags flags); |
| 467 | }; |
| 468 | |
Chia-I Wu | 4d0c792 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 469 | class Shader : public internal::NonDispHandle<VkShader> { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 470 | public: |
Chia-I Wu | 4d0c792 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 471 | ~Shader(); |
| 472 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 473 | // vkCreateShader() |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 474 | void init(const Device &dev, const VkShaderCreateInfo &info); |
| 475 | VkResult init_try(const Device &dev, const VkShaderCreateInfo &info); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 476 | |
Courtney Goeltzenleuchter | ee4027d | 2015-06-28 13:01:17 -0600 | [diff] [blame] | 477 | static VkShaderCreateInfo create_info(VkShaderModule module, const char *pName, VkFlags flags); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 478 | }; |
| 479 | |
Chia-I Wu | 2ff72fd | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 480 | class Pipeline : public internal::NonDispHandle<VkPipeline> { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 481 | public: |
Chia-I Wu | 2ff72fd | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 482 | ~Pipeline(); |
| 483 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 484 | // vkCreateGraphicsPipeline() |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 485 | void init(const Device &dev, const VkGraphicsPipelineCreateInfo &info); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 486 | // vkCreateGraphicsPipelineDerivative() |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 487 | void init(const Device &dev, const VkGraphicsPipelineCreateInfo &info, const VkPipeline basePipeline); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 488 | // vkCreateComputePipeline() |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 489 | void init(const Device &dev, const VkComputePipelineCreateInfo &info); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 490 | // vkLoadPipeline() |
| 491 | void init(const Device&dev, size_t size, const void *data); |
| 492 | // vkLoadPipelineDerivative() |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 493 | void init(const Device&dev, size_t size, const void *data, VkPipeline basePipeline); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 494 | |
Chris Forbes | 95292b1 | 2015-05-25 11:13:26 +1200 | [diff] [blame] | 495 | // vkCreateGraphicsPipeline with error return |
| 496 | VkResult init_try(const Device &dev, const VkGraphicsPipelineCreateInfo &info); |
| 497 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 498 | // vkStorePipeline() |
| 499 | size_t store(size_t size, void *data); |
| 500 | }; |
| 501 | |
Chia-I Wu | fd46e7d | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 502 | class PipelineLayout : public internal::NonDispHandle<VkPipelineLayout> { |
| 503 | public: |
| 504 | ~PipelineLayout(); |
| 505 | |
| 506 | // vCreatePipelineLayout() |
| 507 | void init(const Device &dev, VkPipelineLayoutCreateInfo &info, const std::vector<const DescriptorSetLayout *> &layouts); |
| 508 | }; |
| 509 | |
Chia-I Wu | 8c721c6 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 510 | class Sampler : public internal::NonDispHandle<VkSampler> { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 511 | public: |
Chia-I Wu | 8c721c6 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 512 | ~Sampler(); |
| 513 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 514 | // vkCreateSampler() |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 515 | void init(const Device &dev, const VkSamplerCreateInfo &info); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 516 | }; |
| 517 | |
Chia-I Wu | afdfd7f | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 518 | class DescriptorSetLayout : public internal::NonDispHandle<VkDescriptorSetLayout> { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 519 | public: |
Chia-I Wu | afdfd7f | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 520 | ~DescriptorSetLayout(); |
| 521 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 522 | // vkCreateDescriptorSetLayout() |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 523 | void init(const Device &dev, const VkDescriptorSetLayoutCreateInfo &info); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 524 | }; |
| 525 | |
Chia-I Wu | afdfd7f | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 526 | class DescriptorPool : public internal::NonDispHandle<VkDescriptorPool> { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 527 | public: |
Chia-I Wu | afdfd7f | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 528 | ~DescriptorPool(); |
| 529 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 530 | // vkCreateDescriptorPool() |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 531 | void init(const Device &dev, VkDescriptorPoolUsage usage, |
| 532 | uint32_t max_sets, const VkDescriptorPoolCreateInfo &info); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 533 | |
| 534 | // vkResetDescriptorPool() |
| 535 | void reset(); |
| 536 | |
| 537 | // vkAllocDescriptorSets() |
Mark Lobodzinski | 40f7f40 | 2015-04-16 11:44:05 -0500 | [diff] [blame] | 538 | std::vector<DescriptorSet *> alloc_sets(const Device &dev, VkDescriptorSetUsage usage, const std::vector<const DescriptorSetLayout *> &layouts); |
| 539 | std::vector<DescriptorSet *> alloc_sets(const Device &dev, VkDescriptorSetUsage usage, const DescriptorSetLayout &layout, uint32_t count); |
| 540 | DescriptorSet *alloc_sets(const Device &dev, VkDescriptorSetUsage usage, const DescriptorSetLayout &layout); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 541 | }; |
| 542 | |
Chia-I Wu | afdfd7f | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 543 | class DescriptorSet : public internal::NonDispHandle<VkDescriptorSet> { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 544 | public: |
Chia-I Wu | afdfd7f | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 545 | ~DescriptorSet(); |
| 546 | |
| 547 | explicit DescriptorSet() : NonDispHandle() {} |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 548 | explicit DescriptorSet(const Device &dev, VkDescriptorPool pool, VkDescriptorSet set) : NonDispHandle(dev.handle(), set) { pool_ = pool;} |
| 549 | |
| 550 | private: |
| 551 | VkDescriptorPool pool_; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 552 | }; |
| 553 | |
Tony Barbour | 1d2cd3f | 2015-07-03 10:33:54 -0600 | [diff] [blame] | 554 | class DynamicViewportState : public internal::NonDispHandle<VkDynamicViewportState> { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 555 | public: |
Chia-I Wu | bc4a554 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 556 | ~DynamicViewportState(); |
| 557 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 558 | // vkCreateDynamicViewportState() |
Tony Barbour | 1d2cd3f | 2015-07-03 10:33:54 -0600 | [diff] [blame] | 559 | void init(const Device &dev, const VkDynamicViewportStateCreateInfo &info); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 560 | }; |
| 561 | |
Tony Barbour | 1d2cd3f | 2015-07-03 10:33:54 -0600 | [diff] [blame] | 562 | class DynamicRasterState : public internal::NonDispHandle<VkDynamicRasterState> { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 563 | public: |
Chia-I Wu | bc4a554 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 564 | ~DynamicRasterState(); |
| 565 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 566 | // vkCreateDynamicRasterState() |
Tony Barbour | 1d2cd3f | 2015-07-03 10:33:54 -0600 | [diff] [blame] | 567 | void init(const Device &dev, const VkDynamicRasterStateCreateInfo &info); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 568 | }; |
| 569 | |
Tony Barbour | 1d2cd3f | 2015-07-03 10:33:54 -0600 | [diff] [blame] | 570 | class DynamicColorBlendState : public internal::NonDispHandle<VkDynamicColorBlendState> { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 571 | public: |
Chia-I Wu | bc4a554 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 572 | ~DynamicColorBlendState(); |
| 573 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 574 | // vkCreateDynamicColorBlendState() |
Tony Barbour | 1d2cd3f | 2015-07-03 10:33:54 -0600 | [diff] [blame] | 575 | void init(const Device &dev, const VkDynamicColorBlendStateCreateInfo &info); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 576 | }; |
| 577 | |
Tony Barbour | 1d2cd3f | 2015-07-03 10:33:54 -0600 | [diff] [blame] | 578 | class DynamicDepthStencilState : public internal::NonDispHandle<VkDynamicDepthStencilState> { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 579 | public: |
Chia-I Wu | bc4a554 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 580 | ~DynamicDepthStencilState(); |
| 581 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 582 | // vkCreateDynamicDepthStencilState() |
Tony Barbour | 1d2cd3f | 2015-07-03 10:33:54 -0600 | [diff] [blame] | 583 | void init(const Device &dev, const VkDynamicDepthStencilStateCreateInfo &info); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 584 | }; |
| 585 | |
Courtney Goeltzenleuchter | ee5d80b | 2015-07-10 19:50:17 -0600 | [diff] [blame] | 586 | class CmdPool : public internal::NonDispHandle<VkCmdPool> { |
| 587 | public: |
| 588 | ~CmdPool(); |
| 589 | |
| 590 | explicit CmdPool() : NonDispHandle() {} |
| 591 | explicit CmdPool(const Device &dev, const VkCmdPoolCreateInfo &info) { init(dev, info); } |
| 592 | |
| 593 | // vkCreateDynamicDepthStencilState() |
| 594 | void init(const Device &dev, const VkCmdPoolCreateInfo &info); |
| 595 | |
| 596 | static VkCmdPoolCreateInfo create_info(uint32_t queue_family_index); |
| 597 | }; |
| 598 | |
| 599 | inline VkCmdPoolCreateInfo CmdPool::create_info(uint32_t queue_family_index) |
| 600 | { |
| 601 | VkCmdPoolCreateInfo info = {}; |
Tony Barbour | e815fd7 | 2015-07-27 09:36:24 -0600 | [diff] [blame] | 602 | info.sType = VK_STRUCTURE_TYPE_CMD_POOL_CREATE_INFO; |
Courtney Goeltzenleuchter | ee5d80b | 2015-07-10 19:50:17 -0600 | [diff] [blame] | 603 | info.queueFamilyIndex = queue_family_index; |
| 604 | return info; |
| 605 | } |
| 606 | |
Chia-I Wu | be2b917 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 607 | class CmdBuffer : public internal::Handle<VkCmdBuffer> { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 608 | public: |
Chia-I Wu | be2b917 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 609 | ~CmdBuffer(); |
| 610 | |
| 611 | explicit CmdBuffer() : Handle() {} |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 612 | explicit CmdBuffer(const Device &dev, const VkCmdBufferCreateInfo &info) { init(dev, info); } |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 613 | |
| 614 | // vkCreateCommandBuffer() |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 615 | void init(const Device &dev, const VkCmdBufferCreateInfo &info); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 616 | |
| 617 | // vkBeginCommandBuffer() |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 618 | void begin(const VkCmdBufferBeginInfo *info); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 619 | void begin(); |
| 620 | |
| 621 | // vkEndCommandBuffer() |
| 622 | // vkResetCommandBuffer() |
| 623 | void end(); |
Cody Northrop | e62183e | 2015-07-09 18:08:05 -0600 | [diff] [blame] | 624 | void reset(VkCmdBufferResetFlags flags); |
| 625 | void reset() { reset(VK_CMD_BUFFER_RESET_RELEASE_RESOURCES); } |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 626 | |
Courtney Goeltzenleuchter | ee5d80b | 2015-07-10 19:50:17 -0600 | [diff] [blame] | 627 | static VkCmdBufferCreateInfo create_info(VkCmdPool const &pool); |
Chia-I Wu | be2b917 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 628 | |
| 629 | private: |
| 630 | VkDevice dev_handle_; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 631 | }; |
| 632 | |
Chia-I Wu | f8f074f | 2015-07-03 10:58:57 +0800 | [diff] [blame] | 633 | inline VkMemoryAllocInfo DeviceMemory::alloc_info(VkDeviceSize size, uint32_t memory_type_index) |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 634 | { |
Courtney Goeltzenleuchter | 95487bc | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 635 | VkMemoryAllocInfo info = {}; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 636 | info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
Chia-I Wu | f8f074f | 2015-07-03 10:58:57 +0800 | [diff] [blame] | 637 | info.allocationSize = size; |
| 638 | info.memoryTypeIndex = memory_type_index; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 639 | return info; |
| 640 | } |
| 641 | |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 642 | inline VkBufferCreateInfo Buffer::create_info(VkDeviceSize size, VkFlags usage) |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 643 | { |
Courtney Goeltzenleuchter | 95487bc | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 644 | VkBufferCreateInfo info = {}; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 645 | info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 646 | info.size = size; |
| 647 | info.usage = usage; |
| 648 | return info; |
| 649 | } |
| 650 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 651 | inline VkFenceCreateInfo Fence::create_info(VkFenceCreateFlags flags) |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 652 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 653 | VkFenceCreateInfo info = {}; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 654 | info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 655 | info.flags = flags; |
| 656 | return info; |
| 657 | } |
| 658 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 659 | inline VkFenceCreateInfo Fence::create_info() |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 660 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 661 | VkFenceCreateInfo info = {}; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 662 | info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 663 | return info; |
| 664 | } |
| 665 | |
Tony Barbour | af892a1 | 2015-06-26 12:56:09 -0600 | [diff] [blame] | 666 | inline VkSemaphoreCreateInfo Semaphore::create_info(VkFlags flags) |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 667 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 668 | VkSemaphoreCreateInfo info = {}; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 669 | info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 670 | info.flags = flags; |
| 671 | return info; |
| 672 | } |
| 673 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 674 | inline VkEventCreateInfo Event::create_info(VkFlags flags) |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 675 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 676 | VkEventCreateInfo info = {}; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 677 | info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 678 | info.flags = flags; |
| 679 | return info; |
| 680 | } |
| 681 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 682 | inline VkQueryPoolCreateInfo QueryPool::create_info(VkQueryType type, uint32_t slot_count) |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 683 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 684 | VkQueryPoolCreateInfo info = {}; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 685 | info.sType = VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO; |
| 686 | info.queryType = type; |
| 687 | info.slots = slot_count; |
| 688 | return info; |
| 689 | } |
| 690 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 691 | inline VkImageCreateInfo Image::create_info() |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 692 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 693 | VkImageCreateInfo info = {}; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 694 | info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 695 | info.extent.width = 1; |
| 696 | info.extent.height = 1; |
| 697 | info.extent.depth = 1; |
| 698 | info.mipLevels = 1; |
| 699 | info.arraySize = 1; |
| 700 | info.samples = 1; |
| 701 | return info; |
| 702 | } |
| 703 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 704 | inline VkImageSubresource Image::subresource(VkImageAspect aspect, uint32_t mip_level, uint32_t array_slice) |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 705 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 706 | VkImageSubresource subres = {}; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 707 | subres.aspect = aspect; |
| 708 | subres.mipLevel = mip_level; |
| 709 | subres.arraySlice = array_slice; |
| 710 | return subres; |
| 711 | } |
| 712 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 713 | inline VkImageSubresource Image::subresource(const VkImageSubresourceRange &range, uint32_t mip_level, uint32_t array_slice) |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 714 | { |
| 715 | return subresource(range.aspect, range.baseMipLevel + mip_level, range.baseArraySlice + array_slice); |
| 716 | } |
| 717 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 718 | inline VkImageSubresourceRange Image::subresource_range(VkImageAspect aspect, uint32_t base_mip_level, uint32_t mip_levels, |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 719 | uint32_t base_array_slice, uint32_t array_size) |
| 720 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 721 | VkImageSubresourceRange range = {}; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 722 | range.aspect = aspect; |
| 723 | range.baseMipLevel = base_mip_level; |
| 724 | range.mipLevels = mip_levels; |
| 725 | range.baseArraySlice = base_array_slice; |
| 726 | range.arraySize = array_size; |
| 727 | return range; |
| 728 | } |
| 729 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 730 | inline VkImageSubresourceRange Image::subresource_range(const VkImageCreateInfo &info, VkImageAspect aspect) |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 731 | { |
| 732 | return subresource_range(aspect, 0, info.mipLevels, 0, info.arraySize); |
| 733 | } |
| 734 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 735 | inline VkImageSubresourceRange Image::subresource_range(const VkImageSubresource &subres) |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 736 | { |
| 737 | return subresource_range(subres.aspect, subres.mipLevel, 1, subres.arraySlice, 1); |
| 738 | } |
| 739 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 740 | inline VkExtent2D Image::extent(int32_t width, int32_t height) |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 741 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 742 | VkExtent2D extent = {}; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 743 | extent.width = width; |
| 744 | extent.height = height; |
| 745 | return extent; |
| 746 | } |
| 747 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 748 | inline VkExtent2D Image::extent(const VkExtent2D &extent, uint32_t mip_level) |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 749 | { |
| 750 | const int32_t width = (extent.width >> mip_level) ? extent.width >> mip_level : 1; |
| 751 | const int32_t height = (extent.height >> mip_level) ? extent.height >> mip_level : 1; |
| 752 | return Image::extent(width, height); |
| 753 | } |
| 754 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 755 | inline VkExtent2D Image::extent(const VkExtent3D &extent) |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 756 | { |
| 757 | return Image::extent(extent.width, extent.height); |
| 758 | } |
| 759 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 760 | inline VkExtent3D Image::extent(int32_t width, int32_t height, int32_t depth) |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 761 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 762 | VkExtent3D extent = {}; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 763 | extent.width = width; |
| 764 | extent.height = height; |
| 765 | extent.depth = depth; |
| 766 | return extent; |
| 767 | } |
| 768 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 769 | inline VkExtent3D Image::extent(const VkExtent3D &extent, uint32_t mip_level) |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 770 | { |
| 771 | const int32_t width = (extent.width >> mip_level) ? extent.width >> mip_level : 1; |
| 772 | const int32_t height = (extent.height >> mip_level) ? extent.height >> mip_level : 1; |
| 773 | const int32_t depth = (extent.depth >> mip_level) ? extent.depth >> mip_level : 1; |
| 774 | return Image::extent(width, height, depth); |
| 775 | } |
| 776 | |
Courtney Goeltzenleuchter | ee4027d | 2015-06-28 13:01:17 -0600 | [diff] [blame] | 777 | inline VkShaderModuleCreateInfo ShaderModule::create_info(size_t code_size, const void *code, VkFlags flags) |
| 778 | { |
| 779 | VkShaderModuleCreateInfo info = {}; |
| 780 | info.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 781 | info.codeSize = code_size; |
| 782 | info.pCode = code; |
| 783 | info.flags = flags; |
| 784 | return info; |
| 785 | } |
| 786 | |
| 787 | inline VkShaderCreateInfo Shader::create_info(VkShaderModule module, const char *pName, VkFlags flags) |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 788 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 789 | VkShaderCreateInfo info = {}; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 790 | info.sType = VK_STRUCTURE_TYPE_SHADER_CREATE_INFO; |
Courtney Goeltzenleuchter | ee4027d | 2015-06-28 13:01:17 -0600 | [diff] [blame] | 791 | info.module = module; |
| 792 | info.pName = pName; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 793 | info.flags = flags; |
| 794 | return info; |
| 795 | } |
| 796 | |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 797 | inline VkWriteDescriptorSet Device::write_descriptor_set(const DescriptorSet &set, uint32_t binding, uint32_t array_element, |
| 798 | VkDescriptorType type, uint32_t count, const VkDescriptorInfo *descriptors) |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 799 | { |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 800 | VkWriteDescriptorSet write = {}; |
| 801 | write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | afdfd7f | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 802 | write.destSet = set.handle(); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 803 | write.destBinding = binding; |
| 804 | write.destArrayElement = array_element; |
| 805 | write.count = count; |
| 806 | write.descriptorType = type; |
| 807 | write.pDescriptors = descriptors; |
| 808 | return write; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 809 | } |
| 810 | |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 811 | inline VkWriteDescriptorSet Device::write_descriptor_set(const DescriptorSet &set, uint32_t binding, uint32_t array_element, |
| 812 | VkDescriptorType type, const std::vector<VkDescriptorInfo> &descriptors) |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 813 | { |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 814 | return write_descriptor_set(set, binding, array_element, type, descriptors.size(), &descriptors[0]); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 815 | } |
| 816 | |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 817 | inline VkCopyDescriptorSet Device::copy_descriptor_set(const DescriptorSet &src_set, uint32_t src_binding, uint32_t src_array_element, |
| 818 | const DescriptorSet &dst_set, uint32_t dst_binding, uint32_t dst_array_element, |
| 819 | uint32_t count) |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 820 | { |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 821 | VkCopyDescriptorSet copy = {}; |
| 822 | copy.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
Chia-I Wu | afdfd7f | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 823 | copy.srcSet = src_set.handle(); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 824 | copy.srcBinding = src_binding; |
| 825 | copy.srcArrayElement = src_array_element; |
Chia-I Wu | afdfd7f | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 826 | copy.destSet = dst_set.handle(); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 827 | copy.destBinding = dst_binding; |
| 828 | copy.destArrayElement = dst_array_element; |
| 829 | copy.count = count; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 830 | |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 831 | return copy; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 832 | } |
| 833 | |
Courtney Goeltzenleuchter | ee5d80b | 2015-07-10 19:50:17 -0600 | [diff] [blame] | 834 | inline VkCmdBufferCreateInfo CmdBuffer::create_info(VkCmdPool const &pool) |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 835 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 836 | VkCmdBufferCreateInfo info = {}; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 837 | info.sType = VK_STRUCTURE_TYPE_CMD_BUFFER_CREATE_INFO; |
Cody Northrop | e62183e | 2015-07-09 18:08:05 -0600 | [diff] [blame] | 838 | info.cmdPool = pool; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 839 | return info; |
| 840 | } |
| 841 | |
| 842 | }; // namespace vk_testing |
| 843 | |
| 844 | #endif // VKTESTBINDING_H |