Always use sized internal formats for textures in TextureGL.
On desktop GL, using an internal format of GL_RGBA produces GL_RGBA8
textures even if format is set to GL_FLOAT. Use sized internal formats
whenever possible to ensure that the internal format of the texture is
the expected format.
Fixes:
* conformance/extensions/oes-texture-float-with-image-data.htm
* conformance/extensions/oes-texture-float-with-image.html
* conformance/extensions/oes-texture-float.html
* conformance/extensions/oes-texture-half-float-linear.html
* conformance/extensions/oes-texture-half-float-with-image-data.html
* conformance/extensions/oes-texture-half-float-with-image.html
* conformance/extensions/oes-texture-half-float.html
BUG=angleproject:884
Change-Id: I227e782fe9aae7b2e66df67c7a4519cfc79890b9
Reviewed-on: https://chromium-review.googlesource.com/287529
Reviewed-by: Kenneth Russell <kbr@chromium.org>
Tested-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/libANGLE/renderer/gl/TextureGL.cpp b/src/libANGLE/renderer/gl/TextureGL.cpp
index 70392a7..1dc73d4 100644
--- a/src/libANGLE/renderer/gl/TextureGL.cpp
+++ b/src/libANGLE/renderer/gl/TextureGL.cpp
@@ -55,6 +55,23 @@
}
}
+static const nativegl::InternalFormat &GetNativeInternalFormat(const FunctionsGL *functions,
+ GLenum internalFormat,
+ GLenum type)
+{
+ if (functions->standard == STANDARD_GL_DESKTOP || functions->isAtLeastGLES(gl::Version(3, 0)))
+ {
+ // On Desktop GL, always use sized internal formats. Passing an internal format of
+ // GL_RGBA will generate a GL_RGBA8 texture even if the provided type is GL_FLOAT.
+ GLenum sizedFormat = gl::GetSizedInternalFormat(internalFormat, type);
+ return nativegl::GetInternalFormatInfo(sizedFormat, functions->standard);
+ }
+ else
+ {
+ return nativegl::GetInternalFormatInfo(internalFormat, functions->standard);
+ }
+}
+
TextureGL::TextureGL(GLenum type, const FunctionsGL *functions, StateManagerGL *stateManager)
: TextureImpl(),
mTextureType(type),
@@ -90,7 +107,8 @@
SetUnpackStateForTexImage(mStateManager, unpack);
- const nativegl::InternalFormat &nativeInternalFormatInfo = nativegl::GetInternalFormatInfo(internalFormat, mFunctions->standard);
+ const nativegl::InternalFormat &nativeInternalFormatInfo =
+ GetNativeInternalFormat(mFunctions, internalFormat, type);
mStateManager->bindTexture(mTextureType, mTextureID);
if (UseTexImage2D(mTextureType))
@@ -143,7 +161,8 @@
SetUnpackStateForTexImage(mStateManager, unpack);
- const nativegl::InternalFormat &nativeInternalFormatInfo = nativegl::GetInternalFormatInfo(internalFormat, mFunctions->standard);
+ const nativegl::InternalFormat &nativeInternalFormatInfo =
+ GetNativeInternalFormat(mFunctions, internalFormat, GL_UNSIGNED_BYTE);
mStateManager->bindTexture(mTextureType, mTextureID);
if (UseTexImage2D(mTextureType))
@@ -171,19 +190,17 @@
SetUnpackStateForTexImage(mStateManager, unpack);
- const nativegl::InternalFormat &nativeInternalFormatInfo = nativegl::GetInternalFormatInfo(format, mFunctions->standard);
-
mStateManager->bindTexture(mTextureType, mTextureID);
if (UseTexImage2D(mTextureType))
{
ASSERT(area.z == 0 && area.depth == 1);
- mFunctions->compressedTexSubImage2D(target, level, area.x, area.y, area.width, area.height, nativeInternalFormatInfo.internalFormat, imageSize,
- pixels);
+ mFunctions->compressedTexSubImage2D(target, level, area.x, area.y, area.width, area.height,
+ format, imageSize, pixels);
}
else if (UseTexImage3D(mTextureType))
{
- mFunctions->compressedTexSubImage3D(target, level, area.x, area.y, area.z, area.width, area.height, area.depth,
- nativeInternalFormatInfo.internalFormat, imageSize, pixels);
+ mFunctions->compressedTexSubImage3D(target, level, area.x, area.y, area.z, area.width,
+ area.height, area.depth, format, imageSize, pixels);
}
else
{
@@ -196,7 +213,8 @@
gl::Error TextureGL::copyImage(GLenum target, size_t level, const gl::Rectangle &sourceArea, GLenum internalFormat,
const gl::Framebuffer *source)
{
- const nativegl::InternalFormat &nativeInternalFormatInfo = nativegl::GetInternalFormatInfo(internalFormat, mFunctions->standard);
+ const nativegl::InternalFormat &nativeInternalFormatInfo = GetNativeInternalFormat(
+ mFunctions, internalFormat, source->getImplementationColorReadType());
const FramebufferGL *sourceFramebufferGL = GetImplAs<FramebufferGL>(source);