diff options
author | a_afra <a_afra@users.sourceforge.net> | 2010-08-25 22:55:30 +0400 |
---|---|---|
committer | a_afra <a_afra@users.sourceforge.net> | 2010-08-25 22:55:30 +0400 |
commit | 9fc0785130b063034a5dc36196dfb38eace599af (patch) | |
tree | d5df1f81aaee3b909809729507fd67bb41889a58 /src/filters/renderer | |
parent | f85d304e744542307140110db7f40a029b65818f (diff) |
- Disable color management, floating point and 10-bit options if not supported
- Fixed temporary texture creation bug in full floating point processing
- Renderer cosmetics
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@2346 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/filters/renderer')
6 files changed, 145 insertions, 87 deletions
diff --git a/src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.cpp b/src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.cpp index 271d342f4..100d62316 100644 --- a/src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.cpp +++ b/src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.cpp @@ -697,7 +697,10 @@ bool CDX9AllocatorPresenter::SettingsNeedResetDevice() HRESULT CDX9AllocatorPresenter::CreateDevice(CString &_Error)
{
StopWorkerThreads();
+
CRenderersSettings& s = GetRenderersSettings();
+ CRenderersData* renderersData = GetRenderersData();
+
m_VBlankEndWait = 0;
m_VBlankMin = 300000;
m_VBlankMinCalc = 300000;
@@ -811,7 +814,6 @@ HRESULT CDX9AllocatorPresenter::CreateDevice(CString &_Error) m_bAlternativeVSync = s.m_RenderSettings.fVMR9AlterativeVSync;
m_bHighColorResolution = s.m_RenderSettings.iEVRHighColorResolution && m_bIsEVR;
- m_bForceInputHighColorResolution = s.m_RenderSettings.iEVRForceInputHighColorResolution && m_bIsEVR;
if (m_bIsFullscreen)
{
@@ -959,9 +961,13 @@ HRESULT CDX9AllocatorPresenter::CreateDevice(CString &_Error) return hr;
}
- ZeroMemory(&m_Caps, sizeof(m_Caps));
- m_pD3DDev->GetDeviceCaps(&m_Caps);
+ // Detect the capabilities of the system
+ DetectCaps();
+ // Get settings that depend on caps
+ m_bForceInputHighColorResolution = s.m_RenderSettings.iEVRForceInputHighColorResolution && m_bIsEVR && renderersData->m_b10bitSupport;
+
+ // Initialize the rendering engine
InitRenderingEngine();
CComPtr<ISubPicProvider> pSubPicProvider;
@@ -1148,9 +1154,11 @@ UINT CDX9AllocatorPresenter::GetAdapter(IDirect3D9* pD3D, bool bCreateDevice) DWORD CDX9AllocatorPresenter::GetVertexProcessing()
{
+ HRESULT hr;
D3DCAPS9 caps;
- if (m_pD3D->GetDeviceCaps(m_CurrentAdapter, D3DDEVTYPE_HAL, &caps) != D3D_OK)
+ hr = m_pD3D->GetDeviceCaps(m_CurrentAdapter, D3DDEVTYPE_HAL, &caps);
+ if (FAILED(hr))
return D3DCREATE_SOFTWARE_VERTEXPROCESSING;
if ((caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) == 0 ||
@@ -1162,6 +1170,40 @@ DWORD CDX9AllocatorPresenter::GetVertexProcessing() return D3DCREATE_HARDWARE_VERTEXPROCESSING;
}
+void CDX9AllocatorPresenter::DetectCaps()
+{
+ HRESULT hr;
+ CRenderersData* renderersData = GetRenderersData();
+
+ // Get the device caps
+ ZeroMemory(&m_Caps, sizeof(m_Caps));
+ m_pD3DDev->GetDeviceCaps(&m_Caps);
+
+ // Detect FP16 support
+ renderersData->m_bFP16Support = true;
+
+ hr = m_pD3D->CheckDeviceFormat(m_CurrentAdapter, D3DDEVTYPE_HAL, m_DisplayType, D3DUSAGE_DYNAMIC, D3DRTYPE_TEXTURE, D3DFMT_A16B16G16R16F);
+ renderersData->m_bFP16Support &= SUCCEEDED(hr);
+ hr = m_pD3D->CheckDeviceFormat(m_CurrentAdapter, D3DDEVTYPE_HAL, m_DisplayType, D3DUSAGE_RENDERTARGET, D3DRTYPE_TEXTURE, D3DFMT_A16B16G16R16F);
+ renderersData->m_bFP16Support &= SUCCEEDED(hr);
+ hr = m_pD3D->CheckDeviceFormat(m_CurrentAdapter, D3DDEVTYPE_HAL, m_DisplayType, D3DUSAGE_QUERY_FILTER, D3DRTYPE_TEXTURE, D3DFMT_A16B16G16R16F);
+ renderersData->m_bFP16Support &= SUCCEEDED(hr);
+ hr = m_pD3D->CheckDeviceFormat(m_CurrentAdapter, D3DDEVTYPE_HAL, m_DisplayType, D3DUSAGE_DYNAMIC, D3DRTYPE_VOLUMETEXTURE, D3DFMT_A16B16G16R16F);
+ renderersData->m_bFP16Support &= SUCCEEDED(hr);
+ hr = m_pD3D->CheckDeviceFormat(m_CurrentAdapter, D3DDEVTYPE_HAL, m_DisplayType, D3DUSAGE_QUERY_FILTER, D3DRTYPE_VOLUMETEXTURE, D3DFMT_A16B16G16R16F);
+ renderersData->m_bFP16Support &= SUCCEEDED(hr);
+
+ // Detect 10-bit support
+ renderersData->m_b10bitSupport = true;
+
+ hr = m_pD3D->CheckDeviceFormat(m_CurrentAdapter, D3DDEVTYPE_HAL, m_DisplayType, D3DUSAGE_DYNAMIC, D3DRTYPE_TEXTURE, D3DFMT_A2R10G10B10);
+ renderersData->m_b10bitSupport &= SUCCEEDED(hr);
+ hr = m_pD3D->CheckDeviceFormat(m_CurrentAdapter, D3DDEVTYPE_HAL, m_DisplayType, D3DUSAGE_RENDERTARGET, D3DRTYPE_TEXTURE, D3DFMT_A2R10G10B10);
+ renderersData->m_b10bitSupport &= SUCCEEDED(hr);
+ hr = m_pD3D->CheckDeviceFormat(m_CurrentAdapter, D3DDEVTYPE_HAL, m_DisplayType, D3DUSAGE_QUERY_FILTER, D3DRTYPE_TEXTURE, D3DFMT_A2R10G10B10);
+ renderersData->m_b10bitSupport &= SUCCEEDED(hr);
+}
+
// ISubPicAllocatorPresenter
STDMETHODIMP CDX9AllocatorPresenter::CreateRenderer(IUnknown** ppRenderer)
@@ -1601,7 +1643,7 @@ STDMETHODIMP_(bool) CDX9AllocatorPresenter::Paint(bool fAll) CRect rDstPri(m_WindowRect);
// Render the current video frame
- hr = RenderVideo(pBackBuffer, rSrcVid, rDstVid, s);
+ hr = RenderVideo(pBackBuffer, rSrcVid, rDstVid);
if (FAILED(hr))
{
@@ -2072,7 +2114,7 @@ void CDX9AllocatorPresenter::DrawStats() if (s.m_RenderSettings.iVMRDisableDesktopComposition)
strText += "DisDC ";
- if (s.m_RenderSettings.iVMR9ColorManagementEnable)
+ if (m_bColorManagement)
strText += "ColorMan ";
if (s.m_RenderSettings.iVMRFlushGPUBeforeVSync)
@@ -2092,14 +2134,14 @@ void CDX9AllocatorPresenter::DrawStats() if (s.m_RenderSettings.iVMR9VSyncOffset)
strText.AppendFormat(L"VSOfst(%d)", s.m_RenderSettings.iVMR9VSyncOffset);
- if (s.m_RenderSettings.iVMR9FullFloatingPointProcessing)
+ if (m_bFullFloatingPointProcessing)
strText += "FullFP ";
if (m_bIsEVR)
{
- if (s.m_RenderSettings.iEVRHighColorResolution)
+ if (m_bHighColorResolution)
strText += "10bitOut ";
- if (s.m_RenderSettings.iEVRForceInputHighColorResolution)
+ if (m_bForceInputHighColorResolution)
strText += "For10bitIn ";
if (s.m_RenderSettings.iEVREnableFrameTimeCorrection)
strText += "FTC ";
diff --git a/src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.h b/src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.h index ab98e85d4..a39dce5ec 100644 --- a/src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.h +++ b/src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.h @@ -68,10 +68,6 @@ protected: CCritSec m_RenderLock;
CComPtr<IDirectDraw> m_pDirectDraw;
- CComPtr<IDirect3D9Ex> m_pD3DEx;
- CComPtr<IDirect3D9> m_pD3D;
- CComPtr<IDirect3DDevice9Ex> m_pD3DDevEx;
-
void LockD3DDevice()
{
if (m_pD3DDev)
@@ -127,6 +123,7 @@ protected: UINT m_CurrentAdapter;
UINT GetAdapter(IDirect3D9 *pD3D, bool GetAdapter = false);
DWORD GetVertexProcessing();
+ void DetectCaps();
bool GetVBlank(int &_ScanLine, int &_bInVBlank, bool _bMeasureTime);
bool WaitForVBlankRange(int &_RasterStart, int _RasterEnd, bool _bWaitIfInside, bool _bNeedAccurate, bool _bMeasure, bool &_bTakenLock);
diff --git a/src/filters/renderer/VideoRenderers/DX9RenderingEngine.cpp b/src/filters/renderer/VideoRenderers/DX9RenderingEngine.cpp index f7db55722..0d612515b 100644 --- a/src/filters/renderer/VideoRenderers/DX9RenderingEngine.cpp +++ b/src/filters/renderer/VideoRenderers/DX9RenderingEngine.cpp @@ -171,6 +171,7 @@ void CDX9RenderingEngine::InitRenderingEngine() {
m_pPSC.Attach(DNew CPixelShaderCompiler(m_pD3DDev, true));
+ // Detect supported StrechRect filter
m_StretchRectFilter = D3DTEXF_NONE;
if((m_Caps.StretchRectFilterCaps&D3DPTFILTERCAPS_MINFLINEAR)
&& (m_Caps.StretchRectFilterCaps&D3DPTFILTERCAPS_MAGFLINEAR))
@@ -279,33 +280,91 @@ void CDX9RenderingEngine::FreeVideoSurfaces() }
}
-HRESULT CDX9RenderingEngine::RenderVideo(IDirect3DSurface9* pRenderTarget, const CRect& srcRect, const CRect& destRect, CRenderersSettings& settings)
+HRESULT CDX9RenderingEngine::RenderVideo(IDirect3DSurface9* pRenderTarget, const CRect& srcRect, const CRect& destRect)
{
if (m_RenderingPath == RENDERING_PATH_DRAW)
- return RenderVideoDrawPath(pRenderTarget, srcRect, destRect, settings);
+ return RenderVideoDrawPath(pRenderTarget, srcRect, destRect);
else
- return RenderVideoStretchRectPath(pRenderTarget, srcRect, destRect, settings);
+ return RenderVideoStretchRectPath(pRenderTarget, srcRect, destRect);
}
-HRESULT CDX9RenderingEngine::RenderVideoDrawPath(IDirect3DSurface9* pRenderTarget, const CRect& srcRect, const CRect& destRect, CRenderersSettings& settings)
+HRESULT CDX9RenderingEngine::RenderVideoDrawPath(IDirect3DSurface9* pRenderTarget, const CRect& srcRect, const CRect& destRect)
{
HRESULT hr;
- // Apply the custom pixel shaders if there are any. Result: pVideoTexture
- CComPtr<IDirect3DTexture9> pVideoTexture = m_pVideoTexture[m_nCurSurface];
+ CRenderersSettings& settings = GetRenderersSettings();
+ // Initialize the processing pipeline
bool bCustomPixelShaders;
+ bool bResizerShaders;
+ bool bCustomScreenSpacePixelShaders;
+ bool bFinalPass;
+
+ int screenSpacePassCount = 0;
+ DWORD iDX9Resizer = settings.iDX9Resizer;
if (m_bD3DX)
{
+ // Final pass. Must be initialized first!
+ hr = InitFinalPass();
+ if (SUCCEEDED(hr))
+ bFinalPass = m_bFinalPass;
+ else
+ bFinalPass = false;
+
+ if (bFinalPass)
+ ++screenSpacePassCount;
+
+ // Resizers
+ float bicubicA = 0;
+ switch (iDX9Resizer)
+ {
+ case 3:
+ bicubicA = -0.60f;
+ break;
+ case 4:
+ bicubicA = -0.751f;
+ break; // FIXME : 0.75 crash recent D3D, or eat CPU
+ case 5:
+ bicubicA = -1.00f;
+ break;
+ }
+
+ hr = InitResizers(bicubicA);
+ bResizerShaders = SUCCEEDED(hr);
+ screenSpacePassCount += 1; // currently all resizers are 1-pass
+
+ // Custom screen space pixel shaders
+ bCustomScreenSpacePixelShaders = !m_pCustomScreenSpacePixelShaders.IsEmpty();
+
+ if (bCustomScreenSpacePixelShaders)
+ screenSpacePassCount += m_pCustomScreenSpacePixelShaders.GetCount();
+
+ // Custom pixel shaders
bCustomPixelShaders = !m_pCustomPixelShaders.IsEmpty();
- InitTemporaryVideoTextures(min(m_pCustomPixelShaders.GetCount(), 2));
+
+ hr = InitTemporaryVideoTextures(min(m_pCustomPixelShaders.GetCount(), 2));
+ if (FAILED(hr))
+ bCustomPixelShaders = false;
}
else
{
bCustomPixelShaders = false;
+ bResizerShaders = false;
+ bCustomScreenSpacePixelShaders = false;
+ bFinalPass = false;
+ }
+
+ hr = InitScreenSpacePipeline(screenSpacePassCount, pRenderTarget);
+ if (FAILED(hr))
+ {
+ bCustomScreenSpacePixelShaders = false;
+ bFinalPass = false;
}
+ // Apply the custom pixel shaders if there are any. Result: pVideoTexture
+ CComPtr<IDirect3DTexture9> pVideoTexture = m_pVideoTexture[m_nCurSurface];
+
if (bCustomPixelShaders)
{
static __int64 counter = 0;
@@ -369,65 +428,6 @@ HRESULT CDX9RenderingEngine::RenderVideoDrawPath(IDirect3DSurface9* pRenderTarge pVideoTexture = m_pTemporaryVideoTextures[src];
}
- // Initialize the screen space pipeline
- bool bResizerShaders;
- bool bCustomScreenSpacePixelShaders;
- bool bFinalPass;
-
- int screenSpacePassCount = 0;
- DWORD iDX9Resizer = settings.iDX9Resizer;
-
- if (m_bD3DX)
- {
- float bicubicA = 0;
- switch (iDX9Resizer)
- {
- case 3:
- bicubicA = -0.60f;
- break;
- case 4:
- bicubicA = -0.751f;
- break; // FIXME : 0.75 crash recent D3D, or eat CPU
- case 5:
- bicubicA = -1.00f;
- break;
- }
-
- // Resizers
- hr = InitResizers(bicubicA);
- bResizerShaders = SUCCEEDED(hr);
- screenSpacePassCount += 1; // currently all resizers are 1-pass
-
- // Custom screen space pixel shaders
- bCustomScreenSpacePixelShaders = !m_pCustomScreenSpacePixelShaders.IsEmpty();
-
- if (bCustomScreenSpacePixelShaders)
- screenSpacePassCount += m_pCustomScreenSpacePixelShaders.GetCount();
-
- // Final pass
- hr = InitFinalPass(settings);
- if (SUCCEEDED(hr))
- bFinalPass = m_bFinalPass;
- else
- bFinalPass = false;
-
- if (bFinalPass)
- ++screenSpacePassCount;
- }
- else
- {
- bResizerShaders = false;
- bCustomScreenSpacePixelShaders = false;
- bFinalPass = false;
- }
-
- hr = InitScreenSpacePipeline(screenSpacePassCount, pRenderTarget);
- if (FAILED(hr))
- {
- bCustomScreenSpacePixelShaders = false;
- bFinalPass = false;
- }
-
// Resize the frame
Vector dst[4];
Transform(destRect, dst);
@@ -499,7 +499,7 @@ HRESULT CDX9RenderingEngine::RenderVideoDrawPath(IDirect3DSurface9* pRenderTarge return hr;
}
-HRESULT CDX9RenderingEngine::RenderVideoStretchRectPath(IDirect3DSurface9* pRenderTarget, const CRect& srcRect, const CRect& destRect, CRenderersSettings& settings)
+HRESULT CDX9RenderingEngine::RenderVideoStretchRectPath(IDirect3DSurface9* pRenderTarget, const CRect& srcRect, const CRect& destRect)
{
HRESULT hr = S_OK;
@@ -960,10 +960,13 @@ HRESULT CDX9RenderingEngine::TextureResizeBicubic2pass(IDirect3DTexture9* pTextu }
*/
-HRESULT CDX9RenderingEngine::InitFinalPass(CRenderersSettings& settings)
+HRESULT CDX9RenderingEngine::InitFinalPass()
{
HRESULT hr;
+ CRenderersSettings& settings = GetRenderersSettings();
+ CRenderersData* data = GetRenderersData();
+
// Check whether the final pass must be initialized
bool bFullFloatingPointProcessing = settings.m_RenderSettings.iVMR9FullFloatingPointProcessing;
bool bColorManagement = settings.m_RenderSettings.iVMR9ColorManagementEnable;
@@ -995,6 +998,11 @@ HRESULT CDX9RenderingEngine::InitFinalPass(CRenderersSettings& settings) // Cleanup
CleanupFinalPass();
+ // Check whether the final pass is supported by the hardware
+ m_bFinalPass = data->m_bFP16Support;
+ if (!m_bFinalPass)
+ return S_OK;
+
// Update the settings
m_bFullFloatingPointProcessing = bFullFloatingPointProcessing;
m_bColorManagement = bColorManagement;
diff --git a/src/filters/renderer/VideoRenderers/DX9RenderingEngine.h b/src/filters/renderer/VideoRenderers/DX9RenderingEngine.h index 8bd7a1af3..d7ac58adc 100644 --- a/src/filters/renderer/VideoRenderers/DX9RenderingEngine.h +++ b/src/filters/renderer/VideoRenderers/DX9RenderingEngine.h @@ -45,7 +45,10 @@ protected: static const int MAX_VIDEO_SURFACES = 60;
// Variables initialized/managed by the allocator-presenter!
+ CComPtr<IDirect3D9> m_pD3D;
+ CComPtr<IDirect3D9Ex> m_pD3DEx;
CComPtr<IDirect3DDevice9> m_pD3DDev;
+ CComPtr<IDirect3DDevice9Ex> m_pD3DDevEx;
D3DCAPS9 m_Caps;
D3DFORMAT m_BackbufferType;
D3DFORMAT m_DisplayType;
@@ -55,7 +58,6 @@ protected: bool m_bHighColorResolution;
bool m_bForceInputHighColorResolution;
- bool m_bFullFloatingPointProcessing;
// Variables initialized/managed by this class but can be accessed by the allocator-presenter
bool m_bD3DX;
@@ -64,6 +66,8 @@ protected: CComPtr<IDirect3DTexture9> m_pVideoTexture[MAX_VIDEO_SURFACES];
CComPtr<IDirect3DSurface9> m_pVideoSurface[MAX_VIDEO_SURFACES];
+ bool m_bFullFloatingPointProcessing;
+ bool m_bColorManagement;
CDX9RenderingEngine(HWND hWnd, HRESULT& hr, CString *_pError);
@@ -73,7 +77,7 @@ protected: HRESULT CreateVideoSurfaces(D3DFORMAT format);
void FreeVideoSurfaces();
- HRESULT RenderVideo(IDirect3DSurface9* pRenderTarget, const CRect& srcRect, const CRect& destRect, CRenderersSettings& settings);
+ HRESULT RenderVideo(IDirect3DSurface9* pRenderTarget, const CRect& srcRect, const CRect& destRect);
HRESULT DrawRect(DWORD _Color, DWORD _Alpha, const CRect &_Rect);
HRESULT AlphaBlt(RECT* pSrc, RECT* pDst, IDirect3DTexture9* pTexture);
@@ -108,7 +112,6 @@ private: CAutoPtr<CPixelShaderCompiler> m_pPSC;
// Settings
- bool m_bColorManagement;
VideoSystem m_InputVideoSystem;
GammaCurve m_Gamma;
ColorRenderingIntent m_RenderingIntent;
@@ -148,8 +151,8 @@ private: // Video rendering paths
- HRESULT RenderVideoDrawPath(IDirect3DSurface9* pRenderTarget, const CRect& srcRect, const CRect& destRect, CRenderersSettings& settings);
- HRESULT RenderVideoStretchRectPath(IDirect3DSurface9* pRenderTarget, const CRect& srcRect, const CRect& destRect, CRenderersSettings& settings);
+ HRESULT RenderVideoDrawPath(IDirect3DSurface9* pRenderTarget, const CRect& srcRect, const CRect& destRect);
+ HRESULT RenderVideoStretchRectPath(IDirect3DSurface9* pRenderTarget, const CRect& srcRect, const CRect& destRect);
// Custom pixel shaders
HRESULT InitTemporaryVideoTextures(int count);
@@ -167,7 +170,7 @@ private: //HRESULT TextureResizeBicubic2pass(IDirect3DTexture9* pTexture, Vector dst[4], const CRect &srcRect);
// Final pass
- HRESULT InitFinalPass(CRenderersSettings& settings);
+ HRESULT InitFinalPass();
void CleanupFinalPass();
HRESULT CreateIccProfileLut(TCHAR* profilePath, float* lut3D);
HRESULT FinalPass(IDirect3DTexture9* pTexture);
diff --git a/src/filters/renderer/VideoRenderers/RenderersSettings.cpp b/src/filters/renderer/VideoRenderers/RenderersSettings.cpp index e57a82409..c6762348a 100644 --- a/src/filters/renderer/VideoRenderers/RenderersSettings.cpp +++ b/src/filters/renderer/VideoRenderers/RenderersSettings.cpp @@ -35,6 +35,10 @@ CRenderersData::CRenderersData() m_bResetStats = false;
m_hD3DX9Dll = NULL;
m_nDXSdkRelease = 0;
+
+ // Don't disable caps before initializing a renderer
+ m_bFP16Support = true;
+ m_b10bitSupport = true;
}
LONGLONG CRenderersData::GetPerfCounter()
diff --git a/src/filters/renderer/VideoRenderers/RenderersSettings.h b/src/filters/renderer/VideoRenderers/RenderersSettings.h index 2a1787524..cefcf2433 100644 --- a/src/filters/renderer/VideoRenderers/RenderersSettings.h +++ b/src/filters/renderer/VideoRenderers/RenderersSettings.h @@ -223,6 +223,10 @@ public: bool m_bResetStats; // Set to reset the presentation statistics
CString m_strD3DX9Version;
+ // Caps
+ bool m_bFP16Support;
+ bool m_b10bitSupport;
+
LONGLONG GetPerfCounter();
HINSTANCE GetD3X9Dll();
int GetDXSdkRelease()
|