vulkan: Use structured bindings for result where possible.

This commit is contained in:
squidbus 2024-09-25 02:05:33 -07:00
parent 50f217a076
commit 6cb1222b9a
15 changed files with 155 additions and 154 deletions

View file

@ -128,12 +128,12 @@ vk::BufferView Buffer::View(u32 offset, u32 size, bool is_written, AmdGpu::DataF
.offset = offset,
.range = size,
};
const auto view = instance->GetDevice().createBufferView(view_ci);
ASSERT_MSG(view.result == vk::Result::eSuccess, "Failed to create buffer view: {}",
vk::to_string(view.result));
const auto [view_result, view] = instance->GetDevice().createBufferView(view_ci);
ASSERT_MSG(view_result == vk::Result::eSuccess, "Failed to create buffer view: {}",
vk::to_string(view_result));
scheduler->DeferOperation(
[view, device = instance->GetDevice()] { device.destroyBufferView(view.value); });
return view.value;
[view, device = instance->GetDevice()] { device.destroyBufferView(view); });
return view;
}
constexpr u64 WATCHES_INITIAL_RESERVE = 0x4000;

View file

@ -82,10 +82,11 @@ RendererVulkan::RendererVulkan(Frontend::WindowSDL& window_, AmdGpu::Liverpool*
present_frames.resize(num_images);
for (u32 i = 0; i < num_images; i++) {
Frame& frame = present_frames[i];
auto fence_result = device.createFence({.flags = vk::FenceCreateFlagBits::eSignaled});
ASSERT_MSG(fence_result.result == vk::Result::eSuccess,
"Failed to create present done fence: {}", vk::to_string(fence_result.result));
frame.present_done = fence_result.value;
auto [fence_result, fence] =
device.createFence({.flags = vk::FenceCreateFlagBits::eSignaled});
ASSERT_MSG(fence_result == vk::Result::eSuccess, "Failed to create present done fence: {}",
vk::to_string(fence_result));
frame.present_done = fence;
free_queue.push(&frame);
}
@ -160,10 +161,10 @@ void RendererVulkan::RecreateFrame(Frame* frame, u32 width, u32 height) {
.layerCount = 1,
},
};
auto view_result = device.createImageView(view_info);
ASSERT_MSG(view_result.result == vk::Result::eSuccess, "Failed to create frame image view: {}",
vk::to_string(view_result.result));
frame->image_view = view_result.value;
auto [view_result, view] = device.createImageView(view_info);
ASSERT_MSG(view_result == vk::Result::eSuccess, "Failed to create frame image view: {}",
vk::to_string(view_result));
frame->image_view = view;
frame->width = width;
frame->height = height;
}

View file

@ -15,6 +15,8 @@
#define VULKAN_HPP_NO_STRUCT_SETTERS
#define VULKAN_HPP_HAS_SPACESHIP_OPERATOR
#define VULKAN_HPP_NO_EXCEPTIONS
// Define assert-on-result to nothing to instead return the result for our handling.
#define VULKAN_HPP_ASSERT_ON_RESULT
#include <vulkan/vulkan.hpp>
#define VMA_STATIC_VULKAN_FUNCTIONS 0

View file

