Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(409)

Side by Side Diff: gpu/command_buffer/tests/gl_cube_map_texture_unittest.cc

Issue 1280163004: gpu: workaround force_cube_map_positive_x_allocation fixes Android crash. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix bug about cube incomplete fbo Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <GLES2/gl2.h>
6
7 #include "gpu/command_buffer/tests/gl_manager.h"
8 #include "gpu/command_buffer/tests/gl_test_utils.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 namespace gpu {
12
13 namespace {
14 const GLenum kCubeMapTextureTargets[] = {
15 GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
16 GL_TEXTURE_CUBE_MAP_POSITIVE_Y, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
17 GL_TEXTURE_CUBE_MAP_POSITIVE_Z, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z,
18 };
19 } // namespace
20
21 // A collection of tests that exercise the cube map texture.
22 class GLCubeMapTextureTest : public testing::TestWithParam<GLenum> {
23 protected:
24 void SetUp() override {
25 gl_.Initialize(GLManager::Options());
26 for (int i = 0; i < 256; i++) {
27 pixels_[i * 4] = 255u;
28 pixels_[(i * 4) + 1] = 0;
29 pixels_[(i * 4) + 2] = 0;
30 pixels_[(i * 4) + 3] = 255u;
31 }
32 }
33
34 void TearDown() override { gl_.Destroy(); }
35
36 uint8 pixels_[256 * 4];
37 const int width_ = 16;
38 GLManager gl_;
39 };
40
41 INSTANTIATE_TEST_CASE_P(GLCubeMapTextureTests,
42 GLCubeMapTextureTest,
43 ::testing::ValuesIn(kCubeMapTextureTargets));
44
45 TEST_P(GLCubeMapTextureTest, FramebufferTexture2DToIncompleteCubeTexture) {
46 GLenum cube_map_target = GetParam();
47
48 GLuint texture = 0;
49 glGenTextures(1, &texture);
50
51 glBindTexture(GL_TEXTURE_CUBE_MAP, texture);
52 EXPECT_TRUE(glGetError() == GL_NO_ERROR);
53
54 glTexImage2D(cube_map_target, 0, GL_RGBA, width_, width_, 0, GL_RGBA,
55 GL_UNSIGNED_BYTE, pixels_);
56 EXPECT_TRUE(glGetError() == GL_NO_ERROR);
57
58 GLuint framebuffer_id = 0;
59 glGenFramebuffers(1, &framebuffer_id);
60 glBindFramebuffer(GL_FRAMEBUFFER, framebuffer_id);
61 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, cube_map_target,
62 texture, 0);
63
64 // force_gl_finish_after_compositing workaround prevents Nexus 5 crash.
65 // TODO(dshwang): remove the workaround when it's fixed. crbug.com/518889
66 EXPECT_TRUE(glGetError() == GL_NO_ERROR);
67 }
68
69 TEST_P(GLCubeMapTextureTest, TexImage2DAfterFBOBinding) {
70 GLenum cube_map_target = GetParam();
71
72 GLuint texture = 0;
73 glGenTextures(1, &texture);
74
75 glBindTexture(GL_TEXTURE_CUBE_MAP, texture);
76 EXPECT_TRUE(glGetError() == GL_NO_ERROR);
77
78 GLuint framebuffer_id = 0;
79 glGenFramebuffers(1, &framebuffer_id);
80 glBindFramebuffer(GL_FRAMEBUFFER, framebuffer_id);
81 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, cube_map_target,
82 texture, 0);
83 EXPECT_TRUE(glGetError() == GL_NO_ERROR);
84
85 // force_gl_finish_after_compositing workaround prevents Nexus 5 crash.
86 // TODO(dshwang): remove the workaround when it's fixed. crbug.com/518889
87 glTexImage2D(cube_map_target, 0, GL_RGBA, width_, width_, 0, GL_RGBA,
88 GL_UNSIGNED_BYTE, pixels_);
89 EXPECT_TRUE(glGetError() == GL_NO_ERROR);
90 }
91
92 TEST_P(GLCubeMapTextureTest, ReadPixels) {
93 GLenum cube_map_target = GetParam();
94
95 GLuint texture = 0;
96 glGenTextures(1, &texture);
97
98 glBindTexture(GL_TEXTURE_CUBE_MAP, texture);
99 EXPECT_TRUE(glGetError() == GL_NO_ERROR);
100
101 // Make a cube texture complete
102 for (unsigned i = 0; i < arraysize(kCubeMapTextureTargets); i++) {
103 glTexImage2D(kCubeMapTextureTargets[i], 0, GL_RGBA, width_, width_, 0,
104 GL_RGBA, GL_UNSIGNED_BYTE, pixels_);
105 EXPECT_TRUE(glGetError() == GL_NO_ERROR);
106 }
107
108 GLuint framebuffer_id = 0;
109 glGenFramebuffers(1, &framebuffer_id);
110 glBindFramebuffer(GL_FRAMEBUFFER, framebuffer_id);
111 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, cube_map_target,
112 texture, 0);
113 EXPECT_TRUE(glGetError() == GL_NO_ERROR);
114
115 // Check that FB is complete.
116 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
no sievers 2015/08/11 21:08:54 what about mipmaps? don't you have to set the filt
dshwang 2015/08/12 08:06:09 good point! I add filter setup in SetUp()
117 glCheckFramebufferStatus(GL_FRAMEBUFFER));
118
119 // ANGLE crashes on glReadPixels() except for CUBE_MAP_POSITIVE_X.
120 GLTestHelper::CheckPixels(0, 0, width_, width_, 0, pixels_);
121 EXPECT_TRUE(GL_NO_ERROR == glGetError());
122 }
123
124 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698