blob: 478a72bd05ede6519304e085a843b8423d553578 [file] [log] [blame]
Jamie Madillfa05f602015-05-07 13:47:11 -04001//
2// Copyright 2015 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
Corentin Wallezd3970de2015-05-14 11:07:48 -04007#include "test_utils/ANGLETest.h"
Jamie Madillf67115c2014-04-22 13:14:05 -04008
Jamie Madillfa05f602015-05-07 13:47:11 -04009using namespace angle;
Austin Kinross18b931d2014-09-29 12:58:31 -070010
Jamie Madillfa05f602015-05-07 13:47:11 -040011namespace
12{
13
Olli Etuaho356f5162016-03-18 14:19:41 +020014template <typename T>
15void FillWithRGBA(size_t pixelCount, T red, T green, T blue, T alpha, T *outArray)
16{
17 for (size_t i = 0u; i < pixelCount; ++i)
18 {
19 outArray[i * 4u] = red;
20 outArray[i * 4u + 1u] = green;
21 outArray[i * 4u + 2u] = blue;
22 outArray[i * 4u + 3u] = alpha;
23 }
24}
25
Olli Etuaho4a8329f2016-01-11 17:12:57 +020026class TexCoordDrawTest : public ANGLETest
Jamie Madillf67115c2014-04-22 13:14:05 -040027{
Jamie Madillbc393df2015-01-29 13:46:07 -050028 protected:
Olli Etuaho51f1c0f2016-01-13 16:16:24 +020029 TexCoordDrawTest() : ANGLETest(), mProgram(0), mFramebuffer(0), mFramebufferColorTexture(0)
Jamie Madillf67115c2014-04-22 13:14:05 -040030 {
31 setWindowWidth(128);
32 setWindowHeight(128);
33 setConfigRedBits(8);
34 setConfigGreenBits(8);
35 setConfigBlueBits(8);
36 setConfigAlphaBits(8);
37 }
38
Olli Etuaho4a8329f2016-01-11 17:12:57 +020039 virtual std::string getVertexShaderSource()
Jamie Madillf67115c2014-04-22 13:14:05 -040040 {
Olli Etuaho4a8329f2016-01-11 17:12:57 +020041 return std::string(SHADER_SOURCE
Geoff Langc41e42d2014-04-28 10:58:16 -040042 (
43 precision highp float;
44 attribute vec4 position;
45 varying vec2 texcoord;
46
47 void main()
48 {
Olli Etuaho4a8329f2016-01-11 17:12:57 +020049 gl_Position = vec4(position.xy, 0.0, 1.0);
Geoff Langc41e42d2014-04-28 10:58:16 -040050 texcoord = (position.xy * 0.5) + 0.5;
51 }
Olli Etuaho4a8329f2016-01-11 17:12:57 +020052 )
Geoff Langc41e42d2014-04-28 10:58:16 -040053 );
Olli Etuaho4a8329f2016-01-11 17:12:57 +020054 }
Geoff Langc41e42d2014-04-28 10:58:16 -040055
Olli Etuaho4a8329f2016-01-11 17:12:57 +020056 virtual std::string getFragmentShaderSource() = 0;
57
58 void SetUp() override
59 {
60 ANGLETest::SetUp();
61 const std::string vertexShaderSource = getVertexShaderSource();
62 const std::string fragmentShaderSource = getFragmentShaderSource();
63
64 mProgram = CompileProgram(vertexShaderSource, fragmentShaderSource);
65 ASSERT_NE(0u, mProgram);
66 ASSERT_GL_NO_ERROR();
Olli Etuaho51f1c0f2016-01-13 16:16:24 +020067
68 setUpFramebuffer();
Olli Etuaho4a8329f2016-01-11 17:12:57 +020069 }
70
71 void TearDown() override
72 {
Olli Etuaho51f1c0f2016-01-13 16:16:24 +020073 glBindFramebuffer(GL_FRAMEBUFFER, 0);
74 glDeleteFramebuffers(1, &mFramebuffer);
75 glDeleteTextures(1, &mFramebufferColorTexture);
Olli Etuaho4a8329f2016-01-11 17:12:57 +020076 glDeleteProgram(mProgram);
77 ANGLETest::TearDown();
78 }
79
Olli Etuaho51f1c0f2016-01-13 16:16:24 +020080 void setUpFramebuffer()
81 {
82 // We use an FBO to work around an issue where the default framebuffer applies SRGB
83 // conversion (particularly known to happen incorrectly on Intel GL drivers). It's not
84 // clear whether this issue can even be fixed on all backends. For example GLES 3.0.4 spec
85 // section 4.4 says that the format of the default framebuffer is entirely up to the window
86 // system, so it might be SRGB, and GLES 3.0 doesn't have a "FRAMEBUFFER_SRGB" to turn off
87 // SRGB conversion like desktop GL does.
88 // TODO(oetuaho): Get rid of this if the underlying issue is fixed.
89 glGenFramebuffers(1, &mFramebuffer);
90 glBindFramebuffer(GL_FRAMEBUFFER, mFramebuffer);
91
92 glGenTextures(1, &mFramebufferColorTexture);
93 glBindTexture(GL_TEXTURE_2D, mFramebufferColorTexture);
94 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, getWindowWidth(), getWindowHeight(), 0, GL_RGBA,
95 GL_UNSIGNED_BYTE, nullptr);
96 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
97 mFramebufferColorTexture, 0);
98 ASSERT_GL_NO_ERROR();
99 ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
100 glBindTexture(GL_TEXTURE_2D, 0);
101 }
102
Olli Etuaho4a8329f2016-01-11 17:12:57 +0200103 // Returns the created texture ID.
104 GLuint create2DTexture()
105 {
106 GLuint texture2D;
107 glGenTextures(1, &texture2D);
108 glBindTexture(GL_TEXTURE_2D, texture2D);
109 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
110 EXPECT_GL_NO_ERROR();
111 return texture2D;
112 }
113
114 GLuint mProgram;
Olli Etuaho51f1c0f2016-01-13 16:16:24 +0200115 GLuint mFramebuffer;
116
117 private:
118 GLuint mFramebufferColorTexture;
Olli Etuaho4a8329f2016-01-11 17:12:57 +0200119};
120
121class Texture2DTest : public TexCoordDrawTest
122{
123 protected:
124 Texture2DTest() : TexCoordDrawTest(), mTexture2D(0), mTexture2DUniformLocation(-1) {}
125
126 std::string getFragmentShaderSource() override
127 {
128 return std::string(SHADER_SOURCE
Geoff Langc41e42d2014-04-28 10:58:16 -0400129 (
130 precision highp float;
131 uniform sampler2D tex;
132 varying vec2 texcoord;
133
134 void main()
135 {
136 gl_FragColor = texture2D(tex, texcoord);
137 }
Olli Etuaho4a8329f2016-01-11 17:12:57 +0200138 )
Geoff Langc41e42d2014-04-28 10:58:16 -0400139 );
Olli Etuaho4a8329f2016-01-11 17:12:57 +0200140 }
Geoff Langc41e42d2014-04-28 10:58:16 -0400141
Olli Etuaho4a8329f2016-01-11 17:12:57 +0200142 void SetUp() override
143 {
144 TexCoordDrawTest::SetUp();
145 mTexture2D = create2DTexture();
Jamie Madilld4cfa572014-07-08 10:00:32 -0400146
Jamie Madill9aca0592014-10-06 16:26:59 -0400147 ASSERT_GL_NO_ERROR();
Olli Etuaho4a8329f2016-01-11 17:12:57 +0200148
149 mTexture2DUniformLocation = glGetUniformLocation(mProgram, "tex");
150 ASSERT_NE(-1, mTexture2DUniformLocation);
Jamie Madillf67115c2014-04-22 13:14:05 -0400151 }
152
Jamie Madillfa05f602015-05-07 13:47:11 -0400153 void TearDown() override
Jamie Madillf67115c2014-04-22 13:14:05 -0400154 {
Jamie Madilld4cfa572014-07-08 10:00:32 -0400155 glDeleteTextures(1, &mTexture2D);
Olli Etuaho4a8329f2016-01-11 17:12:57 +0200156 TexCoordDrawTest::TearDown();
Jamie Madillf67115c2014-04-22 13:14:05 -0400157 }
158
Jamie Madillbc393df2015-01-29 13:46:07 -0500159 // Tests CopyTexSubImage with floating point textures of various formats.
160 void testFloatCopySubImage(int sourceImageChannels, int destImageChannels)
161 {
Geoff Langbde666a2015-04-07 17:17:08 -0400162 // TODO(jmadill): Figure out why this is broken on Intel D3D11
Jamie Madill518b9fa2016-03-02 11:26:02 -0500163 if (IsIntel() && getPlatformRenderer() == EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE)
Geoff Langbde666a2015-04-07 17:17:08 -0400164 {
165 std::cout << "Test skipped on Intel D3D11." << std::endl;
166 return;
167 }
168
Geoff Langfbfa47c2015-03-31 11:26:00 -0400169 if (getClientVersion() < 3)
170 {
171 if (!extensionEnabled("GL_OES_texture_float"))
172 {
173 std::cout << "Test skipped due to missing GL_OES_texture_float." << std::endl;
174 return;
175 }
176
177 if ((sourceImageChannels < 3 || destImageChannels < 3) && !extensionEnabled("GL_EXT_texture_rg"))
178 {
179 std::cout << "Test skipped due to missing GL_EXT_texture_rg." << std::endl;
180 return;
181 }
182 }
183
Jamie Madillbc393df2015-01-29 13:46:07 -0500184 GLfloat sourceImageData[4][16] =
185 {
186 { // R
187 1.0f,
188 0.0f,
189 0.0f,
190 1.0f
191 },
192 { // RG
193 1.0f, 0.0f,
194 0.0f, 1.0f,
195 0.0f, 0.0f,
196 1.0f, 1.0f
197 },
198 { // RGB
199 1.0f, 0.0f, 0.0f,
200 0.0f, 1.0f, 0.0f,
201 0.0f, 0.0f, 1.0f,
202 1.0f, 1.0f, 0.0f
203 },
204 { // RGBA
205 1.0f, 0.0f, 0.0f, 1.0f,
206 0.0f, 1.0f, 0.0f, 1.0f,
207 0.0f, 0.0f, 1.0f, 1.0f,
208 1.0f, 1.0f, 0.0f, 1.0f
209 },
210 };
211
212 GLenum imageFormats[] =
213 {
214 GL_R32F,
215 GL_RG32F,
216 GL_RGB32F,
217 GL_RGBA32F,
218 };
219
220 GLenum sourceUnsizedFormats[] =
221 {
222 GL_RED,
223 GL_RG,
224 GL_RGB,
225 GL_RGBA,
226 };
227
228 GLuint textures[2];
229
230 glGenTextures(2, textures);
231
232 GLfloat *imageData = sourceImageData[sourceImageChannels - 1];
233 GLenum sourceImageFormat = imageFormats[sourceImageChannels - 1];
234 GLenum sourceUnsizedFormat = sourceUnsizedFormats[sourceImageChannels - 1];
235 GLenum destImageFormat = imageFormats[destImageChannels - 1];
236
237 glBindTexture(GL_TEXTURE_2D, textures[0]);
238 glTexStorage2DEXT(GL_TEXTURE_2D, 1, sourceImageFormat, 2, 2);
239 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
240 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
241 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 2, 2, sourceUnsizedFormat, GL_FLOAT, imageData);
242
hendrikwb27f79a2015-03-04 11:26:46 -0800243 if (sourceImageChannels < 3 && !extensionEnabled("GL_EXT_texture_rg"))
Jamie Madillbc393df2015-01-29 13:46:07 -0500244 {
245 // This is not supported
246 ASSERT_GL_ERROR(GL_INVALID_OPERATION);
247 }
248 else
249 {
250 ASSERT_GL_NO_ERROR();
251 }
252
253 GLuint fbo;
254 glGenFramebuffers(1, &fbo);
255 glBindFramebuffer(GL_FRAMEBUFFER, fbo);
256 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textures[0], 0);
257
258 glBindTexture(GL_TEXTURE_2D, textures[1]);
259 glTexStorage2DEXT(GL_TEXTURE_2D, 1, destImageFormat, 2, 2);
260 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
261 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
262
263 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 2, 2);
264 ASSERT_GL_NO_ERROR();
265
266 glBindFramebuffer(GL_FRAMEBUFFER, 0);
Olli Etuaho4a8329f2016-01-11 17:12:57 +0200267 drawQuad(mProgram, "position", 0.5f);
Jamie Madillbc393df2015-01-29 13:46:07 -0500268
269 int testImageChannels = std::min(sourceImageChannels, destImageChannels);
270
271 EXPECT_PIXEL_EQ(0, 0, 255, 0, 0, 255);
272 if (testImageChannels > 1)
273 {
274 EXPECT_PIXEL_EQ(getWindowHeight() - 1, 0, 0, 255, 0, 255);
275 EXPECT_PIXEL_EQ(getWindowHeight() - 1, getWindowWidth() - 1, 255, 255, 0, 255);
276 if (testImageChannels > 2)
277 {
278 EXPECT_PIXEL_EQ(0, getWindowWidth() - 1, 0, 0, 255, 255);
279 }
280 }
281
282 glDeleteFramebuffers(1, &fbo);
283 glDeleteTextures(2, textures);
284
285 ASSERT_GL_NO_ERROR();
286 }
287
Jamie Madilld4cfa572014-07-08 10:00:32 -0400288 GLuint mTexture2D;
Jamie Madilld4cfa572014-07-08 10:00:32 -0400289 GLint mTexture2DUniformLocation;
Jamie Madillf67115c2014-04-22 13:14:05 -0400290};
291
Olli Etuahoa7416ff2016-01-18 12:22:55 +0200292class Texture2DTestES3 : public Texture2DTest
293{
294 protected:
295 Texture2DTestES3() : Texture2DTest() {}
296
297 std::string getVertexShaderSource() override
298 {
299 return std::string(
300 "#version 300 es\n"
301 "out vec2 texcoord;\n"
302 "in vec4 position;\n"
303 "void main()\n"
304 "{\n"
305 " gl_Position = vec4(position.xy, 0.0, 1.0);\n"
306 " texcoord = (position.xy * 0.5) + 0.5;\n"
307 "}\n");
308 }
309
310 std::string getFragmentShaderSource() override
311 {
312 return std::string(
313 "#version 300 es\n"
314 "precision highp float;\n"
315 "uniform highp sampler2D tex;\n"
316 "in vec2 texcoord;\n"
317 "out vec4 fragColor;\n"
318 "void main()\n"
319 "{\n"
320 " fragColor = texture(tex, texcoord);\n"
321 "}\n");
322 }
323};
324
Olli Etuaho6ee394a2016-02-18 13:30:09 +0200325class Texture2DIntegerAlpha1TestES3 : public Texture2DTest
326{
327 protected:
328 Texture2DIntegerAlpha1TestES3() : Texture2DTest() {}
329
330 std::string getVertexShaderSource() override
331 {
332 return std::string(
333 "#version 300 es\n"
334 "out vec2 texcoord;\n"
335 "in vec4 position;\n"
336 "void main()\n"
337 "{\n"
338 " gl_Position = vec4(position.xy, 0.0, 1.0);\n"
339 " texcoord = (position.xy * 0.5) + 0.5;\n"
340 "}\n");
341 }
342
343 std::string getFragmentShaderSource() override
344 {
345 return std::string(
346 "#version 300 es\n"
347 "precision highp float;\n"
348 "uniform highp isampler2D tex;\n"
349 "in vec2 texcoord;\n"
350 "out vec4 fragColor;\n"
351 "void main()\n"
352 "{\n"
353 " vec4 green = vec4(0, 1, 0, 1);\n"
354 " vec4 black = vec4(0, 0, 0, 0);\n"
355 " fragColor = (texture(tex, texcoord).a == 1) ? green : black;\n"
356 "}\n");
357 }
358};
359
360class Texture2DUnsignedIntegerAlpha1TestES3 : public Texture2DTest
361{
362 protected:
363 Texture2DUnsignedIntegerAlpha1TestES3() : Texture2DTest() {}
364
365 std::string getVertexShaderSource() override
366 {
367 return std::string(
368 "#version 300 es\n"
369 "out vec2 texcoord;\n"
370 "in vec4 position;\n"
371 "void main()\n"
372 "{\n"
373 " gl_Position = vec4(position.xy, 0.0, 1.0);\n"
374 " texcoord = (position.xy * 0.5) + 0.5;\n"
375 "}\n");
376 }
377
378 std::string getFragmentShaderSource() override
379 {
380 return std::string(
381 "#version 300 es\n"
382 "precision highp float;\n"
383 "uniform highp usampler2D tex;\n"
384 "in vec2 texcoord;\n"
385 "out vec4 fragColor;\n"
386 "void main()\n"
387 "{\n"
388 " vec4 green = vec4(0, 1, 0, 1);\n"
389 " vec4 black = vec4(0, 0, 0, 0);\n"
390 " fragColor = (texture(tex, texcoord).a == 1u) ? green : black;\n"
391 "}\n");
392 }
393};
394
Olli Etuaho4a8329f2016-01-11 17:12:57 +0200395class Texture2DTestWithDrawScale : public Texture2DTest
Jamie Madill2453dbc2015-07-14 11:35:42 -0400396{
397 protected:
Olli Etuaho4a8329f2016-01-11 17:12:57 +0200398 Texture2DTestWithDrawScale() : Texture2DTest(), mDrawScaleUniformLocation(-1) {}
399
400 std::string getVertexShaderSource() override
Jamie Madill2453dbc2015-07-14 11:35:42 -0400401 {
Olli Etuaho4a8329f2016-01-11 17:12:57 +0200402 return std::string(SHADER_SOURCE
403 (
404 precision highp float;
405 attribute vec4 position;
406 varying vec2 texcoord;
407
408 uniform vec2 drawScale;
409
410 void main()
411 {
412 gl_Position = vec4(position.xy * drawScale, 0.0, 1.0);
413 texcoord = (position.xy * 0.5) + 0.5;
414 }
415 )
416 );
Jamie Madill2453dbc2015-07-14 11:35:42 -0400417 }
418
419 void SetUp() override
420 {
Olli Etuaho4a8329f2016-01-11 17:12:57 +0200421 Texture2DTest::SetUp();
422 mDrawScaleUniformLocation = glGetUniformLocation(mProgram, "drawScale");
423 ASSERT_NE(-1, mDrawScaleUniformLocation);
Jamie Madill2453dbc2015-07-14 11:35:42 -0400424
Olli Etuaho4a8329f2016-01-11 17:12:57 +0200425 glUseProgram(mProgram);
426 glUniform2f(mDrawScaleUniformLocation, 1.0f, 1.0f);
427 glUseProgram(0);
428 ASSERT_GL_NO_ERROR();
429 }
430
431 GLint mDrawScaleUniformLocation;
432};
433
Olli Etuaho4644a202016-01-12 15:12:53 +0200434class Sampler2DAsFunctionParameterTest : public Texture2DTest
435{
436 protected:
437 Sampler2DAsFunctionParameterTest() : Texture2DTest() {}
438
439 std::string getFragmentShaderSource() override
440 {
441 return std::string(SHADER_SOURCE
442 (
443 precision highp float;
444 uniform sampler2D tex;
445 varying vec2 texcoord;
446
447 vec4 computeFragColor(sampler2D aTex)
448 {
449 return texture2D(aTex, texcoord);
450 }
451
452 void main()
453 {
454 gl_FragColor = computeFragColor(tex);
455 }
456 )
457 );
458 }
459};
460
Olli Etuaho4a8329f2016-01-11 17:12:57 +0200461class TextureCubeTest : public TexCoordDrawTest
462{
463 protected:
464 TextureCubeTest()
465 : TexCoordDrawTest(),
466 mTexture2D(0),
467 mTextureCube(0),
468 mTexture2DUniformLocation(-1),
469 mTextureCubeUniformLocation(-1)
470 {
471 }
472
473 std::string getFragmentShaderSource() override
474 {
475 return std::string(SHADER_SOURCE
476 (
477 precision highp float;
478 uniform sampler2D tex2D;
479 uniform samplerCube texCube;
480 varying vec2 texcoord;
481
482 void main()
483 {
484 gl_FragColor = texture2D(tex2D, texcoord);
485 gl_FragColor += textureCube(texCube, vec3(texcoord, 0));
486 }
487 )
488 );
489 }
490
491 void SetUp() override
492 {
493 TexCoordDrawTest::SetUp();
494
495 glGenTextures(1, &mTextureCube);
496 glBindTexture(GL_TEXTURE_CUBE_MAP, mTextureCube);
497 glTexStorage2DEXT(GL_TEXTURE_CUBE_MAP, 1, GL_RGBA8, 1, 1);
498 EXPECT_GL_NO_ERROR();
499
500 mTexture2D = create2DTexture();
501
502 mTexture2DUniformLocation = glGetUniformLocation(mProgram, "tex2D");
503 ASSERT_NE(-1, mTexture2DUniformLocation);
504 mTextureCubeUniformLocation = glGetUniformLocation(mProgram, "texCube");
505 ASSERT_NE(-1, mTextureCubeUniformLocation);
506 }
507
508 void TearDown() override
509 {
510 glDeleteTextures(1, &mTextureCube);
511 TexCoordDrawTest::TearDown();
512 }
513
514 GLuint mTexture2D;
515 GLuint mTextureCube;
516 GLint mTexture2DUniformLocation;
517 GLint mTextureCubeUniformLocation;
518};
519
Olli Etuaho2173db3d2016-01-12 13:55:14 +0200520class SamplerArrayTest : public TexCoordDrawTest
521{
522 protected:
523 SamplerArrayTest()
524 : TexCoordDrawTest(),
525 mTexture2DA(0),
526 mTexture2DB(0),
527 mTexture0UniformLocation(-1),
528 mTexture1UniformLocation(-1)
529 {
530 }
531
532 std::string getFragmentShaderSource() override
533 {
534 return std::string(SHADER_SOURCE
535 (
536 precision mediump float;
537 uniform highp sampler2D tex2DArray[2];
538 varying vec2 texcoord;
539 void main()
540 {
541 gl_FragColor = texture2D(tex2DArray[0], texcoord);
542 gl_FragColor += texture2D(tex2DArray[1], texcoord);
543 }
544 )
545 );
546 }
547
548 void SetUp() override
549 {
550 TexCoordDrawTest::SetUp();
551
552 mTexture0UniformLocation = glGetUniformLocation(mProgram, "tex2DArray[0]");
553 ASSERT_NE(-1, mTexture0UniformLocation);
554 mTexture1UniformLocation = glGetUniformLocation(mProgram, "tex2DArray[1]");
555 ASSERT_NE(-1, mTexture1UniformLocation);
556
557 mTexture2DA = create2DTexture();
558 mTexture2DB = create2DTexture();
559 ASSERT_GL_NO_ERROR();
560 }
561
562 void TearDown() override
563 {
564 glDeleteTextures(1, &mTexture2DA);
565 glDeleteTextures(1, &mTexture2DB);
566 TexCoordDrawTest::TearDown();
567 }
568
569 void testSamplerArrayDraw()
570 {
571 GLubyte texData[4];
572 texData[0] = 0;
573 texData[1] = 60;
574 texData[2] = 0;
575 texData[3] = 255;
576
577 glActiveTexture(GL_TEXTURE0);
578 glBindTexture(GL_TEXTURE_2D, mTexture2DA);
579 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, texData);
580
581 texData[1] = 120;
582 glActiveTexture(GL_TEXTURE1);
583 glBindTexture(GL_TEXTURE_2D, mTexture2DB);
584 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, texData);
585 EXPECT_GL_ERROR(GL_NO_ERROR);
586
587 glUseProgram(mProgram);
588 glUniform1i(mTexture0UniformLocation, 0);
589 glUniform1i(mTexture1UniformLocation, 1);
590 drawQuad(mProgram, "position", 0.5f);
591 EXPECT_GL_NO_ERROR();
592
593 EXPECT_PIXEL_NEAR(0, 0, 0, 180, 0, 255, 2);
594 }
595
596 GLuint mTexture2DA;
597 GLuint mTexture2DB;
598 GLint mTexture0UniformLocation;
599 GLint mTexture1UniformLocation;
600};
601
602
603class SamplerArrayAsFunctionParameterTest : public SamplerArrayTest
604{
605 protected:
606 SamplerArrayAsFunctionParameterTest() : SamplerArrayTest() {}
607
608 std::string getFragmentShaderSource() override
609 {
610 return std::string(SHADER_SOURCE
611 (
612 precision mediump float;
613 uniform highp sampler2D tex2DArray[2];
614 varying vec2 texcoord;
615
616 vec4 computeFragColor(highp sampler2D aTex2DArray[2])
617 {
618 return texture2D(aTex2DArray[0], texcoord) + texture2D(aTex2DArray[1], texcoord);
619 }
620
621 void main()
622 {
623 gl_FragColor = computeFragColor(tex2DArray);
624 }
625 )
626 );
627 }
628};
629
Olli Etuaho4a8329f2016-01-11 17:12:57 +0200630class Texture2DArrayTestES3 : public TexCoordDrawTest
631{
632 protected:
633 Texture2DArrayTestES3() : TexCoordDrawTest(), m2DArrayTexture(0), mTextureArrayLocation(-1) {}
634
635 std::string getVertexShaderSource() override
636 {
637 return std::string(
Jamie Madill2453dbc2015-07-14 11:35:42 -0400638 "#version 300 es\n"
639 "out vec2 texcoord;\n"
640 "in vec4 position;\n"
Olli Etuaho4a8329f2016-01-11 17:12:57 +0200641 "void main()\n"
642 "{\n"
643 " gl_Position = vec4(position.xy, 0.0, 1.0);\n"
644 " texcoord = (position.xy * 0.5) + 0.5;\n"
645 "}\n");
646 }
Jamie Madill2453dbc2015-07-14 11:35:42 -0400647
Olli Etuaho4a8329f2016-01-11 17:12:57 +0200648 std::string getFragmentShaderSource() override
649 {
650 return std::string(
Jamie Madill2453dbc2015-07-14 11:35:42 -0400651 "#version 300 es\n"
652 "precision highp float;\n"
Olli Etuaho183d7e22015-11-20 15:59:09 +0200653 "uniform highp sampler2DArray tex2DArray;\n"
Jamie Madill2453dbc2015-07-14 11:35:42 -0400654 "in vec2 texcoord;\n"
655 "out vec4 fragColor;\n"
656 "void main()\n"
657 "{\n"
658 " fragColor = texture(tex2DArray, vec3(texcoord.x, texcoord.y, 0.0));\n"
Olli Etuaho4a8329f2016-01-11 17:12:57 +0200659 "}\n");
660 }
Jamie Madill2453dbc2015-07-14 11:35:42 -0400661
Olli Etuaho4a8329f2016-01-11 17:12:57 +0200662 void SetUp() override
663 {
664 TexCoordDrawTest::SetUp();
Jamie Madill2453dbc2015-07-14 11:35:42 -0400665
Olli Etuaho4a8329f2016-01-11 17:12:57 +0200666 mTextureArrayLocation = glGetUniformLocation(mProgram, "tex2DArray");
Jamie Madill2453dbc2015-07-14 11:35:42 -0400667 ASSERT_NE(-1, mTextureArrayLocation);
668
669 glGenTextures(1, &m2DArrayTexture);
670 ASSERT_GL_NO_ERROR();
671 }
672
673 void TearDown() override
674 {
675 glDeleteTextures(1, &m2DArrayTexture);
Olli Etuaho4a8329f2016-01-11 17:12:57 +0200676 TexCoordDrawTest::TearDown();
Jamie Madill2453dbc2015-07-14 11:35:42 -0400677 }
678
679 GLuint m2DArrayTexture;
Jamie Madill2453dbc2015-07-14 11:35:42 -0400680 GLint mTextureArrayLocation;
681};
682
Olli Etuahobce743a2016-01-15 17:18:28 +0200683class TextureSizeTextureArrayTest : public TexCoordDrawTest
684{
685 protected:
686 TextureSizeTextureArrayTest()
687 : TexCoordDrawTest(),
688 mTexture2DA(0),
689 mTexture2DB(0),
690 mTexture0Location(-1),
691 mTexture1Location(-1)
692 {
693 }
694
695 std::string getVertexShaderSource() override
696 {
697 return std::string(
698 "#version 300 es\n"
699 "in vec4 position;\n"
700 "void main()\n"
701 "{\n"
702 " gl_Position = vec4(position.xy, 0.0, 1.0);\n"
703 "}\n");
704 }
705
706 std::string getFragmentShaderSource() override
707 {
708 return std::string(
709 "#version 300 es\n"
710 "precision highp float;\n"
711 "uniform highp sampler2D tex2DArray[2];\n"
712 "out vec4 fragColor;\n"
713 "void main()\n"
714 "{\n"
715 " float red = float(textureSize(tex2DArray[0], 0).x) / 255.0;\n"
716 " float green = float(textureSize(tex2DArray[1], 0).x) / 255.0;\n"
717 " fragColor = vec4(red, green, 0.0, 1.0);\n"
718 "}\n");
719 }
720
721 void SetUp() override
722 {
723 TexCoordDrawTest::SetUp();
724
725 mTexture0Location = glGetUniformLocation(mProgram, "tex2DArray[0]");
726 ASSERT_NE(-1, mTexture0Location);
727 mTexture1Location = glGetUniformLocation(mProgram, "tex2DArray[1]");
728 ASSERT_NE(-1, mTexture1Location);
729
730 mTexture2DA = create2DTexture();
731 mTexture2DB = create2DTexture();
732 ASSERT_GL_NO_ERROR();
733 }
734
735 void TearDown() override
736 {
737 glDeleteTextures(1, &mTexture2DA);
738 glDeleteTextures(1, &mTexture2DB);
739 TexCoordDrawTest::TearDown();
740 }
741
742 GLuint mTexture2DA;
743 GLuint mTexture2DB;
744 GLint mTexture0Location;
745 GLint mTexture1Location;
746};
747
Olli Etuaho1a679902016-01-14 12:21:47 +0200748class ShadowSamplerPlusSampler3DTestES3 : public TexCoordDrawTest
749{
750 protected:
751 ShadowSamplerPlusSampler3DTestES3()
752 : TexCoordDrawTest(),
753 mTextureShadow(0),
754 mTexture3D(0),
755 mTextureShadowUniformLocation(-1),
756 mTexture3DUniformLocation(-1),
757 mDepthRefUniformLocation(-1)
758 {
759 }
760
761 std::string getVertexShaderSource() override
762 {
763 return std::string(
764 "#version 300 es\n"
765 "out vec2 texcoord;\n"
766 "in vec4 position;\n"
767 "void main()\n"
768 "{\n"
769 " gl_Position = vec4(position.xy, 0.0, 1.0);\n"
770 " texcoord = (position.xy * 0.5) + 0.5;\n"
771 "}\n");
772 }
773
774 std::string getFragmentShaderSource() override
775 {
776 return std::string(
777 "#version 300 es\n"
778 "precision highp float;\n"
779 "uniform highp sampler2DShadow tex2DShadow;\n"
780 "uniform highp sampler3D tex3D;\n"
781 "in vec2 texcoord;\n"
782 "uniform float depthRef;\n"
783 "out vec4 fragColor;\n"
784 "void main()\n"
785 "{\n"
786 " fragColor = vec4(texture(tex2DShadow, vec3(texcoord, depthRef)) * 0.5);\n"
787 " fragColor += texture(tex3D, vec3(texcoord, 0.0));\n"
788 "}\n");
789 }
790
791 void SetUp() override
792 {
793 TexCoordDrawTest::SetUp();
794
795 glGenTextures(1, &mTexture3D);
796
797 glGenTextures(1, &mTextureShadow);
798 glBindTexture(GL_TEXTURE_2D, mTextureShadow);
799 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
800
801 mTextureShadowUniformLocation = glGetUniformLocation(mProgram, "tex2DShadow");
802 ASSERT_NE(-1, mTextureShadowUniformLocation);
803 mTexture3DUniformLocation = glGetUniformLocation(mProgram, "tex3D");
804 ASSERT_NE(-1, mTexture3DUniformLocation);
805 mDepthRefUniformLocation = glGetUniformLocation(mProgram, "depthRef");
806 ASSERT_NE(-1, mDepthRefUniformLocation);
807 }
808
809 void TearDown() override
810 {
811 glDeleteTextures(1, &mTextureShadow);
812 glDeleteTextures(1, &mTexture3D);
813 TexCoordDrawTest::TearDown();
814 }
815
816 GLuint mTextureShadow;
817 GLuint mTexture3D;
818 GLint mTextureShadowUniformLocation;
819 GLint mTexture3DUniformLocation;
820 GLint mDepthRefUniformLocation;
821};
822
Olli Etuahoc8c99a02016-01-14 16:47:22 +0200823class SamplerTypeMixTestES3 : public TexCoordDrawTest
824{
825 protected:
826 SamplerTypeMixTestES3()
827 : TexCoordDrawTest(),
828 mTexture2D(0),
829 mTextureCube(0),
830 mTexture2DShadow(0),
831 mTextureCubeShadow(0),
832 mTexture2DUniformLocation(-1),
833 mTextureCubeUniformLocation(-1),
834 mTexture2DShadowUniformLocation(-1),
835 mTextureCubeShadowUniformLocation(-1),
836 mDepthRefUniformLocation(-1)
837 {
838 }
839
840 std::string getVertexShaderSource() override
841 {
842 return std::string(
843 "#version 300 es\n"
844 "out vec2 texcoord;\n"
845 "in vec4 position;\n"
846 "void main()\n"
847 "{\n"
848 " gl_Position = vec4(position.xy, 0.0, 1.0);\n"
849 " texcoord = (position.xy * 0.5) + 0.5;\n"
850 "}\n");
851 }
852
853 std::string getFragmentShaderSource() override
854 {
855 return std::string(
856 "#version 300 es\n"
857 "precision highp float;\n"
858 "uniform highp sampler2D tex2D;\n"
859 "uniform highp samplerCube texCube;\n"
860 "uniform highp sampler2DShadow tex2DShadow;\n"
861 "uniform highp samplerCubeShadow texCubeShadow;\n"
862 "in vec2 texcoord;\n"
863 "uniform float depthRef;\n"
864 "out vec4 fragColor;\n"
865 "void main()\n"
866 "{\n"
867 " fragColor = texture(tex2D, texcoord);\n"
868 " fragColor += texture(texCube, vec3(1.0, 0.0, 0.0));\n"
869 " fragColor += vec4(texture(tex2DShadow, vec3(texcoord, depthRef)) * 0.25);\n"
870 " fragColor += vec4(texture(texCubeShadow, vec4(1.0, 0.0, 0.0, depthRef)) * "
871 "0.125);\n"
872 "}\n");
873 }
874
875 void SetUp() override
876 {
877 TexCoordDrawTest::SetUp();
878
879 glGenTextures(1, &mTexture2D);
880 glGenTextures(1, &mTextureCube);
881
882 glGenTextures(1, &mTexture2DShadow);
883 glBindTexture(GL_TEXTURE_2D, mTexture2DShadow);
884 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
885
886 glGenTextures(1, &mTextureCubeShadow);
887 glBindTexture(GL_TEXTURE_CUBE_MAP, mTextureCubeShadow);
888 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
889
890 mTexture2DUniformLocation = glGetUniformLocation(mProgram, "tex2D");
891 ASSERT_NE(-1, mTexture2DUniformLocation);
892 mTextureCubeUniformLocation = glGetUniformLocation(mProgram, "texCube");
893 ASSERT_NE(-1, mTextureCubeUniformLocation);
894 mTexture2DShadowUniformLocation = glGetUniformLocation(mProgram, "tex2DShadow");
895 ASSERT_NE(-1, mTexture2DShadowUniformLocation);
896 mTextureCubeShadowUniformLocation = glGetUniformLocation(mProgram, "texCubeShadow");
897 ASSERT_NE(-1, mTextureCubeShadowUniformLocation);
898 mDepthRefUniformLocation = glGetUniformLocation(mProgram, "depthRef");
899 ASSERT_NE(-1, mDepthRefUniformLocation);
900
901 ASSERT_GL_NO_ERROR();
902 }
903
904 void TearDown() override
905 {
906 glDeleteTextures(1, &mTexture2D);
907 glDeleteTextures(1, &mTextureCube);
908 glDeleteTextures(1, &mTexture2DShadow);
909 glDeleteTextures(1, &mTextureCubeShadow);
910 TexCoordDrawTest::TearDown();
911 }
912
913 GLuint mTexture2D;
914 GLuint mTextureCube;
915 GLuint mTexture2DShadow;
916 GLuint mTextureCubeShadow;
917 GLint mTexture2DUniformLocation;
918 GLint mTextureCubeUniformLocation;
919 GLint mTexture2DShadowUniformLocation;
920 GLint mTextureCubeShadowUniformLocation;
921 GLint mDepthRefUniformLocation;
922};
923
Olli Etuaho4a8329f2016-01-11 17:12:57 +0200924TEST_P(Texture2DTest, NegativeAPISubImage)
Jamie Madillf67115c2014-04-22 13:14:05 -0400925{
Jamie Madilld4cfa572014-07-08 10:00:32 -0400926 glBindTexture(GL_TEXTURE_2D, mTexture2D);
Jamie Madillf67115c2014-04-22 13:14:05 -0400927 EXPECT_GL_ERROR(GL_NO_ERROR);
928
929 const GLubyte *pixels[20] = { 0 };
930 glTexSubImage2D(GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
931 EXPECT_GL_ERROR(GL_INVALID_VALUE);
932}
Geoff Langc41e42d2014-04-28 10:58:16 -0400933
Olli Etuaho4a8329f2016-01-11 17:12:57 +0200934TEST_P(Texture2DTest, ZeroSizedUploads)
Geoff Langc41e42d2014-04-28 10:58:16 -0400935{
Jamie Madilld4cfa572014-07-08 10:00:32 -0400936 glBindTexture(GL_TEXTURE_2D, mTexture2D);
Geoff Langc41e42d2014-04-28 10:58:16 -0400937 EXPECT_GL_ERROR(GL_NO_ERROR);
938
939 // Use the texture first to make sure it's in video memory
Olli Etuaho4a8329f2016-01-11 17:12:57 +0200940 glUseProgram(mProgram);
Jamie Madilld4cfa572014-07-08 10:00:32 -0400941 glUniform1i(mTexture2DUniformLocation, 0);
Olli Etuaho4a8329f2016-01-11 17:12:57 +0200942 drawQuad(mProgram, "position", 0.5f);
Geoff Langc41e42d2014-04-28 10:58:16 -0400943
944 const GLubyte *pixel[4] = { 0 };
945
946 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixel);
947 EXPECT_GL_NO_ERROR();
948
949 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel);
950 EXPECT_GL_NO_ERROR();
951
952 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixel);
953 EXPECT_GL_NO_ERROR();
954}
Jamie Madilld4cfa572014-07-08 10:00:32 -0400955
956// Test drawing with two texture types, to trigger an ANGLE bug in validation
Olli Etuaho4a8329f2016-01-11 17:12:57 +0200957TEST_P(TextureCubeTest, CubeMapBug)
Jamie Madilld4cfa572014-07-08 10:00:32 -0400958{
959 glActiveTexture(GL_TEXTURE0);
960 glBindTexture(GL_TEXTURE_2D, mTexture2D);
961 glActiveTexture(GL_TEXTURE1);
962 glBindTexture(GL_TEXTURE_CUBE_MAP, mTextureCube);
963 EXPECT_GL_ERROR(GL_NO_ERROR);
964
Olli Etuaho4a8329f2016-01-11 17:12:57 +0200965 glUseProgram(mProgram);
966 glUniform1i(mTexture2DUniformLocation, 0);
967 glUniform1i(mTextureCubeUniformLocation, 1);
968 drawQuad(mProgram, "position", 0.5f);
Jamie Madilld4cfa572014-07-08 10:00:32 -0400969 EXPECT_GL_NO_ERROR();
970}
Jamie Madill9aca0592014-10-06 16:26:59 -0400971
Olli Etuaho53a2da12016-01-11 15:43:32 +0200972// Test drawing with two texture types accessed from the same shader and check that the result of
973// drawing is correct.
974TEST_P(TextureCubeTest, CubeMapDraw)
975{
976 GLubyte texData[4];
977 texData[0] = 0;
978 texData[1] = 60;
979 texData[2] = 0;
980 texData[3] = 255;
981
982 glActiveTexture(GL_TEXTURE0);
983 glBindTexture(GL_TEXTURE_2D, mTexture2D);
984 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, texData);
985
986 glActiveTexture(GL_TEXTURE1);
987 glBindTexture(GL_TEXTURE_CUBE_MAP, mTextureCube);
988 texData[1] = 120;
989 glTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE,
990 texData);
991 EXPECT_GL_ERROR(GL_NO_ERROR);
992
993 glUseProgram(mProgram);
994 glUniform1i(mTexture2DUniformLocation, 0);
995 glUniform1i(mTextureCubeUniformLocation, 1);
996 drawQuad(mProgram, "position", 0.5f);
997 EXPECT_GL_NO_ERROR();
998
999 int px = getWindowWidth() - 1;
1000 int py = 0;
1001 EXPECT_PIXEL_NEAR(px, py, 0, 180, 0, 255, 2);
1002}
1003
Olli Etuaho4644a202016-01-12 15:12:53 +02001004TEST_P(Sampler2DAsFunctionParameterTest, Sampler2DAsFunctionParameter)
1005{
1006 glActiveTexture(GL_TEXTURE0);
1007 glBindTexture(GL_TEXTURE_2D, mTexture2D);
1008 GLubyte texData[4];
1009 texData[0] = 0;
1010 texData[1] = 128;
1011 texData[2] = 0;
1012 texData[3] = 255;
1013 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, texData);
1014 glUseProgram(mProgram);
1015 glUniform1i(mTexture2DUniformLocation, 0);
1016 drawQuad(mProgram, "position", 0.5f);
1017 EXPECT_GL_NO_ERROR();
1018
1019 EXPECT_PIXEL_NEAR(0, 0, 0, 128, 0, 255, 2);
1020}
1021
Olli Etuaho2173db3d2016-01-12 13:55:14 +02001022// Test drawing with two textures passed to the shader in a sampler array.
1023TEST_P(SamplerArrayTest, SamplerArrayDraw)
1024{
1025 testSamplerArrayDraw();
1026}
1027
1028// Test drawing with two textures passed to the shader in a sampler array which is passed to a
1029// user-defined function in the shader.
1030TEST_P(SamplerArrayAsFunctionParameterTest, SamplerArrayAsFunctionParameter)
1031{
1032 testSamplerArrayDraw();
1033}
1034
Jamie Madill9aca0592014-10-06 16:26:59 -04001035// Copy of a test in conformance/textures/texture-mips, to test generate mipmaps
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001036TEST_P(Texture2DTestWithDrawScale, MipmapsTwice)
Jamie Madill9aca0592014-10-06 16:26:59 -04001037{
1038 int px = getWindowWidth() / 2;
1039 int py = getWindowHeight() / 2;
1040
1041 glActiveTexture(GL_TEXTURE0);
1042 glBindTexture(GL_TEXTURE_2D, mTexture2D);
1043
1044 // Fill with red
1045 std::vector<GLubyte> pixels(4 * 16 * 16);
Olli Etuaho356f5162016-03-18 14:19:41 +02001046 FillWithRGBA<GLubyte>(16u * 16u, 255u, 0u, 0u, 255u, pixels.data());
Jamie Madill9aca0592014-10-06 16:26:59 -04001047
1048 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels.data());
1049 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
1050 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
1051 glGenerateMipmap(GL_TEXTURE_2D);
1052
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001053 glUseProgram(mProgram);
Jamie Madill9aca0592014-10-06 16:26:59 -04001054 glUniform1i(mTexture2DUniformLocation, 0);
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001055 glUniform2f(mDrawScaleUniformLocation, 0.0625f, 0.0625f);
1056 drawQuad(mProgram, "position", 0.5f);
Jamie Madill9aca0592014-10-06 16:26:59 -04001057 EXPECT_GL_NO_ERROR();
1058 EXPECT_PIXEL_EQ(px, py, 255, 0, 0, 255);
1059
1060 // Fill with blue
Olli Etuaho356f5162016-03-18 14:19:41 +02001061 FillWithRGBA<GLubyte>(16u * 16u, 0u, 0u, 255u, 255u, pixels.data());
Jamie Madill9aca0592014-10-06 16:26:59 -04001062
1063 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels.data());
1064 glGenerateMipmap(GL_TEXTURE_2D);
1065
1066 // Fill with green
Olli Etuaho356f5162016-03-18 14:19:41 +02001067 FillWithRGBA<GLubyte>(16u * 16u, 0u, 255u, 0u, 255u, pixels.data());
Jamie Madill9aca0592014-10-06 16:26:59 -04001068
1069 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels.data());
1070 glGenerateMipmap(GL_TEXTURE_2D);
1071
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001072 drawQuad(mProgram, "position", 0.5f);
Jamie Madill9aca0592014-10-06 16:26:59 -04001073
1074 EXPECT_GL_NO_ERROR();
1075 EXPECT_PIXEL_EQ(px, py, 0, 255, 0, 255);
1076}
Jamie Madillf8fccb32014-11-12 15:05:26 -05001077
Jamie Madilleb32a2e2014-12-10 14:27:53 -05001078// Test creating a FBO with a cube map render target, to test an ANGLE bug
1079// https://code.google.com/p/angleproject/issues/detail?id=849
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001080TEST_P(TextureCubeTest, CubeMapFBO)
Jamie Madilleb32a2e2014-12-10 14:27:53 -05001081{
1082 GLuint fbo;
1083 glGenFramebuffers(1, &fbo);
1084 glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1085
1086 glBindTexture(GL_TEXTURE_CUBE_MAP, mTextureCube);
1087 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_Y, mTextureCube, 0);
1088
Corentin Wallez322653b2015-06-17 18:33:56 +02001089 EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
Jamie Madilleb32a2e2014-12-10 14:27:53 -05001090
1091 glDeleteFramebuffers(1, &fbo);
1092
1093 EXPECT_GL_NO_ERROR();
1094}
Gregoire Payen de La Garanderie88fe1ad2015-01-19 15:09:26 +00001095
1096// Test that glTexSubImage2D works properly when glTexStorage2DEXT has initialized the image with a default color.
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001097TEST_P(Texture2DTest, TexStorage)
Gregoire Payen de La Garanderie88fe1ad2015-01-19 15:09:26 +00001098{
1099 int width = getWindowWidth();
1100 int height = getWindowHeight();
1101
1102 GLuint tex2D;
1103 glGenTextures(1, &tex2D);
1104 glActiveTexture(GL_TEXTURE0);
1105 glBindTexture(GL_TEXTURE_2D, tex2D);
1106
1107 // Fill with red
1108 std::vector<GLubyte> pixels(3 * 16 * 16);
1109 for (size_t pixelId = 0; pixelId < 16 * 16; ++pixelId)
1110 {
1111 pixels[pixelId * 3 + 0] = 255;
1112 pixels[pixelId * 3 + 1] = 0;
1113 pixels[pixelId * 3 + 2] = 0;
1114 }
1115
1116 // ANGLE internally uses RGBA as the DirectX format for RGB images
1117 // therefore glTexStorage2DEXT initializes the image to a default color to get a consistent alpha color.
1118 // The data is kept in a CPU-side image and the image is marked as dirty.
1119 glTexStorage2DEXT(GL_TEXTURE_2D, 1, GL_RGB8, 16, 16);
1120
1121 // Initializes the color of the upper-left 8x8 pixels, leaves the other pixels untouched.
1122 // glTexSubImage2D should take into account that the image is dirty.
1123 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 8, 8, GL_RGB, GL_UNSIGNED_BYTE, pixels.data());
1124 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
1125 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
1126
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001127 glUseProgram(mProgram);
Gregoire Payen de La Garanderie88fe1ad2015-01-19 15:09:26 +00001128 glUniform1i(mTexture2DUniformLocation, 0);
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001129 drawQuad(mProgram, "position", 0.5f);
Gregoire Payen de La Garanderie88fe1ad2015-01-19 15:09:26 +00001130 glDeleteTextures(1, &tex2D);
1131 EXPECT_GL_NO_ERROR();
Gregoire Payen de La Garanderie88fe1ad2015-01-19 15:09:26 +00001132 EXPECT_PIXEL_EQ(width / 4, height / 4, 255, 0, 0, 255);
Geoff Langfbfa47c2015-03-31 11:26:00 -04001133
1134 // Validate that the region of the texture without data has an alpha of 1.0
1135 GLubyte pixel[4];
1136 glReadPixels(3 * width / 4, 3 * height / 4, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel);
1137 EXPECT_EQ(pixel[3], 255);
Gregoire Payen de La Garanderie88fe1ad2015-01-19 15:09:26 +00001138}
1139
1140// Test that glTexSubImage2D combined with a PBO works properly when glTexStorage2DEXT has initialized the image with a default color.
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001141TEST_P(Texture2DTest, TexStorageWithPBO)
Gregoire Payen de La Garanderie88fe1ad2015-01-19 15:09:26 +00001142{
1143 if (extensionEnabled("NV_pixel_buffer_object"))
1144 {
1145 int width = getWindowWidth();
1146 int height = getWindowHeight();
1147
1148 GLuint tex2D;
1149 glGenTextures(1, &tex2D);
1150 glActiveTexture(GL_TEXTURE0);
1151 glBindTexture(GL_TEXTURE_2D, tex2D);
1152
1153 // Fill with red
1154 std::vector<GLubyte> pixels(3 * 16 * 16);
1155 for (size_t pixelId = 0; pixelId < 16 * 16; ++pixelId)
1156 {
1157 pixels[pixelId * 3 + 0] = 255;
1158 pixels[pixelId * 3 + 1] = 0;
1159 pixels[pixelId * 3 + 2] = 0;
1160 }
1161
1162 // Read 16x16 region from red backbuffer to PBO
1163 GLuint pbo;
1164 glGenBuffers(1, &pbo);
1165 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo);
1166 glBufferData(GL_PIXEL_UNPACK_BUFFER, 3 * 16 * 16, pixels.data(), GL_STATIC_DRAW);
1167
1168 // ANGLE internally uses RGBA as the DirectX format for RGB images
1169 // therefore glTexStorage2DEXT initializes the image to a default color to get a consistent alpha color.
1170 // The data is kept in a CPU-side image and the image is marked as dirty.
1171 glTexStorage2DEXT(GL_TEXTURE_2D, 1, GL_RGB8, 16, 16);
1172
1173 // Initializes the color of the upper-left 8x8 pixels, leaves the other pixels untouched.
1174 // glTexSubImage2D should take into account that the image is dirty.
1175 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 8, 8, GL_RGB, GL_UNSIGNED_BYTE, NULL);
1176 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
1177 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
1178
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001179 glUseProgram(mProgram);
Gregoire Payen de La Garanderie88fe1ad2015-01-19 15:09:26 +00001180 glUniform1i(mTexture2DUniformLocation, 0);
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001181 drawQuad(mProgram, "position", 0.5f);
Gregoire Payen de La Garanderie88fe1ad2015-01-19 15:09:26 +00001182 glDeleteTextures(1, &tex2D);
Olli Etuaho19d48db2016-01-13 14:43:21 +02001183 glDeleteBuffers(1, &pbo);
Gregoire Payen de La Garanderie88fe1ad2015-01-19 15:09:26 +00001184 EXPECT_GL_NO_ERROR();
1185 EXPECT_PIXEL_EQ(3 * width / 4, 3 * height / 4, 0, 0, 0, 255);
1186 EXPECT_PIXEL_EQ(width / 4, height / 4, 255, 0, 0, 255);
1187 }
1188}
Jamie Madillbc393df2015-01-29 13:46:07 -05001189
1190// See description on testFloatCopySubImage
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001191TEST_P(Texture2DTest, CopySubImageFloat_R_R)
Jamie Madillbc393df2015-01-29 13:46:07 -05001192{
1193 testFloatCopySubImage(1, 1);
1194}
1195
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001196TEST_P(Texture2DTest, CopySubImageFloat_RG_R)
Jamie Madillbc393df2015-01-29 13:46:07 -05001197{
1198 testFloatCopySubImage(2, 1);
1199}
1200
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001201TEST_P(Texture2DTest, CopySubImageFloat_RG_RG)
Jamie Madillbc393df2015-01-29 13:46:07 -05001202{
1203 testFloatCopySubImage(2, 2);
1204}
1205
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001206TEST_P(Texture2DTest, CopySubImageFloat_RGB_R)
Jamie Madillbc393df2015-01-29 13:46:07 -05001207{
1208 testFloatCopySubImage(3, 1);
1209}
1210
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001211TEST_P(Texture2DTest, CopySubImageFloat_RGB_RG)
Jamie Madillbc393df2015-01-29 13:46:07 -05001212{
1213 testFloatCopySubImage(3, 2);
1214}
1215
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001216TEST_P(Texture2DTest, CopySubImageFloat_RGB_RGB)
Jamie Madillbc393df2015-01-29 13:46:07 -05001217{
Austin Kinrossd544cc92016-01-11 15:26:42 -08001218 // TODO (bug 1284): Investigate RGBA32f D3D SDK Layers messages on D3D11_FL9_3
Jamie Madill518b9fa2016-03-02 11:26:02 -05001219 if (IsD3D11_FL93())
Austin Kinrossd544cc92016-01-11 15:26:42 -08001220 {
1221 std::cout << "Test skipped on Feature Level 9_3." << std::endl;
1222 return;
1223 }
1224
Jamie Madillbc393df2015-01-29 13:46:07 -05001225 testFloatCopySubImage(3, 3);
1226}
1227
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001228TEST_P(Texture2DTest, CopySubImageFloat_RGBA_R)
Jamie Madillbc393df2015-01-29 13:46:07 -05001229{
1230 testFloatCopySubImage(4, 1);
1231}
1232
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001233TEST_P(Texture2DTest, CopySubImageFloat_RGBA_RG)
Jamie Madillbc393df2015-01-29 13:46:07 -05001234{
1235 testFloatCopySubImage(4, 2);
1236}
1237
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001238TEST_P(Texture2DTest, CopySubImageFloat_RGBA_RGB)
Jamie Madillbc393df2015-01-29 13:46:07 -05001239{
Austin Kinrossd544cc92016-01-11 15:26:42 -08001240 // TODO (bug 1284): Investigate RGBA32f D3D SDK Layers messages on D3D11_FL9_3
Jamie Madill518b9fa2016-03-02 11:26:02 -05001241 if (IsD3D11_FL93())
Austin Kinrossd544cc92016-01-11 15:26:42 -08001242 {
1243 std::cout << "Test skipped on Feature Level 9_3." << std::endl;
1244 return;
1245 }
1246
Jamie Madillbc393df2015-01-29 13:46:07 -05001247 testFloatCopySubImage(4, 3);
1248}
1249
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001250TEST_P(Texture2DTest, CopySubImageFloat_RGBA_RGBA)
Jamie Madillbc393df2015-01-29 13:46:07 -05001251{
Austin Kinrossd544cc92016-01-11 15:26:42 -08001252 // TODO (bug 1284): Investigate RGBA32f D3D SDK Layers messages on D3D11_FL9_3
Jamie Madill518b9fa2016-03-02 11:26:02 -05001253 if (IsD3D11_FL93())
Austin Kinrossd544cc92016-01-11 15:26:42 -08001254 {
1255 std::cout << "Test skipped on Feature Level 9_3." << std::endl;
1256 return;
1257 }
1258
Jamie Madillbc393df2015-01-29 13:46:07 -05001259 testFloatCopySubImage(4, 4);
1260}
Austin Kinross07285142015-03-26 11:36:16 -07001261
1262// Port of https://www.khronos.org/registry/webgl/conformance-suites/1.0.3/conformance/textures/texture-npot.html
1263// Run against GL_ALPHA/UNSIGNED_BYTE format, to ensure that D3D11 Feature Level 9_3 correctly handles GL_ALPHA
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001264TEST_P(Texture2DTest, TextureNPOT_GL_ALPHA_UBYTE)
Austin Kinross07285142015-03-26 11:36:16 -07001265{
1266 const int npotTexSize = 5;
1267 const int potTexSize = 4; // Should be less than npotTexSize
1268 GLuint tex2D;
1269
1270 if (extensionEnabled("GL_OES_texture_npot"))
1271 {
1272 // This test isn't applicable if texture_npot is enabled
1273 return;
1274 }
1275
1276 glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
1277
Austin Kinross5faa15b2016-01-11 13:32:48 -08001278 // Default unpack alignment is 4. The values of 'pixels' below needs it to be 1.
1279 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
1280
Austin Kinross07285142015-03-26 11:36:16 -07001281 glActiveTexture(GL_TEXTURE0);
1282 glGenTextures(1, &tex2D);
1283 glBindTexture(GL_TEXTURE_2D, tex2D);
1284
1285 std::vector<GLubyte> pixels(1 * npotTexSize * npotTexSize);
1286 for (size_t pixelId = 0; pixelId < npotTexSize * npotTexSize; ++pixelId)
1287 {
1288 pixels[pixelId] = 64;
1289 }
1290
1291 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
1292 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
1293
1294 // Check that an NPOT texture not on level 0 generates INVALID_VALUE
1295 glTexImage2D(GL_TEXTURE_2D, 1, GL_ALPHA, npotTexSize, npotTexSize, 0, GL_ALPHA, GL_UNSIGNED_BYTE, pixels.data());
1296 EXPECT_GL_ERROR(GL_INVALID_VALUE);
1297
1298 // Check that an NPOT texture on level 0 succeeds
1299 glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, npotTexSize, npotTexSize, 0, GL_ALPHA, GL_UNSIGNED_BYTE, pixels.data());
1300 EXPECT_GL_NO_ERROR();
1301
1302 // Check that generateMipmap fails on NPOT
1303 glGenerateMipmap(GL_TEXTURE_2D);
1304 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
1305
1306 // Check that nothing is drawn if filtering is not correct for NPOT
1307 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1308 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1309 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
1310 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
1311 glClear(GL_COLOR_BUFFER_BIT);
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001312 drawQuad(mProgram, "position", 1.0f);
Austin Kinross07285142015-03-26 11:36:16 -07001313 EXPECT_PIXEL_EQ(getWindowWidth() / 2, getWindowHeight() / 2, 0, 0, 0, 255);
1314
1315 // NPOT texture with TEXTURE_MIN_FILTER not NEAREST or LINEAR should draw with 0,0,0,255
1316 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
1317 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
1318 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR);
1319 glClear(GL_COLOR_BUFFER_BIT);
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001320 drawQuad(mProgram, "position", 1.0f);
Austin Kinross07285142015-03-26 11:36:16 -07001321 EXPECT_PIXEL_EQ(getWindowWidth() / 2, getWindowHeight() / 2, 0, 0, 0, 255);
1322
1323 // NPOT texture with TEXTURE_MIN_FILTER set to LINEAR should draw
1324 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
1325 glClear(GL_COLOR_BUFFER_BIT);
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001326 drawQuad(mProgram, "position", 1.0f);
Austin Kinross07285142015-03-26 11:36:16 -07001327 EXPECT_PIXEL_EQ(getWindowWidth() / 2, getWindowHeight() / 2, 0, 0, 0, 64);
1328
1329 // Check that glTexImage2D for POT texture succeeds
1330 glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, potTexSize, potTexSize, 0, GL_ALPHA, GL_UNSIGNED_BYTE, pixels.data());
1331 EXPECT_GL_NO_ERROR();
1332
1333 // Check that generateMipmap for an POT texture succeeds
1334 glGenerateMipmap(GL_TEXTURE_2D);
1335 EXPECT_GL_NO_ERROR();
1336
1337 // POT texture with TEXTURE_MIN_FILTER set to LINEAR_MIPMAP_LINEAR should draw
1338 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
1339 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
1340 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
1341 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
1342 glClear(GL_COLOR_BUFFER_BIT);
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001343 drawQuad(mProgram, "position", 1.0f);
Austin Kinross07285142015-03-26 11:36:16 -07001344 EXPECT_PIXEL_EQ(getWindowWidth() / 2, getWindowHeight() / 2, 0, 0, 0, 64);
1345 EXPECT_GL_NO_ERROR();
1346}
Jamie Madillfa05f602015-05-07 13:47:11 -04001347
Austin Kinross08528e12015-10-07 16:24:40 -07001348// Test to ensure that glTexSubImage2D always accepts data for non-power-of-two subregions.
1349// ANGLE previously rejected this if GL_OES_texture_npot wasn't active, which is incorrect.
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001350TEST_P(Texture2DTest, NPOTSubImageParameters)
Austin Kinross08528e12015-10-07 16:24:40 -07001351{
Geoff Lange0cc2a42016-01-20 10:58:17 -05001352 // TODO(geofflang): Allow the GL backend to accept SubImage calls with a null data ptr. (bug
1353 // 1278)
1354 if (getPlatformRenderer() == EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE ||
1355 getPlatformRenderer() == EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE)
1356 {
1357 std::cout << "Test disabled on OpenGL." << std::endl;
1358 return;
1359 }
1360
Austin Kinross08528e12015-10-07 16:24:40 -07001361 glActiveTexture(GL_TEXTURE0);
1362 glBindTexture(GL_TEXTURE_2D, mTexture2D);
1363
1364 // Create an 8x8 (i.e. power-of-two) texture.
1365 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
1366 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
1367 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
1368 glGenerateMipmap(GL_TEXTURE_2D);
1369
1370 // Supply a 3x3 (i.e. non-power-of-two) subimage to the texture.
1371 // This should always work, even if GL_OES_texture_npot isn't active.
1372 glTexSubImage2D(GL_TEXTURE_2D, 1, 0, 0, 3, 3, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
1373
1374 EXPECT_GL_NO_ERROR();
1375}
1376
Olli Etuahoa7416ff2016-01-18 12:22:55 +02001377// Test to check that texture completeness is determined correctly when the texture base level is
1378// greater than 0, and also that level 0 is not sampled when base level is greater than 0.
1379TEST_P(Texture2DTestES3, DrawWithBaseLevel1)
1380{
1381 glActiveTexture(GL_TEXTURE0);
1382 glBindTexture(GL_TEXTURE_2D, mTexture2D);
1383 GLubyte texDataRed[4u * 4u * 4u];
Olli Etuaho356f5162016-03-18 14:19:41 +02001384 FillWithRGBA<GLubyte>(4u * 4u, 255u, 0u, 0u, 255u, texDataRed);
Olli Etuahoa7416ff2016-01-18 12:22:55 +02001385 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, texDataRed);
1386 GLubyte texDataGreen[2u * 2u * 4u];
Olli Etuaho356f5162016-03-18 14:19:41 +02001387 FillWithRGBA<GLubyte>(2u * 2u, 0u, 255u, 0u, 255u, texDataGreen);
Olli Etuahoa7416ff2016-01-18 12:22:55 +02001388 glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, texDataGreen);
1389 glTexImage2D(GL_TEXTURE_2D, 2, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, texDataGreen);
1390 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
1391 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
1392 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 1);
1393
1394 EXPECT_GL_NO_ERROR();
1395
1396 drawQuad(mProgram, "position", 0.5f);
1397
1398 EXPECT_PIXEL_EQ(0, 0, 0, 255, 0, 255);
1399}
1400
Jamie Madill2453dbc2015-07-14 11:35:42 -04001401// In the D3D11 renderer, we need to initialize some texture formats, to fill empty channels. EG RBA->RGBA8, with 1.0
1402// in the alpha channel. This test covers a bug where redefining array textures with these formats does not work as
1403// expected.
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001404TEST_P(Texture2DArrayTestES3, RedefineInittableArray)
Jamie Madill2453dbc2015-07-14 11:35:42 -04001405{
1406 std::vector<GLubyte> pixelData;
1407 for (size_t count = 0; count < 5000; count++)
1408 {
1409 pixelData.push_back(0u);
1410 pixelData.push_back(255u);
1411 pixelData.push_back(0u);
1412 }
1413
1414 glBindTexture(GL_TEXTURE_2D_ARRAY, m2DArrayTexture);
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001415 glUseProgram(mProgram);
Jamie Madill2453dbc2015-07-14 11:35:42 -04001416 glUniform1i(mTextureArrayLocation, 0);
1417
1418 // The first draw worked correctly.
1419 glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGB, 4, 4, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, &pixelData[0]);
1420
1421 glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1422 glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1423 glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_REPEAT);
1424 glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_REPEAT);
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001425 drawQuad(mProgram, "position", 1.0f);
Jamie Madill2453dbc2015-07-14 11:35:42 -04001426 EXPECT_PIXEL_EQ(0, 0, 0, 255, 0, 255);
1427
1428 // The dimension of the respecification must match the original exactly to trigger the bug.
1429 glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGB, 4, 4, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, &pixelData[0]);
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001430 drawQuad(mProgram, "position", 1.0f);
Jamie Madill2453dbc2015-07-14 11:35:42 -04001431 EXPECT_PIXEL_EQ(0, 0, 0, 255, 0, 255);
1432
1433 ASSERT_GL_NO_ERROR();
1434}
1435
Olli Etuaho1a679902016-01-14 12:21:47 +02001436// Test shadow sampler and regular non-shadow sampler coexisting in the same shader.
1437// This test is needed especially to confirm that sampler registers get assigned correctly on
1438// the HLSL backend even when there's a mix of different HLSL sampler and texture types.
1439TEST_P(ShadowSamplerPlusSampler3DTestES3, ShadowSamplerPlusSampler3DDraw)
1440{
1441 glActiveTexture(GL_TEXTURE0);
1442 glBindTexture(GL_TEXTURE_3D, mTexture3D);
1443 GLubyte texData[4];
1444 texData[0] = 0;
1445 texData[1] = 60;
1446 texData[2] = 0;
1447 texData[3] = 255;
1448 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, texData);
1449
1450 glActiveTexture(GL_TEXTURE1);
1451 glBindTexture(GL_TEXTURE_2D, mTextureShadow);
1452 GLfloat depthTexData[1];
1453 depthTexData[0] = 0.5f;
1454 glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32F, 1, 1, 0, GL_DEPTH_COMPONENT, GL_FLOAT,
1455 depthTexData);
1456
1457 glUseProgram(mProgram);
1458 glUniform1f(mDepthRefUniformLocation, 0.3f);
1459 glUniform1i(mTexture3DUniformLocation, 0);
1460 glUniform1i(mTextureShadowUniformLocation, 1);
1461
1462 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
1463 drawQuad(mProgram, "position", 0.5f);
1464 EXPECT_GL_NO_ERROR();
1465 // The shader writes 0.5 * <comparison result (1.0)> + <texture color>
1466 EXPECT_PIXEL_NEAR(0, 0, 128, 188, 128, 255, 2);
1467
1468 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_GREATER);
1469 drawQuad(mProgram, "position", 0.5f);
1470 EXPECT_GL_NO_ERROR();
1471 // The shader writes 0.5 * <comparison result (0.0)> + <texture color>
1472 EXPECT_PIXEL_NEAR(0, 0, 0, 60, 0, 255, 2);
1473}
1474
Olli Etuahoc8c99a02016-01-14 16:47:22 +02001475// Test multiple different sampler types in the same shader.
1476// This test makes sure that even if sampler / texture registers get grouped together based on type
1477// or otherwise get shuffled around in the HLSL backend of the shader translator, the D3D renderer
1478// still has the right register index information for each ESSL sampler.
1479// The tested ESSL samplers have the following types in D3D11 HLSL:
1480// sampler2D: Texture2D + SamplerState
1481// samplerCube: TextureCube + SamplerState
1482// sampler2DShadow: Texture2D + SamplerComparisonState
1483// samplerCubeShadow: TextureCube + SamplerComparisonState
1484TEST_P(SamplerTypeMixTestES3, SamplerTypeMixDraw)
1485{
1486 glActiveTexture(GL_TEXTURE0);
1487 glBindTexture(GL_TEXTURE_2D, mTexture2D);
1488 GLubyte texData[4];
1489 texData[0] = 0;
1490 texData[1] = 0;
1491 texData[2] = 120;
1492 texData[3] = 255;
1493 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, texData);
1494
1495 glActiveTexture(GL_TEXTURE1);
1496 glBindTexture(GL_TEXTURE_CUBE_MAP, mTextureCube);
1497 texData[0] = 0;
1498 texData[1] = 90;
1499 texData[2] = 0;
1500 texData[3] = 255;
1501 glTexStorage2D(GL_TEXTURE_CUBE_MAP, 1, GL_RGBA8, 1, 1);
1502 glTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE,
1503 texData);
1504
1505 glActiveTexture(GL_TEXTURE2);
1506 glBindTexture(GL_TEXTURE_2D, mTexture2DShadow);
1507 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
1508 GLfloat depthTexData[1];
1509 depthTexData[0] = 0.5f;
1510 glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32F, 1, 1, 0, GL_DEPTH_COMPONENT, GL_FLOAT,
1511 depthTexData);
1512
1513 glActiveTexture(GL_TEXTURE3);
1514 glBindTexture(GL_TEXTURE_CUBE_MAP, mTextureCubeShadow);
1515 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
1516 depthTexData[0] = 0.2f;
1517 glTexStorage2D(GL_TEXTURE_CUBE_MAP, 1, GL_DEPTH_COMPONENT32F, 1, 1);
1518 glTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, 0, 0, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT,
1519 depthTexData);
1520
1521 EXPECT_GL_NO_ERROR();
1522
1523 glUseProgram(mProgram);
1524 glUniform1f(mDepthRefUniformLocation, 0.3f);
1525 glUniform1i(mTexture2DUniformLocation, 0);
1526 glUniform1i(mTextureCubeUniformLocation, 1);
1527 glUniform1i(mTexture2DShadowUniformLocation, 2);
1528 glUniform1i(mTextureCubeShadowUniformLocation, 3);
1529
1530 drawQuad(mProgram, "position", 0.5f);
1531 EXPECT_GL_NO_ERROR();
1532 // The shader writes:
1533 // <texture 2d color> +
1534 // <cube map color> +
1535 // 0.25 * <comparison result (1.0)> +
1536 // 0.125 * <comparison result (0.0)>
1537 EXPECT_PIXEL_NEAR(0, 0, 64, 154, 184, 255, 2);
1538}
1539
Olli Etuahobce743a2016-01-15 17:18:28 +02001540// Test different base levels on textures accessed through the same sampler array.
1541// Calling textureSize() on the samplers hits the D3D sampler metadata workaround.
1542TEST_P(TextureSizeTextureArrayTest, BaseLevelVariesInTextureArray)
1543{
Jamie Madill518b9fa2016-03-02 11:26:02 -05001544 if ((IsAMD() || IsIntel()) && getPlatformRenderer() == EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE)
Olli Etuahobce743a2016-01-15 17:18:28 +02001545 {
1546 std::cout << "Test skipped on Intel and AMD D3D." << std::endl;
1547 return;
1548 }
1549 glActiveTexture(GL_TEXTURE0);
1550 glBindTexture(GL_TEXTURE_2D, mTexture2DA);
1551 GLsizei size = 64;
1552 for (GLint level = 0; level < 7; ++level)
1553 {
1554 ASSERT_LT(0, size);
1555 glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, size, size, 0, GL_RGBA, GL_UNSIGNED_BYTE,
1556 nullptr);
1557 size = size / 2;
1558 }
1559 ASSERT_EQ(0, size);
1560 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 1);
1561
1562 glActiveTexture(GL_TEXTURE1);
1563 glBindTexture(GL_TEXTURE_2D, mTexture2DB);
1564 size = 128;
1565 for (GLint level = 0; level < 8; ++level)
1566 {
1567 ASSERT_LT(0, size);
1568 glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, size, size, 0, GL_RGBA, GL_UNSIGNED_BYTE,
1569 nullptr);
1570 size = size / 2;
1571 }
1572 ASSERT_EQ(0, size);
1573 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 3);
1574 EXPECT_GL_NO_ERROR();
1575
1576 glUseProgram(mProgram);
1577 glUniform1i(mTexture0Location, 0);
1578 glUniform1i(mTexture1Location, 1);
1579
1580 drawQuad(mProgram, "position", 0.5f);
1581 EXPECT_GL_NO_ERROR();
1582 // Red channel: width of level 1 of texture A: 32.
1583 // Green channel: width of level 3 of texture B: 16.
1584 EXPECT_PIXEL_NEAR(0, 0, 32, 16, 0, 255, 2);
1585}
1586
Olli Etuaho6ee394a2016-02-18 13:30:09 +02001587// When sampling a texture without an alpha channel, "1" is returned as the alpha value.
1588// ES 3.0.4 table 3.24
1589TEST_P(Texture2DTestES3, TextureRGBImplicitAlpha1)
1590{
1591 glActiveTexture(GL_TEXTURE0);
1592 glBindTexture(GL_TEXTURE_2D, mTexture2D);
1593 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, nullptr);
1594 EXPECT_GL_NO_ERROR();
1595
1596 drawQuad(mProgram, "position", 0.5f);
1597
1598 EXPECT_PIXEL_ALPHA_EQ(0, 0, 255);
1599}
1600
1601// When sampling a texture without an alpha channel, "1" is returned as the alpha value.
1602// ES 3.0.4 table 3.24
1603TEST_P(Texture2DTestES3, TextureLuminanceImplicitAlpha1)
1604{
1605 glActiveTexture(GL_TEXTURE0);
1606 glBindTexture(GL_TEXTURE_2D, mTexture2D);
1607 glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 1, 1, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, nullptr);
1608 EXPECT_GL_NO_ERROR();
1609
1610 drawQuad(mProgram, "position", 0.5f);
1611
1612 EXPECT_PIXEL_ALPHA_EQ(0, 0, 255);
1613}
1614
1615// When sampling a texture without an alpha channel, "1" is returned as the alpha value.
1616// ES 3.0.4 table 3.24
1617TEST_P(Texture2DTestES3, TextureLuminance32ImplicitAlpha1)
1618{
1619 if (extensionEnabled("GL_OES_texture_float"))
1620 {
1621 glActiveTexture(GL_TEXTURE0);
1622 glBindTexture(GL_TEXTURE_2D, mTexture2D);
1623 glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 1, 1, 0, GL_LUMINANCE, GL_FLOAT, nullptr);
1624 EXPECT_GL_NO_ERROR();
1625
1626 drawQuad(mProgram, "position", 0.5f);
1627
1628 EXPECT_PIXEL_ALPHA_EQ(0, 0, 255);
1629 }
1630}
1631
1632// When sampling a texture without an alpha channel, "1" is returned as the alpha value.
1633// ES 3.0.4 table 3.24
1634TEST_P(Texture2DTestES3, TextureLuminance16ImplicitAlpha1)
1635{
1636 if (extensionEnabled("GL_OES_texture_half_float"))
1637 {
Jamie Madill518b9fa2016-03-02 11:26:02 -05001638 if (IsNVIDIA() && getPlatformRenderer() == EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE)
Olli Etuaho6ee394a2016-02-18 13:30:09 +02001639 {
1640 std::cout << "Test skipped on NVIDIA" << std::endl;
1641 return;
1642 }
1643 glActiveTexture(GL_TEXTURE0);
1644 glBindTexture(GL_TEXTURE_2D, mTexture2D);
1645 glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 1, 1, 0, GL_LUMINANCE, GL_HALF_FLOAT_OES,
1646 nullptr);
1647 EXPECT_GL_NO_ERROR();
1648
1649 drawQuad(mProgram, "position", 0.5f);
1650
1651 EXPECT_PIXEL_ALPHA_EQ(0, 0, 255);
1652 }
1653}
1654
1655// When sampling a texture without an alpha channel, "1" is returned as the alpha value.
1656// ES 3.0.4 table 3.24
1657TEST_P(Texture2DUnsignedIntegerAlpha1TestES3, TextureRGB8UIImplicitAlpha1)
1658{
Jamie Madill518b9fa2016-03-02 11:26:02 -05001659 if (IsIntel())
Olli Etuaho6ee394a2016-02-18 13:30:09 +02001660 {
Jamie Madill518b9fa2016-03-02 11:26:02 -05001661 std::cout << "Test disabled on Intel." << std::endl;
Olli Etuaho6ee394a2016-02-18 13:30:09 +02001662 return;
1663 }
1664 glActiveTexture(GL_TEXTURE0);
1665 glBindTexture(GL_TEXTURE_2D, mTexture2D);
1666 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8UI, 1, 1, 0, GL_RGB_INTEGER, GL_UNSIGNED_BYTE, nullptr);
1667 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1668 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1669 EXPECT_GL_NO_ERROR();
1670
1671 drawQuad(mProgram, "position", 0.5f);
1672
1673 EXPECT_PIXEL_ALPHA_EQ(0, 0, 255);
1674}
1675
1676// When sampling a texture without an alpha channel, "1" is returned as the alpha value.
1677// ES 3.0.4 table 3.24
1678TEST_P(Texture2DIntegerAlpha1TestES3, TextureRGB8IImplicitAlpha1)
1679{
Jamie Madill518b9fa2016-03-02 11:26:02 -05001680 if (IsIntel())
Olli Etuaho6ee394a2016-02-18 13:30:09 +02001681 {
Jamie Madill518b9fa2016-03-02 11:26:02 -05001682 std::cout << "Test disabled on Intel." << std::endl;
Olli Etuaho6ee394a2016-02-18 13:30:09 +02001683 return;
1684 }
1685 glActiveTexture(GL_TEXTURE0);
1686 glBindTexture(GL_TEXTURE_2D, mTexture2D);
1687
1688 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8I, 1, 1, 0, GL_RGB_INTEGER, GL_BYTE, nullptr);
1689 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1690 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1691 EXPECT_GL_NO_ERROR();
1692
1693 drawQuad(mProgram, "position", 0.5f);
1694
1695 EXPECT_PIXEL_ALPHA_EQ(0, 0, 255);
1696}
1697
1698// When sampling a texture without an alpha channel, "1" is returned as the alpha value.
1699// ES 3.0.4 table 3.24
1700TEST_P(Texture2DUnsignedIntegerAlpha1TestES3, TextureRGB16UIImplicitAlpha1)
1701{
Jamie Madill518b9fa2016-03-02 11:26:02 -05001702 if (IsIntel())
Olli Etuaho6ee394a2016-02-18 13:30:09 +02001703 {
Jamie Madill518b9fa2016-03-02 11:26:02 -05001704 std::cout << "Test disabled on Intel." << std::endl;
Olli Etuaho6ee394a2016-02-18 13:30:09 +02001705 return;
1706 }
1707 glActiveTexture(GL_TEXTURE0);
1708 glBindTexture(GL_TEXTURE_2D, mTexture2D);
1709 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB16UI, 1, 1, 0, GL_RGB_INTEGER, GL_UNSIGNED_SHORT, nullptr);
1710 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1711 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1712 EXPECT_GL_NO_ERROR();
1713
1714 drawQuad(mProgram, "position", 0.5f);
1715
1716 EXPECT_PIXEL_ALPHA_EQ(0, 0, 255);
1717}
1718
1719// When sampling a texture without an alpha channel, "1" is returned as the alpha value.
1720// ES 3.0.4 table 3.24
1721TEST_P(Texture2DIntegerAlpha1TestES3, TextureRGB16IImplicitAlpha1)
1722{
Jamie Madill518b9fa2016-03-02 11:26:02 -05001723 if (IsIntel())
Olli Etuaho6ee394a2016-02-18 13:30:09 +02001724 {
Jamie Madill518b9fa2016-03-02 11:26:02 -05001725 std::cout << "Test disabled on Intel." << std::endl;
Olli Etuaho6ee394a2016-02-18 13:30:09 +02001726 return;
1727 }
1728 glActiveTexture(GL_TEXTURE0);
1729 glBindTexture(GL_TEXTURE_2D, mTexture2D);
1730 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB16I, 1, 1, 0, GL_RGB_INTEGER, GL_SHORT, nullptr);
1731 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1732 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1733 EXPECT_GL_NO_ERROR();
1734
1735 drawQuad(mProgram, "position", 0.5f);
1736
1737 EXPECT_PIXEL_ALPHA_EQ(0, 0, 255);
1738}
1739
1740// When sampling a texture without an alpha channel, "1" is returned as the alpha value.
1741// ES 3.0.4 table 3.24
1742TEST_P(Texture2DUnsignedIntegerAlpha1TestES3, TextureRGB32UIImplicitAlpha1)
1743{
Jamie Madill518b9fa2016-03-02 11:26:02 -05001744 if (IsIntel())
Olli Etuaho6ee394a2016-02-18 13:30:09 +02001745 {
Jamie Madill518b9fa2016-03-02 11:26:02 -05001746 std::cout << "Test disabled on Intel." << std::endl;
Olli Etuaho6ee394a2016-02-18 13:30:09 +02001747 return;
1748 }
1749 glActiveTexture(GL_TEXTURE0);
1750 glBindTexture(GL_TEXTURE_2D, mTexture2D);
1751 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB32UI, 1, 1, 0, GL_RGB_INTEGER, GL_UNSIGNED_INT, nullptr);
1752 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1753 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1754 EXPECT_GL_NO_ERROR();
1755
1756 drawQuad(mProgram, "position", 0.5f);
1757
1758 EXPECT_PIXEL_ALPHA_EQ(0, 0, 255);
1759}
1760
1761// When sampling a texture without an alpha channel, "1" is returned as the alpha value.
1762// ES 3.0.4 table 3.24
1763TEST_P(Texture2DIntegerAlpha1TestES3, TextureRGB32IImplicitAlpha1)
1764{
Jamie Madill518b9fa2016-03-02 11:26:02 -05001765 if (IsIntel())
Olli Etuaho6ee394a2016-02-18 13:30:09 +02001766 {
Jamie Madill518b9fa2016-03-02 11:26:02 -05001767 std::cout << "Test disabled on Intel." << std::endl;
Olli Etuaho6ee394a2016-02-18 13:30:09 +02001768 return;
1769 }
1770 glActiveTexture(GL_TEXTURE0);
1771 glBindTexture(GL_TEXTURE_2D, mTexture2D);
1772 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB32I, 1, 1, 0, GL_RGB_INTEGER, GL_INT, nullptr);
1773 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1774 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1775 EXPECT_GL_NO_ERROR();
1776
1777 drawQuad(mProgram, "position", 0.5f);
1778
1779 EXPECT_PIXEL_ALPHA_EQ(0, 0, 255);
1780}
1781
1782// When sampling a texture without an alpha channel, "1" is returned as the alpha value.
1783// ES 3.0.4 table 3.24
1784TEST_P(Texture2DTestES3, TextureRGBSNORMImplicitAlpha1)
1785{
1786 glActiveTexture(GL_TEXTURE0);
1787 glBindTexture(GL_TEXTURE_2D, mTexture2D);
1788 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8_SNORM, 1, 1, 0, GL_RGB, GL_BYTE, nullptr);
1789 EXPECT_GL_NO_ERROR();
1790
1791 drawQuad(mProgram, "position", 0.5f);
1792
1793 EXPECT_PIXEL_ALPHA_EQ(0, 0, 255);
1794}
1795
1796// When sampling a texture without an alpha channel, "1" is returned as the alpha value.
1797// ES 3.0.4 table 3.24
1798TEST_P(Texture2DTestES3, TextureRGB9E5ImplicitAlpha1)
1799{
1800 glActiveTexture(GL_TEXTURE0);
1801 glBindTexture(GL_TEXTURE_2D, mTexture2D);
1802 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB9_E5, 1, 1, 0, GL_RGB, GL_UNSIGNED_INT_5_9_9_9_REV,
1803 nullptr);
1804 EXPECT_GL_NO_ERROR();
1805
1806 drawQuad(mProgram, "position", 0.5f);
1807
1808 EXPECT_PIXEL_ALPHA_EQ(0, 0, 255);
1809}
1810
1811// When sampling a texture without an alpha channel, "1" is returned as the alpha value.
1812// ES 3.0.4 table 3.24
1813TEST_P(Texture2DTestES3, TextureCOMPRESSEDRGB8ETC2ImplicitAlpha1)
1814{
1815 glActiveTexture(GL_TEXTURE0);
1816 glBindTexture(GL_TEXTURE_2D, mTexture2D);
1817 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB8_ETC2, 1, 1, 0, 8, nullptr);
1818 EXPECT_GL_NO_ERROR();
1819
1820 drawQuad(mProgram, "position", 0.5f);
1821
1822 EXPECT_PIXEL_ALPHA_EQ(0, 0, 255);
1823}
1824
1825// When sampling a texture without an alpha channel, "1" is returned as the alpha value.
1826// ES 3.0.4 table 3.24
1827TEST_P(Texture2DTestES3, TextureCOMPRESSEDSRGB8ETC2ImplicitAlpha1)
1828{
1829 glActiveTexture(GL_TEXTURE0);
1830 glBindTexture(GL_TEXTURE_2D, mTexture2D);
1831 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_SRGB8_ETC2, 1, 1, 0, 8, nullptr);
1832 EXPECT_GL_NO_ERROR();
1833
1834 drawQuad(mProgram, "position", 0.5f);
1835
1836 EXPECT_PIXEL_ALPHA_EQ(0, 0, 255);
1837}
1838
Jamie Madill3d3d2f22015-09-23 16:47:51 -04001839class TextureLimitsTest : public ANGLETest
1840{
1841 protected:
1842 struct RGBA8
1843 {
1844 uint8_t R, G, B, A;
1845 };
1846
1847 TextureLimitsTest()
1848 : mProgram(0), mMaxVertexTextures(0), mMaxFragmentTextures(0), mMaxCombinedTextures(0)
1849 {
1850 setWindowWidth(128);
1851 setWindowHeight(128);
1852 setConfigRedBits(8);
1853 setConfigGreenBits(8);
1854 setConfigBlueBits(8);
1855 setConfigAlphaBits(8);
1856 }
1857
1858 ~TextureLimitsTest()
1859 {
1860 if (mProgram != 0)
1861 {
1862 glDeleteProgram(mProgram);
1863 mProgram = 0;
1864
1865 if (!mTextures.empty())
1866 {
1867 glDeleteTextures(static_cast<GLsizei>(mTextures.size()), &mTextures[0]);
1868 }
1869 }
1870 }
1871
1872 void SetUp() override
1873 {
1874 ANGLETest::SetUp();
1875
1876 glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, &mMaxVertexTextures);
1877 glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &mMaxFragmentTextures);
1878 glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &mMaxCombinedTextures);
1879
1880 ASSERT_GL_NO_ERROR();
1881 }
1882
1883 void compileProgramWithTextureCounts(const std::string &vertexPrefix,
1884 GLint vertexTextureCount,
1885 GLint vertexActiveTextureCount,
1886 const std::string &fragPrefix,
1887 GLint fragmentTextureCount,
1888 GLint fragmentActiveTextureCount)
1889 {
1890 std::stringstream vertexShaderStr;
1891 vertexShaderStr << "attribute vec2 position;\n"
1892 << "varying vec4 color;\n"
1893 << "varying vec2 texCoord;\n";
1894
1895 for (GLint textureIndex = 0; textureIndex < vertexTextureCount; ++textureIndex)
1896 {
1897 vertexShaderStr << "uniform sampler2D " << vertexPrefix << textureIndex << ";\n";
1898 }
1899
1900 vertexShaderStr << "void main() {\n"
1901 << " gl_Position = vec4(position, 0, 1);\n"
1902 << " texCoord = (position * 0.5) + 0.5;\n"
1903 << " color = vec4(0);\n";
1904
1905 for (GLint textureIndex = 0; textureIndex < vertexActiveTextureCount; ++textureIndex)
1906 {
1907 vertexShaderStr << " color += texture2D(" << vertexPrefix << textureIndex
1908 << ", texCoord);\n";
1909 }
1910
1911 vertexShaderStr << "}";
1912
1913 std::stringstream fragmentShaderStr;
1914 fragmentShaderStr << "varying mediump vec4 color;\n"
1915 << "varying mediump vec2 texCoord;\n";
1916
1917 for (GLint textureIndex = 0; textureIndex < fragmentTextureCount; ++textureIndex)
1918 {
1919 fragmentShaderStr << "uniform sampler2D " << fragPrefix << textureIndex << ";\n";
1920 }
1921
1922 fragmentShaderStr << "void main() {\n"
1923 << " gl_FragColor = color;\n";
1924
1925 for (GLint textureIndex = 0; textureIndex < fragmentActiveTextureCount; ++textureIndex)
1926 {
1927 fragmentShaderStr << " gl_FragColor += texture2D(" << fragPrefix << textureIndex
1928 << ", texCoord);\n";
1929 }
1930
1931 fragmentShaderStr << "}";
1932
1933 const std::string &vertexShaderSource = vertexShaderStr.str();
1934 const std::string &fragmentShaderSource = fragmentShaderStr.str();
1935
1936 mProgram = CompileProgram(vertexShaderSource, fragmentShaderSource);
1937 }
1938
1939 RGBA8 getPixel(GLint texIndex)
1940 {
1941 RGBA8 pixel = {static_cast<uint8_t>(texIndex & 0x7u), static_cast<uint8_t>(texIndex >> 3),
1942 0, 255u};
1943 return pixel;
1944 }
1945
1946 void initTextures(GLint tex2DCount, GLint texCubeCount)
1947 {
1948 GLint totalCount = tex2DCount + texCubeCount;
1949 mTextures.assign(totalCount, 0);
1950 glGenTextures(totalCount, &mTextures[0]);
1951 ASSERT_GL_NO_ERROR();
1952
1953 std::vector<RGBA8> texData(16 * 16);
1954
1955 GLint texIndex = 0;
1956 for (; texIndex < tex2DCount; ++texIndex)
1957 {
1958 texData.assign(texData.size(), getPixel(texIndex));
1959 glActiveTexture(GL_TEXTURE0 + texIndex);
1960 glBindTexture(GL_TEXTURE_2D, mTextures[texIndex]);
1961 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE,
1962 &texData[0]);
1963 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1964 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1965 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
1966 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
1967 }
1968
1969 ASSERT_GL_NO_ERROR();
1970
1971 for (; texIndex < texCubeCount; ++texIndex)
1972 {
1973 texData.assign(texData.size(), getPixel(texIndex));
1974 glActiveTexture(GL_TEXTURE0 + texIndex);
1975 glBindTexture(GL_TEXTURE_CUBE_MAP, mTextures[texIndex]);
1976 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGBA, 16, 16, 0, GL_RGBA,
1977 GL_UNSIGNED_BYTE, &texData[0]);
1978 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGBA, 16, 16, 0, GL_RGBA,
1979 GL_UNSIGNED_BYTE, &texData[0]);
1980 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGBA, 16, 16, 0, GL_RGBA,
1981 GL_UNSIGNED_BYTE, &texData[0]);
1982 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGBA, 16, 16, 0, GL_RGBA,
1983 GL_UNSIGNED_BYTE, &texData[0]);
1984 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGBA, 16, 16, 0, GL_RGBA,
1985 GL_UNSIGNED_BYTE, &texData[0]);
1986 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGBA, 16, 16, 0, GL_RGBA,
1987 GL_UNSIGNED_BYTE, &texData[0]);
1988 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1989 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1990 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
1991 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
1992 }
1993
1994 ASSERT_GL_NO_ERROR();
1995 }
1996
1997 void testWithTextures(GLint vertexTextureCount,
1998 const std::string &vertexTexturePrefix,
1999 GLint fragmentTextureCount,
2000 const std::string &fragmentTexturePrefix)
2001 {
2002 // Generate textures
2003 initTextures(vertexTextureCount + fragmentTextureCount, 0);
2004
2005 glUseProgram(mProgram);
2006 RGBA8 expectedSum = {0};
2007 for (GLint texIndex = 0; texIndex < vertexTextureCount; ++texIndex)
2008 {
2009 std::stringstream uniformNameStr;
2010 uniformNameStr << vertexTexturePrefix << texIndex;
2011 const std::string &uniformName = uniformNameStr.str();
2012 GLint location = glGetUniformLocation(mProgram, uniformName.c_str());
2013 ASSERT_NE(-1, location);
2014
2015 glUniform1i(location, texIndex);
2016 RGBA8 contribution = getPixel(texIndex);
2017 expectedSum.R += contribution.R;
2018 expectedSum.G += contribution.G;
2019 }
2020
2021 for (GLint texIndex = 0; texIndex < fragmentTextureCount; ++texIndex)
2022 {
2023 std::stringstream uniformNameStr;
2024 uniformNameStr << fragmentTexturePrefix << texIndex;
2025 const std::string &uniformName = uniformNameStr.str();
2026 GLint location = glGetUniformLocation(mProgram, uniformName.c_str());
2027 ASSERT_NE(-1, location);
2028
2029 glUniform1i(location, texIndex + vertexTextureCount);
2030 RGBA8 contribution = getPixel(texIndex + vertexTextureCount);
2031 expectedSum.R += contribution.R;
2032 expectedSum.G += contribution.G;
2033 }
2034
2035 ASSERT_GE(256u, expectedSum.G);
2036
2037 drawQuad(mProgram, "position", 0.5f);
2038 ASSERT_GL_NO_ERROR();
2039 EXPECT_PIXEL_EQ(0, 0, expectedSum.R, expectedSum.G, 0, 255);
2040 }
2041
2042 GLuint mProgram;
2043 std::vector<GLuint> mTextures;
2044 GLint mMaxVertexTextures;
2045 GLint mMaxFragmentTextures;
2046 GLint mMaxCombinedTextures;
2047};
2048
2049// Test rendering with the maximum vertex texture units.
2050TEST_P(TextureLimitsTest, MaxVertexTextures)
2051{
Jamie Madill1ea9aaa2015-10-07 11:13:55 -04002052 // TODO(jmadill): Figure out why this fails on Intel.
Jamie Madill518b9fa2016-03-02 11:26:02 -05002053 if (IsIntel() && GetParam().getRenderer() == EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE)
Jamie Madill1ea9aaa2015-10-07 11:13:55 -04002054 {
2055 std::cout << "Test skipped on Intel." << std::endl;
2056 return;
2057 }
2058
Jamie Madill3d3d2f22015-09-23 16:47:51 -04002059 compileProgramWithTextureCounts("tex", mMaxVertexTextures, mMaxVertexTextures, "tex", 0, 0);
2060 ASSERT_NE(0u, mProgram);
2061 ASSERT_GL_NO_ERROR();
2062
2063 testWithTextures(mMaxVertexTextures, "tex", 0, "tex");
2064}
2065
2066// Test rendering with the maximum fragment texture units.
2067TEST_P(TextureLimitsTest, MaxFragmentTextures)
2068{
Jamie Madill1ea9aaa2015-10-07 11:13:55 -04002069 // TODO(jmadill): Figure out why this fails on Intel.
Jamie Madill518b9fa2016-03-02 11:26:02 -05002070 if (IsIntel() && GetParam().getRenderer() == EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE)
Jamie Madill1ea9aaa2015-10-07 11:13:55 -04002071 {
2072 std::cout << "Test skipped on Intel." << std::endl;
2073 return;
2074 }
2075
Jamie Madill3d3d2f22015-09-23 16:47:51 -04002076 compileProgramWithTextureCounts("tex", 0, 0, "tex", mMaxFragmentTextures, mMaxFragmentTextures);
2077 ASSERT_NE(0u, mProgram);
2078 ASSERT_GL_NO_ERROR();
2079
2080 testWithTextures(mMaxFragmentTextures, "tex", 0, "tex");
2081}
2082
2083// Test rendering with maximum combined texture units.
2084TEST_P(TextureLimitsTest, MaxCombinedTextures)
2085{
Jamie Madill412f17d2015-09-25 08:43:54 -04002086 // TODO(jmadill): Investigate workaround.
Jamie Madill518b9fa2016-03-02 11:26:02 -05002087 if (IsIntel() && GetParam() == ES2_OPENGL())
Jamie Madill412f17d2015-09-25 08:43:54 -04002088 {
2089 std::cout << "Test skipped on Intel." << std::endl;
2090 return;
2091 }
2092
Jamie Madill3d3d2f22015-09-23 16:47:51 -04002093 GLint vertexTextures = mMaxVertexTextures;
2094
2095 if (vertexTextures + mMaxFragmentTextures > mMaxCombinedTextures)
2096 {
2097 vertexTextures = mMaxCombinedTextures - mMaxFragmentTextures;
2098 }
2099
2100 compileProgramWithTextureCounts("vtex", vertexTextures, vertexTextures, "ftex",
2101 mMaxFragmentTextures, mMaxFragmentTextures);
2102 ASSERT_NE(0u, mProgram);
2103 ASSERT_GL_NO_ERROR();
2104
2105 testWithTextures(vertexTextures, "vtex", mMaxFragmentTextures, "ftex");
2106}
2107
2108// Negative test for exceeding the number of vertex textures
2109TEST_P(TextureLimitsTest, ExcessiveVertexTextures)
2110{
2111 compileProgramWithTextureCounts("tex", mMaxVertexTextures + 1, mMaxVertexTextures + 1, "tex", 0,
2112 0);
2113 ASSERT_EQ(0u, mProgram);
2114}
2115
2116// Negative test for exceeding the number of fragment textures
2117TEST_P(TextureLimitsTest, ExcessiveFragmentTextures)
2118{
2119 compileProgramWithTextureCounts("tex", 0, 0, "tex", mMaxFragmentTextures + 1,
2120 mMaxFragmentTextures + 1);
2121 ASSERT_EQ(0u, mProgram);
2122}
2123
2124// Test active vertex textures under the limit, but excessive textures specified.
2125TEST_P(TextureLimitsTest, MaxActiveVertexTextures)
2126{
Jamie Madill1ea9aaa2015-10-07 11:13:55 -04002127 // TODO(jmadill): Figure out why this fails on Intel.
Jamie Madill518b9fa2016-03-02 11:26:02 -05002128 if (IsIntel() && GetParam().getRenderer() == EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE)
Jamie Madill1ea9aaa2015-10-07 11:13:55 -04002129 {
2130 std::cout << "Test skipped on Intel." << std::endl;
2131 return;
2132 }
2133
Jamie Madill3d3d2f22015-09-23 16:47:51 -04002134 compileProgramWithTextureCounts("tex", mMaxVertexTextures + 4, mMaxVertexTextures, "tex", 0, 0);
2135 ASSERT_NE(0u, mProgram);
2136 ASSERT_GL_NO_ERROR();
2137
2138 testWithTextures(mMaxVertexTextures, "tex", 0, "tex");
2139}
2140
2141// Test active fragment textures under the limit, but excessive textures specified.
2142TEST_P(TextureLimitsTest, MaxActiveFragmentTextures)
2143{
Jamie Madill1ea9aaa2015-10-07 11:13:55 -04002144 // TODO(jmadill): Figure out why this fails on Intel.
Jamie Madill518b9fa2016-03-02 11:26:02 -05002145 if (IsIntel() && GetParam().getRenderer() == EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE)
Jamie Madill1ea9aaa2015-10-07 11:13:55 -04002146 {
2147 std::cout << "Test skipped on Intel." << std::endl;
2148 return;
2149 }
2150
Jamie Madill3d3d2f22015-09-23 16:47:51 -04002151 compileProgramWithTextureCounts("tex", 0, 0, "tex", mMaxFragmentTextures + 4,
2152 mMaxFragmentTextures);
2153 ASSERT_NE(0u, mProgram);
2154 ASSERT_GL_NO_ERROR();
2155
2156 testWithTextures(0, "tex", mMaxFragmentTextures, "tex");
2157}
2158
2159// Negative test for pointing two sampler uniforms of different types to the same texture.
Olli Etuaho4a8329f2016-01-11 17:12:57 +02002160// GLES 2.0.25 section 2.10.4 page 39.
Jamie Madill3d3d2f22015-09-23 16:47:51 -04002161TEST_P(TextureLimitsTest, TextureTypeConflict)
2162{
2163 const std::string &vertexShader =
2164 "attribute vec2 position;\n"
2165 "varying float color;\n"
2166 "uniform sampler2D tex2D;\n"
2167 "uniform samplerCube texCube;\n"
2168 "void main() {\n"
2169 " gl_Position = vec4(position, 0, 1);\n"
2170 " vec2 texCoord = (position * 0.5) + 0.5;\n"
2171 " color = texture2D(tex2D, texCoord).x;\n"
2172 " color += textureCube(texCube, vec3(texCoord, 0)).x;\n"
2173 "}";
2174 const std::string &fragmentShader =
2175 "varying mediump float color;\n"
2176 "void main() {\n"
2177 " gl_FragColor = vec4(color, 0, 0, 1);\n"
2178 "}";
2179
2180 mProgram = CompileProgram(vertexShader, fragmentShader);
2181 ASSERT_NE(0u, mProgram);
2182
2183 initTextures(1, 0);
2184
2185 glUseProgram(mProgram);
2186 GLint tex2DLocation = glGetUniformLocation(mProgram, "tex2D");
2187 ASSERT_NE(-1, tex2DLocation);
2188 GLint texCubeLocation = glGetUniformLocation(mProgram, "texCube");
2189 ASSERT_NE(-1, texCubeLocation);
2190
2191 glUniform1i(tex2DLocation, 0);
2192 glUniform1i(texCubeLocation, 0);
2193 ASSERT_GL_NO_ERROR();
2194
2195 drawQuad(mProgram, "position", 0.5f);
2196 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
2197}
2198
2199// Negative test for rendering with texture outside the valid range.
Olli Etuaho4a8329f2016-01-11 17:12:57 +02002200// TODO(jmadill): Possibly adjust the test according to the spec:
2201// GLES 3.0.4 section 2.12.7 mentions that specifying an out-of-range sampler uniform value
2202// generates an INVALID_VALUE error - GLES 2.0 doesn't yet have this mention.
Jamie Madill3d3d2f22015-09-23 16:47:51 -04002203TEST_P(TextureLimitsTest, DrawWithTexturePastMaximum)
2204{
2205 const std::string &vertexShader =
2206 "attribute vec2 position;\n"
2207 "varying float color;\n"
2208 "uniform sampler2D tex2D;\n"
2209 "void main() {\n"
2210 " gl_Position = vec4(position, 0, 1);\n"
2211 " vec2 texCoord = (position * 0.5) + 0.5;\n"
2212 " color = texture2D(tex2D, texCoord).x;\n"
2213 "}";
2214 const std::string &fragmentShader =
2215 "varying mediump float color;\n"
2216 "void main() {\n"
2217 " gl_FragColor = vec4(color, 0, 0, 1);\n"
2218 "}";
2219
2220 mProgram = CompileProgram(vertexShader, fragmentShader);
2221 ASSERT_NE(0u, mProgram);
2222
2223 glUseProgram(mProgram);
2224 GLint tex2DLocation = glGetUniformLocation(mProgram, "tex2D");
2225 ASSERT_NE(-1, tex2DLocation);
2226
2227 glUniform1i(tex2DLocation, mMaxCombinedTextures);
2228 ASSERT_GL_NO_ERROR();
2229
2230 drawQuad(mProgram, "position", 0.5f);
2231 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
2232}
2233
Jamie Madillfa05f602015-05-07 13:47:11 -04002234// Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against.
Olli Etuaho51f1c0f2016-01-13 16:16:24 +02002235// TODO(oetuaho): Enable all below tests on OpenGL. Requires a fix for ANGLE bug 1278.
Geoff Lange0cc2a42016-01-20 10:58:17 -05002236ANGLE_INSTANTIATE_TEST(Texture2DTest,
2237 ES2_D3D9(),
2238 ES2_D3D11(),
2239 ES2_D3D11_FL9_3(),
2240 ES2_OPENGL(),
2241 ES2_OPENGLES());
2242ANGLE_INSTANTIATE_TEST(TextureCubeTest,
2243 ES2_D3D9(),
2244 ES2_D3D11(),
2245 ES2_D3D11_FL9_3(),
2246 ES2_OPENGL(),
2247 ES2_OPENGLES());
Olli Etuaho51f1c0f2016-01-13 16:16:24 +02002248ANGLE_INSTANTIATE_TEST(Texture2DTestWithDrawScale,
2249 ES2_D3D9(),
2250 ES2_D3D11(),
2251 ES2_D3D11_FL9_3(),
Geoff Lange0cc2a42016-01-20 10:58:17 -05002252 ES2_OPENGL(),
2253 ES2_OPENGLES());
Olli Etuaho51f1c0f2016-01-13 16:16:24 +02002254ANGLE_INSTANTIATE_TEST(Sampler2DAsFunctionParameterTest,
2255 ES2_D3D9(),
2256 ES2_D3D11(),
2257 ES2_D3D11_FL9_3(),
Geoff Lange0cc2a42016-01-20 10:58:17 -05002258 ES2_OPENGL(),
2259 ES2_OPENGLES());
2260ANGLE_INSTANTIATE_TEST(SamplerArrayTest,
2261 ES2_D3D9(),
2262 ES2_D3D11(),
2263 ES2_D3D11_FL9_3(),
2264 ES2_OPENGL(),
2265 ES2_OPENGLES());
2266ANGLE_INSTANTIATE_TEST(SamplerArrayAsFunctionParameterTest,
2267 ES2_D3D9(),
2268 ES2_D3D11(),
2269 ES2_D3D11_FL9_3(),
2270 ES2_OPENGL(),
2271 ES2_OPENGLES());
2272ANGLE_INSTANTIATE_TEST(Texture2DTestES3, ES3_D3D11(), ES3_OPENGL(), ES3_OPENGLES());
Olli Etuaho6ee394a2016-02-18 13:30:09 +02002273ANGLE_INSTANTIATE_TEST(Texture2DIntegerAlpha1TestES3, ES3_D3D11(), ES3_OPENGL(), ES3_OPENGLES());
2274ANGLE_INSTANTIATE_TEST(Texture2DUnsignedIntegerAlpha1TestES3,
2275 ES3_D3D11(),
2276 ES3_OPENGL(),
2277 ES3_OPENGLES());
Geoff Lange0cc2a42016-01-20 10:58:17 -05002278ANGLE_INSTANTIATE_TEST(ShadowSamplerPlusSampler3DTestES3,
2279 ES3_D3D11(),
2280 ES3_OPENGL(),
2281 ES3_OPENGLES());
2282ANGLE_INSTANTIATE_TEST(SamplerTypeMixTestES3, ES3_D3D11(), ES3_OPENGL(), ES3_OPENGLES());
2283ANGLE_INSTANTIATE_TEST(Texture2DArrayTestES3, ES3_D3D11(), ES3_OPENGL(), ES3_OPENGLES());
Olli Etuahobce743a2016-01-15 17:18:28 +02002284ANGLE_INSTANTIATE_TEST(TextureSizeTextureArrayTest, ES3_D3D11(), ES3_OPENGL());
Geoff Lange0cc2a42016-01-20 10:58:17 -05002285ANGLE_INSTANTIATE_TEST(TextureLimitsTest, ES2_D3D11(), ES2_OPENGL(), ES2_OPENGLES());
Jamie Madillfa05f602015-05-07 13:47:11 -04002286
2287} // namespace