diff --git a/external/parallel-rdp/ParallelRDPWrapper.cpp b/external/parallel-rdp/ParallelRDPWrapper.cpp index 405ec523..3cede6d7 100644 --- a/external/parallel-rdp/ParallelRDPWrapper.cpp +++ b/external/parallel-rdp/ParallelRDPWrapper.cpp @@ -71,7 +71,7 @@ public: const char* extensions[64]; unsigned int num_extensions = 64; - if (!SDL_Vulkan_GetInstanceExtensions(window, &num_extensions, extensions)) { + if (!SDL_Vulkan_GetInstanceExtensions(g_Window, &num_extensions, extensions)) { util::panic("SDL_Vulkan_GetInstanceExtensions failed: %s", SDL_GetError()); } auto vec = std::vector(); @@ -85,8 +85,8 @@ public: VkSurfaceKHR create_surface(VkInstance instance, VkPhysicalDevice gpu) override { VkSurfaceKHR vk_surface; - if (!SDL_Vulkan_CreateSurface(window, instance, &vk_surface)) { - util::panic("Failed to create Vulkan window surface: %s", SDL_GetError()); + if (!SDL_Vulkan_CreateSurface(g_Window, instance, &vk_surface)) { + util::panic("Failed to create Vulkan window surface: {}", SDL_GetError()); } return vk_surface; } @@ -165,7 +165,8 @@ void LoadParallelRDP(const u8* rdram) { } } -void InitParallelRDP(const u8* rdram) { +void InitParallelRDP(const u8* rdram, SDL_Window* window) { + g_Window = window; LoadWSIPlatform(new SDLWSIPlatform(), std::make_unique()); LoadParallelRDP(rdram); } @@ -183,7 +184,7 @@ void DrawFullscreenTexturedQuad(Util::IntrusivePtr image, Util::Intrusive *data++ = +1.0f; int sdlWinWidth, sdlWinHeight; - SDL_GetWindowSize(window, &sdlWinWidth, &sdlWinHeight); + SDL_GetWindowSize(g_Window, &sdlWinWidth, &sdlWinHeight); float zoom = std::min( (float)sdlWinWidth / wsi->get_platform().get_surface_width(), diff --git a/external/parallel-rdp/ParallelRDPWrapper.hpp b/external/parallel-rdp/ParallelRDPWrapper.hpp index 2422ad92..a8eab8bb 100644 --- a/external/parallel-rdp/ParallelRDPWrapper.hpp +++ b/external/parallel-rdp/ParallelRDPWrapper.hpp @@ -5,7 +5,7 @@ #include struct Window; -static SDL_Window* window; +static SDL_Window* g_Window; class ParallelRdpWindowInfo { public: @@ -20,7 +20,7 @@ public: class SDLParallelRdpWindowInfo : public ParallelRdpWindowInfo { CoordinatePair get_window_size() { int width, height; - SDL_GetWindowSize(window, &width, &height); + SDL_GetWindowSize(g_Window, &width, &height); return CoordinatePair{ width, height }; } }; @@ -34,7 +34,7 @@ uint32_t GetVkGraphicsQueueFamily(); VkFormat GetVkFormat(); VkCommandBuffer GetVkCommandBuffer(); void SubmitRequestedVkCommandBuffer(); -void InitParallelRDP(const u8* rdram); +void InitParallelRDP(const u8* rdram, SDL_Window*); void UpdateScreenParallelRdp(Window& imguiWindow, const n64::VI& vi); void ParallelRdpEnqueueCommand(int command_length, u32* buffer); void ParallelRdpOnFullSync(); diff --git a/src/frontend/imgui/CMakeLists.txt b/src/frontend/imgui/CMakeLists.txt index 5f106ad8..94a6cc8a 100644 --- a/src/frontend/imgui/CMakeLists.txt +++ b/src/frontend/imgui/CMakeLists.txt @@ -16,6 +16,7 @@ target_include_directories(frontend-imgui PUBLIC ../../n64/core/cpu ../../n64/core/cpu/registers ../../../external + ../../../external/parallel-rdp/parallel-rdp-standalone ../../../external/parallel-rdp/parallel-rdp-standalone/vulkan ../../../external/parallel-rdp/parallel-rdp-standalone/util ../../../external/parallel-rdp/parallel-rdp-standalone/volk) diff --git a/src/frontend/imgui/Window.cpp b/src/frontend/imgui/Window.cpp index c92850e4..a220b4d0 100644 --- a/src/frontend/imgui/Window.cpp +++ b/src/frontend/imgui/Window.cpp @@ -2,16 +2,20 @@ #include #include #include -#include -#include #include Window::Window(const n64::Core& core) { InitSDL(); - InitParallelRDP(core.GetRDRAM()); + InitParallelRDP(core.GetRDRAM(), window); InitImgui(); } +[[nodiscard]] bool Window::gotClosed(SDL_Event event) { + return event.type == SDL_WINDOWEVENT + && event.window.event == SDL_WINDOWEVENT_CLOSE + && event.window.windowID == SDL_GetWindowID(window); +} + void Window::InitSDL() { SDL_Init(SDL_INIT_EVERYTHING); window = SDL_CreateWindow( diff --git a/src/frontend/imgui/Window.hpp b/src/frontend/imgui/Window.hpp index 9e928358..8930b32e 100644 --- a/src/frontend/imgui/Window.hpp +++ b/src/frontend/imgui/Window.hpp @@ -1,11 +1,11 @@ #pragma once +#include +#include #include #include -#define VK_NO_PROTOTYPES +#define VULKAN_DEBUG #include -#include -#include -#include +#include #include #include @@ -14,19 +14,14 @@ struct Window { ~Window(); ImDrawData* Present(); - [[nodiscard]] bool gotClosed(SDL_Event event) { - return event.type == SDL_WINDOWEVENT - && event.window.event == SDL_WINDOWEVENT_CLOSE - && event.window.windowID == SDL_GetWindowID(window); - } + [[nodiscard]] bool gotClosed(SDL_Event event); private: + SDL_Window* window; n64::Core core; void InitSDL(); void InitImgui(); void Render(); - SDL_Window* window{}; - VkInstance instance{}; VkPhysicalDevice physicalDevice{}; VkDevice device{};