From 333a10a655c4f9d83a34b25848501bedb1f34b3b Mon Sep 17 00:00:00 2001 From: zeromus Date: Tue, 9 Jun 2009 03:35:37 +0000 Subject: [PATCH] win32: add ability to disable each gpu, for speedup by halting render of useless screens --- desmume/src/GPU.cpp | 8 ++++++++ desmume/src/NDSSystem.h | 8 ++++++++ desmume/src/gfx3d.cpp | 6 ++++-- desmume/src/windows/main.cpp | 16 ++++++++++++++++ desmume/src/windows/resource.h | 2 ++ desmume/src/windows/resources.rc | 2 ++ 6 files changed, 40 insertions(+), 2 deletions(-) diff --git a/desmume/src/GPU.cpp b/desmume/src/GPU.cpp index e2261b2a5..42a0bcce8 100644 --- a/desmume/src/GPU.cpp +++ b/desmume/src/GPU.cpp @@ -3062,6 +3062,14 @@ void GPU_ligne(NDS_Screen * screen, u16 l) gpu->refreshAffineStartRegs(-1,-1); } + //blacken the screen if it is turned off by the user + if(!CommonSettings.showGpu.screens[gpu->core]) + { + u8 * dst = GPU_tempScreen + (screen->offset + l) * 512; + memset(dst,0,512); + return; + } + //cache some parameters which are assumed to be stable throughout the rendering of the entire line gpu->currLine = (u8)l; u16 mosaic_control = T1ReadWord((u8 *)&gpu->dispx_st->dispx_MISC.MOSAIC, 0); diff --git a/desmume/src/NDSSystem.h b/desmume/src/NDSSystem.h index a3650ed1e..94ddfa965 100644 --- a/desmume/src/NDSSystem.h +++ b/desmume/src/NDSSystem.h @@ -389,6 +389,14 @@ extern struct TCommonSettings { //this is the user's choice of manual backup type, for cases when the autodetection can't be trusted int manualBackupType; + struct _ShowGpu { + _ShowGpu() : main(true), sub(true) {} + union { + struct { bool main,sub; }; + bool screens[2]; + }; + } showGpu; + } CommonSettings; extern char ROMserial[20]; diff --git a/desmume/src/gfx3d.cpp b/desmume/src/gfx3d.cpp index bc81d45cc..fb76ce814 100644 --- a/desmume/src/gfx3d.cpp +++ b/desmume/src/gfx3d.cpp @@ -1510,10 +1510,12 @@ void gfx3d_VBlankEndSignal(bool skipFrame) if(!drawPending) return; drawPending = FALSE; - gpu3D->NDS_3D_Render(); + + if(CommonSettings.showGpu.main) + gpu3D->NDS_3D_Render(); //if the null 3d core is chosen, then we need to clear out the 3d buffers to keep old data from being rendered - if(gpu3D == &gpu3DNull) + if(gpu3D == &gpu3DNull || !CommonSettings.showGpu.main) { memset(gfx3d_convertedScreen,0,sizeof(gfx3d_convertedScreen)); memset(gfx3d_convertedScreen,0,sizeof(gfx3d_convertedAlpha)); diff --git a/desmume/src/windows/main.cpp b/desmume/src/windows/main.cpp index f2905b37b..e11311076 100644 --- a/desmume/src/windows/main.cpp +++ b/desmume/src/windows/main.cpp @@ -1639,6 +1639,9 @@ int _main() ShowMicrophone = GetPrivateProfileInt("Display","Display Microphone", 0, IniName); ScreenGap = GetPrivateProfileInt("Display", "ScreenGap", 0, IniName); FrameLimit = GetPrivateProfileInt("FrameLimit", "FrameLimit", 1, IniName); + CommonSettings.showGpu.main = GetPrivateProfileInt("Display", "MainGpu", 1, IniName) != 0; + CommonSettings.showGpu.sub = GetPrivateProfileInt("Display", "SubGpu", 1, IniName) != 0; + //Get Ram-Watch values RWSaveWindowPos = GetPrivateProfileInt("RamWatch", "SaveWindowPos", 0, IniName); @@ -2674,6 +2677,9 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM MainWindow->checkMenu(IDC_FRAMESKIP8, MF_BYCOMMAND | (!autoframeskipenab && frameskiprate==8) ? MF_CHECKED:MF_UNCHECKED); MainWindow->checkMenu(IDC_FRAMESKIP9, MF_BYCOMMAND | (!autoframeskipenab && frameskiprate==9) ? MF_CHECKED:MF_UNCHECKED); + MainWindow->checkMenu(IDM_MGPU, MF_BYCOMMAND | CommonSettings.showGpu.main ? MF_CHECKED:MF_UNCHECKED); + MainWindow->checkMenu(IDM_SGPU, MF_BYCOMMAND | CommonSettings.showGpu.sub ? MF_CHECKED:MF_UNCHECKED); + //Language selection //Save type @@ -3180,6 +3186,16 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM return 0; //========================================================== Tools end + case IDM_MGPU: + CommonSettings.showGpu.main = !CommonSettings.showGpu.main; + WritePrivateProfileInt("Display","MainGpu",CommonSettings.showGpu.main?1:0,IniName); + return 0; + + case IDM_SGPU: + CommonSettings.showGpu.sub = !CommonSettings.showGpu.sub; + WritePrivateProfileInt("Display","SubGpu",CommonSettings.showGpu.sub?1:0,IniName); + return 0; + case IDM_MBG0 : if(MainScreen.gpu->dispBG[0]) { diff --git a/desmume/src/windows/resource.h b/desmume/src/windows/resource.h index cc8645375..29b2f6f00 100644 --- a/desmume/src/windows/resource.h +++ b/desmume/src/windows/resource.h @@ -97,6 +97,8 @@ #define IDC_LANGENGLISH 210 #define IDC_LANGFRENCH 211 #define IDC_LANGDANISH 212 +#define IDM_MGPU 213 +#define IDM_SGPU 214 #define IDC_8_BIT 302 #define IDC_16_BIT 303 #define IDC_32_BIT 304 diff --git a/desmume/src/windows/resources.rc b/desmume/src/windows/resources.rc index 212a120e7..4e57358cd 100644 --- a/desmume/src/windows/resources.rc +++ b/desmume/src/windows/resources.rc @@ -359,11 +359,13 @@ MENU_PRINCIPAL MENU MENUITEM SEPARATOR POPUP "&View Layers" { + MENUITEM "Main GPU", IDM_MGPU, CHECKED MENUITEM "Main BG 0", IDM_MBG0, CHECKED MENUITEM "Main BG 1", IDM_MBG1, CHECKED MENUITEM "Main BG 2", IDM_MBG2, CHECKED MENUITEM "Main BG 3", IDM_MBG3, CHECKED MENUITEM SEPARATOR + MENUITEM "Sub GPU", IDM_SGPU, CHECKED MENUITEM "Sub BG 0", IDM_SBG0, CHECKED MENUITEM "Sub BG 1", IDM_SBG1, CHECKED MENUITEM "Sub BG 2", IDM_SBG2, CHECKED