Commit 0bcb68f3 by Geoff Lang

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/287529Reviewed-by: 's avatarKenneth Russell <kbr@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent d483e422
......@@ -55,6 +55,23 @@ static bool CompatibleTextureTarget(GLenum textureType, GLenum textureTarget)
}
}
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 @@ gl::Error TextureGL::setImage(GLenum target, size_t level, GLenum internalFormat
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 @@ gl::Error TextureGL::setCompressedImage(GLenum target, size_t level, GLenum inte
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 @@ gl::Error TextureGL::setCompressedSubImage(GLenum target, size_t level, const gl
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::setCompressedSubImage(GLenum target, size_t level, const gl
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);
......
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