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

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

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