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

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: resolve sievers's comment 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
« no previous file with comments | « gpu/command_buffer/service/texture_manager.cc ('k') | gpu/config/gpu_driver_bug_list_json.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 glGenTextures(1, &texture_);
34 glBindTexture(GL_TEXTURE_CUBE_MAP, texture_);
35 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
36
37 glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
38 glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
39 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
40 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
41 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
42
43 glGenFramebuffers(1, &framebuffer_id_);
44 }
45
46 void TearDown() override {
47 glDeleteTextures(1, &texture_);
48 glDeleteFramebuffers(1, &framebuffer_id_);
49 gl_.Destroy();
50 }
51
52 GLManager gl_;
53 uint8 pixels_[256 * 4];
54 const int width_ = 16;
55 GLuint texture_;
56 GLuint framebuffer_id_;
57 };
58
59 INSTANTIATE_TEST_CASE_P(GLCubeMapTextureTests,
60 GLCubeMapTextureTest,
61 ::testing::ValuesIn(kCubeMapTextureTargets));
62
63 TEST_P(GLCubeMapTextureTest, TexImage2DAfterFBOBinding) {
64 GLenum cube_map_target = GetParam();
65
66 glBindFramebuffer(GL_FRAMEBUFFER, framebuffer_id_);
67 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, cube_map_target,
68 texture_, 0);
69 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
70
71 glBindTexture(GL_TEXTURE_CUBE_MAP, texture_);
72 // force_gl_finish_after_compositing workaround prevents Nexus 5 crash.
73 // TODO(dshwang): remove the workaround when it's fixed. crbug.com/518889
74 glTexImage2D(cube_map_target, 0, GL_RGBA, width_, width_, 0, GL_RGBA,
75 GL_UNSIGNED_BYTE, pixels_);
76 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
77 }
78
79 TEST_P(GLCubeMapTextureTest, ReadPixels) {
80 GLenum cube_map_target = GetParam();
81
82 glBindTexture(GL_TEXTURE_CUBE_MAP, texture_);
83 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
84
85 // Make a cube texture complete
86 for (unsigned i = 0; i < arraysize(kCubeMapTextureTargets); i++) {
87 glTexImage2D(kCubeMapTextureTargets[i], 0, GL_RGBA, width_, width_, 0,
88 GL_RGBA, GL_UNSIGNED_BYTE, pixels_);
89 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
90 }
91
92 glBindFramebuffer(GL_FRAMEBUFFER, framebuffer_id_);
93 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, cube_map_target,
94 texture_, 0);
95 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
96
97 // Check that FB is complete.
98 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
99 glCheckFramebufferStatus(GL_FRAMEBUFFER));
100
101 GLTestHelper::CheckPixels(0, 0, width_, width_, 0, pixels_);
102 EXPECT_TRUE(GL_NO_ERROR == glGetError());
103 }
104
105 #if defined(OS_WIN)
106 // TODO(dshwang): ANGLE crashes. crbug.com/518889
107 TEST_P(GLCubeMapTextureTest, DISABLED_ReadPixelsFromIncompleteFBO) {
108 #else
109 TEST_P(GLCubeMapTextureTest, ReadPixelsFromIncompleteFBO) {
110 #endif
111 GLenum cube_map_target = GetParam();
112
113 glBindTexture(GL_TEXTURE_CUBE_MAP, texture_);
114 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
115
116 glTexImage2D(cube_map_target, 0, GL_RGBA, width_, width_, 0, GL_RGBA,
117 GL_UNSIGNED_BYTE, pixels_);
118 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
119
120 glBindFramebuffer(GL_FRAMEBUFFER, framebuffer_id_);
121 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, cube_map_target,
122 texture_, 0);
123
124 // force_gl_finish_after_compositing workaround prevents Nexus 5 crash.
125 // TODO(dshwang): remove the workaround when it's fixed. crbug.com/518889
126 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
127
128 GLsizei size = width_ * width_ * 4;
129 scoped_ptr<uint8[]> pixels(new uint8[size]);
130 // ANGLE crashes on glReadPixels() from incomplete FBO.
131 glReadPixels(0, 0, width_, width_, GL_RGBA, GL_UNSIGNED_BYTE, pixels.get());
132 // TODO(dshwang): According to spec, above glReadPixels() should fail and
133 // glGetError() should report an error, but some drivers are fine to bind
134 // incomplete cube map texture to FBO. crbug.com/517548
135 glGetError();
136 }
137
138 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/texture_manager.cc ('k') | gpu/config/gpu_driver_bug_list_json.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698