Use dynamic type for D3D VSync in `UpdateSourceDrawingWork`

This commit is contained in:
YoshiRulz 2022-04-23 14:18:26 +10:00
parent 6ea714ac31
commit 2fde1ce9e9
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
1 changed files with 6 additions and 14 deletions

View File

@ -3,7 +3,6 @@ using System.Diagnostics;
using System.Drawing; using System.Drawing;
using BizHawk.Bizware.BizwareGL; using BizHawk.Bizware.BizwareGL;
using BizHawk.Bizware.DirectX;
using BizHawk.Client.Common; using BizHawk.Client.Common;
using BizHawk.Emulation.Common; using BizHawk.Emulation.Common;
@ -58,9 +57,6 @@ namespace BizHawk.Client.EmuHawk
{ {
bool alternateVsync = false; bool alternateVsync = false;
// only used by alternate vsync
IGL_SlimDX9 dx9 = null;
if (!job.Offscreen) if (!job.Offscreen)
{ {
//apply the vsync setting (should probably try to avoid repeating this) //apply the vsync setting (should probably try to avoid repeating this)
@ -75,16 +71,12 @@ namespace BizHawk.Client.EmuHawk
vsync = false; vsync = false;
//for now, it's assumed that the presentation panel is the main window, but that may not always be true //for now, it's assumed that the presentation panel is the main window, but that may not always be true
if (vsync && GlobalConfig.DispAlternateVsync && GlobalConfig.VSyncThrottle) if (vsync && GlobalConfig.DispAlternateVsync && GlobalConfig.VSyncThrottle && _gl.DispMethodEnum is EDispMethod.SlimDX9)
{
dx9 = _gl as IGL_SlimDX9;
if (dx9 != null)
{ {
alternateVsync = true; alternateVsync = true;
//unset normal vsync if we've chosen the alternate vsync //unset normal vsync if we've chosen the alternate vsync
vsync = false; vsync = false;
} }
}
//TODO - whats so hard about triple buffering anyway? just enable it always, and change api to SetVsync(enable,throttle) //TODO - whats so hard about triple buffering anyway? just enable it always, and change api to SetVsync(enable,throttle)
//maybe even SetVsync(enable,throttlemethod) or just SetVsync(enable,throttle,advanced) //maybe even SetVsync(enable,throttlemethod) or just SetVsync(enable,throttle,advanced)
@ -126,13 +118,13 @@ namespace BizHawk.Client.EmuHawk
Debug.Assert(inFinalTarget); Debug.Assert(inFinalTarget);
// wait for vsync to begin // wait for vsync to begin
if (alternateVsync) dx9.AlternateVsyncPass(0); if (alternateVsync) ((dynamic) _gl).AlternateVsyncPass(0);
// present and conclude drawing // present and conclude drawing
_graphicsControl.SwapBuffers(); _graphicsControl.SwapBuffers();
// wait for vsync to end // wait for vsync to end
if (alternateVsync) dx9.AlternateVsyncPass(1); if (alternateVsync) ((dynamic) _gl).AlternateVsyncPass(1);
// nope. don't do this. workaround for slow context switching on intel GPUs. just switch to another context when necessary before doing anything // nope. don't do this. workaround for slow context switching on intel GPUs. just switch to another context when necessary before doing anything
// presentationPanel.GraphicsControl.End(); // presentationPanel.GraphicsControl.End();