blob: b086461d8d9dd86c2afdc435fd4be394b5245216 [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 Etuaho4a8329f2016-01-11 17:12:57 +020014class TexCoordDrawTest : public ANGLETest
Jamie Madillf67115c2014-04-22 13:14:05 -040015{
Jamie Madillbc393df2015-01-29 13:46:07 -050016 protected:
Olli Etuaho51f1c0f2016-01-13 16:16:24 +020017 TexCoordDrawTest() : ANGLETest(), mProgram(0), mFramebuffer(0), mFramebufferColorTexture(0)
Jamie Madillf67115c2014-04-22 13:14:05 -040018 {
19 setWindowWidth(128);
20 setWindowHeight(128);
21 setConfigRedBits(8);
22 setConfigGreenBits(8);
23 setConfigBlueBits(8);
24 setConfigAlphaBits(8);
25 }
26
Olli Etuaho4a8329f2016-01-11 17:12:57 +020027 virtual std::string getVertexShaderSource()
Jamie Madillf67115c2014-04-22 13:14:05 -040028 {
Olli Etuaho4a8329f2016-01-11 17:12:57 +020029 return std::string(SHADER_SOURCE
Geoff Langc41e42d2014-04-28 10:58:16 -040030 (
31 precision highp float;
32 attribute vec4 position;
33 varying vec2 texcoord;
34
35 void main()
36 {
Olli Etuaho4a8329f2016-01-11 17:12:57 +020037 gl_Position = vec4(position.xy, 0.0, 1.0);
Geoff Langc41e42d2014-04-28 10:58:16 -040038 texcoord = (position.xy * 0.5) + 0.5;
39 }
Olli Etuaho4a8329f2016-01-11 17:12:57 +020040 )
Geoff Langc41e42d2014-04-28 10:58:16 -040041 );
Olli Etuaho4a8329f2016-01-11 17:12:57 +020042 }
Geoff Langc41e42d2014-04-28 10:58:16 -040043
Olli Etuaho4a8329f2016-01-11 17:12:57 +020044 virtual std::string getFragmentShaderSource() = 0;
45
Olli Etuahoa1c917f2016-04-06 13:50:03 +030046 virtual void setUpProgram()
Olli Etuaho4a8329f2016-01-11 17:12:57 +020047 {
Olli Etuaho4a8329f2016-01-11 17:12:57 +020048 const std::string vertexShaderSource = getVertexShaderSource();
49 const std::string fragmentShaderSource = getFragmentShaderSource();
50
51 mProgram = CompileProgram(vertexShaderSource, fragmentShaderSource);
52 ASSERT_NE(0u, mProgram);
53 ASSERT_GL_NO_ERROR();
Olli Etuahoa1c917f2016-04-06 13:50:03 +030054 }
55
56 void SetUp() override
57 {
58 ANGLETest::SetUp();
Olli Etuaho51f1c0f2016-01-13 16:16:24 +020059
60 setUpFramebuffer();
Olli Etuaho4a8329f2016-01-11 17:12:57 +020061 }
62
63 void TearDown() override
64 {
Olli Etuaho51f1c0f2016-01-13 16:16:24 +020065 glBindFramebuffer(GL_FRAMEBUFFER, 0);
66 glDeleteFramebuffers(1, &mFramebuffer);
67 glDeleteTextures(1, &mFramebufferColorTexture);
Olli Etuaho4a8329f2016-01-11 17:12:57 +020068 glDeleteProgram(mProgram);
69 ANGLETest::TearDown();
70 }
71
Olli Etuaho51f1c0f2016-01-13 16:16:24 +020072 void setUpFramebuffer()
73 {
74 // We use an FBO to work around an issue where the default framebuffer applies SRGB
75 // conversion (particularly known to happen incorrectly on Intel GL drivers). It's not
76 // clear whether this issue can even be fixed on all backends. For example GLES 3.0.4 spec
77 // section 4.4 says that the format of the default framebuffer is entirely up to the window
78 // system, so it might be SRGB, and GLES 3.0 doesn't have a "FRAMEBUFFER_SRGB" to turn off
79 // SRGB conversion like desktop GL does.
80 // TODO(oetuaho): Get rid of this if the underlying issue is fixed.
81 glGenFramebuffers(1, &mFramebuffer);
82 glBindFramebuffer(GL_FRAMEBUFFER, mFramebuffer);
83
84 glGenTextures(1, &mFramebufferColorTexture);
85 glBindTexture(GL_TEXTURE_2D, mFramebufferColorTexture);
86 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, getWindowWidth(), getWindowHeight(), 0, GL_RGBA,
87 GL_UNSIGNED_BYTE, nullptr);
88 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
89 mFramebufferColorTexture, 0);
90 ASSERT_GL_NO_ERROR();
91 ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
92 glBindTexture(GL_TEXTURE_2D, 0);
93 }
94
Olli Etuaho4a8329f2016-01-11 17:12:57 +020095 // Returns the created texture ID.
96 GLuint create2DTexture()
97 {
98 GLuint texture2D;
99 glGenTextures(1, &texture2D);
100 glBindTexture(GL_TEXTURE_2D, texture2D);
101 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
102 EXPECT_GL_NO_ERROR();
103 return texture2D;
104 }
105
106 GLuint mProgram;
Olli Etuaho51f1c0f2016-01-13 16:16:24 +0200107 GLuint mFramebuffer;
108
109 private:
110 GLuint mFramebufferColorTexture;
Olli Etuaho4a8329f2016-01-11 17:12:57 +0200111};
112
113class Texture2DTest : public TexCoordDrawTest
114{
115 protected:
116 Texture2DTest() : TexCoordDrawTest(), mTexture2D(0), mTexture2DUniformLocation(-1) {}
117
118 std::string getFragmentShaderSource() override
119 {
120 return std::string(SHADER_SOURCE
Geoff Langc41e42d2014-04-28 10:58:16 -0400121 (
122 precision highp float;
123 uniform sampler2D tex;
124 varying vec2 texcoord;
125
126 void main()
127 {
128 gl_FragColor = texture2D(tex, texcoord);
129 }
Olli Etuaho4a8329f2016-01-11 17:12:57 +0200130 )
Geoff Langc41e42d2014-04-28 10:58:16 -0400131 );
Olli Etuaho4a8329f2016-01-11 17:12:57 +0200132 }
Geoff Langc41e42d2014-04-28 10:58:16 -0400133
Olli Etuaho96963162016-03-21 11:54:33 +0200134 virtual const char *getTextureUniformName() { return "tex"; }
135
Olli Etuahoa1c917f2016-04-06 13:50:03 +0300136 void setUpProgram() override
137 {
138 TexCoordDrawTest::setUpProgram();
139 mTexture2DUniformLocation = glGetUniformLocation(mProgram, getTextureUniformName());
140 ASSERT_NE(-1, mTexture2DUniformLocation);
141 }
142
Olli Etuaho4a8329f2016-01-11 17:12:57 +0200143 void SetUp() override
144 {
145 TexCoordDrawTest::SetUp();
146 mTexture2D = create2DTexture();
Jamie Madilld4cfa572014-07-08 10:00:32 -0400147
Jamie Madill9aca0592014-10-06 16:26:59 -0400148 ASSERT_GL_NO_ERROR();
Jamie Madillf67115c2014-04-22 13:14:05 -0400149 }
150
Jamie Madillfa05f602015-05-07 13:47:11 -0400151 void TearDown() override
Jamie Madillf67115c2014-04-22 13:14:05 -0400152 {
Jamie Madilld4cfa572014-07-08 10:00:32 -0400153 glDeleteTextures(1, &mTexture2D);
Olli Etuaho4a8329f2016-01-11 17:12:57 +0200154 TexCoordDrawTest::TearDown();
Jamie Madillf67115c2014-04-22 13:14:05 -0400155 }
156
Jamie Madillbc393df2015-01-29 13:46:07 -0500157 // Tests CopyTexSubImage with floating point textures of various formats.
158 void testFloatCopySubImage(int sourceImageChannels, int destImageChannels)
159 {
Geoff Langbde666a2015-04-07 17:17:08 -0400160 // TODO(jmadill): Figure out why this is broken on Intel D3D11
Jamie Madill518b9fa2016-03-02 11:26:02 -0500161 if (IsIntel() && getPlatformRenderer() == EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE)
Geoff Langbde666a2015-04-07 17:17:08 -0400162 {
163 std::cout << "Test skipped on Intel D3D11." << std::endl;
164 return;
165 }
166
Olli Etuahoa1c917f2016-04-06 13:50:03 +0300167 setUpProgram();
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
Olli Etuahoa314b612016-03-10 16:43:00 +0200271 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red);
Jamie Madillbc393df2015-01-29 13:46:07 -0500272 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 }
Olli Etuahoa1c917f2016-04-06 13:50:03 +0300323
324 void SetUp() override
325 {
326 Texture2DTest::SetUp();
327 setUpProgram();
328 }
Olli Etuahoa7416ff2016-01-18 12:22:55 +0200329};
330
Olli Etuaho6ee394a2016-02-18 13:30:09 +0200331class Texture2DIntegerAlpha1TestES3 : public Texture2DTest
332{
333 protected:
334 Texture2DIntegerAlpha1TestES3() : Texture2DTest() {}
335
336 std::string getVertexShaderSource() override
337 {
338 return std::string(
339 "#version 300 es\n"
340 "out vec2 texcoord;\n"
341 "in vec4 position;\n"
342 "void main()\n"
343 "{\n"
344 " gl_Position = vec4(position.xy, 0.0, 1.0);\n"
345 " texcoord = (position.xy * 0.5) + 0.5;\n"
346 "}\n");
347 }
348
349 std::string getFragmentShaderSource() override
350 {
351 return std::string(
352 "#version 300 es\n"
353 "precision highp float;\n"
354 "uniform highp isampler2D tex;\n"
355 "in vec2 texcoord;\n"
356 "out vec4 fragColor;\n"
357 "void main()\n"
358 "{\n"
359 " vec4 green = vec4(0, 1, 0, 1);\n"
360 " vec4 black = vec4(0, 0, 0, 0);\n"
361 " fragColor = (texture(tex, texcoord).a == 1) ? green : black;\n"
362 "}\n");
363 }
Olli Etuahoa1c917f2016-04-06 13:50:03 +0300364
365 void SetUp() override
366 {
367 Texture2DTest::SetUp();
368 setUpProgram();
369 }
Olli Etuaho6ee394a2016-02-18 13:30:09 +0200370};
371
372class Texture2DUnsignedIntegerAlpha1TestES3 : public Texture2DTest
373{
374 protected:
375 Texture2DUnsignedIntegerAlpha1TestES3() : Texture2DTest() {}
376
377 std::string getVertexShaderSource() override
378 {
379 return std::string(
380 "#version 300 es\n"
381 "out vec2 texcoord;\n"
382 "in vec4 position;\n"
383 "void main()\n"
384 "{\n"
385 " gl_Position = vec4(position.xy, 0.0, 1.0);\n"
386 " texcoord = (position.xy * 0.5) + 0.5;\n"
387 "}\n");
388 }
389
390 std::string getFragmentShaderSource() override
391 {
392 return std::string(
393 "#version 300 es\n"
394 "precision highp float;\n"
395 "uniform highp usampler2D tex;\n"
396 "in vec2 texcoord;\n"
397 "out vec4 fragColor;\n"
398 "void main()\n"
399 "{\n"
400 " vec4 green = vec4(0, 1, 0, 1);\n"
401 " vec4 black = vec4(0, 0, 0, 0);\n"
402 " fragColor = (texture(tex, texcoord).a == 1u) ? green : black;\n"
403 "}\n");
404 }
Olli Etuahoa1c917f2016-04-06 13:50:03 +0300405
406 void SetUp() override
407 {
408 Texture2DTest::SetUp();
409 setUpProgram();
410 }
Olli Etuaho6ee394a2016-02-18 13:30:09 +0200411};
412
Olli Etuaho4a8329f2016-01-11 17:12:57 +0200413class Texture2DTestWithDrawScale : public Texture2DTest
Jamie Madill2453dbc2015-07-14 11:35:42 -0400414{
415 protected:
Olli Etuaho4a8329f2016-01-11 17:12:57 +0200416 Texture2DTestWithDrawScale() : Texture2DTest(), mDrawScaleUniformLocation(-1) {}
417
418 std::string getVertexShaderSource() override
Jamie Madill2453dbc2015-07-14 11:35:42 -0400419 {
Olli Etuaho4a8329f2016-01-11 17:12:57 +0200420 return std::string(SHADER_SOURCE
421 (
422 precision highp float;
423 attribute vec4 position;
424 varying vec2 texcoord;
425
426 uniform vec2 drawScale;
427
428 void main()
429 {
430 gl_Position = vec4(position.xy * drawScale, 0.0, 1.0);
431 texcoord = (position.xy * 0.5) + 0.5;
432 }
433 )
434 );
Jamie Madill2453dbc2015-07-14 11:35:42 -0400435 }
436
437 void SetUp() override
438 {
Olli Etuaho4a8329f2016-01-11 17:12:57 +0200439 Texture2DTest::SetUp();
Olli Etuahoa1c917f2016-04-06 13:50:03 +0300440
441 setUpProgram();
442
Olli Etuaho4a8329f2016-01-11 17:12:57 +0200443 mDrawScaleUniformLocation = glGetUniformLocation(mProgram, "drawScale");
444 ASSERT_NE(-1, mDrawScaleUniformLocation);
Jamie Madill2453dbc2015-07-14 11:35:42 -0400445
Olli Etuaho4a8329f2016-01-11 17:12:57 +0200446 glUseProgram(mProgram);
447 glUniform2f(mDrawScaleUniformLocation, 1.0f, 1.0f);
448 glUseProgram(0);
449 ASSERT_GL_NO_ERROR();
450 }
451
452 GLint mDrawScaleUniformLocation;
453};
454
Olli Etuaho4644a202016-01-12 15:12:53 +0200455class Sampler2DAsFunctionParameterTest : public Texture2DTest
456{
457 protected:
458 Sampler2DAsFunctionParameterTest() : Texture2DTest() {}
459
460 std::string getFragmentShaderSource() override
461 {
462 return std::string(SHADER_SOURCE
463 (
464 precision highp float;
465 uniform sampler2D tex;
466 varying vec2 texcoord;
467
468 vec4 computeFragColor(sampler2D aTex)
469 {
470 return texture2D(aTex, texcoord);
471 }
472
473 void main()
474 {
475 gl_FragColor = computeFragColor(tex);
476 }
477 )
478 );
479 }
Olli Etuahoa1c917f2016-04-06 13:50:03 +0300480
481 void SetUp() override
482 {
483 Texture2DTest::SetUp();
484 setUpProgram();
485 }
Olli Etuaho4644a202016-01-12 15:12:53 +0200486};
487
Olli Etuaho4a8329f2016-01-11 17:12:57 +0200488class TextureCubeTest : public TexCoordDrawTest
489{
490 protected:
491 TextureCubeTest()
492 : TexCoordDrawTest(),
493 mTexture2D(0),
494 mTextureCube(0),
495 mTexture2DUniformLocation(-1),
496 mTextureCubeUniformLocation(-1)
497 {
498 }
499
500 std::string getFragmentShaderSource() override
501 {
502 return std::string(SHADER_SOURCE
503 (
504 precision highp float;
505 uniform sampler2D tex2D;
506 uniform samplerCube texCube;
507 varying vec2 texcoord;
508
509 void main()
510 {
511 gl_FragColor = texture2D(tex2D, texcoord);
512 gl_FragColor += textureCube(texCube, vec3(texcoord, 0));
513 }
514 )
515 );
516 }
517
518 void SetUp() override
519 {
520 TexCoordDrawTest::SetUp();
521
522 glGenTextures(1, &mTextureCube);
523 glBindTexture(GL_TEXTURE_CUBE_MAP, mTextureCube);
524 glTexStorage2DEXT(GL_TEXTURE_CUBE_MAP, 1, GL_RGBA8, 1, 1);
525 EXPECT_GL_NO_ERROR();
526
527 mTexture2D = create2DTexture();
528
Olli Etuahoa1c917f2016-04-06 13:50:03 +0300529 setUpProgram();
530
Olli Etuaho4a8329f2016-01-11 17:12:57 +0200531 mTexture2DUniformLocation = glGetUniformLocation(mProgram, "tex2D");
532 ASSERT_NE(-1, mTexture2DUniformLocation);
533 mTextureCubeUniformLocation = glGetUniformLocation(mProgram, "texCube");
534 ASSERT_NE(-1, mTextureCubeUniformLocation);
535 }
536
537 void TearDown() override
538 {
539 glDeleteTextures(1, &mTextureCube);
540 TexCoordDrawTest::TearDown();
541 }
542
543 GLuint mTexture2D;
544 GLuint mTextureCube;
545 GLint mTexture2DUniformLocation;
546 GLint mTextureCubeUniformLocation;
547};
548
Olli Etuaho2173db3d2016-01-12 13:55:14 +0200549class SamplerArrayTest : public TexCoordDrawTest
550{
551 protected:
552 SamplerArrayTest()
553 : TexCoordDrawTest(),
554 mTexture2DA(0),
555 mTexture2DB(0),
556 mTexture0UniformLocation(-1),
557 mTexture1UniformLocation(-1)
558 {
559 }
560
561 std::string getFragmentShaderSource() override
562 {
563 return std::string(SHADER_SOURCE
564 (
565 precision mediump float;
566 uniform highp sampler2D tex2DArray[2];
567 varying vec2 texcoord;
568 void main()
569 {
570 gl_FragColor = texture2D(tex2DArray[0], texcoord);
571 gl_FragColor += texture2D(tex2DArray[1], texcoord);
572 }
573 )
574 );
575 }
576
577 void SetUp() override
578 {
579 TexCoordDrawTest::SetUp();
580
Olli Etuahoa1c917f2016-04-06 13:50:03 +0300581 setUpProgram();
582
Olli Etuaho2173db3d2016-01-12 13:55:14 +0200583 mTexture0UniformLocation = glGetUniformLocation(mProgram, "tex2DArray[0]");
584 ASSERT_NE(-1, mTexture0UniformLocation);
585 mTexture1UniformLocation = glGetUniformLocation(mProgram, "tex2DArray[1]");
586 ASSERT_NE(-1, mTexture1UniformLocation);
587
588 mTexture2DA = create2DTexture();
589 mTexture2DB = create2DTexture();
590 ASSERT_GL_NO_ERROR();
591 }
592
593 void TearDown() override
594 {
595 glDeleteTextures(1, &mTexture2DA);
596 glDeleteTextures(1, &mTexture2DB);
597 TexCoordDrawTest::TearDown();
598 }
599
600 void testSamplerArrayDraw()
601 {
602 GLubyte texData[4];
603 texData[0] = 0;
604 texData[1] = 60;
605 texData[2] = 0;
606 texData[3] = 255;
607
608 glActiveTexture(GL_TEXTURE0);
609 glBindTexture(GL_TEXTURE_2D, mTexture2DA);
610 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, texData);
611
612 texData[1] = 120;
613 glActiveTexture(GL_TEXTURE1);
614 glBindTexture(GL_TEXTURE_2D, mTexture2DB);
615 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, texData);
616 EXPECT_GL_ERROR(GL_NO_ERROR);
617
618 glUseProgram(mProgram);
619 glUniform1i(mTexture0UniformLocation, 0);
620 glUniform1i(mTexture1UniformLocation, 1);
621 drawQuad(mProgram, "position", 0.5f);
622 EXPECT_GL_NO_ERROR();
623
624 EXPECT_PIXEL_NEAR(0, 0, 0, 180, 0, 255, 2);
625 }
626
627 GLuint mTexture2DA;
628 GLuint mTexture2DB;
629 GLint mTexture0UniformLocation;
630 GLint mTexture1UniformLocation;
631};
632
633
634class SamplerArrayAsFunctionParameterTest : public SamplerArrayTest
635{
636 protected:
637 SamplerArrayAsFunctionParameterTest() : SamplerArrayTest() {}
638
639 std::string getFragmentShaderSource() override
640 {
641 return std::string(SHADER_SOURCE
642 (
643 precision mediump float;
644 uniform highp sampler2D tex2DArray[2];
645 varying vec2 texcoord;
646
647 vec4 computeFragColor(highp sampler2D aTex2DArray[2])
648 {
649 return texture2D(aTex2DArray[0], texcoord) + texture2D(aTex2DArray[1], texcoord);
650 }
651
652 void main()
653 {
654 gl_FragColor = computeFragColor(tex2DArray);
655 }
656 )
657 );
658 }
659};
660
Olli Etuaho4a8329f2016-01-11 17:12:57 +0200661class Texture2DArrayTestES3 : public TexCoordDrawTest
662{
663 protected:
664 Texture2DArrayTestES3() : TexCoordDrawTest(), m2DArrayTexture(0), mTextureArrayLocation(-1) {}
665
666 std::string getVertexShaderSource() override
667 {
668 return std::string(
Jamie Madill2453dbc2015-07-14 11:35:42 -0400669 "#version 300 es\n"
670 "out vec2 texcoord;\n"
671 "in vec4 position;\n"
Olli Etuaho4a8329f2016-01-11 17:12:57 +0200672 "void main()\n"
673 "{\n"
674 " gl_Position = vec4(position.xy, 0.0, 1.0);\n"
675 " texcoord = (position.xy * 0.5) + 0.5;\n"
676 "}\n");
677 }
Jamie Madill2453dbc2015-07-14 11:35:42 -0400678
Olli Etuaho4a8329f2016-01-11 17:12:57 +0200679 std::string getFragmentShaderSource() override
680 {
681 return std::string(
Jamie Madill2453dbc2015-07-14 11:35:42 -0400682 "#version 300 es\n"
683 "precision highp float;\n"
Olli Etuaho183d7e22015-11-20 15:59:09 +0200684 "uniform highp sampler2DArray tex2DArray;\n"
Jamie Madill2453dbc2015-07-14 11:35:42 -0400685 "in vec2 texcoord;\n"
686 "out vec4 fragColor;\n"
687 "void main()\n"
688 "{\n"
689 " fragColor = texture(tex2DArray, vec3(texcoord.x, texcoord.y, 0.0));\n"
Olli Etuaho4a8329f2016-01-11 17:12:57 +0200690 "}\n");
691 }
Jamie Madill2453dbc2015-07-14 11:35:42 -0400692
Olli Etuaho4a8329f2016-01-11 17:12:57 +0200693 void SetUp() override
694 {
695 TexCoordDrawTest::SetUp();
Jamie Madill2453dbc2015-07-14 11:35:42 -0400696
Olli Etuahoa1c917f2016-04-06 13:50:03 +0300697 setUpProgram();
698
Olli Etuaho4a8329f2016-01-11 17:12:57 +0200699 mTextureArrayLocation = glGetUniformLocation(mProgram, "tex2DArray");
Jamie Madill2453dbc2015-07-14 11:35:42 -0400700 ASSERT_NE(-1, mTextureArrayLocation);
701
702 glGenTextures(1, &m2DArrayTexture);
703 ASSERT_GL_NO_ERROR();
704 }
705
706 void TearDown() override
707 {
708 glDeleteTextures(1, &m2DArrayTexture);
Olli Etuaho4a8329f2016-01-11 17:12:57 +0200709 TexCoordDrawTest::TearDown();
Jamie Madill2453dbc2015-07-14 11:35:42 -0400710 }
711
712 GLuint m2DArrayTexture;
Jamie Madill2453dbc2015-07-14 11:35:42 -0400713 GLint mTextureArrayLocation;
714};
715
Olli Etuahobce743a2016-01-15 17:18:28 +0200716class TextureSizeTextureArrayTest : public TexCoordDrawTest
717{
718 protected:
719 TextureSizeTextureArrayTest()
720 : TexCoordDrawTest(),
721 mTexture2DA(0),
722 mTexture2DB(0),
723 mTexture0Location(-1),
724 mTexture1Location(-1)
725 {
726 }
727
728 std::string getVertexShaderSource() override
729 {
730 return std::string(
731 "#version 300 es\n"
732 "in vec4 position;\n"
733 "void main()\n"
734 "{\n"
735 " gl_Position = vec4(position.xy, 0.0, 1.0);\n"
736 "}\n");
737 }
738
739 std::string getFragmentShaderSource() override
740 {
741 return std::string(
742 "#version 300 es\n"
743 "precision highp float;\n"
744 "uniform highp sampler2D tex2DArray[2];\n"
745 "out vec4 fragColor;\n"
746 "void main()\n"
747 "{\n"
748 " float red = float(textureSize(tex2DArray[0], 0).x) / 255.0;\n"
749 " float green = float(textureSize(tex2DArray[1], 0).x) / 255.0;\n"
750 " fragColor = vec4(red, green, 0.0, 1.0);\n"
751 "}\n");
752 }
753
754 void SetUp() override
755 {
756 TexCoordDrawTest::SetUp();
757
Olli Etuahoa1c917f2016-04-06 13:50:03 +0300758 setUpProgram();
759
Olli Etuahobce743a2016-01-15 17:18:28 +0200760 mTexture0Location = glGetUniformLocation(mProgram, "tex2DArray[0]");
761 ASSERT_NE(-1, mTexture0Location);
762 mTexture1Location = glGetUniformLocation(mProgram, "tex2DArray[1]");
763 ASSERT_NE(-1, mTexture1Location);
764
765 mTexture2DA = create2DTexture();
766 mTexture2DB = create2DTexture();
767 ASSERT_GL_NO_ERROR();
768 }
769
770 void TearDown() override
771 {
772 glDeleteTextures(1, &mTexture2DA);
773 glDeleteTextures(1, &mTexture2DB);
774 TexCoordDrawTest::TearDown();
775 }
776
777 GLuint mTexture2DA;
778 GLuint mTexture2DB;
779 GLint mTexture0Location;
780 GLint mTexture1Location;
781};
782
Olli Etuahoa314b612016-03-10 16:43:00 +0200783class Texture3DTestES3 : public TexCoordDrawTest
784{
785 protected:
786 Texture3DTestES3() : TexCoordDrawTest(), mTexture3D(0), mTexture3DUniformLocation(-1) {}
787
788 std::string getVertexShaderSource() override
789 {
790 return std::string(
791 "#version 300 es\n"
792 "out vec2 texcoord;\n"
793 "in vec4 position;\n"
794 "void main()\n"
795 "{\n"
796 " gl_Position = vec4(position.xy, 0.0, 1.0);\n"
797 " texcoord = (position.xy * 0.5) + 0.5;\n"
798 "}\n");
799 }
800
801 std::string getFragmentShaderSource() override
802 {
803 return std::string(
804 "#version 300 es\n"
805 "precision highp float;\n"
806 "uniform highp sampler3D tex3D;\n"
807 "in vec2 texcoord;\n"
808 "out vec4 fragColor;\n"
809 "void main()\n"
810 "{\n"
811 " fragColor = texture(tex3D, vec3(texcoord, 0.0));\n"
812 "}\n");
813 }
814
815 void SetUp() override
816 {
817 TexCoordDrawTest::SetUp();
818
819 glGenTextures(1, &mTexture3D);
820
821 setUpProgram();
822
823 mTexture3DUniformLocation = glGetUniformLocation(mProgram, "tex3D");
824 ASSERT_NE(-1, mTexture3DUniformLocation);
825 }
826
827 void TearDown() override
828 {
829 glDeleteTextures(1, &mTexture3D);
830 TexCoordDrawTest::TearDown();
831 }
832
833 GLuint mTexture3D;
834 GLint mTexture3DUniformLocation;
835};
836
Olli Etuaho1a679902016-01-14 12:21:47 +0200837class ShadowSamplerPlusSampler3DTestES3 : public TexCoordDrawTest
838{
839 protected:
840 ShadowSamplerPlusSampler3DTestES3()
841 : TexCoordDrawTest(),
842 mTextureShadow(0),
843 mTexture3D(0),
844 mTextureShadowUniformLocation(-1),
845 mTexture3DUniformLocation(-1),
846 mDepthRefUniformLocation(-1)
847 {
848 }
849
850 std::string getVertexShaderSource() override
851 {
852 return std::string(
853 "#version 300 es\n"
854 "out vec2 texcoord;\n"
855 "in vec4 position;\n"
856 "void main()\n"
857 "{\n"
858 " gl_Position = vec4(position.xy, 0.0, 1.0);\n"
859 " texcoord = (position.xy * 0.5) + 0.5;\n"
860 "}\n");
861 }
862
863 std::string getFragmentShaderSource() override
864 {
865 return std::string(
866 "#version 300 es\n"
867 "precision highp float;\n"
868 "uniform highp sampler2DShadow tex2DShadow;\n"
869 "uniform highp sampler3D tex3D;\n"
870 "in vec2 texcoord;\n"
871 "uniform float depthRef;\n"
872 "out vec4 fragColor;\n"
873 "void main()\n"
874 "{\n"
875 " fragColor = vec4(texture(tex2DShadow, vec3(texcoord, depthRef)) * 0.5);\n"
876 " fragColor += texture(tex3D, vec3(texcoord, 0.0));\n"
877 "}\n");
878 }
879
880 void SetUp() override
881 {
882 TexCoordDrawTest::SetUp();
883
884 glGenTextures(1, &mTexture3D);
885
886 glGenTextures(1, &mTextureShadow);
887 glBindTexture(GL_TEXTURE_2D, mTextureShadow);
888 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
889
Olli Etuahoa1c917f2016-04-06 13:50:03 +0300890 setUpProgram();
891
Olli Etuaho1a679902016-01-14 12:21:47 +0200892 mTextureShadowUniformLocation = glGetUniformLocation(mProgram, "tex2DShadow");
893 ASSERT_NE(-1, mTextureShadowUniformLocation);
894 mTexture3DUniformLocation = glGetUniformLocation(mProgram, "tex3D");
895 ASSERT_NE(-1, mTexture3DUniformLocation);
896 mDepthRefUniformLocation = glGetUniformLocation(mProgram, "depthRef");
897 ASSERT_NE(-1, mDepthRefUniformLocation);
898 }
899
900 void TearDown() override
901 {
902 glDeleteTextures(1, &mTextureShadow);
903 glDeleteTextures(1, &mTexture3D);
904 TexCoordDrawTest::TearDown();
905 }
906
907 GLuint mTextureShadow;
908 GLuint mTexture3D;
909 GLint mTextureShadowUniformLocation;
910 GLint mTexture3DUniformLocation;
911 GLint mDepthRefUniformLocation;
912};
913
Olli Etuahoc8c99a02016-01-14 16:47:22 +0200914class SamplerTypeMixTestES3 : public TexCoordDrawTest
915{
916 protected:
917 SamplerTypeMixTestES3()
918 : TexCoordDrawTest(),
919 mTexture2D(0),
920 mTextureCube(0),
921 mTexture2DShadow(0),
922 mTextureCubeShadow(0),
923 mTexture2DUniformLocation(-1),
924 mTextureCubeUniformLocation(-1),
925 mTexture2DShadowUniformLocation(-1),
926 mTextureCubeShadowUniformLocation(-1),
927 mDepthRefUniformLocation(-1)
928 {
929 }
930
931 std::string getVertexShaderSource() override
932 {
933 return std::string(
934 "#version 300 es\n"
935 "out vec2 texcoord;\n"
936 "in vec4 position;\n"
937 "void main()\n"
938 "{\n"
939 " gl_Position = vec4(position.xy, 0.0, 1.0);\n"
940 " texcoord = (position.xy * 0.5) + 0.5;\n"
941 "}\n");
942 }
943
944 std::string getFragmentShaderSource() override
945 {
946 return std::string(
947 "#version 300 es\n"
948 "precision highp float;\n"
949 "uniform highp sampler2D tex2D;\n"
950 "uniform highp samplerCube texCube;\n"
951 "uniform highp sampler2DShadow tex2DShadow;\n"
952 "uniform highp samplerCubeShadow texCubeShadow;\n"
953 "in vec2 texcoord;\n"
954 "uniform float depthRef;\n"
955 "out vec4 fragColor;\n"
956 "void main()\n"
957 "{\n"
958 " fragColor = texture(tex2D, texcoord);\n"
959 " fragColor += texture(texCube, vec3(1.0, 0.0, 0.0));\n"
960 " fragColor += vec4(texture(tex2DShadow, vec3(texcoord, depthRef)) * 0.25);\n"
961 " fragColor += vec4(texture(texCubeShadow, vec4(1.0, 0.0, 0.0, depthRef)) * "
962 "0.125);\n"
963 "}\n");
964 }
965
966 void SetUp() override
967 {
968 TexCoordDrawTest::SetUp();
969
970 glGenTextures(1, &mTexture2D);
971 glGenTextures(1, &mTextureCube);
972
973 glGenTextures(1, &mTexture2DShadow);
974 glBindTexture(GL_TEXTURE_2D, mTexture2DShadow);
975 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
976
977 glGenTextures(1, &mTextureCubeShadow);
978 glBindTexture(GL_TEXTURE_CUBE_MAP, mTextureCubeShadow);
979 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
980
Olli Etuahoa1c917f2016-04-06 13:50:03 +0300981 setUpProgram();
982
Olli Etuahoc8c99a02016-01-14 16:47:22 +0200983 mTexture2DUniformLocation = glGetUniformLocation(mProgram, "tex2D");
984 ASSERT_NE(-1, mTexture2DUniformLocation);
985 mTextureCubeUniformLocation = glGetUniformLocation(mProgram, "texCube");
986 ASSERT_NE(-1, mTextureCubeUniformLocation);
987 mTexture2DShadowUniformLocation = glGetUniformLocation(mProgram, "tex2DShadow");
988 ASSERT_NE(-1, mTexture2DShadowUniformLocation);
989 mTextureCubeShadowUniformLocation = glGetUniformLocation(mProgram, "texCubeShadow");
990 ASSERT_NE(-1, mTextureCubeShadowUniformLocation);
991 mDepthRefUniformLocation = glGetUniformLocation(mProgram, "depthRef");
992 ASSERT_NE(-1, mDepthRefUniformLocation);
993
994 ASSERT_GL_NO_ERROR();
995 }
996
997 void TearDown() override
998 {
999 glDeleteTextures(1, &mTexture2D);
1000 glDeleteTextures(1, &mTextureCube);
1001 glDeleteTextures(1, &mTexture2DShadow);
1002 glDeleteTextures(1, &mTextureCubeShadow);
1003 TexCoordDrawTest::TearDown();
1004 }
1005
1006 GLuint mTexture2D;
1007 GLuint mTextureCube;
1008 GLuint mTexture2DShadow;
1009 GLuint mTextureCubeShadow;
1010 GLint mTexture2DUniformLocation;
1011 GLint mTextureCubeUniformLocation;
1012 GLint mTexture2DShadowUniformLocation;
1013 GLint mTextureCubeShadowUniformLocation;
1014 GLint mDepthRefUniformLocation;
1015};
1016
Olli Etuaho96963162016-03-21 11:54:33 +02001017class SamplerInStructTest : public Texture2DTest
1018{
1019 protected:
1020 SamplerInStructTest() : Texture2DTest() {}
1021
1022 const char *getTextureUniformName() override { return "us.tex"; }
1023
1024 std::string getFragmentShaderSource() override
1025 {
1026 return std::string(
1027 "precision highp float;\n"
1028 "struct S\n"
1029 "{\n"
1030 " vec4 a;\n"
1031 " highp sampler2D tex;\n"
1032 "};\n"
1033 "uniform S us;\n"
1034 "varying vec2 texcoord;\n"
1035 "void main()\n"
1036 "{\n"
1037 " gl_FragColor = texture2D(us.tex, texcoord + us.a.x);\n"
1038 "}\n");
1039 }
1040
1041 void runSamplerInStructTest()
1042 {
Olli Etuahoa1c917f2016-04-06 13:50:03 +03001043 setUpProgram();
1044
Olli Etuaho96963162016-03-21 11:54:33 +02001045 glActiveTexture(GL_TEXTURE0);
1046 glBindTexture(GL_TEXTURE_2D, mTexture2D);
Olli Etuahoa314b612016-03-10 16:43:00 +02001047 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
1048 &GLColor::green);
Olli Etuaho96963162016-03-21 11:54:33 +02001049 drawQuad(mProgram, "position", 0.5f);
Olli Etuahoa314b612016-03-10 16:43:00 +02001050 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
Olli Etuaho96963162016-03-21 11:54:33 +02001051 }
1052};
1053
1054class SamplerInStructAsFunctionParameterTest : public SamplerInStructTest
1055{
1056 protected:
1057 SamplerInStructAsFunctionParameterTest() : SamplerInStructTest() {}
1058
1059 std::string getFragmentShaderSource() override
1060 {
1061 return std::string(
1062 "precision highp float;\n"
1063 "struct S\n"
1064 "{\n"
1065 " vec4 a;\n"
1066 " highp sampler2D tex;\n"
1067 "};\n"
1068 "uniform S us;\n"
1069 "varying vec2 texcoord;\n"
1070 "vec4 sampleFrom(S s) {\n"
1071 " return texture2D(s.tex, texcoord + s.a.x);\n"
1072 "}\n"
1073 "void main()\n"
1074 "{\n"
1075 " gl_FragColor = sampleFrom(us);\n"
1076 "}\n");
1077 }
1078};
1079
1080class SamplerInStructArrayAsFunctionParameterTest : public SamplerInStructTest
1081{
1082 protected:
1083 SamplerInStructArrayAsFunctionParameterTest() : SamplerInStructTest() {}
1084
1085 const char *getTextureUniformName() override { return "us[0].tex"; }
1086
1087 std::string getFragmentShaderSource() override
1088 {
1089 return std::string(
1090 "precision highp float;\n"
1091 "struct S\n"
1092 "{\n"
1093 " vec4 a;\n"
1094 " highp sampler2D tex;\n"
1095 "};\n"
1096 "uniform S us[1];\n"
1097 "varying vec2 texcoord;\n"
1098 "vec4 sampleFrom(S s) {\n"
1099 " return texture2D(s.tex, texcoord + s.a.x);\n"
1100 "}\n"
1101 "void main()\n"
1102 "{\n"
1103 " gl_FragColor = sampleFrom(us[0]);\n"
1104 "}\n");
1105 }
1106};
1107
1108class SamplerInNestedStructAsFunctionParameterTest : public SamplerInStructTest
1109{
1110 protected:
1111 SamplerInNestedStructAsFunctionParameterTest() : SamplerInStructTest() {}
1112
1113 const char *getTextureUniformName() override { return "us[0].sub.tex"; }
1114
1115 std::string getFragmentShaderSource() override
1116 {
1117 return std::string(
1118 "precision highp float;\n"
1119 "struct SUB\n"
1120 "{\n"
1121 " vec4 a;\n"
1122 " highp sampler2D tex;\n"
1123 "};\n"
1124 "struct S\n"
1125 "{\n"
1126 " SUB sub;\n"
1127 "};\n"
1128 "uniform S us[1];\n"
1129 "varying vec2 texcoord;\n"
1130 "vec4 sampleFrom(SUB s) {\n"
1131 " return texture2D(s.tex, texcoord + s.a.x);\n"
1132 "}\n"
1133 "void main()\n"
1134 "{\n"
1135 " gl_FragColor = sampleFrom(us[0].sub);\n"
1136 "}\n");
1137 }
1138};
1139
1140class SamplerInStructAndOtherVariableTest : public SamplerInStructTest
1141{
1142 protected:
1143 SamplerInStructAndOtherVariableTest() : SamplerInStructTest() {}
1144
1145 std::string getFragmentShaderSource() override
1146 {
1147 return std::string(
1148 "precision highp float;\n"
1149 "struct S\n"
1150 "{\n"
1151 " vec4 a;\n"
1152 " highp sampler2D tex;\n"
1153 "};\n"
1154 "uniform S us;\n"
1155 "uniform float us_tex;\n"
1156 "varying vec2 texcoord;\n"
1157 "void main()\n"
1158 "{\n"
1159 " gl_FragColor = texture2D(us.tex, texcoord + us.a.x + us_tex);\n"
1160 "}\n");
1161 }
1162};
1163
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001164TEST_P(Texture2DTest, NegativeAPISubImage)
Jamie Madillf67115c2014-04-22 13:14:05 -04001165{
Jamie Madilld4cfa572014-07-08 10:00:32 -04001166 glBindTexture(GL_TEXTURE_2D, mTexture2D);
Jamie Madillf67115c2014-04-22 13:14:05 -04001167 EXPECT_GL_ERROR(GL_NO_ERROR);
1168
Olli Etuahoa1c917f2016-04-06 13:50:03 +03001169 setUpProgram();
1170
Jamie Madillf67115c2014-04-22 13:14:05 -04001171 const GLubyte *pixels[20] = { 0 };
1172 glTexSubImage2D(GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
1173 EXPECT_GL_ERROR(GL_INVALID_VALUE);
1174}
Geoff Langc41e42d2014-04-28 10:58:16 -04001175
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001176TEST_P(Texture2DTest, ZeroSizedUploads)
Geoff Langc41e42d2014-04-28 10:58:16 -04001177{
Jamie Madilld4cfa572014-07-08 10:00:32 -04001178 glBindTexture(GL_TEXTURE_2D, mTexture2D);
Geoff Langc41e42d2014-04-28 10:58:16 -04001179 EXPECT_GL_ERROR(GL_NO_ERROR);
1180
Olli Etuahoa1c917f2016-04-06 13:50:03 +03001181 setUpProgram();
1182
Geoff Langc41e42d2014-04-28 10:58:16 -04001183 // Use the texture first to make sure it's in video memory
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001184 glUseProgram(mProgram);
Jamie Madilld4cfa572014-07-08 10:00:32 -04001185 glUniform1i(mTexture2DUniformLocation, 0);
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001186 drawQuad(mProgram, "position", 0.5f);
Geoff Langc41e42d2014-04-28 10:58:16 -04001187
1188 const GLubyte *pixel[4] = { 0 };
1189
1190 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixel);
1191 EXPECT_GL_NO_ERROR();
1192
1193 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel);
1194 EXPECT_GL_NO_ERROR();
1195
1196 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixel);
1197 EXPECT_GL_NO_ERROR();
1198}
Jamie Madilld4cfa572014-07-08 10:00:32 -04001199
1200// Test drawing with two texture types, to trigger an ANGLE bug in validation
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001201TEST_P(TextureCubeTest, CubeMapBug)
Jamie Madilld4cfa572014-07-08 10:00:32 -04001202{
1203 glActiveTexture(GL_TEXTURE0);
1204 glBindTexture(GL_TEXTURE_2D, mTexture2D);
1205 glActiveTexture(GL_TEXTURE1);
1206 glBindTexture(GL_TEXTURE_CUBE_MAP, mTextureCube);
1207 EXPECT_GL_ERROR(GL_NO_ERROR);
1208
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001209 glUseProgram(mProgram);
1210 glUniform1i(mTexture2DUniformLocation, 0);
1211 glUniform1i(mTextureCubeUniformLocation, 1);
1212 drawQuad(mProgram, "position", 0.5f);
Jamie Madilld4cfa572014-07-08 10:00:32 -04001213 EXPECT_GL_NO_ERROR();
1214}
Jamie Madill9aca0592014-10-06 16:26:59 -04001215
Olli Etuaho53a2da12016-01-11 15:43:32 +02001216// Test drawing with two texture types accessed from the same shader and check that the result of
1217// drawing is correct.
1218TEST_P(TextureCubeTest, CubeMapDraw)
1219{
1220 GLubyte texData[4];
1221 texData[0] = 0;
1222 texData[1] = 60;
1223 texData[2] = 0;
1224 texData[3] = 255;
1225
1226 glActiveTexture(GL_TEXTURE0);
1227 glBindTexture(GL_TEXTURE_2D, mTexture2D);
1228 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, texData);
1229
1230 glActiveTexture(GL_TEXTURE1);
1231 glBindTexture(GL_TEXTURE_CUBE_MAP, mTextureCube);
1232 texData[1] = 120;
1233 glTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE,
1234 texData);
1235 EXPECT_GL_ERROR(GL_NO_ERROR);
1236
1237 glUseProgram(mProgram);
1238 glUniform1i(mTexture2DUniformLocation, 0);
1239 glUniform1i(mTextureCubeUniformLocation, 1);
1240 drawQuad(mProgram, "position", 0.5f);
1241 EXPECT_GL_NO_ERROR();
1242
1243 int px = getWindowWidth() - 1;
1244 int py = 0;
1245 EXPECT_PIXEL_NEAR(px, py, 0, 180, 0, 255, 2);
1246}
1247
Olli Etuaho4644a202016-01-12 15:12:53 +02001248TEST_P(Sampler2DAsFunctionParameterTest, Sampler2DAsFunctionParameter)
1249{
1250 glActiveTexture(GL_TEXTURE0);
1251 glBindTexture(GL_TEXTURE_2D, mTexture2D);
1252 GLubyte texData[4];
1253 texData[0] = 0;
1254 texData[1] = 128;
1255 texData[2] = 0;
1256 texData[3] = 255;
1257 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, texData);
1258 glUseProgram(mProgram);
1259 glUniform1i(mTexture2DUniformLocation, 0);
1260 drawQuad(mProgram, "position", 0.5f);
1261 EXPECT_GL_NO_ERROR();
1262
1263 EXPECT_PIXEL_NEAR(0, 0, 0, 128, 0, 255, 2);
1264}
1265
Olli Etuaho2173db3d2016-01-12 13:55:14 +02001266// Test drawing with two textures passed to the shader in a sampler array.
1267TEST_P(SamplerArrayTest, SamplerArrayDraw)
1268{
1269 testSamplerArrayDraw();
1270}
1271
1272// Test drawing with two textures passed to the shader in a sampler array which is passed to a
1273// user-defined function in the shader.
1274TEST_P(SamplerArrayAsFunctionParameterTest, SamplerArrayAsFunctionParameter)
1275{
1276 testSamplerArrayDraw();
1277}
1278
Jamie Madill9aca0592014-10-06 16:26:59 -04001279// Copy of a test in conformance/textures/texture-mips, to test generate mipmaps
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001280TEST_P(Texture2DTestWithDrawScale, MipmapsTwice)
Jamie Madill9aca0592014-10-06 16:26:59 -04001281{
1282 int px = getWindowWidth() / 2;
1283 int py = getWindowHeight() / 2;
1284
1285 glActiveTexture(GL_TEXTURE0);
1286 glBindTexture(GL_TEXTURE_2D, mTexture2D);
1287
Olli Etuahoa314b612016-03-10 16:43:00 +02001288 std::vector<GLColor> pixelsRed(16u * 16u, GLColor::red);
Jamie Madill9aca0592014-10-06 16:26:59 -04001289
Olli Etuahoa314b612016-03-10 16:43:00 +02001290 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixelsRed.data());
Jamie Madill9aca0592014-10-06 16:26:59 -04001291 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
1292 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
1293 glGenerateMipmap(GL_TEXTURE_2D);
1294
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001295 glUseProgram(mProgram);
Jamie Madill9aca0592014-10-06 16:26:59 -04001296 glUniform1i(mTexture2DUniformLocation, 0);
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001297 glUniform2f(mDrawScaleUniformLocation, 0.0625f, 0.0625f);
1298 drawQuad(mProgram, "position", 0.5f);
Jamie Madill9aca0592014-10-06 16:26:59 -04001299 EXPECT_GL_NO_ERROR();
Olli Etuahoa314b612016-03-10 16:43:00 +02001300 EXPECT_PIXEL_COLOR_EQ(px, py, GLColor::red);
Jamie Madill9aca0592014-10-06 16:26:59 -04001301
Olli Etuahoa314b612016-03-10 16:43:00 +02001302 std::vector<GLColor> pixelsBlue(16u * 16u, GLColor::blue);
Jamie Madill9aca0592014-10-06 16:26:59 -04001303
Olli Etuahoa314b612016-03-10 16:43:00 +02001304 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE,
1305 pixelsBlue.data());
Jamie Madill9aca0592014-10-06 16:26:59 -04001306 glGenerateMipmap(GL_TEXTURE_2D);
1307
Olli Etuahoa314b612016-03-10 16:43:00 +02001308 std::vector<GLColor> pixelsGreen(16u * 16u, GLColor::green);
Jamie Madill9aca0592014-10-06 16:26:59 -04001309
Olli Etuahoa314b612016-03-10 16:43:00 +02001310 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE,
1311 pixelsGreen.data());
Jamie Madill9aca0592014-10-06 16:26:59 -04001312 glGenerateMipmap(GL_TEXTURE_2D);
1313
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001314 drawQuad(mProgram, "position", 0.5f);
Jamie Madill9aca0592014-10-06 16:26:59 -04001315
1316 EXPECT_GL_NO_ERROR();
Olli Etuahoa314b612016-03-10 16:43:00 +02001317 EXPECT_PIXEL_COLOR_EQ(px, py, GLColor::green);
Jamie Madill9aca0592014-10-06 16:26:59 -04001318}
Jamie Madillf8fccb32014-11-12 15:05:26 -05001319
Jamie Madilleb32a2e2014-12-10 14:27:53 -05001320// Test creating a FBO with a cube map render target, to test an ANGLE bug
1321// https://code.google.com/p/angleproject/issues/detail?id=849
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001322TEST_P(TextureCubeTest, CubeMapFBO)
Jamie Madilleb32a2e2014-12-10 14:27:53 -05001323{
1324 GLuint fbo;
1325 glGenFramebuffers(1, &fbo);
1326 glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1327
1328 glBindTexture(GL_TEXTURE_CUBE_MAP, mTextureCube);
1329 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_Y, mTextureCube, 0);
1330
Corentin Wallez322653b2015-06-17 18:33:56 +02001331 EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
Jamie Madilleb32a2e2014-12-10 14:27:53 -05001332
1333 glDeleteFramebuffers(1, &fbo);
1334
1335 EXPECT_GL_NO_ERROR();
1336}
Gregoire Payen de La Garanderie88fe1ad2015-01-19 15:09:26 +00001337
1338// Test that glTexSubImage2D works properly when glTexStorage2DEXT has initialized the image with a default color.
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001339TEST_P(Texture2DTest, TexStorage)
Gregoire Payen de La Garanderie88fe1ad2015-01-19 15:09:26 +00001340{
1341 int width = getWindowWidth();
1342 int height = getWindowHeight();
1343
1344 GLuint tex2D;
1345 glGenTextures(1, &tex2D);
1346 glActiveTexture(GL_TEXTURE0);
1347 glBindTexture(GL_TEXTURE_2D, tex2D);
1348
1349 // Fill with red
1350 std::vector<GLubyte> pixels(3 * 16 * 16);
1351 for (size_t pixelId = 0; pixelId < 16 * 16; ++pixelId)
1352 {
1353 pixels[pixelId * 3 + 0] = 255;
1354 pixels[pixelId * 3 + 1] = 0;
1355 pixels[pixelId * 3 + 2] = 0;
1356 }
1357
1358 // ANGLE internally uses RGBA as the DirectX format for RGB images
1359 // therefore glTexStorage2DEXT initializes the image to a default color to get a consistent alpha color.
1360 // The data is kept in a CPU-side image and the image is marked as dirty.
1361 glTexStorage2DEXT(GL_TEXTURE_2D, 1, GL_RGB8, 16, 16);
1362
1363 // Initializes the color of the upper-left 8x8 pixels, leaves the other pixels untouched.
1364 // glTexSubImage2D should take into account that the image is dirty.
1365 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 8, 8, GL_RGB, GL_UNSIGNED_BYTE, pixels.data());
1366 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
1367 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
1368
Olli Etuahoa1c917f2016-04-06 13:50:03 +03001369 setUpProgram();
1370
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001371 glUseProgram(mProgram);
Gregoire Payen de La Garanderie88fe1ad2015-01-19 15:09:26 +00001372 glUniform1i(mTexture2DUniformLocation, 0);
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001373 drawQuad(mProgram, "position", 0.5f);
Gregoire Payen de La Garanderie88fe1ad2015-01-19 15:09:26 +00001374 glDeleteTextures(1, &tex2D);
1375 EXPECT_GL_NO_ERROR();
Gregoire Payen de La Garanderie88fe1ad2015-01-19 15:09:26 +00001376 EXPECT_PIXEL_EQ(width / 4, height / 4, 255, 0, 0, 255);
Geoff Langfbfa47c2015-03-31 11:26:00 -04001377
1378 // Validate that the region of the texture without data has an alpha of 1.0
1379 GLubyte pixel[4];
1380 glReadPixels(3 * width / 4, 3 * height / 4, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel);
1381 EXPECT_EQ(pixel[3], 255);
Gregoire Payen de La Garanderie88fe1ad2015-01-19 15:09:26 +00001382}
1383
1384// 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 +02001385TEST_P(Texture2DTest, TexStorageWithPBO)
Gregoire Payen de La Garanderie88fe1ad2015-01-19 15:09:26 +00001386{
1387 if (extensionEnabled("NV_pixel_buffer_object"))
1388 {
1389 int width = getWindowWidth();
1390 int height = getWindowHeight();
1391
1392 GLuint tex2D;
1393 glGenTextures(1, &tex2D);
1394 glActiveTexture(GL_TEXTURE0);
1395 glBindTexture(GL_TEXTURE_2D, tex2D);
1396
1397 // Fill with red
1398 std::vector<GLubyte> pixels(3 * 16 * 16);
1399 for (size_t pixelId = 0; pixelId < 16 * 16; ++pixelId)
1400 {
1401 pixels[pixelId * 3 + 0] = 255;
1402 pixels[pixelId * 3 + 1] = 0;
1403 pixels[pixelId * 3 + 2] = 0;
1404 }
1405
1406 // Read 16x16 region from red backbuffer to PBO
1407 GLuint pbo;
1408 glGenBuffers(1, &pbo);
1409 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo);
1410 glBufferData(GL_PIXEL_UNPACK_BUFFER, 3 * 16 * 16, pixels.data(), GL_STATIC_DRAW);
1411
1412 // ANGLE internally uses RGBA as the DirectX format for RGB images
1413 // therefore glTexStorage2DEXT initializes the image to a default color to get a consistent alpha color.
1414 // The data is kept in a CPU-side image and the image is marked as dirty.
1415 glTexStorage2DEXT(GL_TEXTURE_2D, 1, GL_RGB8, 16, 16);
1416
1417 // Initializes the color of the upper-left 8x8 pixels, leaves the other pixels untouched.
1418 // glTexSubImage2D should take into account that the image is dirty.
1419 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 8, 8, GL_RGB, GL_UNSIGNED_BYTE, NULL);
1420 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
1421 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
1422
Olli Etuahoa1c917f2016-04-06 13:50:03 +03001423 setUpProgram();
1424
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001425 glUseProgram(mProgram);
Gregoire Payen de La Garanderie88fe1ad2015-01-19 15:09:26 +00001426 glUniform1i(mTexture2DUniformLocation, 0);
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001427 drawQuad(mProgram, "position", 0.5f);
Gregoire Payen de La Garanderie88fe1ad2015-01-19 15:09:26 +00001428 glDeleteTextures(1, &tex2D);
Olli Etuaho19d48db2016-01-13 14:43:21 +02001429 glDeleteBuffers(1, &pbo);
Gregoire Payen de La Garanderie88fe1ad2015-01-19 15:09:26 +00001430 EXPECT_GL_NO_ERROR();
1431 EXPECT_PIXEL_EQ(3 * width / 4, 3 * height / 4, 0, 0, 0, 255);
1432 EXPECT_PIXEL_EQ(width / 4, height / 4, 255, 0, 0, 255);
1433 }
1434}
Jamie Madillbc393df2015-01-29 13:46:07 -05001435
1436// See description on testFloatCopySubImage
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001437TEST_P(Texture2DTest, CopySubImageFloat_R_R)
Jamie Madillbc393df2015-01-29 13:46:07 -05001438{
1439 testFloatCopySubImage(1, 1);
1440}
1441
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001442TEST_P(Texture2DTest, CopySubImageFloat_RG_R)
Jamie Madillbc393df2015-01-29 13:46:07 -05001443{
1444 testFloatCopySubImage(2, 1);
1445}
1446
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001447TEST_P(Texture2DTest, CopySubImageFloat_RG_RG)
Jamie Madillbc393df2015-01-29 13:46:07 -05001448{
1449 testFloatCopySubImage(2, 2);
1450}
1451
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001452TEST_P(Texture2DTest, CopySubImageFloat_RGB_R)
Jamie Madillbc393df2015-01-29 13:46:07 -05001453{
Corentin Wallez9e3c6152016-03-29 21:58:33 -04001454 if (IsIntel() && IsLinux())
1455 {
1456 // TODO(cwallez): Fix on Linux Intel drivers (http://anglebug.com/1346)
1457 std::cout << "Test disabled on Linux Intel OpenGL." << std::endl;
1458 return;
1459 }
1460
Jamie Madillbc393df2015-01-29 13:46:07 -05001461 testFloatCopySubImage(3, 1);
1462}
1463
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001464TEST_P(Texture2DTest, CopySubImageFloat_RGB_RG)
Jamie Madillbc393df2015-01-29 13:46:07 -05001465{
Corentin Wallez9e3c6152016-03-29 21:58:33 -04001466 if (IsIntel() && IsLinux())
1467 {
1468 // TODO(cwallez): Fix on Linux Intel drivers (http://anglebug.com/1346)
1469 std::cout << "Test disabled on Linux Intel OpenGL." << std::endl;
1470 return;
1471 }
1472
Jamie Madillbc393df2015-01-29 13:46:07 -05001473 testFloatCopySubImage(3, 2);
1474}
1475
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001476TEST_P(Texture2DTest, CopySubImageFloat_RGB_RGB)
Jamie Madillbc393df2015-01-29 13:46:07 -05001477{
Corentin Wallez9e3c6152016-03-29 21:58:33 -04001478 if (IsIntel() && IsLinux())
1479 {
1480 // TODO(cwallez): Fix on Linux Intel drivers (http://anglebug.com/1346)
1481 std::cout << "Test disabled on Linux Intel OpenGL." << std::endl;
1482 return;
1483 }
1484
Austin Kinrossd544cc92016-01-11 15:26:42 -08001485 // TODO (bug 1284): Investigate RGBA32f D3D SDK Layers messages on D3D11_FL9_3
Jamie Madill518b9fa2016-03-02 11:26:02 -05001486 if (IsD3D11_FL93())
Austin Kinrossd544cc92016-01-11 15:26:42 -08001487 {
1488 std::cout << "Test skipped on Feature Level 9_3." << std::endl;
1489 return;
1490 }
1491
Jamie Madillbc393df2015-01-29 13:46:07 -05001492 testFloatCopySubImage(3, 3);
1493}
1494
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001495TEST_P(Texture2DTest, CopySubImageFloat_RGBA_R)
Jamie Madillbc393df2015-01-29 13:46:07 -05001496{
1497 testFloatCopySubImage(4, 1);
1498}
1499
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001500TEST_P(Texture2DTest, CopySubImageFloat_RGBA_RG)
Jamie Madillbc393df2015-01-29 13:46:07 -05001501{
1502 testFloatCopySubImage(4, 2);
1503}
1504
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001505TEST_P(Texture2DTest, CopySubImageFloat_RGBA_RGB)
Jamie Madillbc393df2015-01-29 13:46:07 -05001506{
Austin Kinrossd544cc92016-01-11 15:26:42 -08001507 // TODO (bug 1284): Investigate RGBA32f D3D SDK Layers messages on D3D11_FL9_3
Jamie Madill518b9fa2016-03-02 11:26:02 -05001508 if (IsD3D11_FL93())
Austin Kinrossd544cc92016-01-11 15:26:42 -08001509 {
1510 std::cout << "Test skipped on Feature Level 9_3." << std::endl;
1511 return;
1512 }
1513
Jamie Madillbc393df2015-01-29 13:46:07 -05001514 testFloatCopySubImage(4, 3);
1515}
1516
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001517TEST_P(Texture2DTest, CopySubImageFloat_RGBA_RGBA)
Jamie Madillbc393df2015-01-29 13:46:07 -05001518{
Austin Kinrossd544cc92016-01-11 15:26:42 -08001519 // TODO (bug 1284): Investigate RGBA32f D3D SDK Layers messages on D3D11_FL9_3
Jamie Madill518b9fa2016-03-02 11:26:02 -05001520 if (IsD3D11_FL93())
Austin Kinrossd544cc92016-01-11 15:26:42 -08001521 {
1522 std::cout << "Test skipped on Feature Level 9_3." << std::endl;
1523 return;
1524 }
1525
Jamie Madillbc393df2015-01-29 13:46:07 -05001526 testFloatCopySubImage(4, 4);
1527}
Austin Kinross07285142015-03-26 11:36:16 -07001528
1529// Port of https://www.khronos.org/registry/webgl/conformance-suites/1.0.3/conformance/textures/texture-npot.html
1530// 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 +02001531TEST_P(Texture2DTest, TextureNPOT_GL_ALPHA_UBYTE)
Austin Kinross07285142015-03-26 11:36:16 -07001532{
1533 const int npotTexSize = 5;
1534 const int potTexSize = 4; // Should be less than npotTexSize
1535 GLuint tex2D;
1536
1537 if (extensionEnabled("GL_OES_texture_npot"))
1538 {
1539 // This test isn't applicable if texture_npot is enabled
1540 return;
1541 }
1542
Olli Etuahoa1c917f2016-04-06 13:50:03 +03001543 setUpProgram();
1544
Austin Kinross07285142015-03-26 11:36:16 -07001545 glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
1546
Austin Kinross5faa15b2016-01-11 13:32:48 -08001547 // Default unpack alignment is 4. The values of 'pixels' below needs it to be 1.
1548 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
1549
Austin Kinross07285142015-03-26 11:36:16 -07001550 glActiveTexture(GL_TEXTURE0);
1551 glGenTextures(1, &tex2D);
1552 glBindTexture(GL_TEXTURE_2D, tex2D);
1553
1554 std::vector<GLubyte> pixels(1 * npotTexSize * npotTexSize);
1555 for (size_t pixelId = 0; pixelId < npotTexSize * npotTexSize; ++pixelId)
1556 {
1557 pixels[pixelId] = 64;
1558 }
1559
1560 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
1561 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
1562
1563 // Check that an NPOT texture not on level 0 generates INVALID_VALUE
1564 glTexImage2D(GL_TEXTURE_2D, 1, GL_ALPHA, npotTexSize, npotTexSize, 0, GL_ALPHA, GL_UNSIGNED_BYTE, pixels.data());
1565 EXPECT_GL_ERROR(GL_INVALID_VALUE);
1566
1567 // Check that an NPOT texture on level 0 succeeds
1568 glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, npotTexSize, npotTexSize, 0, GL_ALPHA, GL_UNSIGNED_BYTE, pixels.data());
1569 EXPECT_GL_NO_ERROR();
1570
1571 // Check that generateMipmap fails on NPOT
1572 glGenerateMipmap(GL_TEXTURE_2D);
1573 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
1574
1575 // Check that nothing is drawn if filtering is not correct for NPOT
1576 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1577 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1578 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
1579 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
1580 glClear(GL_COLOR_BUFFER_BIT);
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001581 drawQuad(mProgram, "position", 1.0f);
Austin Kinross07285142015-03-26 11:36:16 -07001582 EXPECT_PIXEL_EQ(getWindowWidth() / 2, getWindowHeight() / 2, 0, 0, 0, 255);
1583
1584 // NPOT texture with TEXTURE_MIN_FILTER not NEAREST or LINEAR should draw with 0,0,0,255
1585 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
1586 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
1587 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR);
1588 glClear(GL_COLOR_BUFFER_BIT);
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001589 drawQuad(mProgram, "position", 1.0f);
Austin Kinross07285142015-03-26 11:36:16 -07001590 EXPECT_PIXEL_EQ(getWindowWidth() / 2, getWindowHeight() / 2, 0, 0, 0, 255);
1591
1592 // NPOT texture with TEXTURE_MIN_FILTER set to LINEAR should draw
1593 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
1594 glClear(GL_COLOR_BUFFER_BIT);
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001595 drawQuad(mProgram, "position", 1.0f);
Austin Kinross07285142015-03-26 11:36:16 -07001596 EXPECT_PIXEL_EQ(getWindowWidth() / 2, getWindowHeight() / 2, 0, 0, 0, 64);
1597
1598 // Check that glTexImage2D for POT texture succeeds
1599 glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, potTexSize, potTexSize, 0, GL_ALPHA, GL_UNSIGNED_BYTE, pixels.data());
1600 EXPECT_GL_NO_ERROR();
1601
1602 // Check that generateMipmap for an POT texture succeeds
1603 glGenerateMipmap(GL_TEXTURE_2D);
1604 EXPECT_GL_NO_ERROR();
1605
1606 // POT texture with TEXTURE_MIN_FILTER set to LINEAR_MIPMAP_LINEAR should draw
1607 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
1608 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
1609 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
1610 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
1611 glClear(GL_COLOR_BUFFER_BIT);
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001612 drawQuad(mProgram, "position", 1.0f);
Austin Kinross07285142015-03-26 11:36:16 -07001613 EXPECT_PIXEL_EQ(getWindowWidth() / 2, getWindowHeight() / 2, 0, 0, 0, 64);
1614 EXPECT_GL_NO_ERROR();
1615}
Jamie Madillfa05f602015-05-07 13:47:11 -04001616
Austin Kinross08528e12015-10-07 16:24:40 -07001617// Test to ensure that glTexSubImage2D always accepts data for non-power-of-two subregions.
1618// ANGLE previously rejected this if GL_OES_texture_npot wasn't active, which is incorrect.
Olli Etuaho4a8329f2016-01-11 17:12:57 +02001619TEST_P(Texture2DTest, NPOTSubImageParameters)
Austin Kinross08528e12015-10-07 16:24:40 -07001620{
Geoff Lange0cc2a42016-01-20 10:58:17 -05001621 // TODO(geofflang): Allow the GL backend to accept SubImage calls with a null data ptr. (bug
1622 // 1278)
1623 if (getPlatformRenderer() == EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE ||
1624 getPlatformRenderer() == EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE)
1625 {
1626 std::cout << "Test disabled on OpenGL." << std::endl;
1627 return;
1628 }
1629
Austin Kinross08528e12015-10-07 16:24:40 -07001630 glActiveTexture(GL_TEXTURE0);
1631 glBindTexture(GL_TEXTURE_2D, mTexture2D);
1632
1633 // Create an 8x8 (i.e. power-of-two) texture.
1634 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
1635 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
1636 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
1637 glGenerateMipmap(GL_TEXTURE_2D);
1638
1639 // Supply a 3x3 (i.e. non-power-of-two) subimage to the texture.
1640 // This should always work, even if GL_OES_texture_npot isn't active.
1641 glTexSubImage2D(GL_TEXTURE_2D, 1, 0, 0, 3, 3, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
1642
1643 EXPECT_GL_NO_ERROR();
1644}
1645
Olli Etuahoa7416ff2016-01-18 12:22:55 +02001646// Test to check that texture completeness is determined correctly when the texture base level is
1647// greater than 0, and also that level 0 is not sampled when base level is greater than 0.
1648TEST_P(Texture2DTestES3, DrawWithBaseLevel1)
1649{
1650 glActiveTexture(GL_TEXTURE0);
1651 glBindTexture(GL_TEXTURE_2D, mTexture2D);
Olli Etuahoa314b612016-03-10 16:43:00 +02001652
1653 std::vector<GLColor> texDataRed(4u * 4u, GLColor::red);
1654 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, texDataRed.data());
1655 std::vector<GLColor> texDataGreen(2u * 2u, GLColor::green);
1656 glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE,
1657 texDataGreen.data());
1658 glTexImage2D(GL_TEXTURE_2D, 2, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
1659 texDataGreen.data());
Olli Etuahoa7416ff2016-01-18 12:22:55 +02001660 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
1661 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
1662 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 1);
1663
1664 EXPECT_GL_NO_ERROR();
1665
1666 drawQuad(mProgram, "position", 0.5f);
1667
Olli Etuahoa314b612016-03-10 16:43:00 +02001668 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
1669}
1670
1671// Test that drawing works correctly when levels outside the BASE_LEVEL/MAX_LEVEL range do not
1672// have images defined.
1673TEST_P(Texture2DTestES3, DrawWithLevelsOutsideRangeUndefined)
1674{
1675 if (IsAMD() && getPlatformRenderer() == EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE)
1676 {
1677 // Observed crashing on AMD. Oddly the crash only happens with 2D textures, not 3D or array.
1678 std::cout << "Test skipped on AMD OpenGL." << std::endl;
1679 return;
1680 }
1681 if (IsOSX())
1682 {
1683 // Observed incorrect rendering on OSX.
1684 std::cout << "Test skipped on OSX." << std::endl;
1685 return;
1686 }
1687 glActiveTexture(GL_TEXTURE0);
1688 glBindTexture(GL_TEXTURE_2D, mTexture2D);
1689 std::vector<GLColor> texDataGreen(2u * 2u, GLColor::green);
1690 glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE,
1691 texDataGreen.data());
1692 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
1693 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
1694 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 1);
1695 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1);
1696
1697 EXPECT_GL_NO_ERROR();
1698
1699 drawQuad(mProgram, "position", 0.5f);
1700
1701 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
1702}
1703
Olli Etuahoe8528d82016-05-16 17:50:52 +03001704// Test that drawing works correctly when level 0 is undefined and base level is 1.
1705TEST_P(Texture2DTestES3, DrawWithLevelZeroUndefined)
1706{
1707 if (IsAMD() && getPlatformRenderer() == EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE)
1708 {
1709 // Observed crashing on AMD. Oddly the crash only happens with 2D textures, not 3D or array.
1710 std::cout << "Test skipped on AMD OpenGL." << std::endl;
1711 return;
1712 }
1713 if (IsOSX())
1714 {
1715 // Observed incorrect rendering on OSX.
1716 std::cout << "Test skipped on OSX." << std::endl;
1717 return;
1718 }
1719 glActiveTexture(GL_TEXTURE0);
1720 glBindTexture(GL_TEXTURE_2D, mTexture2D);
1721 std::vector<GLColor> texDataGreen(2u * 2u, GLColor::green);
1722 glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE,
1723 texDataGreen.data());
1724 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
1725 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
1726 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 1);
1727 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 2);
1728
1729 EXPECT_GL_NO_ERROR();
1730
1731 // Texture is incomplete.
1732 drawQuad(mProgram, "position", 0.5f);
1733 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::black);
1734
1735 glTexImage2D(GL_TEXTURE_2D, 2, GL_RGBA8, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
1736 texDataGreen.data());
1737
1738 // Texture is now complete.
1739 drawQuad(mProgram, "position", 0.5f);
1740 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
1741}
1742
Olli Etuahoa314b612016-03-10 16:43:00 +02001743// Test that drawing works correctly when levels outside the BASE_LEVEL/MAX_LEVEL range have
1744// dimensions that don't fit the images inside the range.
1745// GLES 3.0.4 section 3.8.13 Texture completeness
1746TEST_P(Texture2DTestES3, DrawWithLevelsOutsideRangeWithInconsistentDimensions)
1747{
1748 if (IsOSX())
1749 {
1750 // Observed incorrect rendering on OSX.
1751 std::cout << "Test skipped on OSX." << std::endl;
1752 return;
1753 }
1754 glActiveTexture(GL_TEXTURE0);
1755 glBindTexture(GL_TEXTURE_2D, mTexture2D);
1756 std::vector<GLColor> texDataRed(8u * 8u, GLColor::red);
1757 std::vector<GLColor> texDataGreen(2u * 2u, GLColor::green);
1758 std::vector<GLColor> texDataCyan(2u * 2u, GLColor::cyan);
1759
1760 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
1761 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
1762
1763 // Two levels that are initially unused.
1764 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, texDataRed.data());
1765 glTexImage2D(GL_TEXTURE_2D, 2, GL_RGBA8, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE,
1766 texDataCyan.data());
1767
1768 // One level that is used - only this level should affect completeness.
1769 glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE,
1770 texDataGreen.data());
1771
1772 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 1);
1773 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1);
1774
1775 EXPECT_GL_NO_ERROR();
1776
1777 drawQuad(mProgram, "position", 0.5f);
1778
1779 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
1780
1781 if (IsIntel() && getPlatformRenderer() == EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE)
1782 {
1783 // Intel was observed drawing color 0,0,0,0 instead of the texture color after the base
1784 // level was changed.
1785 std::cout << "Test partially skipped on Intel OpenGL." << std::endl;
1786 return;
1787 }
1788
1789 // Switch the level that is being used to the cyan level 2.
1790 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 2);
1791 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 2);
1792
1793 EXPECT_GL_NO_ERROR();
1794
1795 drawQuad(mProgram, "position", 0.5f);
1796
1797 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::cyan);
1798}
1799
1800// Test that drawing works correctly when levels outside the BASE_LEVEL/MAX_LEVEL range do not
1801// have images defined.
1802TEST_P(Texture3DTestES3, DrawWithLevelsOutsideRangeUndefined)
1803{
1804 if (IsOSX())
1805 {
1806 // Observed incorrect rendering on OSX.
1807 std::cout << "Test skipped on OSX." << std::endl;
1808 return;
1809 }
1810 glActiveTexture(GL_TEXTURE0);
1811 glBindTexture(GL_TEXTURE_3D, mTexture3D);
1812 std::vector<GLColor> texDataGreen(2u * 2u * 2u, GLColor::green);
1813 glTexImage3D(GL_TEXTURE_3D, 1, GL_RGBA8, 2, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE,
1814 texDataGreen.data());
1815 glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
1816 glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
1817 glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_BASE_LEVEL, 1);
1818 glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAX_LEVEL, 1);
1819
1820 EXPECT_GL_NO_ERROR();
1821
1822 drawQuad(mProgram, "position", 0.5f);
1823
1824 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
1825}
1826
1827// Test that drawing works correctly when levels outside the BASE_LEVEL/MAX_LEVEL range have
1828// dimensions that don't fit the images inside the range.
1829// GLES 3.0.4 section 3.8.13 Texture completeness
1830TEST_P(Texture3DTestES3, DrawWithLevelsOutsideRangeWithInconsistentDimensions)
1831{
1832 if (IsOSX())
1833 {
1834 // Observed incorrect rendering on OSX.
1835 std::cout << "Test skipped on OSX." << std::endl;
1836 return;
1837 }
1838 glActiveTexture(GL_TEXTURE0);
1839 glBindTexture(GL_TEXTURE_3D, mTexture3D);
1840 std::vector<GLColor> texDataRed(8u * 8u * 8u, GLColor::red);
1841 std::vector<GLColor> texDataGreen(2u * 2u * 2u, GLColor::green);
1842 std::vector<GLColor> texDataCyan(2u * 2u * 2u, GLColor::cyan);
1843
1844 glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
1845 glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
1846
1847 // Two levels that are initially unused.
1848 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA8, 8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE,
1849 texDataRed.data());
1850 glTexImage3D(GL_TEXTURE_3D, 2, GL_RGBA8, 2, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE,
1851 texDataCyan.data());
1852
1853 // One level that is used - only this level should affect completeness.
1854 glTexImage3D(GL_TEXTURE_3D, 1, GL_RGBA8, 2, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE,
1855 texDataGreen.data());
1856
1857 glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_BASE_LEVEL, 1);
1858 glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAX_LEVEL, 1);
1859
1860 EXPECT_GL_NO_ERROR();
1861
1862 drawQuad(mProgram, "position", 0.5f);
1863
1864 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
1865
1866 if (IsIntel() && getPlatformRenderer() == EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE)
1867 {
1868 // Intel was observed drawing color 0,0,0,0 instead of the texture color after the base
1869 // level was changed.
1870 std::cout << "Test partially skipped on Intel OpenGL." << std::endl;
1871 return;
1872 }
1873
1874 // Switch the level that is being used to the cyan level 2.
1875 glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_BASE_LEVEL, 2);
1876 glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAX_LEVEL, 2);
1877
1878 EXPECT_GL_NO_ERROR();
1879
1880 drawQuad(mProgram, "position", 0.5f);
1881
1882 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::cyan);
1883}
1884
1885// Test that drawing works correctly when levels outside the BASE_LEVEL/MAX_LEVEL range do not
1886// have images defined.
1887TEST_P(Texture2DArrayTestES3, DrawWithLevelsOutsideRangeUndefined)
1888{
1889 if (IsOSX())
1890 {
1891 // Observed incorrect rendering on OSX.
1892 std::cout << "Test skipped on OSX." << std::endl;
1893 return;
1894 }
1895 glActiveTexture(GL_TEXTURE0);
1896 glBindTexture(GL_TEXTURE_2D_ARRAY, m2DArrayTexture);
1897 std::vector<GLColor> texDataGreen(2u * 2u * 2u, GLColor::green);
1898 glTexImage3D(GL_TEXTURE_2D_ARRAY, 1, GL_RGBA8, 2, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE,
1899 texDataGreen.data());
1900 glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
1901 glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
1902 glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_BASE_LEVEL, 1);
1903 glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAX_LEVEL, 1);
1904
1905 EXPECT_GL_NO_ERROR();
1906
1907 drawQuad(mProgram, "position", 0.5f);
1908
1909 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
1910}
1911
1912// Test that drawing works correctly when levels outside the BASE_LEVEL/MAX_LEVEL range have
1913// dimensions that don't fit the images inside the range.
1914// GLES 3.0.4 section 3.8.13 Texture completeness
1915TEST_P(Texture2DArrayTestES3, DrawWithLevelsOutsideRangeWithInconsistentDimensions)
1916{
1917 if (IsOSX())
1918 {
1919 // Observed incorrect rendering on OSX.
1920 std::cout << "Test skipped on OSX." << std::endl;
1921 return;
1922 }
1923 glActiveTexture(GL_TEXTURE0);
1924 glBindTexture(GL_TEXTURE_3D, m2DArrayTexture);
1925 std::vector<GLColor> texDataRed(8u * 8u * 8u, GLColor::red);
1926 std::vector<GLColor> texDataGreen(2u * 2u * 2u, GLColor::green);
1927 std::vector<GLColor> texDataCyan(2u * 2u * 2u, GLColor::cyan);
1928
1929 glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
1930 glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
1931
1932 // Two levels that are initially unused.
1933 glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA8, 8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE,
1934 texDataRed.data());
1935 glTexImage3D(GL_TEXTURE_2D_ARRAY, 2, GL_RGBA8, 2, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE,
1936 texDataCyan.data());
1937
1938 // One level that is used - only this level should affect completeness.
1939 glTexImage3D(GL_TEXTURE_2D_ARRAY, 1, GL_RGBA8, 2, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE,
1940 texDataGreen.data());
1941
1942 glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_BASE_LEVEL, 1);
1943 glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAX_LEVEL, 1);
1944
1945 EXPECT_GL_NO_ERROR();
1946
1947 drawQuad(mProgram, "position", 0.5f);
1948
1949 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
1950
1951 if (IsIntel() && getPlatformRenderer() == EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE)
1952 {
1953 // Intel was observed drawing color 0,0,0,0 instead of the texture color after the base
1954 // level was changed.
1955 std::cout << "Test partially skipped on Intel OpenGL." << std::endl;
1956 return;
1957 }
1958 if (IsNVIDIA() && (getPlatformRenderer() == EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE ||
1959 getPlatformRenderer() == EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE))
1960 {
1961 // NVIDIA was observed drawing color 0,0,0,0 instead of the texture color after the base
1962 // level was changed.
1963 std::cout << "Test partially skipped on NVIDIA OpenGL." << std::endl;
1964 return;
1965 }
1966
1967 // Switch the level that is being used to the cyan level 2.
1968 glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_BASE_LEVEL, 2);
1969 glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAX_LEVEL, 2);
1970
1971 EXPECT_GL_NO_ERROR();
1972
1973 drawQuad(mProgram, "position", 0.5f);
1974
1975 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::cyan);
1976}
1977
1978// Test that texture completeness is updated if texture max level changes.
1979// GLES 3.0.4 section 3.8.13 Texture completeness
1980TEST_P(Texture2DTestES3, TextureCompletenessChangesWithMaxLevel)
1981{
1982 if (IsIntel() && getPlatformRenderer() == EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE)
1983 {
1984 // Intel was observed having wrong behavior after the texture is made incomplete by changing
1985 // the base level.
1986 std::cout << "Test skipped on Intel OpenGL." << std::endl;
1987 return;
1988 }
1989 if (IsOSX())
1990 {
1991 // Observed incorrect rendering on OSX.
1992 std::cout << "Test skipped on OSX." << std::endl;
1993 return;
1994 }
1995
1996 glActiveTexture(GL_TEXTURE0);
1997 glBindTexture(GL_TEXTURE_2D, mTexture2D);
1998 std::vector<GLColor> texDataGreen(8u * 8u, GLColor::green);
1999
2000 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
2001 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
2002
2003 // A level that is initially unused.
2004 glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE,
2005 texDataGreen.data());
2006
2007 // One level that is initially used - only this level should affect completeness.
2008 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE,
2009 texDataGreen.data());
2010
2011 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
2012 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
2013
2014 EXPECT_GL_NO_ERROR();
2015
2016 drawQuad(mProgram, "position", 0.5f);
2017
2018 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
2019
2020 // Switch the max level to level 1. The levels within the used range now have inconsistent
2021 // dimensions and the texture should be incomplete.
2022 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1);
2023
2024 EXPECT_GL_NO_ERROR();
2025
2026 drawQuad(mProgram, "position", 0.5f);
2027
2028 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::black);
2029}
2030
2031// Test that 3D texture completeness is updated if texture max level changes.
2032// GLES 3.0.4 section 3.8.13 Texture completeness
2033TEST_P(Texture3DTestES3, Texture3DCompletenessChangesWithMaxLevel)
2034{
2035 if (IsIntel() && getPlatformRenderer() == EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE)
2036 {
2037 // Intel was observed having wrong behavior after the texture is made incomplete by changing
2038 // the base level.
2039 std::cout << "Test skipped on Intel OpenGL." << std::endl;
2040 return;
2041 }
2042 if (IsOSX())
2043 {
2044 // Observed incorrect rendering on OSX.
2045 std::cout << "Test skipped on OSX." << std::endl;
2046 return;
2047 }
2048
2049 glActiveTexture(GL_TEXTURE0);
2050 glBindTexture(GL_TEXTURE_3D, mTexture3D);
2051 std::vector<GLColor> texDataGreen(2u * 2u * 2u, GLColor::green);
2052
2053 glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
2054 glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
2055
2056 // A level that is initially unused.
2057 glTexImage3D(GL_TEXTURE_3D, 1, GL_RGBA8, 1, 1, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE,
2058 texDataGreen.data());
2059
2060 // One level that is initially used - only this level should affect completeness.
2061 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA8, 2, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE,
2062 texDataGreen.data());
2063
2064 glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_BASE_LEVEL, 0);
2065 glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAX_LEVEL, 0);
2066
2067 EXPECT_GL_NO_ERROR();
2068
2069 drawQuad(mProgram, "position", 0.5f);
2070
2071 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
2072
2073 // Switch the max level to level 1. The levels within the used range now have inconsistent
2074 // dimensions and the texture should be incomplete.
2075 glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAX_LEVEL, 1);
2076
2077 EXPECT_GL_NO_ERROR();
2078
2079 drawQuad(mProgram, "position", 0.5f);
2080
2081 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::black);
2082}
2083
2084// Test that texture completeness is updated if texture base level changes.
2085// GLES 3.0.4 section 3.8.13 Texture completeness
2086TEST_P(Texture2DTestES3, TextureCompletenessChangesWithBaseLevel)
2087{
2088 if (IsIntel() && getPlatformRenderer() == EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE)
2089 {
2090 // Intel was observed having wrong behavior after the texture is made incomplete by changing
2091 // the base level.
2092 std::cout << "Test skipped on Intel OpenGL." << std::endl;
2093 return;
2094 }
2095
2096 glActiveTexture(GL_TEXTURE0);
2097 glBindTexture(GL_TEXTURE_2D, mTexture2D);
2098 std::vector<GLColor> texDataGreen(8u * 8u, GLColor::green);
2099
2100 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
2101 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
2102
2103 // Two levels that are initially unused.
2104 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE,
2105 texDataGreen.data());
2106 glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE,
2107 texDataGreen.data());
2108
2109 // One level that is initially used - only this level should affect completeness.
2110 glTexImage2D(GL_TEXTURE_2D, 2, GL_RGBA8, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE,
2111 texDataGreen.data());
2112
2113 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 2);
2114 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 2);
2115
2116 EXPECT_GL_NO_ERROR();
2117
2118 drawQuad(mProgram, "position", 0.5f);
2119
2120 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
2121
2122 // Switch the base level to level 1. The levels within the used range now have inconsistent
2123 // dimensions and the texture should be incomplete.
2124 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 1);
2125
2126 EXPECT_GL_NO_ERROR();
2127
2128 drawQuad(mProgram, "position", 0.5f);
2129
2130 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::black);
2131}
2132
2133// Test that texture is not complete if base level is greater than max level.
2134// GLES 3.0.4 section 3.8.13 Texture completeness
2135TEST_P(Texture2DTestES3, TextureBaseLevelGreaterThanMaxLevel)
2136{
2137 if (IsIntel() && getPlatformRenderer() == EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE)
2138 {
2139 // Intel Windows OpenGL driver crashes if the base level of a non-immutable texture is out
2140 // of range.
2141 std::cout << "Test skipped on Intel OpenGL." << std::endl;
2142 return;
2143 }
2144
2145 glActiveTexture(GL_TEXTURE0);
2146 glBindTexture(GL_TEXTURE_2D, mTexture2D);
2147
2148 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
2149 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
2150
2151 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &GLColor::green);
2152
2153 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 10000);
2154 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
2155
2156 EXPECT_GL_NO_ERROR();
2157
2158 drawQuad(mProgram, "position", 0.5f);
2159
2160 // Texture should be incomplete.
2161 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::black);
2162}
2163
2164// Test that immutable texture base level and max level are clamped.
2165// GLES 3.0.4 section 3.8.10 subsection Mipmapping
2166TEST_P(Texture2DTestES3, ImmutableTextureBaseLevelOutOfRange)
2167{
Olli Etuahoa314b612016-03-10 16:43:00 +02002168 glActiveTexture(GL_TEXTURE0);
2169 glBindTexture(GL_TEXTURE_2D, mTexture2D);
2170
2171 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
2172 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
2173
2174 glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 1, 1);
2175
2176 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &GLColor::green);
2177
2178 // For immutable-format textures, base level should be clamped to [0, levels - 1], and max level
2179 // should be clamped to [base_level, levels - 1].
2180 // GLES 3.0.4 section 3.8.10 subsection Mipmapping
2181 // In the case of this test, those rules make the effective base level and max level 0.
2182 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 10000);
2183 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 10000);
2184
2185 EXPECT_GL_NO_ERROR();
2186
2187 drawQuad(mProgram, "position", 0.5f);
2188
2189 // Texture should be complete.
2190 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
2191}
2192
Olli Etuaho87fc71c2016-05-11 14:25:21 +03002193// Test that changing base level works when it affects the format of the texture.
2194TEST_P(Texture2DTestES3, TextureFormatChangesWithBaseLevel)
2195{
2196 if (IsNVIDIA() && (isOpenGL() || isGLES()))
2197 {
2198 // Observed rendering corruption on NVIDIA OpenGL.
2199 std::cout << "Test skipped on NVIDIA OpenGL." << std::endl;
2200 return;
2201 }
2202 if (IsIntel() && isOpenGL())
2203 {
2204 // Observed incorrect rendering on Intel OpenGL.
2205 std::cout << "Test skipped on Intel OpenGL." << std::endl;
2206 return;
2207 }
2208 if (IsAMD() && isOpenGL())
2209 {
2210 // Observed incorrect rendering on AMD OpenGL.
2211 std::cout << "Test skipped on AMD OpenGL." << std::endl;
2212 return;
2213 }
2214
2215 glActiveTexture(GL_TEXTURE0);
2216 glBindTexture(GL_TEXTURE_2D, mTexture2D);
2217 std::vector<GLColor> texDataCyan(4u * 4u, GLColor::cyan);
2218 std::vector<GLColor> texDataGreen(4u * 4u, GLColor::green);
2219
2220 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
2221 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
2222
2223 // RGBA8 level that's initially unused.
2224 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE,
2225 texDataCyan.data());
2226
2227 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 1);
2228 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1);
2229
2230 // RG8 level that's initially used, with consistent dimensions with level 0 but a different
2231 // format. It reads green channel data from the green and alpha channels of texDataGreen
2232 // (this is a bit hacky but works).
2233 glTexImage2D(GL_TEXTURE_2D, 1, GL_RG8, 2, 2, 0, GL_RG, GL_UNSIGNED_BYTE, texDataGreen.data());
2234
2235 EXPECT_GL_NO_ERROR();
2236
2237 drawQuad(mProgram, "position", 0.5f);
2238
2239 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
2240
2241 // Switch the texture to use the cyan level 0 with the RGBA format.
2242 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
2243 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
2244
2245 EXPECT_GL_NO_ERROR();
2246
2247 drawQuad(mProgram, "position", 0.5f);
2248
2249 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::cyan);
2250}
2251
Olli Etuahoa314b612016-03-10 16:43:00 +02002252// Test that setting a texture image works when base level is out of range.
2253TEST_P(Texture2DTestES3, SetImageWhenBaseLevelOutOfRange)
2254{
2255 glActiveTexture(GL_TEXTURE0);
2256 glBindTexture(GL_TEXTURE_2D, mTexture2D);
2257
2258 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
2259 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
2260
2261 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 10000);
2262 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 10000);
2263
2264 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &GLColor::green);
2265
2266 EXPECT_GL_NO_ERROR();
2267
2268 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
2269
2270 drawQuad(mProgram, "position", 0.5f);
2271
2272 // Texture should be complete.
2273 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
Olli Etuahoa7416ff2016-01-18 12:22:55 +02002274}
2275
Jamie Madill2453dbc2015-07-14 11:35:42 -04002276// In the D3D11 renderer, we need to initialize some texture formats, to fill empty channels. EG RBA->RGBA8, with 1.0
2277// in the alpha channel. This test covers a bug where redefining array textures with these formats does not work as
2278// expected.
Olli Etuaho4a8329f2016-01-11 17:12:57 +02002279TEST_P(Texture2DArrayTestES3, RedefineInittableArray)
Jamie Madill2453dbc2015-07-14 11:35:42 -04002280{
2281 std::vector<GLubyte> pixelData;
2282 for (size_t count = 0; count < 5000; count++)
2283 {
2284 pixelData.push_back(0u);
2285 pixelData.push_back(255u);
2286 pixelData.push_back(0u);
2287 }
2288
2289 glBindTexture(GL_TEXTURE_2D_ARRAY, m2DArrayTexture);
Olli Etuaho4a8329f2016-01-11 17:12:57 +02002290 glUseProgram(mProgram);
Jamie Madill2453dbc2015-07-14 11:35:42 -04002291 glUniform1i(mTextureArrayLocation, 0);
2292
2293 // The first draw worked correctly.
2294 glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGB, 4, 4, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, &pixelData[0]);
2295
2296 glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
2297 glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
2298 glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_REPEAT);
2299 glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_REPEAT);
Olli Etuaho4a8329f2016-01-11 17:12:57 +02002300 drawQuad(mProgram, "position", 1.0f);
Olli Etuahoa314b612016-03-10 16:43:00 +02002301 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
Jamie Madill2453dbc2015-07-14 11:35:42 -04002302
2303 // The dimension of the respecification must match the original exactly to trigger the bug.
2304 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 +02002305 drawQuad(mProgram, "position", 1.0f);
Olli Etuahoa314b612016-03-10 16:43:00 +02002306 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
Jamie Madill2453dbc2015-07-14 11:35:42 -04002307
2308 ASSERT_GL_NO_ERROR();
2309}
2310
Olli Etuaho1a679902016-01-14 12:21:47 +02002311// Test shadow sampler and regular non-shadow sampler coexisting in the same shader.
2312// This test is needed especially to confirm that sampler registers get assigned correctly on
2313// the HLSL backend even when there's a mix of different HLSL sampler and texture types.
2314TEST_P(ShadowSamplerPlusSampler3DTestES3, ShadowSamplerPlusSampler3DDraw)
2315{
2316 glActiveTexture(GL_TEXTURE0);
2317 glBindTexture(GL_TEXTURE_3D, mTexture3D);
2318 GLubyte texData[4];
2319 texData[0] = 0;
2320 texData[1] = 60;
2321 texData[2] = 0;
2322 texData[3] = 255;
2323 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, texData);
2324
2325 glActiveTexture(GL_TEXTURE1);
2326 glBindTexture(GL_TEXTURE_2D, mTextureShadow);
2327 GLfloat depthTexData[1];
2328 depthTexData[0] = 0.5f;
2329 glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32F, 1, 1, 0, GL_DEPTH_COMPONENT, GL_FLOAT,
2330 depthTexData);
2331
2332 glUseProgram(mProgram);
2333 glUniform1f(mDepthRefUniformLocation, 0.3f);
2334 glUniform1i(mTexture3DUniformLocation, 0);
2335 glUniform1i(mTextureShadowUniformLocation, 1);
2336
2337 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
2338 drawQuad(mProgram, "position", 0.5f);
2339 EXPECT_GL_NO_ERROR();
2340 // The shader writes 0.5 * <comparison result (1.0)> + <texture color>
2341 EXPECT_PIXEL_NEAR(0, 0, 128, 188, 128, 255, 2);
2342
2343 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_GREATER);
2344 drawQuad(mProgram, "position", 0.5f);
2345 EXPECT_GL_NO_ERROR();
2346 // The shader writes 0.5 * <comparison result (0.0)> + <texture color>
2347 EXPECT_PIXEL_NEAR(0, 0, 0, 60, 0, 255, 2);
2348}
2349
Olli Etuahoc8c99a02016-01-14 16:47:22 +02002350// Test multiple different sampler types in the same shader.
2351// This test makes sure that even if sampler / texture registers get grouped together based on type
2352// or otherwise get shuffled around in the HLSL backend of the shader translator, the D3D renderer
2353// still has the right register index information for each ESSL sampler.
2354// The tested ESSL samplers have the following types in D3D11 HLSL:
2355// sampler2D: Texture2D + SamplerState
2356// samplerCube: TextureCube + SamplerState
2357// sampler2DShadow: Texture2D + SamplerComparisonState
2358// samplerCubeShadow: TextureCube + SamplerComparisonState
2359TEST_P(SamplerTypeMixTestES3, SamplerTypeMixDraw)
2360{
2361 glActiveTexture(GL_TEXTURE0);
2362 glBindTexture(GL_TEXTURE_2D, mTexture2D);
2363 GLubyte texData[4];
2364 texData[0] = 0;
2365 texData[1] = 0;
2366 texData[2] = 120;
2367 texData[3] = 255;
2368 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, texData);
2369
2370 glActiveTexture(GL_TEXTURE1);
2371 glBindTexture(GL_TEXTURE_CUBE_MAP, mTextureCube);
2372 texData[0] = 0;
2373 texData[1] = 90;
2374 texData[2] = 0;
2375 texData[3] = 255;
2376 glTexStorage2D(GL_TEXTURE_CUBE_MAP, 1, GL_RGBA8, 1, 1);
2377 glTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE,
2378 texData);
2379
2380 glActiveTexture(GL_TEXTURE2);
2381 glBindTexture(GL_TEXTURE_2D, mTexture2DShadow);
2382 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
2383 GLfloat depthTexData[1];
2384 depthTexData[0] = 0.5f;
2385 glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32F, 1, 1, 0, GL_DEPTH_COMPONENT, GL_FLOAT,
2386 depthTexData);
2387
2388 glActiveTexture(GL_TEXTURE3);
2389 glBindTexture(GL_TEXTURE_CUBE_MAP, mTextureCubeShadow);
2390 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
2391 depthTexData[0] = 0.2f;
2392 glTexStorage2D(GL_TEXTURE_CUBE_MAP, 1, GL_DEPTH_COMPONENT32F, 1, 1);
2393 glTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, 0, 0, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT,
2394 depthTexData);
2395
2396 EXPECT_GL_NO_ERROR();
2397
2398 glUseProgram(mProgram);
2399 glUniform1f(mDepthRefUniformLocation, 0.3f);
2400 glUniform1i(mTexture2DUniformLocation, 0);
2401 glUniform1i(mTextureCubeUniformLocation, 1);
2402 glUniform1i(mTexture2DShadowUniformLocation, 2);
2403 glUniform1i(mTextureCubeShadowUniformLocation, 3);
2404
2405 drawQuad(mProgram, "position", 0.5f);
2406 EXPECT_GL_NO_ERROR();
2407 // The shader writes:
2408 // <texture 2d color> +
2409 // <cube map color> +
2410 // 0.25 * <comparison result (1.0)> +
2411 // 0.125 * <comparison result (0.0)>
2412 EXPECT_PIXEL_NEAR(0, 0, 64, 154, 184, 255, 2);
2413}
2414
Olli Etuahobce743a2016-01-15 17:18:28 +02002415// Test different base levels on textures accessed through the same sampler array.
2416// Calling textureSize() on the samplers hits the D3D sampler metadata workaround.
2417TEST_P(TextureSizeTextureArrayTest, BaseLevelVariesInTextureArray)
2418{
Jamie Madill518b9fa2016-03-02 11:26:02 -05002419 if ((IsAMD() || IsIntel()) && getPlatformRenderer() == EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE)
Olli Etuahobce743a2016-01-15 17:18:28 +02002420 {
2421 std::cout << "Test skipped on Intel and AMD D3D." << std::endl;
2422 return;
2423 }
2424 glActiveTexture(GL_TEXTURE0);
2425 glBindTexture(GL_TEXTURE_2D, mTexture2DA);
2426 GLsizei size = 64;
2427 for (GLint level = 0; level < 7; ++level)
2428 {
2429 ASSERT_LT(0, size);
2430 glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, size, size, 0, GL_RGBA, GL_UNSIGNED_BYTE,
2431 nullptr);
2432 size = size / 2;
2433 }
2434 ASSERT_EQ(0, size);
2435 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 1);
2436
2437 glActiveTexture(GL_TEXTURE1);
2438 glBindTexture(GL_TEXTURE_2D, mTexture2DB);
2439 size = 128;
2440 for (GLint level = 0; level < 8; ++level)
2441 {
2442 ASSERT_LT(0, size);
2443 glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, size, size, 0, GL_RGBA, GL_UNSIGNED_BYTE,
2444 nullptr);
2445 size = size / 2;
2446 }
2447 ASSERT_EQ(0, size);
2448 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 3);
2449 EXPECT_GL_NO_ERROR();
2450
2451 glUseProgram(mProgram);
2452 glUniform1i(mTexture0Location, 0);
2453 glUniform1i(mTexture1Location, 1);
2454
2455 drawQuad(mProgram, "position", 0.5f);
2456 EXPECT_GL_NO_ERROR();
2457 // Red channel: width of level 1 of texture A: 32.
2458 // Green channel: width of level 3 of texture B: 16.
2459 EXPECT_PIXEL_NEAR(0, 0, 32, 16, 0, 255, 2);
2460}
2461
Olli Etuaho6ee394a2016-02-18 13:30:09 +02002462// When sampling a texture without an alpha channel, "1" is returned as the alpha value.
2463// ES 3.0.4 table 3.24
2464TEST_P(Texture2DTestES3, TextureRGBImplicitAlpha1)
2465{
2466 glActiveTexture(GL_TEXTURE0);
2467 glBindTexture(GL_TEXTURE_2D, mTexture2D);
2468 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, nullptr);
2469 EXPECT_GL_NO_ERROR();
2470
2471 drawQuad(mProgram, "position", 0.5f);
2472
2473 EXPECT_PIXEL_ALPHA_EQ(0, 0, 255);
2474}
2475
2476// When sampling a texture without an alpha channel, "1" is returned as the alpha value.
2477// ES 3.0.4 table 3.24
2478TEST_P(Texture2DTestES3, TextureLuminanceImplicitAlpha1)
2479{
2480 glActiveTexture(GL_TEXTURE0);
2481 glBindTexture(GL_TEXTURE_2D, mTexture2D);
2482 glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 1, 1, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, nullptr);
2483 EXPECT_GL_NO_ERROR();
2484
2485 drawQuad(mProgram, "position", 0.5f);
2486
2487 EXPECT_PIXEL_ALPHA_EQ(0, 0, 255);
2488}
2489
2490// When sampling a texture without an alpha channel, "1" is returned as the alpha value.
2491// ES 3.0.4 table 3.24
2492TEST_P(Texture2DTestES3, TextureLuminance32ImplicitAlpha1)
2493{
2494 if (extensionEnabled("GL_OES_texture_float"))
2495 {
2496 glActiveTexture(GL_TEXTURE0);
2497 glBindTexture(GL_TEXTURE_2D, mTexture2D);
2498 glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 1, 1, 0, GL_LUMINANCE, GL_FLOAT, nullptr);
2499 EXPECT_GL_NO_ERROR();
2500
2501 drawQuad(mProgram, "position", 0.5f);
2502
2503 EXPECT_PIXEL_ALPHA_EQ(0, 0, 255);
2504 }
2505}
2506
2507// When sampling a texture without an alpha channel, "1" is returned as the alpha value.
2508// ES 3.0.4 table 3.24
2509TEST_P(Texture2DTestES3, TextureLuminance16ImplicitAlpha1)
2510{
2511 if (extensionEnabled("GL_OES_texture_half_float"))
2512 {
Jamie Madill518b9fa2016-03-02 11:26:02 -05002513 if (IsNVIDIA() && getPlatformRenderer() == EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE)
Olli Etuaho6ee394a2016-02-18 13:30:09 +02002514 {
2515 std::cout << "Test skipped on NVIDIA" << std::endl;
2516 return;
2517 }
2518 glActiveTexture(GL_TEXTURE0);
2519 glBindTexture(GL_TEXTURE_2D, mTexture2D);
2520 glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 1, 1, 0, GL_LUMINANCE, GL_HALF_FLOAT_OES,
2521 nullptr);
2522 EXPECT_GL_NO_ERROR();
2523
2524 drawQuad(mProgram, "position", 0.5f);
2525
2526 EXPECT_PIXEL_ALPHA_EQ(0, 0, 255);
2527 }
2528}
2529
2530// When sampling a texture without an alpha channel, "1" is returned as the alpha value.
2531// ES 3.0.4 table 3.24
2532TEST_P(Texture2DUnsignedIntegerAlpha1TestES3, TextureRGB8UIImplicitAlpha1)
2533{
Jamie Madill518b9fa2016-03-02 11:26:02 -05002534 if (IsIntel())
Olli Etuaho6ee394a2016-02-18 13:30:09 +02002535 {
Jamie Madill518b9fa2016-03-02 11:26:02 -05002536 std::cout << "Test disabled on Intel." << std::endl;
Olli Etuaho6ee394a2016-02-18 13:30:09 +02002537 return;
2538 }
2539 glActiveTexture(GL_TEXTURE0);
2540 glBindTexture(GL_TEXTURE_2D, mTexture2D);
2541 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8UI, 1, 1, 0, GL_RGB_INTEGER, GL_UNSIGNED_BYTE, nullptr);
2542 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
2543 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
2544 EXPECT_GL_NO_ERROR();
2545
2546 drawQuad(mProgram, "position", 0.5f);
2547
2548 EXPECT_PIXEL_ALPHA_EQ(0, 0, 255);
2549}
2550
2551// When sampling a texture without an alpha channel, "1" is returned as the alpha value.
2552// ES 3.0.4 table 3.24
2553TEST_P(Texture2DIntegerAlpha1TestES3, TextureRGB8IImplicitAlpha1)
2554{
Jamie Madill518b9fa2016-03-02 11:26:02 -05002555 if (IsIntel())
Olli Etuaho6ee394a2016-02-18 13:30:09 +02002556 {
Jamie Madill518b9fa2016-03-02 11:26:02 -05002557 std::cout << "Test disabled on Intel." << std::endl;
Olli Etuaho6ee394a2016-02-18 13:30:09 +02002558 return;
2559 }
2560 glActiveTexture(GL_TEXTURE0);
2561 glBindTexture(GL_TEXTURE_2D, mTexture2D);
2562
2563 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8I, 1, 1, 0, GL_RGB_INTEGER, GL_BYTE, nullptr);
2564 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
2565 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
2566 EXPECT_GL_NO_ERROR();
2567
2568 drawQuad(mProgram, "position", 0.5f);
2569
2570 EXPECT_PIXEL_ALPHA_EQ(0, 0, 255);
2571}
2572
2573// When sampling a texture without an alpha channel, "1" is returned as the alpha value.
2574// ES 3.0.4 table 3.24
2575TEST_P(Texture2DUnsignedIntegerAlpha1TestES3, TextureRGB16UIImplicitAlpha1)
2576{
Jamie Madill518b9fa2016-03-02 11:26:02 -05002577 if (IsIntel())
Olli Etuaho6ee394a2016-02-18 13:30:09 +02002578 {
Jamie Madill518b9fa2016-03-02 11:26:02 -05002579 std::cout << "Test disabled on Intel." << std::endl;
Olli Etuaho6ee394a2016-02-18 13:30:09 +02002580 return;
2581 }
2582 glActiveTexture(GL_TEXTURE0);
2583 glBindTexture(GL_TEXTURE_2D, mTexture2D);
2584 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB16UI, 1, 1, 0, GL_RGB_INTEGER, GL_UNSIGNED_SHORT, nullptr);
2585 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
2586 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
2587 EXPECT_GL_NO_ERROR();
2588
2589 drawQuad(mProgram, "position", 0.5f);
2590
2591 EXPECT_PIXEL_ALPHA_EQ(0, 0, 255);
2592}
2593
2594// When sampling a texture without an alpha channel, "1" is returned as the alpha value.
2595// ES 3.0.4 table 3.24
2596TEST_P(Texture2DIntegerAlpha1TestES3, TextureRGB16IImplicitAlpha1)
2597{
Jamie Madill518b9fa2016-03-02 11:26:02 -05002598 if (IsIntel())
Olli Etuaho6ee394a2016-02-18 13:30:09 +02002599 {
Jamie Madill518b9fa2016-03-02 11:26:02 -05002600 std::cout << "Test disabled on Intel." << std::endl;
Olli Etuaho6ee394a2016-02-18 13:30:09 +02002601 return;
2602 }
2603 glActiveTexture(GL_TEXTURE0);
2604 glBindTexture(GL_TEXTURE_2D, mTexture2D);
2605 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB16I, 1, 1, 0, GL_RGB_INTEGER, GL_SHORT, nullptr);
2606 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
2607 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
2608 EXPECT_GL_NO_ERROR();
2609
2610 drawQuad(mProgram, "position", 0.5f);
2611
2612 EXPECT_PIXEL_ALPHA_EQ(0, 0, 255);
2613}
2614
2615// When sampling a texture without an alpha channel, "1" is returned as the alpha value.
2616// ES 3.0.4 table 3.24
2617TEST_P(Texture2DUnsignedIntegerAlpha1TestES3, TextureRGB32UIImplicitAlpha1)
2618{
Jamie Madill518b9fa2016-03-02 11:26:02 -05002619 if (IsIntel())
Olli Etuaho6ee394a2016-02-18 13:30:09 +02002620 {
Jamie Madill518b9fa2016-03-02 11:26:02 -05002621 std::cout << "Test disabled on Intel." << std::endl;
Olli Etuaho6ee394a2016-02-18 13:30:09 +02002622 return;
2623 }
2624 glActiveTexture(GL_TEXTURE0);
2625 glBindTexture(GL_TEXTURE_2D, mTexture2D);
2626 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB32UI, 1, 1, 0, GL_RGB_INTEGER, GL_UNSIGNED_INT, nullptr);
2627 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
2628 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
2629 EXPECT_GL_NO_ERROR();
2630
2631 drawQuad(mProgram, "position", 0.5f);
2632
2633 EXPECT_PIXEL_ALPHA_EQ(0, 0, 255);
2634}
2635
2636// When sampling a texture without an alpha channel, "1" is returned as the alpha value.
2637// ES 3.0.4 table 3.24
2638TEST_P(Texture2DIntegerAlpha1TestES3, TextureRGB32IImplicitAlpha1)
2639{
Jamie Madill518b9fa2016-03-02 11:26:02 -05002640 if (IsIntel())
Olli Etuaho6ee394a2016-02-18 13:30:09 +02002641 {
Jamie Madill518b9fa2016-03-02 11:26:02 -05002642 std::cout << "Test disabled on Intel." << std::endl;
Olli Etuaho6ee394a2016-02-18 13:30:09 +02002643 return;
2644 }
2645 glActiveTexture(GL_TEXTURE0);
2646 glBindTexture(GL_TEXTURE_2D, mTexture2D);
2647 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB32I, 1, 1, 0, GL_RGB_INTEGER, GL_INT, nullptr);
2648 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
2649 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
2650 EXPECT_GL_NO_ERROR();
2651
2652 drawQuad(mProgram, "position", 0.5f);
2653
2654 EXPECT_PIXEL_ALPHA_EQ(0, 0, 255);
2655}
2656
2657// When sampling a texture without an alpha channel, "1" is returned as the alpha value.
2658// ES 3.0.4 table 3.24
2659TEST_P(Texture2DTestES3, TextureRGBSNORMImplicitAlpha1)
2660{
2661 glActiveTexture(GL_TEXTURE0);
2662 glBindTexture(GL_TEXTURE_2D, mTexture2D);
2663 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8_SNORM, 1, 1, 0, GL_RGB, GL_BYTE, nullptr);
2664 EXPECT_GL_NO_ERROR();
2665
2666 drawQuad(mProgram, "position", 0.5f);
2667
2668 EXPECT_PIXEL_ALPHA_EQ(0, 0, 255);
2669}
2670
2671// When sampling a texture without an alpha channel, "1" is returned as the alpha value.
2672// ES 3.0.4 table 3.24
2673TEST_P(Texture2DTestES3, TextureRGB9E5ImplicitAlpha1)
2674{
2675 glActiveTexture(GL_TEXTURE0);
2676 glBindTexture(GL_TEXTURE_2D, mTexture2D);
2677 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB9_E5, 1, 1, 0, GL_RGB, GL_UNSIGNED_INT_5_9_9_9_REV,
2678 nullptr);
2679 EXPECT_GL_NO_ERROR();
2680
2681 drawQuad(mProgram, "position", 0.5f);
2682
2683 EXPECT_PIXEL_ALPHA_EQ(0, 0, 255);
2684}
2685
2686// When sampling a texture without an alpha channel, "1" is returned as the alpha value.
2687// ES 3.0.4 table 3.24
2688TEST_P(Texture2DTestES3, TextureCOMPRESSEDRGB8ETC2ImplicitAlpha1)
2689{
2690 glActiveTexture(GL_TEXTURE0);
2691 glBindTexture(GL_TEXTURE_2D, mTexture2D);
2692 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB8_ETC2, 1, 1, 0, 8, nullptr);
2693 EXPECT_GL_NO_ERROR();
2694
2695 drawQuad(mProgram, "position", 0.5f);
2696
2697 EXPECT_PIXEL_ALPHA_EQ(0, 0, 255);
2698}
2699
2700// When sampling a texture without an alpha channel, "1" is returned as the alpha value.
2701// ES 3.0.4 table 3.24
2702TEST_P(Texture2DTestES3, TextureCOMPRESSEDSRGB8ETC2ImplicitAlpha1)
2703{
Corentin Wallez9e3c6152016-03-29 21:58:33 -04002704 if (IsIntel() && IsLinux())
2705 {
2706 // TODO(cwallez): Fix on Linux Intel drivers (http://anglebug.com/1346)
2707 std::cout << "Test disabled on Linux Intel OpenGL." << std::endl;
2708 return;
2709 }
2710
Olli Etuaho6ee394a2016-02-18 13:30:09 +02002711 glActiveTexture(GL_TEXTURE0);
2712 glBindTexture(GL_TEXTURE_2D, mTexture2D);
2713 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_SRGB8_ETC2, 1, 1, 0, 8, nullptr);
2714 EXPECT_GL_NO_ERROR();
2715
2716 drawQuad(mProgram, "position", 0.5f);
2717
2718 EXPECT_PIXEL_ALPHA_EQ(0, 0, 255);
2719}
2720
Olli Etuaho96963162016-03-21 11:54:33 +02002721// Use a sampler in a uniform struct.
2722TEST_P(SamplerInStructTest, SamplerInStruct)
2723{
2724 runSamplerInStructTest();
2725}
2726
2727// Use a sampler in a uniform struct that's passed as a function parameter.
2728TEST_P(SamplerInStructAsFunctionParameterTest, SamplerInStructAsFunctionParameter)
2729{
2730 runSamplerInStructTest();
2731}
2732
2733// Use a sampler in a uniform struct array with a struct from the array passed as a function
2734// parameter.
2735TEST_P(SamplerInStructArrayAsFunctionParameterTest, SamplerInStructArrayAsFunctionParameter)
2736{
Olli Etuahoa1c917f2016-04-06 13:50:03 +03002737 if (IsIntel() && GetParam().getRenderer() == EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE)
2738 {
2739 std::cout << "Test skipped on Intel OpenGL." << std::endl;
2740 return;
2741 }
Olli Etuaho96963162016-03-21 11:54:33 +02002742 runSamplerInStructTest();
2743}
2744
2745// Use a sampler in a struct inside a uniform struct with the nested struct passed as a function
2746// parameter.
2747TEST_P(SamplerInNestedStructAsFunctionParameterTest, SamplerInNestedStructAsFunctionParameter)
2748{
Olli Etuahoa1c917f2016-04-06 13:50:03 +03002749 if (IsIntel() && GetParam().getRenderer() == EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE)
2750 {
2751 std::cout << "Test skipped on Intel OpenGL." << std::endl;
2752 return;
2753 }
Olli Etuaho96963162016-03-21 11:54:33 +02002754 runSamplerInStructTest();
2755}
2756
2757// Make sure that there isn't a name conflict between sampler extracted from a struct and a
2758// similarly named uniform.
2759TEST_P(SamplerInStructAndOtherVariableTest, SamplerInStructAndOtherVariable)
2760{
2761 runSamplerInStructTest();
2762}
2763
Jamie Madill3d3d2f22015-09-23 16:47:51 -04002764class TextureLimitsTest : public ANGLETest
2765{
2766 protected:
2767 struct RGBA8
2768 {
2769 uint8_t R, G, B, A;
2770 };
2771
2772 TextureLimitsTest()
2773 : mProgram(0), mMaxVertexTextures(0), mMaxFragmentTextures(0), mMaxCombinedTextures(0)
2774 {
2775 setWindowWidth(128);
2776 setWindowHeight(128);
2777 setConfigRedBits(8);
2778 setConfigGreenBits(8);
2779 setConfigBlueBits(8);
2780 setConfigAlphaBits(8);
2781 }
2782
2783 ~TextureLimitsTest()
2784 {
2785 if (mProgram != 0)
2786 {
2787 glDeleteProgram(mProgram);
2788 mProgram = 0;
2789
2790 if (!mTextures.empty())
2791 {
2792 glDeleteTextures(static_cast<GLsizei>(mTextures.size()), &mTextures[0]);
2793 }
2794 }
2795 }
2796
2797 void SetUp() override
2798 {
2799 ANGLETest::SetUp();
2800
2801 glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, &mMaxVertexTextures);
2802 glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &mMaxFragmentTextures);
2803 glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &mMaxCombinedTextures);
2804
2805 ASSERT_GL_NO_ERROR();
2806 }
2807
2808 void compileProgramWithTextureCounts(const std::string &vertexPrefix,
2809 GLint vertexTextureCount,
2810 GLint vertexActiveTextureCount,
2811 const std::string &fragPrefix,
2812 GLint fragmentTextureCount,
2813 GLint fragmentActiveTextureCount)
2814 {
2815 std::stringstream vertexShaderStr;
2816 vertexShaderStr << "attribute vec2 position;\n"
2817 << "varying vec4 color;\n"
2818 << "varying vec2 texCoord;\n";
2819
2820 for (GLint textureIndex = 0; textureIndex < vertexTextureCount; ++textureIndex)
2821 {
2822 vertexShaderStr << "uniform sampler2D " << vertexPrefix << textureIndex << ";\n";
2823 }
2824
2825 vertexShaderStr << "void main() {\n"
2826 << " gl_Position = vec4(position, 0, 1);\n"
2827 << " texCoord = (position * 0.5) + 0.5;\n"
2828 << " color = vec4(0);\n";
2829
2830 for (GLint textureIndex = 0; textureIndex < vertexActiveTextureCount; ++textureIndex)
2831 {
2832 vertexShaderStr << " color += texture2D(" << vertexPrefix << textureIndex
2833 << ", texCoord);\n";
2834 }
2835
2836 vertexShaderStr << "}";
2837
2838 std::stringstream fragmentShaderStr;
2839 fragmentShaderStr << "varying mediump vec4 color;\n"
2840 << "varying mediump vec2 texCoord;\n";
2841
2842 for (GLint textureIndex = 0; textureIndex < fragmentTextureCount; ++textureIndex)
2843 {
2844 fragmentShaderStr << "uniform sampler2D " << fragPrefix << textureIndex << ";\n";
2845 }
2846
2847 fragmentShaderStr << "void main() {\n"
2848 << " gl_FragColor = color;\n";
2849
2850 for (GLint textureIndex = 0; textureIndex < fragmentActiveTextureCount; ++textureIndex)
2851 {
2852 fragmentShaderStr << " gl_FragColor += texture2D(" << fragPrefix << textureIndex
2853 << ", texCoord);\n";
2854 }
2855
2856 fragmentShaderStr << "}";
2857
2858 const std::string &vertexShaderSource = vertexShaderStr.str();
2859 const std::string &fragmentShaderSource = fragmentShaderStr.str();
2860
2861 mProgram = CompileProgram(vertexShaderSource, fragmentShaderSource);
2862 }
2863
2864 RGBA8 getPixel(GLint texIndex)
2865 {
2866 RGBA8 pixel = {static_cast<uint8_t>(texIndex & 0x7u), static_cast<uint8_t>(texIndex >> 3),
2867 0, 255u};
2868 return pixel;
2869 }
2870
2871 void initTextures(GLint tex2DCount, GLint texCubeCount)
2872 {
2873 GLint totalCount = tex2DCount + texCubeCount;
2874 mTextures.assign(totalCount, 0);
2875 glGenTextures(totalCount, &mTextures[0]);
2876 ASSERT_GL_NO_ERROR();
2877
2878 std::vector<RGBA8> texData(16 * 16);
2879
2880 GLint texIndex = 0;
2881 for (; texIndex < tex2DCount; ++texIndex)
2882 {
2883 texData.assign(texData.size(), getPixel(texIndex));
2884 glActiveTexture(GL_TEXTURE0 + texIndex);
2885 glBindTexture(GL_TEXTURE_2D, mTextures[texIndex]);
2886 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE,
2887 &texData[0]);
2888 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
2889 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
2890 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
2891 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
2892 }
2893
2894 ASSERT_GL_NO_ERROR();
2895
2896 for (; texIndex < texCubeCount; ++texIndex)
2897 {
2898 texData.assign(texData.size(), getPixel(texIndex));
2899 glActiveTexture(GL_TEXTURE0 + texIndex);
2900 glBindTexture(GL_TEXTURE_CUBE_MAP, mTextures[texIndex]);
2901 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGBA, 16, 16, 0, GL_RGBA,
2902 GL_UNSIGNED_BYTE, &texData[0]);
2903 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGBA, 16, 16, 0, GL_RGBA,
2904 GL_UNSIGNED_BYTE, &texData[0]);
2905 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGBA, 16, 16, 0, GL_RGBA,
2906 GL_UNSIGNED_BYTE, &texData[0]);
2907 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGBA, 16, 16, 0, GL_RGBA,
2908 GL_UNSIGNED_BYTE, &texData[0]);
2909 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGBA, 16, 16, 0, GL_RGBA,
2910 GL_UNSIGNED_BYTE, &texData[0]);
2911 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGBA, 16, 16, 0, GL_RGBA,
2912 GL_UNSIGNED_BYTE, &texData[0]);
2913 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
2914 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
2915 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
2916 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
2917 }
2918
2919 ASSERT_GL_NO_ERROR();
2920 }
2921
2922 void testWithTextures(GLint vertexTextureCount,
2923 const std::string &vertexTexturePrefix,
2924 GLint fragmentTextureCount,
2925 const std::string &fragmentTexturePrefix)
2926 {
2927 // Generate textures
2928 initTextures(vertexTextureCount + fragmentTextureCount, 0);
2929
2930 glUseProgram(mProgram);
2931 RGBA8 expectedSum = {0};
2932 for (GLint texIndex = 0; texIndex < vertexTextureCount; ++texIndex)
2933 {
2934 std::stringstream uniformNameStr;
2935 uniformNameStr << vertexTexturePrefix << texIndex;
2936 const std::string &uniformName = uniformNameStr.str();
2937 GLint location = glGetUniformLocation(mProgram, uniformName.c_str());
2938 ASSERT_NE(-1, location);
2939
2940 glUniform1i(location, texIndex);
2941 RGBA8 contribution = getPixel(texIndex);
2942 expectedSum.R += contribution.R;
2943 expectedSum.G += contribution.G;
2944 }
2945
2946 for (GLint texIndex = 0; texIndex < fragmentTextureCount; ++texIndex)
2947 {
2948 std::stringstream uniformNameStr;
2949 uniformNameStr << fragmentTexturePrefix << texIndex;
2950 const std::string &uniformName = uniformNameStr.str();
2951 GLint location = glGetUniformLocation(mProgram, uniformName.c_str());
2952 ASSERT_NE(-1, location);
2953
2954 glUniform1i(location, texIndex + vertexTextureCount);
2955 RGBA8 contribution = getPixel(texIndex + vertexTextureCount);
2956 expectedSum.R += contribution.R;
2957 expectedSum.G += contribution.G;
2958 }
2959
2960 ASSERT_GE(256u, expectedSum.G);
2961
2962 drawQuad(mProgram, "position", 0.5f);
2963 ASSERT_GL_NO_ERROR();
2964 EXPECT_PIXEL_EQ(0, 0, expectedSum.R, expectedSum.G, 0, 255);
2965 }
2966
2967 GLuint mProgram;
2968 std::vector<GLuint> mTextures;
2969 GLint mMaxVertexTextures;
2970 GLint mMaxFragmentTextures;
2971 GLint mMaxCombinedTextures;
2972};
2973
2974// Test rendering with the maximum vertex texture units.
2975TEST_P(TextureLimitsTest, MaxVertexTextures)
2976{
Jamie Madill1ea9aaa2015-10-07 11:13:55 -04002977 // TODO(jmadill): Figure out why this fails on Intel.
Jamie Madill518b9fa2016-03-02 11:26:02 -05002978 if (IsIntel() && GetParam().getRenderer() == EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE)
Jamie Madill1ea9aaa2015-10-07 11:13:55 -04002979 {
2980 std::cout << "Test skipped on Intel." << std::endl;
2981 return;
2982 }
2983
Jamie Madill3d3d2f22015-09-23 16:47:51 -04002984 compileProgramWithTextureCounts("tex", mMaxVertexTextures, mMaxVertexTextures, "tex", 0, 0);
2985 ASSERT_NE(0u, mProgram);
2986 ASSERT_GL_NO_ERROR();
2987
2988 testWithTextures(mMaxVertexTextures, "tex", 0, "tex");
2989}
2990
2991// Test rendering with the maximum fragment texture units.
2992TEST_P(TextureLimitsTest, MaxFragmentTextures)
2993{
Jamie Madill1ea9aaa2015-10-07 11:13:55 -04002994 // TODO(jmadill): Figure out why this fails on Intel.
Jamie Madill518b9fa2016-03-02 11:26:02 -05002995 if (IsIntel() && GetParam().getRenderer() == EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE)
Jamie Madill1ea9aaa2015-10-07 11:13:55 -04002996 {
2997 std::cout << "Test skipped on Intel." << std::endl;
2998 return;
2999 }
3000
Jamie Madill3d3d2f22015-09-23 16:47:51 -04003001 compileProgramWithTextureCounts("tex", 0, 0, "tex", mMaxFragmentTextures, mMaxFragmentTextures);
3002 ASSERT_NE(0u, mProgram);
3003 ASSERT_GL_NO_ERROR();
3004
3005 testWithTextures(mMaxFragmentTextures, "tex", 0, "tex");
3006}
3007
3008// Test rendering with maximum combined texture units.
3009TEST_P(TextureLimitsTest, MaxCombinedTextures)
3010{
Jamie Madill412f17d2015-09-25 08:43:54 -04003011 // TODO(jmadill): Investigate workaround.
Jamie Madill518b9fa2016-03-02 11:26:02 -05003012 if (IsIntel() && GetParam() == ES2_OPENGL())
Jamie Madill412f17d2015-09-25 08:43:54 -04003013 {
3014 std::cout << "Test skipped on Intel." << std::endl;
3015 return;
3016 }
3017
Jamie Madill3d3d2f22015-09-23 16:47:51 -04003018 GLint vertexTextures = mMaxVertexTextures;
3019
3020 if (vertexTextures + mMaxFragmentTextures > mMaxCombinedTextures)
3021 {
3022 vertexTextures = mMaxCombinedTextures - mMaxFragmentTextures;
3023 }
3024
3025 compileProgramWithTextureCounts("vtex", vertexTextures, vertexTextures, "ftex",
3026 mMaxFragmentTextures, mMaxFragmentTextures);
3027 ASSERT_NE(0u, mProgram);
3028 ASSERT_GL_NO_ERROR();
3029
3030 testWithTextures(vertexTextures, "vtex", mMaxFragmentTextures, "ftex");
3031}
3032
3033// Negative test for exceeding the number of vertex textures
3034TEST_P(TextureLimitsTest, ExcessiveVertexTextures)
3035{
3036 compileProgramWithTextureCounts("tex", mMaxVertexTextures + 1, mMaxVertexTextures + 1, "tex", 0,
3037 0);
3038 ASSERT_EQ(0u, mProgram);
3039}
3040
3041// Negative test for exceeding the number of fragment textures
3042TEST_P(TextureLimitsTest, ExcessiveFragmentTextures)
3043{
3044 compileProgramWithTextureCounts("tex", 0, 0, "tex", mMaxFragmentTextures + 1,
3045 mMaxFragmentTextures + 1);
3046 ASSERT_EQ(0u, mProgram);
3047}
3048
3049// Test active vertex textures under the limit, but excessive textures specified.
3050TEST_P(TextureLimitsTest, MaxActiveVertexTextures)
3051{
Jamie Madill1ea9aaa2015-10-07 11:13:55 -04003052 // TODO(jmadill): Figure out why this fails on Intel.
Jamie Madill518b9fa2016-03-02 11:26:02 -05003053 if (IsIntel() && GetParam().getRenderer() == EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE)
Jamie Madill1ea9aaa2015-10-07 11:13:55 -04003054 {
3055 std::cout << "Test skipped on Intel." << std::endl;
3056 return;
3057 }
3058
Jamie Madill3d3d2f22015-09-23 16:47:51 -04003059 compileProgramWithTextureCounts("tex", mMaxVertexTextures + 4, mMaxVertexTextures, "tex", 0, 0);
3060 ASSERT_NE(0u, mProgram);
3061 ASSERT_GL_NO_ERROR();
3062
3063 testWithTextures(mMaxVertexTextures, "tex", 0, "tex");
3064}
3065
3066// Test active fragment textures under the limit, but excessive textures specified.
3067TEST_P(TextureLimitsTest, MaxActiveFragmentTextures)
3068{
Jamie Madill1ea9aaa2015-10-07 11:13:55 -04003069 // TODO(jmadill): Figure out why this fails on Intel.
Jamie Madill518b9fa2016-03-02 11:26:02 -05003070 if (IsIntel() && GetParam().getRenderer() == EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE)
Jamie Madill1ea9aaa2015-10-07 11:13:55 -04003071 {
3072 std::cout << "Test skipped on Intel." << std::endl;
3073 return;
3074 }
3075
Jamie Madill3d3d2f22015-09-23 16:47:51 -04003076 compileProgramWithTextureCounts("tex", 0, 0, "tex", mMaxFragmentTextures + 4,
3077 mMaxFragmentTextures);
3078 ASSERT_NE(0u, mProgram);
3079 ASSERT_GL_NO_ERROR();
3080
3081 testWithTextures(0, "tex", mMaxFragmentTextures, "tex");
3082}
3083
3084// Negative test for pointing two sampler uniforms of different types to the same texture.
Olli Etuaho4a8329f2016-01-11 17:12:57 +02003085// GLES 2.0.25 section 2.10.4 page 39.
Jamie Madill3d3d2f22015-09-23 16:47:51 -04003086TEST_P(TextureLimitsTest, TextureTypeConflict)
3087{
3088 const std::string &vertexShader =
3089 "attribute vec2 position;\n"
3090 "varying float color;\n"
3091 "uniform sampler2D tex2D;\n"
3092 "uniform samplerCube texCube;\n"
3093 "void main() {\n"
3094 " gl_Position = vec4(position, 0, 1);\n"
3095 " vec2 texCoord = (position * 0.5) + 0.5;\n"
3096 " color = texture2D(tex2D, texCoord).x;\n"
3097 " color += textureCube(texCube, vec3(texCoord, 0)).x;\n"
3098 "}";
3099 const std::string &fragmentShader =
3100 "varying mediump float color;\n"
3101 "void main() {\n"
3102 " gl_FragColor = vec4(color, 0, 0, 1);\n"
3103 "}";
3104
3105 mProgram = CompileProgram(vertexShader, fragmentShader);
3106 ASSERT_NE(0u, mProgram);
3107
3108 initTextures(1, 0);
3109
3110 glUseProgram(mProgram);
3111 GLint tex2DLocation = glGetUniformLocation(mProgram, "tex2D");
3112 ASSERT_NE(-1, tex2DLocation);
3113 GLint texCubeLocation = glGetUniformLocation(mProgram, "texCube");
3114 ASSERT_NE(-1, texCubeLocation);
3115
3116 glUniform1i(tex2DLocation, 0);
3117 glUniform1i(texCubeLocation, 0);
3118 ASSERT_GL_NO_ERROR();
3119
3120 drawQuad(mProgram, "position", 0.5f);
3121 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
3122}
3123
3124// Negative test for rendering with texture outside the valid range.
Olli Etuaho4a8329f2016-01-11 17:12:57 +02003125// TODO(jmadill): Possibly adjust the test according to the spec:
3126// GLES 3.0.4 section 2.12.7 mentions that specifying an out-of-range sampler uniform value
3127// generates an INVALID_VALUE error - GLES 2.0 doesn't yet have this mention.
Jamie Madill3d3d2f22015-09-23 16:47:51 -04003128TEST_P(TextureLimitsTest, DrawWithTexturePastMaximum)
3129{
3130 const std::string &vertexShader =
3131 "attribute vec2 position;\n"
3132 "varying float color;\n"
3133 "uniform sampler2D tex2D;\n"
3134 "void main() {\n"
3135 " gl_Position = vec4(position, 0, 1);\n"
3136 " vec2 texCoord = (position * 0.5) + 0.5;\n"
3137 " color = texture2D(tex2D, texCoord).x;\n"
3138 "}";
3139 const std::string &fragmentShader =
3140 "varying mediump float color;\n"
3141 "void main() {\n"
3142 " gl_FragColor = vec4(color, 0, 0, 1);\n"
3143 "}";
3144
3145 mProgram = CompileProgram(vertexShader, fragmentShader);
3146 ASSERT_NE(0u, mProgram);
3147
3148 glUseProgram(mProgram);
3149 GLint tex2DLocation = glGetUniformLocation(mProgram, "tex2D");
3150 ASSERT_NE(-1, tex2DLocation);
3151
3152 glUniform1i(tex2DLocation, mMaxCombinedTextures);
3153 ASSERT_GL_NO_ERROR();
3154
3155 drawQuad(mProgram, "position", 0.5f);
3156 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
3157}
3158
Jamie Madillfa05f602015-05-07 13:47:11 -04003159// 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 +02003160// TODO(oetuaho): Enable all below tests on OpenGL. Requires a fix for ANGLE bug 1278.
Geoff Lange0cc2a42016-01-20 10:58:17 -05003161ANGLE_INSTANTIATE_TEST(Texture2DTest,
3162 ES2_D3D9(),
3163 ES2_D3D11(),
3164 ES2_D3D11_FL9_3(),
3165 ES2_OPENGL(),
3166 ES2_OPENGLES());
3167ANGLE_INSTANTIATE_TEST(TextureCubeTest,
3168 ES2_D3D9(),
3169 ES2_D3D11(),
3170 ES2_D3D11_FL9_3(),
3171 ES2_OPENGL(),
3172 ES2_OPENGLES());
Olli Etuaho51f1c0f2016-01-13 16:16:24 +02003173ANGLE_INSTANTIATE_TEST(Texture2DTestWithDrawScale,
3174 ES2_D3D9(),
3175 ES2_D3D11(),
3176 ES2_D3D11_FL9_3(),
Geoff Lange0cc2a42016-01-20 10:58:17 -05003177 ES2_OPENGL(),
3178 ES2_OPENGLES());
Olli Etuaho51f1c0f2016-01-13 16:16:24 +02003179ANGLE_INSTANTIATE_TEST(Sampler2DAsFunctionParameterTest,
3180 ES2_D3D9(),
3181 ES2_D3D11(),
3182 ES2_D3D11_FL9_3(),
Geoff Lange0cc2a42016-01-20 10:58:17 -05003183 ES2_OPENGL(),
3184 ES2_OPENGLES());
3185ANGLE_INSTANTIATE_TEST(SamplerArrayTest,
3186 ES2_D3D9(),
3187 ES2_D3D11(),
3188 ES2_D3D11_FL9_3(),
3189 ES2_OPENGL(),
3190 ES2_OPENGLES());
3191ANGLE_INSTANTIATE_TEST(SamplerArrayAsFunctionParameterTest,
3192 ES2_D3D9(),
3193 ES2_D3D11(),
3194 ES2_D3D11_FL9_3(),
3195 ES2_OPENGL(),
3196 ES2_OPENGLES());
3197ANGLE_INSTANTIATE_TEST(Texture2DTestES3, ES3_D3D11(), ES3_OPENGL(), ES3_OPENGLES());
Olli Etuahoa314b612016-03-10 16:43:00 +02003198ANGLE_INSTANTIATE_TEST(Texture3DTestES3, ES3_D3D11(), ES3_OPENGL(), ES3_OPENGLES());
Olli Etuaho6ee394a2016-02-18 13:30:09 +02003199ANGLE_INSTANTIATE_TEST(Texture2DIntegerAlpha1TestES3, ES3_D3D11(), ES3_OPENGL(), ES3_OPENGLES());
3200ANGLE_INSTANTIATE_TEST(Texture2DUnsignedIntegerAlpha1TestES3,
3201 ES3_D3D11(),
3202 ES3_OPENGL(),
3203 ES3_OPENGLES());
Geoff Lange0cc2a42016-01-20 10:58:17 -05003204ANGLE_INSTANTIATE_TEST(ShadowSamplerPlusSampler3DTestES3,
3205 ES3_D3D11(),
3206 ES3_OPENGL(),
3207 ES3_OPENGLES());
3208ANGLE_INSTANTIATE_TEST(SamplerTypeMixTestES3, ES3_D3D11(), ES3_OPENGL(), ES3_OPENGLES());
3209ANGLE_INSTANTIATE_TEST(Texture2DArrayTestES3, ES3_D3D11(), ES3_OPENGL(), ES3_OPENGLES());
Olli Etuahobce743a2016-01-15 17:18:28 +02003210ANGLE_INSTANTIATE_TEST(TextureSizeTextureArrayTest, ES3_D3D11(), ES3_OPENGL());
Olli Etuaho96963162016-03-21 11:54:33 +02003211ANGLE_INSTANTIATE_TEST(SamplerInStructTest,
3212 ES2_D3D11(),
3213 ES2_D3D11_FL9_3(),
3214 ES2_D3D9(),
3215 ES2_OPENGL(),
3216 ES2_OPENGLES());
3217ANGLE_INSTANTIATE_TEST(SamplerInStructAsFunctionParameterTest,
3218 ES2_D3D11(),
3219 ES2_D3D11_FL9_3(),
3220 ES2_D3D9(),
3221 ES2_OPENGL(),
3222 ES2_OPENGLES());
3223ANGLE_INSTANTIATE_TEST(SamplerInStructArrayAsFunctionParameterTest,
3224 ES2_D3D11(),
3225 ES2_D3D11_FL9_3(),
3226 ES2_D3D9(),
3227 ES2_OPENGL(),
3228 ES2_OPENGLES());
3229ANGLE_INSTANTIATE_TEST(SamplerInNestedStructAsFunctionParameterTest,
3230 ES2_D3D11(),
3231 ES2_D3D11_FL9_3(),
3232 ES2_D3D9(),
3233 ES2_OPENGL(),
3234 ES2_OPENGLES());
3235ANGLE_INSTANTIATE_TEST(SamplerInStructAndOtherVariableTest,
3236 ES2_D3D11(),
3237 ES2_D3D11_FL9_3(),
3238 ES2_D3D9(),
3239 ES2_OPENGL(),
3240 ES2_OPENGLES());
Geoff Lange0cc2a42016-01-20 10:58:17 -05003241ANGLE_INSTANTIATE_TEST(TextureLimitsTest, ES2_D3D11(), ES2_OPENGL(), ES2_OPENGLES());
Jamie Madillfa05f602015-05-07 13:47:11 -04003242
3243} // namespace