@ -78,12 +78,12 @@ ComputePipeline::ComputePipeline(const Instance& instance_, Scheduler& scheduler
.bindingCount = static_cast<u32>(bindings.size()),
.pBindings = bindings.data(),
};
auto descriptor_set_result =
auto [descriptor_set_result, descriptor_set] =
instance.GetDevice().createDescriptorSetLayoutUnique(desc_layout_ci);
ASSERT_MSG(descriptor_set_result.result == vk::Result::eSuccess,
ASSERT_MSG(descriptor_set_result == vk::Result::eSuccess,
"Failed to create compute descriptor set layout: {}",
vk::to_string(descriptor_set_result.result));
desc_layout = std::move(descriptor_set_result.value);
vk::to_string(descriptor_set_result));
desc_layout = std::move(descriptor_set);
const vk::DescriptorSetLayout set_layout = *desc_layout;
const vk::PipelineLayoutCreateInfo layout_info = {
@ -92,20 +92,20 @@ ComputePipeline::ComputePipeline(const Instance& instance_, Scheduler& scheduler
.pushConstantRangeCount = 1U,
.pPushConstantRanges = &push_constants,
};
auto layout_result = instance.GetDevice().createPipelineLayoutUnique(layout_info);
ASSERT_MSG(layout_result.result == vk::Result::eSuccess,
"Failed to create compute pipeline layout: {}", vk::to_string(layout_result.result));
pipeline_layout = std::move(layout_result.value);
auto [layout_result, layout] = instance.GetDevice().createPipelineLayoutUnique(layout_info);
ASSERT_MSG(layout_result == vk::Result::eSuccess,
"Failed to create compute pipeline layout: {}", vk::to_string(layout_result));
pipeline_layout = std::move(layout);
const vk::ComputePipelineCreateInfo compute_pipeline_ci = {
.stage = shader_ci,
.layout = *pipeline_layout,
};
auto pipeline_result =
auto [pipeline_result, pipe] =
instance.GetDevice().createComputePipelineUnique(pipeline_cache, compute_pipeline_ci);
ASSERT_MSG(pipeline_result.result == vk::Result::eSuccess,
"Failed to create compute pipeline: {}", vk::to_string(pipeline_result.result));
pipeline = std::move(pipeline_result.value);
ASSERT_MSG(pipeline_result == vk::Result::eSuccess, "Failed to create compute pipeline: {}",
vk::to_string(pipeline_result));
pipeline = std::move(pipe);
}
ComputePipeline::~ComputePipeline() = default;

View file

