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

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

Powered by Google App Engine
This is Rietveld 408576698