blob: b3f31a4b800b1cf573a1e684aaf3045eb64b82d7 [file] [log] [blame]
Geoff Langb6a673a2014-06-05 14:19:16 -04001#include "ANGLETest.h"
2
Austin Kinross18b931d2014-09-29 12:58:31 -07003// Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against.
4typedef ::testing::Types<TFT<Gles::Two, Rend::D3D11>, TFT<Gles::Two, Rend::D3D9>> TestFixtureTypes;
5TYPED_TEST_CASE(FramebufferFormatsTest, TestFixtureTypes);
6
7template<typename T>
Geoff Langb6a673a2014-06-05 14:19:16 -04008class FramebufferFormatsTest : public ANGLETest
9{
10protected:
Austin Kinross18b931d2014-09-29 12:58:31 -070011 FramebufferFormatsTest() : ANGLETest(T::GetGlesMajorVersion(), T::GetRequestedRenderer())
Geoff Langb6a673a2014-06-05 14:19:16 -040012 {
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 Kinross18b931d2014-09-29 12:58:31 -070079TYPED_TEST(FramebufferFormatsTest, RGBA4)
Geoff Langb6a673a2014-06-05 14:19:16 -040080{
81 testTextureFormat(GL_RGBA4, 4, 4, 4, 4);
82}
83
Austin Kinross18b931d2014-09-29 12:58:31 -070084TYPED_TEST(FramebufferFormatsTest, RGB565)
Geoff Langb6a673a2014-06-05 14:19:16 -040085{
86 testTextureFormat(GL_RGB565, 5, 6, 5, 0);
87}
88
Austin Kinross18b931d2014-09-29 12:58:31 -070089TYPED_TEST(FramebufferFormatsTest, RGB8)
Geoff Langb6a673a2014-06-05 14:19:16 -040090{
91 testTextureFormat(GL_RGB8_OES, 8, 8, 8, 0);
92}
93
Austin Kinross18b931d2014-09-29 12:58:31 -070094TYPED_TEST(FramebufferFormatsTest, BGRA8)
Geoff Langb6a673a2014-06-05 14:19:16 -040095{
96 testTextureFormat(GL_BGRA8_EXT, 8, 8, 8, 8);
97}
98
Austin Kinross18b931d2014-09-29 12:58:31 -070099TYPED_TEST(FramebufferFormatsTest, RGBA8)
Geoff Langb6a673a2014-06-05 14:19:16 -0400100{
101 testTextureFormat(GL_RGBA8_OES, 8, 8, 8, 8);
102}
103