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

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

Issue 1304103005: Revert of gpu: support GL_TEXTURE_CUBE_MAP destination target to Copy(Sub)TextureCHROMIUM. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 3 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/gles2_cmd_decoder.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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef GL_GLEXT_PROTOTYPES 5 #ifndef GL_GLEXT_PROTOTYPES
6 #define GL_GLEXT_PROTOTYPES 6 #define GL_GLEXT_PROTOTYPES
7 #endif 7 #endif
8 8
9 #include <GLES2/gl2.h> 9 #include <GLES2/gl2.h>
10 #include <GLES2/gl2ext.h> 10 #include <GLES2/gl2ext.h>
11 #include <GLES2/gl2extchromium.h> 11 #include <GLES2/gl2extchromium.h>
12 12
13 #include "base/command_line.h"
14 #include "base/strings/string_number_conversions.h"
15 #include "gpu/command_buffer/tests/gl_manager.h" 13 #include "gpu/command_buffer/tests/gl_manager.h"
16 #include "gpu/command_buffer/tests/gl_test_utils.h" 14 #include "gpu/command_buffer/tests/gl_test_utils.h"
17 #include "gpu/config/gpu_switches.h"
18 #include "testing/gmock/include/gmock/gmock.h" 15 #include "testing/gmock/include/gmock/gmock.h"
19 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
20 17
21 namespace gpu { 18 namespace gpu {
22 19
23 namespace { 20 namespace {
24 enum CopyType { TexImage, TexSubImage }; 21 enum CopyType { TexImage, TexSubImage };
25 const CopyType kCopyTypes[] = { 22 const CopyType kCopyTypes[] = {
26 TexImage, 23 TexImage,
27 TexSubImage, 24 TexSubImage,
28 }; 25 };
29 26 }
30 const GLenum kDestinationFaces[] = {
31 GL_TEXTURE_2D,
32 GL_TEXTURE_CUBE_MAP_POSITIVE_X,
33 #if !defined(OS_ANDROID)
34 // linux_android_rel_ng crashs on glReadPixels()
35 // TODO(dshwang): exclude them for only Nvidia. crbug.com/527126
36 // TODO(dshwang): handle Nvidia. crbug.com/528145
37 GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
38 GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
39 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
40 GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
41 GL_TEXTURE_CUBE_MAP_NEGATIVE_Z,
42 #endif
43 };
44 } // namespace
45 27
46 // A collection of tests that exercise the GL_CHROMIUM_copy_texture extension. 28 // A collection of tests that exercise the GL_CHROMIUM_copy_texture extension.
47 class GLCopyTextureCHROMIUMTest 29 class GLCopyTextureCHROMIUMTest
48 : public testing::TestWithParam<::testing::tuple<CopyType, GLenum>> { 30 : public testing::Test,
31 public ::testing::WithParamInterface<CopyType> {
49 protected: 32 protected:
50 void SetUp() override { 33 void SetUp() override {
51 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); 34 gl_.Initialize(GLManager::Options());
52 // ANGLE and Nvidia fails without this workaround. crbug.com/518889
53 command_line.AppendSwitchASCII(switches::kGpuDriverBugWorkarounds,
54 base::IntToString(gpu::FORCE_CUBE_COMPLETE));
55 gl_.InitializeWithCommandLine(GLManager::Options(), &command_line);
56 DCHECK(gl_.workarounds().force_cube_complete);
57 35
58 // textures_[0] is source texture and textures_[1] is destination texture.
59 glGenTextures(2, textures_); 36 glGenTextures(2, textures_);
60 37 glBindTexture(GL_TEXTURE_2D, textures_[1]);
61 GLenum dest_target = ::testing::get<1>(GetParam());
62 GLenum binding_target =
63 gpu::gles2::GLES2Util::GLTextureTargetToBindingTarget(dest_target);
64
65 glBindTexture(binding_target, textures_[1]);
66 38
67 // Some drivers (NVidia/SGX) require texture settings to be a certain way or 39 // Some drivers (NVidia/SGX) require texture settings to be a certain way or
68 // they won't report FRAMEBUFFER_COMPLETE. 40 // they won't report FRAMEBUFFER_COMPLETE.
69 glTexParameterf(binding_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 41 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
70 glTexParameterf(binding_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 42 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
71 glTexParameteri(binding_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 43 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
72 glTexParameteri(binding_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 44 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
73 45
74 glGenFramebuffers(1, &framebuffer_id_); 46 glGenFramebuffers(1, &framebuffer_id_);
75 glBindFramebuffer(GL_FRAMEBUFFER, framebuffer_id_); 47 glBindFramebuffer(GL_FRAMEBUFFER, framebuffer_id_);
76 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, dest_target, 48 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
77 textures_[1], 0); 49 textures_[1], 0);
78 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
79 } 50 }
80 51
81 void TearDown() override { 52 void TearDown() override {
82 glDeleteTextures(2, textures_); 53 glDeleteTextures(2, textures_);
83 glDeleteFramebuffers(1, &framebuffer_id_); 54 glDeleteFramebuffers(1, &framebuffer_id_);
84 gl_.Destroy(); 55 gl_.Destroy();
85 } 56 }
86 57
87 // Some drivers(Nvidia) require cube complete to do glReadPixels from the FBO.
88 // TODO(dshwang): handle Nvidia. crbug.com/528145
89 void MakeCubeComplete(GLenum target,
90 GLint internalformat,
91 GLenum type,
92 GLsizei width,
93 GLsizei height) {
94 // Make the textures cube complete to bind it to FBO
95 GLenum binding_target =
96 gpu::gles2::GLES2Util::GLTextureTargetToBindingTarget(target);
97 if (binding_target == GL_TEXTURE_CUBE_MAP) {
98 glBindTexture(binding_target, textures_[1]);
99 for (unsigned i = 0; i < 6; i++) {
100 if (target == GL_TEXTURE_CUBE_MAP_POSITIVE_X + i)
101 continue;
102 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, internalformat,
103 width, height, 0, internalformat, type, nullptr);
104 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
105 }
106 }
107 }
108
109 GLManager gl_; 58 GLManager gl_;
110 GLuint textures_[2]; 59 GLuint textures_[2];
111 GLuint framebuffer_id_; 60 GLuint framebuffer_id_;
112 }; 61 };
113 62
114 INSTANTIATE_TEST_CASE_P( 63 INSTANTIATE_TEST_CASE_P(CopyType,
115 GLCopyTextureCHROMIUMTests, 64 GLCopyTextureCHROMIUMTest,
116 GLCopyTextureCHROMIUMTest, 65 ::testing::ValuesIn(kCopyTypes));
117 ::testing::Combine(::testing::ValuesIn(kCopyTypes),
118 ::testing::ValuesIn(kDestinationFaces)));
119 66
120 // Test to ensure that the basic functionality of the extension works. 67 // Test to ensure that the basic functionality of the extension works.
121 TEST_P(GLCopyTextureCHROMIUMTest, Basic) { 68 TEST_P(GLCopyTextureCHROMIUMTest, Basic) {
122 CopyType copy_type = ::testing::get<0>(GetParam()); 69 CopyType copy_type = GetParam();
123 GLenum dest_target = ::testing::get<1>(GetParam());
124 GLenum binding_target =
125 gpu::gles2::GLES2Util::GLTextureTargetToBindingTarget(dest_target);
126 uint8 pixels[1 * 4] = { 255u, 0u, 0u, 255u }; 70 uint8 pixels[1 * 4] = { 255u, 0u, 0u, 255u };
127 71
128 glBindTexture(GL_TEXTURE_2D, textures_[0]); 72 glBindTexture(GL_TEXTURE_2D, textures_[0]);
129 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 73 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
130 pixels); 74 pixels);
131 75
132 if (copy_type == TexImage) { 76 if (copy_type == TexImage) {
133 glCopyTextureCHROMIUM(dest_target, textures_[0], textures_[1], GL_RGBA, 77 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA,
134 GL_UNSIGNED_BYTE, false, false, false); 78 GL_UNSIGNED_BYTE, false, false, false);
135 } else { 79 } else {
136 glBindTexture(binding_target, textures_[1]); 80 glBindTexture(GL_TEXTURE_2D, textures_[1]);
137 glTexImage2D(dest_target, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 81 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
138 nullptr); 82 nullptr);
139 83
140 glCopySubTextureCHROMIUM(dest_target, textures_[0], textures_[1], 0, 0, 0, 84 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0, 0,
141 0, 1, 1, false, false, false); 85 0, 1, 1, false, false, false);
142 } 86 }
143 EXPECT_TRUE(glGetError() == GL_NO_ERROR); 87 EXPECT_TRUE(glGetError() == GL_NO_ERROR);
144 88
145 MakeCubeComplete(dest_target, GL_RGBA, GL_UNSIGNED_BYTE, 1, 1);
146
147 // Check the FB is still bound. 89 // Check the FB is still bound.
148 GLint value = 0; 90 GLint value = 0;
149 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value); 91 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value);
150 GLuint fb_id = value; 92 GLuint fb_id = value;
151 EXPECT_EQ(framebuffer_id_, fb_id); 93 EXPECT_EQ(framebuffer_id_, fb_id);
152 94
153 // Check that FB is complete. 95 // Check that FB is complete.
154 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), 96 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
155 glCheckFramebufferStatus(GL_FRAMEBUFFER)); 97 glCheckFramebufferStatus(GL_FRAMEBUFFER));
156 98
157 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, pixels); 99 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, pixels);
158 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 100 EXPECT_TRUE(GL_NO_ERROR == glGetError());
159 } 101 }
160 102
161 TEST_P(GLCopyTextureCHROMIUMTest, ImmutableTexture) { 103 TEST_P(GLCopyTextureCHROMIUMTest, ImmutableTexture) {
162 if (!GLTestHelper::HasExtension("GL_EXT_texture_storage")) { 104 if (!GLTestHelper::HasExtension("GL_EXT_texture_storage")) {
163 LOG(INFO) << "GL_EXT_texture_storage not supported. Skipping test..."; 105 LOG(INFO) << "GL_EXT_texture_storage not supported. Skipping test...";
164 return; 106 return;
165 } 107 }
166 108 CopyType copy_type = GetParam();
167 CopyType copy_type = ::testing::get<0>(GetParam());
168 GLenum dest_target = ::testing::get<1>(GetParam());
169 GLenum binding_target =
170 gpu::gles2::GLES2Util::GLTextureTargetToBindingTarget(dest_target);
171 109
172 uint8 pixels[1 * 4] = {255u, 0u, 0u, 255u}; 110 uint8 pixels[1 * 4] = {255u, 0u, 0u, 255u};
173 111
174 glBindTexture(GL_TEXTURE_2D, textures_[0]); 112 glBindTexture(GL_TEXTURE_2D, textures_[0]);
175 glTexStorage2DEXT(GL_TEXTURE_2D, 1, GL_RGBA8_OES, 1, 1); 113 glTexStorage2DEXT(GL_TEXTURE_2D, 1, GL_RGBA8_OES, 1, 1);
176 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, 114 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE,
177 pixels); 115 pixels);
178 116
179 glBindTexture(binding_target, textures_[1]); 117 glBindTexture(GL_TEXTURE_2D, textures_[1]);
180 glTexStorage2DEXT(binding_target, 1, GL_RGBA8_OES, 1, 1); 118 glTexStorage2DEXT(GL_TEXTURE_2D, 1, GL_RGBA8_OES, 1, 1);
181 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, dest_target, 119 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
182 textures_[1], 0); 120 textures_[1], 0);
183 EXPECT_TRUE(glGetError() == GL_NO_ERROR); 121 EXPECT_TRUE(glGetError() == GL_NO_ERROR);
184 122
185 if (copy_type == TexImage) { 123 if (copy_type == TexImage) {
186 glCopyTextureCHROMIUM(dest_target, textures_[0], textures_[1], GL_RGBA, 124 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA,
187 GL_UNSIGNED_BYTE, false, false, false); 125 GL_UNSIGNED_BYTE, false, false, false);
188 EXPECT_TRUE(glGetError() == GL_INVALID_OPERATION); 126 EXPECT_TRUE(glGetError() == GL_INVALID_OPERATION);
189 } else { 127 } else {
190 glCopySubTextureCHROMIUM(dest_target, textures_[0], textures_[1], 0, 0, 0, 128 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0, 0,
191 0, 1, 1, false, false, false); 129 0, 1, 1, false, false, false);
192 EXPECT_TRUE(glGetError() == GL_NO_ERROR); 130 EXPECT_TRUE(glGetError() == GL_NO_ERROR);
193 131
194 // Similar quirk to MakeCubeComplete() for immutable texture.
195 if (binding_target == GL_TEXTURE_CUBE_MAP) {
196 for (unsigned i = 0; i < 6; i++) {
197 if (dest_target == GL_TEXTURE_CUBE_MAP_POSITIVE_X + i)
198 continue;
199 glCopySubTextureCHROMIUM(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i,
200 textures_[0], textures_[1], 0, 0, 0, 0, 1, 1,
201 false, false, false);
202 }
203 }
204 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
205
206 // Check the FB is still bound. 132 // Check the FB is still bound.
207 GLint value = 0; 133 GLint value = 0;
208 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value); 134 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value);
209 GLuint fb_id = value; 135 GLuint fb_id = value;
210 EXPECT_EQ(framebuffer_id_, fb_id); 136 EXPECT_EQ(framebuffer_id_, fb_id);
211 137
212 // Check that FB is complete. 138 // Check that FB is complete.
213 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), 139 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
214 glCheckFramebufferStatus(GL_FRAMEBUFFER)); 140 glCheckFramebufferStatus(GL_FRAMEBUFFER));
215 141
216 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, pixels); 142 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, pixels);
217 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 143 EXPECT_TRUE(GL_NO_ERROR == glGetError());
218 } 144 }
219 } 145 }
220 146
221 TEST_P(GLCopyTextureCHROMIUMTest, InternalFormat) { 147 TEST_P(GLCopyTextureCHROMIUMTest, InternalFormat) {
222 CopyType copy_type = ::testing::get<0>(GetParam()); 148 CopyType copy_type = GetParam();
223 GLenum dest_target = ::testing::get<1>(GetParam());
224 GLenum binding_target =
225 gpu::gles2::GLES2Util::GLTextureTargetToBindingTarget(dest_target);
226
227 GLint src_formats[] = {GL_ALPHA, GL_RGB, GL_RGBA, 149 GLint src_formats[] = {GL_ALPHA, GL_RGB, GL_RGBA,
228 GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_BGRA_EXT}; 150 GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_BGRA_EXT};
229 GLint dest_formats[] = {GL_RGB, GL_RGBA}; 151 GLint dest_formats[] = {GL_RGB, GL_RGBA};
230 152
231 for (size_t src_index = 0; src_index < arraysize(src_formats); src_index++) { 153 for (size_t src_index = 0; src_index < arraysize(src_formats); src_index++) {
232 for (size_t dest_index = 0; dest_index < arraysize(dest_formats); 154 for (size_t dest_index = 0; dest_index < arraysize(dest_formats);
233 dest_index++) { 155 dest_index++) {
234 glBindTexture(GL_TEXTURE_2D, textures_[0]); 156 glBindTexture(GL_TEXTURE_2D, textures_[0]);
235 glTexImage2D(GL_TEXTURE_2D, 0, src_formats[src_index], 1, 1, 0, 157 glTexImage2D(GL_TEXTURE_2D, 0, src_formats[src_index], 1, 1, 0,
236 src_formats[src_index], GL_UNSIGNED_BYTE, nullptr); 158 src_formats[src_index], GL_UNSIGNED_BYTE, nullptr);
237 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 159 EXPECT_TRUE(GL_NO_ERROR == glGetError());
238 160
239 if (copy_type == TexImage) { 161 if (copy_type == TexImage) {
240 glCopyTextureCHROMIUM(dest_target, textures_[0], textures_[1], 162 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1],
241 dest_formats[dest_index], GL_UNSIGNED_BYTE, false, 163 dest_formats[dest_index], GL_UNSIGNED_BYTE,
242 false, false); 164 false, false, false);
243 } else { 165 } else {
244 glBindTexture(binding_target, textures_[1]); 166 glBindTexture(GL_TEXTURE_2D, textures_[1]);
245 glTexImage2D(dest_target, 0, dest_formats[dest_index], 1, 1, 0, 167 glTexImage2D(GL_TEXTURE_2D, 0, dest_formats[dest_index], 1, 1, 0,
246 dest_formats[dest_index], GL_UNSIGNED_BYTE, nullptr); 168 dest_formats[dest_index], GL_UNSIGNED_BYTE, nullptr);
247 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 169 EXPECT_TRUE(GL_NO_ERROR == glGetError());
248 170
249 glCopySubTextureCHROMIUM(dest_target, textures_[0], textures_[1], 0, 0, 171 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0,
250 0, 0, 1, 1, false, false, false); 172 0, 0, 0, 1, 1, false, false, false);
251 } 173 }
252 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()) 174
253 << "src_index:" << src_index << " dest_index:" << dest_index; 175 EXPECT_TRUE(GL_NO_ERROR == glGetError()) << "src_index:" << src_index
176 << " dest_index:" << dest_index;
254 } 177 }
255 } 178 }
256 } 179 }
257 180
258 TEST_P(GLCopyTextureCHROMIUMTest, InternalFormatNotSupported) { 181 TEST_P(GLCopyTextureCHROMIUMTest, InternalFormatNotSupported) {
259 CopyType copy_type = ::testing::get<0>(GetParam()); 182 CopyType copy_type = GetParam();
260 GLenum dest_target = ::testing::get<1>(GetParam());
261 GLenum binding_target =
262 gpu::gles2::GLES2Util::GLTextureTargetToBindingTarget(dest_target);
263 glBindTexture(GL_TEXTURE_2D, textures_[0]); 183 glBindTexture(GL_TEXTURE_2D, textures_[0]);
264 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 184 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
265 nullptr); 185 nullptr);
266 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 186 EXPECT_TRUE(GL_NO_ERROR == glGetError());
267 187
268 // Check unsupported format reports error. 188 // Check unsupported format reports error.
269 GLint unsupported_dest_formats[] = {GL_ALPHA, GL_LUMINANCE, 189 GLint unsupported_dest_formats[] = {GL_ALPHA, GL_LUMINANCE,
270 GL_LUMINANCE_ALPHA}; 190 GL_LUMINANCE_ALPHA};
271 for (size_t dest_index = 0; dest_index < arraysize(unsupported_dest_formats); 191 for (size_t dest_index = 0; dest_index < arraysize(unsupported_dest_formats);
272 dest_index++) { 192 dest_index++) {
273 if (copy_type == TexImage) { 193 if (copy_type == TexImage) {
274 glCopyTextureCHROMIUM(dest_target, textures_[0], textures_[1], 194 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1],
275 unsupported_dest_formats[dest_index], 195 unsupported_dest_formats[dest_index],
276 GL_UNSIGNED_BYTE, false, false, false); 196 GL_UNSIGNED_BYTE, false, false, false);
277 } else { 197 } else {
278 glBindTexture(binding_target, textures_[1]); 198 glBindTexture(GL_TEXTURE_2D, textures_[1]);
279 glTexImage2D(dest_target, 0, unsupported_dest_formats[dest_index], 1, 1, 199 glTexImage2D(GL_TEXTURE_2D, 0, unsupported_dest_formats[dest_index], 1, 1,
280 0, unsupported_dest_formats[dest_index], GL_UNSIGNED_BYTE, 200 0, unsupported_dest_formats[dest_index], GL_UNSIGNED_BYTE,
281 nullptr); 201 nullptr);
282 glCopySubTextureCHROMIUM(dest_target, textures_[0], textures_[1], 0, 0, 0, 202 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0,
283 0, 1, 1, false, false, false); 203 0, 0, 1, 1, false, false, false);
284 } 204 }
285 EXPECT_TRUE(GL_INVALID_OPERATION == glGetError()) 205 EXPECT_TRUE(GL_INVALID_OPERATION == glGetError())
286 << "dest_index:" << dest_index; 206 << "dest_index:" << dest_index;
287 } 207 }
288 } 208 }
289 209
290 // Test to ensure that the destination texture is redefined if the properties 210 // Test to ensure that the destination texture is redefined if the properties
291 // are different. 211 // are different.
292 TEST_P(GLCopyTextureCHROMIUMTest, RedefineDestinationTexture) { 212 TEST_F(GLCopyTextureCHROMIUMTest, RedefineDestinationTexture) {
293 GLenum dest_target = ::testing::get<1>(GetParam());
294 GLenum binding_target =
295 gpu::gles2::GLES2Util::GLTextureTargetToBindingTarget(dest_target);
296 uint8 pixels[4 * 4] = {255u, 0u, 0u, 255u, 255u, 0u, 0u, 255u, 213 uint8 pixels[4 * 4] = {255u, 0u, 0u, 255u, 255u, 0u, 0u, 255u,
297 255u, 0u, 0u, 255u, 255u, 0u, 0u, 255u}; 214 255u, 0u, 0u, 255u, 255u, 0u, 0u, 255u};
298 215
299 glBindTexture(GL_TEXTURE_2D, textures_[0]); 216 glBindTexture(GL_TEXTURE_2D, textures_[0]);
300 glTexImage2D( 217 glTexImage2D(
301 GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels); 218 GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
302 219
303 glBindTexture(binding_target, textures_[1]); 220 glBindTexture(GL_TEXTURE_2D, textures_[1]);
304 glTexImage2D(dest_target, 0, GL_BGRA_EXT, 1, 1, 0, GL_BGRA_EXT, 221 glTexImage2D(GL_TEXTURE_2D,
305 GL_UNSIGNED_BYTE, pixels); 222 0,
223 GL_BGRA_EXT,
224 1,
225 1,
226 0,
227 GL_BGRA_EXT,
228 GL_UNSIGNED_BYTE,
229 pixels);
306 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 230 EXPECT_TRUE(GL_NO_ERROR == glGetError());
307 231
308 // GL_INVALID_OPERATION due to "intrinsic format" != "internal format". 232 // GL_INVALID_OPERATION due to "intrinsic format" != "internal format".
309 glTexSubImage2D(dest_target, 0, 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, 233 glTexSubImage2D(
310 pixels); 234 GL_TEXTURE_2D, 0, 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
311 EXPECT_TRUE(GL_INVALID_OPERATION == glGetError()); 235 EXPECT_TRUE(GL_INVALID_OPERATION == glGetError());
312 // GL_INVALID_VALUE due to bad dimensions. 236 // GL_INVALID_VALUE due to bad dimensions.
313 glTexSubImage2D(dest_target, 0, 1, 1, 1, 1, GL_BGRA_EXT, GL_UNSIGNED_BYTE, 237 glTexSubImage2D(
314 pixels); 238 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_BGRA_EXT, GL_UNSIGNED_BYTE, pixels);
315 EXPECT_TRUE(GL_INVALID_VALUE == glGetError()); 239 EXPECT_TRUE(GL_INVALID_VALUE == glGetError());
316 240
317 // If the dest texture has different properties, glCopyTextureCHROMIUM() 241 // If the dest texture has different properties, glCopyTextureCHROMIUM()
318 // redefines them. 242 // redefines them.
319 glCopyTextureCHROMIUM(dest_target, textures_[0], textures_[1], GL_RGBA, 243 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA,
320 GL_UNSIGNED_BYTE, false, false, false); 244 GL_UNSIGNED_BYTE, false, false, false);
321 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 245 EXPECT_TRUE(GL_NO_ERROR == glGetError());
322 246
323 // glTexSubImage2D() succeeds because textures_[1] is redefined into 2x2 247 // glTexSubImage2D() succeeds because textures_[1] is redefined into 2x2
324 // dimension and GL_RGBA format. 248 // dimension and GL_RGBA format.
325 glBindTexture(binding_target, textures_[1]); 249 glBindTexture(GL_TEXTURE_2D, textures_[1]);
326 glTexSubImage2D(dest_target, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, 250 glTexSubImage2D(
327 pixels); 251 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
328 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 252 EXPECT_TRUE(GL_NO_ERROR == glGetError());
329 253
330 MakeCubeComplete(dest_target, GL_RGBA, GL_UNSIGNED_BYTE, 2, 2);
331
332 // Check the FB is still bound. 254 // Check the FB is still bound.
333 GLint value = 0; 255 GLint value = 0;
334 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value); 256 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value);
335 GLuint fb_id = value; 257 GLuint fb_id = value;
336 EXPECT_EQ(framebuffer_id_, fb_id); 258 EXPECT_EQ(framebuffer_id_, fb_id);
337 259
338 // Check that FB is complete. 260 // Check that FB is complete.
339 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), 261 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
340 glCheckFramebufferStatus(GL_FRAMEBUFFER)); 262 glCheckFramebufferStatus(GL_FRAMEBUFFER));
341 263
342 #if defined(OS_MACOSX) || defined(OS_WIN)
343 // Despite of "MakeCubeComplete()" quirk, glReadPixels still fails on
344 // mac_chromium_rel_ng and win_chromium_rel_ng.
345 // TODO(dshwang): exclude it for only Nvidia. crbug.com/527126
346 GLsizei size = 2 * 2 * 4;
347 scoped_ptr<uint8[]> read_pixels(new uint8[size]);
348 glReadPixels(0, 0, 2, 2, GL_RGBA, GL_UNSIGNED_BYTE, read_pixels.get());
349 #else
350 GLTestHelper::CheckPixels(1, 1, 1, 1, 0, &pixels[12]); 264 GLTestHelper::CheckPixels(1, 1, 1, 1, 0, &pixels[12]);
351 #endif
352 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 265 EXPECT_TRUE(GL_NO_ERROR == glGetError());
353 } 266 }
354 267
355 namespace { 268 namespace {
356 269
357 void glEnableDisable(GLint param, GLboolean value) { 270 void glEnableDisable(GLint param, GLboolean value) {
358 if (value) 271 if (value)
359 glEnable(param); 272 glEnable(param);
360 else 273 else
361 glDisable(param); 274 glDisable(param);
362 } 275 }
363 276
364 } // unnamed namespace 277 } // unnamed namespace
365 278
366 // Validate that some basic GL state is not touched upon execution of 279 // Validate that some basic GL state is not touched upon execution of
367 // the extension. 280 // the extension.
368 TEST_P(GLCopyTextureCHROMIUMTest, BasicStatePreservation) { 281 TEST_P(GLCopyTextureCHROMIUMTest, BasicStatePreservation) {
369 CopyType copy_type = ::testing::get<0>(GetParam()); 282 CopyType copy_type = GetParam();
370 GLenum dest_target = ::testing::get<1>(GetParam());
371 GLenum binding_target =
372 gpu::gles2::GLES2Util::GLTextureTargetToBindingTarget(dest_target);
373 uint8 pixels[1 * 4] = { 255u, 0u, 0u, 255u }; 283 uint8 pixels[1 * 4] = { 255u, 0u, 0u, 255u };
374 284
375 glBindFramebuffer(GL_FRAMEBUFFER, 0); 285 glBindFramebuffer(GL_FRAMEBUFFER, 0);
376 286
377 glBindTexture(GL_TEXTURE_2D, textures_[0]); 287 glBindTexture(GL_TEXTURE_2D, textures_[0]);
378 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 288 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
379 pixels); 289 pixels);
380 290
381 if (copy_type == TexSubImage) { 291 if (copy_type == TexSubImage) {
382 glBindTexture(binding_target, textures_[1]); 292 glBindTexture(GL_TEXTURE_2D, textures_[1]);
383 glTexImage2D(dest_target, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 293 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
384 nullptr); 294 nullptr);
385 } 295 }
386 296
387 GLboolean reference_settings[2] = { GL_TRUE, GL_FALSE }; 297 GLboolean reference_settings[2] = { GL_TRUE, GL_FALSE };
388 for (int x = 0; x < 2; ++x) { 298 for (int x = 0; x < 2; ++x) {
389 GLboolean setting = reference_settings[x]; 299 GLboolean setting = reference_settings[x];
390 glEnableDisable(GL_DEPTH_TEST, setting); 300 glEnableDisable(GL_DEPTH_TEST, setting);
391 glEnableDisable(GL_SCISSOR_TEST, setting); 301 glEnableDisable(GL_SCISSOR_TEST, setting);
392 glEnableDisable(GL_STENCIL_TEST, setting); 302 glEnableDisable(GL_STENCIL_TEST, setting);
393 glEnableDisable(GL_CULL_FACE, setting); 303 glEnableDisable(GL_CULL_FACE, setting);
394 glEnableDisable(GL_BLEND, setting); 304 glEnableDisable(GL_BLEND, setting);
395 glColorMask(setting, setting, setting, setting); 305 glColorMask(setting, setting, setting, setting);
396 glDepthMask(setting); 306 glDepthMask(setting);
397 307
398 glActiveTexture(GL_TEXTURE1 + x); 308 glActiveTexture(GL_TEXTURE1 + x);
399 309
400 if (copy_type == TexImage) { 310 if (copy_type == TexImage) {
401 glCopyTextureCHROMIUM(dest_target, textures_[0], textures_[1], GL_RGBA, 311 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA,
402 GL_UNSIGNED_BYTE, false, false, false); 312 GL_UNSIGNED_BYTE, false, false, false);
403 } else { 313 } else {
404 glCopySubTextureCHROMIUM(dest_target, textures_[0], textures_[1], 0, 0, 0, 314 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0,
405 0, 1, 1, false, false, false); 315 0, 0, 1, 1, false, false, false);
406 } 316 }
407 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 317 EXPECT_TRUE(GL_NO_ERROR == glGetError());
408 318
409 EXPECT_EQ(setting, glIsEnabled(GL_DEPTH_TEST)); 319 EXPECT_EQ(setting, glIsEnabled(GL_DEPTH_TEST));
410 EXPECT_EQ(setting, glIsEnabled(GL_SCISSOR_TEST)); 320 EXPECT_EQ(setting, glIsEnabled(GL_SCISSOR_TEST));
411 EXPECT_EQ(setting, glIsEnabled(GL_STENCIL_TEST)); 321 EXPECT_EQ(setting, glIsEnabled(GL_STENCIL_TEST));
412 EXPECT_EQ(setting, glIsEnabled(GL_CULL_FACE)); 322 EXPECT_EQ(setting, glIsEnabled(GL_CULL_FACE));
413 EXPECT_EQ(setting, glIsEnabled(GL_BLEND)); 323 EXPECT_EQ(setting, glIsEnabled(GL_BLEND));
414 324
415 GLboolean bool_array[4] = { GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE }; 325 GLboolean bool_array[4] = { GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE };
(...skipping 11 matching lines...) Expand all
427 glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture); 337 glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture);
428 EXPECT_EQ(GL_TEXTURE1 + x, active_texture); 338 EXPECT_EQ(GL_TEXTURE1 + x, active_texture);
429 } 339 }
430 340
431 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 341 EXPECT_TRUE(GL_NO_ERROR == glGetError());
432 }; 342 };
433 343
434 // Verify that invocation of the extension does not modify the bound 344 // Verify that invocation of the extension does not modify the bound
435 // texture state. 345 // texture state.
436 TEST_P(GLCopyTextureCHROMIUMTest, TextureStatePreserved) { 346 TEST_P(GLCopyTextureCHROMIUMTest, TextureStatePreserved) {
437 CopyType copy_type = ::testing::get<0>(GetParam()); 347 CopyType copy_type = GetParam();
438 GLenum dest_target = ::testing::get<1>(GetParam());
439 GLenum binding_target =
440 gpu::gles2::GLES2Util::GLTextureTargetToBindingTarget(dest_target);
441 GLenum get_binding_target = binding_target == GL_TEXTURE_2D
442 ? GL_TEXTURE_BINDING_2D
443 : GL_TEXTURE_BINDING_CUBE_MAP;
444 // Setup the texture used for the extension invocation. 348 // Setup the texture used for the extension invocation.
445 uint8 pixels[1 * 4] = { 255u, 0u, 0u, 255u }; 349 uint8 pixels[1 * 4] = { 255u, 0u, 0u, 255u };
446 glBindTexture(GL_TEXTURE_2D, textures_[0]); 350 glBindTexture(GL_TEXTURE_2D, textures_[0]);
447 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 351 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
448 pixels); 352 pixels);
449 353
450 if (copy_type == TexSubImage) { 354 if (copy_type == TexSubImage) {
451 glBindTexture(binding_target, textures_[1]); 355 glBindTexture(GL_TEXTURE_2D, textures_[1]);
452 glTexImage2D(dest_target, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 356 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
453 nullptr); 357 nullptr);
454 } 358 }
455 359
456 GLuint texture_ids[2]; 360 GLuint texture_ids[2];
457 glGenTextures(2, texture_ids); 361 glGenTextures(2, texture_ids);
458 362
459 glActiveTexture(GL_TEXTURE0); 363 glActiveTexture(GL_TEXTURE0);
460 glBindTexture(GL_TEXTURE_2D, texture_ids[0]); 364 glBindTexture(GL_TEXTURE_2D, texture_ids[0]);
461 365
462 glActiveTexture(GL_TEXTURE1); 366 glActiveTexture(GL_TEXTURE1);
463 glBindTexture(binding_target, texture_ids[1]); 367 glBindTexture(GL_TEXTURE_2D, texture_ids[1]);
464 368
465 if (copy_type == TexImage) { 369 if (copy_type == TexImage) {
466 glCopyTextureCHROMIUM(dest_target, textures_[0], textures_[1], GL_RGBA, 370 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA,
467 GL_UNSIGNED_BYTE, false, false, false); 371 GL_UNSIGNED_BYTE, false, false, false);
468 } else { 372 } else {
469 glCopySubTextureCHROMIUM(dest_target, textures_[0], textures_[1], 0, 0, 0, 373 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0, 0,
470 0, 1, 1, false, false, false); 374 0, 1, 1, false, false, false);
471 } 375 }
472 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 376 EXPECT_TRUE(GL_NO_ERROR == glGetError());
473 377
474 GLint active_texture = 0; 378 GLint active_texture = 0;
475 glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture); 379 glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture);
476 EXPECT_EQ(GL_TEXTURE1, active_texture); 380 EXPECT_EQ(GL_TEXTURE1, active_texture);
477 381
478 GLint bound_texture = 0; 382 GLint bound_texture = 0;
479 glGetIntegerv(get_binding_target, &bound_texture); 383 glGetIntegerv(GL_TEXTURE_BINDING_2D, &bound_texture);
480 EXPECT_EQ(texture_ids[1], static_cast<GLuint>(bound_texture)); 384 EXPECT_EQ(texture_ids[1], static_cast<GLuint>(bound_texture));
481 glBindTexture(binding_target, 0); 385 glBindTexture(GL_TEXTURE_2D, 0);
482 386
483 bound_texture = 0; 387 bound_texture = 0;
484 glActiveTexture(GL_TEXTURE0); 388 glActiveTexture(GL_TEXTURE0);
485 glGetIntegerv(GL_TEXTURE_BINDING_2D, &bound_texture); 389 glGetIntegerv(GL_TEXTURE_BINDING_2D, &bound_texture);
486 EXPECT_EQ(texture_ids[0], static_cast<GLuint>(bound_texture)); 390 EXPECT_EQ(texture_ids[0], static_cast<GLuint>(bound_texture));
487 glBindTexture(GL_TEXTURE_2D, 0); 391 glBindTexture(GL_TEXTURE_2D, 0);
488 392
489 glDeleteTextures(2, texture_ids); 393 glDeleteTextures(2, texture_ids);
490 394
491 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 395 EXPECT_TRUE(GL_NO_ERROR == glGetError());
492 } 396 }
493 397
494 // Verify that invocation of the extension does not perturb the currently 398 // Verify that invocation of the extension does not perturb the currently
495 // bound FBO state. 399 // bound FBO state.
496 TEST_P(GLCopyTextureCHROMIUMTest, FBOStatePreserved) { 400 TEST_P(GLCopyTextureCHROMIUMTest, FBOStatePreserved) {
497 CopyType copy_type = ::testing::get<0>(GetParam()); 401 CopyType copy_type = GetParam();
498 GLenum dest_target = ::testing::get<1>(GetParam());
499 GLenum binding_target =
500 gpu::gles2::GLES2Util::GLTextureTargetToBindingTarget(dest_target);
501 // Setup the texture used for the extension invocation. 402 // Setup the texture used for the extension invocation.
502 uint8 pixels[1 * 4] = { 255u, 0u, 0u, 255u }; 403 uint8 pixels[1 * 4] = { 255u, 0u, 0u, 255u };
503 glBindTexture(GL_TEXTURE_2D, textures_[0]); 404 glBindTexture(GL_TEXTURE_2D, textures_[0]);
504 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 405 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
505 pixels); 406 pixels);
506 407
507 if (copy_type == TexSubImage) { 408 if (copy_type == TexSubImage) {
508 glBindTexture(binding_target, textures_[1]); 409 glBindTexture(GL_TEXTURE_2D, textures_[1]);
509 glTexImage2D(dest_target, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 410 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
510 nullptr); 411 nullptr);
511 } 412 }
512 413
513 GLuint texture_id; 414 GLuint texture_id;
514 glGenTextures(1, &texture_id); 415 glGenTextures(1, &texture_id);
515 glBindTexture(GL_TEXTURE_2D, texture_id); 416 glBindTexture(GL_TEXTURE_2D, texture_id);
516 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 417 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
517 0); 418 0);
518 419
519 GLuint renderbuffer_id; 420 GLuint renderbuffer_id;
(...skipping 11 matching lines...) Expand all
531 EXPECT_TRUE( 432 EXPECT_TRUE(
532 GL_FRAMEBUFFER_COMPLETE == glCheckFramebufferStatus(GL_FRAMEBUFFER)); 433 GL_FRAMEBUFFER_COMPLETE == glCheckFramebufferStatus(GL_FRAMEBUFFER));
533 434
534 // Test that we can write to the bound framebuffer 435 // Test that we can write to the bound framebuffer
535 uint8 expected_color[4] = { 255u, 255u, 0, 255u }; 436 uint8 expected_color[4] = { 255u, 255u, 0, 255u };
536 glClearColor(1.0, 1.0, 0, 1.0); 437 glClearColor(1.0, 1.0, 0, 1.0);
537 glClear(GL_COLOR_BUFFER_BIT); 438 glClear(GL_COLOR_BUFFER_BIT);
538 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected_color); 439 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected_color);
539 440
540 if (copy_type == TexImage) { 441 if (copy_type == TexImage) {
541 glCopyTextureCHROMIUM(dest_target, textures_[0], textures_[1], GL_RGBA, 442 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA,
542 GL_UNSIGNED_BYTE, false, false, false); 443 GL_UNSIGNED_BYTE, false, false, false);
543 } else { 444 } else {
544 glCopySubTextureCHROMIUM(dest_target, textures_[0], textures_[1], 0, 0, 0, 445 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0, 0,
545 0, 1, 1, false, false, false); 446 0, 1, 1, false, false, false);
546 } 447 }
547 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 448 EXPECT_TRUE(GL_NO_ERROR == glGetError());
548 449
549 MakeCubeComplete(dest_target, GL_RGBA, GL_UNSIGNED_BYTE, 1, 1);
550
551 EXPECT_TRUE(glIsFramebuffer(framebuffer_id)); 450 EXPECT_TRUE(glIsFramebuffer(framebuffer_id));
552 451
553 // Ensure that reading from the framebuffer produces correct pixels. 452 // Ensure that reading from the framebuffer produces correct pixels.
554 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected_color); 453 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected_color);
555 454
556 uint8 expected_color2[4] = { 255u, 0, 255u, 255u }; 455 uint8 expected_color2[4] = { 255u, 0, 255u, 255u };
557 glClearColor(1.0, 0, 1.0, 1.0); 456 glClearColor(1.0, 0, 1.0, 1.0);
558 glClear(GL_COLOR_BUFFER_BIT); 457 glClear(GL_COLOR_BUFFER_BIT);
559 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected_color2); 458 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected_color2);
560 459
(...skipping 26 matching lines...) Expand all
587 EXPECT_EQ(renderbuffer_id, static_cast<GLuint>(fbo_params)); 486 EXPECT_EQ(renderbuffer_id, static_cast<GLuint>(fbo_params));
588 487
589 glDeleteRenderbuffers(1, &renderbuffer_id); 488 glDeleteRenderbuffers(1, &renderbuffer_id);
590 glDeleteTextures(1, &texture_id); 489 glDeleteTextures(1, &texture_id);
591 glDeleteFramebuffers(1, &framebuffer_id); 490 glDeleteFramebuffers(1, &framebuffer_id);
592 491
593 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 492 EXPECT_TRUE(GL_NO_ERROR == glGetError());
594 } 493 }
595 494
596 TEST_P(GLCopyTextureCHROMIUMTest, ProgramStatePreservation) { 495 TEST_P(GLCopyTextureCHROMIUMTest, ProgramStatePreservation) {
597 CopyType copy_type = ::testing::get<0>(GetParam()); 496 CopyType copy_type = GetParam();
598 GLenum dest_target = ::testing::get<1>(GetParam());
599 GLenum binding_target =
600 gpu::gles2::GLES2Util::GLTextureTargetToBindingTarget(dest_target);
601 // unbind the one created in setup. 497 // unbind the one created in setup.
602 glBindFramebuffer(GL_FRAMEBUFFER, 0); 498 glBindFramebuffer(GL_FRAMEBUFFER, 0);
603 glBindTexture(GL_TEXTURE_2D, 0); 499 glBindTexture(GL_TEXTURE_2D, 0);
604 500
605 GLManager gl2; 501 GLManager gl2;
606 GLManager::Options options; 502 GLManager::Options options;
607 options.size = gfx::Size(16, 16); 503 options.size = gfx::Size(16, 16);
608 options.share_group_manager = &gl_; 504 options.share_group_manager = &gl_;
609 gl2.Initialize(options); 505 gl2.Initialize(options);
610 gl_.MakeCurrent(); 506 gl_.MakeCurrent();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, zero)); 541 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, zero));
646 glDrawArrays(GL_TRIANGLES, 0, 6); 542 glDrawArrays(GL_TRIANGLES, 0, 6);
647 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected)); 543 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected));
648 544
649 // Call copyTextureCHROMIUM 545 // Call copyTextureCHROMIUM
650 uint8 pixels[1 * 4] = { 255u, 0u, 0u, 255u }; 546 uint8 pixels[1 * 4] = { 255u, 0u, 0u, 255u };
651 glBindTexture(GL_TEXTURE_2D, textures_[0]); 547 glBindTexture(GL_TEXTURE_2D, textures_[0]);
652 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 548 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
653 pixels); 549 pixels);
654 if (copy_type == TexImage) { 550 if (copy_type == TexImage) {
655 glCopyTextureCHROMIUM(dest_target, textures_[0], textures_[1], GL_RGBA, 551 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA,
656 GL_UNSIGNED_BYTE, false, false, false); 552 GL_UNSIGNED_BYTE, false, false, false);
657 } else { 553 } else {
658 glBindTexture(binding_target, textures_[1]); 554 glBindTexture(GL_TEXTURE_2D, textures_[1]);
659 glTexImage2D(dest_target, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 555 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
660 nullptr); 556 nullptr);
661 glCopySubTextureCHROMIUM(dest_target, textures_[0], textures_[1], 0, 0, 0, 557 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0, 0,
662 0, 1, 1, false, false, false); 558 0, 1, 1, false, false, false);
663 } 559 }
664 560
665 MakeCubeComplete(dest_target, GL_RGBA, GL_UNSIGNED_BYTE, 1, 1);
666
667 // test using program after 561 // test using program after
668 glClear(GL_COLOR_BUFFER_BIT); 562 glClear(GL_COLOR_BUFFER_BIT);
669 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, zero)); 563 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, zero));
670 glDrawArrays(GL_TRIANGLES, 0, 6); 564 glDrawArrays(GL_TRIANGLES, 0, 6);
671 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected)); 565 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected));
672 566
673 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 567 EXPECT_TRUE(GL_NO_ERROR == glGetError());
674 568
675 gl2.MakeCurrent(); 569 gl2.MakeCurrent();
676 gl2.Destroy(); 570 gl2.Destroy();
677 gl_.MakeCurrent(); 571 gl_.MakeCurrent();
678 } 572 }
679 573
680 // Test that glCopyTextureCHROMIUM doesn't leak uninitialized textures. 574 // Test that glCopyTextureCHROMIUM doesn't leak uninitialized textures.
681 TEST_P(GLCopyTextureCHROMIUMTest, UninitializedSource) { 575 TEST_P(GLCopyTextureCHROMIUMTest, UninitializedSource) {
682 CopyType copy_type = ::testing::get<0>(GetParam()); 576 CopyType copy_type = GetParam();
683 GLenum dest_target = ::testing::get<1>(GetParam());
684 GLenum binding_target =
685 gpu::gles2::GLES2Util::GLTextureTargetToBindingTarget(dest_target);
686 const GLsizei kWidth = 64, kHeight = 64; 577 const GLsizei kWidth = 64, kHeight = 64;
687 glBindTexture(GL_TEXTURE_2D, textures_[0]); 578 glBindTexture(GL_TEXTURE_2D, textures_[0]);
688 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, 579 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kWidth, kHeight, 0, GL_RGBA,
689 GL_UNSIGNED_BYTE, nullptr); 580 GL_UNSIGNED_BYTE, nullptr);
690 581
691 if (copy_type == TexImage) { 582 if (copy_type == TexImage) {
692 glCopyTextureCHROMIUM(dest_target, textures_[0], textures_[1], GL_RGBA, 583 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA,
693 GL_UNSIGNED_BYTE, false, false, false); 584 GL_UNSIGNED_BYTE, false, false, false);
694 } else { 585 } else {
695 glBindTexture(binding_target, textures_[1]); 586 glBindTexture(GL_TEXTURE_2D, textures_[1]);
696 glTexImage2D(dest_target, 0, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, 587 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kWidth, kHeight, 0, GL_RGBA,
697 GL_UNSIGNED_BYTE, nullptr); 588 GL_UNSIGNED_BYTE, nullptr);
698 glCopySubTextureCHROMIUM(dest_target, textures_[0], textures_[1], 0, 0, 0, 589 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0, 0,
699 0, kWidth, kHeight, false, false, false); 590 0, kWidth, kHeight, false, false, false);
700 } 591 }
701 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 592 EXPECT_TRUE(GL_NO_ERROR == glGetError());
702 593
703 MakeCubeComplete(dest_target, GL_RGBA, GL_UNSIGNED_BYTE, kWidth, kHeight);
704
705 uint8 pixels[kHeight][kWidth][4] = {{{1}}}; 594 uint8 pixels[kHeight][kWidth][4] = {{{1}}};
706 glReadPixels(0, 0, kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, pixels); 595 glReadPixels(0, 0, kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
707 for (int x = 0; x < kWidth; ++x) { 596 for (int x = 0; x < kWidth; ++x) {
708 for (int y = 0; y < kHeight; ++y) { 597 for (int y = 0; y < kHeight; ++y) {
709 EXPECT_EQ(0, pixels[y][x][0]); 598 EXPECT_EQ(0, pixels[y][x][0]);
710 EXPECT_EQ(0, pixels[y][x][1]); 599 EXPECT_EQ(0, pixels[y][x][1]);
711 EXPECT_EQ(0, pixels[y][x][2]); 600 EXPECT_EQ(0, pixels[y][x][2]);
712 EXPECT_EQ(0, pixels[y][x][3]); 601 EXPECT_EQ(0, pixels[y][x][3]);
713 } 602 }
714 } 603 }
715 604
716 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 605 EXPECT_TRUE(GL_NO_ERROR == glGetError());
717 } 606 }
718 607
719 TEST_P(GLCopyTextureCHROMIUMTest, CopySubTextureDimension) { 608 TEST_F(GLCopyTextureCHROMIUMTest, CopySubTextureDimension) {
720 GLenum dest_target = ::testing::get<1>(GetParam());
721 GLenum binding_target =
722 gpu::gles2::GLES2Util::GLTextureTargetToBindingTarget(dest_target);
723 glBindTexture(GL_TEXTURE_2D, textures_[0]); 609 glBindTexture(GL_TEXTURE_2D, textures_[0]);
724 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 610 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE,
725 nullptr); 611 nullptr);
726 612
727 glBindTexture(binding_target, textures_[1]); 613 glBindTexture(GL_TEXTURE_2D, textures_[1]);
728 glTexImage2D(dest_target, 0, GL_RGBA, 3, 3, 0, GL_RGBA, GL_UNSIGNED_BYTE, 614 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 3, 0, GL_RGBA, GL_UNSIGNED_BYTE,
729 nullptr); 615 nullptr);
730 616
731 glCopySubTextureCHROMIUM(dest_target, textures_[0], textures_[1], 1, 1, 0, 0, 617 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 1, 1, 0,
732 1, 1, false, false, false); 618 0, 1, 1, false, false, false);
733 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 619 EXPECT_TRUE(GL_NO_ERROR == glGetError());
734 620
735 // xoffset < 0 621 // xoffset < 0
736 glCopySubTextureCHROMIUM(dest_target, textures_[0], textures_[1], -1, 1, 0, 0, 622 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], -1, 1, 0,
737 1, 1, false, false, false); 623 0, 1, 1, false, false, false);
738 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE); 624 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE);
739 625
740 // x < 0 626 // x < 0
741 glCopySubTextureCHROMIUM(dest_target, textures_[0], textures_[1], 1, 1, -1, 0, 627 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 1, 1, -1,
742 1, 1, false, false, false); 628 0, 1, 1, false, false, false);
743 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE); 629 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE);
744 630
745 // xoffset + width > dest_width 631 // xoffset + width > dest_width
746 glCopySubTextureCHROMIUM(dest_target, textures_[0], textures_[1], 2, 2, 0, 0, 632 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 2, 2, 0,
747 2, 2, false, false, false); 633 0, 2, 2, false, false, false);
748 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE); 634 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE);
749 635
750 // x + width > source_width 636 // x + width > source_width
751 glCopySubTextureCHROMIUM(dest_target, textures_[0], textures_[1], 0, 0, 1, 1, 637 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0, 1,
752 2, 2, false, false, false); 638 1, 2, 2, false, false, false);
753 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE); 639 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE);
754 } 640 }
755 641
756 TEST_P(GLCopyTextureCHROMIUMTest, CopySubTextureOffset) { 642 TEST_F(GLCopyTextureCHROMIUMTest, CopySubTextureOffset) {
757 GLenum dest_target = ::testing::get<1>(GetParam());
758 GLenum binding_target =
759 gpu::gles2::GLES2Util::GLTextureTargetToBindingTarget(dest_target);
760 uint8 rgba_pixels[4 * 4] = {255u, 643 uint8 rgba_pixels[4 * 4] = {255u,
761 0u, 644 0u,
762 0u, 645 0u,
763 255u, 646 255u,
764 0u, 647 0u,
765 255u, 648 255u,
766 0u, 649 0u,
767 255u, 650 255u,
768 0u, 651 0u,
769 0u, 652 0u,
770 255u, 653 255u,
771 255u, 654 255u,
772 0u, 655 0u,
773 0u, 656 0u,
774 0u, 657 0u,
775 255u}; 658 255u};
776 glBindTexture(GL_TEXTURE_2D, textures_[0]); 659 glBindTexture(GL_TEXTURE_2D, textures_[0]);
777 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 660 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE,
778 rgba_pixels); 661 rgba_pixels);
779 662
780 uint8 transparent_pixels[4 * 4] = { 663 uint8 transparent_pixels[4 * 4] = {
781 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}; 664 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u};
782 glBindTexture(binding_target, textures_[1]); 665 glBindTexture(GL_TEXTURE_2D, textures_[1]);
783 glTexImage2D(dest_target, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 666 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE,
784 transparent_pixels); 667 transparent_pixels);
785 668
786 glCopySubTextureCHROMIUM(dest_target, textures_[0], textures_[1], 1, 1, 0, 0, 669 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 1, 1, 0,
787 1, 1, false, false, false); 670 0, 1, 1, false, false, false);
788 EXPECT_TRUE(glGetError() == GL_NO_ERROR); 671 EXPECT_TRUE(glGetError() == GL_NO_ERROR);
789 glCopySubTextureCHROMIUM(dest_target, textures_[0], textures_[1], 1, 0, 1, 0, 672 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 1, 0, 1,
790 1, 1, false, false, false); 673 0, 1, 1, false, false, false);
791 EXPECT_TRUE(glGetError() == GL_NO_ERROR); 674 EXPECT_TRUE(glGetError() == GL_NO_ERROR);
792 glCopySubTextureCHROMIUM(dest_target, textures_[0], textures_[1], 0, 1, 0, 1, 675 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 1, 0,
793 1, 1, false, false, false); 676 1, 1, 1, false, false, false);
794 EXPECT_TRUE(glGetError() == GL_NO_ERROR); 677 EXPECT_TRUE(glGetError() == GL_NO_ERROR);
795 678
796 MakeCubeComplete(dest_target, GL_RGBA, GL_UNSIGNED_BYTE, 2, 2);
797
798 // Check the FB is still bound. 679 // Check the FB is still bound.
799 GLint value = 0; 680 GLint value = 0;
800 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value); 681 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value);
801 GLuint fb_id = value; 682 GLuint fb_id = value;
802 EXPECT_EQ(framebuffer_id_, fb_id); 683 EXPECT_EQ(framebuffer_id_, fb_id);
803 684
804 // Check that FB is complete. 685 // Check that FB is complete.
805 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), 686 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
806 glCheckFramebufferStatus(GL_FRAMEBUFFER)); 687 glCheckFramebufferStatus(GL_FRAMEBUFFER));
807 688
808 uint8 transparent[1 * 4] = {0u, 0u, 0u, 0u}; 689 uint8 transparent[1 * 4] = {0u, 0u, 0u, 0u};
809 uint8 red[1 * 4] = {255u, 0u, 0u, 255u}; 690 uint8 red[1 * 4] = {255u, 0u, 0u, 255u};
810 uint8 green[1 * 4] = {0u, 255u, 0u, 255u}; 691 uint8 green[1 * 4] = {0u, 255u, 0u, 255u};
811 uint8 blue[1 * 4] = {0u, 0u, 255u, 255u}; 692 uint8 blue[1 * 4] = {0u, 0u, 255u, 255u};
812 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, transparent); 693 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, transparent);
813 GLTestHelper::CheckPixels(1, 1, 1, 1, 0, red); 694 GLTestHelper::CheckPixels(1, 1, 1, 1, 0, red);
814 GLTestHelper::CheckPixels(1, 0, 1, 1, 0, green); 695 GLTestHelper::CheckPixels(1, 0, 1, 1, 0, green);
815 GLTestHelper::CheckPixels(0, 1, 1, 1, 0, blue); 696 GLTestHelper::CheckPixels(0, 1, 1, 1, 0, blue);
816 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 697 EXPECT_TRUE(GL_NO_ERROR == glGetError());
817 } 698 }
818 699
819 } // namespace gpu 700 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder.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