mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2026-04-28 13:21:42 +00:00
Code cache pointers, RenderWindow type.
This commit is contained in:
parent
92eb4df06d
commit
0481d3f539
6 changed files with 17 additions and 15 deletions
|
|
@ -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
|
#ifdef _WIN32
|
||||||
VirtualAlloc(bucket + static_cast<uint64_t>(guest) * 2, sizeof(void*), MEM_COMMIT, PAGE_READWRITE);
|
VirtualAlloc(bucket + static_cast<uint64_t>(guest) * 2, sizeof(void*), MEM_COMMIT, PAGE_READWRITE);
|
||||||
#endif
|
#endif
|
||||||
*reinterpret_cast<const void**>(bucket + static_cast<uint64_t>(guest) * 2) = host;
|
*reinterpret_cast<PPCFunc**>(bucket + static_cast<uint64_t>(guest) * 2) = host;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* CodeCache::Find(uint32_t guest) const
|
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)
|
SWA_API void KeInsertHostFunction(uint32_t guest, PPCFunc* function)
|
||||||
{
|
{
|
||||||
g_codeCache.Insert(guest, (const void*)function);
|
g_codeCache.Insert(guest, function);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ struct CodeCache
|
||||||
~CodeCache();
|
~CodeCache();
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
void Insert(uint32_t guest, const void* host);
|
void Insert(uint32_t guest, PPCFunc* host);
|
||||||
|
|
||||||
void* Find(uint32_t guest) const;
|
void* Find(uint32_t guest) const;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ namespace plume {
|
||||||
#elif defined(__linux__)
|
#elif defined(__linux__)
|
||||||
struct RenderWindow {
|
struct RenderWindow {
|
||||||
Display* display;
|
Display* display;
|
||||||
Window* window;
|
Window window;
|
||||||
bool operator==(const struct RenderWindow& rhs) const {
|
bool operator==(const struct RenderWindow& rhs) const {
|
||||||
return display == rhs.display && window == rhs.window;
|
return display == rhs.display && window == rhs.window;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1360,7 +1360,7 @@ void Video::CreateHostDevice()
|
||||||
break;
|
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_swapChain->setVsyncEnabled(Config::VSync);
|
||||||
g_swapChainValid = !g_swapChain->needsResize();
|
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));
|
memset(device, 0, sizeof(*device));
|
||||||
|
|
||||||
uint32_t functionOffset = 0x443344; // D3D
|
uint32_t functionOffset = 0x443344; // D3D
|
||||||
g_codeCache.Insert(functionOffset, reinterpret_cast<void*>(HostToGuestFunction<SetRenderStateUnimplemented>));
|
g_codeCache.Insert(functionOffset, HostToGuestFunction<SetRenderStateUnimplemented>);
|
||||||
|
|
||||||
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;
|
device->setRenderStateFunctions[i] = functionOffset;
|
||||||
|
|
||||||
for (auto& [state, function] : g_setRenderStateFunctions)
|
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;
|
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<uint32_t*>(g_memory.Translate(0x8330F3DC + i * 0xC));
|
device->setSamplerStateFunctions[i] = *reinterpret_cast<uint32_t*>(g_memory.Translate(0x8330F3DC + i * 0xC));
|
||||||
|
|
||||||
device->viewport.width = 1280.0f;
|
device->viewport.width = 1280.0f;
|
||||||
|
|
|
||||||
|
|
@ -181,14 +181,17 @@ void GameWindow::Init()
|
||||||
SetTitle();
|
SetTitle();
|
||||||
SDL_SetWindowMinimumSize(s_pWindow, 640, 480);
|
SDL_SetWindowMinimumSize(s_pWindow, 640, 480);
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
SDL_SysWMinfo info;
|
SDL_SysWMinfo info;
|
||||||
SDL_VERSION(&info.version);
|
SDL_VERSION(&info.version);
|
||||||
SDL_GetWindowWMInfo(s_pWindow, &info);
|
SDL_GetWindowWMInfo(s_pWindow, &info);
|
||||||
|
|
||||||
s_handle = info.info.win.window;
|
#if defined(_WIN32)
|
||||||
|
s_renderWindow = info.info.win.window;
|
||||||
SetDarkTitleBar(true);
|
SetDarkTitleBar(true);
|
||||||
|
#elif defined(__linux__)
|
||||||
|
s_renderWindow = { info.info.x11.display, info.info.x11.window };
|
||||||
|
#else
|
||||||
|
static_assert(false, "Unknown platform.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SDL_ShowWindow(s_pWindow);
|
SDL_ShowWindow(s_pWindow);
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
#include <os/version.h>
|
#include <os/version.h>
|
||||||
#include <ui/window_events.h>
|
#include <ui/window_events.h>
|
||||||
#include <user/config.h>
|
#include <user/config.h>
|
||||||
|
#include <gpu/rhi/plume_render_interface_types.h>
|
||||||
|
|
||||||
#if _WIN32
|
#if _WIN32
|
||||||
#include <dwmapi.h>
|
#include <dwmapi.h>
|
||||||
|
|
@ -19,9 +20,7 @@ class GameWindow
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static inline SDL_Window* s_pWindow;
|
static inline SDL_Window* s_pWindow;
|
||||||
#ifdef _WIN32
|
static inline plume::RenderWindow s_renderWindow;
|
||||||
static inline HWND s_handle;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static inline int s_x;
|
static inline int s_x;
|
||||||
static inline int s_y;
|
static inline int s_y;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue