3 class DepthStencilFormatsTest : public ANGLETest
6 DepthStencilFormatsTest()
11 setConfigGreenBits(8);
13 setConfigAlphaBits(8);
17 bool checkTexImageFormatSupport(GLenum format, GLenum type)
22 glGenTextures(1, &tex);
23 glBindTexture(GL_TEXTURE_2D, tex);
24 glTexImage2D(GL_TEXTURE_2D, 0, format, 1, 1, 0, format, type, NULL);
25 glDeleteTextures(1, &tex);
27 return (glGetError() == GL_NO_ERROR);
30 bool checkTexStorageFormatSupport(GLenum internalFormat)
35 glGenTextures(1, &tex);
36 glBindTexture(GL_TEXTURE_2D, tex);
37 glTexStorage2DEXT(GL_TEXTURE_2D, 1, internalFormat, 1, 1);
38 glDeleteTextures(1, &tex);
40 return (glGetError() == GL_NO_ERROR);
43 bool checkRenderbufferFormatSupport(GLenum internalFormat)
48 glGenRenderbuffers(1, &rb);
49 glBindRenderbuffer(GL_RENDERBUFFER, rb);
50 glRenderbufferStorage(GL_RENDERBUFFER, internalFormat, 1, 1);
51 glDeleteRenderbuffers(1, &rb);
53 return (glGetError() == GL_NO_ERROR);
61 virtual void TearDown()
63 ANGLETest::TearDown();
67 TEST_F(DepthStencilFormatsTest, DepthTexture)
69 bool shouldHaveTextureSupport = extensionEnabled("GL_ANGLE_depth_texture");
70 EXPECT_EQ(shouldHaveTextureSupport, checkTexImageFormatSupport(GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT));
71 EXPECT_EQ(shouldHaveTextureSupport, checkTexImageFormatSupport(GL_DEPTH_COMPONENT, GL_UNSIGNED_INT));
73 if (extensionEnabled("GL_EXT_texture_storage"))
75 EXPECT_EQ(shouldHaveTextureSupport, checkTexStorageFormatSupport(GL_DEPTH_COMPONENT16));
76 EXPECT_EQ(shouldHaveTextureSupport, checkTexStorageFormatSupport(GL_DEPTH_COMPONENT32_OES));
80 TEST_F(DepthStencilFormatsTest, PackedDepthStencil)
82 // Expected to fail in D3D9 if GL_OES_packed_depth_stencil is not present.
83 // Expected to fail in D3D11 if GL_OES_packed_depth_stencil or GL_ANGLE_depth_texture is not present.
85 bool shouldHaveRenderbufferSupport = extensionEnabled("GL_OES_packed_depth_stencil");
86 EXPECT_EQ(shouldHaveRenderbufferSupport, checkRenderbufferFormatSupport(GL_DEPTH24_STENCIL8_OES));
88 bool shouldHaveTextureSupport = extensionEnabled("GL_OES_packed_depth_stencil") &&
89 extensionEnabled("GL_ANGLE_depth_texture");
90 EXPECT_EQ(shouldHaveTextureSupport, checkTexImageFormatSupport(GL_DEPTH_STENCIL_OES, GL_UNSIGNED_INT_24_8_OES));
92 if (extensionEnabled("GL_EXT_texture_storage"))
94 EXPECT_EQ(shouldHaveTextureSupport, checkTexStorageFormatSupport(GL_DEPTH24_STENCIL8_OES));