Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'FEAT-4164-Use_Direct3D_9Ex_Flip_Mode_Presentation_for_W…

…indows_7_and_later'
  • Loading branch information...
commit c0492d50f0a53b3792763f7f4479413d24606f09 2 parents 4dcb065 + 5b9d0f4
@tourettes tourettes authored
View
15 DirectShowFilters/fontEngine/source/fontEngine.cpp
@@ -123,7 +123,7 @@ struct TEXTURE_PLACE
static FONT_DATA_T* fontData = new FONT_DATA_T[MAX_FONTS];
static TEXTURE_DATA_T* textureData = new TEXTURE_DATA_T[MAX_TEXTURES];
-static LPDIRECT3DDEVICE9 m_pDevice=NULL;
+static LPDIRECT3DDEVICE9EX m_pDevice = NULL;
static CStateManagerInterface* m_pStateManager;
static int textureZ[MAX_TEXTURES];
static TEXTURE_PLACE* texturePlace[MAX_TEXTURES];
@@ -239,7 +239,7 @@ void FontEngineSetDevice(void* device)
return;
}
- m_pDevice = (LPDIRECT3DDEVICE9)device;
+ m_pDevice = (LPDIRECT3DDEVICE9EX)device;
m_Filter = D3DTEXF_NONE;
D3DCAPS9 caps;
@@ -257,6 +257,17 @@ void FontEngineSetDevice(void* device)
//*******************************************************************************************************************
+HRESULT FontEngineSetMaximumFrameLatency(UINT maxLatency)
+{
+ if (m_pDevice)
+ return m_pDevice->SetMaximumFrameLatency(maxLatency);
+ else
+ return S_FALSE;
+}
+
+
+//*******************************************************************************************************************
+
void FontEngineSetRenderState(D3DRENDERSTATETYPE state, DWORD dwValue)
{
m_pStateManager->SetRenderState(state, dwValue);
View
45 DirectShowFilters/fontEngine/source/fontEngine.def
@@ -2,25 +2,26 @@ LIBRARY "fontEngine"
EXPORTS
-FontEngineInitialize @1
-FontEngineAddFont @2
-FontEngineRemoveFont @3
-FontEngineSetCoordinate @4
-FontEngineDrawText3D @5
-FontEnginePresent3D @6
-FontEngineAddTexture @7
-FontEngineRemoveTexture @8
-FontEngineDrawTexture @9
-FontEnginePresentTextures @10
-FontEngineAddSurface @11
-FontEngineSetTexture @12
-FontEngineDrawSurface @13
-FontEngineSetDevice @14
-FontEngineDrawTexture2 @15
-FontEngineDrawMaskedTexture @16
-FontEngineDrawMaskedTexture2 @17
-FontEngineSetClipEnable @18
-FontEngineSetClipDisable @19
-FontEngineSetRenderState @20
-FontEngineSetSamplerState @21
-FontEngineSetTextureStageState @22
+FontEngineInitialize @1
+FontEngineAddFont @2
+FontEngineRemoveFont @3
+FontEngineSetCoordinate @4
+FontEngineDrawText3D @5
+FontEnginePresent3D @6
+FontEngineAddTexture @7
+FontEngineRemoveTexture @8
+FontEngineDrawTexture @9
+FontEnginePresentTextures @10
+FontEngineAddSurface @11
+FontEngineSetTexture @12
+FontEngineDrawSurface @13
+FontEngineSetDevice @14
+FontEngineDrawTexture2 @15
+FontEngineDrawMaskedTexture @16
+FontEngineDrawMaskedTexture2 @17
+FontEngineSetClipEnable @18
+FontEngineSetClipDisable @19
+FontEngineSetRenderState @20
+FontEngineSetSamplerState @21
+FontEngineSetTextureStageState @22
+FontEngineSetMaximumFrameLatency @23
View
2  DirectShowFilters/fontEngine/source/fontEngine.h
@@ -59,5 +59,7 @@ void FontEngineSetRenderState(D3DRENDERSTATETYPE state, DWORD dwValue);
void FontEngineSetSamplerState(DWORD dwStage, D3DSAMPLERSTATETYPE d3dSamplerState, DWORD dwValue);
void FontEngineSetTextureStageState(DWORD dwStage, D3DTEXTURESTAGESTATETYPE d3dTextureStageState, DWORD dwValue);
+HRESULT FontEngineSetMaximumFrameLatency(UINT maxLatency);
+
void PrintStatistics();
void Cleanup();
View
28 mediaportal/MediaPortal.Application/d3dapp.cs
@@ -766,10 +766,32 @@ public bool ChooseInitialSettings()
/// </summary>
public void BuildPresentParamsFromSettings(bool bwindowed)
{
- presentParams.BackBufferCount = 2;
+ bool isWindows7OrLater = OSInfo.OSInfo.Win7OrLater();
presentParams.EnableAutoDepthStencil = false;
presentParams.ForceNoMultiThreadedFlag = false;
+ if (isWindows7OrLater)
+ {
+ if (_doNotWaitForVSync)
+ {
+ // Allow performance measorements when DWM is not blocking Present()
+ presentParams.BackBufferCount = 20;
+ int hr = DXNative.FontEngineSetMaximumFrameLatency(20);
+ if (hr != 0)
+ {
+ Log.Info("D3D: BuildPresentParamsFromSettings failed to set max frame latency - error: {0}", hr);
+ }
+ }
+ else
+ {
+ presentParams.BackBufferCount = 4; // FLIPEX will benefit from more backbuffers
+ }
+ }
+ else
+ {
+ presentParams.BackBufferCount = 2;
+ }
+
if (bwindowed)
{
presentParams.MultiSample = graphicsSettings.WindowedMultisampleType;
@@ -781,7 +803,7 @@ public void BuildPresentParamsFromSettings(bool bwindowed)
presentParams.BackBufferFormat = graphicsSettings.BackBufferFormat;
presentParams.PresentationInterval = _doNotWaitForVSync ? PresentInterval.Immediate : PresentInterval.Default;
presentParams.FullScreenRefreshRateInHz = 0;
- presentParams.SwapEffect = SwapEffect.Discard;
+ presentParams.SwapEffect = isWindows7OrLater ? (SwapEffect)5 : SwapEffect.Discard; // 5 == FLIPEX
presentParams.PresentFlag = PresentFlag.Video; //PresentFlag.LockableBackBuffer;
presentParams.DeviceWindow = ourRenderTarget;
presentParams.Windowed = true;
@@ -799,7 +821,7 @@ public void BuildPresentParamsFromSettings(bool bwindowed)
presentParams.BackBufferFormat = graphicsSettings.DeviceCombo.BackBufferFormat;
presentParams.PresentationInterval = _doNotWaitForVSync ? PresentInterval.Immediate : PresentInterval.Default;
presentParams.FullScreenRefreshRateInHz = graphicsSettings.DisplayMode.RefreshRate;
- presentParams.SwapEffect = SwapEffect.Discard;
+ presentParams.SwapEffect = isWindows7OrLater ? (SwapEffect)5 : SwapEffect.Discard; // 5 == FLIPEX
presentParams.PresentFlag = PresentFlag.Video; //|PresentFlag.LockableBackBuffer;
presentParams.DeviceWindow = this;
presentParams.Windowed = false;
Please sign in to comment.
Something went wrong with that request. Please try again.