Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 1 | #include "ANGLETest.h" |
| 2 | |
Austin Kinross | 18b931d | 2014-09-29 12:58:31 -0700 | [diff] [blame^] | 3 | // Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against. |
| 4 | typedef ::testing::Types<TFT<Gles::Two, Rend::D3D11>, TFT<Gles::Two, Rend::D3D9>> TestFixtureTypes; |
| 5 | TYPED_TEST_CASE(FramebufferFormatsTest, TestFixtureTypes); |
| 6 | |
| 7 | template<typename T> |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 8 | class FramebufferFormatsTest : public ANGLETest |
| 9 | { |
| 10 | protected: |
Austin Kinross | 18b931d | 2014-09-29 12:58:31 -0700 | [diff] [blame^] | 11 | FramebufferFormatsTest() : ANGLETest(T::GetGlesMajorVersion(), T::GetRequestedRenderer()) |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 12 | { |
| 13 | setWindowWidth(128); |
| 14 | setWindowHeight(128); |
| 15 | setConfigRedBits(8); |
| 16 | setConfigGreenBits(8); |
| 17 | setConfigBlueBits(8); |
| 18 | setConfigAlphaBits(8); |
| 19 | } |
| 20 | |
| 21 | void checkBitCount(GLuint fbo, GLenum channel, GLint minBits) |
| 22 | { |
| 23 | glBindFramebuffer(GL_FRAMEBUFFER, fbo); |
| 24 | |
| 25 | GLint bits = 0; |
| 26 | glGetIntegerv(channel, &bits); |
| 27 | |
| 28 | if (minBits == 0) |
| 29 | { |
| 30 | EXPECT_EQ(minBits, bits); |
| 31 | } |
| 32 | else |
| 33 | { |
| 34 | EXPECT_GE(bits, minBits); |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | void testBitCounts(GLuint fbo, GLint minRedBits, GLint minGreenBits, GLint minBlueBits, |
| 39 | GLint minAlphaBits, GLint minDepthBits, GLint minStencilBits) |
| 40 | { |
| 41 | checkBitCount(fbo, GL_RED_BITS, minRedBits); |
| 42 | checkBitCount(fbo, GL_GREEN_BITS, minGreenBits); |
| 43 | checkBitCount(fbo, GL_BLUE_BITS, minBlueBits); |
| 44 | checkBitCount(fbo, GL_ALPHA_BITS, minAlphaBits); |
| 45 | checkBitCount(fbo, GL_DEPTH_BITS, minDepthBits); |
| 46 | checkBitCount(fbo, GL_STENCIL_BITS, minStencilBits); |
| 47 | } |
| 48 | |
| 49 | void testTextureFormat(GLenum internalFormat, GLint minRedBits, GLint minGreenBits, GLint minBlueBits, |
| 50 | GLint minAlphaBits) |
| 51 | { |
| 52 | GLuint tex = 0; |
| 53 | glGenTextures(1, &tex); |
| 54 | glBindTexture(GL_TEXTURE_2D, tex); |
| 55 | glTexStorage2DEXT(GL_TEXTURE_2D, 1, internalFormat, 1, 1); |
| 56 | |
| 57 | GLuint fbo = 0; |
| 58 | glGenFramebuffers(1, &fbo); |
| 59 | glBindFramebuffer(GL_FRAMEBUFFER, fbo); |
| 60 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, 0); |
| 61 | |
| 62 | testBitCounts(fbo, minRedBits, minGreenBits, minBlueBits, minAlphaBits, 0, 0); |
| 63 | |
| 64 | glDeleteTextures(1, &tex); |
| 65 | glDeleteFramebuffers(1, &fbo); |
| 66 | } |
| 67 | |
| 68 | virtual void SetUp() |
| 69 | { |
| 70 | ANGLETest::SetUp(); |
| 71 | } |
| 72 | |
| 73 | virtual void TearDown() |
| 74 | { |
| 75 | ANGLETest::TearDown(); |
| 76 | } |
| 77 | }; |
| 78 | |
Austin Kinross | 18b931d | 2014-09-29 12:58:31 -0700 | [diff] [blame^] | 79 | TYPED_TEST(FramebufferFormatsTest, RGBA4) |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 80 | { |
| 81 | testTextureFormat(GL_RGBA4, 4, 4, 4, 4); |
| 82 | } |
| 83 | |
Austin Kinross | 18b931d | 2014-09-29 12:58:31 -0700 | [diff] [blame^] | 84 | TYPED_TEST(FramebufferFormatsTest, RGB565) |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 85 | { |
| 86 | testTextureFormat(GL_RGB565, 5, 6, 5, 0); |
| 87 | } |
| 88 | |
Austin Kinross | 18b931d | 2014-09-29 12:58:31 -0700 | [diff] [blame^] | 89 | TYPED_TEST(FramebufferFormatsTest, RGB8) |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 90 | { |
| 91 | testTextureFormat(GL_RGB8_OES, 8, 8, 8, 0); |
| 92 | } |
| 93 | |
Austin Kinross | 18b931d | 2014-09-29 12:58:31 -0700 | [diff] [blame^] | 94 | TYPED_TEST(FramebufferFormatsTest, BGRA8) |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 95 | { |
| 96 | testTextureFormat(GL_BGRA8_EXT, 8, 8, 8, 8); |
| 97 | } |
| 98 | |
Austin Kinross | 18b931d | 2014-09-29 12:58:31 -0700 | [diff] [blame^] | 99 | TYPED_TEST(FramebufferFormatsTest, RGBA8) |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 100 | { |
| 101 | testTextureFormat(GL_RGBA8_OES, 8, 8, 8, 8); |
| 102 | } |
| 103 | |