From c29584a0906e4d9a624b58467a74ff9d04c8d5de Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Tue, 21 Jan 2020 17:41:09 -0300 Subject: yuzu_cmd: Fix memcpy on Vulkan handlers --- src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp | 15 ++++++++------- src/yuzu_cmd/emu_window/emu_window_sdl2_vk.h | 4 ++-- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp b/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp index 89e736ef6..a203f0da9 100644 --- a/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp +++ b/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp @@ -82,19 +82,19 @@ EmuWindow_SDL2_VK::EmuWindow_SDL2_VK(bool fullscreen) : EmuWindow_SDL2(fullscree const auto vkCreateInstance = reinterpret_cast(vkGetInstanceProcAddr(nullptr, "vkCreateInstance")); if (vkCreateInstance == nullptr || - vkCreateInstance(&instance_ci, nullptr, &instance) != VK_SUCCESS) { + vkCreateInstance(&instance_ci, nullptr, &vk_instance) != VK_SUCCESS) { LOG_CRITICAL(Frontend, "Failed to create Vulkan instance!"); exit(EXIT_FAILURE); } vkDestroyInstance = reinterpret_cast( - vkGetInstanceProcAddr(instance, "vkDestroyInstance")); + vkGetInstanceProcAddr(vk_instance, "vkDestroyInstance")); if (vkDestroyInstance == nullptr) { LOG_CRITICAL(Frontend, "Failed to retrieve Vulkan function pointer!"); exit(EXIT_FAILURE); } - if (!SDL_Vulkan_CreateSurface(render_window, instance, &surface)) { + if (!SDL_Vulkan_CreateSurface(render_window, vk_instance, &vk_surface)) { LOG_CRITICAL(Frontend, "Failed to create Vulkan surface! {}", SDL_GetError()); exit(EXIT_FAILURE); } @@ -107,7 +107,7 @@ EmuWindow_SDL2_VK::EmuWindow_SDL2_VK(bool fullscreen) : EmuWindow_SDL2(fullscree } EmuWindow_SDL2_VK::~EmuWindow_SDL2_VK() { - vkDestroyInstance(instance, nullptr); + vkDestroyInstance(vk_instance, nullptr); } void EmuWindow_SDL2_VK::SwapBuffers() {} @@ -122,9 +122,10 @@ void EmuWindow_SDL2_VK::DoneCurrent() { void EmuWindow_SDL2_VK::RetrieveVulkanHandlers(void* get_instance_proc_addr, void* instance, void* surface) const { - std::memcpy(get_instance_proc_addr, vkGetInstanceProcAddr, sizeof(vkGetInstanceProcAddr)); - std::memcpy(instance, &this->instance, sizeof(this->instance)); - std::memcpy(surface, &this->surface, sizeof(this->surface)); + const auto instance_proc_addr = vkGetInstanceProcAddr; + std::memcpy(get_instance_proc_addr, &instance_proc_addr, sizeof(instance_proc_addr)); + std::memcpy(instance, &vk_instance, sizeof(vk_instance)); + std::memcpy(surface, &vk_surface, sizeof(vk_surface)); } std::unique_ptr EmuWindow_SDL2_VK::CreateSharedContext() const { diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.h b/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.h index f7234841b..2a7c06a24 100644 --- a/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.h +++ b/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.h @@ -31,8 +31,8 @@ public: private: bool UseStandardLayers(PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr) const; - VkInstance instance{}; - VkSurfaceKHR surface{}; + VkInstance vk_instance{}; + VkSurfaceKHR vk_surface{}; PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr{}; PFN_vkDestroyInstance vkDestroyInstance{}; -- cgit v1.2.3