VERY experimental Nintendo Switch 2 emulator
C++
[vk] unify VkSurfaceKHR with Android and the rest of platforms; remove technically incorrect nullptr() ctor for handles (#2971)
lizzie9a07bd0570ce
diff --git a/src/video_core/renderer_vulkan/blit_image.cpp b/src/video_core/renderer_vulkan/blit_image.cppindex 07611ef98c..789f4da2ed 100644--- a/src/video_core/renderer_vulkan/blit_image.cpp+++ b/src/video_core/renderer_vulkan/blit_image.cpp@@ -1032,7 +1032,7 @@ void BlitImageHelper::ConvertDepthToColorPipeline(vk::Pipeline& pipeline, VkRendVkShaderModule frag_shader = *convert_float_to_depth_frag;const std::array stages = MakeStages(*full_screen_vert, frag_shader);const VkPipelineInputAssemblyStateCreateInfo input_assembly_ci = GetPipelineInputAssemblyStateCreateInfo(device);- pipeline = device.GetLogical().CreateGraphicsPipeline({+ pipeline = device.GetLogical().CreateGraphicsPipeline(VkGraphicsPipelineCreateInfo{.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,.pNext = nullptr,.flags = 0,@@ -1062,7 +1062,7 @@ void BlitImageHelper::ConvertColorToDepthPipeline(vk::Pipeline& pipeline, VkRendVkShaderModule frag_shader = *convert_depth_to_float_frag;const std::array stages = MakeStages(*full_screen_vert, frag_shader);const VkPipelineInputAssemblyStateCreateInfo input_assembly_ci = GetPipelineInputAssemblyStateCreateInfo(device);- pipeline = device.GetLogical().CreateGraphicsPipeline({+ pipeline = device.GetLogical().CreateGraphicsPipeline(VkGraphicsPipelineCreateInfo{.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,.pNext = nullptr,.flags = 0,@@ -1093,7 +1093,7 @@ void BlitImageHelper::ConvertPipelineEx(vk::Pipeline& pipeline, VkRenderPass ren}const std::array stages = MakeStages(*full_screen_vert, *module);const VkPipelineInputAssemblyStateCreateInfo input_assembly_ci = GetPipelineInputAssemblyStateCreateInfo(device);- pipeline = device.GetLogical().CreateGraphicsPipeline({+ pipeline = device.GetLogical().CreateGraphicsPipeline(VkGraphicsPipelineCreateInfo{.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,.pNext = nullptr,.flags = 0,@@ -1135,7 +1135,7 @@ void BlitImageHelper::ConvertPipeline(vk::Pipeline& pipeline, VkRenderPass rendeis_target_depth ? *convert_float_to_depth_frag : *convert_depth_to_float_frag;const std::array stages = MakeStages(*full_screen_vert, frag_shader);const VkPipelineInputAssemblyStateCreateInfo input_assembly_ci = GetPipelineInputAssemblyStateCreateInfo(device);- pipeline = device.GetLogical().CreateGraphicsPipeline({+ pipeline = device.GetLogical().CreateGraphicsPipeline(VkGraphicsPipelineCreateInfo{.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,.pNext = nullptr,.flags = 0,diff --git a/src/video_core/renderer_vulkan/renderer_vulkan.cpp b/src/video_core/renderer_vulkan/renderer_vulkan.cppindex d1e607e75f..cb1b1a5362 100644--- a/src/video_core/renderer_vulkan/renderer_vulkan.cpp+++ b/src/video_core/renderer_vulkan/renderer_vulkan.cpp@@ -137,14 +137,8 @@ trymemory_allocator,scheduler,swapchain,-#ifdef ANDROID- surface)- ,-#else*surface)- ,-#endif- blit_swapchain(device_memory,+ , blit_swapchain(device_memory,device,memory_allocator,present_manager,diff --git a/src/video_core/renderer_vulkan/vk_compute_pass.cpp b/src/video_core/renderer_vulkan/vk_compute_pass.cppindex 22e646afe9..d45a57f7bb 100644--- a/src/video_core/renderer_vulkan/vk_compute_pass.cpp+++ b/src/video_core/renderer_vulkan/vk_compute_pass.cpp@@ -285,7 +285,7 @@ ComputePass::ComputePass(const Device& device_, DescriptorPool& descriptor_pool,.requiredSubgroupSize = optional_subgroup_size ? *optional_subgroup_size : 32U,};bool use_setup_size = device.IsExtSubgroupSizeControlSupported() && optional_subgroup_size;- pipeline = device.GetLogical().CreateComputePipeline({+ pipeline = device.GetLogical().CreateComputePipeline(VkComputePipelineCreateInfo{.sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,.pNext = nullptr,.flags = 0,@@ -299,7 +299,7 @@ ComputePass::ComputePass(const Device& device_, DescriptorPool& descriptor_pool,.pSpecializationInfo = nullptr,},.layout = *layout,- .basePipelineHandle = nullptr,+ .basePipelineHandle = {},.basePipelineIndex = 0,});}@@ -944,7 +944,7 @@ MSAACopyPass::MSAACopyPass(const Device& device_, Scheduler& scheduler_,.codeSize = static_cast<u32>(code.size_bytes()),.pCode = code.data(),});- pipelines[i] = device.GetLogical().CreateComputePipeline({+ pipelines[i] = device.GetLogical().CreateComputePipeline(VkComputePipelineCreateInfo{.sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,.pNext = nullptr,.flags = 0,@@ -958,7 +958,7 @@ MSAACopyPass::MSAACopyPass(const Device& device_, Scheduler& scheduler_,.pSpecializationInfo = nullptr,},.layout = *layout,- .basePipelineHandle = nullptr,+ .basePipelineHandle = {},.basePipelineIndex = 0,});};diff --git a/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp b/src/video_core/renderer_vulkan/vk_compute_pipeline.cppindex 6a6fe2b830..1a62324c95 100644--- a/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp+++ b/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp@@ -67,26 +67,24 @@ ComputePipeline::ComputePipeline(const Device& device_, vk::PipelineCache& pipelif (device.IsKhrPipelineExecutablePropertiesEnabled() && Settings::values.renderer_debug.GetValue()) {flags |= VK_PIPELINE_CREATE_CAPTURE_STATISTICS_BIT_KHR;}- pipeline = device.GetLogical().CreateComputePipeline(- {- .sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,- .pNext = nullptr,- .flags = flags,- .stage{- .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,- .pNext =- device.IsExtSubgroupSizeControlSupported() ? &subgroup_size_ci : nullptr,- .flags = 0,- .stage = VK_SHADER_STAGE_COMPUTE_BIT,- .module = *spv_module,- .pName = "main",- .pSpecializationInfo = nullptr,- },- .layout = *pipeline_layout,- .basePipelineHandle = 0,- .basePipelineIndex = 0,+ pipeline = device.GetLogical().CreateComputePipeline(VkComputePipelineCreateInfo{+ .sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,+ .pNext = nullptr,+ .flags = flags,+ .stage{+ .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,+ .pNext =+ device.IsExtSubgroupSizeControlSupported() ? &subgroup_size_ci : nullptr,+ .flags = 0,+ .stage = VK_SHADER_STAGE_COMPUTE_BIT,+ .module = *spv_module,+ .pName = "main",+ .pSpecializationInfo = nullptr,},- *pipeline_cache);+ .layout = *pipeline_layout,+ .basePipelineHandle = 0,+ .basePipelineIndex = 0,+ }, *pipeline_cache);// Log compute pipeline creationif (Settings::values.gpu_logging_enabled.GetValue()) {diff --git a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cppindex 5b11a34232..e989bf6b31 100644--- a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp+++ b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp@@ -946,29 +946,27 @@ void GraphicsPipeline::MakePipeline(VkRenderPass render_pass) {flags |= VK_PIPELINE_CREATE_CAPTURE_STATISTICS_BIT_KHR;}- pipeline = device.GetLogical().CreateGraphicsPipeline(- {- .sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,- .pNext = nullptr,- .flags = flags,- .stageCount = static_cast<u32>(shader_stages.size()),- .pStages = shader_stages.data(),- .pVertexInputState = &vertex_input_ci,- .pInputAssemblyState = &input_assembly_ci,- .pTessellationState = &tessellation_ci,- .pViewportState = &viewport_ci,- .pRasterizationState = &rasterization_ci,- .pMultisampleState = &multisample_ci,- .pDepthStencilState = &depth_stencil_ci,- .pColorBlendState = &color_blend_ci,- .pDynamicState = &dynamic_state_ci,- .layout = *pipeline_layout,- .renderPass = render_pass,- .subpass = 0,- .basePipelineHandle = nullptr,- .basePipelineIndex = 0,- },- *pipeline_cache);+ pipeline = device.GetLogical().CreateGraphicsPipeline({+ .sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,+ .pNext = nullptr,+ .flags = flags,+ .stageCount = static_cast<u32>(shader_stages.size()),+ .pStages = shader_stages.data(),+ .pVertexInputState = &vertex_input_ci,+ .pInputAssemblyState = &input_assembly_ci,+ .pTessellationState = &tessellation_ci,+ .pViewportState = &viewport_ci,+ .pRasterizationState = &rasterization_ci,+ .pMultisampleState = &multisample_ci,+ .pDepthStencilState = &depth_stencil_ci,+ .pColorBlendState = &color_blend_ci,+ .pDynamicState = &dynamic_state_ci,+ .layout = *pipeline_layout,+ .renderPass = render_pass,+ .subpass = 0,+ .basePipelineHandle = nullptr,+ .basePipelineIndex = 0,+ }, *pipeline_cache);// Log graphics pipeline creationif (Settings::values.gpu_logging_enabled.GetValue()) {diff --git a/src/video_core/renderer_vulkan/vk_present_manager.cpp b/src/video_core/renderer_vulkan/vk_present_manager.cppindex 3b5c2e3c01..aa019a4160 100644--- a/src/video_core/renderer_vulkan/vk_present_manager.cpp+++ b/src/video_core/renderer_vulkan/vk_present_manager.cpp@@ -1,4 +1,4 @@-// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project+// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project// SPDX-License-Identifier: GPL-3.0-or-later// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project@@ -101,22 +101,14 @@ PresentManager::PresentManager(const vk::Instance& instance_,MemoryAllocator& memory_allocator_,Scheduler& scheduler_,Swapchain& swapchain_,-#ifdef ANDROID- vk::SurfaceKHR& surface_)-#else- VkSurfaceKHR_T* surface_handle_)-#endif+ VkSurfaceKHR_T* surface_): instance{instance_}, render_window{render_window_}, device{device_}, memory_allocator{memory_allocator_}, scheduler{scheduler_}, swapchain{swapchain_}-#ifdef ANDROID, surface{surface_}-#else- , surface_handle{surface_handle_}-#endif, blit_supported{CanBlitToSwapchain(device.GetPhysical(), swapchain.GetImageViewFormat())}, use_present_thread{Settings::values.async_presentation.GetValue()}{@@ -299,11 +291,7 @@ void PresentManager::PresentThread(std::stop_token token) {}void PresentManager::RecreateSwapchain(Frame* frame) {-#ifndef ANDROID- swapchain.Create(surface_handle, frame->width, frame->height); // Pass raw pointer-#else- swapchain.Create(*surface, frame->width, frame->height); // Pass raw pointer-#endif+ swapchain.Create(surface, frame->width, frame->height); // Pass raw pointerSetImageCount();}@@ -322,7 +310,7 @@ void PresentManager::CopyToSwapchain(Frame* frame) {// Recreate surface and swapchain if needed.if (requires_recreation) {#ifdef ANDROID- surface = CreateSurface(instance, render_window.GetWindowInfo());+ surface = *CreateSurface(instance, render_window.GetWindowInfo()).address();#endifRecreateSwapchain(frame);}diff --git a/src/video_core/renderer_vulkan/vk_present_manager.h b/src/video_core/renderer_vulkan/vk_present_manager.hindex aacc9b025a..3d5cc32102 100644--- a/src/video_core/renderer_vulkan/vk_present_manager.h+++ b/src/video_core/renderer_vulkan/vk_present_manager.h@@ -1,4 +1,4 @@-// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project+// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project// SPDX-License-Identifier: GPL-3.0-or-later// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project@@ -15,8 +15,6 @@#include "video_core/vulkan_common/vulkan_memory_allocator.h"#include "video_core/vulkan_common/vulkan_wrapper.h"-struct VkSurfaceKHR_T;-namespace Core::Frontend {class EmuWindow;} // namespace Core::Frontend@@ -46,11 +44,7 @@ public:MemoryAllocator& memory_allocator,Scheduler& scheduler,Swapchain& swapchain,-#ifdef ANDROID- vk::SurfaceKHR& surface);-#else- VkSurfaceKHR_T* surface_handle);-#endif+ VkSurfaceKHR_T* surface);~PresentManager();/// Returns the last used presentation frame@@ -84,11 +78,7 @@ private:MemoryAllocator& memory_allocator;Scheduler& scheduler;Swapchain& swapchain;-#ifdef ANDROID- vk::SurfaceKHR& surface;-#else- VkSurfaceKHR_T* surface_handle;-#endif+ VkSurfaceKHR_T* surface;vk::CommandPool cmdpool;std::vector<Frame> frames;boost::container::deque<Frame*> present_queue;diff --git a/src/video_core/renderer_vulkan/vk_query_cache.cpp b/src/video_core/renderer_vulkan/vk_query_cache.cppindex 415259c72c..7cdb3acadd 100644--- a/src/video_core/renderer_vulkan/vk_query_cache.cpp+++ b/src/video_core/renderer_vulkan/vk_query_cache.cpp@@ -1280,7 +1280,7 @@ void QueryCacheRuntime::EndHostConditionalRendering() {PauseHostConditionalRendering();impl->hcr_is_set = false;impl->is_hcr_running = false;- impl->hcr_buffer = nullptr;+ impl->hcr_buffer = VkBuffer{};impl->hcr_offset = 0;}diff --git a/src/video_core/renderer_vulkan/vk_query_cache.h b/src/video_core/renderer_vulkan/vk_query_cache.hindex b8dae9bc2d..e2aa4d991e 100644--- a/src/video_core/renderer_vulkan/vk_query_cache.h+++ b/src/video_core/renderer_vulkan/vk_query_cache.h@@ -1,3 +1,6 @@+// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project+// SPDX-License-Identifier: GPL-3.0-or-later+// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project// SPDX-License-Identifier: GPL-3.0-or-later@@ -35,7 +38,7 @@ public:~QueryCacheRuntime();template <typename SyncValuesType>- void SyncValues(std::span<SyncValuesType> values, VkBuffer base_src_buffer = nullptr);+ void SyncValues(std::span<SyncValuesType> values, VkBuffer base_src_buffer = VkBuffer{});void Barriers(bool is_prebarrier);diff --git a/src/video_core/renderer_vulkan/vk_scheduler.cpp b/src/video_core/renderer_vulkan/vk_scheduler.cppindex 0a032cdae0..947de6a80e 100644--- a/src/video_core/renderer_vulkan/vk_scheduler.cpp+++ b/src/video_core/renderer_vulkan/vk_scheduler.cpp@@ -377,7 +377,7 @@ void Scheduler::EndRenderPass()VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, 0, nullptr, nullptr, vk::Span(barriers.data(), num_images));});- state.renderpass = nullptr;+ state.renderpass = VkRenderPass{};num_renderpass_images = 0;}diff --git a/src/video_core/renderer_vulkan/vk_scheduler.h b/src/video_core/renderer_vulkan/vk_scheduler.hindex 667f136ee6..00a912f2cd 100644--- a/src/video_core/renderer_vulkan/vk_scheduler.h+++ b/src/video_core/renderer_vulkan/vk_scheduler.h@@ -44,10 +44,10 @@ public:~Scheduler();/// Sends the current execution context to the GPU.- u64 Flush(VkSemaphore signal_semaphore = nullptr, VkSemaphore wait_semaphore = nullptr);+ u64 Flush(VkSemaphore signal_semaphore = {}, VkSemaphore wait_semaphore = {});/// Sends the current execution context to the GPU and waits for it to complete.- void Finish(VkSemaphore signal_semaphore = nullptr, VkSemaphore wait_semaphore = nullptr);+ void Finish(VkSemaphore signal_semaphore = {}, VkSemaphore wait_semaphore = {});/// Waits for the worker thread to finish executing everything. After this function returns it's/// safe to touch worker resources.@@ -237,8 +237,8 @@ private:};struct State {- VkRenderPass renderpass = nullptr;- VkFramebuffer framebuffer = nullptr;+ VkRenderPass renderpass{};+ VkFramebuffer framebuffer{};VkExtent2D render_area = {0, 0};GraphicsPipeline* graphics_pipeline = nullptr;bool is_rescaling = false;diff --git a/src/video_core/renderer_vulkan/vk_swapchain.cpp b/src/video_core/renderer_vulkan/vk_swapchain.cppindex b89e981444..cd8f948d8b 100644--- a/src/video_core/renderer_vulkan/vk_swapchain.cpp+++ b/src/video_core/renderer_vulkan/vk_swapchain.cpp@@ -109,38 +109,22 @@ VkCompositeAlphaFlagBitsKHR ChooseAlphaFlags(const VkSurfaceCapabilitiesKHR& cap} // Anonymous namespaceSwapchain::Swapchain(-#ifdef ANDROID- VkSurfaceKHR surface_,-#else- VkSurfaceKHR_T* surface_handle_,-#endif+ VkSurfaceKHR_T* surface_,const Device& device_,Scheduler& scheduler_,u32 width_,u32 height_)-#ifdef ANDROID: surface(surface_)-#else- : surface_handle{surface_handle_}-#endif, device{device_}, scheduler{scheduler_}{-#ifdef ANDROIDCreate(surface, width_, height_);-#else- Create(surface_handle, width_, height_);-#endif}Swapchain::~Swapchain() = default;void Swapchain::Create(-#ifdef ANDROID- VkSurfaceKHR surface_,-#else- VkSurfaceKHR_T* surface_handle_,-#endif+ VkSurfaceKHR_T* surface_,u32 width_,u32 height_){@@ -148,18 +132,10 @@ void Swapchain::Create(is_suboptimal = false;width = width_;height = height_;-#ifdef ANDROIDsurface = surface_;-#else- surface_handle = surface_handle_;-#endifconst auto physical_device = device.GetPhysical();-#ifdef ANDROID- const auto capabilities{physical_device.GetSurfaceCapabilitiesKHR(surface)};-#else- const auto capabilities{physical_device.GetSurfaceCapabilitiesKHR(surface_handle)};-#endif+ const auto capabilities{physical_device.GetSurfaceCapabilitiesKHR(VkSurfaceKHR(surface))};if (capabilities.maxImageExtent.width == 0 || capabilities.maxImageExtent.height == 0) {return;}@@ -254,14 +230,8 @@ void Swapchain::Present(VkSemaphore render_semaphore) {void Swapchain::CreateSwapchain(const VkSurfaceCapabilitiesKHR& capabilities) {const auto physical_device{device.GetPhysical()};--#ifdef ANDROID- const auto formats{physical_device.GetSurfaceFormatsKHR(surface)};- const auto present_modes = physical_device.GetSurfacePresentModesKHR(surface);-#else- const auto formats{physical_device.GetSurfaceFormatsKHR(surface_handle)};- const auto present_modes = physical_device.GetSurfacePresentModesKHR(surface_handle);-#endif+ const auto formats{physical_device.GetSurfaceFormatsKHR(VkSurfaceKHR(surface))};+ const auto present_modes = physical_device.GetSurfacePresentModesKHR(VkSurfaceKHR(surface));has_mailbox = std::find(present_modes.begin(), present_modes.end(), VK_PRESENT_MODE_MAILBOX_KHR)!= present_modes.end();@@ -290,11 +260,7 @@ void Swapchain::CreateSwapchain(const VkSurfaceCapabilitiesKHR& capabilities) {.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR,.pNext = nullptr,.flags = 0,-#ifdef ANDROID- .surface = surface,-#else- .surface = surface_handle,-#endif+ .surface = VkSurfaceKHR(surface),.minImageCount = requested_image_count,.imageFormat = surface_format.format,.imageColorSpace = surface_format.colorSpace,@@ -313,7 +279,7 @@ void Swapchain::CreateSwapchain(const VkSurfaceCapabilitiesKHR& capabilities) {.compositeAlpha = alpha_flags,.presentMode = present_mode,.clipped = VK_FALSE,- .oldSwapchain = nullptr,+ .oldSwapchain = VkSwapchainKHR{},};const u32 graphics_family{device.GetGraphicsFamily()};const u32 present_family{device.GetPresentFamily()};@@ -345,11 +311,7 @@ void Swapchain::CreateSwapchain(const VkSurfaceCapabilitiesKHR& capabilities) {swapchain_ci.flags |= VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR;}// Request the size again to reduce the possibility of a TOCTOU race condition.-#ifdef ANDROID- const auto updated_capabilities = physical_device.GetSurfaceCapabilitiesKHR(surface);-#else- const auto updated_capabilities = physical_device.GetSurfaceCapabilitiesKHR(surface_handle);-#endif+ const auto updated_capabilities = physical_device.GetSurfaceCapabilitiesKHR(VkSurfaceKHR(surface));swapchain_ci.imageExtent = ChooseSwapExtent(updated_capabilities, width, height);// Don't add code within this and the swapchain creation.swapchain = device.GetLogical().CreateSwapchainKHR(swapchain_ci);diff --git a/src/video_core/renderer_vulkan/vk_swapchain.h b/src/video_core/renderer_vulkan/vk_swapchain.hindex 7e99bf8fa7..d926cc118a 100644--- a/src/video_core/renderer_vulkan/vk_swapchain.h+++ b/src/video_core/renderer_vulkan/vk_swapchain.h@@ -1,4 +1,4 @@-// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project+// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project// SPDX-License-Identifier: GPL-3.0-or-later// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project@@ -11,8 +11,6 @@#include "common/common_types.h"#include "video_core/vulkan_common/vulkan_wrapper.h"-struct VkSurfaceKHR_T;-namespace Layout {struct FramebufferLayout;}@@ -25,11 +23,7 @@ class Scheduler;class Swapchain {public:explicit Swapchain(-#ifdef ANDROID- VkSurfaceKHR surface,-#else- VkSurfaceKHR_T* surface_handle,-#endif+ VkSurfaceKHR_T* surface,const Device& device,Scheduler& scheduler,u32 width,@@ -38,11 +32,7 @@ public:/// Creates (or recreates) the swapchain with a given size.void Create(-#ifdef ANDROID- VkSurfaceKHR surface,-#else- VkSurfaceKHR_T* surface_handle,-#endif+ VkSurfaceKHR_T* surface,u32 width,u32 height);@@ -128,11 +118,7 @@ private:bool NeedsPresentModeUpdate() const;-#ifdef ANDROID- VkSurfaceKHR surface;-#else- VkSurfaceKHR_T* surface_handle;-#endif+ VkSurfaceKHR_T* surface;const Device& device;Scheduler& scheduler;diff --git a/src/video_core/vulkan_common/vulkan.h b/src/video_core/vulkan_common/vulkan.hindex 8d2e8e2a37..2cc0f0d7f0 100644--- a/src/video_core/vulkan_common/vulkan.h+++ b/src/video_core/vulkan_common/vulkan.h@@ -1,4 +1,4 @@-// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project+// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project// SPDX-License-Identifier: GPL-3.0-or-later// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project@@ -40,3 +40,6 @@#undef False#undef None#undef True++// "Catch-all" handle for both Android and.. the rest of platforms+struct VkSurfaceKHR_T;diff --git a/src/video_core/vulkan_common/vulkan_device.cpp b/src/video_core/vulkan_common/vulkan_device.cppindex a2ff3ee6ed..b51c57d380 100644--- a/src/video_core/vulkan_common/vulkan_device.cpp+++ b/src/video_core/vulkan_common/vulkan_device.cpp@@ -419,7 +419,7 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR: instance{instance_}, dld{dld_}, physical{physical_},format_properties(GetFormatProperties(physical)) {// Get suitability and device properties.- const bool is_suitable = GetSuitability(surface != nullptr);+ const bool is_suitable = GetSuitability(surface != VkSurfaceKHR{});const VkDriverId driver_id = properties.driver.driverID;diff --git a/src/video_core/vulkan_common/vulkan_surface.cpp b/src/video_core/vulkan_common/vulkan_surface.cppindex dc65d3960a..761b7759c8 100644--- a/src/video_core/vulkan_common/vulkan_surface.cpp+++ b/src/video_core/vulkan_common/vulkan_surface.cpp@@ -15,7 +15,7 @@ vk::SurfaceKHR CreateSurface(const vk::Instance& instance,[[maybe_unused]] const Core::Frontend::EmuWindow::WindowSystemInfo& window_info) {[[maybe_unused]] const vk::InstanceDispatch& dld = instance.Dispatch();- VkSurfaceKHR unsafe_surface = nullptr;+ VkSurfaceKHR unsafe_surface = VkSurfaceKHR{};#ifdef _WIN32if (window_info.type == Core::Frontend::WindowSystemType::Windows) {diff --git a/src/video_core/vulkan_common/vulkan_wrapper.h b/src/video_core/vulkan_common/vulkan_wrapper.hindex 5c04132f7b..872fbd858e 100644--- a/src/video_core/vulkan_common/vulkan_wrapper.h+++ b/src/video_core/vulkan_common/vulkan_wrapper.h@@ -404,13 +404,13 @@ public:/// Construct a handle transferring the ownership from another handle.Handle(Handle&& rhs) noexcept- : handle{std::exchange(rhs.handle, nullptr)}, owner{rhs.owner}, dld{rhs.dld} {}+ : handle{std::exchange(rhs.handle, Type{})}, owner{rhs.owner}, dld{rhs.dld} {}/// Assign the current handle transferring the ownership from another handle./// Destroys any previously held object.Handle& operator=(Handle&& rhs) noexcept {Release();- handle = std::exchange(rhs.handle, nullptr);+ handle = std::exchange(rhs.handle, Type{});owner = rhs.owner;dld = rhs.dld;return *this;@@ -424,7 +424,7 @@ public:/// Destroys any held object.void reset() noexcept {Release();- handle = nullptr;+ handle = Type{};}/// Returns the address of the held object.@@ -440,7 +440,7 @@ public:/// Returns true when there's a held object.explicit operator bool() const noexcept {- return handle != nullptr;+ return handle != Type{};}#ifndef ANDROID@@ -455,7 +455,7 @@ public:#endifprotected:- Type handle = nullptr;+ Type handle{};OwnerType owner = nullptr;const Dispatch* dld = nullptr;@@ -463,7 +463,7 @@ private:/// Destroys the held object if it exists.void Release() noexcept {if (handle) {- Destroy(owner, handle, *dld);+ Destroy(OwnerType(owner), Type(handle), *dld);}}};@@ -506,7 +506,7 @@ public:/// Destroys any held object.void reset() noexcept {Release();- handle = nullptr;+ handle = {};}/// Returns the address of the held object.@@ -522,7 +522,7 @@ public:/// Returns true when there's a held object.explicit operator bool() const noexcept {- return handle != nullptr;+ return handle != Type{};}#ifndef ANDROID@@ -537,7 +537,7 @@ public:#endifprotected:- Type handle = nullptr;+ Type handle{};const Dispatch* dld = nullptr;private:@@ -607,7 +607,7 @@ private:std::unique_ptr<AllocationType[]> allocations;std::size_t num = 0;VkDevice device = nullptr;- PoolType pool = nullptr;+ PoolType pool{};const DeviceDispatch* dld = nullptr;};@@ -669,12 +669,12 @@ public:Image& operator=(const Image&) = delete;Image(Image&& rhs) noexcept- : handle{std::exchange(rhs.handle, nullptr)}, usage{rhs.usage}, owner{rhs.owner},+ : handle{std::exchange(rhs.handle, VkImage{})}, usage{rhs.usage}, owner{rhs.owner},allocator{rhs.allocator}, allocation{rhs.allocation}, dld{rhs.dld} {}Image& operator=(Image&& rhs) noexcept {Release();- handle = std::exchange(rhs.handle, nullptr);+ handle = std::exchange(rhs.handle, VkImage{});usage = rhs.usage;owner = rhs.owner;allocator = rhs.allocator;@@ -693,11 +693,11 @@ public:void reset() noexcept {Release();- handle = nullptr;+ handle = VkImage{};}explicit operator bool() const noexcept {- return handle != nullptr;+ return handle != VkImage{};}void SetObjectNameEXT(const char* name) const;@@ -709,7 +709,7 @@ public:private:void Release() const noexcept;- VkImage handle = nullptr;+ VkImage handle{};VkImageUsageFlags usage{};VkDevice owner = nullptr;VmaAllocator allocator = nullptr;@@ -730,13 +730,13 @@ public:Buffer& operator=(const Buffer&) = delete;Buffer(Buffer&& rhs) noexcept- : handle{std::exchange(rhs.handle, nullptr)}, owner{rhs.owner}, allocator{rhs.allocator},+ : handle{std::exchange(rhs.handle, VkBuffer{})}, owner{rhs.owner}, allocator{rhs.allocator},allocation{rhs.allocation}, mapped{rhs.mapped},is_coherent{rhs.is_coherent}, dld{rhs.dld} {}Buffer& operator=(Buffer&& rhs) noexcept {Release();- handle = std::exchange(rhs.handle, nullptr);+ handle = std::exchange(rhs.handle, VkBuffer{});owner = rhs.owner;allocator = rhs.allocator;allocation = rhs.allocation;@@ -756,11 +756,11 @@ public:void reset() noexcept {Release();- handle = nullptr;+ handle = VkBuffer{};}explicit operator bool() const noexcept {- return handle != nullptr;+ return handle != VkBuffer{};}/// Returns the host mapped memory, an empty span otherwise.@@ -786,7 +786,7 @@ public:private:void Release() const noexcept;- VkBuffer handle = nullptr;+ VkBuffer handle{};VkDevice owner = nullptr;VmaAllocator allocator = nullptr;VmaAllocation allocation = nullptr;@@ -1020,10 +1020,10 @@ public:[[nodiscard]] PipelineLayout CreatePipelineLayout(const VkPipelineLayoutCreateInfo& ci) const;[[nodiscard]] Pipeline CreateGraphicsPipeline(const VkGraphicsPipelineCreateInfo& ci,- VkPipelineCache cache = nullptr) const;+ VkPipelineCache cache = {}) const;[[nodiscard]] Pipeline CreateComputePipeline(const VkComputePipelineCreateInfo& ci,- VkPipelineCache cache = nullptr) const;+ VkPipelineCache cache = {}) const;[[nodiscard]] Sampler CreateSampler(const VkSamplerCreateInfo& ci) const;