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
diff --git a/src/libGLESv2/renderer/Renderer.h b/src/libGLESv2/renderer/Renderer.h
index d01f38c..3d1bdbc 100644
--- a/src/libGLESv2/renderer/Renderer.h
+++ b/src/libGLESv2/renderer/Renderer.h
@@ -134,6 +134,7 @@
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;
diff --git a/src/libGLESv2/renderer/Renderer11.cpp b/src/libGLESv2/renderer/Renderer11.cpp
index 4c72599..95a3fc4 100644
--- a/src/libGLESv2/renderer/Renderer11.cpp
+++ b/src/libGLESv2/renderer/Renderer11.cpp
@@ -92,6 +92,8 @@
mDriverConstantBufferVS = NULL;
mDriverConstantBufferPS = NULL;
+
+ mBGRATextureSupport = false;
}
Renderer11::~Renderer11()
@@ -228,6 +230,19 @@
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 @@
return foo;
}
+bool Renderer11::getBGRATextureSupport() const
+{
+ return mBGRATextureSupport;
+}
+
bool Renderer11::getDXT1TextureSupport()
{
// TODO
diff --git a/src/libGLESv2/renderer/Renderer11.h b/src/libGLESv2/renderer/Renderer11.h
index 5bab122..33ad4e3 100644
--- a/src/libGLESv2/renderer/Renderer11.h
+++ b/src/libGLESv2/renderer/Renderer11.h
@@ -89,6 +89,7 @@
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 @@
DXGI_ADAPTER_DESC mAdapterDescription;
char mDescription[128];
IDXGIFactory *mDxgiFactory;
+
+ // Cached device caps
+ bool mBGRATextureSupport;
};
}
diff --git a/src/libGLESv2/renderer/Renderer9.cpp b/src/libGLESv2/renderer/Renderer9.cpp
index 460a391..830925b 100644
--- a/src/libGLESv2/renderer/Renderer9.cpp
+++ b/src/libGLESv2/renderer/Renderer9.cpp
@@ -2165,6 +2165,12 @@
}
}
+bool Renderer9::getBGRATextureSupport() const
+{
+ // DirectX 9 always supports BGRA
+ return true;
+}
+
bool Renderer9::getDXT1TextureSupport()
{
return mDXT1TextureSupport;
diff --git a/src/libGLESv2/renderer/Renderer9.h b/src/libGLESv2/renderer/Renderer9.h
index 55f98fc..875c359 100644
--- a/src/libGLESv2/renderer/Renderer9.h
+++ b/src/libGLESv2/renderer/Renderer9.h
@@ -114,6 +114,7 @@
virtual std::string getRendererDescription() const;
virtual GUID getAdapterIdentifier() const;
+ virtual bool getBGRATextureSupport() const;
virtual bool getDXT1TextureSupport();
virtual bool getDXT3TextureSupport();
virtual bool getDXT5TextureSupport();