Skip to content
Browse files

Introduced debug / donotwaitforvsync setting for the Skin Engine

This setting has no benefit for normal use, but it is useful when debugging performance issues on Skin Engine side.
  • Loading branch information...
1 parent eb68cc5 commit 40bbf2c51f037ec25e9f361276094fd1a8935b6f @tourettes tourettes committed Nov 12, 2012
Showing with 24 additions and 16 deletions.
  1. +24 −16 mediaportal/MediaPortal.Application/d3dapp.cs
View
40 mediaportal/MediaPortal.Application/d3dapp.cs
@@ -67,8 +67,8 @@ public class D3DApp : MPForm
private MenuItem menuBreakFile;
protected MenuItem menuItemExit;
- #endregion
-
+ #endregion
+
protected bool _resizeOngoing = false; // this is true only when user is resizing the form
protected bool _ignoreNextResizeEvent = false; // True if next event should be ignored (min/max happened)
protected FormWindowState _windowState = FormWindowState.Normal;
@@ -259,7 +259,8 @@ protected virtual void Render(float timePassed)
private bool alwaysOnTopConfig = false;
protected bool useExclusiveDirectXMode;
protected bool useEnhancedVideoRenderer;
- private bool _disableMouseEvents = false;
+ private bool _disableMouseEvents = false;
+ private bool _doNotWaitForVSync = false;
[DllImport("winmm.dll")]
internal static extern uint timeBeginPeriod(uint period);
@@ -308,8 +309,8 @@ public D3DApp()
minDepthBits = 16;
minStencilBits = 0;
showCursorWhenFullscreen = false;
- bool debugChangeDeviceHack = false;
-
+ bool debugChangeDeviceHack = false;
+
using (Settings xmlreader = new MPSettings())
{
useExclusiveDirectXMode = xmlreader.GetValueAsBool("general", "exclusivemode", true);
@@ -321,7 +322,8 @@ public D3DApp()
autoHideTaskbar = xmlreader.GetValueAsBool("general", "hidetaskbar", true);
alwaysOnTopConfig = alwaysOnTop = xmlreader.GetValueAsBool("general", "alwaysontop", false);
debugChangeDeviceHack = xmlreader.GetValueAsBool("debug", "changedevicehack", false);
- _disableMouseEvents = xmlreader.GetValueAsBool("remote", "CentareaJoystickMap", false);
+ _disableMouseEvents = xmlreader.GetValueAsBool("remote", "CentareaJoystickMap", false);
+ _doNotWaitForVSync = xmlreader.GetValueAsBool("debug", "donotwaitforvsync", false);
}
// When clipCursorWhenFullscreen is TRUE, the cursor is limited to
@@ -583,8 +585,8 @@ public bool FindBestWindowedMode(bool doesRequireHardware, bool doesRequireRefer
graphicsSettings.WindowedMultisampleType = (MultiSampleType)bestDeviceCombo.MultiSampleTypeList[iQuality];
graphicsSettings.WindowedMultisampleQuality = 0; //(int)bestDeviceCombo.MultiSampleQualityList[iQuality];
- graphicsSettings.WindowedVertexProcessingType = (VertexProcessingType)bestDeviceCombo.VertexProcessingTypeList[0];
- graphicsSettings.WindowedPresentInterval = (PresentInterval)bestDeviceCombo.PresentIntervalList[0];
+ graphicsSettings.WindowedVertexProcessingType = (VertexProcessingType)bestDeviceCombo.VertexProcessingTypeList[0];
+ graphicsSettings.WindowedPresentInterval = _doNotWaitForVSync ? PresentInterval.Immediate : (PresentInterval)bestDeviceCombo.PresentIntervalList[0];
return true;
}
@@ -733,7 +735,7 @@ public bool FindBestFullscreenMode(bool doesRequireHardware, bool doesRequireRef
graphicsSettings.FullscreenMultisampleQuality = 0;
graphicsSettings.FullscreenVertexProcessingType =
(VertexProcessingType)bestDeviceCombo.VertexProcessingTypeList[0];
- graphicsSettings.FullscreenPresentInterval = PresentInterval.Default;
+ graphicsSettings.FullscreenPresentInterval = _doNotWaitForVSync ? PresentInterval.Immediate : PresentInterval.Default;
return true;
}
@@ -777,7 +779,7 @@ public void BuildPresentParamsFromSettings(bool bwindowed)
presentParams.BackBufferWidth = ourRenderTarget.ClientRectangle.Right - ourRenderTarget.ClientRectangle.Left;
presentParams.BackBufferHeight = ourRenderTarget.ClientRectangle.Bottom - ourRenderTarget.ClientRectangle.Top;
presentParams.BackBufferFormat = graphicsSettings.BackBufferFormat;
- presentParams.PresentationInterval = PresentInterval.Default;
+ presentParams.PresentationInterval = _doNotWaitForVSync ? PresentInterval.Immediate : PresentInterval.Default;
presentParams.FullScreenRefreshRateInHz = 0;
presentParams.SwapEffect = SwapEffect.Discard;
presentParams.PresentFlag = PresentFlag.Video; //PresentFlag.LockableBackBuffer;
@@ -794,8 +796,8 @@ public void BuildPresentParamsFromSettings(bool bwindowed)
presentParams.BackBufferWidth = graphicsSettings.DisplayMode.Width;
presentParams.BackBufferHeight = graphicsSettings.DisplayMode.Height;
- presentParams.BackBufferFormat = graphicsSettings.DeviceCombo.BackBufferFormat;
- presentParams.PresentationInterval = PresentInterval.Default;
+ presentParams.BackBufferFormat = graphicsSettings.DeviceCombo.BackBufferFormat;
+ presentParams.PresentationInterval = _doNotWaitForVSync ? PresentInterval.Immediate : PresentInterval.Default;
presentParams.FullScreenRefreshRateInHz = graphicsSettings.DisplayMode.RefreshRate;
presentParams.SwapEffect = SwapEffect.Discard;
presentParams.PresentFlag = PresentFlag.Video; //|PresentFlag.LockableBackBuffer;
@@ -1186,7 +1188,7 @@ private void CreateDirectX9ExDevice(CreateFlags createFlags)
Marshal.StructureToPtr(displaymodeEx, prt, true);
int hr = m_d3dEx.CreateDeviceEx(graphicsSettings.AdapterOrdinal, graphicsSettings.DevType,
- windowed ? ourRenderTarget.Handle : this.Handle,
+ windowed ? ourRenderTarget.Handle : this.Handle,
createFlags | CreateFlags.MultiThreaded | CreateFlags.FpuPreserve, ref param,
windowed ? IntPtr.Zero : prt, out dev);
GUIGraphicsContext.DX9Device = new Device(dev);
@@ -2722,12 +2724,18 @@ public void HandleMessage()
private void StartFrameClock()
{
+ if (_doNotWaitForVSync)
+ return;
+
clockWatch.Reset();
clockWatch.Start();
}
private void WaitForFrameClock()
- {
+ {
+ if (_doNotWaitForVSync)
+ return;
+
long milliSecondsLeft;
long timeElapsed = 0;
@@ -2817,8 +2825,8 @@ private bool AppStillIdle()
//System.Diagnostics.Debug.WriteLine(String.Format("msg :hwnd:{0:X} msg:{1:x} wparm:{2:X} lparm:{3:X}", msg1.hwnd, msg1.message, msg1.wParam, msg1.lParam));
}
return !result;
- }
-
+ }
+
private void Application_Idle(object sender, EventArgs e)
{
do

0 comments on commit 40bbf2c

Please sign in to comment.
Something went wrong with that request. Please try again.