Index: gpu/command_buffer/tests/gl_cube_map_texture_unittest.cc |
diff --git a/gpu/command_buffer/tests/gl_cube_map_texture_unittest.cc b/gpu/command_buffer/tests/gl_cube_map_texture_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..47509bdf72ce45438586dd794b58f5bbc26a5d30 |
--- /dev/null |
+++ b/gpu/command_buffer/tests/gl_cube_map_texture_unittest.cc |
@@ -0,0 +1,125 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef GL_GLEXT_PROTOTYPES |
+#define GL_GLEXT_PROTOTYPES |
no sievers
2015/08/10 19:34:10
nit: we don't do that elsewhere, it comes in throu
dshwang
2015/08/11 06:28:53
Done.
|
+#endif |
+ |
+#include <GLES2/gl2.h> |
+ |
+#include "gpu/command_buffer/tests/gl_manager.h" |
+#include "gpu/command_buffer/tests/gl_test_utils.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+namespace gpu { |
+ |
+namespace { |
+const GLenum kCubeMapTextureTargets[] = { |
+ GL_TEXTURE_CUBE_MAP_POSITIVE_X, |
+ GL_TEXTURE_CUBE_MAP_NEGATIVE_X, |
+ GL_TEXTURE_CUBE_MAP_POSITIVE_Y, |
+ GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, |
+ GL_TEXTURE_CUBE_MAP_POSITIVE_Z, |
+ GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, |
+}; |
+} // namespace |
+ |
+// A collection of tests that exercise the GL_CHROMIUM_copy_texture extension. |
no sievers
2015/08/10 19:34:10
update comment
dshwang
2015/08/11 06:28:53
Done.
|
+class GLCubeMapTextureTest |
+ : public testing::TestWithParam<GLenum> { |
+ protected: |
+ void SetUp() override { |
+ gl_.Initialize(GLManager::Options()); |
+ } |
+ |
+ void TearDown() override { |
+ gl_.Destroy(); |
+ } |
+ |
+ GLManager gl_; |
+}; |
+ |
+INSTANTIATE_TEST_CASE_P( |
+ GLCubeMapTextureTests, |
+ GLCubeMapTextureTest, |
+ ::testing::ValuesIn(kCubeMapTextureTargets)); |
+ |
+TEST_P(GLCubeMapTextureTest, DISABLED_FramebufferTexture2D) { |
+ GLenum cube_map_target = GetParam(); |
+ uint8 pixels[1 * 4] = { 255u, 0u, 0u, 255u }; |
no sievers
2015/08/10 19:34:10
should we make it slightly more interesting/realis
dshwang
2015/08/11 06:28:53
Done.
|
+ |
+ GLuint texture = 0; |
+ glGenTextures(1, &texture); |
+ |
+ glBindTexture(GL_TEXTURE_CUBE_MAP, texture); |
+ EXPECT_TRUE(glGetError() == GL_NO_ERROR); |
+ |
+ glTexImage2D(cube_map_target, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
+ pixels); |
+ EXPECT_TRUE(glGetError() == GL_NO_ERROR); |
+ |
+ GLuint framebuffer_id = 0; |
+ glGenFramebuffers(1, &framebuffer_id); |
+ glBindFramebuffer(GL_FRAMEBUFFER, framebuffer_id); |
+ glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, cube_map_target, |
+ texture, 0); |
+ // Nexus 5 crashes on this glGetError() except for CUBE_MAP_POSITIVE_X. |
+ EXPECT_TRUE(glGetError() == GL_NO_ERROR); |
+} |
+ |
+TEST_P(GLCubeMapTextureTest, DISABLED_TexImage2DAfterFBOBinding) { |
+ GLenum cube_map_target = GetParam(); |
+ uint8 pixels[1 * 4] = { 255u, 0u, 0u, 255u }; |
+ |
+ GLuint texture = 0; |
+ glGenTextures(1, &texture); |
+ |
+ glBindTexture(GL_TEXTURE_CUBE_MAP, texture); |
+ EXPECT_TRUE(glGetError() == GL_NO_ERROR); |
+ |
+ GLuint framebuffer_id = 0; |
+ glGenFramebuffers(1, &framebuffer_id); |
+ glBindFramebuffer(GL_FRAMEBUFFER, framebuffer_id); |
+ glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, cube_map_target, |
+ texture, 0); |
+ EXPECT_TRUE(glGetError() == GL_NO_ERROR); |
+ |
+ // Nexus 5 crashes on glTexImage2D() except for CUBE_MAP_POSITIVE_X. |
+ glTexImage2D(cube_map_target, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
+ pixels); |
+ EXPECT_TRUE(glGetError() == GL_NO_ERROR); |
+} |
+ |
+TEST_P(GLCubeMapTextureTest, DISABLED_ReadPixels) { |
+ GLenum cube_map_target = GetParam(); |
+ uint8 pixels[1 * 4] = { 255u, 0u, 0u, 255u }; |
+ |
+ GLuint texture = 0; |
+ glGenTextures(1, &texture); |
+ |
+ glBindTexture(GL_TEXTURE_CUBE_MAP, texture); |
+ EXPECT_TRUE(glGetError() == GL_NO_ERROR); |
+ |
+ glTexImage2D(cube_map_target, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
+ pixels); |
+ EXPECT_TRUE(glGetError() == GL_NO_ERROR); |
+ |
+ GLuint framebuffer_id = 0; |
+ glGenFramebuffers(1, &framebuffer_id); |
+ glBindFramebuffer(GL_FRAMEBUFFER, framebuffer_id); |
+ glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, cube_map_target, |
+ texture, 0); |
+ // Nexus 5 crashes on this glGetError() except for CUBE_MAP_POSITIVE_X. |
+ EXPECT_TRUE(glGetError() == GL_NO_ERROR); |
+ |
+ // Check that FB is complete. |
+ EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), |
+ glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
+ |
+ // ANGLE crashes on glReadPixels() except for CUBE_MAP_POSITIVE_X. |
+ GLTestHelper::CheckPixels(0, 0, 1, 1, 0, pixels); |
no sievers
2015/08/10 19:34:10
This seems to be just an extended version of the f
dshwang
2015/08/11 06:28:53
Done.
|
+ EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
+} |
+ |
+} // namespace gpu |