diff --git a/UnleashedRecomp/cpu/code_cache.cpp b/UnleashedRecomp/cpu/code_cache.cpp index b9360656..bbbebc4a 100644 --- a/UnleashedRecomp/cpu/code_cache.cpp +++ b/UnleashedRecomp/cpu/code_cache.cpp @@ -36,12 +36,12 @@ void CodeCache::Init() } } -void CodeCache::Insert(uint32_t guest, const void* host) +void CodeCache::Insert(uint32_t guest, PPCFunc* host) { #ifdef _WIN32 VirtualAlloc(bucket + static_cast(guest) * 2, sizeof(void*), MEM_COMMIT, PAGE_READWRITE); #endif - *reinterpret_cast(bucket + static_cast(guest) * 2) = host; + *reinterpret_cast(bucket + static_cast(guest) * 2) = host; } void* CodeCache::Find(uint32_t guest) const @@ -56,5 +56,5 @@ SWA_API PPCFunc* KeFindHostFunction(uint32_t guest) SWA_API void KeInsertHostFunction(uint32_t guest, PPCFunc* function) { - g_codeCache.Insert(guest, (const void*)function); + g_codeCache.Insert(guest, function); } diff --git a/UnleashedRecomp/cpu/code_cache.h b/UnleashedRecomp/cpu/code_cache.h index 35d610bf..e2a1d5ac 100644 --- a/UnleashedRecomp/cpu/code_cache.h +++ b/UnleashedRecomp/cpu/code_cache.h @@ -8,7 +8,7 @@ struct CodeCache ~CodeCache(); void Init(); - void Insert(uint32_t guest, const void* host); + void Insert(uint32_t guest, PPCFunc* host); void* Find(uint32_t guest) const; }; diff --git a/UnleashedRecomp/gpu/rhi/plume_render_interface_types.h b/UnleashedRecomp/gpu/rhi/plume_render_interface_types.h index f90182e3..f0e94fd3 100644 --- a/UnleashedRecomp/gpu/rhi/plume_render_interface_types.h +++ b/UnleashedRecomp/gpu/rhi/plume_render_interface_types.h @@ -38,7 +38,7 @@ namespace plume { #elif defined(__linux__) struct RenderWindow { Display* display; - Window* window; + Window window; bool operator==(const struct RenderWindow& rhs) const { return display == rhs.display && window == rhs.window; } diff --git a/UnleashedRecomp/gpu/video.cpp b/UnleashedRecomp/gpu/video.cpp index 1685ee28..4aee20cf 100644 --- a/UnleashedRecomp/gpu/video.cpp +++ b/UnleashedRecomp/gpu/video.cpp @@ -1360,7 +1360,7 @@ void Video::CreateHostDevice() break; } - g_swapChain = g_queue->createSwapChain(GameWindow::s_handle, bufferCount, BACKBUFFER_FORMAT); + g_swapChain = g_queue->createSwapChain(GameWindow::s_renderWindow, bufferCount, BACKBUFFER_FORMAT); g_swapChain->setVsyncEnabled(Config::VSync); g_swapChainValid = !g_swapChain->needsResize(); @@ -1662,9 +1662,9 @@ static uint32_t CreateDevice(uint32_t a1, uint32_t a2, uint32_t a3, uint32_t a4, memset(device, 0, sizeof(*device)); uint32_t functionOffset = 0x443344; // D3D - g_codeCache.Insert(functionOffset, reinterpret_cast(HostToGuestFunction)); + g_codeCache.Insert(functionOffset, HostToGuestFunction); - for (size_t i = 0; i < _countof(device->setRenderStateFunctions); i++) + for (size_t i = 0; i < std::size(device->setRenderStateFunctions); i++) device->setRenderStateFunctions[i] = functionOffset; for (auto& [state, function] : g_setRenderStateFunctions) @@ -1674,7 +1674,7 @@ static uint32_t CreateDevice(uint32_t a1, uint32_t a2, uint32_t a3, uint32_t a4, device->setRenderStateFunctions[state / 4] = functionOffset; } - for (size_t i = 0; i < _countof(device->setSamplerStateFunctions); i++) + for (size_t i = 0; i < std::size(device->setSamplerStateFunctions); i++) device->setSamplerStateFunctions[i] = *reinterpret_cast(g_memory.Translate(0x8330F3DC + i * 0xC)); device->viewport.width = 1280.0f; diff --git a/UnleashedRecomp/ui/game_window.cpp b/UnleashedRecomp/ui/game_window.cpp index 25ee8d14..73e5fed2 100644 --- a/UnleashedRecomp/ui/game_window.cpp +++ b/UnleashedRecomp/ui/game_window.cpp @@ -181,14 +181,17 @@ void GameWindow::Init() SetTitle(); SDL_SetWindowMinimumSize(s_pWindow, 640, 480); -#ifdef _WIN32 SDL_SysWMinfo info; SDL_VERSION(&info.version); SDL_GetWindowWMInfo(s_pWindow, &info); - s_handle = info.info.win.window; - +#if defined(_WIN32) + s_renderWindow = info.info.win.window; SetDarkTitleBar(true); +#elif defined(__linux__) + s_renderWindow = { info.info.x11.display, info.info.x11.window }; +#else + static_assert(false, "Unknown platform."); #endif SDL_ShowWindow(s_pWindow); diff --git a/UnleashedRecomp/ui/game_window.h b/UnleashedRecomp/ui/game_window.h index 5be28b01..1be8f1ec 100644 --- a/UnleashedRecomp/ui/game_window.h +++ b/UnleashedRecomp/ui/game_window.h @@ -6,6 +6,7 @@ #include #include #include +#include #if _WIN32 #include @@ -19,9 +20,7 @@ class GameWindow { public: static inline SDL_Window* s_pWindow; -#ifdef _WIN32 - static inline HWND s_handle; -#endif + static inline plume::RenderWindow s_renderWindow; static inline int s_x; static inline int s_y;