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

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

Powered by Google App Engine
This is Rietveld 408576698