Change approach (call from NativeFrame instead). Add Mac support

This commit is contained in:
Henrik Rydgård 2024-01-18 17:57:14 +01:00
parent d45f95e304
commit b899a178bf
6 changed files with 23 additions and 18 deletions

View file

@ -246,6 +246,7 @@ enum class UIMessage {
SAVESTATE_DISPLAY_SLOT,
GAMESETTINGS_SEARCH,
SAVEDATA_SEARCH,
RESTART_GRAPHICS,
};
std::string System_GetProperty(SystemProperty prop);

View file

@ -61,7 +61,6 @@ static std::set<CoreLifecycleFunc> lifecycleFuncs;
static std::set<CoreStopRequestFunc> stopFuncs;
static bool windowHidden = false;
static bool powerSaving = false;
static bool g_restartGraphics = false;
static MIPSExceptionInfo g_exceptionInfo;
@ -212,10 +211,6 @@ void UpdateRunLoop(GraphicsContext *ctx) {
}
}
void Core_DebugRestartGraphics() {
g_restartGraphics = true;
}
// Note: not used on Android.
void Core_RunLoop(GraphicsContext *ctx) {
if (windowHidden && g_Config.bPauseWhenMinimized) {
@ -223,16 +218,6 @@ void Core_RunLoop(GraphicsContext *ctx) {
return;
}
#if PPSSPP_PLATFORM(WINDOWS)
// This can only be accessed from Windows currently, and causes linking errors with headless etc.
if (g_restartGraphics) {
// Used for debugging only.
NativeShutdownGraphics();
NativeInitGraphics(ctx);
g_restartGraphics = false;
}
#endif
NativeFrame(ctx);
}

View file

@ -44,7 +44,6 @@ bool Core_NextFrame();
void Core_DoSingleStep();
void Core_UpdateSingleStep();
void Core_ProcessStepping();
void Core_DebugRestartGraphics();
// Changes every time we enter stepping.
int Core_GetSteppingCounter();

View file

@ -405,6 +405,10 @@ void OSXOpenURL(const char *url) {
copyBaseAddr.target = self;
copyBaseAddr.tag = 11;
NSMenuItem *restartGraphicsAction = [[NSMenuItem alloc] initWithTitle:DESKTOPUI_LOCALIZED("Restart Graphics") action:@selector(restartGraphics) keyEquivalent:@""];
restartGraphicsAction.target = self;
restartGraphicsAction.tag = 12;
MENU_ITEM(showDebugStatsAction, DESKTOPUI_LOCALIZED("Show Debug Statistics"), @selector(toggleShowDebugStats:), ((DebugOverlay)g_Config.iDebugOverlay == DebugOverlay::DEBUG_STATS), 12)
[parent addItem:loadSymbolMapAction];
@ -421,6 +425,7 @@ void OSXOpenURL(const char *url) {
[parent addItem:takeScreenshotAction];
[parent addItem:dumpNextFrameToLogAction];
[parent addItem:showDebugStatsAction];
[parent addItem:restartGraphicsAction];
[parent addItem:[NSMenuItem separatorItem]];
[parent addItem:copyBaseAddr];
@ -462,6 +467,10 @@ void OSXOpenURL(const char *url) {
[NSPasteboard.generalPasteboard setString:stringToCopy forType:NSPasteboardTypeString];
}
-(void)restartGraphics {
System_PostUIMessage(UIMessage::RESTART_GRAPHICS);
}
-(NSURL *)presentOpenPanelWithAllowedFileTypes: (NSArray<NSString *> *)allowedFileTypes {
NSOpenPanel *openPanel = [[NSOpenPanel alloc] init];
openPanel.allowedFileTypes = allowedFileTypes;

View file

@ -183,6 +183,7 @@ static Draw::DrawContext *g_draw;
static Draw::Pipeline *colorPipeline;
static Draw::Pipeline *texColorPipeline;
static UIContext *uiContext;
static bool g_restartGraphics;
#ifdef _WIN32
WindowsAudioBackend *winAudioBackend;
@ -1035,6 +1036,14 @@ static void SendMouseDeltaAxis();
void NativeFrame(GraphicsContext *graphicsContext) {
PROFILE_END_FRAME();
// This can only be accessed from Windows currently, and causes linking errors with headless etc.
if (g_restartGraphics) {
// Used for debugging only.
NativeShutdownGraphics();
NativeInitGraphics(graphicsContext);
g_restartGraphics = false;
}
double startTime = time_now_d();
ProcessWheelRelease(NKCODE_EXT_MOUSEWHEEL_UP, startTime, false);
@ -1173,7 +1182,9 @@ void NativeFrame(GraphicsContext *graphicsContext) {
}
bool HandleGlobalMessage(UIMessage message, const std::string &value) {
if (message == UIMessage::SAVESTATE_DISPLAY_SLOT) {
if (message == UIMessage::RESTART_GRAPHICS) {
g_restartGraphics = true;
} else if (message == UIMessage::SAVESTATE_DISPLAY_SLOT) {
auto sy = GetI18NCategory(I18NCat::SYSTEM);
std::string msg = StringFromFormat("%s: %d", sy->T("Savestate Slot"), SaveState::GetCurrentSlot() + 1);
// Show for the same duration as the preview.

View file

@ -926,7 +926,7 @@ namespace MainWindow {
break;
case ID_DEBUG_RESTARTGRAPHICS:
Core_DebugRestartGraphics();
System_PostUIMessage(UIMessage::RESTART_GRAPHICS);
break;
case ID_FILE_DUMPFRAMES: