Skip to content
This repository has been archived by the owner on Sep 30, 2018. It is now read-only.

Commit

Permalink
[WIN32] workaround Intel compressed texture issue
Browse files Browse the repository at this point in the history
(cherry picked from commit 00452071d88d55e7a5b77f4d6a739b63dd3b89c9)

git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/branches/Dharma@33672 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
  • Loading branch information
CrystalPT authored and CrystalPT committed Sep 10, 2010
1 parent 466b4eb commit 19987ae
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
16 changes: 9 additions & 7 deletions guilib/Texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,17 @@ void CBaseTexture::Allocate(unsigned int width, unsigned int height, unsigned in
m_format = format;
m_orientation = 0;

m_textureWidth = m_imageWidth;
m_textureHeight = m_imageHeight;

if (m_format & XB_FMT_DXT_MASK)
while (GetPitch() < g_Windowing.GetMinDXTPitch())
m_textureWidth += GetBlockSize();

if (!g_Windowing.SupportsNPOT((m_format & XB_FMT_DXT_MASK) != 0))
{
m_textureWidth = PadPow2(m_imageWidth);
m_textureHeight = PadPow2(m_imageHeight);
}
else
{
m_textureWidth = m_imageWidth;
m_textureHeight = m_imageHeight;
m_textureWidth = PadPow2(m_textureWidth);
m_textureHeight = PadPow2(m_textureHeight);
}
if (m_format & XB_FMT_DXT_MASK)
{ // DXT textures must be a multiple of 4 in width and height
Expand Down
1 change: 1 addition & 0 deletions xbmc/RenderSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ CRenderSystemBase::CRenderSystemBase()
m_RenderVersionMajor = 0;
m_RenderVersionMinor = 0;
m_renderCaps = 0;
m_minDXTPitch = 0;
}

CRenderSystemBase::~CRenderSystemBase()
Expand Down
2 changes: 2 additions & 0 deletions xbmc/RenderSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,14 @@ class CRenderSystemBase
bool SupportsDXT() const;
bool SupportsNPOT(bool dxt) const;
unsigned int GetMaxTextureSize() const { return m_maxTextureSize; }
unsigned int GetMinDXTPitch() const { return m_minDXTPitch; }

protected:
bool m_bRenderCreated;
RenderingSystemType m_enumRenderingSystem;
bool m_bVSync;
unsigned int m_maxTextureSize;
unsigned int m_minDXTPitch;

CStdString m_RenderRenderer;
CStdString m_RenderVendor;
Expand Down
14 changes: 14 additions & 0 deletions xbmc/RenderSystemDX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,20 @@ bool CRenderSystemDX::CreateDevice()
m_renderCaps &= ~RENDER_CAPS_DXT_NPOT;
}

// Intel quirk: DXT texture pitch must be > 64
// when using D3DPOOL_DEFAULT + D3DUSAGE_DYNAMIC textures (no other choice with D3D9Ex)
// DXT1: 32 pixels wide is the largest non-working texture width
// DXT3/5: 16 pixels wide ----------------------------------------
// Both equal to a pitch of 64. So far no Intel has DXT NPOT (including i3/i5/i7, so just go with the next higher POT.
// See ticket #9578
// if(m_defaultD3DUsage == D3DUSAGE_DYNAMIC
// && m_defaultD3DPool == D3DPOOL_DEFAULT
// && AIdentifier.VendorId == 32902)
{
CLog::Log(LOGDEBUG, __FUNCTION__" - Intel workaround - specifying minimum pitch for compressed textures.");
m_minDXTPitch = 128;
}

D3DDISPLAYMODE mode;
if (SUCCEEDED(m_pD3DDevice->GetDisplayMode(0, &mode)))
m_screenHeight = mode.Height;
Expand Down

0 comments on commit 19987ae

Please sign in to comment.