1// Copyright 2015 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// https://www.khronos.org/registry/webgl/specs/latest/2.0/#3.7
6
7typedef long long GLint64;
8typedef unsigned long long GLuint64;
9
10interface mixin WebGL2RenderingContextBase {
11    const GLenum READ_BUFFER                                   = 0x0C02;
12    const GLenum UNPACK_ROW_LENGTH                             = 0x0CF2;
13    const GLenum UNPACK_SKIP_ROWS                              = 0x0CF3;
14    const GLenum UNPACK_SKIP_PIXELS                            = 0x0CF4;
15    const GLenum PACK_ROW_LENGTH                               = 0x0D02;
16    const GLenum PACK_SKIP_ROWS                                = 0x0D03;
17    const GLenum PACK_SKIP_PIXELS                              = 0x0D04;
18    const GLenum COLOR                                         = 0x1800;
19    const GLenum DEPTH                                         = 0x1801;
20    const GLenum STENCIL                                       = 0x1802;
21    const GLenum RED                                           = 0x1903;
22    const GLenum RGB8                                          = 0x8051;
23    const GLenum RGBA8                                         = 0x8058;
24    const GLenum RGB10_A2                                      = 0x8059;
25    const GLenum TEXTURE_BINDING_3D                            = 0x806A;
26    const GLenum UNPACK_SKIP_IMAGES                            = 0x806D;
27    const GLenum UNPACK_IMAGE_HEIGHT                           = 0x806E;
28    const GLenum TEXTURE_3D                                    = 0x806F;
29    const GLenum TEXTURE_WRAP_R                                = 0x8072;
30    const GLenum MAX_3D_TEXTURE_SIZE                           = 0x8073;
31    const GLenum UNSIGNED_INT_2_10_10_10_REV                   = 0x8368;
32    const GLenum MAX_ELEMENTS_VERTICES                         = 0x80E8;
33    const GLenum MAX_ELEMENTS_INDICES                          = 0x80E9;
34    const GLenum TEXTURE_MIN_LOD                               = 0x813A;
35    const GLenum TEXTURE_MAX_LOD                               = 0x813B;
36    const GLenum TEXTURE_BASE_LEVEL                            = 0x813C;
37    const GLenum TEXTURE_MAX_LEVEL                             = 0x813D;
38    const GLenum MIN                                           = 0x8007;
39    const GLenum MAX                                           = 0x8008;
40    const GLenum DEPTH_COMPONENT24                             = 0x81A6;
41    const GLenum MAX_TEXTURE_LOD_BIAS                          = 0x84FD;
42    const GLenum TEXTURE_COMPARE_MODE                          = 0x884C;
43    const GLenum TEXTURE_COMPARE_FUNC                          = 0x884D;
44    const GLenum CURRENT_QUERY                                 = 0x8865;
45    const GLenum QUERY_RESULT                                  = 0x8866;
46    const GLenum QUERY_RESULT_AVAILABLE                        = 0x8867;
47    const GLenum STREAM_READ                                   = 0x88E1;
48    const GLenum STREAM_COPY                                   = 0x88E2;
49    const GLenum STATIC_READ                                   = 0x88E5;
50    const GLenum STATIC_COPY                                   = 0x88E6;
51    const GLenum DYNAMIC_READ                                  = 0x88E9;
52    const GLenum DYNAMIC_COPY                                  = 0x88EA;
53    const GLenum MAX_DRAW_BUFFERS                              = 0x8824;
54    const GLenum DRAW_BUFFER0                                  = 0x8825;
55    const GLenum DRAW_BUFFER1                                  = 0x8826;
56    const GLenum DRAW_BUFFER2                                  = 0x8827;
57    const GLenum DRAW_BUFFER3                                  = 0x8828;
58    const GLenum DRAW_BUFFER4                                  = 0x8829;
59    const GLenum DRAW_BUFFER5                                  = 0x882A;
60    const GLenum DRAW_BUFFER6                                  = 0x882B;
61    const GLenum DRAW_BUFFER7                                  = 0x882C;
62    const GLenum DRAW_BUFFER8                                  = 0x882D;
63    const GLenum DRAW_BUFFER9                                  = 0x882E;
64    const GLenum DRAW_BUFFER10                                 = 0x882F;
65    const GLenum DRAW_BUFFER11                                 = 0x8830;
66    const GLenum DRAW_BUFFER12                                 = 0x8831;
67    const GLenum DRAW_BUFFER13                                 = 0x8832;
68    const GLenum DRAW_BUFFER14                                 = 0x8833;
69    const GLenum DRAW_BUFFER15                                 = 0x8834;
70    const GLenum MAX_FRAGMENT_UNIFORM_COMPONENTS               = 0x8B49;
71    const GLenum MAX_VERTEX_UNIFORM_COMPONENTS                 = 0x8B4A;
72    const GLenum SAMPLER_3D                                    = 0x8B5F;
73    const GLenum SAMPLER_2D_SHADOW                             = 0x8B62;
74    const GLenum FRAGMENT_SHADER_DERIVATIVE_HINT               = 0x8B8B;
75    const GLenum PIXEL_PACK_BUFFER                             = 0x88EB;
76    const GLenum PIXEL_UNPACK_BUFFER                           = 0x88EC;
77    const GLenum PIXEL_PACK_BUFFER_BINDING                     = 0x88ED;
78    const GLenum PIXEL_UNPACK_BUFFER_BINDING                   = 0x88EF;
79    const GLenum FLOAT_MAT2x3                                  = 0x8B65;
80    const GLenum FLOAT_MAT2x4                                  = 0x8B66;
81    const GLenum FLOAT_MAT3x2                                  = 0x8B67;
82    const GLenum FLOAT_MAT3x4                                  = 0x8B68;
83    const GLenum FLOAT_MAT4x2                                  = 0x8B69;
84    const GLenum FLOAT_MAT4x3                                  = 0x8B6A;
85    const GLenum SRGB                                          = 0x8C40;
86    const GLenum SRGB8                                         = 0x8C41;
87    const GLenum SRGB8_ALPHA8                                  = 0x8C43;
88    const GLenum COMPARE_REF_TO_TEXTURE                        = 0x884E;
89    const GLenum RGBA32F                                       = 0x8814;
90    const GLenum RGB32F                                        = 0x8815;
91    const GLenum RGBA16F                                       = 0x881A;
92    const GLenum RGB16F                                        = 0x881B;
93    const GLenum VERTEX_ATTRIB_ARRAY_INTEGER                   = 0x88FD;
94    const GLenum MAX_ARRAY_TEXTURE_LAYERS                      = 0x88FF;
95    const GLenum MIN_PROGRAM_TEXEL_OFFSET                      = 0x8904;
96    const GLenum MAX_PROGRAM_TEXEL_OFFSET                      = 0x8905;
97    const GLenum MAX_VARYING_COMPONENTS                        = 0x8B4B;
98    const GLenum TEXTURE_2D_ARRAY                              = 0x8C1A;
99    const GLenum TEXTURE_BINDING_2D_ARRAY                      = 0x8C1D;
100    const GLenum R11F_G11F_B10F                                = 0x8C3A;
101    const GLenum UNSIGNED_INT_10F_11F_11F_REV                  = 0x8C3B;
102    const GLenum RGB9_E5                                       = 0x8C3D;
103    const GLenum UNSIGNED_INT_5_9_9_9_REV                      = 0x8C3E;
104    const GLenum TRANSFORM_FEEDBACK_BUFFER_MODE                = 0x8C7F;
105    const GLenum MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS    = 0x8C80;
106    const GLenum TRANSFORM_FEEDBACK_VARYINGS                   = 0x8C83;
107    const GLenum TRANSFORM_FEEDBACK_BUFFER_START               = 0x8C84;
108    const GLenum TRANSFORM_FEEDBACK_BUFFER_SIZE                = 0x8C85;
109    const GLenum TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN         = 0x8C88;
110    const GLenum RASTERIZER_DISCARD                            = 0x8C89;
111    const GLenum MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS = 0x8C8A;
112    const GLenum MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS       = 0x8C8B;
113    const GLenum INTERLEAVED_ATTRIBS                           = 0x8C8C;
114    const GLenum SEPARATE_ATTRIBS                              = 0x8C8D;
115    const GLenum TRANSFORM_FEEDBACK_BUFFER                     = 0x8C8E;
116    const GLenum TRANSFORM_FEEDBACK_BUFFER_BINDING             = 0x8C8F;
117    const GLenum RGBA32UI                                      = 0x8D70;
118    const GLenum RGB32UI                                       = 0x8D71;
119    const GLenum RGBA16UI                                      = 0x8D76;
120    const GLenum RGB16UI                                       = 0x8D77;
121    const GLenum RGBA8UI                                       = 0x8D7C;
122    const GLenum RGB8UI                                        = 0x8D7D;
123    const GLenum RGBA32I                                       = 0x8D82;
124    const GLenum RGB32I                                        = 0x8D83;
125    const GLenum RGBA16I                                       = 0x8D88;
126    const GLenum RGB16I                                        = 0x8D89;
127    const GLenum RGBA8I                                        = 0x8D8E;
128    const GLenum RGB8I                                         = 0x8D8F;
129    const GLenum RED_INTEGER                                   = 0x8D94;
130    const GLenum RGB_INTEGER                                   = 0x8D98;
131    const GLenum RGBA_INTEGER                                  = 0x8D99;
132    const GLenum SAMPLER_2D_ARRAY                              = 0x8DC1;
133    const GLenum SAMPLER_2D_ARRAY_SHADOW                       = 0x8DC4;
134    const GLenum SAMPLER_CUBE_SHADOW                           = 0x8DC5;
135    const GLenum UNSIGNED_INT_VEC2                             = 0x8DC6;
136    const GLenum UNSIGNED_INT_VEC3                             = 0x8DC7;
137    const GLenum UNSIGNED_INT_VEC4                             = 0x8DC8;
138    const GLenum INT_SAMPLER_2D                                = 0x8DCA;
139    const GLenum INT_SAMPLER_3D                                = 0x8DCB;
140    const GLenum INT_SAMPLER_CUBE                              = 0x8DCC;
141    const GLenum INT_SAMPLER_2D_ARRAY                          = 0x8DCF;
142    const GLenum UNSIGNED_INT_SAMPLER_2D                       = 0x8DD2;
143    const GLenum UNSIGNED_INT_SAMPLER_3D                       = 0x8DD3;
144    const GLenum UNSIGNED_INT_SAMPLER_CUBE                     = 0x8DD4;
145    const GLenum UNSIGNED_INT_SAMPLER_2D_ARRAY                 = 0x8DD7;
146    const GLenum DEPTH_COMPONENT32F                            = 0x8CAC;
147    const GLenum DEPTH32F_STENCIL8                             = 0x8CAD;
148    const GLenum FLOAT_32_UNSIGNED_INT_24_8_REV                = 0x8DAD;
149    const GLenum FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING         = 0x8210;
150    const GLenum FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE         = 0x8211;
151    const GLenum FRAMEBUFFER_ATTACHMENT_RED_SIZE               = 0x8212;
152    const GLenum FRAMEBUFFER_ATTACHMENT_GREEN_SIZE             = 0x8213;
153    const GLenum FRAMEBUFFER_ATTACHMENT_BLUE_SIZE              = 0x8214;
154    const GLenum FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE             = 0x8215;
155    const GLenum FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE             = 0x8216;
156    const GLenum FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE           = 0x8217;
157    const GLenum FRAMEBUFFER_DEFAULT                           = 0x8218;
158    const GLenum UNSIGNED_INT_24_8                             = 0x84FA;
159    const GLenum DEPTH24_STENCIL8                              = 0x88F0;
160    const GLenum UNSIGNED_NORMALIZED                           = 0x8C17;
161    const GLenum DRAW_FRAMEBUFFER_BINDING                      = 0x8CA6; /* Same as FRAMEBUFFER_BINDING */
162    const GLenum READ_FRAMEBUFFER                              = 0x8CA8;
163    const GLenum DRAW_FRAMEBUFFER                              = 0x8CA9;
164    const GLenum READ_FRAMEBUFFER_BINDING                      = 0x8CAA;
165    const GLenum RENDERBUFFER_SAMPLES                          = 0x8CAB;
166    const GLenum FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER          = 0x8CD4;
167    const GLenum MAX_COLOR_ATTACHMENTS                         = 0x8CDF;
168    const GLenum COLOR_ATTACHMENT1                             = 0x8CE1;
169    const GLenum COLOR_ATTACHMENT2                             = 0x8CE2;
170    const GLenum COLOR_ATTACHMENT3                             = 0x8CE3;
171    const GLenum COLOR_ATTACHMENT4                             = 0x8CE4;
172    const GLenum COLOR_ATTACHMENT5                             = 0x8CE5;
173    const GLenum COLOR_ATTACHMENT6                             = 0x8CE6;
174    const GLenum COLOR_ATTACHMENT7                             = 0x8CE7;
175    const GLenum COLOR_ATTACHMENT8                             = 0x8CE8;
176    const GLenum COLOR_ATTACHMENT9                             = 0x8CE9;
177    const GLenum COLOR_ATTACHMENT10                            = 0x8CEA;
178    const GLenum COLOR_ATTACHMENT11                            = 0x8CEB;
179    const GLenum COLOR_ATTACHMENT12                            = 0x8CEC;
180    const GLenum COLOR_ATTACHMENT13                            = 0x8CED;
181    const GLenum COLOR_ATTACHMENT14                            = 0x8CEE;
182    const GLenum COLOR_ATTACHMENT15                            = 0x8CEF;
183    const GLenum FRAMEBUFFER_INCOMPLETE_MULTISAMPLE            = 0x8D56;
184    const GLenum MAX_SAMPLES                                   = 0x8D57;
185    const GLenum HALF_FLOAT                                    = 0x140B;
186    const GLenum RG                                            = 0x8227;
187    const GLenum RG_INTEGER                                    = 0x8228;
188    const GLenum R8                                            = 0x8229;
189    const GLenum RG8                                           = 0x822B;
190    const GLenum R16F                                          = 0x822D;
191    const GLenum R32F                                          = 0x822E;
192    const GLenum RG16F                                         = 0x822F;
193    const GLenum RG32F                                         = 0x8230;
194    const GLenum R8I                                           = 0x8231;
195    const GLenum R8UI                                          = 0x8232;
196    const GLenum R16I                                          = 0x8233;
197    const GLenum R16UI                                         = 0x8234;
198    const GLenum R32I                                          = 0x8235;
199    const GLenum R32UI                                         = 0x8236;
200    const GLenum RG8I                                          = 0x8237;
201    const GLenum RG8UI                                         = 0x8238;
202    const GLenum RG16I                                         = 0x8239;
203    const GLenum RG16UI                                        = 0x823A;
204    const GLenum RG32I                                         = 0x823B;
205    const GLenum RG32UI                                        = 0x823C;
206    const GLenum VERTEX_ARRAY_BINDING                          = 0x85B5;
207    const GLenum R8_SNORM                                      = 0x8F94;
208    const GLenum RG8_SNORM                                     = 0x8F95;
209    const GLenum RGB8_SNORM                                    = 0x8F96;
210    const GLenum RGBA8_SNORM                                   = 0x8F97;
211    const GLenum SIGNED_NORMALIZED                             = 0x8F9C;
212    const GLenum COPY_READ_BUFFER                              = 0x8F36;
213    const GLenum COPY_WRITE_BUFFER                             = 0x8F37;
214    const GLenum COPY_READ_BUFFER_BINDING                      = 0x8F36; /* Same as COPY_READ_BUFFER */
215    const GLenum COPY_WRITE_BUFFER_BINDING                     = 0x8F37; /* Same as COPY_WRITE_BUFFER */
216    const GLenum UNIFORM_BUFFER                                = 0x8A11;
217    const GLenum UNIFORM_BUFFER_BINDING                        = 0x8A28;
218    const GLenum UNIFORM_BUFFER_START                          = 0x8A29;
219    const GLenum UNIFORM_BUFFER_SIZE                           = 0x8A2A;
220    const GLenum MAX_VERTEX_UNIFORM_BLOCKS                     = 0x8A2B;
221    const GLenum MAX_FRAGMENT_UNIFORM_BLOCKS                   = 0x8A2D;
222    const GLenum MAX_COMBINED_UNIFORM_BLOCKS                   = 0x8A2E;
223    const GLenum MAX_UNIFORM_BUFFER_BINDINGS                   = 0x8A2F;
224    const GLenum MAX_UNIFORM_BLOCK_SIZE                        = 0x8A30;
225    const GLenum MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS        = 0x8A31;
226    const GLenum MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS      = 0x8A33;
227    const GLenum UNIFORM_BUFFER_OFFSET_ALIGNMENT               = 0x8A34;
228    const GLenum ACTIVE_UNIFORM_BLOCKS                         = 0x8A36;
229    const GLenum UNIFORM_TYPE                                  = 0x8A37;
230    const GLenum UNIFORM_SIZE                                  = 0x8A38;
231    const GLenum UNIFORM_BLOCK_INDEX                           = 0x8A3A;
232    const GLenum UNIFORM_OFFSET                                = 0x8A3B;
233    const GLenum UNIFORM_ARRAY_STRIDE                          = 0x8A3C;
234    const GLenum UNIFORM_MATRIX_STRIDE                         = 0x8A3D;
235    const GLenum UNIFORM_IS_ROW_MAJOR                          = 0x8A3E;
236    const GLenum UNIFORM_BLOCK_BINDING                         = 0x8A3F;
237    const GLenum UNIFORM_BLOCK_DATA_SIZE                       = 0x8A40;
238    const GLenum UNIFORM_BLOCK_ACTIVE_UNIFORMS                 = 0x8A42;
239    const GLenum UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES          = 0x8A43;
240    const GLenum UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER     = 0x8A44;
241    const GLenum UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER   = 0x8A46;
242    const GLenum INVALID_INDEX                                 = 0xFFFFFFFF;
243    const GLenum MAX_VERTEX_OUTPUT_COMPONENTS                  = 0x9122;
244    const GLenum MAX_FRAGMENT_INPUT_COMPONENTS                 = 0x9125;
245    const GLenum MAX_SERVER_WAIT_TIMEOUT                       = 0x9111;
246    const GLenum OBJECT_TYPE                                   = 0x9112;
247    const GLenum SYNC_CONDITION                                = 0x9113;
248    const GLenum SYNC_STATUS                                   = 0x9114;
249    const GLenum SYNC_FLAGS                                    = 0x9115;
250    const GLenum SYNC_FENCE                                    = 0x9116;
251    const GLenum SYNC_GPU_COMMANDS_COMPLETE                    = 0x9117;
252    const GLenum UNSIGNALED                                    = 0x9118;
253    const GLenum SIGNALED                                      = 0x9119;
254    const GLenum ALREADY_SIGNALED                              = 0x911A;
255    const GLenum TIMEOUT_EXPIRED                               = 0x911B;
256    const GLenum CONDITION_SATISFIED                           = 0x911C;
257    const GLenum WAIT_FAILED                                   = 0x911D;
258    const GLenum SYNC_FLUSH_COMMANDS_BIT                       = 0x00000001;
259    const GLenum VERTEX_ATTRIB_ARRAY_DIVISOR                   = 0x88FE;
260    const GLenum ANY_SAMPLES_PASSED                            = 0x8C2F;
261    const GLenum ANY_SAMPLES_PASSED_CONSERVATIVE               = 0x8D6A;
262    const GLenum SAMPLER_BINDING                               = 0x8919;
263    const GLenum RGB10_A2UI                                    = 0x906F;
264    const GLenum INT_2_10_10_10_REV                            = 0x8D9F;
265    const GLenum TRANSFORM_FEEDBACK                            = 0x8E22;
266    const GLenum TRANSFORM_FEEDBACK_PAUSED                     = 0x8E23;
267    const GLenum TRANSFORM_FEEDBACK_ACTIVE                     = 0x8E24;
268    const GLenum TRANSFORM_FEEDBACK_BINDING                    = 0x8E25;
269    const GLenum TEXTURE_IMMUTABLE_FORMAT                      = 0x912F;
270    const GLenum MAX_ELEMENT_INDEX                             = 0x8D6B;
271    const GLenum TEXTURE_IMMUTABLE_LEVELS                      = 0x82DF;
272    const GLint TIMEOUT_IGNORED                                = -1;
273
274    /* WebGL-specific enums */
275    const GLenum MAX_CLIENT_WAIT_TIMEOUT_WEBGL                 = 0x9247;
276
277    /* Buffer objects */
278    void bufferData(GLenum target, [AllowShared] ArrayBufferView srcData, GLenum usage, GLuint srcOffset, optional GLuint length = 0);
279    void bufferSubData(GLenum target, GLintptr dstByteOffset, [AllowShared] ArrayBufferView srcData, GLuint srcOffset, optional GLuint length = 0);
280    void copyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
281    void getBufferSubData(GLenum target, GLintptr srcByteOffset, [AllowShared] ArrayBufferView dstData, optional GLuint dstOffset = 0, optional GLuint length = 0);
282
283    /* Framebuffer objects */
284    void blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
285    void framebufferTextureLayer(GLenum target, GLenum attachment, WebGLTexture? texture, GLint level, GLint layer);
286    [HighEntropy, MeasureAs=WebGL2RenderingContextGetInternalFormatParameter, CallWith=ScriptState] any getInternalformatParameter(GLenum target, GLenum internalformat, GLenum pname);
287    void invalidateFramebuffer(GLenum target, sequence<GLenum> attachments);
288    void invalidateSubFramebuffer(GLenum target, sequence<GLenum> attachments, GLint x, GLint y, GLsizei width, GLsizei height);
289    void readBuffer(GLenum mode);
290
291    /* Renderbuffer objects */
292    void renderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
293
294    /* Texture objects */
295    void texImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLintptr offset);
296    void texImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, ImageData data);
297    [CallWith=ExecutionContext, RaisesException] void texImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, HTMLImageElement image);
298    [CallWith=ExecutionContext, RaisesException] void texImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, HTMLCanvasElement canvas);
299    [CallWith=ExecutionContext, RaisesException] void texImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, OffscreenCanvas offscreenCanvas);
300    [CallWith=ExecutionContext,RaisesException] void texImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, HTMLVideoElement video);
301    [RaisesException] void texImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, ImageBitmap bitmap);
302    void texImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, [AllowShared] ArrayBufferView srcData, GLuint srcOffset);
303    void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLintptr offset);
304    void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, ImageData data);
305    [CallWith=ExecutionContext, RaisesException] void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, HTMLImageElement image);
306    [CallWith=ExecutionContext, RaisesException] void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, HTMLCanvasElement canvas);
307    [CallWith=ExecutionContext, RaisesException] void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, OffscreenCanvas offscreenCanvas);
308    [CallWith=ExecutionContext, RaisesException] void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, HTMLVideoElement video);
309    [RaisesException] void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, ImageBitmap bitmap);
310    void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, [AllowShared] ArrayBufferView srcData, GLuint srcOffset);
311    void texStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
312    void texStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
313    void texImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, GLintptr offset);
314    void texImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, ImageData data);
315    [CallWith=ExecutionContext, RaisesException] void texImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, HTMLImageElement image);
316    [CallWith=ExecutionContext, RaisesException] void texImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, HTMLCanvasElement canvas);
317    [CallWith=ExecutionContext, RaisesException] void texImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, OffscreenCanvas offscreenCanvas);
318    [CallWith=ExecutionContext, RaisesException] void texImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, HTMLVideoElement video);
319    [RaisesException] void texImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, ImageBitmap bitmap);
320    void texImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, [AllowShared] ArrayBufferView? pixels);
321    void texImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, [AllowShared] ArrayBufferView pixels, GLuint srcOffset);
322    void texSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLintptr offset);
323    void texSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, ImageData data);
324    [CallWith=ExecutionContext, RaisesException] void texSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, HTMLImageElement image);
325    [CallWith=ExecutionContext, RaisesException] void texSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, HTMLCanvasElement canvas);
326    [CallWith=ExecutionContext, RaisesException] void texSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, OffscreenCanvas offscreenCanvas);
327    [CallWith=ExecutionContext, RaisesException] void texSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, HTMLVideoElement video);
328    [RaisesException] void texSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, ImageBitmap bitmap);
329    void texSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, [AllowShared] ArrayBufferView pixels, optional GLuint srcOffset = 0);
330
331    void copyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
332
333    void compressedTexImage2D(GLenum target, GLint level, GLenum internalformat,
334                              GLsizei width, GLsizei height, GLint border,
335                              [AllowShared] ArrayBufferView data, GLuint srcOffset,
336                              optional GLuint srcLengthOverride = 0);
337    void compressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
338                                 GLsizei width, GLsizei height, GLenum format,
339                                 [AllowShared] ArrayBufferView data, GLuint srcOffset,
340                                 optional GLuint srcLengthOverride = 0);
341    void compressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, [AllowShared] ArrayBufferView data, optional GLuint srcOffset = 0, optional GLuint srcLengthOverride = 0);
342    void compressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, [AllowShared] ArrayBufferView data, optional GLuint srcOffset = 0, optional GLuint srcLengthOverride = 0);
343
344    void compressedTexImage2D(GLenum target, GLint level, GLenum internalformat,
345                              GLsizei width, GLsizei height, GLint border,
346                              GLsizei imageSize, GLintptr offset);
347    void compressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
348                                 GLsizei width, GLsizei height, GLenum format,
349                                 GLsizei imageSize, GLintptr offset);
350    void compressedTexImage3D(GLenum target, GLint level, GLenum internalformat,
351                              GLsizei width, GLsizei height, GLsizei depth, GLint border,
352                              GLsizei imageSize, GLintptr offset);
353    void compressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset,
354                                 GLsizei width, GLsizei height, GLsizei depth, GLenum format,
355                                 GLsizei imageSize, GLintptr offset);
356
357    /* Programs and shaders */
358    GLint getFragDataLocation(WebGLProgram program, DOMString name);
359
360    /* Uniforms and attributes */
361    void uniform1ui(WebGLUniformLocation? location, GLuint v0);
362    void uniform2ui(WebGLUniformLocation? location, GLuint v0, GLuint v1);
363    void uniform3ui(WebGLUniformLocation? location, GLuint v0, GLuint v1, GLuint v2);
364    void uniform4ui(WebGLUniformLocation? location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
365    // The WebGL1 uniform*v signatures are visible here, so srcOffset has to be non-optional
366    // to avoid conflicts. The effect is the same: if uniform*v is called with only two arguments,
367    // it goes to the WebGL1 signatures; if it's called with three or four arguments, it goes to
368    // the WebGL2 specific signatures.
369    void uniform1fv(WebGLUniformLocation? location, [AllowShared, FlexibleArrayBufferView] Float32Array v,
370                    GLuint srcOffset, optional GLuint srcLength = 0);
371    void uniform1fv(WebGLUniformLocation? location, sequence<GLfloat> v,
372                    GLuint srcOffset, optional GLuint srcLength = 0);
373    void uniform2fv(WebGLUniformLocation? location, [AllowShared, FlexibleArrayBufferView] Float32Array v,
374                    GLuint srcOffset, optional GLuint srcLength = 0);
375    void uniform2fv(WebGLUniformLocation? location, sequence<GLfloat> v,
376                    GLuint srcOffset, optional GLuint srcLength = 0);
377    void uniform3fv(WebGLUniformLocation? location, [AllowShared, FlexibleArrayBufferView] Float32Array v,
378                    GLuint srcOffset, optional GLuint srcLength = 0);
379    void uniform3fv(WebGLUniformLocation? location, sequence<GLfloat> v,
380                    GLuint srcOffset, optional GLuint srcLength = 0);
381    void uniform4fv(WebGLUniformLocation? location, [AllowShared, FlexibleArrayBufferView] Float32Array v,
382                    GLuint srcOffset, optional GLuint srcLength = 0);
383    void uniform4fv(WebGLUniformLocation? location, sequence<GLfloat> v,
384                    GLuint srcOffset, optional GLuint srcLength = 0);
385    void uniform1iv(WebGLUniformLocation? location, [AllowShared, FlexibleArrayBufferView] Int32Array v,
386                    GLuint srcOffset, optional GLuint srcLength = 0);
387    void uniform1iv(WebGLUniformLocation? location, sequence<GLint> v,
388                    GLuint srcOffset, optional GLuint srcLength = 0);
389    void uniform2iv(WebGLUniformLocation? location, [AllowShared, FlexibleArrayBufferView] Int32Array v,
390                    GLuint srcOffset, optional GLuint srcLength = 0);
391    void uniform2iv(WebGLUniformLocation? location, sequence<GLint> v,
392                    GLuint srcOffset, optional GLuint srcLength = 0);
393    void uniform3iv(WebGLUniformLocation? location, [AllowShared, FlexibleArrayBufferView] Int32Array v,
394                    GLuint srcOffset, optional GLuint srcLength = 0);
395    void uniform3iv(WebGLUniformLocation? location, sequence<GLint> v,
396                    GLuint srcOffset, optional GLuint srcLength = 0);
397    void uniform4iv(WebGLUniformLocation? location, [AllowShared, FlexibleArrayBufferView] Int32Array v,
398                    GLuint srcOffset, optional GLuint srcLength = 0);
399    void uniform4iv(WebGLUniformLocation? location, sequence<GLint> v,
400                    GLuint srcOffset, optional GLuint srcLength = 0);
401    void uniform1uiv(WebGLUniformLocation? location, [AllowShared, FlexibleArrayBufferView] Uint32Array v,
402                     optional GLuint srcOffset = 0, optional GLuint srcLength = 0);
403    void uniform1uiv(WebGLUniformLocation? location, sequence<GLuint> v,
404                     optional GLuint srcOffset = 0, optional GLuint srcLength = 0);
405    void uniform2uiv(WebGLUniformLocation? location, [AllowShared, FlexibleArrayBufferView] Uint32Array v,
406                     optional GLuint srcOffset = 0, optional GLuint srcLength = 0);
407    void uniform2uiv(WebGLUniformLocation? location, sequence<GLuint> v,
408                     optional GLuint srcOffset = 0, optional GLuint srcLength = 0);
409    void uniform3uiv(WebGLUniformLocation? location, [AllowShared, FlexibleArrayBufferView] Uint32Array v,
410                     optional GLuint srcOffset = 0, optional GLuint srcLength = 0);
411    void uniform3uiv(WebGLUniformLocation? location, sequence<GLuint> v,
412                     optional GLuint srcOffset = 0, optional GLuint srcLength = 0);
413    void uniform4uiv(WebGLUniformLocation? location, [AllowShared, FlexibleArrayBufferView] Uint32Array v,
414                     optional GLuint srcOffset = 0, optional GLuint srcLength = 0);
415    void uniform4uiv(WebGLUniformLocation? location, sequence<GLuint> v,
416                     optional GLuint srcOffset = 0, optional GLuint srcLength = 0);
417    void uniformMatrix2fv(WebGLUniformLocation? location, GLboolean transpose, [AllowShared] Float32Array array,
418                          GLuint srcOffset, optional GLuint srcLength = 0);
419    void uniformMatrix2fv(WebGLUniformLocation? location, GLboolean transpose, sequence<GLfloat> array,
420                          GLuint srcOffset, optional GLuint srcLength = 0);
421    void uniformMatrix3fv(WebGLUniformLocation? location, GLboolean transpose, [AllowShared] Float32Array array,
422                          GLuint srcOffset, optional GLuint srcLength = 0);
423    void uniformMatrix3fv(WebGLUniformLocation? location, GLboolean transpose, sequence<GLfloat> array,
424                          GLuint srcOffset, optional GLuint srcLength = 0);
425    void uniformMatrix4fv(WebGLUniformLocation? location, GLboolean transpose, [AllowShared] Float32Array array,
426                          GLuint srcOffset, optional GLuint srcLength = 0);
427    void uniformMatrix4fv(WebGLUniformLocation? location, GLboolean transpose, sequence<GLfloat> array,
428                          GLuint srcOffset, optional GLuint srcLength = 0);
429    void uniformMatrix2x3fv(WebGLUniformLocation? location, GLboolean transpose, [AllowShared] Float32Array value,
430                            optional GLuint srcOffset = 0, optional GLuint srcLength = 0);
431    void uniformMatrix2x3fv(WebGLUniformLocation? location, GLboolean transpose, sequence<GLfloat> value,
432                            optional GLuint srcOffset = 0, optional GLuint srcLength = 0);
433    void uniformMatrix3x2fv(WebGLUniformLocation? location, GLboolean transpose, [AllowShared] Float32Array value,
434                            optional GLuint srcOffset = 0, optional GLuint srcLength = 0);
435    void uniformMatrix3x2fv(WebGLUniformLocation? location, GLboolean transpose, sequence<GLfloat> value,
436                            optional GLuint srcOffset = 0, optional GLuint srcLength = 0);
437    void uniformMatrix2x4fv(WebGLUniformLocation? location, GLboolean transpose, [AllowShared] Float32Array value,
438                            optional GLuint srcOffset = 0, optional GLuint srcLength = 0);
439    void uniformMatrix2x4fv(WebGLUniformLocation? location, GLboolean transpose, sequence<GLfloat> value,
440                            optional GLuint srcOffset = 0, optional GLuint srcLength = 0);
441    void uniformMatrix4x2fv(WebGLUniformLocation? location, GLboolean transpose, [AllowShared] Float32Array value,
442                            optional GLuint srcOffset = 0, optional GLuint srcLength = 0);
443    void uniformMatrix4x2fv(WebGLUniformLocation? location, GLboolean transpose, sequence<GLfloat> value,
444                            optional GLuint srcOffset = 0, optional GLuint srcLength = 0);
445    void uniformMatrix3x4fv(WebGLUniformLocation? location, GLboolean transpose, [AllowShared] Float32Array value,
446                            optional GLuint srcOffset = 0, optional GLuint srcLength = 0);
447    void uniformMatrix3x4fv(WebGLUniformLocation? location, GLboolean transpose, sequence<GLfloat> value,
448                            optional GLuint srcOffset = 0, optional GLuint srcLength = 0);
449    void uniformMatrix4x3fv(WebGLUniformLocation? location, GLboolean transpose, [AllowShared] Float32Array value,
450                            optional GLuint srcOffset = 0, optional GLuint srcLength = 0);
451    void uniformMatrix4x3fv(WebGLUniformLocation? location, GLboolean transpose, sequence<GLfloat> value,
452                            optional GLuint srcOffset = 0, optional GLuint srcLength = 0);
453
454    void vertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w);
455    void vertexAttribI4iv(GLuint index, [AllowShared] Int32Array v);
456    void vertexAttribI4iv(GLuint index, sequence<GLint> v);
457    void vertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
458    void vertexAttribI4uiv(GLuint index, [AllowShared] Uint32Array v);
459    void vertexAttribI4uiv(GLuint index, sequence<GLuint> v);
460    void vertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset);
461
462    /* Writing to the drawing buffer */
463    void vertexAttribDivisor(GLuint index, GLuint divisor);
464    void drawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount);
465    void drawElementsInstanced(GLenum mode, GLsizei count, GLenum type, GLintptr offset, GLsizei instanceCount);
466    void drawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, GLintptr offset);
467
468    /* Multiple Render Targets */
469    void drawBuffers(sequence<GLenum> buffers);
470    void clearBufferiv(GLenum buffer, GLint drawbuffer, [AllowShared] Int32Array value, optional GLuint srcOffset = 0);
471    void clearBufferiv(GLenum buffer, GLint drawbuffer, sequence<GLint> value, optional GLuint srcOffset = 0);
472    void clearBufferuiv(GLenum buffer, GLint drawbuffer, [AllowShared] Uint32Array value, optional GLuint srcOffset = 0);
473    void clearBufferuiv(GLenum buffer, GLint drawbuffer, sequence<GLuint> value, optional GLuint srcOffset = 0);
474    void clearBufferfv(GLenum buffer, GLint drawbuffer, [AllowShared] Float32Array value, optional GLuint srcOffset = 0);
475    void clearBufferfv(GLenum buffer, GLint drawbuffer, sequence<GLfloat> value, optional GLuint srcOffset = 0);
476    void clearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil);
477
478    /* Query Objects */
479    WebGLQuery? createQuery();
480    void deleteQuery(WebGLQuery? query);
481    GLboolean isQuery(WebGLQuery? query);
482    void beginQuery(GLenum target, WebGLQuery query);
483    void endQuery(GLenum target);
484    [CallWith=ScriptState] any getQuery(GLenum target, GLenum pname);
485    [CallWith=ScriptState] any getQueryParameter(WebGLQuery query, GLenum pname);
486
487    /* Sampler Objects */
488    WebGLSampler? createSampler();
489    void deleteSampler(WebGLSampler? sampler);
490    GLboolean isSampler(WebGLSampler? sampler);
491    void bindSampler(GLuint unit, WebGLSampler? sampler);
492    void samplerParameteri(WebGLSampler sampler, GLenum pname, GLint param);
493    void samplerParameterf(WebGLSampler sampler, GLenum pname, GLfloat param);
494    [CallWith=ScriptState] any getSamplerParameter(WebGLSampler sampler, GLenum pname);
495
496    /* Sync objects */
497    WebGLSync? fenceSync(GLenum condition, GLbitfield flags);
498    GLboolean isSync(WebGLSync? sync);
499    void deleteSync(WebGLSync? sync);
500    GLenum clientWaitSync(WebGLSync sync, GLbitfield flags, GLuint64 timeout);
501    void waitSync(WebGLSync sync, GLbitfield flags, GLint64 timeout);
502
503    [CallWith=ScriptState] any getSyncParameter(WebGLSync sync, GLenum pname);
504
505    /* Transform Feedback */
506    WebGLTransformFeedback? createTransformFeedback();
507    void deleteTransformFeedback(WebGLTransformFeedback? feedback);
508    GLboolean isTransformFeedback(WebGLTransformFeedback? feedback);
509    void bindTransformFeedback(GLenum target, WebGLTransformFeedback? feedback);
510    void beginTransformFeedback(GLenum primitiveMode);
511    void endTransformFeedback();
512    void transformFeedbackVaryings(WebGLProgram program, sequence<DOMString> varyings, GLenum bufferMode);
513    WebGLActiveInfo? getTransformFeedbackVarying(WebGLProgram program, GLuint index);
514    void pauseTransformFeedback();
515    void resumeTransformFeedback();
516
517    /* Uniform Buffer Objects and Transform Feedback Buffers */
518    void bindBufferBase(GLenum target, GLuint index, WebGLBuffer? buffer);
519    void bindBufferRange(GLenum target, GLuint index, WebGLBuffer? buffer, GLintptr offset, GLsizeiptr size);
520    [CallWith=ScriptState] any getIndexedParameter(GLenum target, GLuint index);
521    sequence<GLuint>? getUniformIndices(WebGLProgram program, sequence<DOMString> uniformNames);
522    [CallWith=ScriptState] any getActiveUniforms(WebGLProgram program, sequence<GLuint> uniformIndices, GLenum pname);
523    GLuint getUniformBlockIndex(WebGLProgram program, DOMString uniformBlockName);
524    [CallWith=ScriptState] any getActiveUniformBlockParameter(WebGLProgram program, GLuint uniformBlockIndex, GLenum pname);
525    DOMString? getActiveUniformBlockName(WebGLProgram program, GLuint uniformBlockIndex);
526    void uniformBlockBinding(WebGLProgram program, GLuint uniformBlockIndex, GLuint uniformBlockBinding);
527
528    /* Vertex Array Objects */
529    WebGLVertexArrayObject? createVertexArray();
530    void deleteVertexArray(WebGLVertexArrayObject? vertexArray);
531    GLboolean isVertexArray(WebGLVertexArrayObject? vertexArray);
532    void bindVertexArray(WebGLVertexArrayObject? vertexArray);
533
534    /* Reading */
535    void readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, [AllowShared] ArrayBufferView dstData, GLintptr offset);
536    void readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLintptr offset);
537};
538WebGL2RenderingContextBase includes WebGLRenderingContextBase;
539