@ -39,11 +39,10 @@ GraphicsPipeline::GraphicsPipeline(const Instance& instance_, Scheduler& schedul
.pushConstantRangeCount = 1,
.pPushConstantRanges = &push_constants,
};
auto layout_result = instance.GetDevice().createPipelineLayoutUnique(layout_info);
ASSERT_MSG(layout_result.result == vk::Result::eSuccess,
"Failed to create graphics pipeline layout: {}",
vk::to_string(layout_result.result));
pipeline_layout = std::move(layout_result.value);
auto [layout_result, layout] = instance.GetDevice().createPipelineLayoutUnique(layout_info);
ASSERT_MSG(layout_result == vk::Result::eSuccess,
"Failed to create graphics pipeline layout: {}", vk::to_string(layout_result));
pipeline_layout = std::move(layout);
boost::container::static_vector<vk::VertexInputBindingDescription, 32> vertex_bindings;
boost::container::static_vector<vk::VertexInputAttributeDescription, 32> vertex_attributes;
@ -285,10 +284,11 @@ GraphicsPipeline::GraphicsPipeline(const Instance& instance_, Scheduler& schedul
.layout = *pipeline_layout,
};
auto pipeline_result = device.createGraphicsPipelineUnique(pipeline_cache, pipeline_info);
ASSERT_MSG(pipeline_result.result == vk::Result::eSuccess,
"Failed to create graphics pipeline: {}", vk::to_string(pipeline_result.result));
pipeline = std::move(pipeline_result.value);
auto [pipeline_result, pipe] =
device.createGraphicsPipelineUnique(pipeline_cache, pipeline_info);
ASSERT_MSG(pipeline_result == vk::Result::eSuccess, "Failed to create graphics pipeline: {}",
vk::to_string(pipeline_result));
pipeline = std::move(pipe);
}
GraphicsPipeline::~GraphicsPipeline() = default;
@ -347,10 +347,11 @@ void GraphicsPipeline::BuildDescSetLayout() {
.bindingCount = static_cast<u32>(bindings.size()),
.pBindings = bindings.data(),
};
auto result = instance.GetDevice().createDescriptorSetLayoutUnique(desc_layout_ci);
ASSERT_MSG(result.result == vk::Result::eSuccess,
"Failed to create graphics descriptor set layout: {}", vk::to_string(result.result));
desc_layout = std::move(result.value);
auto [layout_result, layout] =
instance.GetDevice().createDescriptorSetLayoutUnique(desc_layout_ci);
ASSERT_MSG(layout_result == vk::Result::eSuccess,
"Failed to create graphics descriptor set layout: {}", vk::to_string(layout_result));
desc_layout = std::move(layout);
}
void GraphicsPipeline::BindResources(const Liverpool::Regs& regs,

View file

@ -24,22 +24,22 @@ namespace Vulkan {
namespace {
std::vector<vk::PhysicalDevice> EnumeratePhysicalDevices(vk::UniqueInstance& instance) {
auto devices_result = instance->enumeratePhysicalDevices();
ASSERT_MSG(devices_result.result == vk::Result::eSuccess,
"Failed to enumerate physical devices: {}", vk::to_string(devices_result.result));
return std::move(devices_result.value);
auto [devices_result, devices] = instance->enumeratePhysicalDevices();
ASSERT_MSG(devices_result == vk::Result::eSuccess, "Failed to enumerate physical devices: {}",
vk::to_string(devices_result));
return std::move(devices);
}
std::vector<std::string> GetSupportedExtensions(vk::PhysicalDevice physical) {
const auto extensions = physical.enumerateDeviceExtensionProperties();
if (extensions.result != vk::Result::eSuccess) {
const auto [extensions_result, extensions] = physical.enumerateDeviceExtensionProperties();
if (extensions_result != vk::Result::eSuccess) {
LOG_ERROR(Render_Vulkan, "Could not query supported extensions: {}",
vk::to_string(extensions.result));
vk::to_string(extensions_result));
return {};
}
std::vector<std::string> supported_extensions;
supported_extensions.reserve(extensions.value.size());
for (const auto& extension : extensions.value) {
supported_extensions.reserve(extensions.size());
for (const auto& extension : extensions) {
supported_extensions.emplace_back(extension.extensionName.data());
}
return supported_extensions;
@ -433,13 +433,12 @@ bool Instance::CreateDevice() {
device_chain.unlink<vk::PhysicalDeviceVertexInputDynamicStateFeaturesEXT>();
}
auto device_result = physical_device.createDeviceUnique(device_chain.get());
if (device_result.result != vk::Result::eSuccess) {
LOG_CRITICAL(Render_Vulkan, "Failed to create device: {}",
vk::to_string(device_result.result));
auto [device_result, dev] = physical_device.createDeviceUnique(device_chain.get());
if (device_result != vk::Result::eSuccess) {
LOG_CRITICAL(Render_Vulkan, "Failed to create device: {}", vk::to_string(device_result));
return false;
}
device = std::move(device_result.value);
device = std::move(dev);
VULKAN_HPP_DEFAULT_DISPATCHER.init(*device);
@ -447,9 +446,9 @@ bool Instance::CreateDevice() {
present_queue = device->getQueue(queue_family_index, 0);
if (calibrated_timestamps) {
const auto& time_domains_result = physical_device.getCalibrateableTimeDomainsEXT();
if (time_domains_result.result == vk::Result::eSuccess) {
const auto& time_domains = time_domains_result.value;
const auto [time_domains_result, time_domains] =
physical_device.getCalibrateableTimeDomainsEXT();
if (time_domains_result == vk::Result::eSuccess) {
#if _WIN64
const bool has_host_time_domain =
std::find(time_domains.cbegin(), time_domains.cend(),
@ -473,7 +472,7 @@ bool Instance::CreateDevice() {
}
} else {
LOG_WARNING(Render_Vulkan, "Could not query calibrated time domains for profiling: {}",
vk::to_string(time_domains_result.result));
vk::to_string(time_domains_result));
}
}
@ -529,13 +528,13 @@ void Instance::CollectToolingInfo() {
if (!tooling_info) {
return;
}
const auto tools = physical_device.getToolPropertiesEXT();
if (tools.result != vk::Result::eSuccess) {
const auto [tools_result, tools] = physical_device.getToolPropertiesEXT();
if (tools_result != vk::Result::eSuccess) {
LOG_ERROR(Render_Vulkan, "Could not get Vulkan tool properties: {}",
vk::to_string(tools.result));
vk::to_string(tools_result));
return;
}
for (const vk::PhysicalDeviceToolProperties& tool : tools.value) {
for (const vk::PhysicalDeviceToolProperties& tool : tools) {
const std::string_view name = tool.name;
LOG_INFO(Render_Vulkan, "Attached debugging tool: {}", name);
has_renderdoc = has_renderdoc || name == "RenderDoc";

View file

@ -19,10 +19,11 @@ MasterSemaphore::MasterSemaphore(const Instance& instance_) : instance{instance_
.initialValue = 0,
},
};
auto result = instance.GetDevice().createSemaphoreUnique(semaphore_chain.get());
ASSERT_MSG(result.result == vk::Result::eSuccess, "Failed to create master semaphore: {}",
vk::to_string(result.result));
semaphore = std::move(result.value);
auto [semaphore_result, sem] =
instance.GetDevice().createSemaphoreUnique(semaphore_chain.get());
ASSERT_MSG(semaphore_result == vk::Result::eSuccess, "Failed to create master semaphore: {}",
vk::to_string(semaphore_result));
semaphore = std::move(sem);
}
MasterSemaphore::~MasterSemaphore() = default;
@ -32,11 +33,10 @@ void MasterSemaphore::Refresh() {
u64 counter{};
do {
this_tick = gpu_tick.load(std::memory_order_acquire);
auto counter_result = instance.GetDevice().getSemaphoreCounterValue(*semaphore);
ASSERT_MSG(counter_result.result == vk::Result::eSuccess,
"Failed to get master semaphore value: {}",
vk::to_string(counter_result.result));
counter = counter_result.value;
auto [counter_result, cntr] = instance.GetDevice().getSemaphoreCounterValue(*semaphore);
ASSERT_MSG(counter_result == vk::Result::eSuccess,
"Failed to get master semaphore value: {}", vk::to_string(counter_result));
counter = cntr;
if (counter < this_tick) {
return;
}

View file

@ -136,10 +136,10 @@ PipelineCache::PipelineCache(const Instance& instance_, Scheduler& scheduler_,
.subgroup_size = instance.SubgroupSize(),
.support_explicit_workgroup_layout = true,
};
auto cache_result = instance.GetDevice().createPipelineCacheUnique({});
ASSERT_MSG(cache_result.result == vk::Result::eSuccess, "Failed to create pipeline cache: {}",
vk::to_string(cache_result.result));
pipeline_cache = std::move(cache_result.value);
auto [cache_result, cache] = instance.GetDevice().createPipelineCacheUnique({});
ASSERT_MSG(cache_result == vk::Result::eSuccess, "Failed to create pipeline cache: {}",
vk::to_string(cache_result));
pipeline_cache = std::move(cache);
}
PipelineCache::~PipelineCache() = default;

View file

@ -134,13 +134,12 @@ vk::SurfaceKHR CreateSurface(vk::Instance instance, const Frontend::WindowSDL& e
std::vector<const char*> GetInstanceExtensions(Frontend::WindowSystemType window_type,
bool enable_debug_utils) {
const auto properties_result = vk::enumerateInstanceExtensionProperties();
if (properties_result.result != vk::Result::eSuccess || properties_result.value.empty()) {
const auto [properties_result, properties] = vk::enumerateInstanceExtensionProperties();
if (properties_result != vk::Result::eSuccess || properties.empty()) {
LOG_ERROR(Render_Vulkan, "Failed to query extension properties: {}",
vk::to_string(properties_result.result));
vk::to_string(properties_result));
return {};
}
const auto& properties = properties_result.value;
// Add the windowing system specific extension
std::vector<const char*> extensions;
@ -209,16 +208,16 @@ vk::UniqueInstance CreateInstance(Frontend::WindowSystemType window_type, bool e
#endif
VULKAN_HPP_DEFAULT_DISPATCHER.init(vkGetInstanceProcAddr);
const auto available_version = VULKAN_HPP_DEFAULT_DISPATCHER.vkEnumerateInstanceVersion
? vk::enumerateInstanceVersion()
: vk::ResultValue(vk::Result::eSuccess, VK_API_VERSION_1_0);
ASSERT_MSG(available_version.result == vk::Result::eSuccess,
"Failed to query Vulkan API version: {}", vk::to_string(available_version.result));
ASSERT_MSG(available_version.value >= TargetVulkanApiVersion,
const auto [available_version_result, available_version] =
VULKAN_HPP_DEFAULT_DISPATCHER.vkEnumerateInstanceVersion
? vk::enumerateInstanceVersion()
: vk::ResultValue(vk::Result::eSuccess, VK_API_VERSION_1_0);
ASSERT_MSG(available_version_result == vk::Result::eSuccess,
"Failed to query Vulkan API version: {}", vk::to_string(available_version_result));
ASSERT_MSG(available_version >= TargetVulkanApiVersion,
"Vulkan {}.{} is required, but only {}.{} is supported by instance!",
VK_VERSION_MAJOR(TargetVulkanApiVersion), VK_VERSION_MINOR(TargetVulkanApiVersion),
VK_VERSION_MAJOR(available_version.value),
VK_VERSION_MINOR(available_version.value));
VK_VERSION_MAJOR(available_version), VK_VERSION_MINOR(available_version));
const auto extensions = GetInstanceExtensions(window_type, true);
@ -227,7 +226,7 @@ vk::UniqueInstance CreateInstance(Frontend::WindowSystemType window_type, bool e
.applicationVersion = VK_MAKE_VERSION(1, 0, 0),
.pEngineName = "shadPS4 Vulkan",
.engineVersion = VK_MAKE_VERSION(1, 0, 0),
.apiVersion = available_version.value,
.apiVersion = available_version,
};
u32 num_layers = 0;
@ -345,13 +344,13 @@ vk::UniqueInstance CreateInstance(Frontend::WindowSystemType window_type, bool e
},
};
auto instance_result = vk::createInstanceUnique(instance_ci_chain.get());
ASSERT_MSG(instance_result.result == vk::Result::eSuccess, "Failed to create instance: {}",
vk::to_string(instance_result.result));
auto [instance_result, instance] = vk::createInstanceUnique(instance_ci_chain.get());
ASSERT_MSG(instance_result == vk::Result::eSuccess, "Failed to create instance: {}",
vk::to_string(instance_result));
VULKAN_HPP_DEFAULT_DISPATCHER.init(*instance_result.value);
VULKAN_HPP_DEFAULT_DISPATCHER.init(*instance);
return std::move(instance_result.value);
return std::move(instance);
}
vk::UniqueDebugUtilsMessengerEXT CreateDebugCallback(vk::Instance instance) {
@ -365,10 +364,10 @@ vk::UniqueDebugUtilsMessengerEXT CreateDebugCallback(vk::Instance instance) {
vk::DebugUtilsMessageTypeFlagBitsEXT::ePerformance,
.pfnUserCallback = DebugUtilsCallback,
};
auto result = instance.createDebugUtilsMessengerEXTUnique(msg_ci);
ASSERT_MSG(result.result == vk::Result::eSuccess, "Failed to create debug callback: {}",
vk::to_string(result.result));
return std::move(result.value);
auto [messenger_result, messenger] = instance.createDebugUtilsMessengerEXTUnique(msg_ci);
ASSERT_MSG(messenger_result == vk::Result::eSuccess, "Failed to create debug callback: {}",
vk::to_string(messenger_result));
return std::move(messenger);
}
} // namespace Vulkan

View file

@ -69,10 +69,10 @@ CommandPool::CommandPool(const Instance& instance, MasterSemaphore* master_semap
.queueFamilyIndex = instance.GetGraphicsQueueFamilyIndex(),
};
const vk::Device device = instance.GetDevice();
auto result = device.createCommandPoolUnique(pool_create_info);
ASSERT_MSG(result.result == vk::Result::eSuccess, "Failed to create command pool: {}",
vk::to_string(result.result));
cmd_pool = std::move(result.value);
auto [pool_result, pool] = device.createCommandPoolUnique(pool_create_info);
ASSERT_MSG(pool_result == vk::Result::eSuccess, "Failed to create command pool: {}",
vk::to_string(pool_result));
cmd_pool = std::move(pool);
if (instance.HasDebuggingToolAttached()) {
SetObjectName(device, *cmd_pool, "CommandPool");
}
@ -185,10 +185,10 @@ void DescriptorHeap::CreateDescriptorPool() {
.poolSizeCount = static_cast<u32>(pool_sizes.size()),
.pPoolSizes = pool_sizes.data(),
};
auto result = device.createDescriptorPool(pool_info);
ASSERT_MSG(result.result == vk::Result::eSuccess, "Failed to create descriptor pool: {}",
vk::to_string(result.result));
curr_pool = result.value;
auto [pool_result, pool] = device.createDescriptorPool(pool_info);
ASSERT_MSG(pool_result == vk::Result::eSuccess, "Failed to create descriptor pool: {}",
vk::to_string(pool_result));
curr_pool = pool;
}
} // namespace Vulkan

View file

@ -218,10 +218,10 @@ vk::ShaderModule CompileSPV(std::span<const u32> code, vk::Device device) {
.pCode = code.data(),
};
auto result = device.createShaderModule(shader_info);
ASSERT_MSG(result.result == vk::Result::eSuccess, "Failed to compile SPIR-V shader: {}",
vk::to_string(result.result));
return result.value;
auto [module_result, module] = device.createShaderModule(shader_info);
ASSERT_MSG(module_result == vk::Result::eSuccess, "Failed to compile SPIR-V shader: {}",
vk::to_string(module_result));
return module;
}
} // namespace Vulkan

View file

@ -37,16 +37,17 @@ void Swapchain::Create(u32 width_, u32 height_, vk::SurfaceKHR surface_) {
instance.GetPresentQueueFamilyIndex(),
};
const auto modes = instance.GetPhysicalDevice().getSurfacePresentModesKHR(surface);
const auto find_mode = [&modes](vk::PresentModeKHR requested) {
if (modes.result != vk::Result::eSuccess) {
const auto [modes_result, modes] =
instance.GetPhysicalDevice().getSurfacePresentModesKHR(surface);
const auto find_mode = [&modes_result, &modes](vk::PresentModeKHR requested) {
if (modes_result != vk::Result::eSuccess) {
return false;
}
const auto it =
std::find_if(modes.value.begin(), modes.value.end(),
std::find_if(modes.begin(), modes.end(),
[&requested](vk::PresentModeKHR mode) { return mode == requested; });
return it != modes.value.end();
return it != modes.end();
};
const bool has_mailbox = find_mode(vk::PresentModeKHR::eMailbox);
@ -73,10 +74,10 @@ void Swapchain::Create(u32 width_, u32 height_, vk::SurfaceKHR surface_) {
.oldSwapchain = nullptr,
};
auto swapchain_result = instance.GetDevice().createSwapchainKHR(swapchain_info);
ASSERT_MSG(swapchain_result.result == vk::Result::eSuccess, "Failed to create swapchain: {}",
vk::to_string(swapchain_result.result));
swapchain = std::move(swapchain_result.value);
auto [swapchain_result, chain] = instance.GetDevice().createSwapchainKHR(swapchain_info);
ASSERT_MSG(swapchain_result == vk::Result::eSuccess, "Failed to create swapchain: {}",
vk::to_string(swapchain_result));
swapchain = chain;
SetupImages();
RefreshSemaphores();
@ -132,10 +133,10 @@ void Swapchain::Present() {
}
void Swapchain::FindPresentFormat() {
const auto formats_result = instance.GetPhysicalDevice().getSurfaceFormatsKHR(surface);
ASSERT_MSG(formats_result.result == vk::Result::eSuccess, "Failed to query surface formats: {}",
vk::to_string(formats_result.result));
const auto& formats = formats_result.value;
const auto [formats_result, formats] =
instance.GetPhysicalDevice().getSurfaceFormatsKHR(surface);
ASSERT_MSG(formats_result == vk::Result::eSuccess, "Failed to query surface formats: {}",
vk::to_string(formats_result));
// If there is a single undefined surface format, the device doesn't care, so we'll just use
// RGBA sRGB.
@ -161,12 +162,10 @@ void Swapchain::FindPresentFormat() {
}
void Swapchain::SetSurfaceProperties() {
const auto capabilities_result =
const auto [capabilities_result, capabilities] =
instance.GetPhysicalDevice().getSurfaceCapabilitiesKHR(surface);
ASSERT_MSG(capabilities_result.result == vk::Result::eSuccess,
"Failed to query surface capabilities: {}",
vk::to_string(capabilities_result.result));
const auto& capabilities = capabilities_result.value;
ASSERT_MSG(capabilities_result == vk::Result::eSuccess,
"Failed to query surface capabilities: {}", vk::to_string(capabilities_result));
extent = capabilities.currentExtent;
if (capabilities.currentExtent.width == std::numeric_limits<u32>::max()) {
@ -214,16 +213,17 @@ void Swapchain::RefreshSemaphores() {
present_ready.resize(image_count);
for (vk::Semaphore& semaphore : image_acquired) {
auto result = device.createSemaphore({});
ASSERT_MSG(result.result == vk::Result::eSuccess,
"Failed to create image acquired semaphore: {}", vk::to_string(result.result));
semaphore = result.value;
auto [semaphore_result, sem] = device.createSemaphore({});
ASSERT_MSG(semaphore_result == vk::Result::eSuccess,
"Failed to create image acquired semaphore: {}",
vk::to_string(semaphore_result));
semaphore = sem;
}
for (vk::Semaphore& semaphore : present_ready) {
auto result = device.createSemaphore({});
ASSERT_MSG(result.result == vk::Result::eSuccess,
"Failed to create present ready semaphore: {}", vk::to_string(result.result));
semaphore = result.value;
auto [semaphore_result, sem] = device.createSemaphore({});
ASSERT_MSG(semaphore_result == vk::Result::eSuccess,
"Failed to create present ready semaphore: {}", vk::to_string(semaphore_result));
semaphore = sem;
}
if (instance.HasDebuggingToolAttached()) {
@ -236,10 +236,10 @@ void Swapchain::RefreshSemaphores() {
void Swapchain::SetupImages() {
vk::Device device = instance.GetDevice();
auto images_result = device.getSwapchainImagesKHR(swapchain);
ASSERT_MSG(images_result.result == vk::Result::eSuccess,
"Failed to create swapchain images: {}", vk::to_string(images_result.result));
images = std::move(images_result.value);
auto [images_result, imgs] = device.getSwapchainImagesKHR(swapchain);
ASSERT_MSG(images_result == vk::Result::eSuccess, "Failed to create swapchain images: {}",
vk::to_string(images_result));
images = std::move(imgs);
image_count = static_cast<u32>(images.size());
if (instance.HasDebuggingToolAttached()) {

View file

@ -175,10 +175,10 @@ ImageView::ImageView(const Vulkan::Instance& instance, const ImageViewInfo& info
.layerCount = info.range.extent.layers,
},
};
auto result = instance.GetDevice().createImageViewUnique(image_view_ci);
ASSERT_MSG(result.result == vk::Result::eSuccess, "Failed to create image view: {}",
vk::to_string(result.result));
image_view = std::move(result.value);
auto [view_result, view] = instance.GetDevice().createImageViewUnique(image_view_ci);
ASSERT_MSG(view_result == vk::Result::eSuccess, "Failed to create image view: {}",
vk::to_string(view_result));
image_view = std::move(view);
}
ImageView::~ImageView() = default;

View file

@ -24,10 +24,10 @@ Sampler::Sampler(const Vulkan::Instance& instance, const AmdGpu::Sampler& sample
.borderColor = LiverpoolToVK::BorderColor(sampler.border_color_type),
.unnormalizedCoordinates = bool(sampler.force_unnormalized),
};
auto result = instance.GetDevice().createSamplerUnique(sampler_ci);
ASSERT_MSG(result.result == vk::Result::eSuccess, "Failed to create sampler: {}",
vk::to_string(result.result));
handle = std::move(result.value);
auto [sampler_result, smplr] = instance.GetDevice().createSamplerUnique(sampler_ci);
ASSERT_MSG(sampler_result == vk::Result::eSuccess, "Failed to create sampler: {}",
vk::to_string(sampler_result));
handle = std::move(smplr);
}
Sampler::~Sampler() = default;

View file

@ -298,11 +298,10 @@ TileManager::TileManager(const Vulkan::Instance& instance, Vulkan::Scheduler& sc
.bindingCount = static_cast<u32>(bindings.size()),
.pBindings = bindings.data(),
};
static auto desc_layout_result =
static auto [desc_layout_result, desc_layout] =
instance.GetDevice().createDescriptorSetLayoutUnique(desc_layout_ci);
ASSERT_MSG(desc_layout_result.result == vk::Result::eSuccess,
"Failed to create descriptor set layout: {}",
vk::to_string(desc_layout_result.result));
ASSERT_MSG(desc_layout_result == vk::Result::eSuccess,
"Failed to create descriptor set layout: {}", vk::to_string(desc_layout_result));
const vk::PushConstantRange push_constants = {
.stageFlags = vk::ShaderStageFlagBits::eCompute,
@ -310,17 +309,17 @@ TileManager::TileManager(const Vulkan::Instance& instance, Vulkan::Scheduler& sc
.size = sizeof(DetilerParams),
};
const vk::DescriptorSetLayout set_layout = *desc_layout_result.value;
const vk::DescriptorSetLayout set_layout = *desc_layout;
const vk::PipelineLayoutCreateInfo layout_info = {
.setLayoutCount = 1U,
.pSetLayouts = &set_layout,
.pushConstantRangeCount = 1,
.pPushConstantRanges = &push_constants,
};
auto layout_result = instance.GetDevice().createPipelineLayoutUnique(layout_info);
ASSERT_MSG(layout_result.result == vk::Result::eSuccess,
"Failed to create pipeline layout: {}", vk::to_string(layout_result.result));
ctx.pl_layout = std::move(layout_result.value);
auto [layout_result, layout] = instance.GetDevice().createPipelineLayoutUnique(layout_info);
ASSERT_MSG(layout_result == vk::Result::eSuccess, "Failed to create pipeline layout: {}",
vk::to_string(layout_result));
ctx.pl_layout = std::move(layout);
const vk::ComputePipelineCreateInfo compute_pipeline_ci = {
.stage = shader_ci,