* Author: Tony Barbour <tony@LunarG.com>
*/
-#include <iostream>
-#include <string.h> // memset(), memcmp()
+#include "vktestbinding.h"
#include <assert.h>
+#include <iostream>
#include <stdarg.h>
-#include "vktestbinding.h"
+#include <string.h> // memset(), memcmp()
namespace {
-#define NON_DISPATCHABLE_HANDLE_INIT(create_func, dev, ...) \
- do { \
- handle_type handle; \
- if (EXPECT(create_func(dev.handle(), __VA_ARGS__, NULL, &handle) == \
- VK_SUCCESS)) \
- NonDispHandle::init(dev.handle(), handle); \
+#define NON_DISPATCHABLE_HANDLE_INIT(create_func, dev, ...) \
+ do { \
+ handle_type handle; \
+ if (EXPECT(create_func(dev.handle(), __VA_ARGS__, NULL, &handle) == VK_SUCCESS)) \
+ NonDispHandle::init(dev.handle(), handle); \
} while (0)
-#define NON_DISPATCHABLE_HANDLE_DTOR(cls, destroy_func) \
- cls::~cls() { \
- if (initialized()) \
- destroy_func(device(), handle(), NULL); \
+#define NON_DISPATCHABLE_HANDLE_DTOR(cls, destroy_func) \
+ cls::~cls() { \
+ if (initialized()) \
+ destroy_func(device(), handle(), NULL); \
}
#define STRINGIFY(x) #x
-#define EXPECT(expr) \
- ((expr) ? true : expect_failure(STRINGIFY(expr), __FILE__, __LINE__, \
- __FUNCTION__))
+#define EXPECT(expr) ((expr) ? true : expect_failure(STRINGIFY(expr), __FILE__, __LINE__, __FUNCTION__))
vk_testing::ErrorCallback error_callback;
-bool expect_failure(const char *expr, const char *file, unsigned int line,
- const char *function) {
+bool expect_failure(const char *expr, const char *file, unsigned int line, const char *function) {
if (error_callback) {
error_callback(expr, file, line, function);
} else {
- std::cerr << file << ":" << line << ": " << function
- << ": Expectation `" << expr << "' failed.\n";
+ std::cerr << file << ":" << line << ": " << function << ": Expectation `" << expr << "' failed.\n";
}
return false;
}
-template <class T, class S>
-std::vector<T> make_handles(const std::vector<S> &v) {
+template <class T, class S> std::vector<T> make_handles(const std::vector<S> &v) {
std::vector<T> handles;
handles.reserve(v.size());
- for (typename std::vector<S>::const_iterator it = v.begin(); it != v.end();
- it++)
+ for (typename std::vector<S>::const_iterator it = v.begin(); it != v.end(); it++)
handles.push_back((*it)->handle());
return handles;
}
-VkMemoryAllocateInfo get_resource_alloc_info(const vk_testing::Device &dev,
- const VkMemoryRequirements &reqs,
+VkMemoryAllocateInfo get_resource_alloc_info(const vk_testing::Device &dev, const VkMemoryRequirements &reqs,
VkMemoryPropertyFlags mem_props) {
- VkMemoryAllocateInfo info =
- vk_testing::DeviceMemory::alloc_info(reqs.size, 0);
+ VkMemoryAllocateInfo info = vk_testing::DeviceMemory::alloc_info(reqs.size, 0);
dev.phy().set_memory_type(reqs.memoryTypeBits, &info, mem_props);
return info;
if (err == VK_SUCCESS) {
layers.reserve(layer_count);
- err =
- vkEnumerateInstanceLayerProperties(&layer_count, layers.data());
+ err = vkEnumerateInstanceLayerProperties(&layer_count, layers.data());
}
} while (err == VK_INCOMPLETE);
/*
* Return list of Global extensions provided by the ICD / Loader
*/
-std::vector<VkExtensionProperties> GetGlobalExtensions() {
- return GetGlobalExtensions(NULL);
-}
+std::vector<VkExtensionProperties> GetGlobalExtensions() { return GetGlobalExtensions(NULL); }
/*
* Return list of Global extensions provided by the specified layer
do {
ext_count = 0;
- err = vkEnumerateInstanceExtensionProperties(pLayerName, &ext_count,
- NULL);
+ err = vkEnumerateInstanceExtensionProperties(pLayerName, &ext_count, NULL);
if (err == VK_SUCCESS) {
exts.resize(ext_count);
- err = vkEnumerateInstanceExtensionProperties(pLayerName, &ext_count,
- exts.data());
+ err = vkEnumerateInstanceExtensionProperties(pLayerName, &ext_count, exts.data());
}
} while (err == VK_INCOMPLETE);
/*
* Return list of PhysicalDevice extensions provided by the ICD / Loader
*/
-std::vector<VkExtensionProperties> PhysicalDevice::extensions() const {
- return extensions(NULL);
-}
+std::vector<VkExtensionProperties> PhysicalDevice::extensions() const { return extensions(NULL); }
/*
* Return list of PhysicalDevice extensions provided by the specified layer
* If pLayerName is NULL, will return extensions for ICD / loader.
*/
-std::vector<VkExtensionProperties>
-PhysicalDevice::extensions(const char *pLayerName) const {
+std::vector<VkExtensionProperties> PhysicalDevice::extensions(const char *pLayerName) const {
std::vector<VkExtensionProperties> exts;
VkResult err;
do {
uint32_t extCount = 0;
- err = vkEnumerateDeviceExtensionProperties(handle(), pLayerName,
- &extCount, NULL);
+ err = vkEnumerateDeviceExtensionProperties(handle(), pLayerName, &extCount, NULL);
if (err == VK_SUCCESS) {
exts.resize(extCount);
- err = vkEnumerateDeviceExtensionProperties(handle(), pLayerName,
- &extCount, exts.data());
+ err = vkEnumerateDeviceExtensionProperties(handle(), pLayerName, &extCount, exts.data());
}
} while (err == VK_INCOMPLETE);
return exts;
}
-bool PhysicalDevice::set_memory_type(const uint32_t type_bits,
- VkMemoryAllocateInfo *info,
- const VkFlags properties,
+bool PhysicalDevice::set_memory_type(const uint32_t type_bits, VkMemoryAllocateInfo *info, const VkFlags properties,
const VkFlags forbid) const {
uint32_t type_mask = type_bits;
// Search memtypes to find first index with those properties
for (uint32_t i = 0; i < memory_properties_.memoryTypeCount; i++) {
if ((type_mask & 1) == 1) {
// Type is available, does it match user properties?
- if ((memory_properties_.memoryTypes[i].propertyFlags &
- properties) == properties &&
- (memory_properties_.memoryTypes[i].propertyFlags & forbid) ==
- 0) {
+ if ((memory_properties_.memoryTypes[i].propertyFlags & properties) == properties &&
+ (memory_properties_.memoryTypes[i].propertyFlags & forbid) == 0) {
info->memoryTypeIndex = i;
return true;
}
if (err == VK_SUCCESS) {
layer_props.reserve(layer_count);
- err = vkEnumerateDeviceLayerProperties(handle(), &layer_count,
- layer_props.data());
+ err = vkEnumerateDeviceLayerProperties(handle(), &layer_count, layer_props.data());
}
} while (err == VK_INCOMPLETE);
return;
for (int i = 0; i < QUEUE_COUNT; i++) {
- for (std::vector<Queue *>::iterator it = queues_[i].begin();
- it != queues_[i].end(); it++)
+ for (std::vector<Queue *>::iterator it = queues_[i].begin(); it != queues_[i].end(); it++)
delete *it;
queues_[i].clear();
}
void Device::init(std::vector<const char *> &extensions, VkPhysicalDeviceFeatures *features) {
// request all queues
- const std::vector<VkQueueFamilyProperties> queue_props =
- phy_.queue_properties();
+ const std::vector<VkQueueFamilyProperties> queue_props = phy_.queue_properties();
std::vector<VkDeviceQueueCreateInfo> queue_info;
queue_info.reserve(queue_props.size());
uint32_t queue_node_count;
// Call with NULL data to get count
- vkGetPhysicalDeviceQueueFamilyProperties(phy_.handle(), &queue_node_count,
- NULL);
+ vkGetPhysicalDeviceQueueFamilyProperties(phy_.handle(), &queue_node_count, NULL);
EXPECT(queue_node_count >= 1);
- VkQueueFamilyProperties *queue_props =
- new VkQueueFamilyProperties[queue_node_count];
+ VkQueueFamilyProperties *queue_props = new VkQueueFamilyProperties[queue_node_count];
- vkGetPhysicalDeviceQueueFamilyProperties(phy_.handle(), &queue_node_count,
- queue_props);
+ vkGetPhysicalDeviceQueueFamilyProperties(phy_.handle(), &queue_node_count, queue_props);
for (uint32_t i = 0; i < queue_node_count; i++) {
VkQueue queue;
const VkFormatProperties props = format_properties(fmt);
if (props.linearTilingFeatures) {
- const Format tmp = {fmt, VK_IMAGE_TILING_LINEAR,
- props.linearTilingFeatures};
+ const Format tmp = {fmt, VK_IMAGE_TILING_LINEAR, props.linearTilingFeatures};
formats_.push_back(tmp);
}
if (props.optimalTilingFeatures) {
- const Format tmp = {fmt, VK_IMAGE_TILING_OPTIMAL,
- props.optimalTilingFeatures};
+ const Format tmp = {fmt, VK_IMAGE_TILING_OPTIMAL, props.optimalTilingFeatures};
formats_.push_back(tmp);
}
}
void Device::wait() { EXPECT(vkDeviceWaitIdle(handle()) == VK_SUCCESS); }
-VkResult Device::wait(const std::vector<const Fence *> &fences, bool wait_all,
- uint64_t timeout) {
+VkResult Device::wait(const std::vector<const Fence *> &fences, bool wait_all, uint64_t timeout) {
const std::vector<VkFence> fence_handles = make_handles<VkFence>(fences);
- VkResult err = vkWaitForFences(handle(), fence_handles.size(),
- fence_handles.data(), wait_all, timeout);
+ VkResult err = vkWaitForFences(handle(), fence_handles.size(), fence_handles.data(), wait_all, timeout);
EXPECT(err == VK_SUCCESS || err == VK_TIMEOUT);
return err;
}
-void Device::update_descriptor_sets(
- const std::vector<VkWriteDescriptorSet> &writes,
- const std::vector<VkCopyDescriptorSet> &copies) {
- vkUpdateDescriptorSets(handle(), writes.size(), writes.data(),
- copies.size(), copies.data());
+void Device::update_descriptor_sets(const std::vector<VkWriteDescriptorSet> &writes,
+ const std::vector<VkCopyDescriptorSet> &copies) {
+ vkUpdateDescriptorSets(handle(), writes.size(), writes.data(), copies.size(), copies.data());
}
-void Queue::submit(const std::vector<const CommandBuffer *> &cmds,
- Fence &fence) {
- const std::vector<VkCommandBuffer> cmd_handles =
- make_handles<VkCommandBuffer>(cmds);
+void Queue::submit(const std::vector<const CommandBuffer *> &cmds, Fence &fence) {
+ const std::vector<VkCommandBuffer> cmd_handles = make_handles<VkCommandBuffer>(cmds);
VkSubmitInfo submit_info;
submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
submit_info.pNext = NULL;
submit_info.signalSemaphoreCount = 0;
submit_info.pSignalSemaphores = NULL;
- EXPECT(vkQueueSubmit(handle(), 1, &submit_info, fence.handle()) ==
- VK_SUCCESS);
+ EXPECT(vkQueueSubmit(handle(), 1, &submit_info, fence.handle()) == VK_SUCCESS);
}
-void Queue::submit(const CommandBuffer &cmd, Fence &fence) {
- submit(std::vector<const CommandBuffer *>(1, &cmd), fence);
-}
+void Queue::submit(const CommandBuffer &cmd, Fence &fence) { submit(std::vector<const CommandBuffer *>(1, &cmd), fence); }
void Queue::submit(const CommandBuffer &cmd) {
Fence fence;
const void *DeviceMemory::map(VkFlags flags) const {
void *data;
- if (!EXPECT(vkMapMemory(device(), handle(), 0, VK_WHOLE_SIZE, flags,
- &data) == VK_SUCCESS))
+ if (!EXPECT(vkMapMemory(device(), handle(), 0, VK_WHOLE_SIZE, flags, &data) == VK_SUCCESS))
data = NULL;
return data;
void *DeviceMemory::map(VkFlags flags) {
void *data;
- if (!EXPECT(vkMapMemory(device(), handle(), 0, VK_WHOLE_SIZE, flags,
- &data) == VK_SUCCESS))
+ if (!EXPECT(vkMapMemory(device(), handle(), 0, VK_WHOLE_SIZE, flags, &data) == VK_SUCCESS))
data = NULL;
return data;
NON_DISPATCHABLE_HANDLE_DTOR(Fence, vkDestroyFence)
-void Fence::init(const Device &dev, const VkFenceCreateInfo &info) {
- NON_DISPATCHABLE_HANDLE_INIT(vkCreateFence, dev, &info);
-}
+void Fence::init(const Device &dev, const VkFenceCreateInfo &info) { NON_DISPATCHABLE_HANDLE_INIT(vkCreateFence, dev, &info); }
NON_DISPATCHABLE_HANDLE_DTOR(Semaphore, vkDestroySemaphore)
NON_DISPATCHABLE_HANDLE_DTOR(Event, vkDestroyEvent)
-void Event::init(const Device &dev, const VkEventCreateInfo &info) {
- NON_DISPATCHABLE_HANDLE_INIT(vkCreateEvent, dev, &info);
-}
+void Event::init(const Device &dev, const VkEventCreateInfo &info) { NON_DISPATCHABLE_HANDLE_INIT(vkCreateEvent, dev, &info); }
void Event::set() { EXPECT(vkSetEvent(device(), handle()) == VK_SUCCESS); }
NON_DISPATCHABLE_HANDLE_INIT(vkCreateQueryPool, dev, &info);
}
-VkResult QueryPool::results(uint32_t first, uint32_t count, size_t size,
- void *data, size_t stride) {
- VkResult err = vkGetQueryPoolResults(device(), handle(), first, count, size,
- data, stride, 0);
+VkResult QueryPool::results(uint32_t first, uint32_t count, size_t size, void *data, size_t stride) {
+ VkResult err = vkGetQueryPoolResults(device(), handle(), first, count, size, data, stride, 0);
EXPECT(err == VK_SUCCESS || err == VK_NOT_READY);
return err;
NON_DISPATCHABLE_HANDLE_DTOR(Buffer, vkDestroyBuffer)
-void Buffer::init(const Device &dev, const VkBufferCreateInfo &info,
- VkMemoryPropertyFlags mem_props) {
+void Buffer::init(const Device &dev, const VkBufferCreateInfo &info, VkMemoryPropertyFlags mem_props) {
init_no_mem(dev, info);
- internal_mem_.init(
- dev, get_resource_alloc_info(dev, memory_requirements(), mem_props));
+ internal_mem_.init(dev, get_resource_alloc_info(dev, memory_requirements(), mem_props));
bind_memory(internal_mem_, 0);
}
}
void Buffer::bind_memory(const DeviceMemory &mem, VkDeviceSize mem_offset) {
- EXPECT(vkBindBufferMemory(device(), handle(), mem.handle(), mem_offset) ==
- VK_SUCCESS);
+ EXPECT(vkBindBufferMemory(device(), handle(), mem.handle(), mem_offset) == VK_SUCCESS);
}
NON_DISPATCHABLE_HANDLE_DTOR(BufferView, vkDestroyBufferView)
NON_DISPATCHABLE_HANDLE_DTOR(Image, vkDestroyImage)
-void Image::init(const Device &dev, const VkImageCreateInfo &info,
- VkMemoryPropertyFlags mem_props) {
+void Image::init(const Device &dev, const VkImageCreateInfo &info, VkMemoryPropertyFlags mem_props) {
init_no_mem(dev, info);
if (initialized()) {
- internal_mem_.init(
- dev, get_resource_alloc_info(dev, memory_requirements(), mem_props));
+ internal_mem_.init(dev, get_resource_alloc_info(dev, memory_requirements(), mem_props));
bind_memory(internal_mem_, 0);
}
}
void Image::init_info(const Device &dev, const VkImageCreateInfo &info) {
create_info_ = info;
- for (std::vector<Device::Format>::const_iterator it = dev.formats().begin();
- it != dev.formats().end(); it++) {
- if (memcmp(&it->format, &create_info_.format, sizeof(it->format)) ==
- 0 &&
- it->tiling == create_info_.tiling) {
+ for (std::vector<Device::Format>::const_iterator it = dev.formats().begin(); it != dev.formats().end(); it++) {
+ if (memcmp(&it->format, &create_info_.format, sizeof(it->format)) == 0 && it->tiling == create_info_.tiling) {
format_features_ = it->features;
break;
}
}
void Image::bind_memory(const DeviceMemory &mem, VkDeviceSize mem_offset) {
- EXPECT(vkBindImageMemory(device(), handle(), mem.handle(), mem_offset) ==
- VK_SUCCESS);
+ EXPECT(vkBindImageMemory(device(), handle(), mem.handle(), mem_offset) == VK_SUCCESS);
}
-VkSubresourceLayout
-Image::subresource_layout(const VkImageSubresource &subres) const {
+VkSubresourceLayout Image::subresource_layout(const VkImageSubresource &subres) const {
VkSubresourceLayout data;
size_t size = sizeof(data);
vkGetImageSubresourceLayout(device(), handle(), &subres, &data);
return data;
}
-VkSubresourceLayout
-Image::subresource_layout(const VkImageSubresourceLayers &subrescopy) const {
+VkSubresourceLayout Image::subresource_layout(const VkImageSubresourceLayers &subrescopy) const {
VkSubresourceLayout data;
- VkImageSubresource subres =
- subresource(subrescopy.aspectMask, subrescopy.mipLevel,
- subrescopy.baseArrayLayer);
+ VkImageSubresource subres = subresource(subrescopy.aspectMask, subrescopy.mipLevel, subrescopy.baseArrayLayer);
size_t size = sizeof(data);
vkGetImageSubresourceLayout(device(), handle(), &subres, &data);
if (size != sizeof(data))
}
bool Image::transparent() const {
- return (
- create_info_.tiling == VK_IMAGE_TILING_LINEAR &&
- create_info_.samples == VK_SAMPLE_COUNT_1_BIT &&
- !(create_info_.usage & (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT |
- VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT)));
+ return (create_info_.tiling == VK_IMAGE_TILING_LINEAR && create_info_.samples == VK_SAMPLE_COUNT_1_BIT &&
+ !(create_info_.usage & (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT)));
}
NON_DISPATCHABLE_HANDLE_DTOR(ImageView, vkDestroyImageView)
NON_DISPATCHABLE_HANDLE_DTOR(ShaderModule, vkDestroyShaderModule)
-void ShaderModule::init(const Device &dev,
- const VkShaderModuleCreateInfo &info) {
+void ShaderModule::init(const Device &dev, const VkShaderModuleCreateInfo &info) {
NON_DISPATCHABLE_HANDLE_INIT(vkCreateShaderModule, dev, &info);
}
-VkResult ShaderModule::init_try(const Device &dev,
- const VkShaderModuleCreateInfo &info) {
+VkResult ShaderModule::init_try(const Device &dev, const VkShaderModuleCreateInfo &info) {
VkShaderModule mod;
VkResult err = vkCreateShaderModule(dev.handle(), &info, NULL, &mod);
NON_DISPATCHABLE_HANDLE_DTOR(Pipeline, vkDestroyPipeline)
-void Pipeline::init(const Device &dev,
- const VkGraphicsPipelineCreateInfo &info) {
+void Pipeline::init(const Device &dev, const VkGraphicsPipelineCreateInfo &info) {
VkPipelineCache cache;
VkPipelineCacheCreateInfo ci;
memset((void *)&ci, 0, sizeof(VkPipelineCacheCreateInfo));
ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO;
VkResult err = vkCreatePipelineCache(dev.handle(), &ci, NULL, &cache);
if (err == VK_SUCCESS) {
- NON_DISPATCHABLE_HANDLE_INIT(vkCreateGraphicsPipelines, dev, cache, 1,
- &info);
+ NON_DISPATCHABLE_HANDLE_INIT(vkCreateGraphicsPipelines, dev, cache, 1, &info);
vkDestroyPipelineCache(dev.handle(), cache, NULL);
}
}
-VkResult Pipeline::init_try(const Device &dev,
- const VkGraphicsPipelineCreateInfo &info) {
+VkResult Pipeline::init_try(const Device &dev, const VkGraphicsPipelineCreateInfo &info) {
VkPipeline pipe;
VkPipelineCache cache;
VkPipelineCacheCreateInfo ci;
VkResult err = vkCreatePipelineCache(dev.handle(), &ci, NULL, &cache);
EXPECT(err == VK_SUCCESS);
if (err == VK_SUCCESS) {
- err = vkCreateGraphicsPipelines(dev.handle(), cache, 1, &info, NULL,
- &pipe);
+ err = vkCreateGraphicsPipelines(dev.handle(), cache, 1, &info, NULL, &pipe);
if (err == VK_SUCCESS) {
NonDispHandle::init(dev.handle(), pipe);
}
return err;
}
-void Pipeline::init(const Device &dev,
- const VkComputePipelineCreateInfo &info) {
+void Pipeline::init(const Device &dev, const VkComputePipelineCreateInfo &info) {
VkPipelineCache cache;
VkPipelineCacheCreateInfo ci;
memset((void *)&ci, 0, sizeof(VkPipelineCacheCreateInfo));
ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO;
VkResult err = vkCreatePipelineCache(dev.handle(), &ci, NULL, &cache);
if (err == VK_SUCCESS) {
- NON_DISPATCHABLE_HANDLE_INIT(vkCreateComputePipelines, dev, cache, 1,
- &info);
+ NON_DISPATCHABLE_HANDLE_INIT(vkCreateComputePipelines, dev, cache, 1, &info);
vkDestroyPipelineCache(dev.handle(), cache, NULL);
}
}
NON_DISPATCHABLE_HANDLE_DTOR(PipelineLayout, vkDestroyPipelineLayout)
-void PipelineLayout::init(
- const Device &dev, VkPipelineLayoutCreateInfo &info,
- const std::vector<const DescriptorSetLayout *> &layouts) {
- const std::vector<VkDescriptorSetLayout> layout_handles =
- make_handles<VkDescriptorSetLayout>(layouts);
+void PipelineLayout::init(const Device &dev, VkPipelineLayoutCreateInfo &info,
+ const std::vector<const DescriptorSetLayout *> &layouts) {
+ const std::vector<VkDescriptorSetLayout> layout_handles = make_handles<VkDescriptorSetLayout>(layouts);
info.pSetLayouts = layout_handles.data();
NON_DISPATCHABLE_HANDLE_INIT(vkCreatePipelineLayout, dev, &info);
NON_DISPATCHABLE_HANDLE_DTOR(DescriptorSetLayout, vkDestroyDescriptorSetLayout)
-void DescriptorSetLayout::init(const Device &dev,
- const VkDescriptorSetLayoutCreateInfo &info) {
+void DescriptorSetLayout::init(const Device &dev, const VkDescriptorSetLayoutCreateInfo &info) {
NON_DISPATCHABLE_HANDLE_INIT(vkCreateDescriptorSetLayout, dev, &info);
}
NON_DISPATCHABLE_HANDLE_DTOR(DescriptorPool, vkDestroyDescriptorPool)
-void DescriptorPool::init(const Device &dev,
- const VkDescriptorPoolCreateInfo &info) {
- setDynamicUsage(info.flags &
- VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT);
+void DescriptorPool::init(const Device &dev, const VkDescriptorPoolCreateInfo &info) {
+ setDynamicUsage(info.flags & VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT);
NON_DISPATCHABLE_HANDLE_INIT(vkCreateDescriptorPool, dev, &info);
}
-void DescriptorPool::reset() {
- EXPECT(vkResetDescriptorPool(device(), handle(), 0) == VK_SUCCESS);
-}
+void DescriptorPool::reset() { EXPECT(vkResetDescriptorPool(device(), handle(), 0) == VK_SUCCESS); }
-std::vector<DescriptorSet *> DescriptorPool::alloc_sets(
- const Device &dev,
- const std::vector<const DescriptorSetLayout *> &layouts) {
- const std::vector<VkDescriptorSetLayout> layout_handles =
- make_handles<VkDescriptorSetLayout>(layouts);
+std::vector<DescriptorSet *> DescriptorPool::alloc_sets(const Device &dev,
+ const std::vector<const DescriptorSetLayout *> &layouts) {
+ const std::vector<VkDescriptorSetLayout> layout_handles = make_handles<VkDescriptorSetLayout>(layouts);
std::vector<VkDescriptorSet> set_handles;
set_handles.resize(layout_handles.size());
alloc_info.descriptorSetCount = layout_handles.size();
alloc_info.descriptorPool = handle();
alloc_info.pSetLayouts = layout_handles.data();
- VkResult err =
- vkAllocateDescriptorSets(device(), &alloc_info, set_handles.data());
+ VkResult err = vkAllocateDescriptorSets(device(), &alloc_info, set_handles.data());
EXPECT(err == VK_SUCCESS);
std::vector<DescriptorSet *> sets;
- for (std::vector<VkDescriptorSet>::const_iterator it = set_handles.begin();
- it != set_handles.end(); it++) {
+ for (std::vector<VkDescriptorSet>::const_iterator it = set_handles.begin(); it != set_handles.end(); it++) {
// do descriptor sets need memories bound?
DescriptorSet *descriptorSet = new DescriptorSet(dev, this, *it);
sets.push_back(descriptorSet);
return sets;
}
-std::vector<DescriptorSet *>
-DescriptorPool::alloc_sets(const Device &dev, const DescriptorSetLayout &layout,
- uint32_t count) {
- return alloc_sets(dev,
- std::vector<const DescriptorSetLayout *>(count, &layout));
+std::vector<DescriptorSet *> DescriptorPool::alloc_sets(const Device &dev, const DescriptorSetLayout &layout, uint32_t count) {
+ return alloc_sets(dev, std::vector<const DescriptorSetLayout *>(count, &layout));
}
-DescriptorSet *DescriptorPool::alloc_sets(const Device &dev,
- const DescriptorSetLayout &layout) {
+DescriptorSet *DescriptorPool::alloc_sets(const Device &dev, const DescriptorSetLayout &layout) {
std::vector<DescriptorSet *> set = alloc_sets(dev, layout, 1);
return (set.empty()) ? NULL : set[0];
}
// Only call vkFree* on sets allocated from pool with usage *_DYNAMIC
if (containing_pool_->getDynamicUsage()) {
VkDescriptorSet sets[1] = {handle()};
- EXPECT(vkFreeDescriptorSets(device(), containing_pool_->GetObj(), 1,
- sets) == VK_SUCCESS);
+ EXPECT(vkFreeDescriptorSets(device(), containing_pool_->GetObj(), 1, sets) == VK_SUCCESS);
}
}
}
}
}
-void CommandBuffer::init(const Device &dev,
- const VkCommandBufferAllocateInfo &info) {
+void CommandBuffer::init(const Device &dev, const VkCommandBufferAllocateInfo &info) {
VkCommandBuffer cmd;
// Make sure commandPool is set
assert(info.commandPool);
- if (EXPECT(vkAllocateCommandBuffers(dev.handle(), &info, &cmd) ==
- VK_SUCCESS)) {
+ if (EXPECT(vkAllocateCommandBuffers(dev.handle(), &info, &cmd) == VK_SUCCESS)) {
Handle::init(cmd);
dev_handle_ = dev.handle();
cmd_pool_ = info.commandPool;
}
}
-void CommandBuffer::begin(const VkCommandBufferBeginInfo *info) {
- EXPECT(vkBeginCommandBuffer(handle(), info) == VK_SUCCESS);
-}
+void CommandBuffer::begin(const VkCommandBufferBeginInfo *info) { EXPECT(vkBeginCommandBuffer(handle(), info) == VK_SUCCESS); }
void CommandBuffer::begin() {
VkCommandBufferBeginInfo info = {};
begin(&info);
}
-void CommandBuffer::end() {
- EXPECT(vkEndCommandBuffer(handle()) == VK_SUCCESS);
-}
+void CommandBuffer::end() { EXPECT(vkEndCommandBuffer(handle()) == VK_SUCCESS); }
-void CommandBuffer::reset(VkCommandBufferResetFlags flags) {
- EXPECT(vkResetCommandBuffer(handle(), flags) == VK_SUCCESS);
-}
+void CommandBuffer::reset(VkCommandBufferResetFlags flags) { EXPECT(vkResetCommandBuffer(handle(), flags) == VK_SUCCESS); }
}; // namespace vk_testing
#ifndef VKTESTBINDING_H
#define VKTESTBINDING_H
-#include <vector>
#include <assert.h>
+#include <vector>
#include "vulkan/vulkan.h"
namespace vk_testing {
-typedef void (*ErrorCallback)(const char *expr, const char *file,
- unsigned int line, const char *function);
+typedef void (*ErrorCallback)(const char *expr, const char *file, unsigned int line, const char *function);
void set_error_callback(ErrorCallback callback);
class PhysicalDevice;
template <typename T> class NonDispHandle : public Handle<T> {
protected:
explicit NonDispHandle() : Handle<T>(), dev_handle_(VK_NULL_HANDLE) {}
- explicit NonDispHandle(VkDevice dev, T handle)
- : Handle<T>(handle), dev_handle_(dev) {}
+ explicit NonDispHandle(VkDevice dev, T handle) : Handle<T>(handle), dev_handle_(dev) {}
const VkDevice &device() const { return dev_handle_; }
std::vector<VkQueueFamilyProperties> queue_properties() const;
VkPhysicalDeviceFeatures features() const;
- bool set_memory_type(const uint32_t type_bits, VkMemoryAllocateInfo *info,
- const VkMemoryPropertyFlags properties,
+ bool set_memory_type(const uint32_t type_bits, VkMemoryAllocateInfo *info, const VkMemoryPropertyFlags properties,
const VkMemoryPropertyFlags forbid = 0) const;
// vkEnumerateDeviceExtensionProperties()
std::vector<VkLayerProperties> layers() const;
private:
- void
- add_extension_dependencies(uint32_t dependency_count,
- VkExtensionProperties *depencency_props,
- std::vector<VkExtensionProperties> &ext_list);
+ void add_extension_dependencies(uint32_t dependency_count, VkExtensionProperties *depencency_props,
+ std::vector<VkExtensionProperties> &ext_list);
VkPhysicalDeviceMemoryProperties memory_properties_;
// vkCreateDevice()
void init(const VkDeviceCreateInfo &info);
- void init(std::vector<const char *>
- &extensions, VkPhysicalDeviceFeatures *features = nullptr); // all queues, all extensions, etc
+ void init(std::vector<const char *> &extensions,
+ VkPhysicalDeviceFeatures *features = nullptr); // all queues, all extensions, etc
void init() {
std::vector<const char *> extensions;
init(extensions);
const PhysicalDevice &phy() const { return phy_; }
// vkGetDeviceProcAddr()
- PFN_vkVoidFunction get_proc(const char *name) const {
- return vkGetDeviceProcAddr(handle(), name);
- }
+ PFN_vkVoidFunction get_proc(const char *name) const { return vkGetDeviceProcAddr(handle(), name); }
// vkGetDeviceQueue()
- const std::vector<Queue *> &graphics_queues() const {
- return queues_[GRAPHICS];
- }
+ const std::vector<Queue *> &graphics_queues() const { return queues_[GRAPHICS]; }
const std::vector<Queue *> &compute_queues() { return queues_[COMPUTE]; }
const std::vector<Queue *> &dma_queues() { return queues_[DMA]; }
uint32_t graphics_queue_node_index_;
void wait();
// vkWaitForFences()
- VkResult wait(const std::vector<const Fence *> &fences, bool wait_all,
- uint64_t timeout);
- VkResult wait(const Fence &fence) {
- return wait(std::vector<const Fence *>(1, &fence), true, (uint64_t)-1);
- }
+ VkResult wait(const std::vector<const Fence *> &fences, bool wait_all, uint64_t timeout);
+ VkResult wait(const Fence &fence) { return wait(std::vector<const Fence *>(1, &fence), true, (uint64_t)-1); }
// vkUpdateDescriptorSets()
- void update_descriptor_sets(const std::vector<VkWriteDescriptorSet> &writes,
- const std::vector<VkCopyDescriptorSet> &copies);
- void
- update_descriptor_sets(const std::vector<VkWriteDescriptorSet> &writes) {
- return update_descriptor_sets(writes,
- std::vector<VkCopyDescriptorSet>());
+ void update_descriptor_sets(const std::vector<VkWriteDescriptorSet> &writes, const std::vector<VkCopyDescriptorSet> &copies);
+ void update_descriptor_sets(const std::vector<VkWriteDescriptorSet> &writes) {
+ return update_descriptor_sets(writes, std::vector<VkCopyDescriptorSet>());
}
- static VkWriteDescriptorSet
- write_descriptor_set(const DescriptorSet &set, uint32_t binding,
- uint32_t array_element, VkDescriptorType type,
- uint32_t count,
- const VkDescriptorImageInfo *image_info);
- static VkWriteDescriptorSet
- write_descriptor_set(const DescriptorSet &set, uint32_t binding,
- uint32_t array_element, VkDescriptorType type,
- uint32_t count,
- const VkDescriptorBufferInfo *buffer_info);
- static VkWriteDescriptorSet
- write_descriptor_set(const DescriptorSet &set, uint32_t binding,
- uint32_t array_element, VkDescriptorType type,
- uint32_t count, const VkBufferView *buffer_views);
- static VkWriteDescriptorSet
- write_descriptor_set(const DescriptorSet &set, uint32_t binding,
- uint32_t array_element, VkDescriptorType type,
- const std::vector<VkDescriptorImageInfo> &image_info);
- static VkWriteDescriptorSet write_descriptor_set(
- const DescriptorSet &set, uint32_t binding, uint32_t array_element,
- VkDescriptorType type,
- const std::vector<VkDescriptorBufferInfo> &buffer_info);
- static VkWriteDescriptorSet
- write_descriptor_set(const DescriptorSet &set, uint32_t binding,
- uint32_t array_element, VkDescriptorType type,
- const std::vector<VkBufferView> &buffer_views);
-
- static VkCopyDescriptorSet
- copy_descriptor_set(const DescriptorSet &src_set, uint32_t src_binding,
- uint32_t src_array_element,
- const DescriptorSet &dst_set, uint32_t dst_binding,
- uint32_t dst_array_element, uint32_t count);
+ static VkWriteDescriptorSet write_descriptor_set(const DescriptorSet &set, uint32_t binding, uint32_t array_element,
+ VkDescriptorType type, uint32_t count,
+ const VkDescriptorImageInfo *image_info);
+ static VkWriteDescriptorSet write_descriptor_set(const DescriptorSet &set, uint32_t binding, uint32_t array_element,
+ VkDescriptorType type, uint32_t count,
+ const VkDescriptorBufferInfo *buffer_info);
+ static VkWriteDescriptorSet write_descriptor_set(const DescriptorSet &set, uint32_t binding, uint32_t array_element,
+ VkDescriptorType type, uint32_t count, const VkBufferView *buffer_views);
+ static VkWriteDescriptorSet write_descriptor_set(const DescriptorSet &set, uint32_t binding, uint32_t array_element,
+ VkDescriptorType type, const std::vector<VkDescriptorImageInfo> &image_info);
+ static VkWriteDescriptorSet write_descriptor_set(const DescriptorSet &set, uint32_t binding, uint32_t array_element,
+ VkDescriptorType type, const std::vector<VkDescriptorBufferInfo> &buffer_info);
+ static VkWriteDescriptorSet write_descriptor_set(const DescriptorSet &set, uint32_t binding, uint32_t array_element,
+ VkDescriptorType type, const std::vector<VkBufferView> &buffer_views);
+
+ static VkCopyDescriptorSet copy_descriptor_set(const DescriptorSet &src_set, uint32_t src_binding, uint32_t src_array_element,
+ const DescriptorSet &dst_set, uint32_t dst_binding, uint32_t dst_array_element,
+ uint32_t count);
private:
enum QueueIndex {
class Queue : public internal::Handle<VkQueue> {
public:
- explicit Queue(VkQueue queue, int index) : Handle(queue) {
- family_index_ = index;
- }
+ explicit Queue(VkQueue queue, int index) : Handle(queue) { family_index_ = index; }
// vkQueueSubmit()
void submit(const std::vector<const CommandBuffer *> &cmds, Fence &fence);
// vkUnmapMemory()
void unmap() const;
- static VkMemoryAllocateInfo alloc_info(VkDeviceSize size,
- uint32_t memory_type_index);
+ static VkMemoryAllocateInfo alloc_info(VkDeviceSize size, uint32_t memory_type_index);
};
class Fence : public internal::NonDispHandle<VkFence> {
void init(const Device &dev, const VkQueryPoolCreateInfo &info);
// vkGetQueryPoolResults()
- VkResult results(uint32_t first, uint32_t count, size_t size, void *data,
- size_t stride);
+ VkResult results(uint32_t first, uint32_t count, size_t size, void *data, size_t stride);
- static VkQueryPoolCreateInfo create_info(VkQueryType type,
- uint32_t slot_count);
+ static VkQueryPoolCreateInfo create_info(VkQueryType type, uint32_t slot_count);
};
class Buffer : public internal::NonDispHandle<VkBuffer> {
public:
explicit Buffer() : NonDispHandle() {}
- explicit Buffer(const Device &dev, const VkBufferCreateInfo &info) {
- init(dev, info);
- }
+ explicit Buffer(const Device &dev, const VkBufferCreateInfo &info) { init(dev, info); }
explicit Buffer(const Device &dev, VkDeviceSize size) { init(dev, size); }
~Buffer();
// vkCreateBuffer()
- void init(const Device &dev, const VkBufferCreateInfo &info,
- VkMemoryPropertyFlags mem_props);
- void init(const Device &dev, const VkBufferCreateInfo &info) {
- init(dev, info, 0);
- }
- void init(const Device &dev, VkDeviceSize size,
- VkMemoryPropertyFlags mem_props) {
- init(dev, create_info(size, 0), mem_props);
- }
+ void init(const Device &dev, const VkBufferCreateInfo &info, VkMemoryPropertyFlags mem_props);
+ void init(const Device &dev, const VkBufferCreateInfo &info) { init(dev, info, 0); }
+ void init(const Device &dev, VkDeviceSize size, VkMemoryPropertyFlags mem_props) { init(dev, create_info(size, 0), mem_props); }
void init(const Device &dev, VkDeviceSize size) { init(dev, size, 0); }
- void init_as_src(const Device &dev, VkDeviceSize size,
- VkMemoryPropertyFlags &reqs) {
+ void init_as_src(const Device &dev, VkDeviceSize size, VkMemoryPropertyFlags &reqs) {
init(dev, create_info(size, VK_BUFFER_USAGE_TRANSFER_SRC_BIT), reqs);
}
- void init_as_dst(const Device &dev, VkDeviceSize size,
- VkMemoryPropertyFlags &reqs) {
+ void init_as_dst(const Device &dev, VkDeviceSize size, VkMemoryPropertyFlags &reqs) {
init(dev, create_info(size, VK_BUFFER_USAGE_TRANSFER_DST_BIT), reqs);
}
- void init_as_src_and_dst(const Device &dev, VkDeviceSize size,
- VkMemoryPropertyFlags &reqs) {
- init(dev, create_info(size, VK_BUFFER_USAGE_TRANSFER_SRC_BIT |
- VK_BUFFER_USAGE_TRANSFER_DST_BIT),
- reqs);
+ void init_as_src_and_dst(const Device &dev, VkDeviceSize size, VkMemoryPropertyFlags &reqs) {
+ init(dev, create_info(size, VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT), reqs);
}
void init_no_mem(const Device &dev, const VkBufferCreateInfo &info);
static VkBufferCreateInfo create_info(VkDeviceSize size, VkFlags usage);
- VkBufferMemoryBarrier buffer_memory_barrier(VkFlags output_mask,
- VkFlags input_mask,
- VkDeviceSize offset,
+ VkBufferMemoryBarrier buffer_memory_barrier(VkFlags output_mask, VkFlags input_mask, VkDeviceSize offset,
VkDeviceSize size) const {
VkBufferMemoryBarrier barrier = {};
barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER;
class Image : public internal::NonDispHandle<VkImage> {
public:
explicit Image() : NonDispHandle(), format_features_(0) {}
- explicit Image(const Device &dev, const VkImageCreateInfo &info)
- : format_features_(0) {
- init(dev, info);
- }
+ explicit Image(const Device &dev, const VkImageCreateInfo &info) : format_features_(0) { init(dev, info); }
~Image();
// vkCreateImage()
- void init(const Device &dev, const VkImageCreateInfo &info,
- VkMemoryPropertyFlags mem_props);
- void init(const Device &dev, const VkImageCreateInfo &info) {
- init(dev, info, 0);
- }
+ void init(const Device &dev, const VkImageCreateInfo &info, VkMemoryPropertyFlags mem_props);
+ void init(const Device &dev, const VkImageCreateInfo &info) { init(dev, info, 0); }
void init_no_mem(const Device &dev, const VkImageCreateInfo &info);
// get the internal memory
void bind_memory(const DeviceMemory &mem, VkDeviceSize mem_offset);
// vkGetImageSubresourceLayout()
- VkSubresourceLayout
- subresource_layout(const VkImageSubresource &subres) const;
- VkSubresourceLayout
- subresource_layout(const VkImageSubresourceLayers &subres) const;
+ VkSubresourceLayout subresource_layout(const VkImageSubresource &subres) const;
+ VkSubresourceLayout subresource_layout(const VkImageSubresourceLayers &subres) const;
bool transparent() const;
- bool copyable() const {
- return (format_features_ & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT);
- }
+ bool copyable() const { return (format_features_ & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT); }
- VkImageSubresourceRange
- subresource_range(VkImageAspectFlagBits aspect) const {
+ VkImageSubresourceRange subresource_range(VkImageAspectFlagBits aspect) const {
return subresource_range(create_info_, aspect);
}
VkExtent3D extent() const { return create_info_.extent; }
- VkExtent3D extent(uint32_t mip_level) const {
- return extent(create_info_.extent, mip_level);
- }
+ VkExtent3D extent(uint32_t mip_level) const { return extent(create_info_.extent, mip_level); }
VkFormat format() const { return create_info_.format; }
- VkImageMemoryBarrier
- image_memory_barrier(VkFlags output_mask, VkFlags input_mask,
- VkImageLayout old_layout, VkImageLayout new_layout,
- const VkImageSubresourceRange &range) const {
+ VkImageMemoryBarrier image_memory_barrier(VkFlags output_mask, VkFlags input_mask, VkImageLayout old_layout,
+ VkImageLayout new_layout, const VkImageSubresourceRange &range) const {
VkImageMemoryBarrier barrier = {};
barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
barrier.srcAccessMask = output_mask;
}
static VkImageCreateInfo create_info();
- static VkImageSubresource subresource(VkImageAspectFlags aspect,
- uint32_t mip_level,
- uint32_t array_layer);
- static VkImageSubresource subresource(const VkImageSubresourceRange &range,
- uint32_t mip_level,
- uint32_t array_layer);
- static VkImageSubresourceLayers subresource(VkImageAspectFlags aspect,
- uint32_t mip_level,
- uint32_t array_layer,
+ static VkImageSubresource subresource(VkImageAspectFlags aspect, uint32_t mip_level, uint32_t array_layer);
+ static VkImageSubresource subresource(const VkImageSubresourceRange &range, uint32_t mip_level, uint32_t array_layer);
+ static VkImageSubresourceLayers subresource(VkImageAspectFlags aspect, uint32_t mip_level, uint32_t array_layer,
+ uint32_t array_size);
+ static VkImageSubresourceLayers subresource(const VkImageSubresourceRange &range, uint32_t mip_level, uint32_t array_layer,
uint32_t array_size);
- static VkImageSubresourceLayers
- subresource(const VkImageSubresourceRange &range, uint32_t mip_level,
- uint32_t array_layer, uint32_t array_size);
- static VkImageSubresourceRange
- subresource_range(VkImageAspectFlags aspect_mask, uint32_t base_mip_level,
- uint32_t mip_levels, uint32_t base_array_layer,
- uint32_t num_layers);
- static VkImageSubresourceRange
- subresource_range(const VkImageCreateInfo &info,
- VkImageAspectFlags aspect_mask);
- static VkImageSubresourceRange
- subresource_range(const VkImageSubresource &subres);
+ static VkImageSubresourceRange subresource_range(VkImageAspectFlags aspect_mask, uint32_t base_mip_level, uint32_t mip_levels,
+ uint32_t base_array_layer, uint32_t num_layers);
+ static VkImageSubresourceRange subresource_range(const VkImageCreateInfo &info, VkImageAspectFlags aspect_mask);
+ static VkImageSubresourceRange subresource_range(const VkImageSubresource &subres);
static VkExtent2D extent(int32_t width, int32_t height);
static VkExtent2D extent(const VkExtent2D &extent, uint32_t mip_level);
void init(const Device &dev, const VkShaderModuleCreateInfo &info);
VkResult init_try(const Device &dev, const VkShaderModuleCreateInfo &info);
- static VkShaderModuleCreateInfo
- create_info(size_t code_size, const uint32_t *code, VkFlags flags);
+ static VkShaderModuleCreateInfo create_info(size_t code_size, const uint32_t *code, VkFlags flags);
};
class Pipeline : public internal::NonDispHandle<VkPipeline> {
// vkCreateGraphicsPipeline()
void init(const Device &dev, const VkGraphicsPipelineCreateInfo &info);
// vkCreateGraphicsPipelineDerivative()
- void init(const Device &dev, const VkGraphicsPipelineCreateInfo &info,
- const VkPipeline basePipeline);
+ void init(const Device &dev, const VkGraphicsPipelineCreateInfo &info, const VkPipeline basePipeline);
// vkCreateComputePipeline()
void init(const Device &dev, const VkComputePipelineCreateInfo &info);
// vkLoadPipeline()
void init(const Device &dev, size_t size, const void *data);
// vkLoadPipelineDerivative()
- void init(const Device &dev, size_t size, const void *data,
- VkPipeline basePipeline);
+ void init(const Device &dev, size_t size, const void *data, VkPipeline basePipeline);
// vkCreateGraphicsPipeline with error return
- VkResult init_try(const Device &dev,
- const VkGraphicsPipelineCreateInfo &info);
+ VkResult init_try(const Device &dev, const VkGraphicsPipelineCreateInfo &info);
// vkStorePipeline()
size_t store(size_t size, void *data);
~PipelineLayout();
// vCreatePipelineLayout()
- void init(const Device &dev, VkPipelineLayoutCreateInfo &info,
- const std::vector<const DescriptorSetLayout *> &layouts);
+ void init(const Device &dev, VkPipelineLayoutCreateInfo &info, const std::vector<const DescriptorSetLayout *> &layouts);
};
class Sampler : public internal::NonDispHandle<VkSampler> {
void init(const Device &dev, const VkSamplerCreateInfo &info);
};
-class DescriptorSetLayout
- : public internal::NonDispHandle<VkDescriptorSetLayout> {
+class DescriptorSetLayout : public internal::NonDispHandle<VkDescriptorSetLayout> {
public:
~DescriptorSetLayout();
bool getDynamicUsage() { return dynamic_usage_; }
// vkAllocateDescriptorSets()
- std::vector<DescriptorSet *>
- alloc_sets(const Device &dev,
- const std::vector<const DescriptorSetLayout *> &layouts);
- std::vector<DescriptorSet *> alloc_sets(const Device &dev,
- const DescriptorSetLayout &layout,
- uint32_t count);
- DescriptorSet *alloc_sets(const Device &dev,
- const DescriptorSetLayout &layout);
+ std::vector<DescriptorSet *> alloc_sets(const Device &dev, const std::vector<const DescriptorSetLayout *> &layouts);
+ std::vector<DescriptorSet *> alloc_sets(const Device &dev, const DescriptorSetLayout &layout, uint32_t count);
+ DescriptorSet *alloc_sets(const Device &dev, const DescriptorSetLayout &layout);
private:
VkDescriptorPool pool_;
~DescriptorSet();
explicit DescriptorSet() : NonDispHandle() {}
- explicit DescriptorSet(const Device &dev, DescriptorPool *pool,
- VkDescriptorSet set)
- : NonDispHandle(dev.handle(), set) {
+ explicit DescriptorSet(const Device &dev, DescriptorPool *pool, VkDescriptorSet set) : NonDispHandle(dev.handle(), set) {
containing_pool_ = pool;
}
~CommandPool();
explicit CommandPool() : NonDispHandle() {}
- explicit CommandPool(const Device &dev,
- const VkCommandPoolCreateInfo &info) {
- init(dev, info);
- }
+ explicit CommandPool(const Device &dev, const VkCommandPoolCreateInfo &info) { init(dev, info); }
void init(const Device &dev, const VkCommandPoolCreateInfo &info);
static VkCommandPoolCreateInfo create_info(uint32_t queue_family_index);
};
-inline VkCommandPoolCreateInfo
-CommandPool::create_info(uint32_t queue_family_index) {
+inline VkCommandPoolCreateInfo CommandPool::create_info(uint32_t queue_family_index) {
VkCommandPoolCreateInfo info = {};
info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
info.queueFamilyIndex = queue_family_index;
~CommandBuffer();
explicit CommandBuffer() : Handle() {}
- explicit CommandBuffer(const Device &dev,
- const VkCommandBufferAllocateInfo &info) {
- init(dev, info);
- }
+ explicit CommandBuffer(const Device &dev, const VkCommandBufferAllocateInfo &info) { init(dev, info); }
// vkAllocateCommandBuffers()
void init(const Device &dev, const VkCommandBufferAllocateInfo &info);
VkCommandPool cmd_pool_;
};
-inline VkMemoryAllocateInfo
-DeviceMemory::alloc_info(VkDeviceSize size, uint32_t memory_type_index) {
+inline VkMemoryAllocateInfo DeviceMemory::alloc_info(VkDeviceSize size, uint32_t memory_type_index) {
VkMemoryAllocateInfo info = {};
info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
info.allocationSize = size;
return info;
}
-inline VkBufferCreateInfo Buffer::create_info(VkDeviceSize size,
- VkFlags usage) {
+inline VkBufferCreateInfo Buffer::create_info(VkDeviceSize size, VkFlags usage) {
VkBufferCreateInfo info = {};
info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
info.size = size;
return info;
}
-inline VkQueryPoolCreateInfo QueryPool::create_info(VkQueryType type,
- uint32_t slot_count) {
+inline VkQueryPoolCreateInfo QueryPool::create_info(VkQueryType type, uint32_t slot_count) {
VkQueryPoolCreateInfo info = {};
info.sType = VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO;
info.queryType = type;
return info;
}
-inline VkImageSubresource Image::subresource(VkImageAspectFlags aspect,
- uint32_t mip_level,
- uint32_t array_layer) {
+inline VkImageSubresource Image::subresource(VkImageAspectFlags aspect, uint32_t mip_level, uint32_t array_layer) {
VkImageSubresource subres = {};
if (aspect == 0) {
assert(!"Invalid VkImageAspectFlags");
return subres;
}
-inline VkImageSubresource
-Image::subresource(const VkImageSubresourceRange &range, uint32_t mip_level,
- uint32_t array_layer) {
- return subresource(range.aspectMask,
- range.baseMipLevel + mip_level,
- range.baseArrayLayer + array_layer);
+inline VkImageSubresource Image::subresource(const VkImageSubresourceRange &range, uint32_t mip_level, uint32_t array_layer) {
+ return subresource(range.aspectMask, range.baseMipLevel + mip_level, range.baseArrayLayer + array_layer);
}
-inline VkImageSubresourceLayers Image::subresource(VkImageAspectFlags aspect,
- uint32_t mip_level,
- uint32_t array_layer,
+inline VkImageSubresourceLayers Image::subresource(VkImageAspectFlags aspect, uint32_t mip_level, uint32_t array_layer,
uint32_t array_size) {
VkImageSubresourceLayers subres = {};
switch (aspect) {
return subres;
}
-inline VkImageSubresourceLayers
-Image::subresource(const VkImageSubresourceRange &range, uint32_t mip_level,
- uint32_t array_layer, uint32_t array_size) {
- return subresource(range.aspectMask,
- range.baseMipLevel + mip_level,
- range.baseArrayLayer + array_layer, array_size);
+inline VkImageSubresourceLayers Image::subresource(const VkImageSubresourceRange &range, uint32_t mip_level, uint32_t array_layer,
+ uint32_t array_size) {
+ return subresource(range.aspectMask, range.baseMipLevel + mip_level, range.baseArrayLayer + array_layer, array_size);
}
-inline VkImageSubresourceRange
-Image::subresource_range(VkImageAspectFlags aspect_mask,
- uint32_t base_mip_level, uint32_t mip_levels,
- uint32_t base_array_layer, uint32_t num_layers) {
+inline VkImageSubresourceRange Image::subresource_range(VkImageAspectFlags aspect_mask, uint32_t base_mip_level,
+ uint32_t mip_levels, uint32_t base_array_layer, uint32_t num_layers) {
VkImageSubresourceRange range = {};
if (aspect_mask == 0) {
assert(!"Invalid VkImageAspectFlags");
return range;
}
-inline VkImageSubresourceRange
-Image::subresource_range(const VkImageCreateInfo &info,
- VkImageAspectFlags aspect_mask) {
- return subresource_range(aspect_mask, 0, info.mipLevels, 0,
- info.arrayLayers);
+inline VkImageSubresourceRange Image::subresource_range(const VkImageCreateInfo &info, VkImageAspectFlags aspect_mask) {
+ return subresource_range(aspect_mask, 0, info.mipLevels, 0, info.arrayLayers);
}
-inline VkImageSubresourceRange
-Image::subresource_range(const VkImageSubresource &subres) {
- return subresource_range(subres.aspectMask, subres.mipLevel, 1,
- subres.arrayLayer, 1);
+inline VkImageSubresourceRange Image::subresource_range(const VkImageSubresource &subres) {
+ return subresource_range(subres.aspectMask, subres.mipLevel, 1, subres.arrayLayer, 1);
}
inline VkExtent2D Image::extent(int32_t width, int32_t height) {
}
inline VkExtent2D Image::extent(const VkExtent2D &extent, uint32_t mip_level) {
- const int32_t width =
- (extent.width >> mip_level) ? extent.width >> mip_level : 1;
- const int32_t height =
- (extent.height >> mip_level) ? extent.height >> mip_level : 1;
+ const int32_t width = (extent.width >> mip_level) ? extent.width >> mip_level : 1;
+ const int32_t height = (extent.height >> mip_level) ? extent.height >> mip_level : 1;
return Image::extent(width, height);
}
-inline VkExtent2D Image::extent(const VkExtent3D &extent) {
- return Image::extent(extent.width, extent.height);
-}
+inline VkExtent2D Image::extent(const VkExtent3D &extent) { return Image::extent(extent.width, extent.height); }
inline VkExtent3D Image::extent(int32_t width, int32_t height, int32_t depth) {
VkExtent3D extent = {};
}
inline VkExtent3D Image::extent(const VkExtent3D &extent, uint32_t mip_level) {
- const int32_t width =
- (extent.width >> mip_level) ? extent.width >> mip_level : 1;
- const int32_t height =
- (extent.height >> mip_level) ? extent.height >> mip_level : 1;
- const int32_t depth =
- (extent.depth >> mip_level) ? extent.depth >> mip_level : 1;
+ const int32_t width = (extent.width >> mip_level) ? extent.width >> mip_level : 1;
+ const int32_t height = (extent.height >> mip_level) ? extent.height >> mip_level : 1;
+ const int32_t depth = (extent.depth >> mip_level) ? extent.depth >> mip_level : 1;
return Image::extent(width, height, depth);
}
-inline VkShaderModuleCreateInfo ShaderModule::create_info(size_t code_size,
- const uint32_t *code,
- VkFlags flags) {
+inline VkShaderModuleCreateInfo ShaderModule::create_info(size_t code_size, const uint32_t *code, VkFlags flags) {
VkShaderModuleCreateInfo info = {};
info.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
info.codeSize = code_size;
return info;
}
-inline VkWriteDescriptorSet
-Device::write_descriptor_set(const DescriptorSet &set, uint32_t binding,
- uint32_t array_element, VkDescriptorType type,
- uint32_t count,
- const VkDescriptorImageInfo *image_info) {
+inline VkWriteDescriptorSet Device::write_descriptor_set(const DescriptorSet &set, uint32_t binding, uint32_t array_element,
+ VkDescriptorType type, uint32_t count,
+ const VkDescriptorImageInfo *image_info) {
VkWriteDescriptorSet write = {};
write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
write.dstSet = set.handle();
return write;
}
-inline VkWriteDescriptorSet
-Device::write_descriptor_set(const DescriptorSet &set, uint32_t binding,
- uint32_t array_element, VkDescriptorType type,
- uint32_t count,
- const VkDescriptorBufferInfo *buffer_info) {
+inline VkWriteDescriptorSet Device::write_descriptor_set(const DescriptorSet &set, uint32_t binding, uint32_t array_element,
+ VkDescriptorType type, uint32_t count,
+ const VkDescriptorBufferInfo *buffer_info) {
VkWriteDescriptorSet write = {};
write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
write.dstSet = set.handle();
return write;
}
-inline VkWriteDescriptorSet
-Device::write_descriptor_set(const DescriptorSet &set, uint32_t binding,
- uint32_t array_element, VkDescriptorType type,
- uint32_t count, const VkBufferView *buffer_views) {
+inline VkWriteDescriptorSet Device::write_descriptor_set(const DescriptorSet &set, uint32_t binding, uint32_t array_element,
+ VkDescriptorType type, uint32_t count, const VkBufferView *buffer_views) {
VkWriteDescriptorSet write = {};
write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
write.dstSet = set.handle();
return write;
}
-inline VkWriteDescriptorSet Device::write_descriptor_set(
- const DescriptorSet &set, uint32_t binding, uint32_t array_element,
- VkDescriptorType type,
- const std::vector<VkDescriptorImageInfo> &image_info) {
- return write_descriptor_set(set, binding, array_element, type,
- image_info.size(), &image_info[0]);
+inline VkWriteDescriptorSet Device::write_descriptor_set(const DescriptorSet &set, uint32_t binding, uint32_t array_element,
+ VkDescriptorType type,
+ const std::vector<VkDescriptorImageInfo> &image_info) {
+ return write_descriptor_set(set, binding, array_element, type, image_info.size(), &image_info[0]);
}
-inline VkWriteDescriptorSet Device::write_descriptor_set(
- const DescriptorSet &set, uint32_t binding, uint32_t array_element,
- VkDescriptorType type,
- const std::vector<VkDescriptorBufferInfo> &buffer_info) {
- return write_descriptor_set(set, binding, array_element, type,
- buffer_info.size(), &buffer_info[0]);
+inline VkWriteDescriptorSet Device::write_descriptor_set(const DescriptorSet &set, uint32_t binding, uint32_t array_element,
+ VkDescriptorType type,
+ const std::vector<VkDescriptorBufferInfo> &buffer_info) {
+ return write_descriptor_set(set, binding, array_element, type, buffer_info.size(), &buffer_info[0]);
}
-inline VkWriteDescriptorSet
-Device::write_descriptor_set(const DescriptorSet &set, uint32_t binding,
- uint32_t array_element, VkDescriptorType type,
- const std::vector<VkBufferView> &buffer_views) {
- return write_descriptor_set(set, binding, array_element, type,
- buffer_views.size(), &buffer_views[0]);
+inline VkWriteDescriptorSet Device::write_descriptor_set(const DescriptorSet &set, uint32_t binding, uint32_t array_element,
+ VkDescriptorType type, const std::vector<VkBufferView> &buffer_views) {
+ return write_descriptor_set(set, binding, array_element, type, buffer_views.size(), &buffer_views[0]);
}
-inline VkCopyDescriptorSet
-Device::copy_descriptor_set(const DescriptorSet &src_set, uint32_t src_binding,
- uint32_t src_array_element,
- const DescriptorSet &dst_set, uint32_t dst_binding,
- uint32_t dst_array_element, uint32_t count) {
+inline VkCopyDescriptorSet Device::copy_descriptor_set(const DescriptorSet &src_set, uint32_t src_binding,
+ uint32_t src_array_element, const DescriptorSet &dst_set,
+ uint32_t dst_binding, uint32_t dst_array_element, uint32_t count) {
VkCopyDescriptorSet copy = {};
copy.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET;
copy.srcSet = src_set.handle();
return copy;
}
-inline VkCommandBufferAllocateInfo
-CommandBuffer::create_info(VkCommandPool const &pool) {
+inline VkCommandBufferAllocateInfo CommandBuffer::create_info(VkCommandPool const &pool) {
VkCommandBufferAllocateInfo info = {};
info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
info.commandPool = pool;