mirror of https://github.com/snes9xgit/snes9x.git
Vulkan-Hpp: Don't use exceptions.
This commit is contained in:
parent
7cf9f59923
commit
46c6bd7eb4
|
@ -107,6 +107,8 @@ if(USE_SLANG)
|
|||
list(APPEND DEFINES "VK_USE_PLATFORM_XLIB_KHR"
|
||||
"VK_USE_PLATFORM_WAYLAND_KHR"
|
||||
"VULKAN_HPP_DISPATCH_LOADER_DYNAMIC=1"
|
||||
"VULKAN_HPP_NO_DISCARD_WARNINGS=1"
|
||||
"VULKAN_HPP_NO_EXCEPTIONS=1"
|
||||
"VMA_DYNAMIC_VULKAN_FUNCTIONS=1"
|
||||
"VMA_STATIC_VULKAN_FUNCTIONS=0"
|
||||
"IMGUI_IMPL_VULKAN_NO_PROTOTYPES")
|
||||
|
|
|
@ -58,7 +58,7 @@ bool S9xVulkanDisplayDriver::init_imgui()
|
|||
.setPoolSizes(pool_sizes)
|
||||
.setMaxSets(1000)
|
||||
.setFlags(vk::DescriptorPoolCreateFlagBits::eFreeDescriptorSet);
|
||||
imgui_descriptor_pool = device.createDescriptorPoolUnique(descriptor_pool_create_info);
|
||||
imgui_descriptor_pool = device.createDescriptorPoolUnique(descriptor_pool_create_info).value;
|
||||
|
||||
ImGui_ImplVulkan_InitInfo init_info{};
|
||||
init_info.Instance = context->instance.get();
|
||||
|
|
|
@ -228,6 +228,8 @@ endif()
|
|||
|
||||
list(APPEND DEFINES
|
||||
"VULKAN_HPP_DISPATCH_LOADER_DYNAMIC=1"
|
||||
"VULKAN_HPP_NO_NODISCARD_WARNINGS=1"
|
||||
"VULKAN_HPP_NO_EXCEPTIONS=1"
|
||||
"VMA_DYNAMIC_VULKAN_FUNCTIONS=1"
|
||||
"VMA_STATIC_VULKAN_FUNCTIONS=0"
|
||||
"USE_SLANG")
|
||||
|
|
|
@ -52,7 +52,7 @@ bool EmuCanvasVulkan::initImGui()
|
|||
.setPoolSizes(pool_sizes)
|
||||
.setMaxSets(1000)
|
||||
.setFlags(vk::DescriptorPoolCreateFlagBits::eFreeDescriptorSet);
|
||||
imgui_descriptor_pool = context->device.createDescriptorPoolUnique(descriptor_pool_create_info);
|
||||
imgui_descriptor_pool = context->device.createDescriptorPoolUnique(descriptor_pool_create_info).value;
|
||||
|
||||
ImGui_ImplVulkan_InitInfo init_info{};
|
||||
init_info.Instance = context->instance.get();
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#include <exception>
|
||||
#include <cstring>
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
|
@ -19,7 +18,7 @@ Context::~Context()
|
|||
{
|
||||
if (!device)
|
||||
return;
|
||||
device.waitIdle();
|
||||
wait_idle();
|
||||
|
||||
swapchain = nullptr;
|
||||
|
||||
|
@ -29,7 +28,7 @@ Context::~Context()
|
|||
allocator.destroy();
|
||||
|
||||
surface.reset();
|
||||
device.waitIdle();
|
||||
wait_idle();
|
||||
|
||||
device.destroy();
|
||||
}
|
||||
|
@ -63,17 +62,17 @@ static vk::UniqueInstance create_instance_preamble(const char *wsi_extension)
|
|||
vk::ApplicationInfo application_info({}, {}, {}, {}, VK_API_VERSION_1_0);
|
||||
vk::InstanceCreateInfo instance_create_info({}, &application_info, {}, extensions);
|
||||
|
||||
vk::UniqueInstance instance;
|
||||
try {
|
||||
instance = vk::createInstanceUnique(instance_create_info);
|
||||
} catch (std::exception &e) {
|
||||
auto [result, instance] = vk::createInstanceUnique(instance_create_info);
|
||||
|
||||
if (result != vk::Result::eSuccess)
|
||||
{
|
||||
instance.reset();
|
||||
return {};
|
||||
}
|
||||
|
||||
VULKAN_HPP_DEFAULT_DISPATCHER.init(instance.get());
|
||||
|
||||
return instance;
|
||||
return std::move(instance);
|
||||
}
|
||||
|
||||
std::vector<std::string> Vulkan::Context::get_device_list()
|
||||
|
@ -83,7 +82,7 @@ std::vector<std::string> Vulkan::Context::get_device_list()
|
|||
if (!instance)
|
||||
return {};
|
||||
|
||||
auto device_list = instance->enumeratePhysicalDevices();
|
||||
auto [result, device_list] = instance->enumeratePhysicalDevices();
|
||||
for (auto &d : device_list)
|
||||
{
|
||||
auto props = d.getProperties();
|
||||
|
@ -119,11 +118,12 @@ bool Context::init_Xlib(Display *dpy, Window xid, int preferred_device)
|
|||
instance = create_instance_preamble(VK_KHR_XLIB_SURFACE_EXTENSION_NAME);
|
||||
if (!instance)
|
||||
return false;
|
||||
|
||||
surface = instance->createXlibSurfaceKHRUnique({ {}, dpy, xid });
|
||||
|
||||
if (!surface)
|
||||
|
||||
auto retval = instance->createXlibSurfaceKHRUnique({ {}, dpy, xid });
|
||||
if (retval.result != vk::Result::eSuccess)
|
||||
return false;
|
||||
surface = std::move(retval.value);
|
||||
|
||||
return init(preferred_device);
|
||||
}
|
||||
#endif
|
||||
|
@ -138,9 +138,11 @@ bool Context::init_wayland(wl_display *dpy, wl_surface *parent, int initial_widt
|
|||
auto wayland_surface_create_info = vk::WaylandSurfaceCreateInfoKHR{}
|
||||
.setSurface(parent)
|
||||
.setDisplay(dpy);
|
||||
surface = instance->createWaylandSurfaceKHRUnique(wayland_surface_create_info);
|
||||
if (!surface)
|
||||
|
||||
auto [result, new_surface] = instance->createWaylandSurfaceKHRUnique(wayland_surface_create_info);
|
||||
if (result != vk::Result::eSuccess)
|
||||
return false;
|
||||
surface = std::move(new_surface);
|
||||
|
||||
init_device(preferred_device);
|
||||
init_vma();
|
||||
|
@ -173,7 +175,9 @@ bool Context::init_descriptor_pool()
|
|||
.setPoolSizes(descriptor_pool_size)
|
||||
.setMaxSets(20)
|
||||
.setFlags(vk::DescriptorPoolCreateFlagBits::eFreeDescriptorSet);
|
||||
descriptor_pool = device.createDescriptorPoolUnique(descriptor_pool_create_info);
|
||||
|
||||
auto retval = device.createDescriptorPoolUnique(descriptor_pool_create_info);
|
||||
descriptor_pool = std::move(retval.value);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -182,19 +186,20 @@ bool Context::init_command_pool()
|
|||
{
|
||||
vk::CommandPoolCreateInfo cpci({}, graphics_queue_family_index);
|
||||
cpci.setFlags(vk::CommandPoolCreateFlagBits::eResetCommandBuffer);
|
||||
command_pool = device.createCommandPoolUnique(cpci);
|
||||
auto retval = device.createCommandPoolUnique(cpci);
|
||||
command_pool = std::move(retval.value);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Context::init_device(int preferred_device)
|
||||
{
|
||||
auto device_list = instance->enumeratePhysicalDevices();
|
||||
auto device_list = instance->enumeratePhysicalDevices().value;
|
||||
|
||||
auto find_device = [&]() -> vk::PhysicalDevice {
|
||||
for (auto &d : device_list)
|
||||
{
|
||||
auto ep = d.enumerateDeviceExtensionProperties();
|
||||
auto [retval, ep] = d.enumerateDeviceExtensionProperties();
|
||||
auto exists = std::find_if(ep.begin(), ep.end(), [](vk::ExtensionProperties &ext) {
|
||||
return (std::string(ext.extensionName.data()) == VK_KHR_SWAPCHAIN_EXTENSION_NAME);
|
||||
});
|
||||
|
@ -228,10 +233,10 @@ bool Context::init_device(int preferred_device)
|
|||
std::vector<float> priorities { 1.0f };
|
||||
vk::DeviceQueueCreateInfo dqci({}, graphics_queue_family_index, priorities);
|
||||
vk::DeviceCreateInfo dci({}, dqci, {}, extension_names, {});
|
||||
device = physical_device.createDevice(dci);
|
||||
device = physical_device.createDevice(dci).value;
|
||||
queue = device.getQueue(graphics_queue_family_index, 0);
|
||||
|
||||
auto surface_formats = physical_device.getSurfaceFormatsKHR(surface.get());
|
||||
auto [retval, surface_formats] = physical_device.getSurfaceFormatsKHR(surface.get());
|
||||
auto format = std::find_if(surface_formats.begin(), surface_formats.end(), [](vk::SurfaceFormatKHR &f) {
|
||||
return (f.format == vk::Format::eB8G8R8A8Unorm);
|
||||
});
|
||||
|
@ -253,7 +258,7 @@ bool Context::init_vma()
|
|||
.setInstance(instance.get())
|
||||
.setPhysicalDevice(physical_device)
|
||||
.setPVulkanFunctions(&vulkan_functions);
|
||||
allocator = vma::createAllocator(allocator_create_info);
|
||||
allocator = vma::createAllocator(allocator_create_info).value;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -279,7 +284,7 @@ void Context::wait_idle()
|
|||
vk::CommandBuffer Context::begin_cmd_buffer()
|
||||
{
|
||||
vk::CommandBufferAllocateInfo command_buffer_allocate_info(command_pool.get(), vk::CommandBufferLevel::ePrimary, 1);
|
||||
auto command_buffer = device.allocateCommandBuffers(command_buffer_allocate_info);
|
||||
auto command_buffer = device.allocateCommandBuffers(command_buffer_allocate_info).value;
|
||||
one_time_use_cmd = command_buffer[0];
|
||||
one_time_use_cmd.begin({ vk::CommandBufferUsageFlagBits::eOneTimeSubmit });
|
||||
return one_time_use_cmd;
|
||||
|
|
|
@ -229,7 +229,7 @@ void PipelineImage::create(int width, int height, vk::Format fmt, vk::RenderPass
|
|||
.setSamples(vk::SampleCountFlagBits::e1)
|
||||
.setSharingMode(vk::SharingMode::eExclusive);
|
||||
|
||||
std::tie(image, image_allocation) = allocator.createImage(image_create_info, allocation_create_info);
|
||||
std::tie(image, image_allocation) = allocator.createImage(image_create_info, allocation_create_info).value;
|
||||
|
||||
auto subresource_range = vk::ImageSubresourceRange{}
|
||||
.setAspectMask(vk::ImageAspectFlagBits::eColor)
|
||||
|
@ -245,10 +245,10 @@ void PipelineImage::create(int width, int height, vk::Format fmt, vk::RenderPass
|
|||
.setComponents(vk::ComponentMapping())
|
||||
.setSubresourceRange(subresource_range);
|
||||
|
||||
image_view = device.createImageView(image_view_create_info);
|
||||
image_view = device.createImageView(image_view_create_info).value;
|
||||
|
||||
image_view_create_info.setSubresourceRange(vk::ImageSubresourceRange(vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1));
|
||||
mipless_view = device.createImageView(image_view_create_info);
|
||||
mipless_view = device.createImageView(image_view_create_info).value;
|
||||
|
||||
image_width = width;
|
||||
image_height = height;
|
||||
|
@ -260,7 +260,7 @@ void PipelineImage::create(int width, int height, vk::Format fmt, vk::RenderPass
|
|||
.setRenderPass(renderpass)
|
||||
.setLayers(1);
|
||||
|
||||
framebuffer = device.createFramebufferUnique(framebuffer_create_info);
|
||||
framebuffer = device.createFramebufferUnique(framebuffer_create_info).value;
|
||||
}
|
||||
|
||||
} // namespace Vulkan
|
|
@ -40,7 +40,7 @@ void ShaderChain::construct_buffer_objects()
|
|||
uint8_t *ubo_memory = nullptr;
|
||||
|
||||
if (pipeline.shader->ubo_size > 0)
|
||||
ubo_memory = (uint8_t *)context->allocator.mapMemory(pipeline.uniform_buffer_allocation);
|
||||
ubo_memory = (uint8_t *)context->allocator.mapMemory(pipeline.uniform_buffer_allocation).value;
|
||||
|
||||
for (auto &uniform : pipeline.shader->uniforms)
|
||||
{
|
||||
|
@ -248,7 +248,7 @@ bool ShaderChain::load_shader_preset(std::string filename)
|
|||
.setMaxSets(pipelines.size() * queue_size)
|
||||
.setFlags(vk::DescriptorPoolCreateFlagBits::eFreeDescriptorSet);
|
||||
|
||||
descriptor_pool = context->device.createDescriptorPoolUnique(descriptor_pool_create_info);
|
||||
descriptor_pool = context->device.createDescriptorPoolUnique(descriptor_pool_create_info).value;
|
||||
|
||||
for (auto &p : pipelines)
|
||||
p->generate_frame_resources(descriptor_pool.get());
|
||||
|
@ -267,9 +267,9 @@ bool ShaderChain::load_shader_preset(std::string filename)
|
|||
.setFlags(vma::AllocationCreateFlagBits::eHostAccessSequentialWrite)
|
||||
.setRequiredFlags(vk::MemoryPropertyFlagBits::eHostVisible);
|
||||
|
||||
std::tie(vertex_buffer, vertex_buffer_allocation) = context->allocator.createBuffer(buffer_create_info, allocation_create_info);
|
||||
std::tie(vertex_buffer, vertex_buffer_allocation) = context->allocator.createBuffer(buffer_create_info, allocation_create_info).value;
|
||||
|
||||
auto vertex_buffer_memory = context->allocator.mapMemory(vertex_buffer_allocation);
|
||||
auto vertex_buffer_memory = context->allocator.mapMemory(vertex_buffer_allocation).value;
|
||||
memcpy(vertex_buffer_memory, vertex_data, sizeof(vertex_data));
|
||||
context->allocator.unmapMemory(vertex_buffer_allocation);
|
||||
context->allocator.flushAllocation(vertex_buffer_allocation, 0, sizeof(vertex_data));
|
||||
|
|
|
@ -62,7 +62,7 @@ void SimpleOutput::create_objects()
|
|||
.setDescriptorPool(context->descriptor_pool.get())
|
||||
.setDescriptorSetCount(1)
|
||||
.setSetLayouts(descriptor_set_layout.get());
|
||||
auto descriptor = device.allocateDescriptorSetsUnique(dsai);
|
||||
auto descriptor = device.allocateDescriptorSetsUnique(dsai).value;
|
||||
descriptors.push_back(std::move(descriptor[0]));
|
||||
}
|
||||
|
||||
|
@ -87,11 +87,11 @@ void SimpleOutput::create_objects()
|
|||
.setMaxLod(1.0f)
|
||||
.setMipLodBias(0.0)
|
||||
.setCompareEnable(false);
|
||||
linear_sampler = device.createSampler(sci);
|
||||
linear_sampler = device.createSampler(sci).value;
|
||||
|
||||
sci.setMinFilter(vk::Filter::eNearest)
|
||||
.setMagFilter(vk::Filter::eNearest);
|
||||
nearest_sampler = device.createSampler(sci);
|
||||
nearest_sampler = device.createSampler(sci).value;
|
||||
}
|
||||
|
||||
void SimpleOutput::create_pipeline()
|
||||
|
@ -99,8 +99,8 @@ void SimpleOutput::create_pipeline()
|
|||
auto vertex_spirv = SlangShader::generate_spirv(vertex_shader, "vertex");
|
||||
auto fragment_spirv = SlangShader::generate_spirv(fragment_shader, "fragment");
|
||||
|
||||
auto vertex_module = device.createShaderModuleUnique({ {}, vertex_spirv });
|
||||
auto fragment_module = device.createShaderModuleUnique({ {}, fragment_spirv });
|
||||
auto vertex_module = device.createShaderModuleUnique({ {}, vertex_spirv }).value;
|
||||
auto fragment_module = device.createShaderModuleUnique({ {}, fragment_spirv }).value;
|
||||
|
||||
vk::PipelineShaderStageCreateInfo vertex_ci;
|
||||
vertex_ci.setStage(vk::ShaderStageFlagBits::eVertex)
|
||||
|
@ -182,14 +182,14 @@ void SimpleOutput::create_pipeline()
|
|||
.setDescriptorType(vk::DescriptorType::eCombinedImageSampler);
|
||||
vk::DescriptorSetLayoutCreateInfo dslci{};
|
||||
dslci.setBindings(dslb);
|
||||
descriptor_set_layout = device.createDescriptorSetLayoutUnique(dslci);
|
||||
descriptor_set_layout = device.createDescriptorSetLayoutUnique(dslci).value;
|
||||
|
||||
vk::PipelineLayoutCreateInfo pipeline_layout_info;
|
||||
pipeline_layout_info.setSetLayoutCount(0)
|
||||
.setPushConstantRangeCount(0)
|
||||
.setSetLayouts(descriptor_set_layout.get());
|
||||
|
||||
pipeline_layout = device.createPipelineLayoutUnique(pipeline_layout_info);
|
||||
pipeline_layout = device.createPipelineLayoutUnique(pipeline_layout_info).value;
|
||||
|
||||
vk::GraphicsPipelineCreateInfo pipeline_create_info;
|
||||
pipeline_create_info.setStageCount(2)
|
||||
|
|
|
@ -156,10 +156,10 @@ bool SlangPipeline::generate_pipeline(bool lastpass)
|
|||
.setDependencies(subpass_dependency)
|
||||
.setAttachments(attachment_description);
|
||||
|
||||
render_pass = device.createRenderPassUnique(render_pass_create_info);
|
||||
render_pass = device.createRenderPassUnique(render_pass_create_info).value;
|
||||
|
||||
auto vertex_module = device.createShaderModuleUnique({ {}, shader->vertex_shader_spirv });
|
||||
auto fragment_module = device.createShaderModuleUnique({ {}, shader->fragment_shader_spirv });
|
||||
auto vertex_module = device.createShaderModuleUnique({ {}, shader->vertex_shader_spirv }).value;
|
||||
auto fragment_module = device.createShaderModuleUnique({ {}, shader->fragment_shader_spirv }).value;
|
||||
|
||||
auto vertex_ci = vk::PipelineShaderStageCreateInfo{}
|
||||
.setStage(vk::ShaderStageFlagBits::eVertex)
|
||||
|
@ -278,7 +278,7 @@ bool SlangPipeline::generate_pipeline(bool lastpass)
|
|||
|
||||
auto dslci = vk::DescriptorSetLayoutCreateInfo{}
|
||||
.setBindings(descriptor_set_layout_bindings);
|
||||
descriptor_set_layout = device.createDescriptorSetLayoutUnique(dslci);
|
||||
descriptor_set_layout = device.createDescriptorSetLayoutUnique(dslci).value;
|
||||
|
||||
vk::PushConstantRange pcr(vk::ShaderStageFlagBits::eAllGraphics, 0, shader->push_constant_block_size);
|
||||
|
||||
|
@ -289,7 +289,7 @@ bool SlangPipeline::generate_pipeline(bool lastpass)
|
|||
if (shader->push_constant_block_size > 0)
|
||||
pipeline_layout_info.setPushConstantRanges(pcr);
|
||||
|
||||
pipeline_layout = device.createPipelineLayoutUnique(pipeline_layout_info);
|
||||
pipeline_layout = device.createPipelineLayoutUnique(pipeline_layout_info).value;
|
||||
|
||||
auto pipeline_create_info = vk::GraphicsPipelineCreateInfo{}
|
||||
.setStageCount(2)
|
||||
|
@ -343,11 +343,11 @@ bool SlangPipeline::generate_frame_resources(vk::DescriptorPool pool)
|
|||
|
||||
vk::DescriptorSetAllocateInfo descriptor_set_allocate_info(pool, descriptor_set_layout.get());
|
||||
|
||||
auto result = device.allocateDescriptorSetsUnique(descriptor_set_allocate_info);
|
||||
auto result = device.allocateDescriptorSetsUnique(descriptor_set_allocate_info).value;
|
||||
f.descriptor_set = std::move(result[0]);
|
||||
}
|
||||
|
||||
semaphore = device.createSemaphoreUnique({});
|
||||
semaphore = device.createSemaphoreUnique({}).value;
|
||||
|
||||
push_constants.resize(shader->push_constant_block_size);
|
||||
|
||||
|
@ -361,7 +361,7 @@ bool SlangPipeline::generate_frame_resources(vk::DescriptorPool pool)
|
|||
.setFlags(vma::AllocationCreateFlagBits::eHostAccessSequentialWrite)
|
||||
.setRequiredFlags(vk::MemoryPropertyFlagBits::eHostVisible);
|
||||
|
||||
std::tie(uniform_buffer, uniform_buffer_allocation) = context->allocator.createBuffer(buffer_create_info, allocation_create_info);
|
||||
std::tie(uniform_buffer, uniform_buffer_allocation) = context->allocator.createBuffer(buffer_create_info, allocation_create_info).value;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -385,7 +385,7 @@ bool SlangPipeline::generate_frame_resources(vk::DescriptorPool pool)
|
|||
.setMaxLod(VK_LOD_CLAMP_NONE)
|
||||
.setAnisotropyEnable(false);
|
||||
|
||||
sampler = device.createSamplerUnique(sampler_create_info);
|
||||
sampler = device.createSamplerUnique(sampler_create_info).value;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ void Swapchain::create_render_pass()
|
|||
.setDependencies(subpass_dependency)
|
||||
.setAttachments(attachment_description);
|
||||
|
||||
render_pass = device.createRenderPassUnique(render_pass_create_info);
|
||||
render_pass = device.createRenderPassUnique(render_pass_create_info).value;
|
||||
}
|
||||
|
||||
bool Swapchain::recreate(int new_width, int new_height)
|
||||
|
@ -95,7 +95,7 @@ bool Swapchain::check_and_resize(int width, int height)
|
|||
|
||||
if (width == -1 && height == -1)
|
||||
{
|
||||
surface_capabilities = physical_device.getSurfaceCapabilitiesKHR(surface);
|
||||
surface_capabilities = physical_device.getSurfaceCapabilitiesKHR(surface).value;
|
||||
width = surface_capabilities.currentExtent.width;
|
||||
height = surface_capabilities.currentExtent.height;
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ bool Swapchain::create(unsigned int desired_num_swapchain_images, int new_width,
|
|||
frames.clear();
|
||||
imageviewfbs.clear();
|
||||
|
||||
auto surface_capabilities = physical_device.getSurfaceCapabilitiesKHR(surface);
|
||||
auto surface_capabilities = physical_device.getSurfaceCapabilitiesKHR(surface).value;
|
||||
|
||||
if (surface_capabilities.minImageCount > desired_num_swapchain_images)
|
||||
num_swapchain_images = surface_capabilities.minImageCount;
|
||||
|
@ -163,7 +163,7 @@ bool Swapchain::create(unsigned int desired_num_swapchain_images, int new_width,
|
|||
if (extents.height < surface_capabilities.minImageExtent.height)
|
||||
extents.height = surface_capabilities.minImageExtent.height;
|
||||
|
||||
auto present_modes = physical_device.getSurfacePresentModesKHR(surface);
|
||||
auto present_modes = physical_device.getSurfacePresentModesKHR(surface).value;
|
||||
auto tearing_present_mode = vk::PresentModeKHR::eFifo;
|
||||
if (std::find(present_modes.begin(), present_modes.end(), vk::PresentModeKHR::eImmediate) != present_modes.end())
|
||||
tearing_present_mode = vk::PresentModeKHR::eImmediate;
|
||||
|
@ -189,7 +189,7 @@ bool Swapchain::create(unsigned int desired_num_swapchain_images, int new_width,
|
|||
swapchain_create_info.setOldSwapchain(swapchain_object.get());
|
||||
|
||||
try {
|
||||
swapchain_object = device.createSwapchainKHRUnique(swapchain_create_info);
|
||||
swapchain_object = device.createSwapchainKHRUnique(swapchain_create_info).value;
|
||||
} catch (std::exception &e) {
|
||||
swapchain_object.reset();
|
||||
}
|
||||
|
@ -197,9 +197,9 @@ bool Swapchain::create(unsigned int desired_num_swapchain_images, int new_width,
|
|||
if (!swapchain_object)
|
||||
return false;
|
||||
|
||||
auto swapchain_images = device.getSwapchainImagesKHR(swapchain_object.get());
|
||||
auto swapchain_images = device.getSwapchainImagesKHR(swapchain_object.get()).value;
|
||||
vk::CommandBufferAllocateInfo command_buffer_allocate_info(command_pool, vk::CommandBufferLevel::ePrimary, swapchain_images.size());
|
||||
auto command_buffers = device.allocateCommandBuffersUnique(command_buffer_allocate_info);
|
||||
auto command_buffers = device.allocateCommandBuffersUnique(command_buffer_allocate_info).value;
|
||||
|
||||
if (imageviewfbs.size() > num_swapchain_images)
|
||||
num_swapchain_images = imageviewfbs.size();
|
||||
|
@ -214,9 +214,9 @@ bool Swapchain::create(unsigned int desired_num_swapchain_images, int new_width,
|
|||
// Create frame queue resources
|
||||
auto &frame = frames[i];
|
||||
frame.command_buffer = std::move(command_buffers[i]);
|
||||
frame.fence = device.createFenceUnique(fence_create_info);
|
||||
frame.acquire = device.createSemaphoreUnique({});
|
||||
frame.complete = device.createSemaphoreUnique({});
|
||||
frame.fence = device.createFenceUnique(fence_create_info).value;
|
||||
frame.acquire = device.createSemaphoreUnique({}).value;
|
||||
frame.complete = device.createSemaphoreUnique({}).value;
|
||||
}
|
||||
current_frame = 0;
|
||||
|
||||
|
@ -231,7 +231,7 @@ bool Swapchain::create(unsigned int desired_num_swapchain_images, int new_width,
|
|||
.setFormat(vk::Format::eB8G8R8A8Unorm)
|
||||
.setComponents(vk::ComponentMapping())
|
||||
.setSubresourceRange(vk::ImageSubresourceRange(vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1));
|
||||
image.image_view = device.createImageViewUnique(image_view_create_info);
|
||||
image.image_view = device.createImageViewUnique(image_view_create_info).value;
|
||||
|
||||
auto framebuffer_create_info = vk::FramebufferCreateInfo{}
|
||||
.setAttachments(image.image_view.get())
|
||||
|
@ -239,7 +239,7 @@ bool Swapchain::create(unsigned int desired_num_swapchain_images, int new_width,
|
|||
.setHeight(extents.height)
|
||||
.setLayers(1)
|
||||
.setRenderPass(render_pass.get());
|
||||
image.framebuffer = device.createFramebufferUnique(framebuffer_create_info);
|
||||
image.framebuffer = device.createFramebufferUnique(framebuffer_create_info).value;
|
||||
}
|
||||
|
||||
device.waitIdle();
|
||||
|
@ -267,12 +267,8 @@ bool Swapchain::begin_frame()
|
|||
}
|
||||
|
||||
vk::ResultValue<uint32_t> result_value(vk::Result::eSuccess, 0);
|
||||
try {
|
||||
result_value = device.acquireNextImageKHR(swapchain_object.get(), UINT64_MAX, frame.acquire.get());
|
||||
} catch (vk::OutOfDateKHRError &e) {
|
||||
result_value.result = vk::Result::eErrorOutOfDateKHR;
|
||||
}
|
||||
|
||||
result_value = device.acquireNextImageKHR(swapchain_object.get(), UINT64_MAX, frame.acquire.get());
|
||||
|
||||
if (result_value.result == vk::Result::eErrorOutOfDateKHR ||
|
||||
result_value.result == vk::Result::eSuboptimalKHR)
|
||||
{
|
||||
|
@ -325,14 +321,12 @@ bool Swapchain::swap()
|
|||
.setImageIndices(current_swapchain_image);
|
||||
|
||||
vk::Result result = vk::Result::eSuccess;
|
||||
try {
|
||||
result = queue.presentKHR(present_info);
|
||||
} catch (vk::OutOfDateKHRError &e) {
|
||||
result = queue.presentKHR(present_info);
|
||||
if (result == vk::Result::eErrorOutOfDateKHR)
|
||||
{
|
||||
// NVIDIA binary drivers will set OutOfDate between acquire and
|
||||
// present. Ignore this and fix it on the next swapchain acquire.
|
||||
} catch (std::exception &e) {
|
||||
printf("%s\n", e.what());
|
||||
}
|
||||
}
|
||||
|
||||
current_frame = (current_frame + 1) % num_swapchain_images;
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ void Texture::from_buffer(vk::CommandBuffer cmd,
|
|||
byte_stride = pixel_size * width;
|
||||
}
|
||||
|
||||
auto map = allocator.mapMemory(buffer_allocation);
|
||||
auto map = allocator.mapMemory(buffer_allocation).value;
|
||||
for (int y = 0; y < height; y++)
|
||||
{
|
||||
auto src = buffer + byte_stride * y;
|
||||
|
@ -206,7 +206,7 @@ void Texture::from_buffer(vk::CommandBuffer cmd,
|
|||
void Texture::from_buffer(uint8_t *buffer, int width, int height, int byte_stride)
|
||||
{
|
||||
vk::CommandBufferAllocateInfo cbai(command_pool, vk::CommandBufferLevel::ePrimary, 1);
|
||||
auto command_buffer_vector = device.allocateCommandBuffersUnique(cbai);
|
||||
auto command_buffer_vector = device.allocateCommandBuffersUnique(cbai).value;
|
||||
auto &cmd = command_buffer_vector[0];
|
||||
cmd->begin({ vk::CommandBufferUsageFlagBits::eOneTimeSubmit });
|
||||
from_buffer(cmd.get(), buffer, width, height, byte_stride);
|
||||
|
@ -241,7 +241,7 @@ void Texture::create(int width, int height, vk::Format fmt, vk::SamplerAddressMo
|
|||
.setSamples(vk::SampleCountFlagBits::e1)
|
||||
.setSharingMode(vk::SharingMode::eExclusive);
|
||||
|
||||
std::tie(image, image_allocation) = allocator.createImage(ici, aci);
|
||||
std::tie(image, image_allocation) = allocator.createImage(ici, aci).value;
|
||||
|
||||
buffer_size = width * height * 4;
|
||||
if (format == vk::Format::eR5G6B5UnormPack16)
|
||||
|
@ -254,7 +254,7 @@ void Texture::create(int width, int height, vk::Format fmt, vk::SamplerAddressMo
|
|||
.setFlags(vma::AllocationCreateFlagBits::eHostAccessSequentialWrite)
|
||||
.setUsage(vma::MemoryUsage::eAutoPreferHost);
|
||||
|
||||
std::tie(buffer, buffer_allocation) = allocator.createBuffer(bci, aci);
|
||||
std::tie(buffer, buffer_allocation) = allocator.createBuffer(bci, aci).value;
|
||||
|
||||
auto isrr = vk::ImageSubresourceRange{}
|
||||
.setAspectMask(vk::ImageAspectFlagBits::eColor)
|
||||
|
@ -269,7 +269,7 @@ void Texture::create(int width, int height, vk::Format fmt, vk::SamplerAddressMo
|
|||
.setComponents(vk::ComponentMapping())
|
||||
.setSubresourceRange(isrr);
|
||||
|
||||
image_view = device.createImageView(ivci);
|
||||
image_view = device.createImageView(ivci).value;
|
||||
|
||||
image_width = width;
|
||||
image_height = height;
|
||||
|
@ -293,7 +293,7 @@ void Texture::create(int width, int height, vk::Format fmt, vk::SamplerAddressMo
|
|||
.setMaxLod(10000.0f)
|
||||
.setMipmapMode(vk::SamplerMipmapMode::eLinear);
|
||||
|
||||
sampler = device.createSampler(sampler_create_info);
|
||||
sampler = device.createSampler(sampler_create_info).value;
|
||||
}
|
||||
|
||||
void Texture::discard_staging_buffer()
|
||||
|
|
|
@ -29,7 +29,7 @@ bool CVulkan::InitImGui()
|
|||
.setPoolSizes(pool_sizes)
|
||||
.setMaxSets(1000)
|
||||
.setFlags(vk::DescriptorPoolCreateFlagBits::eFreeDescriptorSet);
|
||||
imgui_descriptor_pool = context->device.createDescriptorPoolUnique(descriptor_pool_create_info);
|
||||
imgui_descriptor_pool = context->device.createDescriptorPoolUnique(descriptor_pool_create_info).value;
|
||||
|
||||
ImGui_ImplVulkan_InitInfo init_info{};
|
||||
init_info.Instance = context->instance.get();
|
||||
|
@ -286,4 +286,4 @@ std::function<void(const char *)> CVulkan::GetShaderParametersSaveFunction()
|
|||
if (shaderchain)
|
||||
shaderchain->preset->save_to_file(filename);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -118,7 +118,7 @@
|
|||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir);$(ProjectDir)..\;$(ProjectDir)..\..\;$(ProjectDir)zlib\src;$(ProjectDir)..\unzip;$(ProjectDir)libpng\src;$(ProjectDir)..\apu\bapu;$(ProjectDir)..\external\glslang;$(ProjectDir)..\external\stb;$(ProjectDir)..\external\vulkan-headers\include;$(ProjectDir)..\external\VulkanMemoryAllocator-Hpp\include;$(ProjectDir)..\external\fmt\include;$(ProjectDir)..\external\imgui</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>_DEBUG;ALLOW_CPU_OVERCLOCK;HAVE_LIBPNG;JMA_SUPPORT;ZLIB;UNZIP_SUPPORT;__WIN32__;NETPLAY_SUPPORT;D3D_DEBUG_INFO;DIRECTDRAW_SUPPORT;USE_SLANG;%(PreprocessorDefinitions);VK_USE_PLATFORM_WIN32_KHR;VULKAN_HPP_DISPATCH_LOADER_DYNAMIC=1;VMA_DYNAMIC_VULKAN_FUNCTIONS=1;VMA_STATIC_VULKAN_FUNCTIONS=0;VMA_USE_STL_SHARED_MUTEX=0;IMGUI_IMPL_VULKAN_NO_PROTOTYPES</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>_DEBUG;ALLOW_CPU_OVERCLOCK;HAVE_LIBPNG;JMA_SUPPORT;ZLIB;UNZIP_SUPPORT;__WIN32__;NETPLAY_SUPPORT;D3D_DEBUG_INFO;DIRECTDRAW_SUPPORT;USE_SLANG;%(PreprocessorDefinitions);VK_USE_PLATFORM_WIN32_KHR;VULKAN_HPP_DISPATCH_LOADER_DYNAMIC=1;VULKAN_HPP_NO_EXCEPTIONS=1;VULKAN_HPP_NO_DISCARD_WARNINGS=1;VMA_DYNAMIC_VULKAN_FUNCTIONS=1;VMA_STATIC_VULKAN_FUNCTIONS=0;VMA_USE_STL_SHARED_MUTEX=0;IMGUI_IMPL_VULKAN_NO_PROTOTYPES</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<StructMemberAlignment>Default</StructMemberAlignment>
|
||||
<PrecompiledHeader />
|
||||
|
@ -169,7 +169,7 @@
|
|||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir);$(ProjectDir)..\;$(ProjectDir)..\..\;$(ProjectDir)zlib\src;$(ProjectDir)..\unzip;$(ProjectDir)libpng\src;$(ProjectDir)..\apu\bapu;$(ProjectDir)..\external\glslang;$(ProjectDir)..\external\stb;$(ProjectDir)..\external\vulkan-headers\include;$(ProjectDir)..\external\VulkanMemoryAllocator-Hpp\include;$(ProjectDir)..\external\fmt\include;$(ProjectDir)..\external\imgui</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>_DEBUG;ALLOW_CPU_OVERCLOCK;HAVE_LIBPNG;JMA_SUPPORT;ZLIB;UNZIP_SUPPORT;__WIN32__;NETPLAY_SUPPORT;D3D_DEBUG_INFO;DIRECTDRAW_SUPPORT;USE_SLANG;%(PreprocessorDefinitions);VK_USE_PLATFORM_WIN32_KHR;VULKAN_HPP_DISPATCH_LOADER_DYNAMIC=1;VMA_DYNAMIC_VULKAN_FUNCTIONS=1;VMA_STATIC_VULKAN_FUNCTIONS=0;VMA_USE_STL_SHARED_MUTEX=0;IMGUI_IMPL_VULKAN_NO_PROTOTYPES</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>_DEBUG;ALLOW_CPU_OVERCLOCK;HAVE_LIBPNG;JMA_SUPPORT;ZLIB;UNZIP_SUPPORT;__WIN32__;NETPLAY_SUPPORT;D3D_DEBUG_INFO;DIRECTDRAW_SUPPORT;USE_SLANG;%(PreprocessorDefinitions);VK_USE_PLATFORM_WIN32_KHR;VULKAN_HPP_DISPATCH_LOADER_DYNAMIC=1;VULKAN_HPP_NO_EXCEPTIONS=1;VULKAN_HPP_NO_DISCARD_WARNINGS=1;VMA_DYNAMIC_VULKAN_FUNCTIONS=1;VMA_STATIC_VULKAN_FUNCTIONS=0;VMA_USE_STL_SHARED_MUTEX=0;IMGUI_IMPL_VULKAN_NO_PROTOTYPES</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<StructMemberAlignment>Default</StructMemberAlignment>
|
||||
<PrecompiledHeader />
|
||||
|
@ -225,7 +225,7 @@
|
|||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir);$(ProjectDir)..\;$(ProjectDir)..\..\;$(ProjectDir)zlib\src;$(ProjectDir)..\unzip;$(ProjectDir)libpng\src;$(ProjectDir)..\apu\bapu;$(ProjectDir)..\external\glslang;$(ProjectDir)..\external\stb;$(ProjectDir)..\external\vulkan-headers\include;$(ProjectDir)..\external\VulkanMemoryAllocator-Hpp\include;$(ProjectDir)..\external\fmt\include;$(ProjectDir)..\external\imgui</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>NDEBUG;ALLOW_CPU_OVERCLOCK;HAVE_LIBPNG;JMA_SUPPORT;ZLIB;UNZIP_SUPPORT;__WIN32__;NETPLAY_SUPPORT;DIRECTDRAW_SUPPORT;USE_SLANG;%(PreprocessorDefinitions);VK_USE_PLATFORM_WIN32_KHR;VULKAN_HPP_DISPATCH_LOADER_DYNAMIC=1;VMA_DYNAMIC_VULKAN_FUNCTIONS=1;VMA_STATIC_VULKAN_FUNCTIONS=0;VMA_USE_STL_SHARED_MUTEX=0;IMGUI_IMPL_VULKAN_NO_PROTOTYPES</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>NDEBUG;ALLOW_CPU_OVERCLOCK;HAVE_LIBPNG;JMA_SUPPORT;ZLIB;UNZIP_SUPPORT;__WIN32__;NETPLAY_SUPPORT;DIRECTDRAW_SUPPORT;USE_SLANG;%(PreprocessorDefinitions);VK_USE_PLATFORM_WIN32_KHR;VULKAN_HPP_DISPATCH_LOADER_DYNAMIC=1;VULKAN_HPP_NO_EXCEPTIONS=1;VULKAN_HPP_NO_DISCARD_WARNINGS=1;VMA_DYNAMIC_VULKAN_FUNCTIONS=1;VMA_STATIC_VULKAN_FUNCTIONS=0;VMA_USE_STL_SHARED_MUTEX=0;IMGUI_IMPL_VULKAN_NO_PROTOTYPES</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<StructMemberAlignment>Default</StructMemberAlignment>
|
||||
|
@ -280,7 +280,7 @@
|
|||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir);$(ProjectDir)..\;$(ProjectDir)..\..\;$(ProjectDir)zlib\src;$(ProjectDir)..\unzip;$(ProjectDir)libpng\src;$(ProjectDir)..\apu\bapu;$(ProjectDir)..\external\glslang;$(ProjectDir)..\external\stb;$(ProjectDir)..\external\vulkan-headers\include;$(ProjectDir)..\external\VulkanMemoryAllocator-Hpp\include;$(ProjectDir)..\external\fmt\include;$(ProjectDir)..\external\imgui</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>NDEBUG;ALLOW_CPU_OVERCLOCK;HAVE_LIBPNG;JMA_SUPPORT;ZLIB;UNZIP_SUPPORT;__WIN32__;NETPLAY_SUPPORT;DIRECTDRAW_SUPPORT;USE_SLANG;%(PreprocessorDefinitions);VK_USE_PLATFORM_WIN32_KHR;VULKAN_HPP_DISPATCH_LOADER_DYNAMIC=1;VMA_DYNAMIC_VULKAN_FUNCTIONS=1;VMA_STATIC_VULKAN_FUNCTIONS=0;VMA_USE_STL_SHARED_MUTEX=0;IMGUI_IMPL_VULKAN_NO_PROTOTYPES</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>NDEBUG;ALLOW_CPU_OVERCLOCK;HAVE_LIBPNG;JMA_SUPPORT;ZLIB;UNZIP_SUPPORT;__WIN32__;NETPLAY_SUPPORT;DIRECTDRAW_SUPPORT;USE_SLANG;%(PreprocessorDefinitions);VK_USE_PLATFORM_WIN32_KHR;VULKAN_HPP_DISPATCH_LOADER_DYNAMIC=1;VULKAN_HPP_NO_EXCEPTIONS=1;VULKAN_HPP_NO_DISCARD_WARNINGS=1;VMA_DYNAMIC_VULKAN_FUNCTIONS=1;VMA_STATIC_VULKAN_FUNCTIONS=0;VMA_USE_STL_SHARED_MUTEX=0;IMGUI_IMPL_VULKAN_NO_PROTOTYPES</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<StructMemberAlignment>Default</StructMemberAlignment>
|
||||
|
@ -708,4 +708,4 @@
|
|||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
Loading…
Reference in New Issue