| Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015-2016 The Khronos Group Inc. |
| 3 | * Copyright (c) 2015-2016 Valve Corporation |
| 4 | * Copyright (c) 2015-2016 LunarG, Inc. |
| 5 | * |
| Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | * you may not use this file except in compliance with the License. |
| 8 | * You may obtain a copy of the License at |
| Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9 | * |
| Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11 | * |
| Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 12 | * Unless required by applicable law or agreed to in writing, software |
| 13 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | * See the License for the specific language governing permissions and |
| 16 | * limitations under the License. |
| Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 17 | * |
| 18 | * Author: Courtney Goeltzenleuchter <courtney@LunarG.com> |
| 19 | * Author: Cody Northrop <cody@lunarg.com> |
| 20 | */ |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 21 | |
| 22 | #ifndef VKTESTBINDING_H |
| 23 | #define VKTESTBINDING_H |
| 24 | |
| Chia-I Wu | b0ed7d4 | 2015-07-03 10:13:26 +0800 | [diff] [blame] | 25 | #include <assert.h> |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 26 | #include <vector> |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 27 | |
| David Pinedo | 9316d3b | 2015-11-06 12:54:48 -0700 | [diff] [blame] | 28 | #include "vulkan/vulkan.h" |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 29 | |
| 30 | namespace vk_testing { |
| 31 | |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 32 | typedef void (*ErrorCallback)(const char *expr, const char *file, unsigned int line, const char *function); |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 33 | void set_error_callback(ErrorCallback callback); |
| 34 | |
| Chia-I Wu | 999f048 | 2015-07-03 10:32:05 +0800 | [diff] [blame] | 35 | class PhysicalDevice; |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 36 | class Device; |
| 37 | class Queue; |
| Chia-I Wu | f8f074f | 2015-07-03 10:58:57 +0800 | [diff] [blame] | 38 | class DeviceMemory; |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 39 | class Fence; |
| 40 | class Semaphore; |
| 41 | class Event; |
| 42 | class QueryPool; |
| 43 | class Buffer; |
| 44 | class BufferView; |
| 45 | class Image; |
| 46 | class ImageView; |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 47 | class DepthStencilView; |
| 48 | class Shader; |
| 49 | class Pipeline; |
| 50 | class PipelineDelta; |
| 51 | class Sampler; |
| 52 | class DescriptorSetLayout; |
| Mark Lobodzinski | 0fadf5f | 2015-04-17 14:11:39 -0500 | [diff] [blame] | 53 | class PipelineLayout; |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 54 | class DescriptorSetPool; |
| 55 | class DescriptorSet; |
| Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 56 | class CommandBuffer; |
| 57 | class CommandPool; |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 58 | |
| Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 59 | std::vector<VkLayerProperties> GetGlobalLayers(); |
| 60 | std::vector<VkExtensionProperties> GetGlobalExtensions(); |
| 61 | std::vector<VkExtensionProperties> GetGlobalExtensions(const char *pLayerName); |
| 62 | |
| Chia-I Wu | b0ed7d4 | 2015-07-03 10:13:26 +0800 | [diff] [blame] | 63 | namespace internal { |
| 64 | |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 65 | template <typename T> |
| 66 | class Handle { |
| 67 | public: |
| Chia-I Wu | b0ed7d4 | 2015-07-03 10:13:26 +0800 | [diff] [blame] | 68 | const T &handle() const { return handle_; } |
| 69 | bool initialized() const { return (handle_ != VK_NULL_HANDLE); } |
| 70 | |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 71 | protected: |
| Chia-I Wu | b0ed7d4 | 2015-07-03 10:13:26 +0800 | [diff] [blame] | 72 | typedef T handle_type; |
| 73 | |
| 74 | explicit Handle() : handle_(VK_NULL_HANDLE) {} |
| 75 | explicit Handle(T handle) : handle_(handle) {} |
| 76 | |
| Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 77 | void init(T handle) { |
| Chia-I Wu | b0ed7d4 | 2015-07-03 10:13:26 +0800 | [diff] [blame] | 78 | assert(!initialized()); |
| 79 | handle_ = handle; |
| 80 | } |
| 81 | |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 82 | private: |
| Chia-I Wu | b0ed7d4 | 2015-07-03 10:13:26 +0800 | [diff] [blame] | 83 | // handles are non-copyable |
| 84 | Handle(const Handle &); |
| 85 | Handle &operator=(const Handle &); |
| 86 | |
| 87 | T handle_; |
| 88 | }; |
| 89 | |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 90 | template <typename T> |
| 91 | class NonDispHandle : public Handle<T> { |
| 92 | protected: |
| Chia-I Wu | b0ed7d4 | 2015-07-03 10:13:26 +0800 | [diff] [blame] | 93 | explicit NonDispHandle() : Handle<T>(), dev_handle_(VK_NULL_HANDLE) {} |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 94 | explicit NonDispHandle(VkDevice dev, T handle) : Handle<T>(handle), dev_handle_(dev) {} |
| Chia-I Wu | b0ed7d4 | 2015-07-03 10:13:26 +0800 | [diff] [blame] | 95 | |
| 96 | const VkDevice &device() const { return dev_handle_; } |
| 97 | |
| Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 98 | void init(VkDevice dev, T handle) { |
| Chia-I Wu | b0ed7d4 | 2015-07-03 10:13:26 +0800 | [diff] [blame] | 99 | assert(!Handle<T>::initialized() && dev_handle_ == VK_NULL_HANDLE); |
| 100 | Handle<T>::init(handle); |
| 101 | dev_handle_ = dev; |
| 102 | } |
| 103 | |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 104 | private: |
| Chia-I Wu | b0ed7d4 | 2015-07-03 10:13:26 +0800 | [diff] [blame] | 105 | VkDevice dev_handle_; |
| 106 | }; |
| 107 | |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 108 | } // namespace internal |
| Chia-I Wu | b0ed7d4 | 2015-07-03 10:13:26 +0800 | [diff] [blame] | 109 | |
| Chia-I Wu | 999f048 | 2015-07-03 10:32:05 +0800 | [diff] [blame] | 110 | class PhysicalDevice : public internal::Handle<VkPhysicalDevice> { |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 111 | public: |
| Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 112 | explicit PhysicalDevice(VkPhysicalDevice phy) : Handle(phy) { |
| Mark Lobodzinski | b3fbcd9 | 2015-07-02 16:49:40 -0600 | [diff] [blame] | 113 | memory_properties_ = memory_properties(); |
| Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 114 | device_properties_ = properties(); |
| Mark Lobodzinski | b3fbcd9 | 2015-07-02 16:49:40 -0600 | [diff] [blame] | 115 | } |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 116 | |
| Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 117 | VkPhysicalDeviceProperties properties() const; |
| Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 118 | VkPhysicalDeviceMemoryProperties memory_properties() const; |
| Cody Northrop | d080288 | 2015-08-03 17:04:53 -0600 | [diff] [blame] | 119 | std::vector<VkQueueFamilyProperties> queue_properties() const; |
| Chris Forbes | f9cfe18 | 2016-04-04 17:22:42 +1200 | [diff] [blame] | 120 | VkPhysicalDeviceFeatures features() const; |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 121 | |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 122 | bool set_memory_type(const uint32_t type_bits, VkMemoryAllocateInfo *info, const VkMemoryPropertyFlags properties, |
| Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 123 | const VkMemoryPropertyFlags forbid = 0) const; |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 124 | |
| Courtney Goeltzenleuchter | 35985f6 | 2015-09-14 17:22:16 -0600 | [diff] [blame] | 125 | // vkEnumerateDeviceExtensionProperties() |
| Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 126 | std::vector<VkExtensionProperties> extensions() const; |
| Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 127 | std::vector<VkExtensionProperties> extensions(const char *pLayerName) const; |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 128 | |
| 129 | // vkEnumerateLayers() |
| Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 130 | std::vector<VkLayerProperties> layers() const; |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 131 | |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 132 | private: |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 133 | void add_extension_dependencies(uint32_t dependency_count, VkExtensionProperties *depencency_props, |
| 134 | std::vector<VkExtensionProperties> &ext_list); |
| Chia-I Wu | 999f048 | 2015-07-03 10:32:05 +0800 | [diff] [blame] | 135 | |
| Mark Lobodzinski | b3fbcd9 | 2015-07-02 16:49:40 -0600 | [diff] [blame] | 136 | VkPhysicalDeviceMemoryProperties memory_properties_; |
| Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 137 | |
| 138 | VkPhysicalDeviceProperties device_properties_; |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 139 | }; |
| 140 | |
| John Zulauf | 01da3ee | 2017-10-18 18:13:37 -0600 | [diff] [blame] | 141 | class QueueCreateInfoArray { |
| 142 | private: |
| 143 | std::vector<VkDeviceQueueCreateInfo> queue_info_; |
| 144 | std::vector<std::vector<float>> queue_priorities_; |
| 145 | |
| 146 | public: |
| 147 | QueueCreateInfoArray(const std::vector<VkQueueFamilyProperties> &queue_props); |
| 148 | size_t size() const { return queue_info_.size(); } |
| 149 | const VkDeviceQueueCreateInfo *data() const { return queue_info_.data(); } |
| 150 | }; |
| 151 | |
| Chia-I Wu | f368b60 | 2015-07-03 10:41:20 +0800 | [diff] [blame] | 152 | class Device : public internal::Handle<VkDevice> { |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 153 | public: |
| Chia-I Wu | 999f048 | 2015-07-03 10:32:05 +0800 | [diff] [blame] | 154 | explicit Device(VkPhysicalDevice phy) : phy_(phy) {} |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 155 | ~Device(); |
| 156 | |
| 157 | // vkCreateDevice() |
| Courtney Goeltzenleuchter | 95487bc | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 158 | void init(const VkDeviceCreateInfo &info); |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 159 | void init(std::vector<const char *> &extensions, |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 160 | VkPhysicalDeviceFeatures *features = nullptr); // all queues, all extensions, etc |
| Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 161 | void init() { |
| Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 162 | std::vector<const char *> extensions; |
| Tony Barbour | 4c70d10 | 2016-08-08 16:06:56 -0600 | [diff] [blame] | 163 | init(extensions); |
| Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 164 | }; |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 165 | |
| Chia-I Wu | 999f048 | 2015-07-03 10:32:05 +0800 | [diff] [blame] | 166 | const PhysicalDevice &phy() const { return phy_; } |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 167 | |
| Petr Kraus | b9659a0 | 2017-12-11 01:17:46 +0100 | [diff] [blame] | 168 | std::vector<const char *> GetEnabledExtensions() { return enabled_extensions_; } |
| 169 | bool IsEnbledExtension(const char *extension); |
| 170 | |
| Jon Ashburn | 8d1b0b5 | 2015-05-18 13:20:15 -0600 | [diff] [blame] | 171 | // vkGetDeviceProcAddr() |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 172 | PFN_vkVoidFunction get_proc(const char *name) const { return vkGetDeviceProcAddr(handle(), name); } |
| Jon Ashburn | 8d1b0b5 | 2015-05-18 13:20:15 -0600 | [diff] [blame] | 173 | |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 174 | // vkGetDeviceQueue() |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 175 | const std::vector<Queue *> &graphics_queues() const { return queues_[GRAPHICS]; } |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 176 | const std::vector<Queue *> &compute_queues() { return queues_[COMPUTE]; } |
| 177 | const std::vector<Queue *> &dma_queues() { return queues_[DMA]; } |
| Mike Schuchardt | 06304c2 | 2017-03-01 17:09:09 -0700 | [diff] [blame] | 178 | uint32_t queue_family_without_capabilities( VkQueueFlags capabilities ); |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 179 | uint32_t graphics_queue_node_index_; |
| 180 | |
| 181 | struct Format { |
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 182 | VkFormat format; |
| 183 | VkImageTiling tiling; |
| 184 | VkFlags features; |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 185 | }; |
| 186 | // vkGetFormatInfo() |
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 187 | VkFormatProperties format_properties(VkFormat format); |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 188 | const std::vector<Format> &formats() const { return formats_; } |
| 189 | |
| 190 | // vkDeviceWaitIdle() |
| 191 | void wait(); |
| 192 | |
| 193 | // vkWaitForFences() |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 194 | VkResult wait(const std::vector<const Fence *> &fences, bool wait_all, uint64_t timeout); |
| 195 | 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] | 196 | |
| Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 197 | // vkUpdateDescriptorSets() |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 198 | void update_descriptor_sets(const std::vector<VkWriteDescriptorSet> &writes, const std::vector<VkCopyDescriptorSet> &copies); |
| 199 | void update_descriptor_sets(const std::vector<VkWriteDescriptorSet> &writes) { |
| 200 | return update_descriptor_sets(writes, std::vector<VkCopyDescriptorSet>()); |
| Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 201 | } |
| Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 202 | |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 203 | static VkWriteDescriptorSet write_descriptor_set(const DescriptorSet &set, uint32_t binding, uint32_t array_element, |
| 204 | VkDescriptorType type, uint32_t count, |
| 205 | const VkDescriptorImageInfo *image_info); |
| 206 | static VkWriteDescriptorSet write_descriptor_set(const DescriptorSet &set, uint32_t binding, uint32_t array_element, |
| 207 | VkDescriptorType type, uint32_t count, |
| 208 | const VkDescriptorBufferInfo *buffer_info); |
| 209 | static VkWriteDescriptorSet write_descriptor_set(const DescriptorSet &set, uint32_t binding, uint32_t array_element, |
| 210 | VkDescriptorType type, uint32_t count, const VkBufferView *buffer_views); |
| 211 | static VkWriteDescriptorSet write_descriptor_set(const DescriptorSet &set, uint32_t binding, uint32_t array_element, |
| 212 | VkDescriptorType type, const std::vector<VkDescriptorImageInfo> &image_info); |
| 213 | static VkWriteDescriptorSet write_descriptor_set(const DescriptorSet &set, uint32_t binding, uint32_t array_element, |
| 214 | VkDescriptorType type, const std::vector<VkDescriptorBufferInfo> &buffer_info); |
| 215 | static VkWriteDescriptorSet write_descriptor_set(const DescriptorSet &set, uint32_t binding, uint32_t array_element, |
| 216 | VkDescriptorType type, const std::vector<VkBufferView> &buffer_views); |
| Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 217 | |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 218 | static VkCopyDescriptorSet copy_descriptor_set(const DescriptorSet &src_set, uint32_t src_binding, uint32_t src_array_element, |
| 219 | const DescriptorSet &dst_set, uint32_t dst_binding, uint32_t dst_array_element, |
| 220 | uint32_t count); |
| Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 221 | |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 222 | private: |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 223 | enum QueueIndex { |
| 224 | GRAPHICS, |
| 225 | COMPUTE, |
| 226 | DMA, |
| 227 | QUEUE_COUNT, |
| 228 | }; |
| 229 | |
| 230 | void init_queues(); |
| 231 | void init_formats(); |
| 232 | |
| Chia-I Wu | 999f048 | 2015-07-03 10:32:05 +0800 | [diff] [blame] | 233 | PhysicalDevice phy_; |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 234 | |
| Petr Kraus | b9659a0 | 2017-12-11 01:17:46 +0100 | [diff] [blame] | 235 | std::vector<const char *> enabled_extensions_; |
| 236 | |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 237 | std::vector<Queue *> queues_[QUEUE_COUNT]; |
| 238 | std::vector<Format> formats_; |
| 239 | }; |
| 240 | |
| Chia-I Wu | df12ffd | 2015-07-03 10:53:18 +0800 | [diff] [blame] | 241 | class Queue : public internal::Handle<VkQueue> { |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 242 | public: |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 243 | explicit Queue(VkQueue queue, int index) : Handle(queue) { family_index_ = index; } |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 244 | |
| 245 | // vkQueueSubmit() |
| Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 246 | void submit(const std::vector<const CommandBuffer *> &cmds, Fence &fence); |
| 247 | void submit(const CommandBuffer &cmd, Fence &fence); |
| 248 | void submit(const CommandBuffer &cmd); |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 249 | |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 250 | // vkQueueWaitIdle() |
| 251 | void wait(); |
| 252 | |
| Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 253 | int get_family_index() { return family_index_; } |
| Tony Barbour | fb21ea3 | 2015-07-23 10:35:30 -0600 | [diff] [blame] | 254 | |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 255 | private: |
| Tony Barbour | fb21ea3 | 2015-07-23 10:35:30 -0600 | [diff] [blame] | 256 | int family_index_; |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 257 | }; |
| 258 | |
| Chia-I Wu | f8f074f | 2015-07-03 10:58:57 +0800 | [diff] [blame] | 259 | class DeviceMemory : public internal::NonDispHandle<VkDeviceMemory> { |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 260 | public: |
| Chia-I Wu | f8f074f | 2015-07-03 10:58:57 +0800 | [diff] [blame] | 261 | ~DeviceMemory(); |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 262 | |
| Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 263 | // vkAllocateMemory() |
| 264 | void init(const Device &dev, const VkMemoryAllocateInfo &info); |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 265 | |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 266 | // vkMapMemory() |
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 267 | const void *map(VkFlags flags) const; |
| Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 268 | void *map(VkFlags flags); |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 269 | const void *map() const { return map(0); } |
| Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 270 | void *map() { return map(0); } |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 271 | |
| 272 | // vkUnmapMemory() |
| 273 | void unmap() const; |
| 274 | |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 275 | static VkMemoryAllocateInfo alloc_info(VkDeviceSize size, uint32_t memory_type_index); |
| Mike Schuchardt | 8cacbb0 | 2017-10-26 14:06:38 -0600 | [diff] [blame] | 276 | static VkMemoryAllocateInfo get_resource_alloc_info(const vk_testing::Device &dev, const VkMemoryRequirements &reqs, |
| 277 | VkMemoryPropertyFlags mem_props); |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 278 | }; |
| 279 | |
| Chia-I Wu | d9e8e82 | 2015-07-03 11:45:55 +0800 | [diff] [blame] | 280 | class Fence : public internal::NonDispHandle<VkFence> { |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 281 | public: |
| Chia-I Wu | d9e8e82 | 2015-07-03 11:45:55 +0800 | [diff] [blame] | 282 | ~Fence(); |
| 283 | |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 284 | // vkCreateFence() |
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 285 | void init(const Device &dev, const VkFenceCreateInfo &info); |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 286 | |
| 287 | // vkGetFenceStatus() |
| Chia-I Wu | d9e8e82 | 2015-07-03 11:45:55 +0800 | [diff] [blame] | 288 | VkResult status() const { return vkGetFenceStatus(device(), handle()); } |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 289 | |
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 290 | static VkFenceCreateInfo create_info(VkFenceCreateFlags flags); |
| 291 | static VkFenceCreateInfo create_info(); |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 292 | }; |
| 293 | |
| Chia-I Wu | 6b1c248 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 294 | class Semaphore : public internal::NonDispHandle<VkSemaphore> { |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 295 | public: |
| Chia-I Wu | 6b1c248 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 296 | ~Semaphore(); |
| 297 | |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 298 | // vkCreateSemaphore() |
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 299 | void init(const Device &dev, const VkSemaphoreCreateInfo &info); |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 300 | |
| Tony Barbour | af892a1 | 2015-06-26 12:56:09 -0600 | [diff] [blame] | 301 | static VkSemaphoreCreateInfo create_info(VkFlags flags); |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 302 | }; |
| 303 | |
| Chia-I Wu | c5c9799 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 304 | class Event : public internal::NonDispHandle<VkEvent> { |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 305 | public: |
| Chia-I Wu | c5c9799 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 306 | ~Event(); |
| 307 | |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 308 | // vkCreateEvent() |
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 309 | void init(const Device &dev, const VkEventCreateInfo &info); |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 310 | |
| 311 | // vkGetEventStatus() |
| 312 | // vkSetEvent() |
| 313 | // vkResetEvent() |
| Chia-I Wu | c5c9799 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 314 | VkResult status() const { return vkGetEventStatus(device(), handle()); } |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 315 | void set(); |
| 316 | void reset(); |
| 317 | |
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 318 | static VkEventCreateInfo create_info(VkFlags flags); |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 319 | }; |
| 320 | |
| Chia-I Wu | 1b7d476 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 321 | class QueryPool : public internal::NonDispHandle<VkQueryPool> { |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 322 | public: |
| Chia-I Wu | 1b7d476 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 323 | ~QueryPool(); |
| 324 | |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 325 | // vkCreateQueryPool() |
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 326 | void init(const Device &dev, const VkQueryPoolCreateInfo &info); |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 327 | |
| 328 | // vkGetQueryPoolResults() |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 329 | VkResult results(uint32_t first, uint32_t count, size_t size, void *data, size_t stride); |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 330 | |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 331 | static VkQueryPoolCreateInfo create_info(VkQueryType type, uint32_t slot_count); |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 332 | }; |
| 333 | |
| Chia-I Wu | 681d7a0 | 2015-07-03 13:44:34 +0800 | [diff] [blame] | 334 | class Buffer : public internal::NonDispHandle<VkBuffer> { |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 335 | public: |
| Chia-I Wu | 681d7a0 | 2015-07-03 13:44:34 +0800 | [diff] [blame] | 336 | explicit Buffer() : NonDispHandle() {} |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 337 | explicit Buffer(const Device &dev, const VkBufferCreateInfo &info) { init(dev, info); } |
| Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 338 | explicit Buffer(const Device &dev, VkDeviceSize size) { init(dev, size); } |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 339 | |
| Chia-I Wu | 681d7a0 | 2015-07-03 13:44:34 +0800 | [diff] [blame] | 340 | ~Buffer(); |
| 341 | |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 342 | // vkCreateBuffer() |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 343 | void init(const Device &dev, const VkBufferCreateInfo &info, VkMemoryPropertyFlags mem_props); |
| 344 | void init(const Device &dev, const VkBufferCreateInfo &info) { init(dev, info, 0); } |
| 345 | void init(const Device &dev, VkDeviceSize size, VkMemoryPropertyFlags mem_props) { init(dev, create_info(size, 0), mem_props); } |
| Chia-I Wu | 681d7a0 | 2015-07-03 13:44:34 +0800 | [diff] [blame] | 346 | void init(const Device &dev, VkDeviceSize size) { init(dev, size, 0); } |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 347 | void init_as_src(const Device &dev, VkDeviceSize size, VkMemoryPropertyFlags &reqs) { |
| Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 348 | init(dev, create_info(size, VK_BUFFER_USAGE_TRANSFER_SRC_BIT), reqs); |
| 349 | } |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 350 | void init_as_dst(const Device &dev, VkDeviceSize size, VkMemoryPropertyFlags &reqs) { |
| Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 351 | init(dev, create_info(size, VK_BUFFER_USAGE_TRANSFER_DST_BIT), reqs); |
| 352 | } |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 353 | void init_as_src_and_dst(const Device &dev, VkDeviceSize size, VkMemoryPropertyFlags &reqs) { |
| 354 | init(dev, create_info(size, VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT), reqs); |
| Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 355 | } |
| Courtney Goeltzenleuchter | 95487bc | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 356 | void init_no_mem(const Device &dev, const VkBufferCreateInfo &info); |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 357 | |
| Chia-I Wu | 681d7a0 | 2015-07-03 13:44:34 +0800 | [diff] [blame] | 358 | // get the internal memory |
| 359 | const DeviceMemory &memory() const { return internal_mem_; } |
| Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 360 | DeviceMemory &memory() { return internal_mem_; } |
| Chia-I Wu | 681d7a0 | 2015-07-03 13:44:34 +0800 | [diff] [blame] | 361 | |
| 362 | // vkGetObjectMemoryRequirements() |
| 363 | VkMemoryRequirements memory_requirements() const; |
| 364 | |
| 365 | // vkBindObjectMemory() |
| 366 | void bind_memory(const DeviceMemory &mem, VkDeviceSize mem_offset); |
| Mark Lobodzinski | 942b172 | 2015-05-11 17:21:15 -0500 | [diff] [blame] | 367 | |
| Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 368 | static VkBufferCreateInfo create_info(VkDeviceSize size, VkFlags usage); |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 369 | |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 370 | VkBufferMemoryBarrier buffer_memory_barrier(VkFlags output_mask, VkFlags input_mask, VkDeviceSize offset, |
| Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 371 | VkDeviceSize size) const { |
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 372 | VkBufferMemoryBarrier barrier = {}; |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 373 | barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
| Chia-I Wu | 681d7a0 | 2015-07-03 13:44:34 +0800 | [diff] [blame] | 374 | barrier.buffer = handle(); |
| Chia-I Wu | a459420 | 2015-10-27 19:54:37 +0800 | [diff] [blame] | 375 | barrier.srcAccessMask = output_mask; |
| 376 | barrier.dstAccessMask = input_mask; |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 377 | barrier.offset = offset; |
| 378 | barrier.size = size; |
| 379 | return barrier; |
| 380 | } |
| Chia-I Wu | 681d7a0 | 2015-07-03 13:44:34 +0800 | [diff] [blame] | 381 | |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 382 | private: |
| Courtney Goeltzenleuchter | 95487bc | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 383 | VkBufferCreateInfo create_info_; |
| Chia-I Wu | 681d7a0 | 2015-07-03 13:44:34 +0800 | [diff] [blame] | 384 | |
| 385 | DeviceMemory internal_mem_; |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 386 | }; |
| 387 | |
| Chia-I Wu | 3158bf3 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 388 | class BufferView : public internal::NonDispHandle<VkBufferView> { |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 389 | public: |
| Chia-I Wu | 3158bf3 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 390 | ~BufferView(); |
| 391 | |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 392 | // vkCreateBufferView() |
| Courtney Goeltzenleuchter | 95487bc | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 393 | void init(const Device &dev, const VkBufferViewCreateInfo &info); |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 394 | }; |
| 395 | |
| Chia-I Wu | 681d7a0 | 2015-07-03 13:44:34 +0800 | [diff] [blame] | 396 | class Image : public internal::NonDispHandle<VkImage> { |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 397 | public: |
| Chia-I Wu | 681d7a0 | 2015-07-03 13:44:34 +0800 | [diff] [blame] | 398 | explicit Image() : NonDispHandle(), format_features_(0) {} |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 399 | 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] | 400 | |
| Chia-I Wu | 681d7a0 | 2015-07-03 13:44:34 +0800 | [diff] [blame] | 401 | ~Image(); |
| 402 | |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 403 | // vkCreateImage() |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 404 | void init(const Device &dev, const VkImageCreateInfo &info, VkMemoryPropertyFlags mem_props); |
| 405 | void init(const Device &dev, const VkImageCreateInfo &info) { init(dev, info, 0); } |
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 406 | void init_no_mem(const Device &dev, const VkImageCreateInfo &info); |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 407 | |
| Chia-I Wu | 681d7a0 | 2015-07-03 13:44:34 +0800 | [diff] [blame] | 408 | // get the internal memory |
| 409 | const DeviceMemory &memory() const { return internal_mem_; } |
| Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 410 | DeviceMemory &memory() { return internal_mem_; } |
| Chia-I Wu | 681d7a0 | 2015-07-03 13:44:34 +0800 | [diff] [blame] | 411 | |
| 412 | // vkGetObjectMemoryRequirements() |
| 413 | VkMemoryRequirements memory_requirements() const; |
| 414 | |
| 415 | // vkBindObjectMemory() |
| 416 | void bind_memory(const DeviceMemory &mem, VkDeviceSize mem_offset); |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 417 | |
| Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 418 | // vkGetImageSubresourceLayout() |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 419 | VkSubresourceLayout subresource_layout(const VkImageSubresource &subres) const; |
| 420 | VkSubresourceLayout subresource_layout(const VkImageSubresourceLayers &subres) const; |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 421 | |
| 422 | bool transparent() const; |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 423 | bool copyable() const { return (format_features_ & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT); } |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 424 | |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 425 | VkImageSubresourceRange subresource_range(VkImageAspectFlagBits aspect) const { |
| Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 426 | return subresource_range(create_info_, aspect); |
| 427 | } |
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 428 | VkExtent3D extent() const { return create_info_.extent; } |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 429 | VkExtent3D extent(uint32_t mip_level) const { return extent(create_info_.extent, mip_level); } |
| Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 430 | VkFormat format() const { return create_info_.format; } |
| Mike Weiblen | e6e0117 | 2017-03-07 22:18:40 -0700 | [diff] [blame] | 431 | VkImageUsageFlags usage() const { return create_info_.usage; } |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 432 | VkImageMemoryBarrier image_memory_barrier(VkFlags output_mask, VkFlags input_mask, VkImageLayout old_layout, |
| 433 | VkImageLayout new_layout, const VkImageSubresourceRange &range) const { |
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 434 | VkImageMemoryBarrier barrier = {}; |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 435 | barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| Chia-I Wu | a459420 | 2015-10-27 19:54:37 +0800 | [diff] [blame] | 436 | barrier.srcAccessMask = output_mask; |
| 437 | barrier.dstAccessMask = input_mask; |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 438 | barrier.oldLayout = old_layout; |
| 439 | barrier.newLayout = new_layout; |
| Chia-I Wu | 681d7a0 | 2015-07-03 13:44:34 +0800 | [diff] [blame] | 440 | barrier.image = handle(); |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 441 | barrier.subresourceRange = range; |
| 442 | return barrier; |
| 443 | } |
| 444 | |
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 445 | static VkImageCreateInfo create_info(); |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 446 | static VkImageSubresource subresource(VkImageAspectFlags aspect, uint32_t mip_level, uint32_t array_layer); |
| 447 | static VkImageSubresource subresource(const VkImageSubresourceRange &range, uint32_t mip_level, uint32_t array_layer); |
| 448 | static VkImageSubresourceLayers subresource(VkImageAspectFlags aspect, uint32_t mip_level, uint32_t array_layer, |
| Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 449 | uint32_t array_size); |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 450 | static VkImageSubresourceLayers subresource(const VkImageSubresourceRange &range, uint32_t mip_level, uint32_t array_layer, |
| 451 | uint32_t array_size); |
| 452 | static VkImageSubresourceRange subresource_range(VkImageAspectFlags aspect_mask, uint32_t base_mip_level, uint32_t mip_levels, |
| 453 | uint32_t base_array_layer, uint32_t num_layers); |
| 454 | static VkImageSubresourceRange subresource_range(const VkImageCreateInfo &info, VkImageAspectFlags aspect_mask); |
| 455 | static VkImageSubresourceRange subresource_range(const VkImageSubresource &subres); |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 456 | |
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 457 | static VkExtent2D extent(int32_t width, int32_t height); |
| 458 | static VkExtent2D extent(const VkExtent2D &extent, uint32_t mip_level); |
| 459 | static VkExtent2D extent(const VkExtent3D &extent); |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 460 | |
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 461 | static VkExtent3D extent(int32_t width, int32_t height, int32_t depth); |
| 462 | static VkExtent3D extent(const VkExtent3D &extent, uint32_t mip_level); |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 463 | |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 464 | private: |
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 465 | void init_info(const Device &dev, const VkImageCreateInfo &info); |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 466 | |
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 467 | VkImageCreateInfo create_info_; |
| 468 | VkFlags format_features_; |
| Chia-I Wu | 681d7a0 | 2015-07-03 13:44:34 +0800 | [diff] [blame] | 469 | |
| 470 | DeviceMemory internal_mem_; |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 471 | }; |
| 472 | |
| Chia-I Wu | 3158bf3 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 473 | class ImageView : public internal::NonDispHandle<VkImageView> { |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 474 | public: |
| Chia-I Wu | 3158bf3 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 475 | ~ImageView(); |
| 476 | |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 477 | // vkCreateImageView() |
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 478 | void init(const Device &dev, const VkImageViewCreateInfo &info); |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 479 | }; |
| 480 | |
| Chia-I Wu | 4d0c792 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 481 | class ShaderModule : public internal::NonDispHandle<VkShaderModule> { |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 482 | public: |
| Chia-I Wu | 4d0c792 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 483 | ~ShaderModule(); |
| 484 | |
| Courtney Goeltzenleuchter | ee4027d | 2015-06-28 13:01:17 -0600 | [diff] [blame] | 485 | // vkCreateShaderModule() |
| 486 | void init(const Device &dev, const VkShaderModuleCreateInfo &info); |
| 487 | VkResult init_try(const Device &dev, const VkShaderModuleCreateInfo &info); |
| 488 | |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 489 | static VkShaderModuleCreateInfo create_info(size_t code_size, const uint32_t *code, VkFlags flags); |
| Courtney Goeltzenleuchter | ee4027d | 2015-06-28 13:01:17 -0600 | [diff] [blame] | 490 | }; |
| 491 | |
| Chia-I Wu | 2ff72fd | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 492 | class Pipeline : public internal::NonDispHandle<VkPipeline> { |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 493 | public: |
| Chia-I Wu | 2ff72fd | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 494 | ~Pipeline(); |
| 495 | |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 496 | // vkCreateGraphicsPipeline() |
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 497 | void init(const Device &dev, const VkGraphicsPipelineCreateInfo &info); |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 498 | // vkCreateGraphicsPipelineDerivative() |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 499 | void init(const Device &dev, const VkGraphicsPipelineCreateInfo &info, const VkPipeline basePipeline); |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 500 | // vkCreateComputePipeline() |
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 501 | void init(const Device &dev, const VkComputePipelineCreateInfo &info); |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 502 | // vkLoadPipeline() |
| Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 503 | void init(const Device &dev, size_t size, const void *data); |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 504 | // vkLoadPipelineDerivative() |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 505 | 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] | 506 | |
| Chris Forbes | 95292b1 | 2015-05-25 11:13:26 +1200 | [diff] [blame] | 507 | // vkCreateGraphicsPipeline with error return |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 508 | VkResult init_try(const Device &dev, const VkGraphicsPipelineCreateInfo &info); |
| Chris Forbes | 95292b1 | 2015-05-25 11:13:26 +1200 | [diff] [blame] | 509 | |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 510 | // vkStorePipeline() |
| 511 | size_t store(size_t size, void *data); |
| 512 | }; |
| 513 | |
| Chia-I Wu | fd46e7d | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 514 | class PipelineLayout : public internal::NonDispHandle<VkPipelineLayout> { |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 515 | public: |
| Chia-I Wu | fd46e7d | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 516 | ~PipelineLayout(); |
| 517 | |
| 518 | // vCreatePipelineLayout() |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 519 | void init(const Device &dev, VkPipelineLayoutCreateInfo &info, const std::vector<const DescriptorSetLayout *> &layouts); |
| Chia-I Wu | fd46e7d | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 520 | }; |
| 521 | |
| Chia-I Wu | 8c721c6 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 522 | class Sampler : public internal::NonDispHandle<VkSampler> { |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 523 | public: |
| Chia-I Wu | 8c721c6 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 524 | ~Sampler(); |
| 525 | |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 526 | // vkCreateSampler() |
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 527 | void init(const Device &dev, const VkSamplerCreateInfo &info); |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 528 | }; |
| 529 | |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 530 | class DescriptorSetLayout : public internal::NonDispHandle<VkDescriptorSetLayout> { |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 531 | public: |
| Chia-I Wu | afdfd7f | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 532 | ~DescriptorSetLayout(); |
| 533 | |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 534 | // vkCreateDescriptorSetLayout() |
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 535 | void init(const Device &dev, const VkDescriptorSetLayoutCreateInfo &info); |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 536 | }; |
| 537 | |
| Chia-I Wu | afdfd7f | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 538 | class DescriptorPool : public internal::NonDispHandle<VkDescriptorPool> { |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 539 | public: |
| Chia-I Wu | afdfd7f | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 540 | ~DescriptorPool(); |
| 541 | |
| Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 542 | // Descriptor sets allocated from this pool will need access to the original |
| 543 | // object |
| Cody Northrop | cdc72a4 | 2015-10-08 11:39:25 -0600 | [diff] [blame] | 544 | VkDescriptorPool GetObj() { return pool_; } |
| 545 | |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 546 | // vkCreateDescriptorPool() |
| Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 547 | void init(const Device &dev, const VkDescriptorPoolCreateInfo &info); |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 548 | |
| 549 | // vkResetDescriptorPool() |
| 550 | void reset(); |
| 551 | |
| Cody Northrop | cdc72a4 | 2015-10-08 11:39:25 -0600 | [diff] [blame] | 552 | // vkFreeDescriptorSet() |
| 553 | void setDynamicUsage(bool isDynamic) { dynamic_usage_ = isDynamic; } |
| 554 | bool getDynamicUsage() { return dynamic_usage_; } |
| 555 | |
| Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 556 | // vkAllocateDescriptorSets() |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 557 | std::vector<DescriptorSet *> alloc_sets(const Device &dev, const std::vector<const DescriptorSetLayout *> &layouts); |
| 558 | std::vector<DescriptorSet *> alloc_sets(const Device &dev, const DescriptorSetLayout &layout, uint32_t count); |
| 559 | DescriptorSet *alloc_sets(const Device &dev, const DescriptorSetLayout &layout); |
| Cody Northrop | cdc72a4 | 2015-10-08 11:39:25 -0600 | [diff] [blame] | 560 | |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 561 | private: |
| Cody Northrop | cdc72a4 | 2015-10-08 11:39:25 -0600 | [diff] [blame] | 562 | VkDescriptorPool pool_; |
| 563 | |
| 564 | // Track whether this pool's usage is VK_DESCRIPTOR_POOL_USAGE_DYNAMIC |
| 565 | bool dynamic_usage_; |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 566 | }; |
| 567 | |
| Chia-I Wu | afdfd7f | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 568 | class DescriptorSet : public internal::NonDispHandle<VkDescriptorSet> { |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 569 | public: |
| Chia-I Wu | afdfd7f | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 570 | ~DescriptorSet(); |
| 571 | |
| 572 | explicit DescriptorSet() : NonDispHandle() {} |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 573 | explicit DescriptorSet(const Device &dev, DescriptorPool *pool, VkDescriptorSet set) : NonDispHandle(dev.handle(), set) { |
| Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 574 | containing_pool_ = pool; |
| 575 | } |
| Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 576 | |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 577 | private: |
| Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 578 | DescriptorPool *containing_pool_; |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 579 | }; |
| 580 | |
| Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 581 | class CommandPool : public internal::NonDispHandle<VkCommandPool> { |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 582 | public: |
| Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 583 | ~CommandPool(); |
| Courtney Goeltzenleuchter | ee5d80b | 2015-07-10 19:50:17 -0600 | [diff] [blame] | 584 | |
| Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 585 | explicit CommandPool() : NonDispHandle() {} |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 586 | explicit CommandPool(const Device &dev, const VkCommandPoolCreateInfo &info) { init(dev, info); } |
| Courtney Goeltzenleuchter | ee5d80b | 2015-07-10 19:50:17 -0600 | [diff] [blame] | 587 | |
| Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 588 | void init(const Device &dev, const VkCommandPoolCreateInfo &info); |
| Courtney Goeltzenleuchter | ee5d80b | 2015-07-10 19:50:17 -0600 | [diff] [blame] | 589 | |
| Mike Schuchardt | 06304c2 | 2017-03-01 17:09:09 -0700 | [diff] [blame] | 590 | static VkCommandPoolCreateInfo create_info(uint32_t queue_family_index, VkCommandPoolCreateFlags flags); |
| Courtney Goeltzenleuchter | ee5d80b | 2015-07-10 19:50:17 -0600 | [diff] [blame] | 591 | }; |
| 592 | |
| Mike Schuchardt | 06304c2 | 2017-03-01 17:09:09 -0700 | [diff] [blame] | 593 | inline VkCommandPoolCreateInfo CommandPool::create_info(uint32_t queue_family_index, VkCommandPoolCreateFlags flags) { |
| Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 594 | VkCommandPoolCreateInfo info = {}; |
| 595 | info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| Courtney Goeltzenleuchter | ee5d80b | 2015-07-10 19:50:17 -0600 | [diff] [blame] | 596 | info.queueFamilyIndex = queue_family_index; |
| Mike Schuchardt | 06304c2 | 2017-03-01 17:09:09 -0700 | [diff] [blame] | 597 | info.flags = flags; |
| Courtney Goeltzenleuchter | ee5d80b | 2015-07-10 19:50:17 -0600 | [diff] [blame] | 598 | return info; |
| 599 | } |
| 600 | |
| Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 601 | class CommandBuffer : public internal::Handle<VkCommandBuffer> { |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 602 | public: |
| Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 603 | ~CommandBuffer(); |
| Chia-I Wu | be2b917 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 604 | |
| Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 605 | explicit CommandBuffer() : Handle() {} |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 606 | explicit CommandBuffer(const Device &dev, const VkCommandBufferAllocateInfo &info) { init(dev, info); } |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 607 | |
| Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 608 | // vkAllocateCommandBuffers() |
| 609 | void init(const Device &dev, const VkCommandBufferAllocateInfo &info); |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 610 | |
| 611 | // vkBeginCommandBuffer() |
| Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 612 | void begin(const VkCommandBufferBeginInfo *info); |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 613 | void begin(); |
| 614 | |
| 615 | // vkEndCommandBuffer() |
| 616 | // vkResetCommandBuffer() |
| 617 | void end(); |
| Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 618 | void reset(VkCommandBufferResetFlags flags); |
| 619 | void reset() { reset(VK_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT); } |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 620 | |
| Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 621 | static VkCommandBufferAllocateInfo create_info(VkCommandPool const &pool); |
| Chia-I Wu | be2b917 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 622 | |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 623 | private: |
| Chia-I Wu | be2b917 | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 624 | VkDevice dev_handle_; |
| Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 625 | VkCommandPool cmd_pool_; |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 626 | }; |
| 627 | |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 628 | inline VkMemoryAllocateInfo DeviceMemory::alloc_info(VkDeviceSize size, uint32_t memory_type_index) { |
| Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 629 | VkMemoryAllocateInfo info = {}; |
| Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 630 | info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| Chia-I Wu | f8f074f | 2015-07-03 10:58:57 +0800 | [diff] [blame] | 631 | info.allocationSize = size; |
| 632 | info.memoryTypeIndex = memory_type_index; |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 633 | return info; |
| 634 | } |
| 635 | |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 636 | inline VkBufferCreateInfo Buffer::create_info(VkDeviceSize size, VkFlags usage) { |
| Courtney Goeltzenleuchter | 95487bc | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 637 | VkBufferCreateInfo info = {}; |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 638 | info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 639 | info.size = size; |
| 640 | info.usage = usage; |
| 641 | return info; |
| 642 | } |
| 643 | |
| Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 644 | inline VkFenceCreateInfo Fence::create_info(VkFenceCreateFlags flags) { |
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 645 | VkFenceCreateInfo info = {}; |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 646 | info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 647 | info.flags = flags; |
| 648 | return info; |
| 649 | } |
| 650 | |
| Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 651 | inline VkFenceCreateInfo Fence::create_info() { |
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 652 | VkFenceCreateInfo info = {}; |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 653 | info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 654 | return info; |
| 655 | } |
| 656 | |
| Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 657 | inline VkSemaphoreCreateInfo Semaphore::create_info(VkFlags flags) { |
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 658 | VkSemaphoreCreateInfo info = {}; |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 659 | info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 660 | info.flags = flags; |
| 661 | return info; |
| 662 | } |
| 663 | |
| Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 664 | inline VkEventCreateInfo Event::create_info(VkFlags flags) { |
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 665 | VkEventCreateInfo info = {}; |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 666 | info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 667 | info.flags = flags; |
| 668 | return info; |
| 669 | } |
| 670 | |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 671 | inline VkQueryPoolCreateInfo QueryPool::create_info(VkQueryType type, uint32_t slot_count) { |
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 672 | VkQueryPoolCreateInfo info = {}; |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 673 | info.sType = VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO; |
| 674 | info.queryType = type; |
| Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 675 | info.queryCount = slot_count; |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 676 | return info; |
| 677 | } |
| 678 | |
| Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 679 | inline VkImageCreateInfo Image::create_info() { |
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 680 | VkImageCreateInfo info = {}; |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 681 | info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 682 | info.extent.width = 1; |
| 683 | info.extent.height = 1; |
| 684 | info.extent.depth = 1; |
| 685 | info.mipLevels = 1; |
| Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 686 | info.arrayLayers = 1; |
| Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 687 | info.samples = VK_SAMPLE_COUNT_1_BIT; |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 688 | return info; |
| 689 | } |
| 690 | |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 691 | inline VkImageSubresource Image::subresource(VkImageAspectFlags aspect, uint32_t mip_level, uint32_t array_layer) { |
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 692 | VkImageSubresource subres = {}; |
| Karl Schultz | 0ab73f8 | 2016-03-29 12:41:24 -0600 | [diff] [blame] | 693 | if (aspect == 0) { |
| 694 | assert(!"Invalid VkImageAspectFlags"); |
| 695 | } |
| Chia-I Wu | 52b07e7 | 2015-10-27 19:55:05 +0800 | [diff] [blame] | 696 | subres.aspectMask = aspect; |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 697 | subres.mipLevel = mip_level; |
| Courtney Goeltzenleuchter | 4a26189 | 2015-09-10 16:38:41 -0600 | [diff] [blame] | 698 | subres.arrayLayer = array_layer; |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 699 | return subres; |
| 700 | } |
| 701 | |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 702 | inline VkImageSubresource Image::subresource(const VkImageSubresourceRange &range, uint32_t mip_level, uint32_t array_layer) { |
| 703 | return subresource(range.aspectMask, range.baseMipLevel + mip_level, range.baseArrayLayer + array_layer); |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 704 | } |
| 705 | |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 706 | inline VkImageSubresourceLayers Image::subresource(VkImageAspectFlags aspect, uint32_t mip_level, uint32_t array_layer, |
| Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 707 | uint32_t array_size) { |
| Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 708 | VkImageSubresourceLayers subres = {}; |
| Karl Schultz | 0ab73f8 | 2016-03-29 12:41:24 -0600 | [diff] [blame] | 709 | switch (aspect) { |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 710 | case VK_IMAGE_ASPECT_COLOR_BIT: |
| 711 | case VK_IMAGE_ASPECT_DEPTH_BIT: |
| 712 | case VK_IMAGE_ASPECT_STENCIL_BIT: |
| 713 | case VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT: |
| 714 | /* valid */ |
| 715 | break; |
| 716 | default: |
| 717 | assert(!"Invalid VkImageAspectFlags"); |
| Karl Schultz | 0ab73f8 | 2016-03-29 12:41:24 -0600 | [diff] [blame] | 718 | } |
| Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 719 | subres.aspectMask = aspect; |
| Courtney Goeltzenleuchter | 01ee1ca | 2015-09-10 16:41:13 -0600 | [diff] [blame] | 720 | subres.mipLevel = mip_level; |
| Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 721 | subres.baseArrayLayer = array_layer; |
| Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 722 | subres.layerCount = array_size; |
| Courtney Goeltzenleuchter | 01ee1ca | 2015-09-10 16:41:13 -0600 | [diff] [blame] | 723 | return subres; |
| 724 | } |
| 725 | |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 726 | inline VkImageSubresourceLayers Image::subresource(const VkImageSubresourceRange &range, uint32_t mip_level, uint32_t array_layer, |
| 727 | uint32_t array_size) { |
| 728 | return subresource(range.aspectMask, range.baseMipLevel + mip_level, range.baseArrayLayer + array_layer, array_size); |
| Courtney Goeltzenleuchter | ba72451 | 2015-09-10 17:58:54 -0600 | [diff] [blame] | 729 | } |
| 730 | |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 731 | inline VkImageSubresourceRange Image::subresource_range(VkImageAspectFlags aspect_mask, uint32_t base_mip_level, |
| 732 | uint32_t mip_levels, uint32_t base_array_layer, uint32_t num_layers) { |
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 733 | VkImageSubresourceRange range = {}; |
| Karl Schultz | 0ab73f8 | 2016-03-29 12:41:24 -0600 | [diff] [blame] | 734 | if (aspect_mask == 0) { |
| 735 | assert(!"Invalid VkImageAspectFlags"); |
| 736 | } |
| Courtney Goeltzenleuchter | ba72451 | 2015-09-10 17:58:54 -0600 | [diff] [blame] | 737 | range.aspectMask = aspect_mask; |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 738 | range.baseMipLevel = base_mip_level; |
| Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 739 | range.levelCount = mip_levels; |
| Courtney Goeltzenleuchter | 4a26189 | 2015-09-10 16:38:41 -0600 | [diff] [blame] | 740 | range.baseArrayLayer = base_array_layer; |
| Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 741 | range.layerCount = num_layers; |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 742 | return range; |
| 743 | } |
| 744 | |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 745 | inline VkImageSubresourceRange Image::subresource_range(const VkImageCreateInfo &info, VkImageAspectFlags aspect_mask) { |
| 746 | return subresource_range(aspect_mask, 0, info.mipLevels, 0, info.arrayLayers); |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 747 | } |
| 748 | |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 749 | inline VkImageSubresourceRange Image::subresource_range(const VkImageSubresource &subres) { |
| 750 | return subresource_range(subres.aspectMask, subres.mipLevel, 1, subres.arrayLayer, 1); |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 751 | } |
| 752 | |
| Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 753 | inline VkExtent2D Image::extent(int32_t width, int32_t height) { |
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 754 | VkExtent2D extent = {}; |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 755 | extent.width = width; |
| 756 | extent.height = height; |
| 757 | return extent; |
| 758 | } |
| 759 | |
| Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 760 | inline VkExtent2D Image::extent(const VkExtent2D &extent, uint32_t mip_level) { |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 761 | const int32_t width = (extent.width >> mip_level) ? extent.width >> mip_level : 1; |
| 762 | const int32_t height = (extent.height >> mip_level) ? extent.height >> mip_level : 1; |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 763 | return Image::extent(width, height); |
| 764 | } |
| 765 | |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 766 | inline VkExtent2D Image::extent(const VkExtent3D &extent) { return Image::extent(extent.width, extent.height); } |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 767 | |
| Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 768 | inline VkExtent3D Image::extent(int32_t width, int32_t height, int32_t depth) { |
| Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 769 | VkExtent3D extent = {}; |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 770 | extent.width = width; |
| 771 | extent.height = height; |
| 772 | extent.depth = depth; |
| 773 | return extent; |
| 774 | } |
| 775 | |
| Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 776 | inline VkExtent3D Image::extent(const VkExtent3D &extent, uint32_t mip_level) { |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 777 | const int32_t width = (extent.width >> mip_level) ? extent.width >> mip_level : 1; |
| 778 | const int32_t height = (extent.height >> mip_level) ? extent.height >> mip_level : 1; |
| 779 | const int32_t depth = (extent.depth >> mip_level) ? extent.depth >> mip_level : 1; |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 780 | return Image::extent(width, height, depth); |
| 781 | } |
| 782 | |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 783 | inline VkShaderModuleCreateInfo ShaderModule::create_info(size_t code_size, const uint32_t *code, VkFlags flags) { |
| Courtney Goeltzenleuchter | ee4027d | 2015-06-28 13:01:17 -0600 | [diff] [blame] | 784 | VkShaderModuleCreateInfo info = {}; |
| 785 | info.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 786 | info.codeSize = code_size; |
| 787 | info.pCode = code; |
| 788 | info.flags = flags; |
| 789 | return info; |
| 790 | } |
| 791 | |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 792 | inline VkWriteDescriptorSet Device::write_descriptor_set(const DescriptorSet &set, uint32_t binding, uint32_t array_element, |
| 793 | VkDescriptorType type, uint32_t count, |
| 794 | const VkDescriptorImageInfo *image_info) { |
| Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 795 | VkWriteDescriptorSet write = {}; |
| 796 | write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 797 | write.dstSet = set.handle(); |
| 798 | write.dstBinding = binding; |
| 799 | write.dstArrayElement = array_element; |
| Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 800 | write.descriptorCount = count; |
| Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 801 | write.descriptorType = type; |
| Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 802 | write.pImageInfo = image_info; |
| Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 803 | return write; |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 804 | } |
| 805 | |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [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, |
| 808 | const VkDescriptorBufferInfo *buffer_info) { |
| Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 809 | VkWriteDescriptorSet write = {}; |
| 810 | write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 811 | write.dstSet = set.handle(); |
| 812 | write.dstBinding = binding; |
| 813 | write.dstArrayElement = array_element; |
| Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 814 | write.descriptorCount = count; |
| Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 815 | write.descriptorType = type; |
| 816 | write.pBufferInfo = buffer_info; |
| 817 | return write; |
| 818 | } |
| 819 | |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 820 | inline VkWriteDescriptorSet Device::write_descriptor_set(const DescriptorSet &set, uint32_t binding, uint32_t array_element, |
| 821 | VkDescriptorType type, uint32_t count, const VkBufferView *buffer_views) { |
| Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 822 | VkWriteDescriptorSet write = {}; |
| 823 | write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 824 | write.dstSet = set.handle(); |
| 825 | write.dstBinding = binding; |
| 826 | write.dstArrayElement = array_element; |
| Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 827 | write.descriptorCount = count; |
| Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 828 | write.descriptorType = type; |
| 829 | write.pTexelBufferView = buffer_views; |
| 830 | return write; |
| 831 | } |
| 832 | |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 833 | inline VkWriteDescriptorSet Device::write_descriptor_set(const DescriptorSet &set, uint32_t binding, uint32_t array_element, |
| 834 | VkDescriptorType type, |
| 835 | const std::vector<VkDescriptorImageInfo> &image_info) { |
| 836 | return write_descriptor_set(set, binding, array_element, type, image_info.size(), &image_info[0]); |
| Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 837 | } |
| 838 | |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 839 | inline VkWriteDescriptorSet Device::write_descriptor_set(const DescriptorSet &set, uint32_t binding, uint32_t array_element, |
| 840 | VkDescriptorType type, |
| 841 | const std::vector<VkDescriptorBufferInfo> &buffer_info) { |
| 842 | return write_descriptor_set(set, binding, array_element, type, buffer_info.size(), &buffer_info[0]); |
| Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 843 | } |
| 844 | |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 845 | inline VkWriteDescriptorSet Device::write_descriptor_set(const DescriptorSet &set, uint32_t binding, uint32_t array_element, |
| 846 | VkDescriptorType type, const std::vector<VkBufferView> &buffer_views) { |
| 847 | return write_descriptor_set(set, binding, array_element, type, buffer_views.size(), &buffer_views[0]); |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 848 | } |
| 849 | |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 850 | inline VkCopyDescriptorSet Device::copy_descriptor_set(const DescriptorSet &src_set, uint32_t src_binding, |
| 851 | uint32_t src_array_element, const DescriptorSet &dst_set, |
| 852 | uint32_t dst_binding, uint32_t dst_array_element, uint32_t count) { |
| Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 853 | VkCopyDescriptorSet copy = {}; |
| 854 | copy.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| Chia-I Wu | afdfd7f | 2015-07-03 11:49:42 +0800 | [diff] [blame] | 855 | copy.srcSet = src_set.handle(); |
| Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 856 | copy.srcBinding = src_binding; |
| 857 | copy.srcArrayElement = src_array_element; |
| Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 858 | copy.dstSet = dst_set.handle(); |
| 859 | copy.dstBinding = dst_binding; |
| 860 | copy.dstArrayElement = dst_array_element; |
| Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 861 | copy.descriptorCount = count; |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 862 | |
| Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 863 | return copy; |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 864 | } |
| 865 | |
| Mark Lobodzinski | 722841d | 2016-09-07 16:34:56 -0600 | [diff] [blame] | 866 | inline VkCommandBufferAllocateInfo CommandBuffer::create_info(VkCommandPool const &pool) { |
| Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 867 | VkCommandBufferAllocateInfo info = {}; |
| Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 868 | info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 869 | info.commandPool = pool; |
| Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 870 | info.commandBufferCount = 1; |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 871 | return info; |
| 872 | } |
| 873 | |
| Petr Kraus | 13c98a6 | 2017-12-09 00:22:39 +0100 | [diff] [blame^] | 874 | } // namespace vk_testing |
| Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 875 | |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 876 | #endif // VKTESTBINDING_H |