Skip to content

Commit

Permalink
3rdParty: misc changes to rt64
Browse files Browse the repository at this point in the history
  • Loading branch information
Rosalie241 committed May 27, 2024
1 parent e8af9fe commit 33d93e2
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 25 deletions.
18 changes: 7 additions & 11 deletions Source/3rdParty/rt64/src/api/rt64_api_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,11 @@ DLLEXPORT void CALL UpdateScreen(void) {
}

DLLEXPORT void CALL ChangeWindow(void) {
CoreVideo_ToggleFullScreen();
#if 0 // TODO...
RT64::ApplicationWindow *appWindow = RT64::API.app->appWindow.get();
appWindow->setFullScreen(!appWindow->fullScreen);
#endif
const bool isPJ64 = (RT64::API.apiType == RT64::APIType::Project64);
if (isPJ64) {
CoreVideo_ToggleFullScreen();
} else {
RT64::ApplicationWindow *appWindow = RT64::API.app->appWindow.get();
appWindow->setFullScreen(!appWindow->fullScreen);
}
}

DLLEXPORT m64p_error CALL PluginShutdown(void) {


return M64ERR_SUCCESS;
}
4 changes: 2 additions & 2 deletions Source/3rdParty/rt64/src/api/rt64_api_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "m64p_types.h"
#include "m64p_vidext.h"

// uglyyyyy
// mupen64plus function pointers for the video extension functions
extern ptr_VidExt_InitWithRenderMode CoreVideo_InitWithRenderMode;
extern ptr_VidExt_Quit CoreVideo_Quit;
extern ptr_VidExt_SetCaption CoreVideo_SetCaption;
Expand All @@ -17,8 +17,8 @@ extern ptr_VidExt_ResizeWindow CoreVideo_ResizeWindow;
extern ptr_VidExt_VK_GetSurface CoreVideo_VK_GetSurface;
extern ptr_VidExt_VK_GetInstanceExtensions CoreVideo_VK_GetInstanceExtensions;
extern ptr_VidExt_SetVideoMode CoreVideo_SetVideoMode;
extern ptr_VidExt_GL_SwapBuffers CoreVideo_SwapCounter;

// TODO: move this to applicationwindow?
extern int window_width;
extern int window_height;

Expand Down
20 changes: 14 additions & 6 deletions Source/3rdParty/rt64/src/api/rt64_api_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ ptr_VidExt_ResizeWindow CoreVideo_ResizeWindow = NULL;
ptr_VidExt_VK_GetSurface CoreVideo_VK_GetSurface = NULL;
ptr_VidExt_VK_GetInstanceExtensions CoreVideo_VK_GetInstanceExtensions = NULL;
ptr_VidExt_SetVideoMode CoreVideo_SetVideoMode = NULL;
ptr_VidExt_GL_SwapBuffers CoreVideo_SwapCounter = NULL;

#ifdef _WIN32
#define DLSYM(a, b) GetProcAddress(a, b)
Expand All @@ -40,7 +39,20 @@ DLLEXPORT m64p_error CALL PluginStartup(m64p_dynlib_handle CoreLibHandle, void *
CoreVideo_VK_GetSurface = (ptr_VidExt_VK_GetSurface)DLSYM(CoreLibHandle, "VidExt_VK_GetSurface");
CoreVideo_VK_GetInstanceExtensions = (ptr_VidExt_VK_GetInstanceExtensions)DLSYM(CoreLibHandle, "VidExt_VK_GetInstanceExtensions");
CoreVideo_SetVideoMode = (ptr_VidExt_SetVideoMode)DLSYM(CoreLibHandle, "VidExt_SetVideoMode");
CoreVideo_SwapCounter = (ptr_VidExt_GL_SwapBuffers)DLSYM(CoreLibHandle, "VidExt_GL_SwapBuffers");
if (CoreVideo_InitWithRenderMode == NULL ||
CoreVideo_Quit == NULL ||
CoreVideo_SetCaption == NULL ||
CoreVideo_ToggleFullScreen == NULL ||
CoreVideo_ResizeWindow == NULL ||
CoreVideo_VK_GetSurface == NULL ||
CoreVideo_VK_GetInstanceExtensions == NULL ||
CoreVideo_SetVideoMode == NULL) {
return M64ERR_SYSTEM_FAIL;
}
return M64ERR_SUCCESS;
}

DLLEXPORT m64p_error CALL PluginShutdown(void) {
return M64ERR_SUCCESS;
}

Expand Down Expand Up @@ -83,18 +95,14 @@ DLLEXPORT void CALL RomClosed(void) {
RT64::API.app->end();
RT64::API.app.reset();
}
// Do nothing.
}

DLLEXPORT int CALL RomOpen(void) {
#if 0
const bool isPJ64 = (RT64::API.apiType == RT64::APIType::Project64);
if (isPJ64) {
RT64::ApplicationWindow *appWindow = RT64::API.app->appWindow.get();
appWindow->makeResizable();
}
#endif

return 1;
}

Expand Down
2 changes: 1 addition & 1 deletion Source/3rdParty/rt64/src/hle/rt64_present_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ namespace RT64 {

if (needsResize || ext.appWindow->detectWindowMoved()) {
ext.appWindow->detectRefreshRate();
ext.sharedResources->setSwapChainRate(std::min(60u, displayTimingRate));
ext.sharedResources->setSwapChainRate(std::min(ext.appWindow->getRefreshRate(), displayTimingRate));
}

if (displayTiming) {
Expand Down
2 changes: 1 addition & 1 deletion Source/3rdParty/rt64/src/render/rt64_optimus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

extern "C" {
// Exporting this flag indicates to the NVIDIA driver that it should prefer using the high performance device.
_declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
__declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
}

#endif
13 changes: 9 additions & 4 deletions Source/3rdParty/rt64/src/vulkan/rt64_vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2216,9 +2216,14 @@ namespace RT64 {
}

void VulkanSwapChain::getWindowSize(uint32_t &dstWidth, uint32_t &dstHeight) const {
dstWidth = window_width;
dstHeight = window_height;
return;
# if defined(RT64_BUILD_PLUGIN)
const bool isPJ64 = (RT64::API.apiType == RT64::APIType::Project64);
if (!isPJ64) {
dstWidth = window_width;
dstHeight = window_height;
return;
}
# endif

# if defined(_WIN64)
RECT rect;
Expand All @@ -2228,7 +2233,7 @@ namespace RT64 {
# elif defined(__ANDROID__)
dstWidth = ANativeWindow_getWidth(renderWindow);
dstHeight = ANativeWindow_getHeight(renderWindow);
# elif defined(__linux__)
# elif defined(__linux__) && !defined(RT64_BUILD_PLUGIN)
XWindowAttributes attributes;
XGetWindowAttributes(renderWindow.display, renderWindow.window, &attributes);
// The attributes width and height members do not include the border.
Expand Down

0 comments on commit 33d93e2

Please sign in to comment.