wrapper: Make use of designated initializers where applicable
This commit is contained in:
parent
01da386617
commit
7785123b1c
|
@ -377,24 +377,26 @@ VkResult Free(VkDevice device, VkCommandPool handle, Span<VkCommandBuffer> buffe
|
||||||
|
|
||||||
Instance Instance::Create(Span<const char*> layers, Span<const char*> extensions,
|
Instance Instance::Create(Span<const char*> layers, Span<const char*> extensions,
|
||||||
InstanceDispatch& dld) noexcept {
|
InstanceDispatch& dld) noexcept {
|
||||||
VkApplicationInfo application_info;
|
static constexpr VkApplicationInfo application_info{
|
||||||
application_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
|
.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO,
|
||||||
application_info.pNext = nullptr;
|
.pNext = nullptr,
|
||||||
application_info.pApplicationName = "yuzu Emulator";
|
.pApplicationName = "yuzu Emulator",
|
||||||
application_info.applicationVersion = VK_MAKE_VERSION(0, 1, 0);
|
.applicationVersion = VK_MAKE_VERSION(0, 1, 0),
|
||||||
application_info.pEngineName = "yuzu Emulator";
|
.pEngineName = "yuzu Emulator",
|
||||||
application_info.engineVersion = VK_MAKE_VERSION(0, 1, 0);
|
.engineVersion = VK_MAKE_VERSION(0, 1, 0),
|
||||||
application_info.apiVersion = VK_API_VERSION_1_1;
|
.apiVersion = VK_API_VERSION_1_1,
|
||||||
|
};
|
||||||
|
|
||||||
VkInstanceCreateInfo ci;
|
const VkInstanceCreateInfo ci{
|
||||||
ci.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
|
.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
|
||||||
ci.pNext = nullptr;
|
.pNext = nullptr,
|
||||||
ci.flags = 0;
|
.flags = 0,
|
||||||
ci.pApplicationInfo = &application_info;
|
.pApplicationInfo = &application_info,
|
||||||
ci.enabledLayerCount = layers.size();
|
.enabledLayerCount = layers.size(),
|
||||||
ci.ppEnabledLayerNames = layers.data();
|
.ppEnabledLayerNames = layers.data(),
|
||||||
ci.enabledExtensionCount = extensions.size();
|
.enabledExtensionCount = extensions.size(),
|
||||||
ci.ppEnabledExtensionNames = extensions.data();
|
.ppEnabledExtensionNames = extensions.data(),
|
||||||
|
};
|
||||||
|
|
||||||
VkInstance instance;
|
VkInstance instance;
|
||||||
if (dld.vkCreateInstance(&ci, nullptr, &instance) != VK_SUCCESS) {
|
if (dld.vkCreateInstance(&ci, nullptr, &instance) != VK_SUCCESS) {
|
||||||
|
@ -425,19 +427,20 @@ std::optional<std::vector<VkPhysicalDevice>> Instance::EnumeratePhysicalDevices(
|
||||||
|
|
||||||
DebugCallback Instance::TryCreateDebugCallback(
|
DebugCallback Instance::TryCreateDebugCallback(
|
||||||
PFN_vkDebugUtilsMessengerCallbackEXT callback) noexcept {
|
PFN_vkDebugUtilsMessengerCallbackEXT callback) noexcept {
|
||||||
VkDebugUtilsMessengerCreateInfoEXT ci;
|
const VkDebugUtilsMessengerCreateInfoEXT ci{
|
||||||
ci.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT;
|
.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT,
|
||||||
ci.pNext = nullptr;
|
.pNext = nullptr,
|
||||||
ci.flags = 0;
|
.flags = 0,
|
||||||
ci.messageSeverity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT |
|
.messageSeverity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT |
|
||||||
VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT |
|
VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT |
|
||||||
VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT |
|
VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT |
|
||||||
VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT;
|
VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT,
|
||||||
ci.messageType = VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT |
|
.messageType = VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT |
|
||||||
VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT |
|
VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT |
|
||||||
VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT;
|
VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT,
|
||||||
ci.pfnUserCallback = callback;
|
.pfnUserCallback = callback,
|
||||||
ci.pUserData = nullptr;
|
.pUserData = nullptr,
|
||||||
|
};
|
||||||
|
|
||||||
VkDebugUtilsMessengerEXT messenger;
|
VkDebugUtilsMessengerEXT messenger;
|
||||||
if (dld->vkCreateDebugUtilsMessengerEXT(handle, &ci, nullptr, &messenger) != VK_SUCCESS) {
|
if (dld->vkCreateDebugUtilsMessengerEXT(handle, &ci, nullptr, &messenger) != VK_SUCCESS) {
|
||||||
|
@ -468,12 +471,13 @@ DescriptorSets DescriptorPool::Allocate(const VkDescriptorSetAllocateInfo& ai) c
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandBuffers CommandPool::Allocate(std::size_t num_buffers, VkCommandBufferLevel level) const {
|
CommandBuffers CommandPool::Allocate(std::size_t num_buffers, VkCommandBufferLevel level) const {
|
||||||
VkCommandBufferAllocateInfo ai;
|
const VkCommandBufferAllocateInfo ai{
|
||||||
ai.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
|
.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,
|
||||||
ai.pNext = nullptr;
|
.pNext = nullptr,
|
||||||
ai.commandPool = handle;
|
.commandPool = handle,
|
||||||
ai.level = level;
|
.level = level,
|
||||||
ai.commandBufferCount = static_cast<u32>(num_buffers);
|
.commandBufferCount = static_cast<u32>(num_buffers),
|
||||||
|
};
|
||||||
|
|
||||||
std::unique_ptr buffers = std::make_unique<VkCommandBuffer[]>(num_buffers);
|
std::unique_ptr buffers = std::make_unique<VkCommandBuffer[]>(num_buffers);
|
||||||
switch (const VkResult result = dld->vkAllocateCommandBuffers(owner, &ai, buffers.get())) {
|
switch (const VkResult result = dld->vkAllocateCommandBuffers(owner, &ai, buffers.get())) {
|
||||||
|
@ -497,17 +501,18 @@ std::vector<VkImage> SwapchainKHR::GetImages() const {
|
||||||
Device Device::Create(VkPhysicalDevice physical_device, Span<VkDeviceQueueCreateInfo> queues_ci,
|
Device Device::Create(VkPhysicalDevice physical_device, Span<VkDeviceQueueCreateInfo> queues_ci,
|
||||||
Span<const char*> enabled_extensions, const void* next,
|
Span<const char*> enabled_extensions, const void* next,
|
||||||
DeviceDispatch& dld) noexcept {
|
DeviceDispatch& dld) noexcept {
|
||||||
VkDeviceCreateInfo ci;
|
const VkDeviceCreateInfo ci{
|
||||||
ci.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
|
.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,
|
||||||
ci.pNext = next;
|
.pNext = next,
|
||||||
ci.flags = 0;
|
.flags = 0,
|
||||||
ci.queueCreateInfoCount = queues_ci.size();
|
.queueCreateInfoCount = queues_ci.size(),
|
||||||
ci.pQueueCreateInfos = queues_ci.data();
|
.pQueueCreateInfos = queues_ci.data(),
|
||||||
ci.enabledLayerCount = 0;
|
.enabledLayerCount = 0,
|
||||||
ci.ppEnabledLayerNames = nullptr;
|
.ppEnabledLayerNames = nullptr,
|
||||||
ci.enabledExtensionCount = enabled_extensions.size();
|
.enabledExtensionCount = enabled_extensions.size(),
|
||||||
ci.ppEnabledExtensionNames = enabled_extensions.data();
|
.ppEnabledExtensionNames = enabled_extensions.data(),
|
||||||
ci.pEnabledFeatures = nullptr;
|
.pEnabledFeatures = nullptr,
|
||||||
|
};
|
||||||
|
|
||||||
VkDevice device;
|
VkDevice device;
|
||||||
if (dld.vkCreateDevice(physical_device, &ci, nullptr, &device) != VK_SUCCESS) {
|
if (dld.vkCreateDevice(physical_device, &ci, nullptr, &device) != VK_SUCCESS) {
|
||||||
|
@ -548,10 +553,11 @@ ImageView Device::CreateImageView(const VkImageViewCreateInfo& ci) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
Semaphore Device::CreateSemaphore() const {
|
Semaphore Device::CreateSemaphore() const {
|
||||||
VkSemaphoreCreateInfo ci;
|
static constexpr VkSemaphoreCreateInfo ci{
|
||||||
ci.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
|
.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO,
|
||||||
ci.pNext = nullptr;
|
.pNext = nullptr,
|
||||||
ci.flags = 0;
|
.flags = 0,
|
||||||
|
};
|
||||||
|
|
||||||
VkSemaphore object;
|
VkSemaphore object;
|
||||||
Check(dld->vkCreateSemaphore(handle, &ci, nullptr, &object));
|
Check(dld->vkCreateSemaphore(handle, &ci, nullptr, &object));
|
||||||
|
@ -639,10 +645,12 @@ ShaderModule Device::CreateShaderModule(const VkShaderModuleCreateInfo& ci) cons
|
||||||
}
|
}
|
||||||
|
|
||||||
Event Device::CreateEvent() const {
|
Event Device::CreateEvent() const {
|
||||||
VkEventCreateInfo ci;
|
static constexpr VkEventCreateInfo ci{
|
||||||
ci.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO;
|
.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO,
|
||||||
ci.pNext = nullptr;
|
.pNext = nullptr,
|
||||||
ci.flags = 0;
|
.flags = 0,
|
||||||
|
};
|
||||||
|
|
||||||
VkEvent object;
|
VkEvent object;
|
||||||
Check(dld->vkCreateEvent(handle, &ci, nullptr, &object));
|
Check(dld->vkCreateEvent(handle, &ci, nullptr, &object));
|
||||||
return Event(object, handle, *dld);
|
return Event(object, handle, *dld);
|
||||||
|
|
Reference in New Issue