win32: Add a reduce input lag option for OpenGL and Direct3D.

This commit is contained in:
Brandon Wright 2018-05-05 16:31:54 -05:00
parent 7566704e65
commit 113a43c4cd
7 changed files with 26 additions and 2 deletions

View File

@ -731,6 +731,20 @@ void CDirect3D::Render(SSurface Src)
pDevice->Present(NULL, NULL, NULL, NULL);
if (GUI.ReduceInputLag)
{
IDirect3DSurface9 *surface;
if (pDevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &surface) == D3D_OK)
{
if (surface->LockRect(&lr, NULL, D3DLOCK_READONLY) == D3D_OK)
{
surface->UnlockRect();
}
surface->Release();
}
}
return;
}
@ -927,6 +941,7 @@ bool CDirect3D::ResetDevice()
dPresentParams.FullScreen_RefreshRateInHz = 0;
dPresentParams.Windowed = true;
dPresentParams.PresentationInterval = GUI.Vsync?D3DPRESENT_INTERVAL_ONE:D3DPRESENT_INTERVAL_IMMEDIATE;
dPresentParams.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;
if(fullscreen) {
dPresentParams.BackBufferWidth = GUI.FullscreenMode.width;

View File

@ -521,6 +521,8 @@ void COpenGL::Render(SSurface Src)
glFlush();
SwapBuffers(hDC);
if (GUI.ReduceInputLag)
glFinish();
}
bool COpenGL::ChangeRenderSize(unsigned int newWidth, unsigned int newHeight)

View File

@ -329,6 +329,7 @@
#define IDC_LABEL_HK12 1255
#define IDC_LABEL_HK13 1256
#define IDC_PLAYWARN 1257
#define IDC_REDUCEINPUTLAG 1258
#define IDC_HOTKEY1 2000
#define IDC_HOTKEY2 2001
#define IDC_HOTKEY3 2002

View File

@ -231,7 +231,7 @@ BEGIN
GROUPBOX "Output Image Processing",IDC_STATIC,179,7,166,46,0,WS_EX_TRANSPARENT
GROUPBOX "Fullscreen Display Settings",IDC_STATIC,179,56,166,44,0,WS_EX_TRANSPARENT
LTEXT "Hi Res:",IDC_HIRESLABEL,186,36,31,8
GROUPBOX "General",IDC_STATIC,7,7,167,113,0,WS_EX_TRANSPARENT
GROUPBOX "General",IDC_STATIC,7,7,167,118,0,WS_EX_TRANSPARENT
LTEXT "Max skipped frames:",IDC_STATIC,62,140,67,8
LTEXT "Amount skipped:",IDC_STATIC,62,158,67,8
LTEXT "Output Method",IDC_STATIC,10,19,51,11
@ -242,6 +242,7 @@ BEGIN
LTEXT "OpenGL Shader File",IDC_STATIC,13,224,104,8
CONTROL "Blend Hi-Res Images",IDC_HIRESBLEND,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,187,135,82,10
CONTROL "VSync",IDC_VSYNC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,102,37,10
CONTROL "Reduce Input Lag", IDC_REDUCEINPUTLAG, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 11, 113, 76, 10
CONTROL "Scale messages with EPX if possible",IDC_MESSAGES_SCALE,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,187,168,131,10
END

View File

@ -926,6 +926,7 @@ void WinRegisterConfigItems()
AddBoolC("Fullscreen:EmulateFullscreen", GUI.EmulateFullscreen, true,"true makes snes9x create a window that spans the entire screen when going fullscreen");
AddBoolC("HideMenu", GUI.HideMenu, false, "true to auto-hide the menu bar on startup.");
AddBoolC("Vsync", GUI.Vsync, false, "true to enable Vsync");
AddBoolC("ReduceInputLag", GUI.ReduceInputLag, false, "true to reduce input lag by hard synchronization");
AddBoolC("FilterMessageFont", GUI.filterMessagFont, true, "true to filter message font with EPX on 2x/3x scales if MessagesInImage is false)");
#undef CATEGORY
#define CATEGORY "Settings"

View File

@ -7375,6 +7375,8 @@ INT_PTR CALLBACK DlgFunky(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
SendDlgItemMessage(hDlg, IDC_DBLBUFFER, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
if (GUI.Vsync)
SendDlgItemMessage(hDlg, IDC_VSYNC, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
if (GUI.ReduceInputLag)
SendDlgItemMessage(hDlg, IDC_REDUCEINPUTLAG, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
SendDlgItemMessage(hDlg, IDC_FRAMERATESKIPSLIDER, TBM_SETRANGE, (WPARAM)true, (LPARAM)MAKELONG(0, 9));
if (Settings.SkipFrames != AUTO_FRAMERATE)
SendDlgItemMessage(hDlg, IDC_FRAMERATESKIPSLIDER, TBM_SETPOS, (WPARAM)true, (LPARAM)Settings.SkipFrames);
@ -7773,6 +7775,7 @@ updateFilterBox2:
Settings.AutoDisplayMessages = IsDlgButtonChecked(hDlg, IDC_MESSAGES_IN_IMAGE);
GUI.filterMessagFont = IsDlgButtonChecked(hDlg, IDC_MESSAGES_SCALE);
GUI.DoubleBuffered = (bool)(IsDlgButtonChecked(hDlg, IDC_DBLBUFFER)==BST_CHECKED);
GUI.ReduceInputLag = (bool)(IsDlgButtonChecked(hDlg, IDC_REDUCEINPUTLAG) == BST_CHECKED);
GUI.Vsync = (bool)(IsDlgButtonChecked(hDlg, IDC_VSYNC
)==BST_CHECKED);

View File

@ -333,7 +333,8 @@ struct sGUI {
bool EmulatedFullscreen;
bool BilinearFilter;
bool LocalVidMem;
bool Vsync;
bool Vsync;
bool ReduceInputLag;
bool shaderEnabled;
TCHAR D3DshaderFileName[MAX_PATH];
TCHAR OGLshaderFileName[MAX_PATH];