Home | History | Annotate | Download | only in angle_tests
      1 #include "ANGLETest.h"
      2 
      3 class FramebufferFormatsTest : public ANGLETest
      4 {
      5 protected:
      6     FramebufferFormatsTest()
      7     {
      8         setWindowWidth(128);
      9         setWindowHeight(128);
     10         setConfigRedBits(8);
     11         setConfigGreenBits(8);
     12         setConfigBlueBits(8);
     13         setConfigAlphaBits(8);
     14     }
     15 
     16     void checkBitCount(GLuint fbo, GLenum channel, GLint minBits)
     17     {
     18         glBindFramebuffer(GL_FRAMEBUFFER, fbo);
     19 
     20         GLint bits = 0;
     21         glGetIntegerv(channel, &bits);
     22 
     23         if (minBits == 0)
     24         {
     25             EXPECT_EQ(minBits, bits);
     26         }
     27         else
     28         {
     29             EXPECT_GE(bits, minBits);
     30         }
     31     }
     32 
     33     void testBitCounts(GLuint fbo, GLint minRedBits, GLint minGreenBits, GLint minBlueBits,
     34                        GLint minAlphaBits, GLint minDepthBits, GLint minStencilBits)
     35     {
     36         checkBitCount(fbo, GL_RED_BITS, minRedBits);
     37         checkBitCount(fbo, GL_GREEN_BITS, minGreenBits);
     38         checkBitCount(fbo, GL_BLUE_BITS, minBlueBits);
     39         checkBitCount(fbo, GL_ALPHA_BITS, minAlphaBits);
     40         checkBitCount(fbo, GL_DEPTH_BITS, minDepthBits);
     41         checkBitCount(fbo, GL_STENCIL_BITS, minStencilBits);
     42     }
     43 
     44     void testTextureFormat(GLenum internalFormat, GLint minRedBits, GLint minGreenBits, GLint minBlueBits,
     45                            GLint minAlphaBits)
     46     {
     47         GLuint tex = 0;
     48         glGenTextures(1, &tex);
     49         glBindTexture(GL_TEXTURE_2D, tex);
     50         glTexStorage2DEXT(GL_TEXTURE_2D, 1, internalFormat, 1, 1);
     51 
     52         GLuint fbo = 0;
     53         glGenFramebuffers(1, &fbo);
     54         glBindFramebuffer(GL_FRAMEBUFFER, fbo);
     55         glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, 0);
     56 
     57         testBitCounts(fbo, minRedBits, minGreenBits, minBlueBits, minAlphaBits, 0, 0);
     58 
     59         glDeleteTextures(1, &tex);
     60         glDeleteFramebuffers(1, &fbo);
     61     }
     62 
     63     virtual void SetUp()
     64     {
     65         ANGLETest::SetUp();
     66     }
     67 
     68     virtual void TearDown()
     69     {
     70         ANGLETest::TearDown();
     71     }
     72 };
     73 
     74 TEST_F(FramebufferFormatsTest, RGBA4)
     75 {
     76     testTextureFormat(GL_RGBA4, 4, 4, 4, 4);
     77 }
     78 
     79 TEST_F(FramebufferFormatsTest, RGB565)
     80 {
     81     testTextureFormat(GL_RGB565, 5, 6, 5, 0);
     82 }
     83 
     84 TEST_F(FramebufferFormatsTest, RGB8)
     85 {
     86     testTextureFormat(GL_RGB8_OES, 8, 8, 8, 0);
     87 }
     88 
     89 TEST_F(FramebufferFormatsTest, BGRA8)
     90 {
     91     testTextureFormat(GL_BGRA8_EXT, 8, 8, 8, 8);
     92 }
     93 
     94 TEST_F(FramebufferFormatsTest, RGBA8)
     95 {
     96     testTextureFormat(GL_RGBA8_OES, 8, 8, 8, 8);
     97 }
     98 
     99