blob: cad628370a762395f906cfdd07e9c35b1389a330 [file] [log] [blame]
Geoff Langc287ea62016-09-16 14:46:51 -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
7// WebGLCompatibilityTest.cpp : Tests of the GL_ANGLE_webgl_compatibility extension.
8
9#include "test_utils/ANGLETest.h"
10
Geoff Lang677bb6f2017-04-05 12:40:40 -040011#include "common/mathutil.h"
Geoff Langc287ea62016-09-16 14:46:51 -040012#include "test_utils/gl_raii.h"
13
Frank Henigman146e8a12017-03-02 23:22:37 -050014namespace
15{
16
17bool ConstantColorAndAlphaBlendFunctions(GLenum first, GLenum second)
18{
19 return (first == GL_CONSTANT_COLOR || first == GL_ONE_MINUS_CONSTANT_COLOR) &&
20 (second == GL_CONSTANT_ALPHA || second == GL_ONE_MINUS_CONSTANT_ALPHA);
21}
22
23void CheckBlendFunctions(GLenum src, GLenum dst)
24{
25 if (ConstantColorAndAlphaBlendFunctions(src, dst) ||
26 ConstantColorAndAlphaBlendFunctions(dst, src))
27 {
28 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
29 }
30 else
31 {
32 ASSERT_GL_NO_ERROR();
33 }
34}
35
Geoff Lang677bb6f2017-04-05 12:40:40 -040036// Extensions that affect the ability to use floating point textures
37constexpr const char *FloatingPointTextureExtensions[] = {
38 "",
39 "GL_EXT_texture_storage",
Geoff Lang677bb6f2017-04-05 12:40:40 -040040 "GL_OES_texture_half_float",
41 "GL_OES_texture_half_float_linear",
42 "GL_EXT_color_buffer_half_float",
Geoff Lang7d4602f2017-09-13 10:45:09 -040043 "GL_OES_texture_float",
44 "GL_OES_texture_float_linear",
Geoff Lang677bb6f2017-04-05 12:40:40 -040045 "GL_EXT_color_buffer_float",
46 "GL_CHROMIUM_color_buffer_float_rgba",
47 "GL_CHROMIUM_color_buffer_float_rgb",
48};
49
Frank Henigman146e8a12017-03-02 23:22:37 -050050} // namespace
51
Geoff Langc287ea62016-09-16 14:46:51 -040052namespace angle
53{
54
55class WebGLCompatibilityTest : public ANGLETest
56{
57 protected:
58 WebGLCompatibilityTest()
59 {
60 setWindowWidth(128);
61 setWindowHeight(128);
62 setConfigRedBits(8);
63 setConfigGreenBits(8);
64 setConfigBlueBits(8);
65 setConfigAlphaBits(8);
66 setWebGLCompatibilityEnabled(true);
67 }
68
69 void SetUp() override
70 {
71 ANGLETest::SetUp();
Geoff Langc339c4e2016-11-29 10:37:36 -050072 glRequestExtensionANGLE = reinterpret_cast<PFNGLREQUESTEXTENSIONANGLEPROC>(
73 eglGetProcAddress("glRequestExtensionANGLE"));
Geoff Langc287ea62016-09-16 14:46:51 -040074 }
75
Geoff Lang677bb6f2017-04-05 12:40:40 -040076 template <typename T>
77 void TestFloatTextureFormat(GLenum internalFormat,
78 GLenum format,
79 GLenum type,
80 bool texturingEnabled,
81 bool linearSamplingEnabled,
82 bool renderingEnabled,
83 const T textureData[4],
84 const float floatData[4])
85 {
86 ASSERT_GL_NO_ERROR();
87
88 const std::string samplingVs =
89 "attribute vec4 position;\n"
90 "varying vec2 texcoord;\n"
91 "void main()\n"
92 "{\n"
93 " gl_Position = vec4(position.xy, 0.0, 1.0);\n"
94 " texcoord = (position.xy * 0.5) + 0.5;\n"
95 "}\n";
96
97 const std::string samplingFs =
98 "precision mediump float;\n"
99 "uniform sampler2D tex;\n"
100 "uniform vec4 subtractor;\n"
101 "varying vec2 texcoord;\n"
102 "void main()\n"
103 "{\n"
104 " vec4 color = texture2D(tex, texcoord);\n"
105 " if (abs(color.r - subtractor.r) +\n"
106 " abs(color.g - subtractor.g) +\n"
107 " abs(color.b - subtractor.b) +\n"
108 " abs(color.a - subtractor.a) < 8.0)\n"
109 " {\n"
110 " gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);\n"
111 " }\n"
112 " else\n"
113 " {\n"
114 " gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n"
115 " }\n"
116 "}\n";
117
118 ANGLE_GL_PROGRAM(samplingProgram, samplingVs, samplingFs);
119 glUseProgram(samplingProgram.get());
120
Geoff Langd84a00b2017-10-27 17:27:26 -0400121 // Need RGBA8 renderbuffers for enough precision on the readback
122 if (extensionRequestable("GL_OES_rgb8_rgba8"))
123 {
124 glRequestExtensionANGLE("GL_OES_rgb8_rgba8");
125 }
126 ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_OES_rgb8_rgba8") && getClientMajorVersion() < 3);
127 ASSERT_GL_NO_ERROR();
128
Geoff Lang677bb6f2017-04-05 12:40:40 -0400129 GLRenderbuffer rbo;
130 glBindRenderbuffer(GL_RENDERBUFFER, rbo.get());
131 glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, 1, 1);
132
133 GLFramebuffer fbo;
134 glBindFramebuffer(GL_FRAMEBUFFER, fbo.get());
135 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo.get());
136
137 GLTexture texture;
138 glBindTexture(GL_TEXTURE_2D, texture.get());
139
140 if (internalFormat == format)
141 {
142 glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, 1, 1, 0, format, type, textureData);
143 }
144 else
145 {
146 if (getClientMajorVersion() >= 3)
147 {
148 glTexStorage2D(GL_TEXTURE_2D, 1, internalFormat, 1, 1);
149 }
150 else
151 {
152 ASSERT_TRUE(extensionEnabled("GL_EXT_texture_storage"));
153 glTexStorage2DEXT(GL_TEXTURE_2D, 1, internalFormat, 1, 1);
154 }
155 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 1, 1, format, type, textureData);
156 }
157
158 if (!texturingEnabled)
159 {
160 // Depending on the entry point and client version, different errors may be generated
161 ASSERT_GLENUM_NE(GL_NO_ERROR, glGetError());
162
163 // Two errors may be generated in the glTexStorage + glTexSubImage case, clear the
164 // second error
165 glGetError();
166
167 return;
168 }
169 ASSERT_GL_NO_ERROR();
170
171 glUniform1i(glGetUniformLocation(samplingProgram.get(), "tex"), 0);
172 glUniform4fv(glGetUniformLocation(samplingProgram.get(), "subtractor"), 1, floatData);
173
174 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
175 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
176 drawQuad(samplingProgram.get(), "position", 0.5f, 1.0f, true);
177 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
178
179 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
180 drawQuad(samplingProgram.get(), "position", 0.5f, 1.0f, true);
181
182 if (linearSamplingEnabled)
183 {
184 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
185 }
186 else
187 {
188 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red);
189 }
190
191 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture.get(),
192 0);
193 glBindTexture(GL_TEXTURE_2D, 0);
194 if (!renderingEnabled)
195 {
196 EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT,
197 glCheckFramebufferStatus(GL_FRAMEBUFFER));
198 return;
199 }
200 ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
201
202 const std::string renderingVs =
203 "attribute vec4 position;\n"
204 "void main()\n"
205 "{\n"
206 " gl_Position = vec4(position.xy, 0.0, 1.0);\n"
207 "}\n";
208
209 const std::string renderingFs =
210 "precision mediump float;\n"
211 "uniform vec4 writeValue;\n"
212 "void main()\n"
213 "{\n"
214 " gl_FragColor = writeValue;\n"
215 "}\n";
216
217 ANGLE_GL_PROGRAM(renderingProgram, renderingVs, renderingFs);
218 glUseProgram(renderingProgram.get());
219
220 glUniform4fv(glGetUniformLocation(renderingProgram.get(), "writeValue"), 1, floatData);
221
222 drawQuad(renderingProgram.get(), "position", 0.5f, 1.0f, true);
223
224 EXPECT_PIXEL_COLOR32F_NEAR(
225 0, 0, GLColor32F(floatData[0], floatData[1], floatData[2], floatData[3]), 1.0f);
226 }
227
Jamie Madillcad97ee2017-02-02 18:52:44 -0500228 // Called from RenderingFeedbackLoopWithDrawBuffersEXT.
229 void drawBuffersEXTFeedbackLoop(GLuint program,
230 const std::array<GLenum, 2> &drawBuffers,
231 GLenum expectedError);
232
Jamie Madill07be8bf2017-02-02 19:59:57 -0500233 // Called from RenderingFeedbackLoopWithDrawBuffers.
234 void drawBuffersFeedbackLoop(GLuint program,
235 const std::array<GLenum, 2> &drawBuffers,
236 GLenum expectedError);
237
Bryan Bernhart (Intel Americas Inc)2a357412017-09-05 10:42:47 -0700238 // Called from InvalidTextureFormat
239 void validateTexImageExtensionFormat(GLenum format, const std::string &extName);
240
Geoff Langc339c4e2016-11-29 10:37:36 -0500241 PFNGLREQUESTEXTENSIONANGLEPROC glRequestExtensionANGLE = nullptr;
Geoff Langc287ea62016-09-16 14:46:51 -0400242};
243
Corentin Wallezfd456442016-12-21 17:57:00 -0500244class WebGL2CompatibilityTest : public WebGLCompatibilityTest
245{
246};
247
Geoff Langc287ea62016-09-16 14:46:51 -0400248// Context creation would fail if EGL_ANGLE_create_context_webgl_compatibility was not available so
249// the GL extension should always be present
250TEST_P(WebGLCompatibilityTest, ExtensionStringExposed)
251{
252 EXPECT_TRUE(extensionEnabled("GL_ANGLE_webgl_compatibility"));
253}
254
255// Verify that all extension entry points are available
256TEST_P(WebGLCompatibilityTest, EntryPoints)
257{
Geoff Langc339c4e2016-11-29 10:37:36 -0500258 if (extensionEnabled("GL_ANGLE_request_extension"))
Geoff Langc287ea62016-09-16 14:46:51 -0400259 {
Geoff Langc339c4e2016-11-29 10:37:36 -0500260 EXPECT_NE(nullptr, eglGetProcAddress("glRequestExtensionANGLE"));
Geoff Langc287ea62016-09-16 14:46:51 -0400261 }
262}
263
264// WebGL 1 allows GL_DEPTH_STENCIL_ATTACHMENT as a valid binding point. Make sure it is usable,
265// even in ES2 contexts.
266TEST_P(WebGLCompatibilityTest, DepthStencilBindingPoint)
267{
268 GLRenderbuffer renderbuffer;
269 glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer.get());
270 glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 32, 32);
271
272 GLFramebuffer framebuffer;
273 glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.get());
274 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER,
275 renderbuffer.get());
276
277 EXPECT_GL_NO_ERROR();
278}
279
280// Test that attempting to enable an extension that doesn't exist generates GL_INVALID_OPERATION
281TEST_P(WebGLCompatibilityTest, EnableExtensionValidation)
282{
Geoff Langc339c4e2016-11-29 10:37:36 -0500283 glRequestExtensionANGLE("invalid_extension_string");
Geoff Langc287ea62016-09-16 14:46:51 -0400284 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
285}
286
287// Test enabling the GL_OES_element_index_uint extension
288TEST_P(WebGLCompatibilityTest, EnableExtensionUintIndices)
289{
290 if (getClientMajorVersion() != 2)
291 {
292 // This test only works on ES2 where uint indices are not available by default
293 return;
294 }
295
296 EXPECT_FALSE(extensionEnabled("GL_OES_element_index_uint"));
297
298 GLBuffer indexBuffer;
299 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer.get());
300
301 GLuint data[] = {0, 1, 2, 1, 3, 2};
302 glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(data), data, GL_STATIC_DRAW);
303
304 ANGLE_GL_PROGRAM(program, "void main() { gl_Position = vec4(0, 0, 0, 1); }",
305 "void main() { gl_FragColor = vec4(0, 1, 0, 1); }")
306 glUseProgram(program.get());
307
Jamie Madille7b96342017-06-23 15:06:08 -0400308 glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, nullptr);
Geoff Langc287ea62016-09-16 14:46:51 -0400309 EXPECT_GL_ERROR(GL_INVALID_ENUM);
310
Geoff Langc339c4e2016-11-29 10:37:36 -0500311 if (extensionRequestable("GL_OES_element_index_uint"))
Geoff Langc287ea62016-09-16 14:46:51 -0400312 {
Geoff Langc339c4e2016-11-29 10:37:36 -0500313 glRequestExtensionANGLE("GL_OES_element_index_uint");
Geoff Langc287ea62016-09-16 14:46:51 -0400314 EXPECT_GL_NO_ERROR();
315 EXPECT_TRUE(extensionEnabled("GL_OES_element_index_uint"));
316
Jamie Madille7b96342017-06-23 15:06:08 -0400317 glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, nullptr);
Geoff Langc287ea62016-09-16 14:46:51 -0400318 EXPECT_GL_NO_ERROR();
319 }
320}
321
Geoff Langff5c63e2017-04-12 15:26:54 -0400322// Test enabling the GL_OES_standard_derivatives extension
323TEST_P(WebGLCompatibilityTest, EnableExtensionStandardDerivitives)
324{
325 EXPECT_FALSE(extensionEnabled("GL_OES_standard_derivatives"));
326
327 const std::string source =
328 "#extension GL_OES_standard_derivatives : require\n"
329 "void main() { gl_FragColor = vec4(dFdx(vec2(1.0, 1.0)).x, 1, 0, 1); }\n";
330 ASSERT_EQ(0u, CompileShader(GL_FRAGMENT_SHADER, source));
331
332 if (extensionRequestable("GL_OES_standard_derivatives"))
333 {
334 glRequestExtensionANGLE("GL_OES_standard_derivatives");
335 EXPECT_GL_NO_ERROR();
336 EXPECT_TRUE(extensionEnabled("GL_OES_standard_derivatives"));
337
338 GLuint shader = CompileShader(GL_FRAGMENT_SHADER, source);
339 ASSERT_NE(0u, shader);
340 glDeleteShader(shader);
341 }
342}
343
344// Test enabling the GL_EXT_shader_texture_lod extension
345TEST_P(WebGLCompatibilityTest, EnableExtensionTextureLOD)
346{
347 EXPECT_FALSE(extensionEnabled("GL_EXT_shader_texture_lod"));
348
349 const std::string source =
350 "#extension GL_EXT_shader_texture_lod : require\n"
351 "uniform sampler2D u_texture;\n"
352 "void main() {\n"
353 " gl_FragColor = texture2DGradEXT(u_texture, vec2(0.0, 0.0), vec2(0.0, 0.0), vec2(0.0, "
354 "0.0));\n"
355 "}\n";
356 ASSERT_EQ(0u, CompileShader(GL_FRAGMENT_SHADER, source));
357
358 if (extensionRequestable("GL_EXT_shader_texture_lod"))
359 {
360 glRequestExtensionANGLE("GL_EXT_shader_texture_lod");
361 EXPECT_GL_NO_ERROR();
362 EXPECT_TRUE(extensionEnabled("GL_EXT_shader_texture_lod"));
363
364 GLuint shader = CompileShader(GL_FRAGMENT_SHADER, source);
365 ASSERT_NE(0u, shader);
366 glDeleteShader(shader);
367 }
368}
369
370// Test enabling the GL_EXT_frag_depth extension
371TEST_P(WebGLCompatibilityTest, EnableExtensionFragDepth)
372{
373 EXPECT_FALSE(extensionEnabled("GL_EXT_frag_depth"));
374
375 const std::string source =
376 "#extension GL_EXT_frag_depth : require\n"
377 "void main() {\n"
378 " gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);\n"
379 " gl_FragDepthEXT = 1.0;\n"
380 "}\n";
381 ASSERT_EQ(0u, CompileShader(GL_FRAGMENT_SHADER, source));
382
383 if (extensionRequestable("GL_EXT_frag_depth"))
384 {
385 glRequestExtensionANGLE("GL_EXT_frag_depth");
386 EXPECT_GL_NO_ERROR();
387 EXPECT_TRUE(extensionEnabled("GL_EXT_frag_depth"));
388
389 GLuint shader = CompileShader(GL_FRAGMENT_SHADER, source);
390 ASSERT_NE(0u, shader);
391 glDeleteShader(shader);
392 }
393}
394
Geoff Langd7d526a2017-02-21 16:48:43 -0500395// Test enabling the GL_EXT_texture_filter_anisotropic extension
396TEST_P(WebGLCompatibilityTest, EnableExtensionTextureFilterAnisotropic)
397{
398 EXPECT_FALSE(extensionEnabled("GL_EXT_texture_filter_anisotropic"));
399
400 GLfloat maxAnisotropy = 0.0f;
401 glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maxAnisotropy);
402 EXPECT_GL_ERROR(GL_INVALID_ENUM);
403
404 GLTexture texture;
405 glBindTexture(GL_TEXTURE_2D, texture.get());
406 ASSERT_GL_NO_ERROR();
407
408 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0f);
409 EXPECT_GL_ERROR(GL_INVALID_ENUM);
410
411 GLfloat currentAnisotropy = 0.0f;
412 glGetTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, &currentAnisotropy);
413 EXPECT_GL_ERROR(GL_INVALID_ENUM);
414
415 if (extensionRequestable("GL_EXT_texture_filter_anisotropic"))
416 {
417 glRequestExtensionANGLE("GL_EXT_texture_filter_anisotropic");
418 EXPECT_GL_NO_ERROR();
419 EXPECT_TRUE(extensionEnabled("GL_EXT_texture_filter_anisotropic"));
420
421 glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maxAnisotropy);
422 ASSERT_GL_NO_ERROR();
423 EXPECT_GE(maxAnisotropy, 2.0f);
424
425 glGetTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, &currentAnisotropy);
426 ASSERT_GL_NO_ERROR();
427 EXPECT_EQ(1.0f, currentAnisotropy);
428
429 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 2.0f);
430 ASSERT_GL_NO_ERROR();
431 }
432}
433
Bryan Bernhart87c182e2016-11-02 11:23:22 -0700434// Verify that shaders are of a compatible spec when the extension is enabled.
435TEST_P(WebGLCompatibilityTest, ExtensionCompilerSpec)
436{
437 EXPECT_TRUE(extensionEnabled("GL_ANGLE_webgl_compatibility"));
438
439 // Use of reserved _webgl prefix should fail when the shader specification is for WebGL.
440 const std::string &vert =
441 "struct Foo {\n"
442 " int _webgl_bar;\n"
443 "};\n"
444 "void main()\n"
445 "{\n"
446 " Foo foo = Foo(1);\n"
447 "}";
448
449 // Default fragement shader.
450 const std::string &frag =
451 "void main()\n"
452 "{\n"
453 " gl_FragColor = vec4(1.0,0.0,0.0,1.0);\n"
454 "}";
455
456 GLuint program = CompileProgram(vert, frag);
457 EXPECT_EQ(0u, program);
458 glDeleteProgram(program);
459}
460
Geoff Lang3fab7632017-09-26 15:45:54 -0400461// Test enabling the GL_NV_pixel_buffer_object extension
462TEST_P(WebGLCompatibilityTest, EnablePixelBufferObjectExtensions)
463{
464 EXPECT_FALSE(extensionEnabled("GL_NV_pixel_buffer_object"));
465 EXPECT_FALSE(extensionEnabled("GL_OES_mapbuffer"));
466 EXPECT_FALSE(extensionEnabled("GL_EXT_map_buffer_range"));
467
468 // These extensions become core in in ES3/WebGL2.
469 ANGLE_SKIP_TEST_IF(getClientMajorVersion() >= 3);
470
471 GLBuffer buffer;
472 glBindBuffer(GL_PIXEL_PACK_BUFFER, buffer);
473 EXPECT_GL_ERROR(GL_INVALID_ENUM);
474
475 if (extensionRequestable("GL_NV_pixel_buffer_object"))
476 {
477 glRequestExtensionANGLE("GL_NV_pixel_buffer_object");
478 EXPECT_GL_NO_ERROR();
479
480 glBindBuffer(GL_PIXEL_PACK_BUFFER, buffer);
481 EXPECT_GL_NO_ERROR();
482
483 glBufferData(GL_PIXEL_PACK_BUFFER, 4, nullptr, GL_STATIC_DRAW);
484 glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
485 EXPECT_GL_NO_ERROR();
486 }
487}
488
489// Test enabling the GL_OES_mapbuffer and GL_EXT_map_buffer_range extensions
490TEST_P(WebGLCompatibilityTest, EnableMapBufferExtensions)
491{
492 EXPECT_FALSE(extensionEnabled("GL_OES_mapbuffer"));
493 EXPECT_FALSE(extensionEnabled("GL_EXT_map_buffer_range"));
494
495 // These extensions become core in in ES3/WebGL2.
496 ANGLE_SKIP_TEST_IF(getClientMajorVersion() >= 3);
497
498 GLBuffer buffer;
499 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffer);
500 glBufferData(GL_ELEMENT_ARRAY_BUFFER, 4, nullptr, GL_STATIC_DRAW);
501
502 glMapBufferOES(GL_ELEMENT_ARRAY_BUFFER, GL_WRITE_ONLY_OES);
503 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
504
505 glMapBufferRangeEXT(GL_ELEMENT_ARRAY_BUFFER, 0, 4, GL_MAP_WRITE_BIT);
506 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
507
508 GLint access = 0;
509 glGetBufferParameteriv(GL_ELEMENT_ARRAY_BUFFER, GL_BUFFER_ACCESS_OES, &access);
510 EXPECT_GL_ERROR(GL_INVALID_ENUM);
511
512 if (extensionRequestable("GL_OES_mapbuffer"))
513 {
514 glRequestExtensionANGLE("GL_OES_mapbuffer");
515 EXPECT_GL_NO_ERROR();
516
517 glMapBufferOES(GL_ELEMENT_ARRAY_BUFFER, GL_WRITE_ONLY_OES);
518 glUnmapBufferOES(GL_ELEMENT_ARRAY_BUFFER);
519 glGetBufferParameteriv(GL_ELEMENT_ARRAY_BUFFER, GL_BUFFER_ACCESS_OES, &access);
520 EXPECT_GL_NO_ERROR();
521 }
522
523 if (extensionRequestable("GL_EXT_map_buffer_range"))
524 {
525 glRequestExtensionANGLE("GL_EXT_map_buffer_range");
526 EXPECT_GL_NO_ERROR();
527
528 glMapBufferRangeEXT(GL_ELEMENT_ARRAY_BUFFER, 0, 4, GL_MAP_WRITE_BIT);
529 glUnmapBufferOES(GL_ELEMENT_ARRAY_BUFFER);
530 glGetBufferParameteriv(GL_ELEMENT_ARRAY_BUFFER, GL_BUFFER_ACCESS_OES, &access);
531 EXPECT_GL_NO_ERROR();
532 }
533}
534
Geoff Lang8c7133c2017-09-26 17:31:10 -0400535// Test enabling the GL_OES_fbo_render_mipmap extension
536TEST_P(WebGLCompatibilityTest, EnableRenderMipmapExtension)
537{
538 EXPECT_FALSE(extensionEnabled("GL_OES_fbo_render_mipmap"));
539
540 // This extensions become core in in ES3/WebGL2.
541 ANGLE_SKIP_TEST_IF(getClientMajorVersion() >= 3);
542
543 GLTexture texture;
544 glBindTexture(GL_TEXTURE_2D, texture);
545 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
546 glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
547
548 GLFramebuffer fbo;
549 glBindFramebuffer(GL_FRAMEBUFFER, fbo);
550 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
551 EXPECT_GL_NO_ERROR();
552
553 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 1);
554 EXPECT_GL_ERROR(GL_INVALID_VALUE);
555
556 if (extensionRequestable("GL_OES_fbo_render_mipmap"))
557 {
558 glRequestExtensionANGLE("GL_OES_fbo_render_mipmap");
559 EXPECT_GL_NO_ERROR();
560
561 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 1);
562 EXPECT_GL_NO_ERROR();
563 }
564}
565
Geoff Lang50cac572017-09-26 17:37:43 -0400566// Test enabling the GL_EXT_blend_minmax extension
567TEST_P(WebGLCompatibilityTest, EnableBlendMinMaxExtension)
568{
569 EXPECT_FALSE(extensionEnabled("GL_EXT_blend_minmax"));
570
571 // This extensions become core in in ES3/WebGL2.
572 ANGLE_SKIP_TEST_IF(getClientMajorVersion() >= 3);
573
574 glBlendEquation(GL_MIN);
575 EXPECT_GL_ERROR(GL_INVALID_ENUM);
576
577 glBlendEquation(GL_MAX);
578 EXPECT_GL_ERROR(GL_INVALID_ENUM);
579
580 if (extensionRequestable("GL_EXT_blend_minmax"))
581 {
582 glRequestExtensionANGLE("GL_EXT_blend_minmax");
583 EXPECT_GL_NO_ERROR();
584
585 glBlendEquation(GL_MIN);
586 glBlendEquation(GL_MAX);
587 EXPECT_GL_NO_ERROR();
588 }
589}
590
Geoff Lang8c5b31c2017-09-26 18:07:44 -0400591// Test enabling the query extensions
592TEST_P(WebGLCompatibilityTest, EnableQueryExtensions)
593{
594 EXPECT_FALSE(extensionEnabled("GL_EXT_occlusion_query_boolean"));
595 EXPECT_FALSE(extensionEnabled("GL_EXT_disjoint_timer_query"));
596 EXPECT_FALSE(extensionEnabled("GL_CHROMIUM_sync_query"));
597
598 // This extensions become core in in ES3/WebGL2.
599 ANGLE_SKIP_TEST_IF(getClientMajorVersion() >= 3);
600
601 GLQueryEXT badQuery;
602
603 glBeginQueryEXT(GL_ANY_SAMPLES_PASSED_EXT, badQuery);
604 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
605
606 glBeginQueryEXT(GL_ANY_SAMPLES_PASSED_CONSERVATIVE, badQuery);
607 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
608
609 glBeginQueryEXT(GL_TIME_ELAPSED_EXT, badQuery);
610 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
611
612 glQueryCounterEXT(GL_TIMESTAMP_EXT, badQuery);
613 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
614
615 glBeginQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM, badQuery);
616 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
617
618 if (extensionRequestable("GL_EXT_occlusion_query_boolean"))
619 {
620 glRequestExtensionANGLE("GL_EXT_occlusion_query_boolean");
621 EXPECT_GL_NO_ERROR();
622
623 GLQueryEXT query;
624 glBeginQueryEXT(GL_ANY_SAMPLES_PASSED_EXT, query);
625 glEndQueryEXT(GL_ANY_SAMPLES_PASSED_EXT);
626 EXPECT_GL_NO_ERROR();
627 }
628
629 if (extensionRequestable("GL_EXT_disjoint_timer_query"))
630 {
631 glRequestExtensionANGLE("GL_EXT_disjoint_timer_query");
632 EXPECT_GL_NO_ERROR();
633
634 GLQueryEXT query1;
635 glBeginQueryEXT(GL_TIME_ELAPSED_EXT, query1);
636 glEndQueryEXT(GL_TIME_ELAPSED_EXT);
637 EXPECT_GL_NO_ERROR();
638
639 GLQueryEXT query2;
640 glQueryCounterEXT(query2, GL_TIMESTAMP_EXT);
641 EXPECT_GL_NO_ERROR();
642 }
643
644 if (extensionRequestable("GL_CHROMIUM_sync_query"))
645 {
646 glRequestExtensionANGLE("GL_CHROMIUM_sync_query");
647 EXPECT_GL_NO_ERROR();
648
649 GLQueryEXT query;
650 glBeginQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM, query);
651 glEndQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM);
652 EXPECT_GL_NO_ERROR();
653 }
654}
655
Geoff Lang488130e2017-09-27 13:53:11 -0400656// Test enabling the GL_ANGLE_framebuffer_multisample extension
657TEST_P(WebGLCompatibilityTest, EnableFramebufferMultisampleExtension)
658{
659 EXPECT_FALSE(extensionEnabled("GL_ANGLE_framebuffer_multisample"));
660
661 // This extensions become core in in ES3/WebGL2.
662 ANGLE_SKIP_TEST_IF(getClientMajorVersion() >= 3);
663
664 GLint maxSamples = 0;
665 glGetIntegerv(GL_MAX_SAMPLES, &maxSamples);
666 EXPECT_GL_ERROR(GL_INVALID_ENUM);
667
668 GLRenderbuffer renderbuffer;
669 glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer);
670 glRenderbufferStorageMultisampleANGLE(GL_RENDERBUFFER, 1, GL_RGBA4, 1, 1);
671 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
672
673 if (extensionRequestable("GL_ANGLE_framebuffer_multisample"))
674 {
675 glRequestExtensionANGLE("GL_ANGLE_framebuffer_multisample");
676 EXPECT_GL_NO_ERROR();
677
678 glGetIntegerv(GL_MAX_SAMPLES, &maxSamples);
679 EXPECT_GL_NO_ERROR();
680
681 glRenderbufferStorageMultisampleANGLE(GL_RENDERBUFFER, maxSamples, GL_RGBA4, 1, 1);
682 EXPECT_GL_NO_ERROR();
683 }
684}
685
Geoff Lang63c5a592017-09-27 14:08:16 -0400686// Test enabling the GL_ANGLE_instanced_arrays extension
687TEST_P(WebGLCompatibilityTest, EnableInstancedArraysExtension)
688{
689 EXPECT_FALSE(extensionEnabled("GL_ANGLE_instanced_arrays"));
690
691 // This extensions become core in in ES3/WebGL2.
692 ANGLE_SKIP_TEST_IF(getClientMajorVersion() >= 3);
693
694 GLint divisor = 0;
695 glGetVertexAttribiv(0, GL_VERTEX_ATTRIB_ARRAY_DIVISOR, &divisor);
696 EXPECT_GL_ERROR(GL_INVALID_ENUM);
697
698 glVertexAttribDivisorANGLE(0, 1);
699 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
700
701 if (extensionRequestable("GL_ANGLE_instanced_arrays"))
702 {
703 glRequestExtensionANGLE("GL_ANGLE_instanced_arrays");
704 EXPECT_GL_NO_ERROR();
705
706 glGetVertexAttribiv(0, GL_VERTEX_ATTRIB_ARRAY_DIVISOR, &divisor);
707 glVertexAttribDivisorANGLE(0, 1);
708 EXPECT_GL_NO_ERROR();
709 }
710}
711
Geoff Lang000dab82017-09-27 14:27:07 -0400712// Test enabling the GL_ANGLE_pack_reverse_row_order extension
713TEST_P(WebGLCompatibilityTest, EnablePackReverseRowOrderExtension)
714{
715 EXPECT_FALSE(extensionEnabled("GL_ANGLE_pack_reverse_row_order"));
716
717 GLint result = 0;
718 glGetIntegerv(GL_PACK_REVERSE_ROW_ORDER_ANGLE, &result);
719 EXPECT_GL_ERROR(GL_INVALID_ENUM);
720
721 glPixelStorei(GL_PACK_REVERSE_ROW_ORDER_ANGLE, GL_TRUE);
722 EXPECT_GL_ERROR(GL_INVALID_ENUM);
723
724 if (extensionRequestable("GL_ANGLE_pack_reverse_row_order"))
725 {
726 glRequestExtensionANGLE("GL_ANGLE_pack_reverse_row_order");
727 EXPECT_GL_NO_ERROR();
728
729 glGetIntegerv(GL_PACK_REVERSE_ROW_ORDER_ANGLE, &result);
730 glPixelStorei(GL_PACK_REVERSE_ROW_ORDER_ANGLE, GL_TRUE);
731 EXPECT_GL_NO_ERROR();
732 }
733}
734
735// Test enabling the GL_EXT_unpack_subimage extension
736TEST_P(WebGLCompatibilityTest, EnablePackUnpackSubImageExtension)
737{
738 EXPECT_FALSE(extensionEnabled("GL_EXT_unpack_subimage"));
739
740 // This extensions become core in in ES3/WebGL2.
741 ANGLE_SKIP_TEST_IF(getClientMajorVersion() >= 3);
742
743 constexpr GLenum parameters[] = {
744 GL_UNPACK_ROW_LENGTH_EXT, GL_UNPACK_SKIP_ROWS_EXT, GL_UNPACK_SKIP_PIXELS_EXT,
745 };
746
747 for (GLenum param : parameters)
748 {
749 GLint resultI = 0;
750 glGetIntegerv(param, &resultI);
751 EXPECT_GL_ERROR(GL_INVALID_ENUM);
752
753 GLfloat resultF = 0.0f;
754 glGetFloatv(param, &resultF);
755 EXPECT_GL_ERROR(GL_INVALID_ENUM);
756
757 glPixelStorei(param, 0);
758 EXPECT_GL_ERROR(GL_INVALID_ENUM);
759 }
760
761 if (extensionRequestable("GL_EXT_unpack_subimage"))
762 {
763 glRequestExtensionANGLE("GL_EXT_unpack_subimage");
764 EXPECT_GL_NO_ERROR();
765
766 for (GLenum param : parameters)
767 {
768 GLint resultI = 0;
769 glGetIntegerv(param, &resultI);
770
771 GLfloat resultF = 0.0f;
772 glGetFloatv(param, &resultF);
773
774 glPixelStorei(param, 0);
775
776 EXPECT_GL_NO_ERROR();
777 }
778 }
779}
780
781// Test enabling the GL_NV_pack_subimage extension
782TEST_P(WebGLCompatibilityTest, EnablePackPackSubImageExtension)
783{
784 EXPECT_FALSE(extensionEnabled("GL_NV_pack_subimage"));
785
786 // This extensions become core in in ES3/WebGL2.
787 ANGLE_SKIP_TEST_IF(getClientMajorVersion() >= 3);
788
789 constexpr GLenum parameters[] = {
790 GL_PACK_ROW_LENGTH, GL_PACK_SKIP_ROWS, GL_PACK_SKIP_PIXELS,
791 };
792
793 for (GLenum param : parameters)
794 {
795 GLint resultI = 0;
796 glGetIntegerv(param, &resultI);
797 EXPECT_GL_ERROR(GL_INVALID_ENUM);
798
799 GLfloat resultF = 0.0f;
800 glGetFloatv(param, &resultF);
801 EXPECT_GL_ERROR(GL_INVALID_ENUM);
802
803 glPixelStorei(param, 0);
804 EXPECT_GL_ERROR(GL_INVALID_ENUM);
805 }
806
807 if (extensionRequestable("GL_NV_pack_subimage"))
808 {
809 glRequestExtensionANGLE("GL_NV_pack_subimage");
810 EXPECT_GL_NO_ERROR();
811
812 for (GLenum param : parameters)
813 {
814 GLint resultI = 0;
815 glGetIntegerv(param, &resultI);
816
817 GLfloat resultF = 0.0f;
818 glGetFloatv(param, &resultF);
819
820 glPixelStorei(param, 0);
821
822 EXPECT_GL_NO_ERROR();
823 }
824 }
825}
826
Geoff Langd84a00b2017-10-27 17:27:26 -0400827TEST_P(WebGLCompatibilityTest, EnableRGB8RGBA8Extension)
828{
829 EXPECT_FALSE(extensionEnabled("GL_OES_rgb8_rgba8"));
830
831 // This extensions become core in in ES3/WebGL2.
832 ANGLE_SKIP_TEST_IF(getClientMajorVersion() >= 3);
833
834 GLRenderbuffer renderbuffer;
835 glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer);
836 EXPECT_GL_NO_ERROR();
837
838 glRenderbufferStorage(GL_RENDERBUFFER, GL_RGB8_OES, 1, 1);
839 EXPECT_GL_ERROR(GL_INVALID_ENUM);
840
841 glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8_OES, 1, 1);
842 EXPECT_GL_ERROR(GL_INVALID_ENUM);
843
844 if (extensionRequestable("GL_OES_rgb8_rgba8"))
845 {
846 glRequestExtensionANGLE("GL_OES_rgb8_rgba8");
847 EXPECT_GL_NO_ERROR();
848
849 EXPECT_TRUE(extensionEnabled("GL_OES_rgb8_rgba8"));
850
851 glRenderbufferStorage(GL_RENDERBUFFER, GL_RGB8_OES, 1, 1);
852 EXPECT_GL_NO_ERROR();
853
854 glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8_OES, 1, 1);
855 EXPECT_GL_NO_ERROR();
856 }
857}
858
Geoff Langa0e0aeb2017-04-12 15:06:29 -0400859// Verify that the context generates the correct error when the framebuffer attachments are
860// different sizes
Corentin Wallezc3bc9842017-10-11 15:15:59 -0400861TEST_P(WebGLCompatibilityTest, FramebufferAttachmentSizeMismatch)
Geoff Langa0e0aeb2017-04-12 15:06:29 -0400862{
863 GLFramebuffer fbo;
864 glBindFramebuffer(GL_FRAMEBUFFER, fbo);
865
866 GLTexture textures[2];
867 glBindTexture(GL_TEXTURE_2D, textures[0]);
868 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
869 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textures[0], 0);
870
871 ASSERT_GL_NO_ERROR();
872 ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
873
874 GLRenderbuffer renderbuffer;
875 glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer);
876 glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, 3, 3);
877 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, renderbuffer);
878
879 ASSERT_GL_NO_ERROR();
880 ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS,
881 glCheckFramebufferStatus(GL_FRAMEBUFFER));
882
883 if (extensionRequestable("GL_EXT_draw_buffers"))
884 {
885 glRequestExtensionANGLE("GL_EXT_draw_buffers");
886 EXPECT_GL_NO_ERROR();
887 EXPECT_TRUE(extensionEnabled("GL_EXT_draw_buffers"));
888
889 glBindTexture(GL_TEXTURE_2D, textures[1]);
890 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
891 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, textures[1], 0);
892 ASSERT_GL_NO_ERROR();
893
894 ASSERT_GL_NO_ERROR();
895 ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS,
896 glCheckFramebufferStatus(GL_FRAMEBUFFER));
897
898 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, 0);
899
900 ASSERT_GL_NO_ERROR();
901 ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
902
903 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 3, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
904
905 ASSERT_GL_NO_ERROR();
906 ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS,
907 glCheckFramebufferStatus(GL_FRAMEBUFFER));
908 }
909}
910
Corentin Wallez327411e2016-12-09 11:09:17 -0500911// Test that client-side array buffers are forbidden in WebGL mode
912TEST_P(WebGLCompatibilityTest, ForbidsClientSideArrayBuffer)
913{
914 const std::string &vert =
915 "attribute vec3 a_pos;\n"
916 "void main()\n"
917 "{\n"
918 " gl_Position = vec4(a_pos, 1.0);\n"
919 "}\n";
920
921 const std::string &frag =
922 "precision highp float;\n"
923 "void main()\n"
924 "{\n"
925 " gl_FragColor = vec4(1.0);\n"
926 "}\n";
927
928 ANGLE_GL_PROGRAM(program, vert, frag);
929
930 GLint posLocation = glGetAttribLocation(program.get(), "a_pos");
931 ASSERT_NE(-1, posLocation);
932 glUseProgram(program.get());
933
934 const auto &vertices = GetQuadVertices();
Corentin Wallezfd456442016-12-21 17:57:00 -0500935 glVertexAttribPointer(posLocation, 3, GL_FLOAT, GL_FALSE, 4, vertices.data());
Corentin Wallez327411e2016-12-09 11:09:17 -0500936 glEnableVertexAttribArray(posLocation);
937
938 ASSERT_GL_NO_ERROR();
939 glDrawArrays(GL_TRIANGLES, 0, 6);
940 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
941}
942
943// Test that client-side element array buffers are forbidden in WebGL mode
944TEST_P(WebGLCompatibilityTest, ForbidsClientSideElementBuffer)
945{
946 const std::string &vert =
947 "attribute vec3 a_pos;\n"
948 "void main()\n"
949 "{\n"
950 " gl_Position = vec4(a_pos, 1.0);\n"
951 "}\n";
952
953 const std::string &frag =
954 "precision highp float;\n"
955 "void main()\n"
956 "{\n"
957 " gl_FragColor = vec4(1.0);\n"
958 "}\n";
959
960 ANGLE_GL_PROGRAM(program, vert, frag);
961
962 GLint posLocation = glGetAttribLocation(program.get(), "a_pos");
963 ASSERT_NE(-1, posLocation);
964 glUseProgram(program.get());
965
966 const auto &vertices = GetQuadVertices();
967
968 GLBuffer vertexBuffer;
969 glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer.get());
970 glBufferData(GL_ARRAY_BUFFER, sizeof(vertices[0]) * vertices.size(), vertices.data(),
971 GL_STATIC_DRAW);
972
973 glVertexAttribPointer(posLocation, 3, GL_FLOAT, GL_FALSE, 0, 0);
974 glEnableVertexAttribArray(posLocation);
975
Corentin Wallez327411e2016-12-09 11:09:17 -0500976 ASSERT_GL_NO_ERROR();
Corentin Wallezded1b5a2017-03-09 18:58:48 -0500977
978 // Use the pointer with value of 1 for indices instead of an actual pointer because WebGL also
979 // enforces that the top bit of indices must be 0 (i.e. offset >= 0) and would generate
980 // GL_INVALID_VALUE in that case. Using a null pointer gets caught by another check.
981 glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, reinterpret_cast<const void*>(intptr_t(1)));
Corentin Wallez327411e2016-12-09 11:09:17 -0500982 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
983}
984
Corentin Wallez672f7f32017-06-15 17:42:17 -0400985// Test that client-side array buffers are forbidden even if the program doesn't use the attribute
986TEST_P(WebGLCompatibilityTest, ForbidsClientSideArrayBufferEvenNotUsedOnes)
987{
988 const std::string &vert =
989 "void main()\n"
990 "{\n"
991 " gl_Position = vec4(1.0);\n"
992 "}\n";
993
994 const std::string &frag =
995 "precision highp float;\n"
996 "void main()\n"
997 "{\n"
998 " gl_FragColor = vec4(1.0);\n"
999 "}\n";
1000
1001 ANGLE_GL_PROGRAM(program, vert, frag);
1002
1003 glUseProgram(program.get());
1004
1005 const auto &vertices = GetQuadVertices();
1006 glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 4, vertices.data());
1007 glEnableVertexAttribArray(0);
1008
1009 ASSERT_GL_NO_ERROR();
1010 glDrawArrays(GL_TRIANGLES, 0, 6);
1011 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
1012}
1013
Corentin Wallezb1d0a2552016-12-19 16:15:54 -05001014// Tests the WebGL requirement of having the same stencil mask, writemask and ref for fron and back
1015TEST_P(WebGLCompatibilityTest, RequiresSameStencilMaskAndRef)
1016{
1017 // Run the test in an FBO to make sure we have some stencil bits.
1018 GLRenderbuffer renderbuffer;
1019 glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer.get());
1020 glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 32, 32);
1021
1022 GLFramebuffer framebuffer;
1023 glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.get());
1024 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER,
1025 renderbuffer.get());
1026
1027 ANGLE_GL_PROGRAM(program, "void main() { gl_Position = vec4(0, 0, 0, 1); }",
1028 "void main() { gl_FragColor = vec4(0, 1, 0, 1); }")
1029 glUseProgram(program.get());
1030 ASSERT_GL_NO_ERROR();
1031
1032 // Having ref and mask the same for front and back is valid.
1033 glStencilMask(255);
1034 glStencilFunc(GL_ALWAYS, 0, 255);
1035 glDrawArrays(GL_TRIANGLES, 0, 6);
1036 ASSERT_GL_NO_ERROR();
1037
1038 // Having a different front - back write mask generates an error.
1039 glStencilMaskSeparate(GL_FRONT, 1);
1040 glDrawArrays(GL_TRIANGLES, 0, 6);
1041 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
1042
1043 // Setting both write masks separately to the same value is valid.
1044 glStencilMaskSeparate(GL_BACK, 1);
1045 glDrawArrays(GL_TRIANGLES, 0, 6);
1046 ASSERT_GL_NO_ERROR();
1047
1048 // Having a different stencil front - back mask generates an error
1049 glStencilFuncSeparate(GL_FRONT, GL_ALWAYS, 0, 1);
1050 glDrawArrays(GL_TRIANGLES, 0, 6);
1051 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
1052
1053 // Setting both masks separately to the same value is valid.
1054 glStencilFuncSeparate(GL_BACK, GL_ALWAYS, 0, 1);
1055 glDrawArrays(GL_TRIANGLES, 0, 6);
1056 ASSERT_GL_NO_ERROR();
1057
1058 // Having a different stencil front - back reference generates an error
1059 glStencilFuncSeparate(GL_FRONT, GL_ALWAYS, 255, 1);
1060 glDrawArrays(GL_TRIANGLES, 0, 6);
1061 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
1062
1063 // Setting both references separately to the same value is valid.
1064 glStencilFuncSeparate(GL_BACK, GL_ALWAYS, 255, 1);
1065 glDrawArrays(GL_TRIANGLES, 0, 6);
1066 ASSERT_GL_NO_ERROR();
1067
1068 // Using different stencil funcs, everything being equal is valid.
1069 glStencilFuncSeparate(GL_BACK, GL_NEVER, 255, 1);
1070 glDrawArrays(GL_TRIANGLES, 0, 6);
1071 ASSERT_GL_NO_ERROR();
1072}
1073
Corentin Wallez506fc9c2016-12-21 16:53:33 -05001074// Test that GL_FIXED is forbidden
1075TEST_P(WebGLCompatibilityTest, ForbidsGLFixed)
1076{
1077 GLBuffer buffer;
1078 glBindBuffer(GL_ARRAY_BUFFER, buffer.get());
1079 glBufferData(GL_ARRAY_BUFFER, 16, nullptr, GL_STATIC_DRAW);
1080
1081 glVertexAttribPointer(0, 1, GL_FLOAT, GL_FALSE, 0, nullptr);
1082 ASSERT_GL_NO_ERROR();
1083
1084 glVertexAttribPointer(0, 1, GL_FIXED, GL_FALSE, 0, nullptr);
1085 EXPECT_GL_ERROR(GL_INVALID_ENUM);
1086}
1087
1088// Test the WebGL limit of 255 for the attribute stride
1089TEST_P(WebGLCompatibilityTest, MaxStride)
1090{
1091 GLBuffer buffer;
1092 glBindBuffer(GL_ARRAY_BUFFER, buffer.get());
1093 glBufferData(GL_ARRAY_BUFFER, 1024, nullptr, GL_STATIC_DRAW);
1094
1095 glVertexAttribPointer(0, 1, GL_UNSIGNED_BYTE, GL_FALSE, 255, nullptr);
1096 ASSERT_GL_NO_ERROR();
1097
1098 glVertexAttribPointer(0, 1, GL_UNSIGNED_BYTE, GL_FALSE, 256, nullptr);
1099 EXPECT_GL_ERROR(GL_INVALID_VALUE);
1100}
1101
Corentin Wallezfd456442016-12-21 17:57:00 -05001102// Test the checks for OOB reads in the vertex buffers, non-instanced version
1103TEST_P(WebGLCompatibilityTest, DrawArraysBufferOutOfBoundsNonInstanced)
1104{
1105 const std::string &vert =
1106 "attribute float a_pos;\n"
1107 "void main()\n"
1108 "{\n"
1109 " gl_Position = vec4(a_pos, a_pos, a_pos, 1.0);\n"
1110 "}\n";
1111
1112 const std::string &frag =
1113 "precision highp float;\n"
1114 "void main()\n"
1115 "{\n"
1116 " gl_FragColor = vec4(1.0);\n"
1117 "}\n";
1118
1119 ANGLE_GL_PROGRAM(program, vert, frag);
Corentin Wallezfd456442016-12-21 17:57:00 -05001120 GLint posLocation = glGetAttribLocation(program.get(), "a_pos");
1121 ASSERT_NE(-1, posLocation);
1122 glUseProgram(program.get());
1123
1124 GLBuffer buffer;
1125 glBindBuffer(GL_ARRAY_BUFFER, buffer.get());
1126 glBufferData(GL_ARRAY_BUFFER, 16, nullptr, GL_STATIC_DRAW);
1127
1128 glEnableVertexAttribArray(posLocation);
1129
1130 const uint8_t* zeroOffset = nullptr;
1131
1132 // Test touching the last element is valid.
Corentin Wallez91c8de82017-10-12 16:32:44 -04001133 glVertexAttribPointer(posLocation, 1, GL_UNSIGNED_BYTE, GL_FALSE, 0, zeroOffset + 12);
Corentin Wallezfd456442016-12-21 17:57:00 -05001134 glDrawArrays(GL_POINTS, 0, 4);
1135 ASSERT_GL_NO_ERROR();
1136
1137 // Test touching the last element + 1 is invalid.
Corentin Wallez91c8de82017-10-12 16:32:44 -04001138 glVertexAttribPointer(posLocation, 1, GL_UNSIGNED_BYTE, GL_FALSE, 0, zeroOffset + 13);
Corentin Wallezfd456442016-12-21 17:57:00 -05001139 glDrawArrays(GL_POINTS, 0, 4);
1140 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
1141
1142 // Test touching the last element is valid, using a stride.
Corentin Wallez91c8de82017-10-12 16:32:44 -04001143 glVertexAttribPointer(posLocation, 1, GL_UNSIGNED_BYTE, GL_FALSE, 2, zeroOffset + 9);
Corentin Wallezfd456442016-12-21 17:57:00 -05001144 glDrawArrays(GL_POINTS, 0, 4);
1145 ASSERT_GL_NO_ERROR();
1146
1147 // Test touching the last element + 1 is invalid, using a stride.
Corentin Wallez91c8de82017-10-12 16:32:44 -04001148 glVertexAttribPointer(posLocation, 1, GL_UNSIGNED_BYTE, GL_FALSE, 2, zeroOffset + 10);
Corentin Wallezfd456442016-12-21 17:57:00 -05001149 glDrawArrays(GL_POINTS, 0, 4);
1150 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
1151
1152 // Test any offset is valid if no vertices are drawn.
Corentin Wallez91c8de82017-10-12 16:32:44 -04001153 glVertexAttribPointer(posLocation, 1, GL_UNSIGNED_BYTE, GL_FALSE, 0, zeroOffset + 32);
Corentin Wallezfd456442016-12-21 17:57:00 -05001154 glDrawArrays(GL_POINTS, 0, 0);
1155 ASSERT_GL_NO_ERROR();
Corentin Wallez91c8de82017-10-12 16:32:44 -04001156
1157 // Test a case of overflow that could give a max vertex that's negative
1158 constexpr GLint kIntMax = std::numeric_limits<GLint>::max();
1159 glVertexAttribPointer(posLocation, 1, GL_UNSIGNED_BYTE, GL_FALSE, 0, zeroOffset + 0);
1160 glDrawArrays(GL_POINTS, kIntMax, kIntMax);
1161 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
1162}
1163
1164// Test the checks for OOB reads in the vertex buffers, instanced version
1165TEST_P(WebGL2CompatibilityTest, DrawArraysBufferOutOfBoundsInstanced)
1166{
1167 const std::string &vert =
1168 "attribute float a_pos;\n"
1169 "attribute float a_w;\n"
1170 "void main()\n"
1171 "{\n"
1172 " gl_Position = vec4(a_pos, a_pos, a_pos, a_w);\n"
1173 "}\n";
1174
1175 const std::string &frag =
1176 "precision highp float;\n"
1177 "void main()\n"
1178 "{\n"
1179 " gl_FragColor = vec4(1.0);\n"
1180 "}\n";
1181
1182 ANGLE_GL_PROGRAM(program, vert, frag);
1183 GLint posLocation = glGetAttribLocation(program.get(), "a_pos");
1184 GLint wLocation = glGetAttribLocation(program.get(), "a_w");
1185 ASSERT_NE(-1, posLocation);
1186 ASSERT_NE(-1, wLocation);
1187 glUseProgram(program.get());
1188
1189 GLBuffer buffer;
1190 glBindBuffer(GL_ARRAY_BUFFER, buffer.get());
1191 glBufferData(GL_ARRAY_BUFFER, 16, nullptr, GL_STATIC_DRAW);
1192
1193 glEnableVertexAttribArray(posLocation);
1194 glVertexAttribPointer(posLocation, 1, GL_UNSIGNED_BYTE, GL_FALSE, 0, 0);
1195 glVertexAttribDivisor(posLocation, 0);
1196
1197 glEnableVertexAttribArray(wLocation);
1198 glVertexAttribDivisor(wLocation, 1);
1199
1200 const uint8_t* zeroOffset = nullptr;
1201
1202 // Test touching the last element is valid.
1203 glVertexAttribPointer(wLocation, 1, GL_UNSIGNED_BYTE, GL_FALSE, 0, zeroOffset + 12);
1204 glDrawArraysInstanced(GL_POINTS, 0, 1, 4);
1205 ASSERT_GL_NO_ERROR();
1206
1207 // Test touching the last element + 1 is invalid.
1208 glVertexAttribPointer(wLocation, 1, GL_UNSIGNED_BYTE, GL_FALSE, 0, zeroOffset + 13);
1209 glDrawArraysInstanced(GL_POINTS, 0, 1, 4);
1210 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
1211
1212 // Test touching the last element is valid, using a stride.
1213 glVertexAttribPointer(wLocation, 1, GL_UNSIGNED_BYTE, GL_FALSE, 2, zeroOffset + 9);
1214 glDrawArraysInstanced(GL_POINTS, 0, 1, 4);
1215 ASSERT_GL_NO_ERROR();
1216
1217 // Test touching the last element + 1 is invalid, using a stride.
1218 glVertexAttribPointer(wLocation, 1, GL_UNSIGNED_BYTE, GL_FALSE, 2, zeroOffset + 10);
1219 glDrawArraysInstanced(GL_POINTS, 0, 1, 4);
1220 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
1221
1222 // Test any offset is valid if no vertices are drawn.
1223 glVertexAttribPointer(wLocation, 1, GL_UNSIGNED_BYTE, GL_FALSE, 0, zeroOffset + 32);
1224 glDrawArraysInstanced(GL_POINTS, 0, 0, 1);
1225 ASSERT_GL_NO_ERROR();
1226
1227 // Test any offset is valid if no primitives are drawn.
1228 glVertexAttribPointer(wLocation, 1, GL_UNSIGNED_BYTE, GL_FALSE, 0, zeroOffset + 32);
1229 glDrawArraysInstanced(GL_POINTS, 0, 1, 0);
1230 ASSERT_GL_NO_ERROR();
1231}
1232
1233// Test the checks for OOB reads in the vertex buffers, ANGLE_instanced_arrays version
1234TEST_P(WebGLCompatibilityTest, DrawArraysBufferOutOfBoundsInstancedANGLE)
1235{
1236 ANGLE_SKIP_TEST_IF(!extensionRequestable("GL_ANGLE_instanced_arrays"));
1237 glRequestExtensionANGLE("GL_ANGLE_instanced_arrays");
1238 EXPECT_GL_NO_ERROR();
1239
1240 const std::string &vert =
1241 "attribute float a_pos;\n"
1242 "attribute float a_w;\n"
1243 "void main()\n"
1244 "{\n"
1245 " gl_Position = vec4(a_pos, a_pos, a_pos, a_w);\n"
1246 "}\n";
1247
1248 const std::string &frag =
1249 "precision highp float;\n"
1250 "void main()\n"
1251 "{\n"
1252 " gl_FragColor = vec4(1.0);\n"
1253 "}\n";
1254
1255 ANGLE_GL_PROGRAM(program, vert, frag);
1256 GLint posLocation = glGetAttribLocation(program.get(), "a_pos");
1257 GLint wLocation = glGetAttribLocation(program.get(), "a_w");
1258 ASSERT_NE(-1, posLocation);
1259 ASSERT_NE(-1, wLocation);
1260 glUseProgram(program.get());
1261
1262 GLBuffer buffer;
1263 glBindBuffer(GL_ARRAY_BUFFER, buffer.get());
1264 glBufferData(GL_ARRAY_BUFFER, 16, nullptr, GL_STATIC_DRAW);
1265
1266 glEnableVertexAttribArray(posLocation);
1267 glVertexAttribPointer(posLocation, 1, GL_UNSIGNED_BYTE, GL_FALSE, 0, 0);
1268 glVertexAttribDivisorANGLE(posLocation, 0);
1269
1270 glEnableVertexAttribArray(wLocation);
1271 glVertexAttribDivisorANGLE(wLocation, 1);
1272
1273 const uint8_t* zeroOffset = nullptr;
1274
1275 // Test touching the last element is valid.
1276 glVertexAttribPointer(wLocation, 1, GL_UNSIGNED_BYTE, GL_FALSE, 0, zeroOffset + 12);
1277 glDrawArraysInstancedANGLE(GL_POINTS, 0, 1, 4);
1278 ASSERT_GL_NO_ERROR();
1279
1280 // Test touching the last element + 1 is invalid.
1281 glVertexAttribPointer(wLocation, 1, GL_UNSIGNED_BYTE, GL_FALSE, 0, zeroOffset + 13);
1282 glDrawArraysInstancedANGLE(GL_POINTS, 0, 1, 4);
1283 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
1284
1285 // Test touching the last element is valid, using a stride.
1286 glVertexAttribPointer(wLocation, 1, GL_UNSIGNED_BYTE, GL_FALSE, 2, zeroOffset + 9);
1287 glDrawArraysInstancedANGLE(GL_POINTS, 0, 1, 4);
1288 ASSERT_GL_NO_ERROR();
1289
1290 // Test touching the last element + 1 is invalid, using a stride.
1291 glVertexAttribPointer(wLocation, 1, GL_UNSIGNED_BYTE, GL_FALSE, 2, zeroOffset + 10);
1292 glDrawArraysInstancedANGLE(GL_POINTS, 0, 1, 4);
1293 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
1294
1295 // Test any offset is valid if no vertices are drawn.
1296 glVertexAttribPointer(wLocation, 1, GL_UNSIGNED_BYTE, GL_FALSE, 0, zeroOffset + 32);
1297 glDrawArraysInstancedANGLE(GL_POINTS, 0, 0, 1);
1298 ASSERT_GL_NO_ERROR();
1299
1300 // Test any offset is valid if no primitives are drawn.
1301 glVertexAttribPointer(wLocation, 1, GL_UNSIGNED_BYTE, GL_FALSE, 0, zeroOffset + 32);
1302 glDrawArraysInstancedANGLE(GL_POINTS, 0, 1, 0);
1303 ASSERT_GL_NO_ERROR();
Corentin Wallezfd456442016-12-21 17:57:00 -05001304}
1305
Corentin Wallez0844f2d2017-01-31 17:02:59 -05001306// Test the checks for OOB reads in the index buffer
1307TEST_P(WebGLCompatibilityTest, DrawElementsBufferOutOfBoundsInIndexBuffer)
Geoff Lang5f319a42017-01-09 16:49:19 -05001308{
Corentin Wallez0844f2d2017-01-31 17:02:59 -05001309 const std::string &vert =
1310 "attribute float a_pos;\n"
1311 "void main()\n"
1312 "{\n"
1313 " gl_Position = vec4(a_pos, a_pos, a_pos, 1.0);\n"
1314 "}\n";
Geoff Lang5f319a42017-01-09 16:49:19 -05001315
Corentin Wallez0844f2d2017-01-31 17:02:59 -05001316 const std::string &frag =
1317 "precision highp float;\n"
1318 "void main()\n"
1319 "{\n"
1320 " gl_FragColor = vec4(1.0);\n"
1321 "}\n";
1322
1323 ANGLE_GL_PROGRAM(program, vert, frag);
Corentin Wallez0844f2d2017-01-31 17:02:59 -05001324 GLint posLocation = glGetAttribLocation(program.get(), "a_pos");
1325 ASSERT_NE(-1, posLocation);
1326 glUseProgram(program.get());
1327
1328 GLBuffer vertexBuffer;
1329 glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer.get());
1330 glBufferData(GL_ARRAY_BUFFER, 16, nullptr, GL_STATIC_DRAW);
1331
1332 glEnableVertexAttribArray(posLocation);
Corentin Wallez91c8de82017-10-12 16:32:44 -04001333 glVertexAttribPointer(posLocation, 1, GL_UNSIGNED_BYTE, GL_FALSE, 0, nullptr);
Corentin Wallez0844f2d2017-01-31 17:02:59 -05001334
1335 const uint8_t *zeroOffset = nullptr;
1336 const uint8_t zeroIndices[] = {0, 0, 0, 0, 0, 0, 0, 0};
1337
Corentin Wallez0844f2d2017-01-31 17:02:59 -05001338 GLBuffer indexBuffer;
1339 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer.get());
1340 glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(zeroIndices), zeroIndices, GL_STATIC_DRAW);
Geoff Lang5f319a42017-01-09 16:49:19 -05001341 ASSERT_GL_NO_ERROR();
1342
Corentin Wallez0844f2d2017-01-31 17:02:59 -05001343 // Test touching the last index is valid
1344 glDrawElements(GL_POINTS, 4, GL_UNSIGNED_BYTE, zeroOffset + 4);
1345 ASSERT_GL_NO_ERROR();
Geoff Lang5f319a42017-01-09 16:49:19 -05001346
Corentin Wallez0844f2d2017-01-31 17:02:59 -05001347 // Test touching the last + 1 element is invalid
1348 glDrawElements(GL_POINTS, 4, GL_UNSIGNED_BYTE, zeroOffset + 5);
1349 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
Geoff Lang5f319a42017-01-09 16:49:19 -05001350
Corentin Wallez0844f2d2017-01-31 17:02:59 -05001351 // Test any offset if valid if count is zero
1352 glDrawElements(GL_POINTS, 0, GL_UNSIGNED_BYTE, zeroOffset + 42);
1353 ASSERT_GL_NO_ERROR();
Corentin Wallezfe9306a2017-02-01 17:41:05 -05001354
1355 // Test touching the first index is valid
1356 glDrawElements(GL_POINTS, 4, GL_UNSIGNED_BYTE, zeroOffset + 4);
1357 ASSERT_GL_NO_ERROR();
1358
1359 // Test touching the first - 1 index is invalid
1360 // The error ha been specified to be INVALID_VALUE instead of INVALID_OPERATION because it was
1361 // the historic behavior of WebGL implementations
1362 glDrawElements(GL_POINTS, 4, GL_UNSIGNED_BYTE, zeroOffset - 1);
1363 EXPECT_GL_ERROR(GL_INVALID_VALUE);
Geoff Lang5f319a42017-01-09 16:49:19 -05001364}
1365
Corentin Wallez91c8de82017-10-12 16:32:44 -04001366// Test the checks for OOB in vertex buffers caused by indices, non-instanced version
Corentin Wallezc3bc9842017-10-11 15:15:59 -04001367TEST_P(WebGLCompatibilityTest, DrawElementsBufferOutOfBoundsInVertexBuffer)
1368{
1369 const std::string &vert =
1370 "attribute float a_pos;\n"
1371 "void main()\n"
1372 "{\n"
1373 " gl_Position = vec4(a_pos, a_pos, a_pos, 1.0);\n"
1374 "}\n";
1375
1376 const std::string &frag =
1377 "precision highp float;\n"
1378 "void main()\n"
1379 "{\n"
1380 " gl_FragColor = vec4(1.0);\n"
1381 "}\n";
1382
1383 ANGLE_GL_PROGRAM(program, vert, frag);
Corentin Wallezc3bc9842017-10-11 15:15:59 -04001384 GLint posLocation = glGetAttribLocation(program.get(), "a_pos");
1385 ASSERT_NE(-1, posLocation);
1386 glUseProgram(program.get());
1387
1388 GLBuffer vertexBuffer;
1389 glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer.get());
1390 glBufferData(GL_ARRAY_BUFFER, 8, nullptr, GL_STATIC_DRAW);
1391
1392 glEnableVertexAttribArray(posLocation);
Corentin Wallez91c8de82017-10-12 16:32:44 -04001393 glVertexAttribPointer(posLocation, 1, GL_UNSIGNED_BYTE, GL_FALSE, 0, nullptr);
Corentin Wallezc3bc9842017-10-11 15:15:59 -04001394
1395 const uint8_t *zeroOffset = nullptr;
1396 const uint8_t testIndices[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 255};
1397
Corentin Wallezc3bc9842017-10-11 15:15:59 -04001398 GLBuffer indexBuffer;
1399 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer.get());
1400 glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(testIndices), testIndices, GL_STATIC_DRAW);
1401 ASSERT_GL_NO_ERROR();
1402
1403 // Test touching the end of the vertex buffer is valid
1404 glDrawElements(GL_POINTS, 1, GL_UNSIGNED_BYTE, zeroOffset + 7);
1405 ASSERT_GL_NO_ERROR();
1406
1407 // Test touching just after the end of the vertex buffer is invalid
1408 glDrawElements(GL_POINTS, 1, GL_UNSIGNED_BYTE, zeroOffset + 8);
1409 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
1410
1411 // Test touching the whole vertex buffer is valid
1412 glDrawElements(GL_POINTS, 8, GL_UNSIGNED_BYTE, zeroOffset + 0);
1413 ASSERT_GL_NO_ERROR();
1414
1415 // Test an index that would be negative
1416 glDrawElements(GL_POINTS, 1, GL_UNSIGNED_BYTE, zeroOffset + 9);
1417 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
1418}
1419
Frank Henigman6137ddc2017-02-10 18:55:07 -05001420// Test depth range with 'near' more or less than 'far.'
1421TEST_P(WebGLCompatibilityTest, DepthRange)
1422{
1423 glDepthRangef(0, 1);
1424 ASSERT_GL_NO_ERROR();
1425
1426 glDepthRangef(.5, .5);
1427 ASSERT_GL_NO_ERROR();
1428
1429 glDepthRangef(1, 0);
1430 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
1431}
1432
Frank Henigman146e8a12017-03-02 23:22:37 -05001433// Test all blend function combinations.
1434// In WebGL it is invalid to combine constant color with constant alpha.
1435TEST_P(WebGLCompatibilityTest, BlendWithConstantColor)
1436{
1437 constexpr GLenum srcFunc[] = {
1438 GL_ZERO,
1439 GL_ONE,
1440 GL_SRC_COLOR,
1441 GL_ONE_MINUS_SRC_COLOR,
1442 GL_DST_COLOR,
1443 GL_ONE_MINUS_DST_COLOR,
1444 GL_SRC_ALPHA,
1445 GL_ONE_MINUS_SRC_ALPHA,
1446 GL_DST_ALPHA,
1447 GL_ONE_MINUS_DST_ALPHA,
1448 GL_CONSTANT_COLOR,
1449 GL_ONE_MINUS_CONSTANT_COLOR,
1450 GL_CONSTANT_ALPHA,
1451 GL_ONE_MINUS_CONSTANT_ALPHA,
1452 GL_SRC_ALPHA_SATURATE,
1453 };
1454
1455 constexpr GLenum dstFunc[] = {
1456 GL_ZERO, GL_ONE,
1457 GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR,
1458 GL_DST_COLOR, GL_ONE_MINUS_DST_COLOR,
1459 GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA,
1460 GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA,
1461 GL_CONSTANT_COLOR, GL_ONE_MINUS_CONSTANT_COLOR,
1462 GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA,
1463 };
1464
1465 for (GLenum src : srcFunc)
1466 {
1467 for (GLenum dst : dstFunc)
1468 {
1469 glBlendFunc(src, dst);
1470 CheckBlendFunctions(src, dst);
1471 glBlendFuncSeparate(src, dst, GL_ONE, GL_ONE);
1472 CheckBlendFunctions(src, dst);
1473 }
1474 }
1475}
1476
Geoff Langfc32e8b2017-05-31 14:16:59 -04001477// Test that binding/querying uniforms and attributes with invalid names generates errors
1478TEST_P(WebGLCompatibilityTest, InvalidAttributeAndUniformNames)
1479{
1480 const std::string validAttribName =
1481 "abcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
1482 const std::string validUniformName =
1483 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_1234567890";
Geoff Langa71a98e2017-06-19 15:15:00 -04001484 std::vector<char> invalidSet = {'"', '$', '`', '@', '\''};
1485 if (getClientMajorVersion() < 3)
1486 {
1487 invalidSet.push_back('\\');
1488 }
Geoff Langfc32e8b2017-05-31 14:16:59 -04001489
1490 std::string vert = "attribute float ";
1491 vert += validAttribName;
1492 vert +=
1493 ";\n"
1494 "void main()\n"
1495 "{\n"
1496 " gl_Position = vec4(1.0);\n"
1497 "}\n";
1498
1499 std::string frag =
1500 "precision highp float;\n"
1501 "uniform vec4 ";
1502 frag += validUniformName;
Geoff Langcab92ee2017-07-19 17:32:07 -04001503 // Insert illegal characters into comments
Geoff Langfc32e8b2017-05-31 14:16:59 -04001504 frag +=
1505 ";\n"
Geoff Langcab92ee2017-07-19 17:32:07 -04001506 " // $ \" @ /*\n"
Geoff Langfc32e8b2017-05-31 14:16:59 -04001507 "void main()\n"
Geoff Langcab92ee2017-07-19 17:32:07 -04001508 "{/*\n"
1509 " ` @ $\n"
1510 " */gl_FragColor = vec4(1.0);\n"
Geoff Langfc32e8b2017-05-31 14:16:59 -04001511 "}\n";
1512
1513 ANGLE_GL_PROGRAM(program, vert, frag);
1514 EXPECT_GL_NO_ERROR();
1515
1516 for (char invalidChar : invalidSet)
1517 {
1518 std::string invalidName = validAttribName + invalidChar;
1519 glGetAttribLocation(program, invalidName.c_str());
1520 EXPECT_GL_ERROR(GL_INVALID_VALUE)
1521 << "glGetAttribLocation unexpectedly succeeded for name \"" << invalidName << "\".";
1522
1523 glBindAttribLocation(program, 0, invalidName.c_str());
1524 EXPECT_GL_ERROR(GL_INVALID_VALUE)
1525 << "glBindAttribLocation unexpectedly succeeded for name \"" << invalidName << "\".";
1526 }
1527
1528 for (char invalidChar : invalidSet)
1529 {
1530 std::string invalidName = validUniformName + invalidChar;
1531 glGetUniformLocation(program, invalidName.c_str());
1532 EXPECT_GL_ERROR(GL_INVALID_VALUE)
1533 << "glGetUniformLocation unexpectedly succeeded for name \"" << invalidName << "\".";
1534 }
1535
1536 for (char invalidChar : invalidSet)
1537 {
1538 std::string invalidAttribName = validAttribName + invalidChar;
1539 const char *invalidVert[] = {
1540 "attribute float ",
1541 invalidAttribName.c_str(),
1542 ";\n",
1543 "void main()\n",
1544 "{\n",
1545 " gl_Position = vec4(1.0);\n",
1546 "}\n",
1547 };
1548
1549 GLuint shader = glCreateShader(GL_VERTEX_SHADER);
1550 glShaderSource(shader, static_cast<GLsizei>(ArraySize(invalidVert)), invalidVert, nullptr);
1551 EXPECT_GL_ERROR(GL_INVALID_VALUE);
1552 glDeleteShader(shader);
1553 }
1554}
1555
Geoff Langcab92ee2017-07-19 17:32:07 -04001556// Test that line continuation is handled correctly when valdiating shader source
Bryan Bernhart (Intel Americas Inc)335d8bf2017-10-23 15:41:43 -07001557TEST_P(WebGLCompatibilityTest, ShaderSourceLineContinuation)
1558{
1559 // Verify that a line continuation character (i.e. backslash) cannot be used
1560 // within a preprocessor directive in a ES2 context.
1561 ANGLE_SKIP_TEST_IF(getClientMajorVersion() >= 3);
1562
1563 const char *validVert =
1564 "#define foo this is a test\n"
1565 "precision mediump float;\n"
1566 "void main()\n"
1567 "{\n"
1568 " gl_Position = vec4(1.0);\n"
1569 "}\n";
1570
1571 const char *invalidVert =
1572 "#define foo this \\n"
1573 " is a test\n"
1574 "precision mediump float;\n"
1575 "void main()\n"
1576 "{\n"
1577 " gl_Position = vec4(1.0);\n"
1578 "}\n";
1579
1580 GLuint shader = glCreateShader(GL_VERTEX_SHADER);
1581 glShaderSource(shader, 1, &validVert, nullptr);
1582 EXPECT_GL_NO_ERROR();
1583
1584 glShaderSource(shader, 1, &invalidVert, nullptr);
1585 EXPECT_GL_ERROR(GL_INVALID_VALUE);
1586 glDeleteShader(shader);
1587}
1588
1589// Test that line continuation is handled correctly when valdiating shader source
Geoff Langcab92ee2017-07-19 17:32:07 -04001590TEST_P(WebGL2CompatibilityTest, ShaderSourceLineContinuation)
1591{
1592 const char *validVert =
1593 "#version 300 es\n"
1594 "precision mediump float;\n"
1595 "\n"
1596 "void main ()\n"
1597 "{\n"
1598 " float f\\\n"
1599 "oo = 1.0;\n"
1600 " gl_Position = vec4(foo);\n"
1601 "}\n";
1602
1603 const char *invalidVert =
1604 "#version 300 es\n"
1605 "precision mediump float;\n"
1606 "\n"
1607 "void main ()\n"
1608 "{\n"
1609 " float f\\$\n"
1610 "oo = 1.0;\n"
1611 " gl_Position = vec4(foo);\n"
1612 "}\n";
1613
1614 GLuint shader = glCreateShader(GL_VERTEX_SHADER);
1615 glShaderSource(shader, 1, &validVert, nullptr);
1616 EXPECT_GL_NO_ERROR();
1617 glShaderSource(shader, 1, &invalidVert, nullptr);
1618 EXPECT_GL_ERROR(GL_INVALID_VALUE);
1619 glDeleteShader(shader);
1620}
1621
Brandon Jonesed5b46f2017-07-21 08:39:17 -07001622// Tests bindAttribLocations for reserved prefixes and length limits
1623TEST_P(WebGLCompatibilityTest, BindAttribLocationLimitation)
1624{
1625 constexpr int maxLocStringLength = 256;
1626 const std::string tooLongString(maxLocStringLength + 1, '_');
1627
1628 glBindAttribLocation(0, 0, "_webgl_var");
1629
1630 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
1631
1632 glBindAttribLocation(0, 0, static_cast<const GLchar *>(tooLongString.c_str()));
1633
1634 EXPECT_GL_ERROR(GL_INVALID_VALUE);
1635}
1636
Corentin Wallez0dc97812017-06-22 14:38:44 -04001637// Test that having no attributes with a zero divisor is valid in WebGL2
Geoff Lang407d4e72017-04-12 14:54:11 -04001638TEST_P(WebGL2CompatibilityTest, InstancedDrawZeroDivisor)
1639{
1640 const std::string &vert =
1641 "attribute float a_pos;\n"
1642 "void main()\n"
1643 "{\n"
1644 " gl_Position = vec4(a_pos, a_pos, a_pos, 1.0);\n"
1645 "}\n";
1646
1647 const std::string &frag =
1648 "precision highp float;\n"
1649 "void main()\n"
1650 "{\n"
1651 " gl_FragColor = vec4(1.0);\n"
1652 "}\n";
1653
1654 ANGLE_GL_PROGRAM(program, vert, frag);
1655
1656 GLint posLocation = glGetAttribLocation(program.get(), "a_pos");
1657 ASSERT_NE(-1, posLocation);
1658
1659 glUseProgram(program.get());
1660
1661 GLBuffer buffer;
1662 glBindBuffer(GL_ARRAY_BUFFER, buffer.get());
1663 glBufferData(GL_ARRAY_BUFFER, 16, nullptr, GL_STATIC_DRAW);
1664
1665 glEnableVertexAttribArray(posLocation);
1666 glVertexAttribDivisor(posLocation, 1);
1667
Geoff Lang407d4e72017-04-12 14:54:11 -04001668 glVertexAttribPointer(0, 1, GL_UNSIGNED_BYTE, GL_FALSE, 0, nullptr);
1669 glDrawArraysInstanced(GL_POINTS, 0, 1, 4);
Geoff Lang407d4e72017-04-12 14:54:11 -04001670 ASSERT_GL_NO_ERROR();
1671}
1672
Corentin Wallez0844f2d2017-01-31 17:02:59 -05001673// Tests that NPOT is not enabled by default in WebGL 1 and that it can be enabled
1674TEST_P(WebGLCompatibilityTest, NPOT)
1675{
1676 EXPECT_FALSE(extensionEnabled("GL_OES_texture_npot"));
1677
1678 // Create a texture and set an NPOT mip 0, should always be acceptable.
1679 GLTexture texture;
1680 glBindTexture(GL_TEXTURE_2D, texture.get());
1681 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 10, 10, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
1682 ASSERT_GL_NO_ERROR();
1683
1684 // Try setting an NPOT mip 1 and verify the error if WebGL 1
1685 glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, 5, 5, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
1686 if (getClientMajorVersion() < 3)
1687 {
1688 ASSERT_GL_ERROR(GL_INVALID_VALUE);
1689 }
1690 else
1691 {
1692 ASSERT_GL_NO_ERROR();
1693 }
1694
1695 if (extensionRequestable("GL_OES_texture_npot"))
1696 {
1697 glRequestExtensionANGLE("GL_OES_texture_npot");
1698 ASSERT_GL_NO_ERROR();
1699
1700 // Try again to set NPOT mip 1
1701 glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, 5, 5, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
1702 ASSERT_GL_NO_ERROR();
1703 }
1704}
1705
Jamie Madillcad97ee2017-02-02 18:52:44 -05001706template <typename T>
1707void FillTexture2D(GLuint texture,
1708 GLsizei width,
1709 GLsizei height,
1710 const T &onePixelData,
1711 GLint level,
1712 GLint internalFormat,
1713 GLenum format,
1714 GLenum type)
1715{
1716 std::vector<T> allPixelsData(width * height, onePixelData);
1717
1718 glBindTexture(GL_TEXTURE_2D, texture);
1719 glTexImage2D(GL_TEXTURE_2D, level, internalFormat, width, height, 0, format, type,
1720 allPixelsData.data());
1721 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1722 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1723 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
1724 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
1725}
1726
Frank Henigman875bbba2017-02-08 16:38:17 -05001727// Test that unset gl_Position defaults to (0,0,0,0).
1728TEST_P(WebGLCompatibilityTest, DefaultPosition)
1729{
1730 // Draw a quad where each vertex is red if gl_Position is (0,0,0,0) before it is set,
1731 // and green otherwise. The center of each quadrant will be red if and only if all
1732 // four corners are red.
1733 const std::string vertexShader =
1734 "attribute vec3 pos;\n"
1735 "varying vec4 color;\n"
1736 "void main() {\n"
1737 " if (gl_Position == vec4(0,0,0,0)) {\n"
1738 " color = vec4(1,0,0,1);\n"
1739 " } else {\n"
1740 " color = vec4(0,1,0,1);\n"
1741 " }\n"
1742 " gl_Position = vec4(pos,1);\n"
1743 "}\n";
1744
1745 const std::string fragmentShader =
1746 "precision mediump float;\n"
1747 "varying vec4 color;\n"
1748 "void main() {\n"
1749 " gl_FragColor = color;\n"
1750 "}\n";
1751
1752 ANGLE_GL_PROGRAM(program, vertexShader, fragmentShader);
1753 drawQuad(program.get(), "pos", 0.0f, 1.0f, true);
1754 EXPECT_PIXEL_COLOR_EQ(getWindowWidth() * 1 / 4, getWindowHeight() * 1 / 4, GLColor::red);
1755 EXPECT_PIXEL_COLOR_EQ(getWindowWidth() * 1 / 4, getWindowHeight() * 3 / 4, GLColor::red);
1756 EXPECT_PIXEL_COLOR_EQ(getWindowWidth() * 3 / 4, getWindowHeight() * 1 / 4, GLColor::red);
1757 EXPECT_PIXEL_COLOR_EQ(getWindowWidth() * 3 / 4, getWindowHeight() * 3 / 4, GLColor::red);
1758}
1759
Jamie Madilla4595b82017-01-11 17:36:34 -05001760// Tests that a rendering feedback loop triggers a GL error under WebGL.
1761// Based on WebGL test conformance/renderbuffers/feedback-loop.html.
1762TEST_P(WebGLCompatibilityTest, RenderingFeedbackLoop)
1763{
1764 const std::string vertexShader =
1765 "attribute vec4 a_position;\n"
1766 "varying vec2 v_texCoord;\n"
1767 "void main() {\n"
1768 " gl_Position = a_position;\n"
1769 " v_texCoord = (a_position.xy * 0.5) + 0.5;\n"
1770 "}\n";
1771
1772 const std::string fragmentShader =
1773 "precision mediump float;\n"
1774 "varying vec2 v_texCoord;\n"
1775 "uniform sampler2D u_texture;\n"
1776 "void main() {\n"
1777 " // Shader swizzles color channels so we can tell if the draw succeeded.\n"
1778 " gl_FragColor = texture2D(u_texture, v_texCoord).gbra;\n"
1779 "}\n";
1780
1781 GLTexture texture;
Jamie Madillcad97ee2017-02-02 18:52:44 -05001782 FillTexture2D(texture.get(), 1, 1, GLColor::red, 0, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE);
Jamie Madilla4595b82017-01-11 17:36:34 -05001783
1784 ASSERT_GL_NO_ERROR();
1785
1786 GLFramebuffer framebuffer;
1787 glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.get());
1788 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture.get(), 0);
1789
1790 ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
1791
1792 ANGLE_GL_PROGRAM(program, vertexShader, fragmentShader);
1793
1794 GLint uniformLoc = glGetUniformLocation(program.get(), "u_texture");
1795 ASSERT_NE(-1, uniformLoc);
1796
1797 glUseProgram(program.get());
1798 glUniform1i(uniformLoc, 0);
1799 glDisable(GL_BLEND);
1800 glDisable(GL_DEPTH_TEST);
1801 ASSERT_GL_NO_ERROR();
1802
1803 // Drawing with a texture that is also bound to the current framebuffer should fail
1804 glBindTexture(GL_TEXTURE_2D, texture.get());
1805 drawQuad(program.get(), "a_position", 0.5f, 1.0f, true);
1806 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
1807
1808 // Ensure that the texture contents did not change after the previous render
1809 glBindFramebuffer(GL_FRAMEBUFFER, 0);
1810 drawQuad(program.get(), "a_position", 0.5f, 1.0f, true);
1811 ASSERT_GL_NO_ERROR();
1812 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::blue);
1813
1814 // Drawing when texture is bound to an inactive uniform should succeed
1815 GLTexture texture2;
Jamie Madillcad97ee2017-02-02 18:52:44 -05001816 FillTexture2D(texture2.get(), 1, 1, GLColor::green, 0, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE);
Jamie Madilla4595b82017-01-11 17:36:34 -05001817
1818 glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.get());
1819 glActiveTexture(GL_TEXTURE1);
1820 glBindTexture(GL_TEXTURE_2D, texture.get());
1821 drawQuad(program.get(), "a_position", 0.5f, 1.0f, true);
1822 ASSERT_GL_NO_ERROR();
1823 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red);
1824}
1825
Bryan Bernhart58806562017-01-05 13:09:31 -08001826// Test for the max draw buffers and color attachments.
1827TEST_P(WebGLCompatibilityTest, MaxDrawBuffersAttachmentPoints)
1828{
1829 // This test only applies to ES2.
1830 if (getClientMajorVersion() != 2)
1831 {
1832 return;
1833 }
1834
1835 GLFramebuffer fbo[2];
1836 glBindFramebuffer(GL_FRAMEBUFFER, fbo[0].get());
1837
1838 // Test that is valid when we bind with a single attachment point.
1839 GLTexture texture;
1840 glBindTexture(GL_TEXTURE_2D, texture.get());
1841 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
1842 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture.get(), 0);
1843 ASSERT_GL_NO_ERROR();
1844
1845 // Test that enabling the draw buffers extension will allow us to bind with a non-zero
1846 // attachment point.
1847 if (extensionRequestable("GL_EXT_draw_buffers"))
1848 {
1849 glRequestExtensionANGLE("GL_EXT_draw_buffers");
1850 EXPECT_GL_NO_ERROR();
1851 EXPECT_TRUE(extensionEnabled("GL_EXT_draw_buffers"));
1852
1853 glBindFramebuffer(GL_FRAMEBUFFER, fbo[1].get());
1854
1855 GLTexture texture2;
1856 glBindTexture(GL_TEXTURE_2D, texture2.get());
1857 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
1858 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, texture2.get(),
1859 0);
1860 ASSERT_GL_NO_ERROR();
1861 }
1862}
1863
Corentin Wallez3f6d4df2017-01-30 18:04:36 -05001864// Test that the offset in the index buffer is forced to be a multiple of the element size
1865TEST_P(WebGLCompatibilityTest, DrawElementsOffsetRestriction)
1866{
1867 const std::string &vert =
1868 "attribute vec3 a_pos;\n"
1869 "void main()\n"
1870 "{\n"
1871 " gl_Position = vec4(a_pos, 1.0);\n"
1872 "}\n";
1873
1874 const std::string &frag =
1875 "precision highp float;\n"
1876 "void main()\n"
1877 "{\n"
1878 " gl_FragColor = vec4(1.0);\n"
1879 "}\n";
1880
1881 ANGLE_GL_PROGRAM(program, vert, frag);
1882
1883 GLint posLocation = glGetAttribLocation(program.get(), "a_pos");
1884 ASSERT_NE(-1, posLocation);
1885 glUseProgram(program.get());
1886
1887 const auto &vertices = GetQuadVertices();
1888
1889 GLBuffer vertexBuffer;
1890 glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer.get());
1891 glBufferData(GL_ARRAY_BUFFER, sizeof(vertices[0]) * vertices.size(), vertices.data(),
1892 GL_STATIC_DRAW);
1893
1894 glVertexAttribPointer(posLocation, 3, GL_FLOAT, GL_FALSE, 0, 0);
1895 glEnableVertexAttribArray(posLocation);
1896
1897 GLBuffer indexBuffer;
Brandon Jonesed5b46f2017-07-21 08:39:17 -07001898 const GLubyte indices[] = {0, 0, 0, 0, 0, 0, 0, 0};
Corentin Wallez3f6d4df2017-01-30 18:04:36 -05001899 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer.get());
1900 glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW);
1901
1902 ASSERT_GL_NO_ERROR();
1903
1904 const char *zeroIndices = nullptr;
1905
1906 glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, zeroIndices);
1907 ASSERT_GL_NO_ERROR();
1908
Brandon Jonesed5b46f2017-07-21 08:39:17 -07001909 glDrawElements(GL_TRIANGLES, 4, GL_UNSIGNED_SHORT, zeroIndices);
Corentin Wallez3f6d4df2017-01-30 18:04:36 -05001910 ASSERT_GL_NO_ERROR();
1911
Brandon Jonesed5b46f2017-07-21 08:39:17 -07001912 glDrawElements(GL_TRIANGLES, 4, GL_UNSIGNED_SHORT, zeroIndices + 1);
Corentin Wallez3f6d4df2017-01-30 18:04:36 -05001913 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
1914}
1915
1916// Test that the offset and stride in the vertex buffer is forced to be a multiple of the element
1917// size
1918TEST_P(WebGLCompatibilityTest, VertexAttribPointerOffsetRestriction)
1919{
1920 const char *zeroOffset = nullptr;
1921
1922 // Base case, vector of two floats
1923 glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, zeroOffset);
1924 ASSERT_GL_NO_ERROR();
1925
1926 // Test setting a non-multiple offset
1927 glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, zeroOffset + 1);
1928 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
1929 glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, zeroOffset + 2);
1930 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
1931 glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, zeroOffset + 3);
1932 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
1933
1934 // Test setting a non-multiple stride
1935 glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 1, zeroOffset);
1936 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
1937 glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 2, zeroOffset);
1938 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
1939 glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 3, zeroOffset);
1940 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
1941}
1942
Jamie Madillcad97ee2017-02-02 18:52:44 -05001943void WebGLCompatibilityTest::drawBuffersEXTFeedbackLoop(GLuint program,
1944 const std::array<GLenum, 2> &drawBuffers,
1945 GLenum expectedError)
1946{
1947 glDrawBuffersEXT(2, drawBuffers.data());
1948
1949 // Make sure framebuffer is complete before feedback loop detection
1950 ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
1951
1952 drawQuad(program, "aPosition", 0.5f, 1.0f, true);
1953
1954 // "Rendering to a texture where it samples from should geneates INVALID_OPERATION. Otherwise,
1955 // it should be NO_ERROR"
1956 EXPECT_GL_ERROR(expectedError);
1957}
1958
1959// This tests that rendering feedback loops works as expected with GL_EXT_draw_buffers.
1960// Based on WebGL test conformance/extensions/webgl-draw-buffers-feedback-loop.html
1961TEST_P(WebGLCompatibilityTest, RenderingFeedbackLoopWithDrawBuffersEXT)
1962{
1963 const std::string vertexShader =
1964 "attribute vec4 aPosition;\n"
1965 "varying vec2 texCoord;\n"
1966 "void main() {\n"
1967 " gl_Position = aPosition;\n"
1968 " texCoord = (aPosition.xy * 0.5) + 0.5;\n"
1969 "}\n";
1970
1971 const std::string fragmentShader =
1972 "#extension GL_EXT_draw_buffers : require\n"
1973 "precision mediump float;\n"
1974 "uniform sampler2D tex;\n"
1975 "varying vec2 texCoord;\n"
1976 "void main() {\n"
1977 " gl_FragData[0] = texture2D(tex, texCoord);\n"
1978 " gl_FragData[1] = texture2D(tex, texCoord);\n"
1979 "}\n";
1980
1981 GLsizei width = 8;
1982 GLsizei height = 8;
1983
1984 // This shader cannot be run in ES3, because WebGL 2 does not expose the draw buffers
1985 // extension and gl_FragData semantics are changed to enforce indexing by zero always.
1986 // TODO(jmadill): This extension should be disabled in WebGL 2 contexts.
1987 if (/*!extensionEnabled("GL_EXT_draw_buffers")*/ getClientMajorVersion() != 2)
1988 {
1989 // No WEBGL_draw_buffers support -- this is legal.
1990 return;
1991 }
1992
1993 GLint maxDrawBuffers = 0;
1994 glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
1995
1996 if (maxDrawBuffers < 2)
1997 {
1998 std::cout << "Test skipped because MAX_DRAW_BUFFERS is too small." << std::endl;
1999 return;
2000 }
2001
2002 ANGLE_GL_PROGRAM(program, vertexShader, fragmentShader);
2003 glUseProgram(program.get());
2004 glViewport(0, 0, width, height);
2005
2006 GLTexture tex0;
2007 GLTexture tex1;
2008 GLFramebuffer fbo;
2009 FillTexture2D(tex0.get(), width, height, GLColor::red, 0, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE);
2010 FillTexture2D(tex1.get(), width, height, GLColor::green, 0, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE);
2011 ASSERT_GL_NO_ERROR();
2012
2013 glBindTexture(GL_TEXTURE_2D, tex1.get());
2014 GLint texLoc = glGetUniformLocation(program.get(), "tex");
2015 ASSERT_NE(-1, texLoc);
2016 glUniform1i(texLoc, 0);
2017 ASSERT_GL_NO_ERROR();
2018
2019 // The sampling texture is bound to COLOR_ATTACHMENT1 during resource allocation
2020 glBindFramebuffer(GL_FRAMEBUFFER, fbo.get());
2021 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex0.get(), 0);
2022 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, tex1.get(), 0);
2023
2024 drawBuffersEXTFeedbackLoop(program.get(), {{GL_NONE, GL_COLOR_ATTACHMENT1}},
2025 GL_INVALID_OPERATION);
2026 drawBuffersEXTFeedbackLoop(program.get(), {{GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1}},
2027 GL_INVALID_OPERATION);
2028 drawBuffersEXTFeedbackLoop(program.get(), {{GL_COLOR_ATTACHMENT0, GL_NONE}}, GL_NO_ERROR);
2029}
2030
Jamie Madill07be8bf2017-02-02 19:59:57 -05002031// Test tests that texture copying feedback loops are properly rejected in WebGL.
2032// Based on the WebGL test conformance/textures/misc/texture-copying-feedback-loops.html
2033TEST_P(WebGLCompatibilityTest, TextureCopyingFeedbackLoops)
2034{
2035 GLTexture texture;
2036 glBindTexture(GL_TEXTURE_2D, texture.get());
2037 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
2038 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
2039 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
2040 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
2041 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
2042
2043 GLTexture texture2;
2044 glBindTexture(GL_TEXTURE_2D, texture2.get());
2045 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
2046 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
2047 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
2048 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
2049 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
2050
2051 GLFramebuffer framebuffer;
2052 glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.get());
2053 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture.get(), 0);
2054
2055 // framebuffer should be FRAMEBUFFER_COMPLETE.
2056 ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
2057 ASSERT_GL_NO_ERROR();
2058
2059 // testing copyTexImage2D
2060
2061 // copyTexImage2D to same texture but different level
2062 glBindTexture(GL_TEXTURE_2D, texture.get());
2063 glCopyTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, 0, 0, 2, 2, 0);
2064 EXPECT_GL_NO_ERROR();
2065
2066 // copyTexImage2D to same texture same level, invalid feedback loop
2067 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 2, 2, 0);
2068 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
2069
2070 // copyTexImage2D to different texture
2071 glBindTexture(GL_TEXTURE_2D, texture2.get());
2072 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 2, 2, 0);
2073 EXPECT_GL_NO_ERROR();
2074
2075 // testing copyTexSubImage2D
2076
2077 // copyTexSubImage2D to same texture but different level
2078 glBindTexture(GL_TEXTURE_2D, texture.get());
2079 glCopyTexSubImage2D(GL_TEXTURE_2D, 1, 0, 0, 0, 0, 1, 1);
2080 EXPECT_GL_NO_ERROR();
2081
2082 // copyTexSubImage2D to same texture same level, invalid feedback loop
2083 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 1, 1);
2084 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
2085
2086 // copyTexSubImage2D to different texture
2087 glBindTexture(GL_TEXTURE_2D, texture2.get());
2088 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 1, 1);
2089 EXPECT_GL_NO_ERROR();
2090}
2091
2092void WebGLCompatibilityTest::drawBuffersFeedbackLoop(GLuint program,
2093 const std::array<GLenum, 2> &drawBuffers,
2094 GLenum expectedError)
2095{
2096 glDrawBuffers(2, drawBuffers.data());
2097
2098 // Make sure framebuffer is complete before feedback loop detection
2099 ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
2100
2101 drawQuad(program, "aPosition", 0.5f, 1.0f, true);
2102
2103 // "Rendering to a texture where it samples from should geneates INVALID_OPERATION. Otherwise,
2104 // it should be NO_ERROR"
2105 EXPECT_GL_ERROR(expectedError);
2106}
2107
Yuly Novikov817232e2017-02-22 18:36:10 -05002108// Tests invariance matching rules between built in varyings.
2109// Based on WebGL test conformance/glsl/misc/shaders-with-invariance.html.
2110TEST_P(WebGLCompatibilityTest, BuiltInInvariant)
2111{
2112 const std::string vertexShaderVariant =
2113 "varying vec4 v_varying;\n"
2114 "void main()\n"
2115 "{\n"
2116 " gl_PointSize = 1.0;\n"
2117 " gl_Position = v_varying;\n"
2118 "}";
2119 const std::string fragmentShaderInvariantGlFragCoord =
2120 "invariant gl_FragCoord;\n"
2121 "void main()\n"
2122 "{\n"
2123 " gl_FragColor = gl_FragCoord;\n"
2124 "}";
2125 const std::string fragmentShaderInvariantGlPointCoord =
2126 "invariant gl_PointCoord;\n"
2127 "void main()\n"
2128 "{\n"
2129 " gl_FragColor = vec4(gl_PointCoord, 0.0, 0.0);\n"
2130 "}";
2131
2132 GLuint program = CompileProgram(vertexShaderVariant, fragmentShaderInvariantGlFragCoord);
2133 EXPECT_EQ(0u, program);
2134
2135 program = CompileProgram(vertexShaderVariant, fragmentShaderInvariantGlPointCoord);
2136 EXPECT_EQ(0u, program);
2137}
2138
Yuly Novikovcaa5cda2017-06-15 21:14:03 -04002139// Tests global namespace conflicts between uniforms and attributes.
2140// Based on WebGL test conformance/glsl/misc/shaders-with-name-conflicts.html.
2141TEST_P(WebGLCompatibilityTest, GlobalNamesConflict)
2142{
2143 const std::string vertexShader =
2144 "attribute vec4 foo;\n"
2145 "void main()\n"
2146 "{\n"
2147 " gl_Position = foo;\n"
2148 "}";
2149 const std::string fragmentShader =
2150 "precision mediump float;\n"
2151 "uniform vec4 foo;\n"
2152 "void main()\n"
2153 "{\n"
2154 " gl_FragColor = foo;\n"
2155 "}";
2156
2157 GLuint program = CompileProgram(vertexShader, fragmentShader);
2158 EXPECT_EQ(0u, program);
2159}
2160
Geoff Lang966c9402017-04-18 12:38:27 -04002161// Test dimension and image size validation of compressed textures
2162TEST_P(WebGLCompatibilityTest, CompressedTextureS3TC)
2163{
2164 if (extensionRequestable("GL_EXT_texture_compression_dxt1"))
2165 {
2166 glRequestExtensionANGLE("GL_EXT_texture_compression_dxt1");
2167 }
2168
2169 if (!extensionEnabled("GL_EXT_texture_compression_dxt1"))
2170 {
2171 std::cout << "Test skipped because GL_EXT_texture_compression_dxt1 is not available."
2172 << std::endl;
2173 return;
2174 }
2175
2176 constexpr uint8_t CompressedImageDXT1[] = {0x00, 0xf8, 0x00, 0xf8, 0xaa, 0xaa, 0xaa, 0xaa};
2177
2178 GLTexture texture;
2179 glBindTexture(GL_TEXTURE_2D, texture);
2180
2181 // Regular case, verify that it works
2182 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, 4, 4, 0,
2183 sizeof(CompressedImageDXT1), CompressedImageDXT1);
2184 ASSERT_GL_NO_ERROR();
2185
2186 // Test various dimensions that are not valid
2187 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, 3, 4, 0,
2188 sizeof(CompressedImageDXT1), CompressedImageDXT1);
2189 ASSERT_GL_ERROR(GL_INVALID_OPERATION);
2190
2191 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, 4, 3, 0,
2192 sizeof(CompressedImageDXT1), CompressedImageDXT1);
2193 ASSERT_GL_ERROR(GL_INVALID_OPERATION);
2194
2195 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, 2, 2, 0,
2196 sizeof(CompressedImageDXT1), CompressedImageDXT1);
2197 ASSERT_GL_ERROR(GL_INVALID_OPERATION);
2198
2199 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, 1, 1, 0,
2200 sizeof(CompressedImageDXT1), CompressedImageDXT1);
2201 ASSERT_GL_ERROR(GL_INVALID_OPERATION);
2202
2203 // Test various image sizes that are not valid
2204 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, 4, 4, 0,
2205 sizeof(CompressedImageDXT1) - 1, CompressedImageDXT1);
2206 ASSERT_GL_ERROR(GL_INVALID_VALUE);
2207
2208 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, 4, 4, 0,
2209 sizeof(CompressedImageDXT1) + 1, CompressedImageDXT1);
2210 ASSERT_GL_ERROR(GL_INVALID_VALUE);
2211
2212 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, 4, 4, 0, 0,
2213 CompressedImageDXT1);
2214 ASSERT_GL_ERROR(GL_INVALID_VALUE);
2215
2216 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, 0, 0, 0,
2217 sizeof(CompressedImageDXT1), CompressedImageDXT1);
2218 ASSERT_GL_ERROR(GL_INVALID_VALUE);
2219
2220 // Fill a full mip chain and verify that it works
2221 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, 4, 4, 0,
2222 sizeof(CompressedImageDXT1), CompressedImageDXT1);
2223 glCompressedTexImage2D(GL_TEXTURE_2D, 1, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, 2, 2, 0,
2224 sizeof(CompressedImageDXT1), CompressedImageDXT1);
2225 glCompressedTexImage2D(GL_TEXTURE_2D, 2, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, 1, 1, 0,
2226 sizeof(CompressedImageDXT1), CompressedImageDXT1);
2227 ASSERT_GL_NO_ERROR();
2228
2229 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
2230 sizeof(CompressedImageDXT1), CompressedImageDXT1);
2231 ASSERT_GL_NO_ERROR();
2232
2233 // Test that non-block size sub-uploads are not valid for the 0 mip
2234 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 2, 2, 2, 2, GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
2235 sizeof(CompressedImageDXT1), CompressedImageDXT1);
2236 ASSERT_GL_ERROR(GL_INVALID_OPERATION);
2237
2238 // Test that non-block size sub-uploads are valid for if they fill the whole mip
2239 glCompressedTexSubImage2D(GL_TEXTURE_2D, 1, 0, 0, 2, 2, GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
2240 sizeof(CompressedImageDXT1), CompressedImageDXT1);
2241 glCompressedTexSubImage2D(GL_TEXTURE_2D, 2, 0, 0, 1, 1, GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
2242 sizeof(CompressedImageDXT1), CompressedImageDXT1);
2243 ASSERT_GL_NO_ERROR();
2244
2245 // Test that if the format miss-matches the texture, an error is generated
2246 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 2, 2, 2, 2, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
2247 sizeof(CompressedImageDXT1), CompressedImageDXT1);
2248 ASSERT_GL_ERROR(GL_INVALID_OPERATION);
2249}
2250
Geoff Lang677bb6f2017-04-05 12:40:40 -04002251TEST_P(WebGLCompatibilityTest, L32FTextures)
2252{
2253 constexpr float textureData[] = {15.1f, 0.0f, 0.0f, 0.0f};
2254 constexpr float readPixelData[] = {textureData[0], textureData[0], textureData[0], 1.0f};
2255
2256 for (auto extension : FloatingPointTextureExtensions)
2257 {
2258 if (strlen(extension) > 0 && extensionRequestable(extension))
2259 {
2260 glRequestExtensionANGLE(extension);
2261 ASSERT_GL_NO_ERROR();
2262 }
2263
2264 // Unsized L 32F
2265 {
2266 bool texture = extensionEnabled("GL_OES_texture_float");
2267 bool filter = extensionEnabled("GL_OES_texture_float_linear");
2268 bool render = false;
2269 TestFloatTextureFormat(GL_LUMINANCE, GL_LUMINANCE, GL_FLOAT, texture, filter, render,
2270 textureData, readPixelData);
2271 }
2272
2273 if (getClientMajorVersion() >= 3 || extensionEnabled("GL_EXT_texture_storage"))
2274 {
2275 // Sized L 32F
2276 bool texture = extensionEnabled("GL_OES_texture_float") &&
2277 extensionEnabled("GL_EXT_texture_storage");
2278 bool filter = extensionEnabled("GL_OES_texture_float_linear");
2279 bool render = false;
2280 TestFloatTextureFormat(GL_LUMINANCE32F_EXT, GL_LUMINANCE, GL_FLOAT, texture, filter,
2281 render, textureData, readPixelData);
2282 }
2283 }
2284}
2285
2286TEST_P(WebGLCompatibilityTest, A32FTextures)
2287{
2288 constexpr float textureData[] = {33.33f, 0.0f, 0.0f, 0.0f};
2289 constexpr float readPixelData[] = {0.0f, 0.0f, 0.0f, textureData[0]};
2290
2291 for (auto extension : FloatingPointTextureExtensions)
2292 {
2293 if (strlen(extension) > 0 && extensionRequestable(extension))
2294 {
2295 glRequestExtensionANGLE(extension);
2296 ASSERT_GL_NO_ERROR();
2297 }
2298
2299 // Unsized A 32F
2300 {
2301 bool texture = extensionEnabled("GL_OES_texture_float");
2302 bool filter = extensionEnabled("GL_OES_texture_float_linear");
2303 bool render = false;
2304 TestFloatTextureFormat(GL_ALPHA, GL_ALPHA, GL_FLOAT, texture, filter, render,
2305 textureData, readPixelData);
2306 }
2307
2308 if (getClientMajorVersion() >= 3 || extensionEnabled("GL_EXT_texture_storage"))
2309 {
2310 // Sized A 32F
2311 bool texture = extensionEnabled("GL_OES_texture_float") &&
2312 extensionEnabled("GL_EXT_texture_storage");
2313 bool filter = extensionEnabled("GL_OES_texture_float_linear");
2314 bool render = false;
2315 TestFloatTextureFormat(GL_ALPHA32F_EXT, GL_ALPHA, GL_FLOAT, texture, filter, render,
2316 textureData, readPixelData);
2317 }
2318 }
2319}
2320
2321TEST_P(WebGLCompatibilityTest, LA32FTextures)
2322{
2323 constexpr float textureData[] = {-0.21f, 15.1f, 0.0f, 0.0f};
2324 constexpr float readPixelData[] = {textureData[0], textureData[0], textureData[0],
2325 textureData[1]};
2326
2327 for (auto extension : FloatingPointTextureExtensions)
2328 {
2329 if (strlen(extension) > 0 && extensionRequestable(extension))
2330 {
2331 glRequestExtensionANGLE(extension);
2332 ASSERT_GL_NO_ERROR();
2333 }
2334
2335 // Unsized LA 32F
2336 {
2337 bool texture = extensionEnabled("GL_OES_texture_float");
2338 bool filter = extensionEnabled("GL_OES_texture_float_linear");
2339 bool render = false;
2340 TestFloatTextureFormat(GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_FLOAT, texture,
2341 filter, render, textureData, readPixelData);
2342 }
2343
2344 if (getClientMajorVersion() >= 3 || extensionEnabled("GL_EXT_texture_storage"))
2345 {
2346 // Sized LA 32F
2347 bool texture = extensionEnabled("GL_OES_texture_float") &&
2348 extensionEnabled("GL_EXT_texture_storage");
2349 bool filter = extensionEnabled("GL_OES_texture_float_linear");
2350 bool render = false;
2351 TestFloatTextureFormat(GL_LUMINANCE_ALPHA32F_EXT, GL_LUMINANCE_ALPHA, GL_FLOAT, texture,
2352 filter, render, textureData, readPixelData);
2353 }
2354 }
2355}
2356
2357TEST_P(WebGLCompatibilityTest, R32FTextures)
2358{
2359 constexpr float data[] = {1000.0f, 0.0f, 0.0f, 1.0f};
2360
2361 for (auto extension : FloatingPointTextureExtensions)
2362 {
2363 if (strlen(extension) > 0 && extensionRequestable(extension))
2364 {
2365 glRequestExtensionANGLE(extension);
2366 ASSERT_GL_NO_ERROR();
2367 }
2368
2369 // Unsized R 32F
2370 {
2371 bool texture =
2372 extensionEnabled("GL_OES_texture_float") && extensionEnabled("GL_EXT_texture_rg");
2373 bool filter = extensionEnabled("GL_OES_texture_float_linear");
2374 bool render = extensionEnabled("GL_EXT_color_buffer_float");
2375 TestFloatTextureFormat(GL_RED, GL_RED, GL_FLOAT, texture, filter, render, data, data);
2376 }
2377
2378 if (getClientMajorVersion() >= 3 || extensionEnabled("GL_EXT_texture_storage"))
2379 {
2380 // Sized R 32F
2381 bool texture =
2382 (getClientMajorVersion() >= 3) || (extensionEnabled("GL_OES_texture_float") &&
2383 extensionEnabled("GL_EXT_texture_rg") &&
2384 extensionEnabled("GL_EXT_texture_storage"));
2385 bool filter = extensionEnabled("GL_OES_texture_float_linear");
2386 bool render = extensionEnabled("GL_EXT_color_buffer_float");
2387 TestFloatTextureFormat(GL_R32F, GL_RED, GL_FLOAT, texture, filter, render, data, data);
2388 }
2389 }
2390}
2391
2392TEST_P(WebGLCompatibilityTest, RG32FTextures)
2393{
2394 constexpr float data[] = {1000.0f, -0.001f, 0.0f, 1.0f};
2395
2396 for (auto extension : FloatingPointTextureExtensions)
2397 {
2398 if (strlen(extension) > 0 && extensionRequestable(extension))
2399 {
2400 glRequestExtensionANGLE(extension);
2401 ASSERT_GL_NO_ERROR();
2402 }
2403
2404 // Unsized RG 32F
2405 {
2406 bool texture =
2407 (extensionEnabled("GL_OES_texture_float") && extensionEnabled("GL_EXT_texture_rg"));
2408 bool filter = extensionEnabled("GL_OES_texture_float_linear");
2409 bool render = extensionEnabled("GL_EXT_color_buffer_float");
2410 TestFloatTextureFormat(GL_RG, GL_RG, GL_FLOAT, texture, filter, render, data, data);
2411 }
2412
2413 if (getClientMajorVersion() >= 3 || extensionEnabled("GL_EXT_texture_storage"))
2414 {
2415 // Sized RG 32F
2416 bool texture =
2417 (getClientMajorVersion() >= 3) || (extensionEnabled("GL_OES_texture_float") &&
2418 extensionEnabled("GL_EXT_texture_rg") &&
2419 extensionEnabled("GL_EXT_texture_storage"));
2420 bool filter = extensionEnabled("GL_OES_texture_float_linear");
2421 bool render = extensionEnabled("GL_EXT_color_buffer_float");
2422 TestFloatTextureFormat(GL_RG32F, GL_RG, GL_FLOAT, texture, filter, render, data, data);
2423 }
2424 }
2425}
2426
2427TEST_P(WebGLCompatibilityTest, RGB32FTextures)
2428{
Geoff Lang40762ef2017-05-08 13:47:03 -04002429 if (IsLinux() && IsIntel())
2430 {
2431 std::cout << "Test skipped on Linux Intel." << std::endl;
2432 return;
2433 }
2434
Geoff Lang677bb6f2017-04-05 12:40:40 -04002435 constexpr float data[] = {1000.0f, -500.0f, 10.0f, 1.0f};
2436
2437 for (auto extension : FloatingPointTextureExtensions)
2438 {
2439 if (strlen(extension) > 0 && extensionRequestable(extension))
2440 {
2441 glRequestExtensionANGLE(extension);
2442 ASSERT_GL_NO_ERROR();
2443 }
2444
2445 // Unsized RGB 32F
2446 {
2447 bool texture = extensionEnabled("GL_OES_texture_float");
2448 bool filter = extensionEnabled("GL_OES_texture_float_linear");
2449 bool render = extensionEnabled("GL_CHROMIUM_color_buffer_float_rgb");
2450 TestFloatTextureFormat(GL_RGB, GL_RGB, GL_FLOAT, texture, filter, render, data, data);
2451 }
2452
2453 if (getClientMajorVersion() >= 3 || extensionEnabled("GL_EXT_texture_storage"))
2454 {
2455 // Sized RGBA 32F
2456 bool texture =
2457 (getClientMajorVersion() >= 3) || (extensionEnabled("GL_OES_texture_float") &&
2458 extensionEnabled("GL_EXT_texture_storage"));
2459 bool filter = extensionEnabled("GL_OES_texture_float_linear");
2460 bool render = extensionEnabled("GL_CHROMIUM_color_buffer_float_rgb");
2461 TestFloatTextureFormat(GL_RGB32F, GL_RGB, GL_FLOAT, texture, filter, render, data,
2462 data);
2463 }
2464 }
2465}
2466
2467TEST_P(WebGLCompatibilityTest, RGBA32FTextures)
2468{
2469 constexpr float data[] = {7000.0f, 100.0f, 33.0f, -1.0f};
2470
2471 for (auto extension : FloatingPointTextureExtensions)
2472 {
2473 if (strlen(extension) > 0 && extensionRequestable(extension))
2474 {
2475 glRequestExtensionANGLE(extension);
2476 ASSERT_GL_NO_ERROR();
2477 }
2478
2479 // Unsized RGBA 32F
2480 {
2481 bool texture = extensionEnabled("GL_OES_texture_float");
2482 bool filter = extensionEnabled("GL_OES_texture_float_linear");
2483 bool render = extensionEnabled("GL_EXT_color_buffer_float") ||
2484 extensionEnabled("GL_CHROMIUM_color_buffer_float_rgba");
2485 TestFloatTextureFormat(GL_RGBA, GL_RGBA, GL_FLOAT, texture, filter, render, data, data);
2486 }
2487
2488 if (getClientMajorVersion() >= 3 || extensionEnabled("GL_EXT_texture_storage"))
2489 {
2490 // Sized RGBA 32F
2491 bool texture =
2492 (getClientMajorVersion() >= 3) || (extensionEnabled("GL_OES_texture_float") &&
2493 extensionEnabled("GL_EXT_texture_storage"));
2494 bool filter = extensionEnabled("GL_OES_texture_float_linear");
2495 bool render = extensionEnabled("GL_EXT_color_buffer_float") ||
2496 extensionEnabled("GL_CHROMIUM_color_buffer_float_rgba");
2497 TestFloatTextureFormat(GL_RGBA32F, GL_RGBA, GL_FLOAT, texture, filter, render, data,
2498 data);
2499 }
2500 }
2501}
2502
2503TEST_P(WebGLCompatibilityTest, R16FTextures)
2504{
2505 constexpr float readPixelsData[] = {-5000.0f, 0.0f, 0.0f, 1.0f};
2506 const GLushort textureData[] = {
2507 gl::float32ToFloat16(readPixelsData[0]), gl::float32ToFloat16(readPixelsData[1]),
2508 gl::float32ToFloat16(readPixelsData[2]), gl::float32ToFloat16(readPixelsData[3])};
2509
2510 for (auto extension : FloatingPointTextureExtensions)
2511 {
2512 if (strlen(extension) > 0 && extensionRequestable(extension))
2513 {
2514 glRequestExtensionANGLE(extension);
2515 ASSERT_GL_NO_ERROR();
2516 }
2517
2518 // Unsized R 16F (OES)
2519 {
2520 bool texture = extensionEnabled("GL_OES_texture_half_float") &&
2521 extensionEnabled("GL_EXT_texture_rg");
2522 bool filter = getClientMajorVersion() >= 3 ||
2523 extensionEnabled("GL_OES_texture_half_float_linear");
2524 bool render = extensionEnabled("GL_EXT_color_buffer_half_float");
2525 TestFloatTextureFormat(GL_RED, GL_RED, GL_HALF_FLOAT_OES, texture, filter, render,
2526 textureData, readPixelsData);
2527 }
2528
2529 // Unsized R 16F
2530 {
2531 bool texture = false;
2532 bool filter = false;
2533 bool render = false;
2534 TestFloatTextureFormat(GL_RED, GL_RED, GL_HALF_FLOAT, texture, filter, render,
2535 textureData, readPixelsData);
2536 }
2537
2538 if (getClientMajorVersion() >= 3 || extensionEnabled("GL_EXT_texture_storage"))
2539 {
2540 // Sized R 16F
2541 bool texture = getClientMajorVersion() >= 3;
2542 bool filter = getClientMajorVersion() >= 3 ||
2543 extensionEnabled("GL_OES_texture_half_float_linear");
2544 bool render = extensionEnabled("GL_EXT_color_buffer_half_float") ||
2545 extensionEnabled("GL_EXT_color_buffer_float");
2546 TestFloatTextureFormat(GL_R16F, GL_RED, GL_HALF_FLOAT, texture, filter, render,
2547 textureData, readPixelsData);
2548 }
2549 }
2550}
2551
2552TEST_P(WebGLCompatibilityTest, RG16FTextures)
2553{
2554 constexpr float readPixelsData[] = {7108.0f, -10.0f, 0.0f, 1.0f};
2555 const GLushort textureData[] = {
2556 gl::float32ToFloat16(readPixelsData[0]), gl::float32ToFloat16(readPixelsData[1]),
2557 gl::float32ToFloat16(readPixelsData[2]), gl::float32ToFloat16(readPixelsData[3])};
2558
2559 for (auto extension : FloatingPointTextureExtensions)
2560 {
2561 if (strlen(extension) > 0 && extensionRequestable(extension))
2562 {
2563 glRequestExtensionANGLE(extension);
2564 ASSERT_GL_NO_ERROR();
2565 }
2566
2567 // Unsized RG 16F (OES)
2568 {
2569 bool texture = extensionEnabled("GL_OES_texture_half_float") &&
2570 extensionEnabled("GL_EXT_texture_rg");
2571 bool filter = getClientMajorVersion() >= 3 ||
2572 extensionEnabled("GL_OES_texture_half_float_linear");
2573 bool render = extensionEnabled("GL_EXT_color_buffer_half_float") &&
2574 extensionEnabled("GL_EXT_texture_rg");
2575 TestFloatTextureFormat(GL_RG, GL_RG, GL_HALF_FLOAT_OES, texture, filter, render,
2576 textureData, readPixelsData);
2577 }
2578
2579 // Unsized RG 16F
2580 {
2581 bool texture = false;
2582 bool filter = false;
2583 bool render = false;
2584 TestFloatTextureFormat(GL_RG, GL_RG, GL_HALF_FLOAT, texture, filter, render,
2585 textureData, readPixelsData);
2586 }
2587
2588 if (getClientMajorVersion() >= 3 || extensionEnabled("GL_EXT_texture_storage"))
2589 {
2590 // Sized RG 16F
2591 bool texture = getClientMajorVersion() >= 3;
2592 bool filter = getClientMajorVersion() >= 3 ||
2593 extensionEnabled("GL_OES_texture_half_float_linear");
2594 bool render = extensionEnabled("GL_EXT_color_buffer_half_float") ||
2595 extensionEnabled("GL_EXT_color_buffer_float");
2596 TestFloatTextureFormat(GL_RG16F, GL_RG, GL_HALF_FLOAT, texture, filter, render,
2597 textureData, readPixelsData);
2598 }
2599 }
2600}
2601
2602TEST_P(WebGLCompatibilityTest, RGB16FTextures)
2603{
Geoff Lang40762ef2017-05-08 13:47:03 -04002604 if (IsOzone() && IsIntel())
2605 {
2606 std::cout << "Test skipped on Intel Ozone." << std::endl;
2607 return;
2608 }
2609
Geoff Lang677bb6f2017-04-05 12:40:40 -04002610 constexpr float readPixelsData[] = {7000.0f, 100.0f, 33.0f, 1.0f};
2611 const GLushort textureData[] = {
2612 gl::float32ToFloat16(readPixelsData[0]), gl::float32ToFloat16(readPixelsData[1]),
2613 gl::float32ToFloat16(readPixelsData[2]), gl::float32ToFloat16(readPixelsData[3])};
2614
2615 for (auto extension : FloatingPointTextureExtensions)
2616 {
2617 if (strlen(extension) > 0 && extensionRequestable(extension))
2618 {
2619 glRequestExtensionANGLE(extension);
2620 ASSERT_GL_NO_ERROR();
2621 }
2622
2623 // Unsized RGB 16F (OES)
2624 {
2625 bool texture = extensionEnabled("GL_OES_texture_half_float");
2626 bool filter = getClientMajorVersion() >= 3 ||
2627 extensionEnabled("GL_OES_texture_half_float_linear");
2628 bool render = extensionEnabled("GL_EXT_color_buffer_half_float");
2629 TestFloatTextureFormat(GL_RGB, GL_RGB, GL_HALF_FLOAT_OES, texture, filter, render,
2630 textureData, readPixelsData);
2631 }
2632
2633 // Unsized RGB 16F
2634 {
2635 bool texture = false;
2636 bool filter = false;
2637 bool render = false;
2638 TestFloatTextureFormat(GL_RGB, GL_RGB, GL_HALF_FLOAT, texture, filter, render,
2639 textureData, readPixelsData);
2640 }
2641
2642 if (getClientMajorVersion() >= 3 || extensionEnabled("GL_EXT_texture_storage"))
2643 {
2644 // Sized RGB 16F
2645 bool texture = getClientMajorVersion() >= 3;
2646 bool filter = getClientMajorVersion() >= 3 ||
2647 extensionEnabled("GL_OES_texture_half_float_linear");
2648 bool render = extensionEnabled("GL_EXT_color_buffer_half_float");
2649 TestFloatTextureFormat(GL_RGB16F, GL_RGB, GL_HALF_FLOAT, texture, filter, render,
2650 textureData, readPixelsData);
2651 }
2652 }
2653}
2654
2655TEST_P(WebGLCompatibilityTest, RGBA16FTextures)
2656{
Geoff Lang40762ef2017-05-08 13:47:03 -04002657 if (IsOzone() && IsIntel())
2658 {
2659 std::cout << "Test skipped on Intel Ozone." << std::endl;
2660 return;
2661 }
2662
Geoff Lang677bb6f2017-04-05 12:40:40 -04002663 constexpr float readPixelsData[] = {7000.0f, 100.0f, 33.0f, -1.0f};
2664 const GLushort textureData[] = {
2665 gl::float32ToFloat16(readPixelsData[0]), gl::float32ToFloat16(readPixelsData[1]),
2666 gl::float32ToFloat16(readPixelsData[2]), gl::float32ToFloat16(readPixelsData[3])};
2667
2668 for (auto extension : FloatingPointTextureExtensions)
2669 {
2670 if (strlen(extension) > 0 && extensionRequestable(extension))
2671 {
2672 glRequestExtensionANGLE(extension);
2673 ASSERT_GL_NO_ERROR();
2674 }
2675
2676 // Unsized RGBA 16F (OES)
2677 {
2678 bool texture = extensionEnabled("GL_OES_texture_half_float");
2679 bool filter = getClientMajorVersion() >= 3 ||
2680 extensionEnabled("GL_OES_texture_half_float_linear");
2681 bool render = extensionEnabled("GL_EXT_color_buffer_half_float") ||
2682 extensionEnabled("GL_EXT_color_buffer_float");
2683 TestFloatTextureFormat(GL_RGBA, GL_RGBA, GL_HALF_FLOAT_OES, texture, filter, render,
2684 textureData, readPixelsData);
2685 }
2686
2687 // Unsized RGBA 16F
2688 {
2689 bool texture = false;
2690 bool filter = false;
2691 bool render = false;
2692 TestFloatTextureFormat(GL_RGBA, GL_RGBA, GL_HALF_FLOAT, texture, filter, render,
2693 textureData, readPixelsData);
2694 }
2695
2696 if (getClientMajorVersion() >= 3 || extensionEnabled("GL_EXT_texture_storage"))
2697 {
2698 // Sized RGBA 16F
2699 bool texture = getClientMajorVersion() >= 3;
2700 bool filter = getClientMajorVersion() >= 3 ||
2701 extensionEnabled("GL_OES_texture_half_float_linear");
2702 bool render = extensionEnabled("GL_EXT_color_buffer_half_float") ||
2703 extensionEnabled("GL_EXT_color_buffer_float");
2704 TestFloatTextureFormat(GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT, texture, filter, render,
2705 textureData, readPixelsData);
2706 }
2707 }
2708}
2709
Geoff Lang6e898aa2017-06-02 11:17:26 -04002710// Test that when GL_CHROMIUM_color_buffer_float_rgb[a] is enabled, sized GL_RGB[A]_32F formats are
2711// accepted by glTexImage2D
2712TEST_P(WebGLCompatibilityTest, SizedRGBA32FFormats)
2713{
2714 if (getClientMajorVersion() != 2)
2715 {
2716 std::cout << "Test skipped because it is only valid for WebGL1 contexts." << std::endl;
2717 return;
2718 }
2719
2720 if (!extensionRequestable("GL_OES_texture_float"))
2721 {
2722 std::cout << "Test skipped because GL_OES_texture_float is not requestable." << std::endl;
2723 return;
2724 }
2725 glRequestExtensionANGLE("GL_OES_texture_float");
2726 ASSERT_GL_NO_ERROR();
2727
2728 GLTexture texture;
2729 glBindTexture(GL_TEXTURE_2D, texture);
2730
2731 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, 1, 1, 0, GL_RGBA, GL_FLOAT, nullptr);
2732 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
2733
2734 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB32F, 1, 1, 0, GL_RGB, GL_FLOAT, nullptr);
2735 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
2736
2737 if (extensionRequestable("GL_CHROMIUM_color_buffer_float_rgba"))
2738 {
2739 glRequestExtensionANGLE("GL_CHROMIUM_color_buffer_float_rgba");
2740 ASSERT_GL_NO_ERROR();
2741
2742 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, 1, 1, 0, GL_RGBA, GL_FLOAT, nullptr);
2743 EXPECT_GL_NO_ERROR();
2744 }
2745
2746 if (extensionRequestable("GL_CHROMIUM_color_buffer_float_rgb"))
2747 {
2748 glRequestExtensionANGLE("GL_CHROMIUM_color_buffer_float_rgb");
2749 ASSERT_GL_NO_ERROR();
2750
2751 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB32F, 1, 1, 0, GL_RGB, GL_FLOAT, nullptr);
2752 EXPECT_GL_NO_ERROR();
2753 }
2754}
2755
Jamie Madill07be8bf2017-02-02 19:59:57 -05002756// This tests that rendering feedback loops works as expected with WebGL 2.
2757// Based on WebGL test conformance2/rendering/rendering-sampling-feedback-loop.html
2758TEST_P(WebGL2CompatibilityTest, RenderingFeedbackLoopWithDrawBuffers)
2759{
2760 const std::string vertexShader =
2761 "#version 300 es\n"
2762 "in vec4 aPosition;\n"
2763 "out vec2 texCoord;\n"
2764 "void main() {\n"
2765 " gl_Position = aPosition;\n"
2766 " texCoord = (aPosition.xy * 0.5) + 0.5;\n"
2767 "}\n";
2768
2769 const std::string fragmentShader =
2770 "#version 300 es\n"
2771 "precision mediump float;\n"
2772 "uniform sampler2D tex;\n"
2773 "in vec2 texCoord;\n"
2774 "out vec4 oColor;\n"
2775 "void main() {\n"
2776 " oColor = texture(tex, texCoord);\n"
2777 "}\n";
2778
2779 GLsizei width = 8;
2780 GLsizei height = 8;
2781
2782 GLint maxDrawBuffers = 0;
2783 glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
2784 // ES3 requires a minimum value of 4 for MAX_DRAW_BUFFERS.
2785 ASSERT_GE(maxDrawBuffers, 2);
2786
2787 ANGLE_GL_PROGRAM(program, vertexShader, fragmentShader);
2788 glUseProgram(program.get());
2789 glViewport(0, 0, width, height);
2790
2791 GLTexture tex0;
2792 GLTexture tex1;
2793 GLFramebuffer fbo;
2794 FillTexture2D(tex0.get(), width, height, GLColor::red, 0, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE);
2795 FillTexture2D(tex1.get(), width, height, GLColor::green, 0, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE);
2796 ASSERT_GL_NO_ERROR();
2797
2798 glBindTexture(GL_TEXTURE_2D, tex1.get());
2799 GLint texLoc = glGetUniformLocation(program.get(), "tex");
2800 ASSERT_NE(-1, texLoc);
2801 glUniform1i(texLoc, 0);
2802
2803 // The sampling texture is bound to COLOR_ATTACHMENT1 during resource allocation
2804 glBindFramebuffer(GL_FRAMEBUFFER, fbo.get());
2805 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex0.get(), 0);
2806 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, tex1.get(), 0);
2807 ASSERT_GL_NO_ERROR();
2808
2809 drawBuffersFeedbackLoop(program.get(), {{GL_NONE, GL_COLOR_ATTACHMENT1}}, GL_INVALID_OPERATION);
2810 drawBuffersFeedbackLoop(program.get(), {{GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1}},
2811 GL_INVALID_OPERATION);
2812 drawBuffersFeedbackLoop(program.get(), {{GL_COLOR_ATTACHMENT0, GL_NONE}}, GL_NO_ERROR);
2813}
2814
Jamie Madill1d37bc52017-02-02 19:59:58 -05002815// This test covers detection of rendering feedback loops between the FBO and a depth Texture.
2816// Based on WebGL test conformance2/rendering/depth-stencil-feedback-loop.html
2817TEST_P(WebGL2CompatibilityTest, RenderingFeedbackLoopWithDepthStencil)
2818{
2819 const std::string vertexShader =
2820 "#version 300 es\n"
2821 "in vec4 aPosition;\n"
2822 "out vec2 texCoord;\n"
2823 "void main() {\n"
2824 " gl_Position = aPosition;\n"
2825 " texCoord = (aPosition.xy * 0.5) + 0.5;\n"
2826 "}\n";
2827
2828 const std::string fragmentShader =
2829 "#version 300 es\n"
2830 "precision mediump float;\n"
2831 "uniform sampler2D tex;\n"
2832 "in vec2 texCoord;\n"
2833 "out vec4 oColor;\n"
2834 "void main() {\n"
2835 " oColor = texture(tex, texCoord);\n"
2836 "}\n";
2837
2838 GLsizei width = 8;
2839 GLsizei height = 8;
2840
2841 ANGLE_GL_PROGRAM(program, vertexShader, fragmentShader);
2842 glUseProgram(program.get());
2843
2844 glViewport(0, 0, width, height);
2845
2846 GLint texLoc = glGetUniformLocation(program.get(), "tex");
2847 glUniform1i(texLoc, 0);
2848
2849 // Create textures and allocate storage
2850 GLTexture tex0;
2851 GLTexture tex1;
2852 GLRenderbuffer rb;
2853 FillTexture2D(tex0.get(), width, height, GLColor::black, 0, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE);
2854 FillTexture2D(tex1.get(), width, height, 0x80, 0, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT,
2855 GL_UNSIGNED_INT);
2856 glBindRenderbuffer(GL_RENDERBUFFER, rb.get());
2857 glRenderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX8, width, height);
2858 ASSERT_GL_NO_ERROR();
2859
2860 GLFramebuffer fbo;
2861 glBindFramebuffer(GL_FRAMEBUFFER, fbo.get());
2862 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex0.get(), 0);
2863
2864 // Test rendering and sampling feedback loop for depth buffer
2865 glBindTexture(GL_TEXTURE_2D, tex1.get());
2866 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, tex1.get(), 0);
2867 ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
2868
2869 // The same image is used as depth buffer during rendering.
2870 glEnable(GL_DEPTH_TEST);
2871 drawQuad(program.get(), "aPosition", 0.5f, 1.0f, true);
2872 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
2873
2874 // The same image is used as depth buffer. But depth mask is false.
2875 glDepthMask(GL_FALSE);
2876 drawQuad(program.get(), "aPosition", 0.5f, 1.0f, true);
2877 EXPECT_GL_NO_ERROR();
2878
2879 // The same image is used as depth buffer. But depth test is not enabled during rendering.
2880 glDepthMask(GL_TRUE);
2881 glDisable(GL_DEPTH_TEST);
2882 drawQuad(program.get(), "aPosition", 0.5f, 1.0f, true);
2883 EXPECT_GL_NO_ERROR();
2884
2885 // Test rendering and sampling feedback loop for stencil buffer
2886 glBindTexture(GL_RENDERBUFFER, rb.get());
2887 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
2888 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rb.get());
2889 ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
2890 constexpr GLint stencilClearValue = 0x40;
2891 glClearBufferiv(GL_STENCIL, 0, &stencilClearValue);
2892
2893 // The same image is used as stencil buffer during rendering.
2894 glEnable(GL_STENCIL_TEST);
2895 drawQuad(program.get(), "aPosition", 0.5f, 1.0f, true);
2896 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
2897
2898 // The same image is used as stencil buffer. But stencil mask is zero.
2899 glStencilMask(0x0);
2900 drawQuad(program.get(), "aPosition", 0.5f, 1.0f, true);
2901 EXPECT_GL_NO_ERROR();
2902
2903 // The same image is used as stencil buffer. But stencil test is not enabled during rendering.
2904 glStencilMask(0xffff);
2905 glDisable(GL_STENCIL_TEST);
2906 drawQuad(program.get(), "aPosition", 0.5f, 1.0f, true);
2907 EXPECT_GL_NO_ERROR();
2908}
2909
Jamie Madillfd3dd432017-02-02 19:59:59 -05002910// The source and the target for CopyTexSubImage3D are the same 3D texture.
2911// But the level of the 3D texture != the level of the read attachment.
2912TEST_P(WebGL2CompatibilityTest, NoTextureCopyingFeedbackLoopBetween3DLevels)
2913{
2914 GLTexture texture;
2915 GLFramebuffer framebuffer;
2916
2917 glBindTexture(GL_TEXTURE_3D, texture.get());
2918 glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.get());
2919
2920 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA8, 2, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
2921 glTexImage3D(GL_TEXTURE_3D, 1, GL_RGBA8, 2, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
2922 glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, texture.get(), 0, 0);
2923 ASSERT_GL_NO_ERROR();
2924
2925 glCopyTexSubImage3D(GL_TEXTURE_3D, 1, 0, 0, 0, 0, 0, 2, 2);
2926 EXPECT_GL_NO_ERROR();
2927}
2928
2929// The source and the target for CopyTexSubImage3D are the same 3D texture.
2930// But the zoffset of the 3D texture != the layer of the read attachment.
2931TEST_P(WebGL2CompatibilityTest, NoTextureCopyingFeedbackLoopBetween3DLayers)
2932{
2933 GLTexture texture;
2934 GLFramebuffer framebuffer;
2935
2936 glBindTexture(GL_TEXTURE_3D, texture.get());
2937 glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.get());
2938
2939 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA8, 2, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
2940 glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, texture.get(), 0, 1);
2941 ASSERT_GL_NO_ERROR();
2942
2943 glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 0, 0, 2, 2);
2944 EXPECT_GL_NO_ERROR();
2945}
2946
2947// The source and the target for CopyTexSubImage3D are the same 3D texture.
2948// And the level / zoffset of the 3D texture is equal to the level / layer of the read attachment.
2949TEST_P(WebGL2CompatibilityTest, TextureCopyingFeedbackLoop3D)
2950{
2951 GLTexture texture;
2952 GLFramebuffer framebuffer;
2953
2954 glBindTexture(GL_TEXTURE_3D, texture.get());
2955 glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.get());
2956
2957 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA8, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
2958 glTexImage3D(GL_TEXTURE_3D, 1, GL_RGBA8, 2, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
2959 glTexImage3D(GL_TEXTURE_3D, 2, GL_RGBA8, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
2960 glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, texture.get(), 1, 0);
2961 ASSERT_GL_NO_ERROR();
2962
2963 glCopyTexSubImage3D(GL_TEXTURE_3D, 1, 0, 0, 0, 0, 0, 2, 2);
2964 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
2965}
2966
Corentin Wallez59c41592017-07-11 13:19:54 -04002967// Verify that errors are generated when there isn't a defined conversion between the clear type and
2968// the buffer type.
Geoff Lang76e65652017-03-27 14:58:02 -04002969TEST_P(WebGL2CompatibilityTest, ClearBufferTypeCompatibity)
2970{
2971 if (IsD3D11())
2972 {
2973 std::cout << "Test skipped because it generates D3D11 runtime warnings." << std::endl;
2974 return;
2975 }
2976
2977 constexpr float clearFloat[] = {0.0f, 0.0f, 0.0f, 0.0f};
2978 constexpr int clearInt[] = {0, 0, 0, 0};
2979 constexpr unsigned int clearUint[] = {0, 0, 0, 0};
2980
2981 GLTexture texture;
2982 GLFramebuffer framebuffer;
2983
2984 glBindTexture(GL_TEXTURE_2D, texture.get());
2985 glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.get());
2986
2987 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture.get(), 0);
2988 ASSERT_GL_NO_ERROR();
2989
2990 // Unsigned integer buffer
2991 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32UI, 1, 1, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, nullptr);
2992 ASSERT_GL_NO_ERROR();
2993
2994 glClearBufferfv(GL_COLOR, 0, clearFloat);
2995 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
2996
2997 glClearBufferiv(GL_COLOR, 0, clearInt);
2998 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
2999
3000 glClearBufferuiv(GL_COLOR, 0, clearUint);
3001 EXPECT_GL_NO_ERROR();
3002
3003 glClear(GL_COLOR_BUFFER_BIT);
3004 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
3005
3006 // Integer buffer
3007 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32I, 1, 1, 0, GL_RGBA_INTEGER, GL_INT, nullptr);
3008 ASSERT_GL_NO_ERROR();
3009
3010 glClearBufferfv(GL_COLOR, 0, clearFloat);
3011 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
3012
3013 glClearBufferiv(GL_COLOR, 0, clearInt);
3014 EXPECT_GL_NO_ERROR();
3015
3016 glClearBufferuiv(GL_COLOR, 0, clearUint);
3017 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
3018
3019 glClear(GL_COLOR_BUFFER_BIT);
3020 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
3021
3022 // Float buffer
Geoff Lang677bb6f2017-04-05 12:40:40 -04003023 if (extensionRequestable("GL_EXT_color_buffer_float"))
3024 {
3025 glRequestExtensionANGLE("GL_EXT_color_buffer_float");
3026 }
Geoff Lang76e65652017-03-27 14:58:02 -04003027
Geoff Lang677bb6f2017-04-05 12:40:40 -04003028 if (extensionEnabled("GL_EXT_color_buffer_float"))
3029 {
3030 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, 1, 1, 0, GL_RGBA, GL_FLOAT, nullptr);
3031 ASSERT_GL_NO_ERROR();
Geoff Lang76e65652017-03-27 14:58:02 -04003032
Geoff Lang677bb6f2017-04-05 12:40:40 -04003033 glClearBufferfv(GL_COLOR, 0, clearFloat);
3034 EXPECT_GL_NO_ERROR();
Geoff Lang76e65652017-03-27 14:58:02 -04003035
Geoff Lang677bb6f2017-04-05 12:40:40 -04003036 glClearBufferiv(GL_COLOR, 0, clearInt);
3037 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
Geoff Lang76e65652017-03-27 14:58:02 -04003038
Geoff Lang677bb6f2017-04-05 12:40:40 -04003039 glClearBufferuiv(GL_COLOR, 0, clearUint);
3040 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
3041
3042 glClear(GL_COLOR_BUFFER_BIT);
3043 EXPECT_GL_NO_ERROR();
3044 }
Geoff Lang76e65652017-03-27 14:58:02 -04003045
3046 // Normalized uint buffer
3047 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
3048 ASSERT_GL_NO_ERROR();
3049
3050 glClearBufferfv(GL_COLOR, 0, clearFloat);
3051 EXPECT_GL_NO_ERROR();
3052
3053 glClearBufferiv(GL_COLOR, 0, clearInt);
3054 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
3055
3056 glClearBufferuiv(GL_COLOR, 0, clearUint);
3057 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
3058
3059 glClear(GL_COLOR_BUFFER_BIT);
3060 EXPECT_GL_NO_ERROR();
3061}
3062
Corentin Wallez59c41592017-07-11 13:19:54 -04003063// Test the interaction of WebGL compatibility clears with default framebuffers
3064TEST_P(WebGL2CompatibilityTest, ClearBufferDefaultFramebuffer)
3065{
3066 constexpr float clearFloat[] = {0.0f, 0.0f, 0.0f, 0.0f};
3067 constexpr int clearInt[] = {0, 0, 0, 0};
3068 constexpr unsigned int clearUint[] = {0, 0, 0, 0};
3069
3070 // glClear works as usual, this is also a regression test for a bug where we
3071 // iterated on maxDrawBuffers for default framebuffers, triggering an assert
3072 glClear(GL_COLOR_BUFFER_BIT);
3073 EXPECT_GL_NO_ERROR();
3074
3075 // Default framebuffers are normalized uints, so only glClearBufferfv works.
3076 glClearBufferfv(GL_COLOR, 0, clearFloat);
3077 EXPECT_GL_NO_ERROR();
3078
3079 glClearBufferiv(GL_COLOR, 0, clearInt);
3080 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
3081
3082 glClearBufferuiv(GL_COLOR, 0, clearUint);
3083 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
3084}
3085
Geoff Lange4915782017-04-12 15:19:07 -04003086// Verify that errors are generate when trying to blit from an image to itself
3087TEST_P(WebGL2CompatibilityTest, BlitFramebufferSameImage)
3088{
3089 GLTexture textures[2];
3090 glBindTexture(GL_TEXTURE_2D, textures[0]);
3091 glTexStorage2D(GL_TEXTURE_2D, 3, GL_RGBA8, 4, 4);
3092 glBindTexture(GL_TEXTURE_2D, textures[1]);
3093 glTexStorage2D(GL_TEXTURE_2D, 3, GL_RGBA8, 4, 4);
3094
3095 GLRenderbuffer renderbuffers[2];
3096 glBindRenderbuffer(GL_RENDERBUFFER, renderbuffers[0]);
3097 glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 4, 4);
3098 glBindRenderbuffer(GL_RENDERBUFFER, renderbuffers[1]);
3099 glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 4, 4);
3100
3101 GLFramebuffer framebuffers[2];
3102 glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffers[0]);
3103 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, framebuffers[1]);
3104
3105 ASSERT_GL_NO_ERROR();
3106
3107 // Same texture
3108 glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textures[0],
3109 0);
3110 glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textures[0],
3111 0);
3112 ASSERT_GL_NO_ERROR();
3113 glBlitFramebuffer(0, 0, 4, 4, 0, 0, 4, 4, GL_COLOR_BUFFER_BIT, GL_NEAREST);
3114 ASSERT_GL_ERROR(GL_INVALID_OPERATION);
3115
3116 // Same textures but different renderbuffers
3117 glFramebufferRenderbuffer(GL_READ_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER,
3118 renderbuffers[0]);
3119 glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER,
3120 renderbuffers[1]);
3121 ASSERT_GL_NO_ERROR();
3122 glBlitFramebuffer(0, 0, 4, 4, 0, 0, 4, 4, GL_DEPTH_BUFFER_BIT, GL_NEAREST);
3123 ASSERT_GL_NO_ERROR();
3124 glBlitFramebuffer(0, 0, 4, 4, 0, 0, 4, 4, GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT,
3125 GL_NEAREST);
3126 ASSERT_GL_NO_ERROR();
3127 glBlitFramebuffer(0, 0, 4, 4, 0, 0, 4, 4,
3128 GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT,
3129 GL_NEAREST);
3130 ASSERT_GL_ERROR(GL_INVALID_OPERATION);
3131
3132 // Same renderbuffers but different textures
3133 glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textures[0],
3134 0);
3135 glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textures[1],
3136 0);
3137 glFramebufferRenderbuffer(GL_READ_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER,
3138 renderbuffers[0]);
3139 glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER,
3140 renderbuffers[0]);
3141 ASSERT_GL_NO_ERROR();
3142 glBlitFramebuffer(0, 0, 4, 4, 0, 0, 4, 4, GL_COLOR_BUFFER_BIT, GL_NEAREST);
3143 ASSERT_GL_NO_ERROR();
3144 glBlitFramebuffer(0, 0, 4, 4, 0, 0, 4, 4, GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT,
3145 GL_NEAREST);
3146 ASSERT_GL_ERROR(GL_INVALID_OPERATION);
3147 glBlitFramebuffer(0, 0, 4, 4, 0, 0, 4, 4,
3148 GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT,
3149 GL_NEAREST);
3150 ASSERT_GL_ERROR(GL_INVALID_OPERATION);
3151}
3152
Geoff Lange0cff192017-05-30 13:04:56 -04003153// Verify that errors are generated when the fragment shader output doesn't match the bound color
3154// buffer types
3155TEST_P(WebGL2CompatibilityTest, FragmentShaderColorBufferTypeMissmatch)
3156{
3157 const std::string vertexShader =
3158 "#version 300 es\n"
3159 "void main() {\n"
3160 " gl_Position = vec4(0, 0, 0, 1);\n"
3161 "}\n";
3162
3163 const std::string fragmentShader =
3164 "#version 300 es\n"
3165 "precision mediump float;\n"
3166 "layout(location = 0) out vec4 floatOutput;\n"
3167 "layout(location = 1) out uvec4 uintOutput;\n"
3168 "layout(location = 2) out ivec4 intOutput;\n"
3169 "void main() {\n"
3170 " floatOutput = vec4(0, 0, 0, 1);\n"
3171 " uintOutput = uvec4(0, 0, 0, 1);\n"
3172 " intOutput = ivec4(0, 0, 0, 1);\n"
3173 "}\n";
3174
3175 ANGLE_GL_PROGRAM(program, vertexShader, fragmentShader);
3176 glUseProgram(program.get());
3177
3178 GLuint floatLocation = glGetFragDataLocation(program, "floatOutput");
3179 GLuint uintLocation = glGetFragDataLocation(program, "uintOutput");
3180 GLuint intLocation = glGetFragDataLocation(program, "intOutput");
3181
3182 GLFramebuffer fbo;
3183 glBindFramebuffer(GL_FRAMEBUFFER, fbo);
3184
3185 GLRenderbuffer floatRenderbuffer;
3186 glBindRenderbuffer(GL_RENDERBUFFER, floatRenderbuffer);
3187 glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, 1, 1);
3188 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + floatLocation, GL_RENDERBUFFER,
3189 floatRenderbuffer);
3190
3191 GLRenderbuffer uintRenderbuffer;
3192 glBindRenderbuffer(GL_RENDERBUFFER, uintRenderbuffer);
3193 glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8UI, 1, 1);
3194 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + uintLocation, GL_RENDERBUFFER,
3195 uintRenderbuffer);
3196
3197 GLRenderbuffer intRenderbuffer;
3198 glBindRenderbuffer(GL_RENDERBUFFER, intRenderbuffer);
3199 glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8I, 1, 1);
3200 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + intLocation, GL_RENDERBUFFER,
3201 intRenderbuffer);
3202
3203 ASSERT_GL_NO_ERROR();
3204
3205 GLint maxDrawBuffers = 0;
3206 glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
3207 std::vector<GLenum> drawBuffers(static_cast<size_t>(maxDrawBuffers), GL_NONE);
3208 drawBuffers[floatLocation] = GL_COLOR_ATTACHMENT0 + floatLocation;
3209 drawBuffers[uintLocation] = GL_COLOR_ATTACHMENT0 + uintLocation;
3210 drawBuffers[intLocation] = GL_COLOR_ATTACHMENT0 + intLocation;
3211
3212 glDrawBuffers(maxDrawBuffers, drawBuffers.data());
3213
3214 // Check that the correct case generates no errors
3215 glDrawArrays(GL_TRIANGLES, 0, 6);
3216 EXPECT_GL_NO_ERROR();
3217
3218 // Unbind some buffers and verify that there are still no errors
3219 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + uintLocation, GL_RENDERBUFFER,
3220 0);
3221 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + intLocation, GL_RENDERBUFFER,
3222 0);
3223 glDrawArrays(GL_TRIANGLES, 0, 6);
3224 EXPECT_GL_NO_ERROR();
3225
3226 // Swap the int and uint buffers to and verify that an error is generated
3227 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + uintLocation, GL_RENDERBUFFER,
3228 intRenderbuffer);
3229 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + intLocation, GL_RENDERBUFFER,
3230 uintRenderbuffer);
3231 glDrawArrays(GL_TRIANGLES, 0, 6);
3232 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
3233
3234 // Swap the float and uint buffers to and verify that an error is generated
3235 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + uintLocation, GL_RENDERBUFFER,
3236 floatRenderbuffer);
3237 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + floatLocation, GL_RENDERBUFFER,
3238 uintRenderbuffer);
3239 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + intLocation, GL_RENDERBUFFER,
3240 intRenderbuffer);
3241 glDrawArrays(GL_TRIANGLES, 0, 6);
3242 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
3243}
3244
Geoff Lang9ab5b822017-05-30 16:19:23 -04003245// Verify that errors are generated when the vertex shader intput doesn't match the bound attribute
3246// types
Corentin Wallezc3bc9842017-10-11 15:15:59 -04003247TEST_P(WebGL2CompatibilityTest, VertexShaderAttributeTypeMismatch)
Geoff Lang9ab5b822017-05-30 16:19:23 -04003248{
3249 const std::string vertexShader =
3250 "#version 300 es\n"
3251 "in vec4 floatInput;\n"
3252 "in uvec4 uintInput;\n"
3253 "in ivec4 intInput;\n"
3254 "void main() {\n"
3255 " gl_Position = vec4(floatInput.x, uintInput.x, intInput.x, 1);\n"
3256 "}\n";
3257
3258 const std::string fragmentShader =
3259 "#version 300 es\n"
3260 "precision mediump float;\n"
3261 "out vec4 outputColor;\n"
3262 "void main() {\n"
3263 " outputColor = vec4(0, 0, 0, 1);"
3264 "}\n";
3265
3266 ANGLE_GL_PROGRAM(program, vertexShader, fragmentShader);
3267 glUseProgram(program.get());
3268
3269 GLint floatLocation = glGetAttribLocation(program, "floatInput");
3270 GLint uintLocation = glGetAttribLocation(program, "uintInput");
3271 GLint intLocation = glGetAttribLocation(program, "intInput");
3272
3273 // Default attributes are of float types
3274 glDrawArrays(GL_TRIANGLES, 0, 6);
3275 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
3276
3277 // Set the default attributes to the correct types, should succeed
3278 glVertexAttribI4ui(uintLocation, 0, 0, 0, 1);
3279 glVertexAttribI4i(intLocation, 0, 0, 0, 1);
3280 glDrawArrays(GL_TRIANGLES, 0, 6);
3281 EXPECT_GL_NO_ERROR();
3282
3283 // Change the default float attribute to an integer, should fail
3284 glVertexAttribI4ui(floatLocation, 0, 0, 0, 1);
3285 glDrawArrays(GL_TRIANGLES, 0, 6);
3286 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
3287
3288 // Use a buffer for some attributes
3289 GLBuffer buffer;
3290 glBindBuffer(GL_ARRAY_BUFFER, buffer);
3291 glBufferData(GL_ARRAY_BUFFER, 1024, nullptr, GL_STATIC_DRAW);
3292 glEnableVertexAttribArray(floatLocation);
3293 glVertexAttribPointer(floatLocation, 4, GL_FLOAT, GL_FALSE, 0, nullptr);
3294 glDrawArrays(GL_TRIANGLES, 0, 6);
3295 EXPECT_GL_NO_ERROR();
3296
3297 // Use a float pointer attrib for a uint input
3298 glEnableVertexAttribArray(uintLocation);
3299 glVertexAttribPointer(uintLocation, 4, GL_FLOAT, GL_FALSE, 0, nullptr);
3300 glDrawArrays(GL_TRIANGLES, 0, 6);
3301 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
3302
3303 // Use a uint pointer for the uint input
3304 glVertexAttribIPointer(uintLocation, 4, GL_UNSIGNED_INT, 0, nullptr);
3305 glDrawArrays(GL_TRIANGLES, 0, 6);
3306 EXPECT_GL_NO_ERROR();
3307}
3308
Corentin Walleze7557742017-06-01 13:09:57 -04003309// Tests the WebGL removal of undefined behavior when attachments aren't written to.
3310TEST_P(WebGLCompatibilityTest, DrawBuffers)
3311{
Corentin Walleze7557742017-06-01 13:09:57 -04003312 // Make sure we can use at least 4 attachments for the tests.
3313 bool useEXT = false;
3314 if (getClientMajorVersion() < 3)
3315 {
3316 if (!extensionRequestable("GL_EXT_draw_buffers"))
3317 {
3318 std::cout << "Test skipped because draw buffers are not available" << std::endl;
3319 return;
3320 }
3321
3322 glRequestExtensionANGLE("GL_EXT_draw_buffers");
3323 useEXT = true;
3324 EXPECT_GL_NO_ERROR();
3325 }
3326
3327 GLint maxDrawBuffers = 0;
3328 glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
3329 if (maxDrawBuffers < 4)
3330 {
3331 std::cout << "Test skipped because MAX_DRAW_BUFFERS is too small." << std::endl;
3332 return;
3333 }
3334
3335 // Clears all the renderbuffers to red.
3336 auto ClearEverythingToRed = [](GLRenderbuffer *renderbuffers) {
3337 GLFramebuffer clearFBO;
3338 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, clearFBO);
3339
3340 glClearColor(1, 0, 0, 1);
3341 for (int i = 0; i < 4; ++i)
3342 {
3343 glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER,
3344 renderbuffers[i]);
3345 glClear(GL_COLOR_BUFFER_BIT);
3346 }
3347 ASSERT_GL_NO_ERROR();
3348 };
3349
3350 // Checks that the renderbuffers specified by mask have the correct color
3351 auto CheckColors = [](GLRenderbuffer *renderbuffers, int mask, GLColor color) {
3352 GLFramebuffer readFBO;
3353 glBindFramebuffer(GL_READ_FRAMEBUFFER, readFBO);
3354
3355 for (int i = 0; i < 4; ++i)
3356 {
3357 if (mask & (1 << i))
3358 {
3359 glFramebufferRenderbuffer(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
3360 GL_RENDERBUFFER, renderbuffers[i]);
3361 EXPECT_PIXEL_COLOR_EQ(0, 0, color);
3362 }
3363 }
3364 ASSERT_GL_NO_ERROR();
3365 };
3366
3367 // Depending on whether we are using the extension or ES3, a different entrypoint must be called
3368 auto DrawBuffers = [](bool useEXT, int numBuffers, GLenum *buffers) {
3369 if (useEXT)
3370 {
3371 glDrawBuffersEXT(numBuffers, buffers);
3372 }
3373 else
3374 {
3375 glDrawBuffers(numBuffers, buffers);
3376 }
3377 };
3378
3379 // Initialized the test framebuffer
3380 GLFramebuffer drawFBO;
3381 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, drawFBO);
3382
3383 GLRenderbuffer renderbuffers[4];
3384 for (int i = 0; i < 4; ++i)
3385 {
3386 glBindRenderbuffer(GL_RENDERBUFFER, renderbuffers[i]);
Geoff Langd84a00b2017-10-27 17:27:26 -04003387 glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA4, 1, 1);
Corentin Walleze7557742017-06-01 13:09:57 -04003388 glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, GL_RENDERBUFFER,
3389 renderbuffers[i]);
3390 }
3391
3392 ASSERT_GL_NO_ERROR();
3393
3394 const char *vertESSL1 =
3395 "attribute vec4 a_pos;\n"
3396 "void main()\n"
3397 "{\n"
3398 " gl_Position = a_pos;\n"
3399 "}\n";
3400 const char *vertESSL3 =
3401 "#version 300 es\n"
3402 "in vec4 a_pos;\n"
3403 "void main()\n"
3404 "{\n"
3405 " gl_Position = a_pos;\n"
3406 "}\n";
3407
3408 GLenum allDrawBuffers[] = {
3409 GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2, GL_COLOR_ATTACHMENT3,
3410 };
3411
3412 GLenum halfDrawBuffers[] = {
3413 GL_NONE, GL_NONE, GL_COLOR_ATTACHMENT2, GL_COLOR_ATTACHMENT3,
3414 };
3415
3416 // Test that when using gl_FragColor, only the first attachment is written to.
3417 const char *fragESSL1 =
3418 "precision highp float;\n"
3419 "void main()\n"
3420 "{\n"
3421 " gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);\n"
3422 "}\n";
3423 ANGLE_GL_PROGRAM(programESSL1, vertESSL1, fragESSL1);
3424
3425 {
3426 ClearEverythingToRed(renderbuffers);
3427
3428 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, drawFBO);
3429 DrawBuffers(useEXT, 4, allDrawBuffers);
3430 drawQuad(programESSL1, "a_pos", 0.5, 1.0, true);
3431 ASSERT_GL_NO_ERROR();
3432
3433 CheckColors(renderbuffers, 0b0001, GLColor::green);
3434 CheckColors(renderbuffers, 0b1110, GLColor::red);
3435 }
3436
3437 // Test that when using gl_FragColor, but the first draw buffer is 0, then no attachment is
3438 // written to.
3439 {
3440 ClearEverythingToRed(renderbuffers);
3441
3442 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, drawFBO);
3443 DrawBuffers(useEXT, 4, halfDrawBuffers);
3444 drawQuad(programESSL1, "a_pos", 0.5, 1.0, true);
3445 ASSERT_GL_NO_ERROR();
3446
3447 CheckColors(renderbuffers, 0b1111, GLColor::red);
3448 }
3449
3450 // Test what happens when rendering to a subset of the outputs. There is a behavior difference
3451 // between the extension and ES3. In the extension gl_FragData is implicitly declared as an
3452 // array of size MAX_DRAW_BUFFERS, so the WebGL spec stipulates that elements not written to
3453 // should default to 0. On the contrary, in ES3 outputs are specified one by one, so
3454 // attachments not declared in the shader should not be written to.
3455 const char *writeOddOutputsVert;
3456 const char *writeOddOutputsFrag;
3457 GLColor unwrittenColor;
3458 if (useEXT)
3459 {
3460 // In the extension, when an attachment isn't written to, it should get 0's
3461 unwrittenColor = GLColor(0, 0, 0, 0);
3462 writeOddOutputsVert = vertESSL1;
3463 writeOddOutputsFrag =
3464 "#extension GL_EXT_draw_buffers : require\n"
3465 "precision highp float;\n"
3466 "void main()\n"
3467 "{\n"
3468 " gl_FragData[1] = vec4(0.0, 1.0, 0.0, 1.0);\n"
3469 " gl_FragData[3] = vec4(0.0, 1.0, 0.0, 1.0);\n"
3470 "}\n";
3471 }
3472 else
3473 {
3474 // In ES3 if an attachment isn't declared, it shouldn't get written and should be red
3475 // because of the preceding clears.
3476 unwrittenColor = GLColor::red;
3477 writeOddOutputsVert = vertESSL3;
3478 writeOddOutputsFrag =
3479 "#version 300 es\n"
3480 "precision highp float;\n"
3481 "layout(location = 1) out vec4 output1;"
3482 "layout(location = 3) out vec4 output2;"
3483 "void main()\n"
3484 "{\n"
3485 " output1 = vec4(0.0, 1.0, 0.0, 1.0);\n"
3486 " output2 = vec4(0.0, 1.0, 0.0, 1.0);\n"
3487 "}\n";
3488 }
3489 ANGLE_GL_PROGRAM(writeOddOutputsProgram, writeOddOutputsVert, writeOddOutputsFrag);
3490
3491 // Test that attachments not written to get the "unwritten" color
3492 {
3493 ClearEverythingToRed(renderbuffers);
3494
3495 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, drawFBO);
3496 DrawBuffers(useEXT, 4, allDrawBuffers);
3497 drawQuad(writeOddOutputsProgram, "a_pos", 0.5, 1.0, true);
3498 ASSERT_GL_NO_ERROR();
3499
3500 CheckColors(renderbuffers, 0b1010, GLColor::green);
3501 CheckColors(renderbuffers, 0b0101, unwrittenColor);
3502 }
3503
3504 // Test that attachments not written to get the "unwritten" color but that even when the
3505 // extension is used, disabled attachments are not written at all and stay red.
3506 {
3507 ClearEverythingToRed(renderbuffers);
3508
3509 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, drawFBO);
3510 DrawBuffers(useEXT, 4, halfDrawBuffers);
3511 drawQuad(writeOddOutputsProgram, "a_pos", 0.5, 1.0, true);
3512 ASSERT_GL_NO_ERROR();
3513
3514 CheckColors(renderbuffers, 0b1000, GLColor::green);
3515 CheckColors(renderbuffers, 0b0100, unwrittenColor);
3516 CheckColors(renderbuffers, 0b0011, GLColor::red);
3517 }
3518}
3519
Geoff Lang536eca12017-09-13 11:23:35 -04003520// Test that it's possible to generate mipmaps on unsized floating point textures once the
3521// extensions have been enabled
3522TEST_P(WebGLCompatibilityTest, GenerateMipmapUnsizedFloatingPointTexture)
3523{
3524 if (extensionRequestable("GL_OES_texture_float"))
3525 {
3526 glRequestExtensionANGLE("GL_OES_texture_float");
3527 }
3528 ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_OES_texture_float"));
3529
3530 GLTexture texture;
3531 glBindTexture(GL_TEXTURE_2D, texture);
3532
3533 constexpr GLColor32F data[4] = {
3534 kFloatRed, kFloatRed, kFloatGreen, kFloatBlue,
3535 };
3536 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_FLOAT, data);
3537 ASSERT_GL_NO_ERROR();
3538
3539 glGenerateMipmap(GL_TEXTURE_2D);
3540 EXPECT_GL_NO_ERROR();
3541}
3542// Test that it's possible to generate mipmaps on unsized floating point textures once the
3543// extensions have been enabled
3544TEST_P(WebGLCompatibilityTest, GenerateMipmapSizedFloatingPointTexture)
3545{
3546 if (extensionRequestable("GL_OES_texture_float"))
3547 {
3548 glRequestExtensionANGLE("GL_OES_texture_float");
3549 }
3550 ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_OES_texture_float"));
3551
3552 if (extensionRequestable("GL_EXT_texture_storage"))
3553 {
3554 glRequestExtensionANGLE("GL_EXT_texture_storage");
3555 }
3556 ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_EXT_texture_storage"));
3557
3558 GLTexture texture;
3559 glBindTexture(GL_TEXTURE_2D, texture);
3560
3561 constexpr GLColor32F data[4] = {
3562 kFloatRed, kFloatRed, kFloatGreen, kFloatBlue,
3563 };
3564 glTexStorage2DEXT(GL_TEXTURE_2D, 2, GL_RGBA32F, 2, 2);
3565 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 2, 2, GL_RGBA, GL_FLOAT, data);
3566 ASSERT_GL_NO_ERROR();
3567
3568 glGenerateMipmap(GL_TEXTURE_2D);
3569 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
3570
3571 if (extensionRequestable("GL_EXT_color_buffer_float"))
3572 {
3573 // Format is renderable but not filterable
3574 glRequestExtensionANGLE("GL_EXT_color_buffer_float");
3575 glGenerateMipmap(GL_TEXTURE_2D);
3576 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
3577 }
3578
3579 if (extensionRequestable("GL_EXT_color_buffer_float_linear"))
3580 {
3581 // Format is renderable but not filterable
3582 glRequestExtensionANGLE("GL_EXT_color_buffer_float_linear");
3583
3584 if (extensionEnabled("GL_EXT_color_buffer_float"))
3585 {
3586 // Format is filterable and renderable
3587 glGenerateMipmap(GL_TEXTURE_2D);
3588 EXPECT_GL_NO_ERROR();
3589 }
3590 else
3591 {
3592 // Format is filterable but not renderable
3593 glGenerateMipmap(GL_TEXTURE_2D);
3594 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
3595 }
3596 }
3597}
3598
Bryan Bernhart (Intel Americas Inc)2a357412017-09-05 10:42:47 -07003599// Verify that a texture format is only allowed with extension enabled.
3600void WebGLCompatibilityTest::validateTexImageExtensionFormat(GLenum format,
3601 const std::string &extName)
3602{
3603 // Verify texture format fails by default.
3604 glTexImage2D(GL_TEXTURE_2D, 0, format, 1, 1, 0, format, GL_UNSIGNED_BYTE, nullptr);
3605 EXPECT_GL_ERROR(GL_INVALID_ENUM);
3606
3607 if (extensionRequestable(extName))
3608 {
3609 // Verify texture format is allowed once extension is enabled.
3610 glRequestExtensionANGLE(extName.c_str());
3611 EXPECT_TRUE(extensionEnabled(extName));
3612
3613 glTexImage2D(GL_TEXTURE_2D, 0, format, 1, 1, 0, format, GL_UNSIGNED_BYTE, nullptr);
3614 ASSERT_GL_NO_ERROR();
3615 }
3616}
3617
3618// Verify that only valid texture formats are allowed.
3619TEST_P(WebGLCompatibilityTest, InvalidTextureFormat)
3620{
3621 ANGLE_SKIP_TEST_IF(getClientMajorVersion() != 2);
3622
3623 GLTexture texture;
3624 glBindTexture(GL_TEXTURE_2D, texture.get());
3625
3626 // Verify valid format is allowed.
3627 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
3628 ASSERT_GL_NO_ERROR();
3629
3630 // Verify invalid format fails.
3631 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, 1, 1, 0, GL_RGBA32F, GL_UNSIGNED_BYTE, nullptr);
3632 EXPECT_GL_ERROR(GL_INVALID_ENUM);
3633
3634 // Verify formats from enableable extensions.
Geoff Lang660b28c2017-10-30 12:58:56 -04003635 if (!IsOpenGLES())
Bryan Bernhart (Intel Americas Inc)2a357412017-09-05 10:42:47 -07003636 {
3637 validateTexImageExtensionFormat(GL_RED_EXT, "GL_EXT_texture_rg");
3638 }
3639
3640 validateTexImageExtensionFormat(GL_SRGB_EXT, "GL_EXT_texture_sRGB");
3641 validateTexImageExtensionFormat(GL_BGRA_EXT, "GL_EXT_texture_format_BGRA8888");
3642}
3643
Frank Henigmanfccbac22017-05-28 17:29:26 -04003644// Linking should fail when corresponding vertex/fragment uniform blocks have different precision
3645// qualifiers.
3646TEST_P(WebGL2CompatibilityTest, UniformBlockPrecisionMismatch)
3647{
3648 const std::string vertexShader =
3649 "#version 300 es\n"
3650 "uniform Block { mediump vec4 val; };\n"
3651 "void main() { gl_Position = val; }\n";
3652 const std::string fragmentShader =
3653 "#version 300 es\n"
3654 "uniform Block { highp vec4 val; };\n"
3655 "out highp vec4 out_FragColor;\n"
3656 "void main() { out_FragColor = val; }\n";
3657
3658 GLuint vs = CompileShader(GL_VERTEX_SHADER, vertexShader);
3659 ASSERT_NE(0u, vs);
3660 GLuint fs = CompileShader(GL_FRAGMENT_SHADER, fragmentShader);
3661 ASSERT_NE(0u, fs);
3662
3663 GLuint program = glCreateProgram();
3664
3665 glAttachShader(program, vs);
3666 glDeleteShader(vs);
3667 glAttachShader(program, fs);
3668 glDeleteShader(fs);
3669
3670 glLinkProgram(program);
3671 GLint linkStatus;
3672 glGetProgramiv(program, GL_LINK_STATUS, &linkStatus);
3673 ASSERT_EQ(0, linkStatus);
3674
3675 glDeleteProgram(program);
3676}
3677
Geoff Lang69df2422017-07-05 12:42:31 -04003678// Test no attribute vertex shaders
3679TEST_P(WebGL2CompatibilityTest, NoAttributeVertexShader)
3680{
3681 const std::string vertexShader =
3682 "#version 300 es\n"
3683 "void main()\n"
3684 "{\n"
3685 "\n"
3686 " ivec2 xy = ivec2(gl_VertexID % 2, (gl_VertexID / 2 + gl_VertexID / 3) % 2);\n"
3687 " gl_Position = vec4(vec2(xy) * 2. - 1., 0, 1);\n"
3688 "}";
3689 const std::string fragmentShader =
3690 "#version 300 es\n"
3691 "precision mediump float;\n"
3692 "out vec4 result;\n"
3693 "void main()\n"
3694 "{\n"
3695 " result = vec4(0, 1, 0, 1);\n"
3696 "}";
3697
3698 ANGLE_GL_PROGRAM(program, vertexShader, fragmentShader);
3699 glUseProgram(program);
3700
3701 glDrawArrays(GL_TRIANGLES, 0, 6);
3702 ASSERT_GL_NO_ERROR();
3703 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
3704}
3705
Brandon Jonesed5b46f2017-07-21 08:39:17 -07003706// Tests bindAttribLocations for length limit
3707TEST_P(WebGL2CompatibilityTest, BindAttribLocationLimitation)
3708{
3709 constexpr int maxLocStringLength = 1024;
3710 const std::string tooLongString(maxLocStringLength + 1, '_');
3711
3712 glBindAttribLocation(0, 0, static_cast<const GLchar *>(tooLongString.c_str()));
3713
3714 EXPECT_GL_ERROR(GL_INVALID_VALUE);
3715}
3716
Geoff Langc287ea62016-09-16 14:46:51 -04003717// Use this to select which configurations (e.g. which renderer, which GLES major version) these
3718// tests should be run against.
3719ANGLE_INSTANTIATE_TEST(WebGLCompatibilityTest,
3720 ES2_D3D9(),
3721 ES2_D3D11(),
3722 ES3_D3D11(),
Geoff Langc287ea62016-09-16 14:46:51 -04003723 ES2_OPENGL(),
3724 ES3_OPENGL(),
3725 ES2_OPENGLES(),
3726 ES3_OPENGLES());
3727
Jamie Madill07be8bf2017-02-02 19:59:57 -05003728ANGLE_INSTANTIATE_TEST(WebGL2CompatibilityTest, ES3_D3D11(), ES3_OPENGL(), ES3_OPENGLES());
Geoff Langc287ea62016-09-16 14:46:51 -04003729} // namespace