diff options
author | CrystalPT <CrystalPT@svn> | 2010-08-30 03:48:27 +0000 |
---|---|---|
committer | CrystalPT <CrystalPT@svn> | 2010-08-30 03:48:27 +0000 |
commit | 87e318bc01bbbbf00260a1c8b8af9a7aae583a1a (patch) | |
tree | 87384434bef2e1a1f42ea05f39998f60b2fbadc9 | |
parent | 28f8126ac9dafdb4bb8d64f320660eef913ae6bf (diff) |
[WIN32] added: DXT1/3 availability check + refactored texture/surface availability check
git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@33329 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
-rw-r--r-- | xbmc/RenderSystemDX.cpp | 52 | ||||
-rw-r--r-- | xbmc/RenderSystemDX.h | 5 |
2 files changed, 30 insertions, 27 deletions
diff --git a/xbmc/RenderSystemDX.cpp b/xbmc/RenderSystemDX.cpp index 3d1bdd48a7..4bf220dd5b 100644 --- a/xbmc/RenderSystemDX.cpp +++ b/xbmc/RenderSystemDX.cpp @@ -183,7 +183,7 @@ bool CRenderSystemDX::ResetRenderSystem(int width, int height, bool fullScreen, return true; } -bool CRenderSystemDX::IsTextureFormatOk(D3DFORMAT depthFormat, DWORD usage) +bool CRenderSystemDX::IsSurfaceFormatOk(D3DFORMAT surfFormat, DWORD usage) { // Verify the compatibility HRESULT hr = m_pD3D->CheckDeviceFormat(m_adapter, @@ -191,27 +191,34 @@ bool CRenderSystemDX::IsTextureFormatOk(D3DFORMAT depthFormat, DWORD usage) m_D3DPP.BackBufferFormat, usage, D3DRTYPE_SURFACE, - depthFormat); + surfFormat); return (SUCCEEDED(hr)) ? true : false; } -BOOL CRenderSystemDX::IsDepthFormatOk(D3DFORMAT DepthFormat, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat) +bool CRenderSystemDX::IsTextureFormatOk(D3DFORMAT texFormat, DWORD usage) { - // Verify that the depth format exists + // Verify the compatibility HRESULT hr = m_pD3D->CheckDeviceFormat(m_adapter, m_devType, - AdapterFormat, - D3DUSAGE_DEPTHSTENCIL, - D3DRTYPE_SURFACE, - DepthFormat); + m_D3DPP.BackBufferFormat, + usage, + D3DRTYPE_TEXTURE, + texFormat); - if(FAILED(hr)) return FALSE; + return (SUCCEEDED(hr)) ? true : false; +} + +BOOL CRenderSystemDX::IsDepthFormatOk(D3DFORMAT DepthFormat, D3DFORMAT RenderTargetFormat) +{ + // Verify that the depth format exists + if (!IsSurfaceFormatOk(DepthFormat, D3DUSAGE_DEPTHSTENCIL)) + return false; // Verify that the depth format is compatible - hr = m_pD3D->CheckDepthStencilMatch(m_adapter, + HRESULT hr = m_pD3D->CheckDepthStencilMatch(m_adapter, m_devType, - AdapterFormat, + m_D3DPP.BackBufferFormat, RenderTargetFormat, DepthFormat); @@ -251,12 +258,12 @@ void CRenderSystemDX::BuildPresentParameters() m_D3DPP.MultiSampleQuality = 0; D3DFORMAT zFormat = D3DFMT_D16; - if (IsDepthFormatOk(D3DFMT_D32, m_D3DPP.BackBufferFormat, m_D3DPP.BackBufferFormat)) zFormat = D3DFMT_D32; - else if (IsDepthFormatOk(D3DFMT_D24S8, m_D3DPP.BackBufferFormat, m_D3DPP.BackBufferFormat)) zFormat = D3DFMT_D24S8; - else if (IsDepthFormatOk(D3DFMT_D24X4S4, m_D3DPP.BackBufferFormat, m_D3DPP.BackBufferFormat)) zFormat = D3DFMT_D24X4S4; - else if (IsDepthFormatOk(D3DFMT_D24X8, m_D3DPP.BackBufferFormat, m_D3DPP.BackBufferFormat)) zFormat = D3DFMT_D24X8; - else if (IsDepthFormatOk(D3DFMT_D16, m_D3DPP.BackBufferFormat, m_D3DPP.BackBufferFormat)) zFormat = D3DFMT_D16; - else if (IsDepthFormatOk(D3DFMT_D15S1, m_D3DPP.BackBufferFormat, m_D3DPP.BackBufferFormat)) zFormat = D3DFMT_D15S1; + if (IsDepthFormatOk(D3DFMT_D32, m_D3DPP.BackBufferFormat)) zFormat = D3DFMT_D32; + else if (IsDepthFormatOk(D3DFMT_D24S8, m_D3DPP.BackBufferFormat)) zFormat = D3DFMT_D24S8; + else if (IsDepthFormatOk(D3DFMT_D24X4S4, m_D3DPP.BackBufferFormat)) zFormat = D3DFMT_D24X4S4; + else if (IsDepthFormatOk(D3DFMT_D24X8, m_D3DPP.BackBufferFormat)) zFormat = D3DFMT_D24X8; + else if (IsDepthFormatOk(D3DFMT_D16, m_D3DPP.BackBufferFormat)) zFormat = D3DFMT_D16; + else if (IsDepthFormatOk(D3DFMT_D15S1, m_D3DPP.BackBufferFormat)) zFormat = D3DFMT_D15S1; m_D3DPP.EnableAutoDepthStencil = TRUE; m_D3DPP.AutoDepthStencilFormat = zFormat; @@ -447,15 +454,10 @@ bool CRenderSystemDX::CreateDevice() CLog::Log(LOGDEBUG, __FUNCTION__" - texture caps: 0x%08X", caps.TextureCaps); - if (SUCCEEDED(m_pD3D->CheckDeviceFormat( m_adapter, - m_devType, - m_D3DPP.BackBufferFormat, - m_defaultD3DUsage, - D3DRTYPE_TEXTURE, - D3DFMT_DXT5 ))) - { + if(IsTextureFormatOk(D3DFMT_DXT1, m_defaultD3DUsage) + && IsTextureFormatOk(D3DFMT_DXT3, m_defaultD3DUsage) + && IsTextureFormatOk(D3DFMT_DXT5, m_defaultD3DUsage)) m_renderCaps |= RENDER_CAPS_DXT; - } if ((caps.TextureCaps & D3DPTEXTURECAPS_POW2) == 0) { // we're allowed NPOT textures diff --git a/xbmc/RenderSystemDX.h b/xbmc/RenderSystemDX.h index 33eb1a95dd..d35a77b531 100644 --- a/xbmc/RenderSystemDX.h +++ b/xbmc/RenderSystemDX.h @@ -46,7 +46,8 @@ public: virtual bool PresentRender(); virtual bool ClearBuffers(color_t color); virtual bool IsExtSupported(const char* extension); - virtual bool IsTextureFormatOk(D3DFORMAT DepthFormat, DWORD usage); + virtual bool IsSurfaceFormatOk(D3DFORMAT surfFormat, DWORD usage); + virtual bool IsTextureFormatOk(D3DFORMAT texFormat, DWORD usage); virtual void SetVSync(bool vsync); @@ -103,7 +104,7 @@ protected: void SetRenderParams(unsigned int width, unsigned int height, bool fullScreen, float refreshRate); void BuildPresentParameters(); virtual void UpdateMonitor() {}; - BOOL IsDepthFormatOk(D3DFORMAT DepthFormat, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat); + BOOL IsDepthFormatOk(D3DFORMAT DepthFormat, D3DFORMAT RenderTargetFormat); LPDIRECT3D9 m_pD3D; |