Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkinddragon <kinddragon@users.sourceforge.net>2010-05-17 03:55:45 +0400
committerkinddragon <kinddragon@users.sourceforge.net>2010-05-17 03:55:45 +0400
commit4e0bb6595d4c1e9df9d30e217c77e6e17604c3be (patch)
tree772f052af6fd4df8530d4f4d0f28d1802db81fad /src/filters/renderer/VideoRenderers
parenteab6a6a1d35226284a1bcc9f63b9b0ccf8c0d623 (diff)
Previous commit SyncClock path fix
Probably fixed ticket #474 Some L4 warnings fixed in VideoRenderers library git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@1888 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/filters/renderer/VideoRenderers')
-rw-r--r--src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.cpp76
-rw-r--r--src/filters/renderer/VideoRenderers/SyncRenderer.cpp108
2 files changed, 118 insertions, 66 deletions
diff --git a/src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.cpp b/src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.cpp
index cb103561d..0efc3725a 100644
--- a/src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.cpp
+++ b/src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.cpp
@@ -596,15 +596,15 @@ void CDX9AllocatorPresenter::VSyncThread()
TIMECAPS tc;
DWORD dwResolution;
DWORD dwUser = 0;
- DWORD dwTaskIndex = 0;
- // Tell Vista Multimedia Class Scheduler we are a playback thretad (increase priority)
-// if (pfAvSetMmThreadCharacteristicsW)
-// hAvrt = pfAvSetMmThreadCharacteristicsW (L"Playback", &dwTaskIndex);
-// if (pfAvSetMmThreadPriority)
-// pfAvSetMmThreadPriority (hAvrt, AVRT_PRIORITY_HIGH /*AVRT_PRIORITY_CRITICAL*/);
+ //DWORD dwTaskIndex = 0;
+ //// Tell Vista Multimedia Class Scheduler we are a playback thretad (increase priority)
+ //if (pfAvSetMmThreadCharacteristicsW)
+ // hAvrt = pfAvSetMmThreadCharacteristicsW (L"Playback", &dwTaskIndex);
+ //if (pfAvSetMmThreadPriority)
+ // pfAvSetMmThreadPriority (hAvrt, AVRT_PRIORITY_HIGH /*AVRT_PRIORITY_CRITICAL*/);
-// Sleep(2000); // Remove ugly patch : create a 2s delay on opening files with Win7!
+ //Sleep(2000); // Remove ugly patch : create a 2s delay on opening files with Win7!
timeGetDevCaps(&tc, sizeof(TIMECAPS));
dwResolution = min(max(tc.wPeriodMin, 0), tc.wPeriodMax);
@@ -638,13 +638,13 @@ void CDX9AllocatorPresenter::VSyncThread()
VSyncPos += m_ScreenSize.cy;
int ScanLine = 0;
- int bInVBlank = 0;
- int StartScanLine = ScanLine;
- int LastPos = ScanLine;
+ int StartScanLine = ScanLine;
+ UNUSED_ALWAYS(StartScanLine);
+ int LastPos = ScanLine;
+ UNUSED_ALWAYS(LastPos);
ScanLine = (VSyncPos + 1) % m_ScreenSize.cy;
if (ScanLine < 0)
ScanLine += m_ScreenSize.cy;
- int FirstScanLine = ScanLine;
int ScanLineMiddle = ScanLine + m_ScreenSize.cy/2;
ScanLineMiddle = ScanLineMiddle % m_ScreenSize.cy;
if (ScanLineMiddle < 0)
@@ -763,7 +763,7 @@ void CDX9AllocatorPresenter::VSyncThread()
DWORD WINAPI CDX9AllocatorPresenter::VSyncThreadStatic(LPVOID lpParam)
{
- SetThreadName(-1, "CDX9Presenter::VSyncThread");
+ SetThreadName((DWORD)-1, "CDX9Presenter::VSyncThread");
CDX9AllocatorPresenter* pThis = (CDX9AllocatorPresenter*) lpParam;
pThis->VSyncThread();
return 0;
@@ -1037,7 +1037,7 @@ HRESULT CDX9AllocatorPresenter::CreateDevice(CString &_Error)
m_CurrentAdapter = GetAdapter(m_pD3D, true);
hr = m_pD3DEx->CreateDeviceEx(
m_CurrentAdapter, D3DDEVTYPE_HAL, m_hWnd,
- D3DCREATE_SOFTWARE_VERTEXPROCESSING|D3DCREATE_MULTITHREADED, //D3DCREATE_MANAGED
+ D3DCREATE_SOFTWARE_VERTEXPROCESSING|D3DCREATE_MULTITHREADED|D3DCREATE_ENABLE_PRESENTSTATS, //D3DCREATE_MANAGED
&pp, &DisplayMode, &m_pD3DDevEx);
m_D3DDevExError = GetWindowsErrorMessage(hr, m_hD3D9);
@@ -1067,11 +1067,7 @@ HRESULT CDX9AllocatorPresenter::CreateDevice(CString &_Error)
m_pD3DDev->SetDialogBoxMode(true);
//if (m_pD3DDev->SetDialogBoxMode(true) != S_OK)
// ExitProcess(0);
-
}
-
- TRACE("CreateDevice: %d\n", (LONG)hr);
- ASSERT (SUCCEEDED (hr));
}
else
{
@@ -1107,7 +1103,7 @@ HRESULT CDX9AllocatorPresenter::CreateDevice(CString &_Error)
{
hr = m_pD3DEx->CreateDeviceEx(
m_CurrentAdapter, D3DDEVTYPE_HAL, m_hWnd,
- D3DCREATE_SOFTWARE_VERTEXPROCESSING|D3DCREATE_MULTITHREADED, //D3DCREATE_MANAGED
+ D3DCREATE_SOFTWARE_VERTEXPROCESSING|D3DCREATE_MULTITHREADED|D3DCREATE_ENABLE_PRESENTSTATS, //D3DCREATE_MANAGED
&pp, NULL, &m_pD3DDevEx);
if (m_pD3DDevEx)
m_pD3DDev = m_pD3DDevEx;
@@ -1121,6 +1117,20 @@ HRESULT CDX9AllocatorPresenter::CreateDevice(CString &_Error)
}
}
+ while(hr == D3DERR_DEVICELOST)
+ {
+ TRACE("D3DERR_DEVICELOST. Trying to Reset.\n");
+ hr = m_pD3DDev->TestCooperativeLevel();
+ }
+ if (hr == D3DERR_DEVICENOTRESET)
+ {
+ TRACE("D3DERR_DEVICENOTRESET\n");
+ hr = m_pD3DDev->Reset(&pp);
+ }
+
+ TRACE("CreateDevice: %d\n", (LONG)hr);
+ ASSERT (SUCCEEDED (hr));
+
m_MainThreadId = GetCurrentThreadId();
if (m_pD3DDevEx)
@@ -1612,8 +1622,6 @@ HRESULT CDX9AllocatorPresenter::TextureResize(IDirect3DTexture9* pTexture, Vecto
float w = (float)desc.Width;
float h = (float)desc.Height;
- float dx = 1.0f/w;
- float dy = 1.0f/h;
float dx2 = 1.0/w;
float dy2 = 1.0/h;
@@ -1738,12 +1746,15 @@ HRESULT CDX9AllocatorPresenter::TextureResizeBicubic2pass(IDirect3DTexture9* pTe
float Tex0_Width = desc.Width;
float Tex0_Height = desc.Height;
- double dx0 = 1.0/desc.Width;
- double dy0 = 1.0/desc.Height;
+ double dx0 = 1.0/desc.Width;
+ UNUSED_ALWAYS(dx0);
+ double dy0 = 1.0/desc.Height;
+ UNUSED_ALWAYS(dy0);
CSize SrcTextSize = CSize(desc.Width, desc.Height);
double w = (double)SrcRect.Width();
double h = (double)SrcRect.Height();
+ UNUSED_ALWAYS(w);
CRect dst1(0, 0, (int)(dst[3].x - dst[0].x), (int)h);
@@ -1753,14 +1764,21 @@ HRESULT CDX9AllocatorPresenter::TextureResizeBicubic2pass(IDirect3DTexture9* pTe
float Tex1_Width = desc.Width;
float Tex1_Height = desc.Height;
- double dx1 = 1.0/desc.Width;
- double dy1 = 1.0/desc.Height;
+ double dx1 = 1.0/desc.Width;
+ UNUSED_ALWAYS(dx1);
+ double dy1 = 1.0/desc.Height;
+ UNUSED_ALWAYS(dy1);
- double dw = (double)dst1.Width() / desc.Width;
- double dh = (double)dst1.Height() / desc.Height;
+ double dw = (double)dst1.Width() / desc.Width;
+ UNUSED_ALWAYS(dw);
+ double dh = (double)dst1.Height() / desc.Height;
+ UNUSED_ALWAYS(dh);
float dx2 = 1.0f/SrcTextSize.cx;
+ UNUSED_ALWAYS(dx2);
float dy2 = 1.0f/SrcTextSize.cy;
+ UNUSED_ALWAYS(dy2);
+
float tx0 = SrcRect.left;
float tx1 = SrcRect.right;
float ty0 = SrcRect.top;
@@ -2017,6 +2035,10 @@ bool CDX9AllocatorPresenter::GetVBlank(int &_ScanLine, int &_bInVBlank, bool _bM
if (_bMeasureTime)
{
LONGLONG Time = GetRenderersData()->GetPerfCounter() - llPerf;
+ if (Time > 5000000) // 0.5 sec
+ {
+ TRACE("GetVBlank too long (%f sec)\n", Time / 10000000.0);
+ }
m_RasterStatusWaitTimeMaxCalc = max(m_RasterStatusWaitTimeMaxCalc, Time);
}
@@ -3170,7 +3192,7 @@ void CDX9AllocatorPresenter::DrawStats()
else if (m_pVideoSurface[0])
m_pVideoSurface[0]->GetDesc(&desc);
- if (desc.Width != m_NativeVideoSize.cx || desc.Height != m_NativeVideoSize.cy)
+ if (desc.Width != (UINT)m_NativeVideoSize.cx || desc.Height != (UINT)m_NativeVideoSize.cy)
{
strText.Format(L"Texture size : %d x %d", desc.Width, desc.Height);
DrawText(rc, strText, 1);
diff --git a/src/filters/renderer/VideoRenderers/SyncRenderer.cpp b/src/filters/renderer/VideoRenderers/SyncRenderer.cpp
index c3ec0e813..5af870a4a 100644
--- a/src/filters/renderer/VideoRenderers/SyncRenderer.cpp
+++ b/src/filters/renderer/VideoRenderers/SyncRenderer.cpp
@@ -22,7 +22,7 @@
*/
#include "stdafx.h"
-#include "../../filters/misc/SyncClock/Interfaces.h"
+#include "../../filters/renderer/misc/SyncClock/Interfaces.h"
#include <atlbase.h>
#include <atlcoll.h>
#include "../apps/mplayerc/resource.h"
@@ -584,7 +584,9 @@ HRESULT CBaseAP::CreateDXDevice(CString &_Error)
DisplayMode.Format = pp.BackBufferFormat;
pp.FullScreen_RefreshRateInHz = DisplayMode.RefreshRate;
- if FAILED(m_pD3DEx->CreateDeviceEx(m_CurrentAdapter, D3DDEVTYPE_HAL, m_hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING|D3DCREATE_MULTITHREADED, &pp, &DisplayMode, &m_pD3DDevEx))
+ if FAILED(m_pD3DEx->CreateDeviceEx(m_CurrentAdapter, D3DDEVTYPE_HAL, m_hWnd,
+ D3DCREATE_HARDWARE_VERTEXPROCESSING|D3DCREATE_MULTITHREADED|D3DCREATE_ENABLE_PRESENTSTATS,
+ &pp, &DisplayMode, &m_pD3DDevEx))
{
_Error += GothSyncErrorMessage(hr, m_hD3D9);
return hr;
@@ -648,7 +650,9 @@ HRESULT CBaseAP::CreateDXDevice(CString &_Error)
}
if (m_pD3DEx)
{
- if FAILED(m_pD3DEx->CreateDeviceEx(m_CurrentAdapter, D3DDEVTYPE_HAL, m_hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING|D3DCREATE_MULTITHREADED, &pp, NULL, &m_pD3DDevEx))
+ if FAILED(m_pD3DEx->CreateDeviceEx(m_CurrentAdapter, D3DDEVTYPE_HAL, m_hWnd,
+ D3DCREATE_HARDWARE_VERTEXPROCESSING|D3DCREATE_MULTITHREADED|D3DCREATE_ENABLE_PRESENTSTATS,
+ &pp, NULL, &m_pD3DDevEx))
{
_Error += GothSyncErrorMessage(hr, m_hD3D9);
return hr;
@@ -657,14 +661,30 @@ HRESULT CBaseAP::CreateDXDevice(CString &_Error)
}
else
{
- if FAILED(m_pD3D->CreateDevice(m_CurrentAdapter, D3DDEVTYPE_HAL, m_hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING|D3DCREATE_MULTITHREADED, &pp, &m_pD3DDev))
+ if FAILED(m_pD3D->CreateDevice(m_CurrentAdapter, D3DDEVTYPE_HAL, m_hWnd,
+ D3DCREATE_HARDWARE_VERTEXPROCESSING|D3DCREATE_MULTITHREADED,
+ &pp, &m_pD3DDev))
{
_Error += GothSyncErrorMessage(hr, m_hD3D9);
return hr;
}
_tprintf(_T("Created windowed device\n"));
}
- }
+ }
+
+ while(hr == D3DERR_DEVICELOST)
+ {
+ TRACE("D3DERR_DEVICELOST. Trying to Reset.\n");
+ hr = m_pD3DDev->TestCooperativeLevel();
+ }
+ if (hr == D3DERR_DEVICENOTRESET)
+ {
+ TRACE("D3DERR_DEVICENOTRESET\n");
+ hr = m_pD3DDev->Reset(&pp);
+ }
+
+ TRACE("CreateDevice: %d\n", (LONG)hr);
+ ASSERT (SUCCEEDED (hr));
if (m_pD3DDevEx)
{
@@ -1332,8 +1352,6 @@ HRESULT CBaseAP::TextureResize(IDirect3DTexture9* pTexture, Vector dst[4], D3DTE
float w = (float)desc.Width;
float h = (float)desc.Height;
- float dx = 1.0f/w;
- float dy = 1.0f/h;
float dx2 = 1.0/w;
float dy2 = 1.0/h;
@@ -1362,8 +1380,6 @@ HRESULT CBaseAP::TextureResizeBilinear(IDirect3DTexture9* pTexture, Vector dst[4
float w = (float)desc.Width;
float h = (float)desc.Height;
- float dx = 1.0f/w;
- float dy = 1.0f/h;
float tx0 = SrcRect.left;
float tx1 = SrcRect.right;
float ty0 = SrcRect.top;
@@ -1397,14 +1413,6 @@ HRESULT CBaseAP::TextureResizeBicubic1pass(IDirect3DTexture9* pTexture, Vector d
double w = (double)desc.Width;
double h = (double)desc.Height;
- double sw = SrcRect.Width();
- double sh = SrcRect.Height();
-
- double dx = 1.0f/w;
- double dy = 1.0f/h;
-
- float dx2 = 1.0f/w;
- float dy2 = 1.0f/h;
float tx0 = SrcRect.left;
float tx1 = SrcRect.right;
float ty0 = SrcRect.top;
@@ -1446,12 +1454,10 @@ HRESULT CBaseAP::TextureResizeBicubic2pass(IDirect3DTexture9* pTexture, Vector d
float Tex0_Width = desc.Width;
float Tex0_Height = desc.Height;
- double dx0 = 1.0/desc.Width;
- double dy0 = 1.0/desc.Height;
-
CSize SrcTextSize = CSize(desc.Width, desc.Height);
double w = (double)SrcRect.Width();
- double h = (double)SrcRect.Height();
+ double h = (double)SrcRect.Height();
+ UNUSED_ALWAYS(w);
CRect dst1(0, 0, (int)(dst[3].x - dst[0].x), (int)h);
@@ -1461,14 +1467,6 @@ HRESULT CBaseAP::TextureResizeBicubic2pass(IDirect3DTexture9* pTexture, Vector d
float Tex1_Width = desc.Width;
float Tex1_Height = desc.Height;
- double dx1 = 1.0/desc.Width;
- double dy1 = 1.0/desc.Height;
-
- double dw = (double)dst1.Width() / desc.Width;
- double dh = (double)dst1.Height() / desc.Height;
-
- float dx2 = 1.0f/SrcTextSize.cx;
- float dy2 = 1.0f/SrcTextSize.cy;
float tx0 = SrcRect.left;
float tx1 = SrcRect.right;
float ty0 = SrcRect.top;
@@ -2115,8 +2113,6 @@ void CBaseAP::DrawStats()
LONGLONG llMaxJitter = m_MaxJitter;
LONGLONG llMinJitter = m_MinJitter;
- LONGLONG llMaxSyncOffset = m_MaxSyncOffset;
- LONGLONG llMinSyncOffset = m_MinSyncOffset;
RECT rc = {20, 20, 520, 520 };
// pApp->m_fDisplayStats = 1 for full stats, 2 for little less, 3 for basic, 0 for no stats
@@ -2164,7 +2160,46 @@ void CBaseAP::DrawStats()
strText.Format(L"Graphics device does not support scan line access. No sync is possible");
DrawText(rc, strText, 1);
OffsetRect(&rc, 0, TextHeight);
- }
+ }
+
+#ifdef _DEBUG
+ if (m_pD3DDevEx)
+ {
+ CComPtr<IDirect3DSwapChain9> pSC;
+ HRESULT hr = m_pD3DDevEx->GetSwapChain(0, &pSC);
+ CComQIPtr<IDirect3DSwapChain9Ex> pSCEx = pSC;
+ if (pSCEx)
+ {
+ D3DPRESENTSTATS stats;
+ hr = pSCEx->GetPresentStats(&stats);
+ if (SUCCEEDED(hr))
+ {
+ strText.Format(L"Graphics device present stats:");
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+
+ strText.Format(L" PresentCount %d PresentRefreshCount %d SyncRefreshCount %d",
+ stats.PresentCount, stats.PresentRefreshCount, stats.SyncRefreshCount);
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+
+ LARGE_INTEGER Freq;
+ QueryPerformanceFrequency (&Freq);
+ Freq.QuadPart /= 1000;
+ strText.Format(L" SyncQPCTime %dms SyncGPUTime %dms",
+ stats.SyncQPCTime.QuadPart / Freq.QuadPart, stats.SyncGPUTime.QuadPart / Freq.QuadPart);
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+ }
+ else
+ {
+ strText.Format(L"Graphics device does not support present stats");
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+ }
+ }
+ }
+#endif
strText.Format(L"Video resolution: %d x %d | Aspect ratio: %d x %d", m_NativeVideoSize.cx, m_NativeVideoSize.cy, m_AspectRatio.cx, m_AspectRatio.cy);
DrawText(rc, strText, 1);
@@ -2951,7 +2986,6 @@ void CSyncAP::CompleteFrameStep(bool bCancel)
STDMETHODIMP CSyncAP::ProcessMessage(MFVP_MESSAGE_TYPE eMessage, ULONG_PTR ulParam)
{
HRESULT hr = S_OK;
- CRenderersSettings& s = GetRenderersSettings();
switch (eMessage)
{
@@ -3556,7 +3590,8 @@ STDMETHODIMP CSyncAP::GetVideoService(HANDLE hDevice, REFIID riid, void **ppServ
}
else if (riid == __uuidof(IDirectXVideoProcessorService))
{
- IDirectXVideoProcessorService* pDXVAProcessor = (IDirectXVideoProcessorService*) *ppService;
+ IDirectXVideoProcessorService* pDXVAProcessor = (IDirectXVideoProcessorService*) *ppService;
+ UNUSED_ALWAYS(pDXVAProcessor);
}
return hr;
@@ -3623,7 +3658,6 @@ void CSyncAP::MixerThread()
TIMECAPS tc;
DWORD dwResolution;
DWORD dwUser = 0;
- DWORD dwTaskIndex = 0;
timeGetDevCaps(&tc, sizeof(TIMECAPS));
dwResolution = min(max(tc.wPeriodMin, 0), tc.wPeriodMax);
@@ -3683,8 +3717,6 @@ void CSyncAP::RenderThread()
if (pfAvSetMmThreadCharacteristicsW) hAvrt = pfAvSetMmThreadCharacteristicsW (L"Playback", &dwTaskIndex);
if (pfAvSetMmThreadPriority) pfAvSetMmThreadPriority (hAvrt, AVRT_PRIORITY_HIGH);
- CRenderersSettings& s = GetRenderersSettings();
-
// Set timer resolution
timeGetDevCaps(&tc, sizeof(TIMECAPS));
dwResolution = min(max(tc.wPeriodMin, 0), tc.wPeriodMax);
@@ -4011,7 +4043,6 @@ HRESULT CSyncAP::AdviseSyncClock(ISyncClock* sC)
HRESULT CSyncAP::BeginStreaming()
{
- CRenderersSettings& s = GetRenderersSettings();
m_pcFramesDropped = 0;
m_pcFramesDrawn = 0;
@@ -4320,7 +4351,6 @@ HRESULT CGenlock::GetTiming()
INT i = 0;
INT j = 0;
INT params = 0;
- BOOL done = FALSE;
TCHAR tmpStr[MAX_LOADSTRING];
CAutoLock lock(&csGenlockLock);