blob: 4f1ac478c3bd6df341c9ac550a9d068f65f75d4a [file] [log] [blame]
Geoff Lang97073d12016-04-20 10:42:34 -07001//
2// Copyright 2016 The ANGLE Project Authors. All rights reserved.
3// Use of this source code is governed by a BSD-style license that can be
4// found in the LICENSE file.
5//
6
7// CopyTextureTest.cpp: Tests of the GL_CHROMIUM_copy_texture extension
8
9#include "test_utils/ANGLETest.h"
10
Geoff Lang4f0e0032017-05-01 16:04:35 -040011#include "test_utils/gl_raii.h"
12
Geoff Lang97073d12016-04-20 10:42:34 -070013namespace angle
14{
15
16class CopyTextureTest : public ANGLETest
17{
18 protected:
19 CopyTextureTest()
20 {
21 setWindowWidth(256);
22 setWindowHeight(256);
23 setConfigRedBits(8);
24 setConfigGreenBits(8);
25 setConfigBlueBits(8);
26 setConfigAlphaBits(8);
27 }
28
29 void SetUp() override
30 {
31 ANGLETest::SetUp();
32
33 glGenTextures(2, mTextures);
34 glBindTexture(GL_TEXTURE_2D, mTextures[1]);
35
36 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
37 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
38 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
39 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
40
41 glGenFramebuffers(1, &mFramebuffer);
42 glBindFramebuffer(GL_FRAMEBUFFER, mFramebuffer);
43 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mTextures[1],
44 0);
45
46 if (extensionEnabled("GL_CHROMIUM_copy_texture"))
47 {
48 glCopyTextureCHROMIUM = reinterpret_cast<PFNGLCOPYTEXTURECHROMIUMPROC>(
49 eglGetProcAddress("glCopyTextureCHROMIUM"));
50 glCopySubTextureCHROMIUM = reinterpret_cast<PFNGLCOPYSUBTEXTURECHROMIUMPROC>(
51 eglGetProcAddress("glCopySubTextureCHROMIUM"));
52 }
53 }
54
55 void TearDown() override
56 {
57 glDeleteTextures(2, mTextures);
58 glDeleteFramebuffers(1, &mFramebuffer);
59
60 ANGLETest::TearDown();
61 }
62
63 bool checkExtensions() const
64 {
65 if (!extensionEnabled("GL_CHROMIUM_copy_texture"))
66 {
67 std::cout << "Test skipped because GL_CHROMIUM_copy_texture is not available."
68 << std::endl;
69 return false;
70 }
71
72 EXPECT_NE(nullptr, glCopyTextureCHROMIUM);
73 EXPECT_NE(nullptr, glCopySubTextureCHROMIUM);
74 return true;
75 }
76
Geoff Langf81d17c2018-02-02 15:10:37 -050077 void testGradientDownsampleUniqueValues(GLenum destFormat,
78 GLenum destType,
79 const std::array<size_t, 4> &expectedUniqueValues)
80 {
81 std::array<GLColor, 256> sourceGradient;
82 for (size_t i = 0; i < sourceGradient.size(); i++)
83 {
84 GLubyte value = static_cast<GLubyte>(i);
85 sourceGradient[i] = GLColor(value, value, value, value);
86 }
87 GLTexture sourceTexture;
88 glBindTexture(GL_TEXTURE_2D, sourceTexture);
89 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
90 sourceGradient.data());
91
92 GLTexture destTexture;
93 glBindTexture(GL_TEXTURE_2D, destTexture);
94 glCopyTextureCHROMIUM(sourceTexture, 0, GL_TEXTURE_2D, destTexture, 0, destFormat, destType,
95 GL_FALSE, GL_FALSE, GL_FALSE);
96 EXPECT_GL_NO_ERROR();
97
98 GLFramebuffer fbo;
99 glBindFramebuffer(GL_FRAMEBUFFER, fbo);
100 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, destTexture, 0);
101
102 std::array<GLColor, 256> destData;
103 glReadPixels(0, 0, 256, 1, GL_RGBA, GL_UNSIGNED_BYTE, destData.data());
104 EXPECT_GL_NO_ERROR();
105
106 std::set<GLubyte> uniqueValues[4];
107 for (size_t i = 0; i < destData.size(); i++)
108 {
109 GLColor color = destData[i];
110 uniqueValues[0].insert(color.R);
111 uniqueValues[1].insert(color.G);
112 uniqueValues[2].insert(color.B);
113 uniqueValues[3].insert(color.A);
114 }
115
116 EXPECT_EQ(expectedUniqueValues[0], uniqueValues[0].size());
117 EXPECT_EQ(expectedUniqueValues[1], uniqueValues[1].size());
118 EXPECT_EQ(expectedUniqueValues[2], uniqueValues[2].size());
119 EXPECT_EQ(expectedUniqueValues[3], uniqueValues[3].size());
120 }
121
Geoff Lang97073d12016-04-20 10:42:34 -0700122 GLuint mTextures[2] = {
Jamie Madillb980c562018-11-27 11:34:27 -0500123 0,
124 0,
Geoff Lang97073d12016-04-20 10:42:34 -0700125 };
126 GLuint mFramebuffer = 0;
127
128 PFNGLCOPYTEXTURECHROMIUMPROC glCopyTextureCHROMIUM = nullptr;
129 PFNGLCOPYSUBTEXTURECHROMIUMPROC glCopySubTextureCHROMIUM = nullptr;
130};
131
Brandon Jones340b7b82017-06-26 13:02:31 -0700132class CopyTextureTestDest : public CopyTextureTest
Jamie Madillb980c562018-11-27 11:34:27 -0500133{};
Brandon Jones340b7b82017-06-26 13:02:31 -0700134
Brandon Jones28783792018-03-05 09:37:32 -0800135class CopyTextureTestWebGL : public CopyTextureTest
136{
137 protected:
138 CopyTextureTestWebGL() : CopyTextureTest() { setWebGLCompatibilityEnabled(true); }
139};
140
Geoff Lang4f0e0032017-05-01 16:04:35 -0400141class CopyTextureTestES3 : public CopyTextureTest
Jamie Madillb980c562018-11-27 11:34:27 -0500142{};
Geoff Lang4f0e0032017-05-01 16:04:35 -0400143
Geoff Lang97073d12016-04-20 10:42:34 -0700144// Test to ensure that the basic functionality of the extension works.
145TEST_P(CopyTextureTest, BasicCopyTexture)
146{
147 if (!checkExtensions())
148 {
149 return;
150 }
151
152 GLColor pixels = GLColor::red;
153
154 glBindTexture(GL_TEXTURE_2D, mTextures[0]);
155 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &pixels);
156
Geoff Langfc72a072017-03-24 14:52:39 -0400157 glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA,
158 GL_UNSIGNED_BYTE, false, false, false);
Geoff Lang97073d12016-04-20 10:42:34 -0700159
160 EXPECT_GL_NO_ERROR();
161
162 EXPECT_PIXEL_COLOR_EQ(0, 0, pixels);
163}
164
165// Test to ensure that the basic functionality of the extension works.
166TEST_P(CopyTextureTest, BasicCopySubTexture)
167{
168 if (!checkExtensions())
169 {
170 return;
171 }
172
173 GLColor pixels = GLColor::red;
174
175 glBindTexture(GL_TEXTURE_2D, mTextures[0]);
176 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &pixels);
177
178 glBindTexture(GL_TEXTURE_2D, mTextures[1]);
179 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
180
Geoff Langfc72a072017-03-24 14:52:39 -0400181 glCopySubTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, 0, 0, 0, 0, 1, 1,
182 false, false, false);
Geoff Lang97073d12016-04-20 10:42:34 -0700183
184 EXPECT_GL_NO_ERROR();
185
186 // Check that FB is complete.
187 EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
188
189 EXPECT_PIXEL_COLOR_EQ(0, 0, pixels);
190
191 EXPECT_GL_NO_ERROR();
192}
193
194// Test that CopyTexture cannot redefine an immutable texture and CopySubTexture can copy data to
195// immutable textures
196TEST_P(CopyTextureTest, ImmutableTexture)
197{
198 if (!checkExtensions())
199 {
200 return;
201 }
202
Yunchao He9550c602018-02-13 14:47:05 +0800203 ANGLE_SKIP_TEST_IF(
204 getClientMajorVersion() < 3 &&
205 (!extensionEnabled("GL_EXT_texture_storage") || !extensionEnabled("GL_OES_rgb8_rgba8")));
Geoff Lang97073d12016-04-20 10:42:34 -0700206
207 GLColor pixels = GLColor::red;
208
209 glBindTexture(GL_TEXTURE_2D, mTextures[0]);
210 glTexStorage2DEXT(GL_TEXTURE_2D, 1, GL_RGBA8_OES, 1, 1);
211 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixels);
212
213 glBindTexture(GL_TEXTURE_2D, mTextures[1]);
214 glTexStorage2DEXT(GL_TEXTURE_2D, 1, GL_RGBA8_OES, 1, 1);
215 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mTextures[1], 0);
216 EXPECT_GL_NO_ERROR();
217
218 // Should generate an error when the texture is redefined
Geoff Langfc72a072017-03-24 14:52:39 -0400219 glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA,
220 GL_UNSIGNED_BYTE, false, false, false);
Geoff Lang97073d12016-04-20 10:42:34 -0700221 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
222
223 // Should succeed when using CopySubTexture
Geoff Langfc72a072017-03-24 14:52:39 -0400224 glCopySubTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, 0, 0, 0, 0, 1, 1,
225 false, false, false);
Geoff Lang97073d12016-04-20 10:42:34 -0700226 EXPECT_GL_NO_ERROR();
227
228 // Check that FB is complete.
229 EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
230
231 EXPECT_PIXEL_COLOR_EQ(0, 0, pixels);
232
233 EXPECT_GL_NO_ERROR();
234}
235
236// Test validation of internal formats in CopyTexture and CopySubTexture
237TEST_P(CopyTextureTest, InternalFormat)
238{
239 if (!checkExtensions())
240 {
241 return;
242 }
243
244 std::vector<GLint> sourceFormats;
245 sourceFormats.push_back(GL_ALPHA);
246 sourceFormats.push_back(GL_RGB);
247 sourceFormats.push_back(GL_RGBA);
248 sourceFormats.push_back(GL_LUMINANCE);
249 sourceFormats.push_back(GL_LUMINANCE_ALPHA);
250
251 std::vector<GLint> destFormats;
252 destFormats.push_back(GL_RGB);
253 destFormats.push_back(GL_RGBA);
254
255 if (extensionEnabled("GL_EXT_texture_format_BGRA8888"))
256 {
257 sourceFormats.push_back(GL_BGRA_EXT);
258 destFormats.push_back(GL_BGRA_EXT);
259 }
260
261 // Test with glCopyTexture
262 for (GLint sourceFormat : sourceFormats)
263 {
264 for (GLint destFormat : destFormats)
265 {
266 glBindTexture(GL_TEXTURE_2D, mTextures[0]);
267 glTexImage2D(GL_TEXTURE_2D, 0, sourceFormat, 1, 1, 0, sourceFormat, GL_UNSIGNED_BYTE,
268 nullptr);
269 EXPECT_GL_NO_ERROR();
270
Geoff Langfc72a072017-03-24 14:52:39 -0400271 glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, destFormat,
272 GL_UNSIGNED_BYTE, false, false, false);
Geoff Lang97073d12016-04-20 10:42:34 -0700273
274 EXPECT_GL_NO_ERROR();
275 }
276 }
277
278 // Test with glCopySubTexture
279 for (GLint sourceFormat : sourceFormats)
280 {
281 for (GLint destFormat : destFormats)
282 {
283 glBindTexture(GL_TEXTURE_2D, mTextures[0]);
284 glTexImage2D(GL_TEXTURE_2D, 0, sourceFormat, 1, 1, 0, sourceFormat, GL_UNSIGNED_BYTE,
285 nullptr);
286 EXPECT_GL_NO_ERROR();
287
288 glBindTexture(GL_TEXTURE_2D, mTextures[1]);
289 glTexImage2D(GL_TEXTURE_2D, 0, destFormat, 1, 1, 0, destFormat, GL_UNSIGNED_BYTE,
290 nullptr);
291 EXPECT_GL_NO_ERROR();
292
Geoff Langfc72a072017-03-24 14:52:39 -0400293 glCopySubTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, 0, 0, 0, 0, 1,
294 1, false, false, false);
Geoff Lang97073d12016-04-20 10:42:34 -0700295
296 EXPECT_GL_NO_ERROR();
297 }
298 }
299}
300
Geoff Lang97073d12016-04-20 10:42:34 -0700301// Test to ensure that the destination texture is redefined if the properties are different.
302TEST_P(CopyTextureTest, RedefineDestinationTexture)
303{
Bryan Bernhart (Intel Americas Inc)2a357412017-09-05 10:42:47 -0700304 ANGLE_SKIP_TEST_IF(!checkExtensions());
305 ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_EXT_texture_format_BGRA8888"));
Geoff Lang97073d12016-04-20 10:42:34 -0700306
307 GLColor pixels[4] = {GLColor::red, GLColor::red, GLColor::red, GLColor::red};
308
309 glBindTexture(GL_TEXTURE_2D, mTextures[0]);
310 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
311
312 glBindTexture(GL_TEXTURE_2D, mTextures[1]);
313 glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT, 1, 1, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, pixels);
314 EXPECT_GL_NO_ERROR();
315
316 // GL_INVALID_OPERATION due to "intrinsic format" != "internal format".
317 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
318 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
319 // GL_INVALID_VALUE due to bad dimensions.
320 glTexSubImage2D(GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_BGRA_EXT, GL_UNSIGNED_BYTE, pixels);
321 EXPECT_GL_ERROR(GL_INVALID_VALUE);
322
323 // If the dest texture has different properties, glCopyTextureCHROMIUM()
324 // redefines them.
Geoff Langfc72a072017-03-24 14:52:39 -0400325 glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA,
326 GL_UNSIGNED_BYTE, false, false, false);
Geoff Lang97073d12016-04-20 10:42:34 -0700327 EXPECT_GL_NO_ERROR();
328
329 // glTexSubImage2D() succeeds because mTextures[1] is redefined into 2x2
330 // dimension and GL_RGBA format.
331 glBindTexture(GL_TEXTURE_2D, mTextures[1]);
332 glTexSubImage2D(GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
333 EXPECT_GL_NO_ERROR();
334
335 // Check that FB is complete.
336 EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
337
338 EXPECT_PIXEL_COLOR_EQ(1, 1, pixels[3]);
339 EXPECT_GL_NO_ERROR();
340}
341
342// Test that invalid dimensions in CopySubTexture are validated
343TEST_P(CopyTextureTest, CopySubTextureDimension)
344{
345 if (!checkExtensions())
346 {
347 return;
348 }
349
350 glBindTexture(GL_TEXTURE_2D, mTextures[0]);
351 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
352
353 glBindTexture(GL_TEXTURE_2D, mTextures[1]);
354 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 3, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
355
Geoff Langfc72a072017-03-24 14:52:39 -0400356 glCopySubTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, 1, 1, 0, 0, 1, 1,
357 false, false, false);
Geoff Lang97073d12016-04-20 10:42:34 -0700358 EXPECT_GL_NO_ERROR();
359
360 // xoffset < 0
Geoff Langfc72a072017-03-24 14:52:39 -0400361 glCopySubTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, -1, 1, 0, 0, 1, 1,
362 false, false, false);
Geoff Lang97073d12016-04-20 10:42:34 -0700363 EXPECT_GL_ERROR(GL_INVALID_VALUE);
364
365 // x < 0
Geoff Langfc72a072017-03-24 14:52:39 -0400366 glCopySubTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, 1, 1, -1, 0, 1, 1,
367 false, false, false);
Geoff Lang97073d12016-04-20 10:42:34 -0700368 EXPECT_GL_ERROR(GL_INVALID_VALUE);
369
370 // xoffset + width > dest_width
Geoff Langfc72a072017-03-24 14:52:39 -0400371 glCopySubTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, 2, 2, 0, 0, 2, 2,
372 false, false, false);
Geoff Lang97073d12016-04-20 10:42:34 -0700373 EXPECT_GL_ERROR(GL_INVALID_VALUE);
374
375 // x + width > source_width
Geoff Langfc72a072017-03-24 14:52:39 -0400376 glCopySubTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, 0, 0, 1, 1, 2, 2,
377 false, false, false);
Geoff Lang97073d12016-04-20 10:42:34 -0700378 EXPECT_GL_ERROR(GL_INVALID_VALUE);
379}
380
381// Test that invalid IDs in CopyTexture are validated
382TEST_P(CopyTextureTest, CopyTextureInvalidTextureIds)
383{
384 if (!checkExtensions())
385 {
386 return;
387 }
388
389 glBindTexture(GL_TEXTURE_2D, mTextures[0]);
390 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
391
392 glBindTexture(GL_TEXTURE_2D, mTextures[1]);
393 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 3, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
394
Geoff Langfc72a072017-03-24 14:52:39 -0400395 glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, 99993, 0, GL_RGBA, GL_UNSIGNED_BYTE,
396 false, false, false);
Geoff Lang97073d12016-04-20 10:42:34 -0700397 EXPECT_GL_ERROR(GL_INVALID_VALUE);
398
Geoff Langfc72a072017-03-24 14:52:39 -0400399 glCopyTextureCHROMIUM(99994, 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA, GL_UNSIGNED_BYTE,
400 false, false, false);
Geoff Lang97073d12016-04-20 10:42:34 -0700401 EXPECT_GL_ERROR(GL_INVALID_VALUE);
402
Geoff Langfc72a072017-03-24 14:52:39 -0400403 glCopyTextureCHROMIUM(99995, 0, GL_TEXTURE_2D, 99996, 0, GL_RGBA, GL_UNSIGNED_BYTE, false,
404 false, false);
Geoff Lang97073d12016-04-20 10:42:34 -0700405 EXPECT_GL_ERROR(GL_INVALID_VALUE);
406
Geoff Langfc72a072017-03-24 14:52:39 -0400407 glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA,
408 GL_UNSIGNED_BYTE, false, false, false);
Geoff Lang97073d12016-04-20 10:42:34 -0700409 EXPECT_GL_NO_ERROR();
410}
411
412// Test that invalid IDs in CopySubTexture are validated
413TEST_P(CopyTextureTest, CopySubTextureInvalidTextureIds)
414{
415 if (!checkExtensions())
416 {
417 return;
418 }
419
420 glBindTexture(GL_TEXTURE_2D, mTextures[0]);
421 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
422
423 glBindTexture(GL_TEXTURE_2D, mTextures[1]);
424 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 3, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
425
Geoff Langfc72a072017-03-24 14:52:39 -0400426 glCopySubTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, 99993, 0, 1, 1, 0, 0, 1, 1, false,
427 false, false);
Geoff Lang97073d12016-04-20 10:42:34 -0700428 EXPECT_GL_ERROR(GL_INVALID_VALUE);
429
Geoff Langfc72a072017-03-24 14:52:39 -0400430 glCopySubTextureCHROMIUM(99994, 0, GL_TEXTURE_2D, mTextures[1], 0, 1, 1, 0, 0, 1, 1, false,
431 false, false);
Geoff Lang97073d12016-04-20 10:42:34 -0700432 EXPECT_GL_ERROR(GL_INVALID_VALUE);
433
Geoff Langfc72a072017-03-24 14:52:39 -0400434 glCopySubTextureCHROMIUM(99995, 0, GL_TEXTURE_2D, 99996, 0, 1, 1, 0, 0, 1, 1, false, false,
435 false);
Geoff Lang97073d12016-04-20 10:42:34 -0700436 EXPECT_GL_ERROR(GL_INVALID_VALUE);
437
Geoff Langfc72a072017-03-24 14:52:39 -0400438 glCopySubTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, 1, 1, 0, 0, 1, 1,
439 false, false, false);
Geoff Lang97073d12016-04-20 10:42:34 -0700440 EXPECT_GL_NO_ERROR();
441}
442
Geoff Lang63458a32017-10-30 15:16:53 -0400443TEST_P(CopyTextureTest, InvalidTarget)
444{
445 ANGLE_SKIP_TEST_IF(!checkExtensions());
446
447 GLTexture textures[2];
448
449 glBindTexture(GL_TEXTURE_2D, textures[0]);
450 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
451
452 glBindTexture(GL_TEXTURE_2D, textures[1]);
453 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 3, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
454
455 // Invalid enum for a completely invalid target
456 glCopySubTextureCHROMIUM(textures[0], 0, GL_INVALID_VALUE, textures[1], 0, 1, 1, 0, 0, 1, 1,
457 false, false, false);
458 EXPECT_GL_ERROR(GL_INVALID_ENUM);
459
460 // Invalid value for a valid target enum but is not valid for the destination texture
461 glCopySubTextureCHROMIUM(textures[0], 0, GL_TEXTURE_CUBE_MAP_POSITIVE_X, textures[1], 0, 1, 1,
462 0, 0, 1, 1, false, false, false);
463 EXPECT_GL_ERROR(GL_INVALID_VALUE);
464}
465
Geoff Lang97073d12016-04-20 10:42:34 -0700466// Test that using an offset in CopySubTexture works correctly
467TEST_P(CopyTextureTest, CopySubTextureOffset)
468{
469 if (!checkExtensions())
470 {
471 return;
472 }
473
474 GLColor rgbaPixels[4 * 4] = {GLColor::red, GLColor::green, GLColor::blue, GLColor::black};
475 glBindTexture(GL_TEXTURE_2D, mTextures[0]);
476 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, rgbaPixels);
477
478 GLColor transparentPixels[4 * 4] = {GLColor::transparentBlack, GLColor::transparentBlack,
479 GLColor::transparentBlack, GLColor::transparentBlack};
480 glBindTexture(GL_TEXTURE_2D, mTextures[1]);
481 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, transparentPixels);
482
Geoff Langfc72a072017-03-24 14:52:39 -0400483 glCopySubTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, 1, 1, 0, 0, 1, 1,
484 false, false, false);
Geoff Lang97073d12016-04-20 10:42:34 -0700485 EXPECT_GL_NO_ERROR();
Geoff Langfc72a072017-03-24 14:52:39 -0400486 glCopySubTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, 1, 0, 1, 0, 1, 1,
487 false, false, false);
Geoff Lang97073d12016-04-20 10:42:34 -0700488 EXPECT_GL_NO_ERROR();
Geoff Langfc72a072017-03-24 14:52:39 -0400489 glCopySubTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, 0, 1, 0, 1, 1, 1,
490 false, false, false);
Geoff Lang97073d12016-04-20 10:42:34 -0700491 EXPECT_GL_NO_ERROR();
492
493 // Check that FB is complete.
494 EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
495
496 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::transparentBlack);
497 EXPECT_PIXEL_COLOR_EQ(1, 1, GLColor::red);
498 EXPECT_PIXEL_COLOR_EQ(1, 0, GLColor::green);
499 EXPECT_PIXEL_COLOR_EQ(0, 1, GLColor::blue);
500 EXPECT_GL_NO_ERROR();
501}
502
503// Test that flipping the Y component works correctly
504TEST_P(CopyTextureTest, FlipY)
505{
506 if (!checkExtensions())
507 {
508 return;
509 }
510
511 GLColor rgbaPixels[4] = {GLColor(255u, 255u, 255u, 255u), GLColor(127u, 127u, 127u, 127u),
512 GLColor(63u, 63u, 63u, 127u), GLColor(255u, 255u, 255u, 0u)};
513
514 glBindTexture(GL_TEXTURE_2D, mTextures[0]);
515 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, rgbaPixels);
516
Geoff Langfc72a072017-03-24 14:52:39 -0400517 glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA,
518 GL_UNSIGNED_BYTE, GL_TRUE, GL_FALSE, GL_FALSE);
Geoff Lang97073d12016-04-20 10:42:34 -0700519 EXPECT_GL_NO_ERROR();
520
521 // Check that FB is complete.
522 EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
523
524 EXPECT_PIXEL_COLOR_EQ(0, 0, rgbaPixels[2]);
525 EXPECT_PIXEL_COLOR_EQ(1, 0, rgbaPixels[3]);
526 EXPECT_PIXEL_COLOR_EQ(0, 1, rgbaPixels[0]);
527 EXPECT_PIXEL_COLOR_EQ(1, 1, rgbaPixels[1]);
528 EXPECT_GL_NO_ERROR();
529}
530
531// Test that premultipying the alpha on copy works correctly
532TEST_P(CopyTextureTest, PremultiplyAlpha)
533{
534 if (!checkExtensions())
535 {
536 return;
537 }
538
539 GLColor rgbaPixels[4] = {GLColor(255u, 255u, 255u, 255u), GLColor(255u, 255u, 255u, 127u),
540 GLColor(127u, 127u, 127u, 127u), GLColor(255u, 255u, 255u, 0u)};
541
542 glBindTexture(GL_TEXTURE_2D, mTextures[0]);
543 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, rgbaPixels);
544
Geoff Langfc72a072017-03-24 14:52:39 -0400545 glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA,
546 GL_UNSIGNED_BYTE, GL_FALSE, GL_TRUE, GL_FALSE);
Geoff Lang97073d12016-04-20 10:42:34 -0700547 EXPECT_GL_NO_ERROR();
548
549 // Check that FB is complete.
550 EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
551
552 EXPECT_PIXEL_COLOR_NEAR(0, 0, GLColor(255, 255, 255, 255), 1.0);
553 EXPECT_PIXEL_COLOR_NEAR(1, 0, GLColor(127, 127, 127, 127), 1.0);
554 EXPECT_PIXEL_COLOR_NEAR(0, 1, GLColor(63, 63, 63, 127), 1.0);
555 EXPECT_PIXEL_COLOR_NEAR(1, 1, GLColor(0, 0, 0, 0), 1.0);
556 EXPECT_GL_NO_ERROR();
557}
558
559// Test that unmultipying the alpha on copy works correctly
560TEST_P(CopyTextureTest, UnmultiplyAlpha)
561{
562 if (!checkExtensions())
563 {
564 return;
565 }
566
567 GLColor rgbaPixels[4] = {GLColor(255u, 255u, 255u, 255u), GLColor(127u, 127u, 127u, 127u),
568 GLColor(63u, 63u, 63u, 127u), GLColor(255u, 255u, 255u, 0u)};
569
570 glBindTexture(GL_TEXTURE_2D, mTextures[0]);
571 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, rgbaPixels);
572
Geoff Langfc72a072017-03-24 14:52:39 -0400573 glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA,
574 GL_UNSIGNED_BYTE, GL_FALSE, GL_FALSE, GL_TRUE);
Geoff Lang97073d12016-04-20 10:42:34 -0700575 EXPECT_GL_NO_ERROR();
576
577 // Check that FB is complete.
578 EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
579
580 EXPECT_PIXEL_COLOR_NEAR(0, 0, GLColor(255, 255, 255, 255), 1.0);
581 EXPECT_PIXEL_COLOR_NEAR(1, 0, GLColor(255, 255, 255, 127), 1.0);
582 EXPECT_PIXEL_COLOR_NEAR(0, 1, GLColor(127, 127, 127, 127), 1.0);
583 EXPECT_PIXEL_COLOR_NEAR(1, 1, GLColor(255, 255, 255, 0), 1.0);
584 EXPECT_GL_NO_ERROR();
585}
586
587// Test that unmultipying and premultiplying the alpha is the same as doing neither
Corentin Wallez133a2ec2016-11-17 16:28:03 -0500588TEST_P(CopyTextureTest, UnmultiplyAndPremultiplyAlpha)
Geoff Lang97073d12016-04-20 10:42:34 -0700589{
590 if (!checkExtensions())
591 {
592 return;
593 }
594
595 GLColor rgbaPixels[4] = {GLColor(255u, 255u, 255u, 255u), GLColor(127u, 127u, 127u, 127u),
596 GLColor(63u, 63u, 63u, 127u), GLColor(255u, 255u, 255u, 0u)};
597
598 glBindTexture(GL_TEXTURE_2D, mTextures[0]);
599 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, rgbaPixels);
600
Geoff Langfc72a072017-03-24 14:52:39 -0400601 glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA,
602 GL_UNSIGNED_BYTE, GL_FALSE, GL_TRUE, GL_TRUE);
Geoff Lang97073d12016-04-20 10:42:34 -0700603 EXPECT_GL_NO_ERROR();
604
605 // Check that FB is complete.
606 EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
607
608 EXPECT_PIXEL_COLOR_NEAR(0, 0, GLColor(255, 255, 255, 255), 1.0);
609 EXPECT_PIXEL_COLOR_NEAR(1, 0, GLColor(127, 127, 127, 127), 1.0);
610 EXPECT_PIXEL_COLOR_NEAR(0, 1, GLColor(63, 63, 63, 127), 1.0);
611 EXPECT_PIXEL_COLOR_NEAR(1, 1, GLColor(255, 255, 255, 0), 1.0);
612 EXPECT_GL_NO_ERROR();
613}
614
Corentin Wallez133a2ec2016-11-17 16:28:03 -0500615// Test to ensure that CopyTexture works with LUMINANCE_ALPHA texture
616TEST_P(CopyTextureTest, LuminanceAlpha)
617{
618 if (!checkExtensions())
619 {
620 return;
621 }
622
623 uint8_t originalPixels[] = {163u, 67u};
624 GLColor expectedPixels(163u, 163u, 163u, 67u);
625
626 glBindTexture(GL_TEXTURE_2D, mTextures[0]);
627 glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, 1, 1, 0, GL_LUMINANCE_ALPHA,
628 GL_UNSIGNED_BYTE, &originalPixels);
629
Geoff Langfc72a072017-03-24 14:52:39 -0400630 glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA,
631 GL_UNSIGNED_BYTE, false, false, false);
Corentin Wallez133a2ec2016-11-17 16:28:03 -0500632
633 EXPECT_GL_NO_ERROR();
634
635 EXPECT_PIXEL_COLOR_EQ(0, 0, expectedPixels);
636}
637
638// Test to ensure that CopyTexture works with LUMINANCE texture
639TEST_P(CopyTextureTest, Luminance)
640{
641 if (!checkExtensions())
642 {
643 return;
644 }
645
646 uint8_t originalPixels[] = {57u};
647 GLColor expectedPixels(57u, 57u, 57u, 255u);
648
649 glBindTexture(GL_TEXTURE_2D, mTextures[0]);
650 glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 1, 1, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE,
651 &originalPixels);
652
Geoff Langfc72a072017-03-24 14:52:39 -0400653 glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA,
654 GL_UNSIGNED_BYTE, false, false, false);
Corentin Wallez133a2ec2016-11-17 16:28:03 -0500655
656 EXPECT_GL_NO_ERROR();
657
658 EXPECT_PIXEL_COLOR_EQ(0, 0, expectedPixels);
659}
660
661// Test to ensure that CopyTexture works with ALPHA texture
662TEST_P(CopyTextureTest, Alpha)
663{
664 if (!checkExtensions())
665 {
666 return;
667 }
668
669 uint8_t originalPixels[] = {77u};
670 GLColor expectedPixels(0u, 0u, 0u, 77u);
671
672 glBindTexture(GL_TEXTURE_2D, mTextures[0]);
673 glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, 1, 1, 0, GL_ALPHA, GL_UNSIGNED_BYTE, &originalPixels);
674
Geoff Langfc72a072017-03-24 14:52:39 -0400675 glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA,
676 GL_UNSIGNED_BYTE, false, false, false);
Corentin Wallez133a2ec2016-11-17 16:28:03 -0500677
678 EXPECT_GL_NO_ERROR();
679
680 EXPECT_PIXEL_COLOR_EQ(0, 0, expectedPixels);
681}
682
Geoff Lang4f0e0032017-05-01 16:04:35 -0400683// Test that copying to cube maps works
684TEST_P(CopyTextureTest, CubeMapTarget)
685{
686 if (!checkExtensions())
687 {
688 return;
689 }
690
691 GLColor pixels = GLColor::red;
692
693 GLTexture textures[2];
694
695 glBindTexture(GL_TEXTURE_2D, textures[0]);
696 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &pixels);
697
698 glBindTexture(GL_TEXTURE_CUBE_MAP, textures[1]);
699 for (GLenum face = GL_TEXTURE_CUBE_MAP_POSITIVE_X; face <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z;
700 face++)
701 {
702 glTexImage2D(face, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
703 }
704
705 glCopySubTextureCHROMIUM(textures[0], 0, GL_TEXTURE_CUBE_MAP_POSITIVE_X, textures[1], 0, 0, 0,
706 0, 0, 1, 1, false, false, false);
707
708 EXPECT_GL_NO_ERROR();
709
710 GLFramebuffer fbo;
711 glBindFramebuffer(GL_FRAMEBUFFER, fbo);
712 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X,
713 textures[1], 0);
714
715 // Check that FB is complete.
716 EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
717
718 EXPECT_PIXEL_COLOR_EQ(0, 0, pixels);
719
720 EXPECT_GL_NO_ERROR();
721}
722
723// Test that copying to non-zero mipmaps works
Geoff Lang165dcf12017-06-07 15:05:14 -0400724TEST_P(CopyTextureTest, CopyToMipmap)
Geoff Lang4f0e0032017-05-01 16:04:35 -0400725{
726 if (!checkExtensions())
727 {
728 return;
729 }
730
Yunchao He9550c602018-02-13 14:47:05 +0800731 ANGLE_SKIP_TEST_IF(getClientMajorVersion() < 3 &&
732 !extensionEnabled("GL_OES_fbo_render_mipmap"));
Geoff Lang165dcf12017-06-07 15:05:14 -0400733
Yunchao He9550c602018-02-13 14:47:05 +0800734 ANGLE_SKIP_TEST_IF(IsOSX() && IsIntel());
Geoff Lang4f0e0032017-05-01 16:04:35 -0400735
Geoff Lang165dcf12017-06-07 15:05:14 -0400736 GLColor pixels[] = {GLColor::red, GLColor::red, GLColor::red, GLColor::red};
Geoff Lang4f0e0032017-05-01 16:04:35 -0400737
738 GLTexture textures[2];
739
Geoff Lang4f0e0032017-05-01 16:04:35 -0400740 glBindTexture(GL_TEXTURE_2D, textures[0]);
Geoff Lang165dcf12017-06-07 15:05:14 -0400741 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
742 glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
Geoff Lang4f0e0032017-05-01 16:04:35 -0400743
744 glBindTexture(GL_TEXTURE_2D, textures[1]);
745 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
746 glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
747 glTexImage2D(GL_TEXTURE_2D, 2, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
748
Geoff Lang165dcf12017-06-07 15:05:14 -0400749 std::vector<std::pair<GLint, GLint>> soureDestPairs;
750 soureDestPairs.push_back(std::make_pair(0, 1));
Geoff Lang4f0e0032017-05-01 16:04:35 -0400751
Geoff Lang165dcf12017-06-07 15:05:14 -0400752 // ES3 allows copying from non-zero mips
753 if (getClientMajorVersion() >= 3)
754 {
755 soureDestPairs.push_back(std::make_pair(1, 2));
756 }
Geoff Lang4f0e0032017-05-01 16:04:35 -0400757
Geoff Lang165dcf12017-06-07 15:05:14 -0400758 for (const auto &sourceDestPair : soureDestPairs)
759 {
760 const GLint sourceLevel = sourceDestPair.first;
761 const GLint destLevel = sourceDestPair.second;
Geoff Lang4f0e0032017-05-01 16:04:35 -0400762
Geoff Lang165dcf12017-06-07 15:05:14 -0400763 glCopyTextureCHROMIUM(textures[0], sourceLevel, GL_TEXTURE_2D, textures[1], destLevel,
764 GL_RGBA, GL_UNSIGNED_BYTE, false, false, false);
Geoff Lang4f0e0032017-05-01 16:04:35 -0400765
Geoff Lang165dcf12017-06-07 15:05:14 -0400766 EXPECT_GL_NO_ERROR();
Geoff Lang4f0e0032017-05-01 16:04:35 -0400767
Geoff Lang165dcf12017-06-07 15:05:14 -0400768 GLFramebuffer fbo;
769 glBindFramebuffer(GL_FRAMEBUFFER, fbo);
770 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textures[1],
771 destLevel);
772
773 // Check that FB is complete.
774 EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
775
776 EXPECT_PIXEL_COLOR_EQ(0, 0, pixels[0]);
777
778 EXPECT_GL_NO_ERROR();
779 }
Geoff Lang4f0e0032017-05-01 16:04:35 -0400780}
781
Geoff Langf81d17c2018-02-02 15:10:37 -0500782// Test that copying from an RGBA8 texture to RGBA4 results in exactly 4-bit precision in the result
783TEST_P(CopyTextureTest, DownsampleRGBA4444)
784{
785 // Downsampling on copy is only guarenteed on D3D11
786 ANGLE_SKIP_TEST_IF(!IsD3D11());
787
788 GLTexture textures[2];
789
790 GLColor pixels[] = {GLColor(0, 5, 6, 7), GLColor(17, 22, 25, 24), GLColor(34, 35, 36, 36),
791 GLColor(51, 53, 55, 55)};
792
793 glBindTexture(GL_TEXTURE_2D, textures[0]);
794 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
795
796 glBindTexture(GL_TEXTURE_2D, textures[1]);
797 glCopyTextureCHROMIUM(textures[0], 0, GL_TEXTURE_2D, textures[1], 0, GL_RGBA,
798 GL_UNSIGNED_SHORT_4_4_4_4, GL_FALSE, GL_FALSE, GL_FALSE);
799
800 GLFramebuffer fbo;
801 glBindFramebuffer(GL_FRAMEBUFFER, fbo);
802 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textures[1], 0);
803
804 EXPECT_PIXEL_COLOR_NEAR(0, 0, GLColor(0, 0, 0, 0), 1.0);
805 EXPECT_PIXEL_COLOR_NEAR(1, 0, GLColor(17, 17, 17, 17), 1.0);
806 EXPECT_PIXEL_COLOR_NEAR(0, 1, GLColor(34, 34, 34, 34), 1.0);
807 EXPECT_PIXEL_COLOR_NEAR(1, 1, GLColor(51, 51, 51, 51), 1.0);
808
809 testGradientDownsampleUniqueValues(GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, {16, 16, 16, 16});
810}
811
812// Test that copying from an RGBA8 texture to RGB565 results in exactly 4-bit precision in the
813// result
814TEST_P(CopyTextureTest, DownsampleRGB565)
815{
816 // Downsampling on copy is only guarenteed on D3D11
817 ANGLE_SKIP_TEST_IF(!IsD3D11());
818
819 GLTexture textures[2];
820
821 GLColor pixels[] = {GLColor(0, 5, 2, 14), GLColor(17, 22, 25, 30), GLColor(34, 33, 36, 46),
822 GLColor(50, 54, 49, 60)};
823
824 glBindTexture(GL_TEXTURE_2D, textures[0]);
825 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
826
827 glBindTexture(GL_TEXTURE_2D, textures[1]);
828 glCopyTextureCHROMIUM(textures[0], 0, GL_TEXTURE_2D, textures[1], 0, GL_RGB,
829 GL_UNSIGNED_SHORT_5_6_5, GL_FALSE, GL_FALSE, GL_FALSE);
830
831 GLFramebuffer fbo;
832 glBindFramebuffer(GL_FRAMEBUFFER, fbo);
833 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textures[1], 0);
834
835 EXPECT_PIXEL_COLOR_NEAR(0, 0, GLColor(0, 4, 0, 255), 1.0);
836 EXPECT_PIXEL_COLOR_NEAR(1, 0, GLColor(16, 20, 25, 255), 1.0);
837 EXPECT_PIXEL_COLOR_NEAR(0, 1, GLColor(33, 32, 33, 255), 1.0);
838 EXPECT_PIXEL_COLOR_NEAR(1, 1, GLColor(49, 53, 49, 255), 1.0);
839
840 testGradientDownsampleUniqueValues(GL_RGB, GL_UNSIGNED_SHORT_5_6_5, {32, 64, 32, 1});
841}
842
843// Test that copying from an RGBA8 texture to RGBA5551 results in exactly 4-bit precision in the
844// result
845TEST_P(CopyTextureTest, DownsampleRGBA5551)
846{
847 // Downsampling on copy is only guarenteed on D3D11
848 ANGLE_SKIP_TEST_IF(!IsD3D11());
849
850 GLTexture textures[2];
851
852 GLColor pixels[] = {GLColor(0, 1, 2, 3), GLColor(14, 16, 17, 18), GLColor(33, 34, 36, 46),
853 GLColor(50, 51, 52, 255)};
854
855 glBindTexture(GL_TEXTURE_2D, textures[0]);
856 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
857
858 glBindTexture(GL_TEXTURE_2D, textures[1]);
859 glCopyTextureCHROMIUM(textures[0], 0, GL_TEXTURE_2D, textures[1], 0, GL_RGBA,
860 GL_UNSIGNED_SHORT_5_5_5_1, GL_FALSE, GL_FALSE, GL_FALSE);
861
862 GLFramebuffer fbo;
863 glBindFramebuffer(GL_FRAMEBUFFER, fbo);
864 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textures[1], 0);
865
866 EXPECT_PIXEL_COLOR_NEAR(0, 0, GLColor(0, 0, 0, 0), 1.0);
867 EXPECT_PIXEL_COLOR_NEAR(1, 0, GLColor(16, 16, 16, 0), 1.0);
868 EXPECT_PIXEL_COLOR_NEAR(0, 1, GLColor(33, 33, 33, 0), 1.0);
869 EXPECT_PIXEL_COLOR_NEAR(1, 1, GLColor(49, 49, 49, 255), 1.0);
870
871 testGradientDownsampleUniqueValues(GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, {32, 32, 32, 2});
872}
873
Brandon Jones340b7b82017-06-26 13:02:31 -0700874// Test to ensure that CopyTexture works with LUMINANCE texture as a destination
875TEST_P(CopyTextureTestDest, Luminance)
876{
877 if (!checkExtensions())
878 {
879 return;
880 }
881
882 GLColor originalPixels(50u, 100u, 150u, 200u);
883 GLColor expectedPixels(50u, 50u, 50u, 255u);
884
885 // ReadPixels doesn't work with LUMINANCE (non-renderable), so we copy again back to an RGBA
886 // texture to verify contents.
887 glBindTexture(GL_TEXTURE_2D, mTextures[1]);
888 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &originalPixels);
889 glBindTexture(GL_TEXTURE_2D, mTextures[0]);
890 glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 1, 1, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, nullptr);
891
892 glCopyTextureCHROMIUM(mTextures[1], 0, GL_TEXTURE_2D, mTextures[0], 0, GL_LUMINANCE,
893 GL_UNSIGNED_BYTE, false, false, false);
894
895 EXPECT_GL_NO_ERROR();
896
897 glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA,
898 GL_UNSIGNED_BYTE, false, false, false);
899
900 EXPECT_GL_NO_ERROR();
901
902 EXPECT_PIXEL_COLOR_EQ(0, 0, expectedPixels);
903}
904
905// Test to ensure that CopyTexture works with LUMINANCE texture as a destination with
906// UnpackPremultiply parameter
907TEST_P(CopyTextureTestDest, LuminanceMultiply)
908{
909 if (!checkExtensions())
910 {
911 return;
912 }
913
914 GLColor originalPixels(50u, 100u, 150u, 200u);
915 GLColor expectedPixels(39u, 39u, 39u, 255u);
916
917 // ReadPixels doesn't work with LUMINANCE (non-renderable), so we copy again back to an RGBA
918 // texture to verify contents.
919 glBindTexture(GL_TEXTURE_2D, mTextures[1]);
920 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &originalPixels);
921 glBindTexture(GL_TEXTURE_2D, mTextures[0]);
922 glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 1, 1, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, nullptr);
923
924 glCopyTextureCHROMIUM(mTextures[1], 0, GL_TEXTURE_2D, mTextures[0], 0, GL_LUMINANCE,
925 GL_UNSIGNED_BYTE, false, true, false);
926
927 EXPECT_GL_NO_ERROR();
928
929 glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA,
930 GL_UNSIGNED_BYTE, false, false, false);
931
932 EXPECT_GL_NO_ERROR();
933
934 EXPECT_PIXEL_COLOR_EQ(0, 0, expectedPixels);
935}
936
937// Test to ensure that CopyTexture works with LUMINANCE texture as a destination with
938// UnpackUnmultiply parameter
939TEST_P(CopyTextureTestDest, LuminanceUnmultiply)
940{
941 if (!checkExtensions())
942 {
943 return;
944 }
945
946 GLColor originalPixels(50u, 100u, 150u, 200u);
947 GLColor expectedPixels(64u, 64u, 64u, 255u);
948
949 // ReadPixels doesn't work with LUMINANCE (non-renderable), so we copy again back to an RGBA
950 // texture to verify contents.
951 glBindTexture(GL_TEXTURE_2D, mTextures[1]);
952 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &originalPixels);
953 glBindTexture(GL_TEXTURE_2D, mTextures[0]);
954 glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 1, 1, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, nullptr);
955
956 glCopyTextureCHROMIUM(mTextures[1], 0, GL_TEXTURE_2D, mTextures[0], 0, GL_LUMINANCE,
957 GL_UNSIGNED_BYTE, false, false, true);
958
959 EXPECT_GL_NO_ERROR();
960
961 glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA,
962 GL_UNSIGNED_BYTE, false, false, false);
963
964 EXPECT_GL_NO_ERROR();
965
966 EXPECT_PIXEL_COLOR_EQ(0, 0, expectedPixels);
967}
968
969// Test to ensure that CopyTexture works with LUMINANCE_ALPHA texture as a destination
970TEST_P(CopyTextureTestDest, LuminanceAlpha)
971{
972 if (!checkExtensions())
973 {
974 return;
975 }
976
977 GLColor originalPixels(50u, 100u, 150u, 200u);
978 GLColor expectedPixels(50u, 50u, 50u, 200u);
979
980 // ReadPixels doesn't work with LUMINANCE_ALPHA (non-renderable), so we copy again back to an
981 // RGBA texture to verify contents.
982 glBindTexture(GL_TEXTURE_2D, mTextures[1]);
983 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &originalPixels);
984 glBindTexture(GL_TEXTURE_2D, mTextures[0]);
985 glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, 1, 1, 0, GL_LUMINANCE_ALPHA,
986 GL_UNSIGNED_BYTE, nullptr);
987
988 glCopyTextureCHROMIUM(mTextures[1], 0, GL_TEXTURE_2D, mTextures[0], 0, GL_LUMINANCE_ALPHA,
989 GL_UNSIGNED_BYTE, false, false, false);
990
991 EXPECT_GL_NO_ERROR();
992
993 glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA,
994 GL_UNSIGNED_BYTE, false, false, false);
995
996 EXPECT_PIXEL_COLOR_EQ(0, 0, expectedPixels);
997}
998
999// Test to ensure that CopyTexture works with LUMINANCE_ALPHA texture as a destination with
1000// UnpackPremultiply parameter
1001TEST_P(CopyTextureTestDest, LuminanceAlphaMultiply)
1002{
1003 if (!checkExtensions())
1004 {
1005 return;
1006 }
1007
1008 GLColor originalPixels(50u, 100u, 150u, 200u);
1009 GLColor expectedPixels(39u, 39u, 39u, 200u);
1010
1011 // ReadPixels doesn't work with LUMINANCE_ALPHA (non-renderable), so we copy again back to an
1012 // RGBA texture to verify contents.
1013 glBindTexture(GL_TEXTURE_2D, mTextures[1]);
1014 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &originalPixels);
1015 glBindTexture(GL_TEXTURE_2D, mTextures[0]);
1016 glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, 1, 1, 0, GL_LUMINANCE_ALPHA,
1017 GL_UNSIGNED_BYTE, nullptr);
1018
1019 glCopyTextureCHROMIUM(mTextures[1], 0, GL_TEXTURE_2D, mTextures[0], 0, GL_LUMINANCE_ALPHA,
1020 GL_UNSIGNED_BYTE, false, true, false);
1021
1022 EXPECT_GL_NO_ERROR();
1023
1024 glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA,
1025 GL_UNSIGNED_BYTE, false, false, false);
1026
1027 EXPECT_PIXEL_COLOR_EQ(0, 0, expectedPixels);
1028}
1029
1030// Test to ensure that CopyTexture works with LUMINANCE_ALPHA texture as a destination with
1031// UnpackUnmultiplyAlpha parameter
1032TEST_P(CopyTextureTestDest, LuminanceAlphaUnmultiply)
1033{
1034 if (!checkExtensions())
1035 {
1036 return;
1037 }
1038
1039 GLColor originalPixels(50u, 100u, 150u, 200u);
1040 GLColor expectedPixels(64u, 64u, 64u, 200u);
1041
1042 // ReadPixels doesn't work with LUMINANCE_ALPHA (non-renderable), so we copy again back to an
1043 // RGBA texture to verify contents.
1044 glBindTexture(GL_TEXTURE_2D, mTextures[1]);
1045 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &originalPixels);
1046 glBindTexture(GL_TEXTURE_2D, mTextures[0]);
1047 glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, 1, 1, 0, GL_LUMINANCE_ALPHA,
1048 GL_UNSIGNED_BYTE, nullptr);
1049
1050 glCopyTextureCHROMIUM(mTextures[1], 0, GL_TEXTURE_2D, mTextures[0], 0, GL_LUMINANCE_ALPHA,
1051 GL_UNSIGNED_BYTE, false, false, true);
1052
1053 EXPECT_GL_NO_ERROR();
1054
1055 glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA,
1056 GL_UNSIGNED_BYTE, false, false, false);
1057
1058 EXPECT_GL_NO_ERROR();
1059
1060 EXPECT_PIXEL_COLOR_EQ(0, 0, expectedPixels);
1061}
1062
1063// Test to ensure that CopyTexture works with ALPHA texture as a destination
1064TEST_P(CopyTextureTestDest, Alpha)
1065{
1066 if (!checkExtensions())
1067 {
1068 return;
1069 }
1070
1071 GLColor originalPixels(50u, 100u, 150u, 155u);
1072 GLColor expectedPixels(0u, 0u, 0u, 155u);
1073
1074 // ReadPixels doesn't work with ALPHA (non-renderable), so we copy again back to an RGBA
1075 // texture to verify contents.
1076 glBindTexture(GL_TEXTURE_2D, mTextures[1]);
1077 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &originalPixels);
1078 glBindTexture(GL_TEXTURE_2D, mTextures[0]);
1079 glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, 1, 1, 0, GL_ALPHA, GL_UNSIGNED_BYTE, nullptr);
1080
1081 glCopyTextureCHROMIUM(mTextures[1], 0, GL_TEXTURE_2D, mTextures[0], 0, GL_ALPHA,
1082 GL_UNSIGNED_BYTE, false, false, false);
1083
1084 EXPECT_GL_NO_ERROR();
1085
1086 glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA,
1087 GL_UNSIGNED_BYTE, false, false, false);
1088
1089 EXPECT_GL_NO_ERROR();
1090
1091 EXPECT_PIXEL_COLOR_EQ(0, 0, expectedPixels);
1092}
1093
1094// Test to ensure that CopyTexture works with ALPHA texture as a destination with
1095// UnpackPremultiplyAlpha parameter
1096TEST_P(CopyTextureTestDest, AlphaMultiply)
1097{
1098 if (!checkExtensions())
1099 {
1100 return;
1101 }
1102
1103 GLColor originalPixels(50u, 100u, 150u, 155u);
1104 GLColor expectedPixels(0u, 0u, 0u, 155u);
1105
1106 // ReadPixels doesn't work with ALPHA (non-renderable), so we copy again back to an RGBA
1107 // texture to verify contents.
1108 glBindTexture(GL_TEXTURE_2D, mTextures[1]);
1109 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &originalPixels);
1110 glBindTexture(GL_TEXTURE_2D, mTextures[0]);
1111 glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, 1, 1, 0, GL_ALPHA, GL_UNSIGNED_BYTE, nullptr);
1112
1113 glCopyTextureCHROMIUM(mTextures[1], 0, GL_TEXTURE_2D, mTextures[0], 0, GL_ALPHA,
1114 GL_UNSIGNED_BYTE, false, true, false);
1115
1116 EXPECT_GL_NO_ERROR();
1117
1118 glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA,
1119 GL_UNSIGNED_BYTE, false, false, false);
1120
1121 EXPECT_GL_NO_ERROR();
1122
1123 EXPECT_PIXEL_COLOR_EQ(0, 0, expectedPixels);
1124}
1125
1126// Test to ensure that CopyTexture works with ALPHA texture as a destination with
1127// UnpackUnmultiplyAlpha parameter
1128TEST_P(CopyTextureTestDest, AlphaUnmultiply)
1129{
1130 if (!checkExtensions())
1131 {
1132 return;
1133 }
1134
1135 GLColor originalPixels(50u, 100u, 150u, 155u);
1136 GLColor expectedPixels(0u, 0u, 0u, 155u);
1137
1138 // ReadPixels doesn't work with ALPHA (non-renderable), so we copy again back to an RGBA
1139 // texture to verify contents.
1140 glBindTexture(GL_TEXTURE_2D, mTextures[1]);
1141 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &originalPixels);
1142 glBindTexture(GL_TEXTURE_2D, mTextures[0]);
1143 glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, 1, 1, 0, GL_ALPHA, GL_UNSIGNED_BYTE, nullptr);
1144
1145 glCopyTextureCHROMIUM(mTextures[1], 0, GL_TEXTURE_2D, mTextures[0], 0, GL_ALPHA,
1146 GL_UNSIGNED_BYTE, false, false, true);
1147
1148 EXPECT_GL_NO_ERROR();
1149
1150 glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA,
1151 GL_UNSIGNED_BYTE, false, false, false);
1152
1153 EXPECT_GL_NO_ERROR();
1154
1155 EXPECT_PIXEL_COLOR_EQ(0, 0, expectedPixels);
1156}
1157
Brandon Jones92a14592017-11-16 10:01:08 -08001158// Test to ensure that CopyTexture uses the correct ALPHA passthrough shader to ensure RGB channels
1159// are set to 0.
1160TEST_P(CopyTextureTestDest, AlphaCopyWithRGB)
1161{
1162 ANGLE_SKIP_TEST_IF(!checkExtensions());
1163
1164 GLColor originalPixels(50u, 100u, 150u, 155u);
1165 GLColor expectedPixels(0u, 0u, 0u, 155u);
1166
1167 // ReadPixels doesn't work with ALPHA (non-renderable), so we copy again back to an RGBA
1168 // texture to verify contents.
1169 glBindTexture(GL_TEXTURE_2D, mTextures[1]);
1170 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &originalPixels);
1171 glBindTexture(GL_TEXTURE_2D, mTextures[0]);
1172 glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, 1, 1, 0, GL_ALPHA, GL_HALF_FLOAT_OES, nullptr);
1173
1174 glCopyTextureCHROMIUM(mTextures[1], 0, GL_TEXTURE_2D, mTextures[0], 0, GL_ALPHA,
1175 GL_HALF_FLOAT_OES, false, false, false);
1176
1177 EXPECT_GL_NO_ERROR();
1178
1179 glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA,
1180 GL_UNSIGNED_BYTE, false, false, false);
1181
1182 EXPECT_GL_NO_ERROR();
1183
1184 EXPECT_PIXEL_COLOR_EQ(0, 0, expectedPixels);
1185}
1186
Brandon Jones28783792018-03-05 09:37:32 -08001187// Test to ensure that CopyTexture will fail with a non-zero level and NPOT texture in WebGL
1188TEST_P(CopyTextureTestWebGL, NPOT)
1189{
1190 if (extensionRequestable("GL_CHROMIUM_copy_texture"))
1191 {
1192 glRequestExtensionANGLE("GL_CHROMIUM_copy_texture");
1193 }
1194 ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_CHROMIUM_copy_texture"));
1195
1196 std::vector<GLColor> pixelData(10 * 10, GLColor::red);
1197
1198 glBindTexture(GL_TEXTURE_2D, mTextures[0]);
1199 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 10, 10, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixelData.data());
1200
1201 // Do a basic copy to make sure things work
1202 glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA,
1203 GL_UNSIGNED_BYTE, false, false, false);
1204
1205 EXPECT_GL_NO_ERROR();
1206
1207 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red);
1208
1209 // Do the same operation with destLevel 1, which should fail
1210 glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 1, GL_RGBA,
1211 GL_UNSIGNED_BYTE, false, false, false);
1212
1213 EXPECT_GL_ERROR(GL_INVALID_VALUE);
1214}
1215
Geoff Lang4f0e0032017-05-01 16:04:35 -04001216// Test the newly added ES3 unorm formats
1217TEST_P(CopyTextureTestES3, ES3UnormFormats)
1218{
1219 if (!checkExtensions())
1220 {
1221 return;
1222 }
1223
1224 auto testOutput = [this](GLuint texture, const GLColor &expectedColor) {
Jamie Madill35cd7332018-12-02 12:03:33 -05001225 constexpr char kVS[] =
Geoff Lang4f0e0032017-05-01 16:04:35 -04001226 "#version 300 es\n"
1227 "in vec4 position;\n"
1228 "out vec2 texcoord;\n"
1229 "void main()\n"
1230 "{\n"
1231 " gl_Position = vec4(position.xy, 0.0, 1.0);\n"
1232 " texcoord = (position.xy * 0.5) + 0.5;\n"
1233 "}\n";
1234
Jamie Madill35cd7332018-12-02 12:03:33 -05001235 constexpr char kFS[] =
Geoff Lang4f0e0032017-05-01 16:04:35 -04001236 "#version 300 es\n"
1237 "precision mediump float;\n"
1238 "uniform sampler2D tex;\n"
1239 "in vec2 texcoord;\n"
1240 "out vec4 color;\n"
1241 "void main()\n"
1242 "{\n"
1243 " color = texture(tex, texcoord);\n"
1244 "}\n";
1245
Jamie Madill35cd7332018-12-02 12:03:33 -05001246 ANGLE_GL_PROGRAM(program, kVS, kFS);
Geoff Lang4f0e0032017-05-01 16:04:35 -04001247 glUseProgram(program);
1248
1249 GLRenderbuffer rbo;
1250 glBindRenderbuffer(GL_RENDERBUFFER, rbo);
1251 glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, 1, 1);
1252
1253 GLFramebuffer fbo;
1254 glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1255 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo);
1256
1257 glActiveTexture(GL_TEXTURE0);
1258 glBindTexture(GL_TEXTURE_2D, texture);
1259 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1260 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1261 glUniform1i(glGetUniformLocation(program.get(), "tex"), 0);
1262
1263 drawQuad(program, "position", 0.5f, 1.0f, true);
1264
1265 EXPECT_PIXEL_COLOR_NEAR(0, 0, expectedColor, 1.0);
1266 };
1267
1268 auto testCopyCombination = [this, testOutput](GLenum sourceInternalFormat, GLenum sourceFormat,
1269 GLenum sourceType, const GLColor &sourceColor,
1270 GLenum destInternalFormat, GLenum destType,
1271 bool flipY, bool premultiplyAlpha,
1272 bool unmultiplyAlpha,
1273 const GLColor &expectedColor) {
Geoff Lang4f0e0032017-05-01 16:04:35 -04001274 GLTexture sourceTexture;
1275 glBindTexture(GL_TEXTURE_2D, sourceTexture);
1276 glTexImage2D(GL_TEXTURE_2D, 0, sourceInternalFormat, 1, 1, 0, sourceFormat, sourceType,
1277 &sourceColor);
1278
1279 GLTexture destTexture;
1280 glBindTexture(GL_TEXTURE_2D, destTexture);
1281
1282 glCopyTextureCHROMIUM(sourceTexture, 0, GL_TEXTURE_2D, destTexture, 0, destInternalFormat,
1283 destType, flipY, premultiplyAlpha, unmultiplyAlpha);
1284 ASSERT_GL_NO_ERROR();
1285
1286 testOutput(destTexture, expectedColor);
1287 };
1288
Geoff Lang00689192018-03-27 17:34:20 -04001289 auto testSubCopyCombination = [this, testOutput](
1290 GLenum sourceInternalFormat, GLenum sourceFormat,
1291 GLenum sourceType, const GLColor &sourceColor,
1292 GLenum destInternalFormat, GLenum destFormat, GLenum destType,
1293 bool flipY, bool premultiplyAlpha, bool unmultiplyAlpha,
1294 const GLColor &expectedColor) {
Geoff Lang00689192018-03-27 17:34:20 -04001295 GLTexture sourceTexture;
1296 glBindTexture(GL_TEXTURE_2D, sourceTexture);
1297 glTexImage2D(GL_TEXTURE_2D, 0, sourceInternalFormat, 1, 1, 0, sourceFormat, sourceType,
1298 &sourceColor);
1299
1300 GLTexture destTexture;
1301 glBindTexture(GL_TEXTURE_2D, destTexture);
1302
1303 glTexImage2D(GL_TEXTURE_2D, 0, destInternalFormat, 1, 1, 0, destFormat, destType, nullptr);
1304 glCopySubTextureCHROMIUM(sourceTexture, 0, GL_TEXTURE_2D, destTexture, 0, 0, 0, 0, 0, 1, 1,
1305 flipY, premultiplyAlpha, unmultiplyAlpha);
1306 ASSERT_GL_NO_ERROR();
1307
1308 testOutput(destTexture, expectedColor);
1309 };
1310
Geoff Lang4f0e0032017-05-01 16:04:35 -04001311 // New LUMA source formats
1312 testCopyCombination(GL_LUMINANCE, GL_LUMINANCE, GL_UNSIGNED_BYTE, GLColor(128, 0, 0, 0), GL_RGB,
1313 GL_UNSIGNED_BYTE, false, false, false, GLColor(128, 128, 128, 255));
1314 testCopyCombination(GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE,
1315 GLColor(128, 64, 0, 0), GL_RGB, GL_UNSIGNED_BYTE, false, false, false,
1316 GLColor(128, 128, 128, 255));
1317 testCopyCombination(GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE,
1318 GLColor(128, 64, 0, 0), GL_RGB, GL_UNSIGNED_BYTE, false, true, false,
1319 GLColor(32, 32, 32, 255));
1320 testCopyCombination(GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE,
1321 GLColor(128, 128, 0, 0), GL_RGB, GL_UNSIGNED_BYTE, false, false, true,
1322 GLColor(255, 255, 255, 255));
1323 testCopyCombination(GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE, GLColor(128, 0, 0, 0), GL_RGBA,
1324 GL_UNSIGNED_BYTE, false, false, false, GLColor(0, 0, 0, 128));
1325 testCopyCombination(GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE, GLColor(128, 0, 0, 0), GL_RGBA,
1326 GL_UNSIGNED_BYTE, false, false, true, GLColor(0, 0, 0, 128));
1327 testCopyCombination(GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE, GLColor(128, 0, 0, 0), GL_RGBA,
1328 GL_UNSIGNED_BYTE, false, true, false, GLColor(0, 0, 0, 128));
1329
1330 // New sRGB dest formats
Geoff Lang7198ebc2018-11-22 14:36:06 -05001331 if (extensionEnabled("GL_EXT_sRGB"))
1332 {
1333 testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_SRGB,
1334 GL_UNSIGNED_BYTE, false, false, false, GLColor(55, 13, 4, 255));
1335 testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_SRGB,
1336 GL_UNSIGNED_BYTE, false, true, false, GLColor(13, 4, 1, 255));
1337 testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128),
1338 GL_SRGB_ALPHA_EXT, GL_UNSIGNED_BYTE, false, false, false,
1339 GLColor(55, 13, 4, 128));
Geoff Lang00689192018-03-27 17:34:20 -04001340
Geoff Lang7198ebc2018-11-22 14:36:06 -05001341 testSubCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128),
1342 GL_SRGB, GL_SRGB, GL_UNSIGNED_BYTE, false, false, false,
1343 GLColor(55, 13, 4, 255));
1344 testSubCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128),
1345 GL_SRGB, GL_SRGB, GL_UNSIGNED_BYTE, false, true, false,
1346 GLColor(13, 4, 1, 255));
1347 testSubCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128),
1348 GL_SRGB_ALPHA_EXT, GL_SRGB_ALPHA_EXT, GL_UNSIGNED_BYTE, false, false,
1349 false, GLColor(55, 13, 4, 128));
1350 }
Geoff Lang4f0e0032017-05-01 16:04:35 -04001351}
1352
1353// Test the newly added ES3 float formats
1354TEST_P(CopyTextureTestES3, ES3FloatFormats)
1355{
1356 if (!checkExtensions())
1357 {
1358 return;
1359 }
1360
Yunchao He9550c602018-02-13 14:47:05 +08001361 ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_EXT_color_buffer_float"));
Geoff Lang4f0e0032017-05-01 16:04:35 -04001362
1363 auto testOutput = [this](GLuint texture, const GLColor32F &expectedColor) {
Jamie Madill35cd7332018-12-02 12:03:33 -05001364 constexpr char kVS[] =
Geoff Lang4f0e0032017-05-01 16:04:35 -04001365 "#version 300 es\n"
1366 "in vec4 position;\n"
1367 "out vec2 texcoord;\n"
1368 "void main()\n"
1369 "{\n"
1370 " gl_Position = vec4(position.xy, 0.0, 1.0);\n"
1371 " texcoord = (position.xy * 0.5) + 0.5;\n"
1372 "}\n";
1373
Jamie Madill35cd7332018-12-02 12:03:33 -05001374 constexpr char kFS[] =
Geoff Lang4f0e0032017-05-01 16:04:35 -04001375 "#version 300 es\n"
1376 "precision mediump float;\n"
1377 "uniform sampler2D tex;\n"
1378 "in vec2 texcoord;\n"
1379 "out vec4 color;\n"
1380 "void main()\n"
1381 "{\n"
1382 " color = texture(tex, texcoord);\n"
1383 "}\n";
1384
Jamie Madill35cd7332018-12-02 12:03:33 -05001385 ANGLE_GL_PROGRAM(program, kVS, kFS);
Geoff Lang4f0e0032017-05-01 16:04:35 -04001386 glUseProgram(program);
1387
1388 GLRenderbuffer rbo;
1389 glBindRenderbuffer(GL_RENDERBUFFER, rbo);
1390 glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA32F, 1, 1);
1391
1392 GLFramebuffer fbo;
1393 glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1394 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo);
1395
1396 glActiveTexture(GL_TEXTURE0);
1397 glBindTexture(GL_TEXTURE_2D, texture);
1398 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1399 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1400 glUniform1i(glGetUniformLocation(program.get(), "tex"), 0);
1401
1402 drawQuad(program, "position", 0.5f, 1.0f, true);
1403
1404 EXPECT_PIXEL_COLOR32F_NEAR(0, 0, expectedColor, 0.05);
1405 };
1406
1407 auto testCopyCombination = [this, testOutput](GLenum sourceInternalFormat, GLenum sourceFormat,
1408 GLenum sourceType, const GLColor &sourceColor,
1409 GLenum destInternalFormat, GLenum destType,
1410 bool flipY, bool premultiplyAlpha,
1411 bool unmultiplyAlpha,
1412 const GLColor32F &expectedColor) {
Geoff Lang4f0e0032017-05-01 16:04:35 -04001413 GLTexture sourceTexture;
1414 glBindTexture(GL_TEXTURE_2D, sourceTexture);
1415 glTexImage2D(GL_TEXTURE_2D, 0, sourceInternalFormat, 1, 1, 0, sourceFormat, sourceType,
1416 &sourceColor);
1417
1418 GLTexture destTexture;
1419 glBindTexture(GL_TEXTURE_2D, destTexture);
1420
1421 glCopyTextureCHROMIUM(sourceTexture, 0, GL_TEXTURE_2D, destTexture, 0, destInternalFormat,
1422 destType, flipY, premultiplyAlpha, unmultiplyAlpha);
1423 ASSERT_GL_NO_ERROR();
1424
1425 testOutput(destTexture, expectedColor);
1426 };
1427
1428 testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RGBA32F,
1429 GL_FLOAT, false, false, false, GLColor32F(0.5f, 0.25f, 0.125f, 0.5f));
1430 testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RGBA32F,
1431 GL_FLOAT, false, true, false, GLColor32F(0.25f, 0.125f, 0.0625f, 0.5f));
1432 testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RGBA32F,
1433 GL_FLOAT, false, false, true, GLColor32F(1.0f, 0.5f, 0.25f, 0.5f));
1434
1435 testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_R16F,
1436 GL_FLOAT, false, false, false, GLColor32F(0.5f, 0.0f, 0.0f, 1.0f));
1437 testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_R16F,
1438 GL_FLOAT, false, true, false, GLColor32F(0.25f, 0.0f, 0.0f, 1.0f));
1439 testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_R16F,
1440 GL_FLOAT, false, false, true, GLColor32F(1.0f, 0.0f, 0.0f, 1.0f));
1441
1442 testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RG16F,
1443 GL_FLOAT, false, false, false, GLColor32F(0.5f, 0.25f, 0.0f, 1.0f));
1444 testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RG16F,
1445 GL_FLOAT, false, true, false, GLColor32F(0.25f, 0.125f, 0.0f, 1.0f));
1446 testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RG16F,
1447 GL_FLOAT, false, false, true, GLColor32F(1.0f, 0.5f, 0.0f, 1.0f));
1448
1449 testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RGB16F,
1450 GL_FLOAT, false, false, false, GLColor32F(0.5f, 0.25f, 0.125f, 1.0f));
1451 testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RGB16F,
1452 GL_FLOAT, false, true, false, GLColor32F(0.25f, 0.125f, 0.0625f, 1.0f));
1453 testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RGB16F,
1454 GL_FLOAT, false, false, true, GLColor32F(1.0f, 0.5f, 0.25f, 1.0f));
1455
1456 testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128),
1457 GL_R11F_G11F_B10F, GL_FLOAT, false, false, false,
1458 GLColor32F(0.5f, 0.25f, 0.125f, 1.0f));
1459 testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128),
1460 GL_R11F_G11F_B10F, GL_FLOAT, false, true, false,
1461 GLColor32F(0.25f, 0.125f, 0.0625f, 1.0f));
1462 testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128),
1463 GL_R11F_G11F_B10F, GL_FLOAT, false, false, true,
1464 GLColor32F(1.0f, 0.5f, 0.25f, 1.0f));
1465
Geoff Langaadc8f32017-08-11 17:34:44 -04001466 testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RGB9_E5,
1467 GL_FLOAT, false, false, false, GLColor32F(0.5f, 0.25f, 0.125f, 1.0f));
1468 testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RGB9_E5,
1469 GL_FLOAT, false, true, false, GLColor32F(0.25f, 0.125f, 0.0625f, 1.0f));
1470 testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RGB9_E5,
1471 GL_FLOAT, false, false, true, GLColor32F(1.0f, 0.5f, 0.25f, 1.0f));
Geoff Lang4f0e0032017-05-01 16:04:35 -04001472}
1473
1474// Test the newly added ES3 unsigned integer formats
1475TEST_P(CopyTextureTestES3, ES3UintFormats)
1476{
Jamie Madill3dfaf262017-08-18 12:32:14 -04001477 ANGLE_SKIP_TEST_IF(IsLinux() && IsOpenGL() && IsIntel());
1478
Geoff Lang4f0e0032017-05-01 16:04:35 -04001479 if (!checkExtensions())
1480 {
1481 return;
1482 }
1483
Geoff Lang4f0e0032017-05-01 16:04:35 -04001484 using GLColor32U = std::tuple<GLuint, GLuint, GLuint, GLuint>;
1485
1486 auto testOutput = [this](GLuint texture, const GLColor32U &expectedColor) {
Jamie Madill35cd7332018-12-02 12:03:33 -05001487 constexpr char kVS[] =
Geoff Lang4f0e0032017-05-01 16:04:35 -04001488 "#version 300 es\n"
1489 "in vec4 position;\n"
1490 "out vec2 texcoord;\n"
1491 "void main()\n"
1492 "{\n"
1493 " gl_Position = vec4(position.xy, 0.0, 1.0);\n"
1494 " texcoord = (position.xy * 0.5) + 0.5;\n"
1495 "}\n";
1496
Jamie Madill35cd7332018-12-02 12:03:33 -05001497 constexpr char kFS[] =
Geoff Lang4f0e0032017-05-01 16:04:35 -04001498 "#version 300 es\n"
1499 "precision mediump float;\n"
1500 "precision mediump usampler2D;\n"
1501 "in vec2 texcoord;\n"
1502 "uniform usampler2D tex;\n"
1503 "out uvec4 color;\n"
1504 "void main()\n"
1505 "{\n"
1506 " color = texture(tex, texcoord);\n"
1507 "}\n";
1508
Jamie Madill35cd7332018-12-02 12:03:33 -05001509 ANGLE_GL_PROGRAM(program, kVS, kFS);
Geoff Lang4f0e0032017-05-01 16:04:35 -04001510 glUseProgram(program);
1511
1512 GLRenderbuffer rbo;
1513 glBindRenderbuffer(GL_RENDERBUFFER, rbo);
1514 glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8UI, 1, 1);
1515
1516 GLFramebuffer fbo;
1517 glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1518 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo);
1519
1520 glActiveTexture(GL_TEXTURE0);
1521 glBindTexture(GL_TEXTURE_2D, texture);
1522 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1523 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1524 glUniform1i(glGetUniformLocation(program.get(), "tex"), 0);
1525
1526 drawQuad(program, "position", 0.5f, 1.0f, true);
1527 ASSERT_GL_NO_ERROR();
1528
1529 GLuint pixel[4] = {0};
1530 glReadPixels(0, 0, 1, 1, GL_RGBA_INTEGER, GL_UNSIGNED_INT, pixel);
1531 ASSERT_GL_NO_ERROR();
1532 EXPECT_NEAR(std::get<0>(expectedColor), pixel[0], 1);
1533 EXPECT_NEAR(std::get<1>(expectedColor), pixel[1], 1);
1534 EXPECT_NEAR(std::get<2>(expectedColor), pixel[2], 1);
1535 EXPECT_NEAR(std::get<3>(expectedColor), pixel[3], 1);
1536 };
1537
1538 auto testCopyCombination = [this, testOutput](GLenum sourceInternalFormat, GLenum sourceFormat,
1539 GLenum sourceType, const GLColor &sourceColor,
1540 GLenum destInternalFormat, GLenum destType,
1541 bool flipY, bool premultiplyAlpha,
1542 bool unmultiplyAlpha,
1543 const GLColor32U &expectedColor) {
Geoff Lang4f0e0032017-05-01 16:04:35 -04001544 GLTexture sourceTexture;
1545 glBindTexture(GL_TEXTURE_2D, sourceTexture);
1546 glTexImage2D(GL_TEXTURE_2D, 0, sourceInternalFormat, 1, 1, 0, sourceFormat, sourceType,
1547 &sourceColor);
1548
1549 GLTexture destTexture;
1550 glBindTexture(GL_TEXTURE_2D, destTexture);
1551
1552 glCopyTextureCHROMIUM(sourceTexture, 0, GL_TEXTURE_2D, destTexture, 0, destInternalFormat,
1553 destType, flipY, premultiplyAlpha, unmultiplyAlpha);
1554 ASSERT_GL_NO_ERROR();
1555
1556 testOutput(destTexture, expectedColor);
1557 };
1558
1559 testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RGBA8UI,
1560 GL_UNSIGNED_BYTE, false, false, false, GLColor32U(128, 64, 32, 128));
1561 testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RGBA8UI,
1562 GL_UNSIGNED_BYTE, false, true, false, GLColor32U(64, 32, 16, 128));
1563 testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RGBA8UI,
1564 GL_UNSIGNED_BYTE, false, false, true, GLColor32U(255, 128, 64, 128));
1565
Geoff Langaadc8f32017-08-11 17:34:44 -04001566 testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RGB8UI,
1567 GL_UNSIGNED_BYTE, false, false, false, GLColor32U(128, 64, 32, 1));
1568 testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RGB8UI,
1569 GL_UNSIGNED_BYTE, false, true, false, GLColor32U(64, 32, 16, 1));
1570 testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RGB8UI,
1571 GL_UNSIGNED_BYTE, false, false, true, GLColor32U(255, 128, 64, 1));
Geoff Lang4f0e0032017-05-01 16:04:35 -04001572
1573 testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RG8UI,
1574 GL_UNSIGNED_BYTE, false, false, false, GLColor32U(128, 64, 0, 1));
1575 testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RG8UI,
1576 GL_UNSIGNED_BYTE, false, true, false, GLColor32U(64, 32, 0, 1));
1577 testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RG8UI,
1578 GL_UNSIGNED_BYTE, false, false, true, GLColor32U(255, 128, 0, 1));
1579
1580 testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_R8UI,
1581 GL_UNSIGNED_BYTE, false, false, false, GLColor32U(128, 0, 0, 1));
1582 testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_R8UI,
1583 GL_UNSIGNED_BYTE, false, true, false, GLColor32U(64, 0, 0, 1));
1584 testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(120, 64, 32, 128), GL_R8UI,
1585 GL_UNSIGNED_BYTE, false, false, true, GLColor32U(240, 0, 0, 1));
1586}
1587
Geoff Lang97073d12016-04-20 10:42:34 -07001588// Use this to select which configurations (e.g. which renderer, which GLES major version) these
1589// tests should be run against.
Luc Ferronaf883622018-06-08 15:57:31 -04001590ANGLE_INSTANTIATE_TEST(CopyTextureTest,
1591 ES2_D3D9(),
1592 ES2_D3D11(),
1593 ES2_OPENGL(),
1594 ES2_OPENGLES(),
1595 ES2_VULKAN());
1596ANGLE_INSTANTIATE_TEST(CopyTextureTestWebGL,
1597 ES2_D3D9(),
1598 ES2_D3D11(),
1599 ES2_OPENGL(),
1600 ES2_OPENGLES(),
1601 ES2_VULKAN());
Brandon Jones340b7b82017-06-26 13:02:31 -07001602ANGLE_INSTANTIATE_TEST(CopyTextureTestDest, ES2_D3D11());
Geoff Lang4f0e0032017-05-01 16:04:35 -04001603ANGLE_INSTANTIATE_TEST(CopyTextureTestES3, ES3_D3D11(), ES3_OPENGL(), ES3_OPENGLES());
Geoff Lang97073d12016-04-20 10:42:34 -07001604
1605} // namespace angle