diff --git a/src/BizHawk.Bizware.Graphics/Interfaces/I2DRenderer.cs b/src/BizHawk.Bizware.Graphics/Interfaces/I2DRenderer.cs index bf80dd8cd0..6946de88e7 100644 --- a/src/BizHawk.Bizware.Graphics/Interfaces/I2DRenderer.cs +++ b/src/BizHawk.Bizware.Graphics/Interfaces/I2DRenderer.cs @@ -29,6 +29,12 @@ namespace BizHawk.Bizware.Graphics /// void Clear(); + /// + /// Discards any pending draw calls. + /// Similar to Clear(), except this won't insert a command to clear the target texture + /// + void Discard(); + CompositingMode CompositingMode { set; } void DrawBezier(Color color, Point pt1, Point pt2, Point pt3, Point pt4); diff --git a/src/BizHawk.Bizware.Graphics/Renderers/ImGui2DRenderer.cs b/src/BizHawk.Bizware.Graphics/Renderers/ImGui2DRenderer.cs index afe48c4c14..394d293d4c 100644 --- a/src/BizHawk.Bizware.Graphics/Renderers/ImGui2DRenderer.cs +++ b/src/BizHawk.Bizware.Graphics/Renderers/ImGui2DRenderer.cs @@ -302,6 +302,9 @@ namespace BizHawk.Bizware.Graphics _hasClearPending = true; } + public void Discard() + => ResetDrawList(); + protected bool EnableBlending { get; private set; } private bool _pendingBlendEnable; diff --git a/src/BizHawk.Client.Common/Api/Classes/EmuClientApi.cs b/src/BizHawk.Client.Common/Api/Classes/EmuClientApi.cs index a1c4aa63c2..113cfcce53 100644 --- a/src/BizHawk.Client.Common/Api/Classes/EmuClientApi.cs +++ b/src/BizHawk.Client.Common/Api/Classes/EmuClientApi.cs @@ -90,7 +90,7 @@ namespace BizHawk.Client.Common public void DoFrameAdvance() { - _mainForm.FrameAdvance(); + _mainForm.FrameAdvance(discardApiHawkSurfaces: false); // we're rendering, so we don't want to discard _mainForm.StepRunLoop_Throttle(); _mainForm.Render(); } diff --git a/src/BizHawk.Client.Common/DisplayManager/DisplayManagerBase.cs b/src/BizHawk.Client.Common/DisplayManager/DisplayManagerBase.cs index caa38a4ba4..566a6fdd93 100644 --- a/src/BizHawk.Client.Common/DisplayManager/DisplayManagerBase.cs +++ b/src/BizHawk.Client.Common/DisplayManager/DisplayManagerBase.cs @@ -933,5 +933,13 @@ namespace BizHawk.Client.Common renderer.Clear(); } } + + public void DiscardApiHawkSurfaces() + { + foreach (var renderer in _apiHawkIDTo2DRenderer.Values) + { + renderer.Discard(); + } + } } } diff --git a/src/BizHawk.Client.Common/IMainFormForApi.cs b/src/BizHawk.Client.Common/IMainFormForApi.cs index 343aeff4ce..b835fa02ed 100644 --- a/src/BizHawk.Client.Common/IMainFormForApi.cs +++ b/src/BizHawk.Client.Common/IMainFormForApi.cs @@ -52,7 +52,7 @@ namespace BizHawk.Client.Common bool FlushSaveRAM(bool autosave = false); /// only referenced from EmuClientApi - void FrameAdvance(); + void FrameAdvance(bool discardApiHawkSurfaces = true); void FrameBufferResized(); diff --git a/src/BizHawk.Client.EmuHawk/IMainFormForTools.cs b/src/BizHawk.Client.EmuHawk/IMainFormForTools.cs index dcc52ea5f1..db3b8031ff 100644 --- a/src/BizHawk.Client.EmuHawk/IMainFormForTools.cs +++ b/src/BizHawk.Client.EmuHawk/IMainFormForTools.cs @@ -56,7 +56,7 @@ namespace BizHawk.Client.EmuHawk bool EnsureCoreIsAccurate(); /// only referenced from - void FrameAdvance(); + void FrameAdvance(bool discardApiHawkSurfaces = true); /// only referenced from void FrameBufferResized(); diff --git a/src/BizHawk.Client.EmuHawk/MainForm.cs b/src/BizHawk.Client.EmuHawk/MainForm.cs index cb3d706d3d..34e200ccbe 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.cs @@ -2477,6 +2477,7 @@ namespace BizHawk.Client.EmuHawk { if (Config.DispSpeedupFeatures == 0) { + DisplayManager.DiscardApiHawkSurfaces(); return; } @@ -3069,16 +3070,21 @@ namespace BizHawk.Client.EmuHawk _throttle.Step(Config, Sound, allowSleep: true, forceFrameSkip: -1); } - public void FrameAdvance() + public void FrameAdvance(bool discardApiHawkSurfaces) { PressFrameAdvance = true; StepRunLoop_Core(true); + if (discardApiHawkSurfaces) + { + DisplayManager.DiscardApiHawkSurfaces(); + } } public void SeekFrameAdvance() { PressFrameAdvance = true; StepRunLoop_Core(true); + DisplayManager.DiscardApiHawkSurfaces(); PressFrameAdvance = false; }