Implement proper BGRA extension support on D3D11.

See GL_EXT_texture_format_BGRA8888. TRAC #22410 Signed-off-by: Geoff Lang Signed-off-by: Daniel Koch Author: Jamie Madill git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1771 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 0b7f7cfb
......@@ -169,6 +169,7 @@ Context::Context(const gl::Context *shareContext, rx::Renderer *renderer, bool n
mResetStrategy = (notifyResets ? GL_LOSE_CONTEXT_ON_RESET_EXT : GL_NO_RESET_NOTIFICATION_EXT);
mRobustAccess = robustAccess;
mSupportsBGRATextures = false;
mSupportsDXT1Textures = false;
mSupportsDXT3Textures = false;
mSupportsDXT5Textures = false;
......@@ -259,6 +260,7 @@ void Context::makeCurrent(egl::Surface *surface)
mSupportsEventQueries = mRenderer->getEventQuerySupport();
mSupportsOcclusionQueries = mRenderer->getOcclusionQuerySupport();
mSupportsBGRATextures = mRenderer->getBGRATextureSupport();
mSupportsDXT1Textures = mRenderer->getDXT1TextureSupport();
mSupportsDXT3Textures = mRenderer->getDXT3TextureSupport();
mSupportsDXT5Textures = mRenderer->getDXT5TextureSupport();
......@@ -2154,6 +2156,11 @@ bool Context::supportsOcclusionQueries() const
return mSupportsOcclusionQueries;
}
bool Context::supportsBGRATextures() const
{
return mSupportsBGRATextures;
}
bool Context::supportsDXT1Textures() const
{
return mSupportsDXT1Textures;
......@@ -2543,7 +2550,11 @@ void Context::initExtensionString()
extensionString += "GL_EXT_texture_filter_anisotropic ";
}
extensionString += "GL_EXT_texture_format_BGRA8888 ";
if (supportsBGRATextures())
{
extensionString += "GL_EXT_texture_format_BGRA8888 ";
}
extensionString += "GL_EXT_texture_storage ";
// ANGLE-specific extensions
......
......@@ -392,6 +392,7 @@ class Context
const char *getRendererString() const;
bool supportsEventQueries() const;
bool supportsOcclusionQueries() const;
bool supportsBGRATextures() const;
bool supportsDXT1Textures() const;
bool supportsDXT3Textures() const;
bool supportsDXT5Textures() const;
......@@ -500,6 +501,7 @@ class Context
float mMaxTextureAnisotropy;
bool mSupportsEventQueries;
bool mSupportsOcclusionQueries;
bool mSupportsBGRATextures;
bool mSupportsDXT1Textures;
bool mSupportsDXT3Textures;
bool mSupportsDXT5Textures;
......
......@@ -134,6 +134,7 @@ class Renderer
virtual std::string getRendererDescription() const = 0;
virtual GUID getAdapterIdentifier() const = 0;
virtual bool getBGRATextureSupport() const = 0;
virtual bool getDXT1TextureSupport() = 0;
virtual bool getDXT3TextureSupport() = 0;
virtual bool getDXT5TextureSupport() = 0;
......
......@@ -92,6 +92,8 @@ Renderer11::Renderer11(egl::Display *display, HDC hDc) : Renderer(display), mDc(
mDriverConstantBufferVS = NULL;
mDriverConstantBufferPS = NULL;
mBGRATextureSupport = false;
}
Renderer11::~Renderer11()
......@@ -228,6 +230,19 @@ EGLint Renderer11::initialize()
initializeDevice();
// BGRA texture support is optional in feature levels 10 and 10_1
UINT formatSupport;
result = mDevice->CheckFormatSupport(DXGI_FORMAT_B8G8R8A8_UNORM, &formatSupport);
if (FAILED(result))
{
ERR("Error checking BGRA format support: 0x%08X", result);
}
else
{
const int flags = (D3D11_FORMAT_SUPPORT_TEXTURE2D | D3D11_FORMAT_SUPPORT_RENDER_TARGET);
mBGRATextureSupport = (formatSupport & flags) == flags;
}
return EGL_SUCCESS;
}
......@@ -1752,6 +1767,11 @@ GUID Renderer11::getAdapterIdentifier() const
return foo;
}
bool Renderer11::getBGRATextureSupport() const
{
return mBGRATextureSupport;
}
bool Renderer11::getDXT1TextureSupport()
{
// TODO
......
......@@ -89,6 +89,7 @@ class Renderer11 : public Renderer
virtual std::string getRendererDescription() const;
virtual GUID getAdapterIdentifier() const;
virtual bool getBGRATextureSupport() const;
virtual bool getDXT1TextureSupport();
virtual bool getDXT3TextureSupport();
virtual bool getDXT5TextureSupport();
......@@ -280,6 +281,9 @@ class Renderer11 : public Renderer
DXGI_ADAPTER_DESC mAdapterDescription;
char mDescription[128];
IDXGIFactory *mDxgiFactory;
// Cached device caps
bool mBGRATextureSupport;
};
}
......
......@@ -2165,6 +2165,12 @@ void Renderer9::getMultiSampleSupport(D3DFORMAT format, bool *multiSampleArray)
}
}
bool Renderer9::getBGRATextureSupport() const
{
// DirectX 9 always supports BGRA
return true;
}
bool Renderer9::getDXT1TextureSupport()
{
return mDXT1TextureSupport;
......
......@@ -114,6 +114,7 @@ class Renderer9 : public Renderer
virtual std::string getRendererDescription() const;
virtual GUID getAdapterIdentifier() const;
virtual bool getBGRATextureSupport() const;
virtual bool getDXT1TextureSupport();
virtual bool getDXT3TextureSupport();
virtual bool getDXT5TextureSupport();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment