Commit b6a673a0 by Geoff Lang

Report zero bit sizes for channels that shouldn't exist.

If the actual format has more channels than the internal format of a framebuffer, bits counts greater than zero will be returned for channels that should not exist. While it is not against the spec to return more bits than exist in the format, it can be confusing for users or break tests. get*Bits will now only return greater than zero bit counts when the format should have the given channel. Since this is the only location that we return information about the "real" internal format we're using, it's safe to only make the modifications here. BUG=angle:653 Change-Id: I43ef4c6290c8c70737d579d7e9a2dd30d653330b Reviewed-on: https://chromium-review.googlesource.com/202594Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 80ebce59
...@@ -422,32 +422,74 @@ GLenum FramebufferAttachment::getActualFormat() const ...@@ -422,32 +422,74 @@ GLenum FramebufferAttachment::getActualFormat() const
GLuint FramebufferAttachment::getRedSize() const GLuint FramebufferAttachment::getRedSize() const
{ {
return gl::GetRedBits(getActualFormat(), mRenderer->getCurrentClientVersion()); if (gl::GetRedBits(getInternalFormat(), mRenderer->getCurrentClientVersion()) > 0)
{
return gl::GetRedBits(getActualFormat(), mRenderer->getCurrentClientVersion());
}
else
{
return 0;
}
} }
GLuint FramebufferAttachment::getGreenSize() const GLuint FramebufferAttachment::getGreenSize() const
{ {
return gl::GetGreenBits(getActualFormat(), mRenderer->getCurrentClientVersion()); if (gl::GetGreenBits(getInternalFormat(), mRenderer->getCurrentClientVersion()) > 0)
{
return gl::GetGreenBits(getActualFormat(), mRenderer->getCurrentClientVersion());
}
else
{
return 0;
}
} }
GLuint FramebufferAttachment::getBlueSize() const GLuint FramebufferAttachment::getBlueSize() const
{ {
return gl::GetBlueBits(getActualFormat(), mRenderer->getCurrentClientVersion()); if (gl::GetBlueBits(getInternalFormat(), mRenderer->getCurrentClientVersion()) > 0)
{
return gl::GetBlueBits(getActualFormat(), mRenderer->getCurrentClientVersion());
}
else
{
return 0;
}
} }
GLuint FramebufferAttachment::getAlphaSize() const GLuint FramebufferAttachment::getAlphaSize() const
{ {
return gl::GetAlphaBits(getActualFormat(), mRenderer->getCurrentClientVersion()); if (gl::GetAlphaBits(getInternalFormat(), mRenderer->getCurrentClientVersion()) > 0)
{
return gl::GetAlphaBits(getActualFormat(), mRenderer->getCurrentClientVersion());
}
else
{
return 0;
}
} }
GLuint FramebufferAttachment::getDepthSize() const GLuint FramebufferAttachment::getDepthSize() const
{ {
return gl::GetDepthBits(getActualFormat(), mRenderer->getCurrentClientVersion()); if (gl::GetDepthBits(getInternalFormat(), mRenderer->getCurrentClientVersion()) > 0)
{
return gl::GetDepthBits(getActualFormat(), mRenderer->getCurrentClientVersion());
}
else
{
return 0;
}
} }
GLuint FramebufferAttachment::getStencilSize() const GLuint FramebufferAttachment::getStencilSize() const
{ {
return gl::GetStencilBits(getActualFormat(), mRenderer->getCurrentClientVersion()); if (gl::GetStencilBits(getInternalFormat(), mRenderer->getCurrentClientVersion()) > 0)
{
return gl::GetStencilBits(getActualFormat(), mRenderer->getCurrentClientVersion());
}
else
{
return 0;
}
} }
GLenum FramebufferAttachment::getComponentType() const GLenum FramebufferAttachment::getComponentType() const
......
#include "ANGLETest.h"
class FramebufferFormatsTest : public ANGLETest
{
protected:
FramebufferFormatsTest()
{
setWindowWidth(128);
setWindowHeight(128);
setConfigRedBits(8);
setConfigGreenBits(8);
setConfigBlueBits(8);
setConfigAlphaBits(8);
}
void checkBitCount(GLuint fbo, GLenum channel, GLint minBits)
{
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
GLint bits = 0;
glGetIntegerv(channel, &bits);
if (minBits == 0)
{
EXPECT_EQ(minBits, bits);
}
else
{
EXPECT_GE(bits, minBits);
}
}
void testBitCounts(GLuint fbo, GLint minRedBits, GLint minGreenBits, GLint minBlueBits,
GLint minAlphaBits, GLint minDepthBits, GLint minStencilBits)
{
checkBitCount(fbo, GL_RED_BITS, minRedBits);
checkBitCount(fbo, GL_GREEN_BITS, minGreenBits);
checkBitCount(fbo, GL_BLUE_BITS, minBlueBits);
checkBitCount(fbo, GL_ALPHA_BITS, minAlphaBits);
checkBitCount(fbo, GL_DEPTH_BITS, minDepthBits);
checkBitCount(fbo, GL_STENCIL_BITS, minStencilBits);
}
void testTextureFormat(GLenum internalFormat, GLint minRedBits, GLint minGreenBits, GLint minBlueBits,
GLint minAlphaBits)
{
GLuint tex = 0;
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D, tex);
glTexStorage2DEXT(GL_TEXTURE_2D, 1, internalFormat, 1, 1);
GLuint fbo = 0;
glGenFramebuffers(1, &fbo);
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, 0);
testBitCounts(fbo, minRedBits, minGreenBits, minBlueBits, minAlphaBits, 0, 0);
glDeleteTextures(1, &tex);
glDeleteFramebuffers(1, &fbo);
}
virtual void SetUp()
{
ANGLETest::SetUp();
}
virtual void TearDown()
{
ANGLETest::TearDown();
}
};
TEST_F(FramebufferFormatsTest, rgba4)
{
testTextureFormat(GL_RGBA4, 4, 4, 4, 4);
}
TEST_F(FramebufferFormatsTest, rgb565)
{
testTextureFormat(GL_RGB565, 5, 6, 5, 0);
}
TEST_F(FramebufferFormatsTest, rgb8)
{
testTextureFormat(GL_RGB8_OES, 8, 8, 8, 0);
}
TEST_F(FramebufferFormatsTest, bgra8)
{
testTextureFormat(GL_BGRA8_EXT, 8, 8, 8, 8);
}
TEST_F(FramebufferFormatsTest, rgba8)
{
testTextureFormat(GL_RGBA8_OES, 8, 8, 8, 8);
}
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