WebGL 2.0 Compute

Editor’s Draft,

Editors:
(Intel)
(Intel)
(Google)
(Intel)
(Intel)
(Intel)
(Intel)
(Intel)

Abstract

This is the WebGL 2.0 compute specification.

This specification describes an additional rendering context and supports objects for the HTML5 Canvas element [Canvas]. This context allows rendering using an API that conforms closely to the OpenGL ES 3.1 API. The most important feature in OpenGL ES 3.1 is GPU compute.

This document should be read as an extension to the WebGL 2.0 specification. It will only describe the differences from 2.0.

This document is a draft. Implementations based on this document may not be shipped.

Status of this document

This document is an editor’s draft. Do not cite this document as other than work in progress.

1. Introduction

WebGL™ is an immediate mode 3D rendering API designed for the web. This is the WebGL 2.0 compute specification. It is derived from OpenGL® ES 3.1, and provides similar rendering functionality, but in an HTML context.

WebGL 2.0 compute extends WebGL 2.0 and expose features in OpenGL ES 3.1. It is not entirely backwards compatible with WebGL 2.0. Existing error-free content written against the core WebGL 2.0 specification without extensions will often run in WebGL 2.0 compute without modification, but this is not always the case. All exceptions to backwards compatibility are recorded in the [Backwards Incompatibility] section. To access the new behavior provided in this specification, the content explicitly requests a new context below.

2. Context Creation and Drawing Buffer Presentation

Each WebGLRenderingContext and WebGL2RenderingContext and WebGL2ComputeRenderingContext has an associated canvas, set upon creation, which is a canvas [Canvas].

Each WebGLRenderingContext and WebGL2RenderingContext and WebGL2ComputeRenderingContext has context creation parameters, set upon creation, in a WebGLContextAttributes object.

Each WebGLRenderingContext and WebGL2RenderingContext and WebGL2ComputeRenderingContext has actual context parameters, set each time the drawing buffer is created, in a WebGLContextAttributes object.

Each WebGLRenderingContext and WebGL2RenderingContext and WebGL2ComputeRenderingContext has a webgl context lost flag, which is initially unset.

When the getContext() method of a canvas element is to return a new object for the contextId webgl2Compute [\CANVASCONTEXTS], the user agent must perform the following steps:

Create a new WebGL2ComputeRenderingContext object, context.

Let context’s canvas be the canvas the getContext() method is associated with.

Create a new WebGLContextAttributes object, contextAttributes.

If getContext() was invoked with a second argument, options, set the attributes of contextAttributes from those specified in options.

Create a drawing buffer using the settings specified in contextAttributes, and associate the drawing buffer with context.

If drawing buffer creation failed, perform the following steps: Fire a WebGL context creation error at canvas. Return null and terminate these steps. Create a new WebGLContextAttributes object, actualAttributes. Set the attributes of actualAttributes based on the properties of the newly created drawing buffer. Set context’s context creation parameters to contextAttributes. Set context’s actual context parameters to actualAttributes. Return context.

3. DOM Interfaces

This section describes the interfaces and functionality added to the DOM to support runtime access to the functionality described above.

3.1. The WebGL 2 Compute Rendering Context

The WebGL2ComputeRenderingContext represents the API allowing OpenGL ES 3.1 style rendering into the canvas element.

interface WebGL2ComputeRenderingContextBase {
  const GLenum  COMPUTE_SHADER                             = 0x91B9;
  const GLenum  MAX_COMPUTE_UNIFORM_BLOCKS                 = 0x91BB;
  const GLenum  MAX_COMPUTE_TEXTURE_IMAGE_UNITS            = 0x91BC;
  const GLenum  MAX_COMPUTE_IMAGE_UNIFORMS                 = 0x91BD;
  const GLenum  MAX_COMPUTE_SHARED_MEMORY_SIZE             = 0x8262;
  const GLenum  MAX_COMPUTE_UNIFORM_COMPONENTS             = 0x8263;
  const GLenum  MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS         = 0x8264;
  const GLenum  MAX_COMPUTE_ATOMIC_COUNTERS                = 0x8265;
  const GLenum  MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS    = 0x8266;
  const GLenum  MAX_COMPUTE_WORK_GROUP_INVOCATIONS         = 0x90EB;
  const GLenum  MAX_COMPUTE_WORK_GROUP_COUNT               = 0x91BE;
  const GLenum  MAX_COMPUTE_WORK_GROUP_SIZE                = 0x91BF;
  const GLenum  COMPUTE_WORK_GROUP_SIZE                    = 0x8267;
  const GLenum  DISPATCH_INDIRECT_BUFFER                   = 0x90EE;
  const GLenum  DISPATCH_INDIRECT_BUFFER_BINDING           = 0x90EF;
  const GLenum  COMPUTE_SHADER_BIT                         = 0x00000020;
  const GLenum  DRAW_INDIRECT_BUFFER                       = 0x8F3F;
  const GLenum  DRAW_INDIRECT_BUFFER_BINDING               = 0x8F43;
  const GLenum  MAX_UNIFORM_LOCATIONS                      = 0x826E;
  const GLenum  FRAMEBUFFER_DEFAULT_WIDTH                  = 0x9310;
  const GLenum  FRAMEBUFFER_DEFAULT_HEIGHT                 = 0x9311;
  const GLenum  FRAMEBUFFER_DEFAULT_SAMPLES                = 0x9313;
  const GLenum  FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS = 0x9314;
  const GLenum  MAX_FRAMEBUFFER_WIDTH                      = 0x9315;
  const GLenum  MAX_FRAMEBUFFER_HEIGHT                     = 0x9316;
  const GLenum  MAX_FRAMEBUFFER_SAMPLES                    = 0x9318;
  const GLenum  UNIFORM                                    = 0x92E1;
  const GLenum  UNIFORM_BLOCK                              = 0x92E2;
  const GLenum  PROGRAM_INPUT                              = 0x92E3;
  const GLenum  PROGRAM_OUTPUT                             = 0x92E4;
  const GLenum  BUFFER_VARIABLE                            = 0x92E5;
  const GLenum  SHADER_STORAGE_BLOCK                       = 0x92E6;
  const GLenum  ATOMIC_COUNTER_BUFFER                      = 0x92C0;
  const GLenum  TRANSFORM_FEEDBACK_VARYING                 = 0x92F4;
  const GLenum  ACTIVE_RESOURCES                           = 0x92F5;
  const GLenum  MAX_NAME_LENGTH                            = 0x92F6;
  const GLenum  MAX_NUM_ACTIVE_VARIABLES                   = 0x92F7;
  const GLenum  NAME_LENGTH                                = 0x92F9;
  const GLenum  TYPE                                       = 0x92FA;
  const GLenum  ARRAY_SIZE                                 = 0x92FB;
  const GLenum  OFFSET                                     = 0x92FC;
  const GLenum  BLOCK_INDEX                                = 0x92FD;
  const GLenum  ARRAY_STRIDE                               = 0x92FE;
  const GLenum  MATRIX_STRIDE                              = 0x92FF;
  const GLenum  IS_ROW_MAJOR                               = 0x9300;
  const GLenum  ATOMIC_COUNTER_BUFFER_INDEX                = 0x9301;
  const GLenum  BUFFER_BINDING                             = 0x9302;
  const GLenum  BUFFER_DATA_SIZE                           = 0x9303;
  const GLenum  NUM_ACTIVE_VARIABLES                       = 0x9304;
  const GLenum  ACTIVE_VARIABLES                           = 0x9305;
  const GLenum  REFERENCED_BY_VERTEX_SHADER                = 0x9306;
  const GLenum  REFERENCED_BY_FRAGMENT_SHADER              = 0x930A;
  const GLenum  REFERENCED_BY_COMPUTE_SHADER               = 0x930B;
  const GLenum  TOP_LEVEL_ARRAY_SIZE                       = 0x930C;
  const GLenum  TOP_LEVEL_ARRAY_STRIDE                     = 0x930D;
  const GLenum  LOCATION                                   = 0x930E;
  const GLenum  VERTEX_SHADER_BIT                          = 0x00000001;
  const GLenum  FRAGMENT_SHADER_BIT                        = 0x00000002;
  const GLenum  ALL_SHADER_BITS                            = 0xFFFFFFFF;
  const GLenum  ATOMIC_COUNTER_BUFFER_BINDING              = 0x92C1;
  const GLenum  ATOMIC_COUNTER_BUFFER_START                = 0x92C2;
  const GLenum  ATOMIC_COUNTER_BUFFER_SIZE                 = 0x92C3;
  const GLenum  MAX_VERTEX_ATOMIC_COUNTER_BUFFERS          = 0x92CC;
  const GLenum  MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS        = 0x92D0;
  const GLenum  MAX_COMBINED_ATOMIC_COUNTER_BUFFERS        = 0x92D1;
  const GLenum  MAX_VERTEX_ATOMIC_COUNTERS                 = 0x92D2;
  const GLenum  MAX_FRAGMENT_ATOMIC_COUNTERS               = 0x92D6;
  const GLenum  MAX_COMBINED_ATOMIC_COUNTERS               = 0x92D7;
  const GLenum  MAX_ATOMIC_COUNTER_BUFFER_SIZE             = 0x92D8;
  const GLenum  MAX_ATOMIC_COUNTER_BUFFER_BINDINGS         = 0x92DC;
  const GLenum  ACTIVE_ATOMIC_COUNTER_BUFFERS              = 0x92D9;
  const GLenum  UNSIGNED_INT_ATOMIC_COUNTER                = 0x92DB;
  const GLenum  MAX_IMAGE_UNITS                            = 0x8F38;
  const GLenum  MAX_VERTEX_IMAGE_UNIFORMS                  = 0x90CA;
  const GLenum  MAX_FRAGMENT_IMAGE_UNIFORMS                = 0x90CE;
  const GLenum  MAX_COMBINED_IMAGE_UNIFORMS                = 0x90CF;
  const GLenum  IMAGE_BINDING_NAME                         = 0x8F3A;
  const GLenum  IMAGE_BINDING_LEVEL                        = 0x8F3B;
  const GLenum  IMAGE_BINDING_LAYERED                      = 0x8F3C;
  const GLenum  IMAGE_BINDING_LAYER                        = 0x8F3D;
  const GLenum  IMAGE_BINDING_ACCESS                       = 0x8F3E;
  const GLenum  IMAGE_BINDING_FORMAT                       = 0x906E;
  const GLenum  VERTEX_ATTRIB_ARRAY_BARRIER_BIT            = 0x00000001;
  const GLenum  ELEMENT_ARRAY_BARRIER_BIT                  = 0x00000002;
  const GLenum  UNIFORM_BARRIER_BIT                        = 0x00000004;
  const GLenum  TEXTURE_FETCH_BARRIER_BIT                  = 0x00000008;
  const GLenum  SHADER_IMAGE_ACCESS_BARRIER_BIT            = 0x00000020;
  const GLenum  COMMAND_BARRIER_BIT                        = 0x00000040;
  const GLenum  PIXEL_BUFFER_BARRIER_BIT                   = 0x00000080;
  const GLenum  TEXTURE_UPDATE_BARRIER_BIT                 = 0x00000100;
  const GLenum  BUFFER_UPDATE_BARRIER_BIT                  = 0x00000200;
  const GLenum  FRAMEBUFFER_BARRIER_BIT                    = 0x00000400;
  const GLenum  TRANSFORM_FEEDBACK_BARRIER_BIT             = 0x00000800;
  const GLenum  ATOMIC_COUNTER_BARRIER_BIT                 = 0x00001000;
  const GLenum  SHADER_STORAGE_BARRIER_BIT                 = 0x00002000;
  const GLenum  ALL_BARRIER_BITS                           = 0xFFFFFFFF;
  const GLenum  IMAGE_2D                                   = 0x904D;
  const GLenum  IMAGE_3D                                   = 0x904E;
  const GLenum  IMAGE_CUBE                                 = 0x9050;
  const GLenum  IMAGE_2D_ARRAY                             = 0x9053;
  const GLenum  INT_IMAGE_2D                               = 0x9058;
  const GLenum  INT_IMAGE_3D                               = 0x9059;
  const GLenum  INT_IMAGE_CUBE                             = 0x905B;
  const GLenum  INT_IMAGE_2D_ARRAY                         = 0x905E;
  const GLenum  UNSIGNED_INT_IMAGE_2D                      = 0x9063;
  const GLenum  UNSIGNED_INT_IMAGE_3D                      = 0x9064;
  const GLenum  UNSIGNED_INT_IMAGE_CUBE                    = 0x9066;
  const GLenum  UNSIGNED_INT_IMAGE_2D_ARRAY                = 0x9069;
  const GLenum  IMAGE_FORMAT_COMPATIBILITY_TYPE            = 0x90C7;
  const GLenum  IMAGE_FORMAT_COMPATIBILITY_BY_SIZE         = 0x90C8;
  const GLenum  IMAGE_FORMAT_COMPATIBILITY_BY_CLASS        = 0x90C9;
  const GLenum  READ_ONLY                                  = 0x88B8;
  const GLenum  WRITE_ONLY                                 = 0x88B9;
  const GLenum  READ_WRITE                                 = 0x88BA;
  const GLenum  SHADER_STORAGE_BUFFER                      = 0x90D2;
  const GLenum  SHADER_STORAGE_BUFFER_BINDING              = 0x90D3;
  const GLenum  SHADER_STORAGE_BUFFER_START                = 0x90D4;
  const GLenum  SHADER_STORAGE_BUFFER_SIZE                 = 0x90D5;
  const GLenum  MAX_VERTEX_SHADER_STORAGE_BLOCKS           = 0x90D6;
  const GLenum  MAX_FRAGMENT_SHADER_STORAGE_BLOCKS         = 0x90DA;
  const GLenum  MAX_COMPUTE_SHADER_STORAGE_BLOCKS          = 0x90DB;
  const GLenum  MAX_COMBINED_SHADER_STORAGE_BLOCKS         = 0x90DC;
  const GLenum  MAX_SHADER_STORAGE_BUFFER_BINDINGS         = 0x90DD;
  const GLenum  MAX_SHADER_STORAGE_BLOCK_SIZE              = 0x90DE;
  const GLenum  SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT     = 0x90DF;
  const GLenum  MAX_COMBINED_SHADER_OUTPUT_RESOURCES       = 0x8F39;
  const GLenum  DEPTH_STENCIL_TEXTURE_MODE                 = 0x90EA;
  const GLenum  STENCIL_INDEX                              = 0x1901;
  const GLenum  MIN_PROGRAM_TEXTURE_GATHER_OFFSET          = 0x8E5E;
  const GLenum  MAX_PROGRAM_TEXTURE_GATHER_OFFSET          = 0x8E5F;
  const GLenum  SAMPLE_POSITION                            = 0x8E50;
  const GLenum  SAMPLE_MASK                                = 0x8E51;
  const GLenum  SAMPLE_MASK_VALUE                          = 0x8E52;
  const GLenum  TEXTURE_2D_MULTISAMPLE                     = 0x9100;
  const GLenum  MAX_SAMPLE_MASK_WORDS                      = 0x8E59;
  const GLenum  MAX_COLOR_TEXTURE_SAMPLES                  = 0x910E;
  const GLenum  MAX_DEPTH_TEXTURE_SAMPLES                  = 0x910F;
  const GLenum  MAX_INTEGER_SAMPLES                        = 0x9110;
  const GLenum  TEXTURE_BINDING_2D_MULTISAMPLE             = 0x9104;
  const GLenum  TEXTURE_SAMPLES                            = 0x9106;
  const GLenum  TEXTURE_FIXED_SAMPLE_LOCATIONS             = 0x9107;
  const GLenum  TEXTURE_WIDTH                              = 0x1000;
  const GLenum  TEXTURE_HEIGHT                             = 0x1001;
  const GLenum  TEXTURE_DEPTH                              = 0x8071;
  const GLenum  TEXTURE_INTERNAL_FORMAT                    = 0x1003;
  const GLenum  TEXTURE_RED_SIZE                           = 0x805C;
  const GLenum  TEXTURE_GREEN_SIZE                         = 0x805D;
  const GLenum  TEXTURE_BLUE_SIZE                          = 0x805E;
  const GLenum  TEXTURE_ALPHA_SIZE                         = 0x805F;
  const GLenum  TEXTURE_DEPTH_SIZE                         = 0x884A;
  const GLenum  TEXTURE_STENCIL_SIZE                       = 0x88F1;
  const GLenum  TEXTURE_SHARED_SIZE                        = 0x8C3F;
  const GLenum  TEXTURE_RED_TYPE                           = 0x8C10;
  const GLenum  TEXTURE_GREEN_TYPE                         = 0x8C11;
  const GLenum  TEXTURE_BLUE_TYPE                          = 0x8C12;
  const GLenum  TEXTURE_ALPHA_TYPE                         = 0x8C13;
  const GLenum  TEXTURE_DEPTH_TYPE                         = 0x8C16;
  const GLenum  TEXTURE_COMPRESSED                         = 0x86A1;
  const GLenum  SAMPLER_2D_MULTISAMPLE                     = 0x9108;
  const GLenum  INT_SAMPLER_2D_MULTISAMPLE                 = 0x9109;
  const GLenum  UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE        = 0x910A;
  const GLenum  VERTEX_ATTRIB_BINDING                      = 0x82D4;
  const GLenum  VERTEX_ATTRIB_RELATIVE_OFFSET              = 0x82D5;
  const GLenum  VERTEX_BINDING_DIVISOR                     = 0x82D6;
  const GLenum  VERTEX_BINDING_OFFSET                      = 0x82D7;
  const GLenum  VERTEX_BINDING_STRIDE                      = 0x82D8;
  const GLenum  VERTEX_BINDING_BUFFER                      = 0x8F4F;
  const GLenum  MAX_VERTEX_ATTRIB_RELATIVE_OFFSET          = 0x82D9;
  const GLenum  MAX_VERTEX_ATTRIB_BINDINGS                 = 0x82DA;
  const GLenum  MAX_VERTEX_ATTRIB_STRIDE                   = 0x82E5;

  void dispatchCompute(GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z);
  void dispatchComputeIndirect(GLintptr offset);

  void drawArraysIndirect(GLenum mode, GLintptr offset);
  void drawElementsIndirect(GLenum mode, GLenum type, GLintptr offset);

  void framebufferParameter(GLenum target, GLenum pname, GLint param);
  any getFramebufferParameter(GLenum target, GLenum pname);

  any getProgramInterfaceParameter(WebGLProgram program, GLenum programInterface, GLenum pname);
  any getProgramResource(WebGLProgram program, GLenum programInterface, GLuint index, GLenum props);
  GLuint getProgramResourceIndex(WebGLProgram program, GLenum programInterface, DOMString name);
  DOMString? getProgramResourceName(WebGLProgram program, GLenum programInterface, GLuint index);
  any getProgramResourceLocation(WebGLProgram program, GLenum programInterface, DOMString name);

  void programUniform1i(WebGLProgram? program, WebGLUniformLocation? location, GLint v0);
  void programUniform2i(WebGLProgram? program, WebGLUniformLocation? location, GLint v0, GLint v1);
  void programUniform3i(WebGLProgram? program, WebGLUniformLocation? location, GLint v0, GLint v1, GLint v2);
  void programUniform4i(WebGLProgram? program, WebGLUniformLocation? location, GLint v0, GLint v1, GLint v2, GLint v3);

  void programUniform1ui(WebGLProgram? program, WebGLUniformLocation? location, GLuint v0);
  void programUniform2ui(WebGLProgram? program, WebGLUniformLocation? location, GLuint v0, GLuint v1);
  void programUniform3ui(WebGLProgram? program, WebGLUniformLocation? location, GLuint v0, GLuint v1, GLuint v2);
  void programUniform4ui(WebGLProgram? program, WebGLUniformLocation? location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);

  void programUniform1f(WebGLProgram? program, WebGLUniformLocation? location, GLfloat v0);
  void programUniform2f(WebGLProgram? program, WebGLUniformLocation? location, GLfloat v0, GLfloat v1);
  void programUniform3f(WebGLProgram? program, WebGLUniformLocation? location, GLfloat v0, GLfloat v1, GLfloat v2);
  void programUniform4f(WebGLProgram? program, WebGLUniformLocation? location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);

  void programUniform1iv(WebGLProgram? program, WebGLUniformLocation? location, GLsizei count, Int32List data);
  void programUniform2iv(WebGLProgram? program, WebGLUniformLocation? location, GLsizei count, Int32List data);
  void programUniform3iv(WebGLProgram? program, WebGLUniformLocation? location, GLsizei count, Int32List data);
  void programUniform4iv(WebGLProgram? program, WebGLUniformLocation? location, GLsizei count, Int32List data);

  void programUniform1uiv(WebGLProgram? program, WebGLUniformLocation? location, GLsizei count, Uint32List data);
  void programUniform2uiv(WebGLProgram? program, WebGLUniformLocation? location, GLsizei count, Uint32List data);
  void programUniform3uiv(WebGLProgram? program, WebGLUniformLocation? location, GLsizei count, Uint32List data);
  void programUniform4uiv(WebGLProgram? program, WebGLUniformLocation? location, GLsizei count, Uint32List data);

  void programUniform1fv(WebGLProgram? program, WebGLUniformLocation? location, GLsizei count, Float32List data);
  void programUniform2fv(WebGLProgram? program, WebGLUniformLocation? location, GLsizei count, Float32List data);
  void programUniform3fv(WebGLProgram? program, WebGLUniformLocation? location, GLsizei count, Float32List data);
  void programUniform4fv(WebGLProgram? program, WebGLUniformLocation? location, GLsizei count, Float32List data);

  void programUniformMatrix2fv(WebGLProgram? program, WebGLUniformLocation? location, GLsizei count,
                           GLboolean transpose, Float32List data);
  void programUniformMatrix3fv(WebGLProgram? program, WebGLUniformLocation? location, GLsizei count,
                           GLboolean transpose, Float32List data);
  void programUniformMatrix4fv(WebGLProgram? program, WebGLUniformLocation? location, GLsizei count,
                           GLboolean transpose, Float32List data);
  void programUniformMatrix2x3fv(WebGLProgram? program, WebGLUniformLocation? location, GLsizei count,
                             GLboolean transpose, Float32List data);
  void programUniformMatrix3x2fv(WebGLProgram? program, WebGLUniformLocation? location, GLsizei count,
                             GLboolean transpose, Float32List data);
  void programUniformMatrix2x4fv(WebGLProgram? program, WebGLUniformLocation? location, GLsizei count,
                             GLboolean transpose, Float32List data);
  void programUniformMatrix4x2fv(WebGLProgram? program, WebGLUniformLocation? location, GLsizei count,
                             GLboolean transpose, Float32List data);
  void programUniformMatrix3x4fv(WebGLProgram? program, WebGLUniformLocation? location, GLsizei count,
                             GLboolean transpose, Float32List data);
  void programUniformMatrix4x3fv(WebGLProgram? program, WebGLUniformLocation? location, GLsizei count,
                             GLboolean transpose, Float32List data);

  void bindImageTexture(GLuint unit, WebGLTexture? texture, GLint level,
                        GLboolean layered, GLint layer, GLenum access, GLenum format);

  void memoryBarrier(GLbitfield barriers);
  void memoryBarrierByRegion(GLbitfield barriers);

  void texStorage2DMultisample(GLenum target, GLsizei samples, GLenum internalformat,
                               GLsizei width, GLsizei height, GLboolean fixedsamplelocations);
  any getTexLevelParameter(GLenum target, GLint level, GLenum pname);
  any getMultisample(GLenum pname, GLuint index);
  void sampleMask(GLuint index, GLbitfield mask);

  void bindVertexBuffer(GLuint bindingindex, WebGLBuffer? buffer, GLintptr offset, GLsizei stride);
  void vertexAttribFormat(GLuint attribindex, GLint size, GLenum type,
                          GLboolean normalized, GLuint relativeoffset);
  void vertexAttribIFormat(GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);
  void vertexAttribBinding(GLuint attribindex, GLuint bindingindex);
  void vertexBindingDivisor(GLuint bindingindex, GLuint divisor);
};

3.1.1. Framebuffer Object

void framebufferParameter(GLenum target, GLenum pname, GLint param) ( OpenGL ES 3.1 Section 9.2.1, man page)

Set framebuffer default parameter.
See glFramebufferParameteri at OpenGL ES 3.1 Section 9.2.1, and man page

any getFramebufferParameter(GLenum target, GLenum pname)

Set framebuffer default parameter.
See glFramebufferParameteri at OpenGL ES 3.1 Section 9.2.1, and man page

3.1.2. Texture Object

void texStorage2DMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedSsampleLlocations)

Establish the data storage, format, dimensions, and number of samples of a multisample texture’s image.
See glTexStorage2DMultisample at OpenGL ES 3.1 Section 8.8, and man page

any getTexLevelParameter(GLenum target, GLint level, GLenum valuepname)

Query the level-of-detail information of the given pname for the currently bound texture specified by target.
See glGetTexLevelParameter{if}v at OpenGL ES 3.1 Section 8.10.3, and man page
The requested pname and its return type are given in the following table:

pname returned type
TEXTURE_SAMPLES GLuint
TEXTURE_FIXED_SAMPLE_LOCATIONS GLboolean
TEXTURE_WIDTH GLuint
TEXTURE_HEIGHT GLuint
TEXTURE_DEPTH GLuint
TEXTURE_INTERNAL_FORMAT GLenum
TEXTURE_RED_SIZE GLuint
TEXTURE_GREEN_SIZE GLuint
TEXTURE_BLUE_SIZE GLuint
TEXTURE_ALPHA_SIZE GLuint
TEXTURE_DEPTH_SIZE GLuint
TEXTURE_STENCIL_SIZE GLuint
TEXTURE_SHARED_SIZE GLuint
TEXTURE_RED_TYPE GLenum
TEXTURE_GREEN_TYPE GLenum
TEXTURE_BLUE_TYPE GLenum
TEXTURE_ALPHA_TYPE GLenum
TEXTURE_DEPTH_TYPE GLenum
TEXTURE_COMPRESSED GLboolean

3.1.3. Sampler Object

any getMultisample(GLenum pname, GLuint index)

Query the location of a given sample within the pixel.
See glGetMultisamplefv at OpenGL ES 3.1 Section 13.2.1, and man page

void sampleMask(GLuint index, GLbitfield mask)

Specify the sample mask value to mask for desired mask of index.
See glSampleMaski at OpenGL ES 3.1 Section 13.6.3, and man page

3.1.4. Uniforms and Attributes

void programUniform[1234][if](WebGLProgram? program, WebGLUniformLocation? location, ...)

Set uniform value for a given program.
See glProgramUniform[1234][if] at OpenGL ES 3.1 Section 7.6.1, and man page

void programUniform[1234][if]v(WebGLProgram? program, WebGLUniformLocation? location, ...)

Set uniform value for a given program.
See glProgramUniform[1234][if]v at OpenGL ES 3.1 Section 7.6.1, and man page

void programUniform[1234]ui(WebGLProgram? program, WebGLUniformLocation? location, ...)

Set uniform value for a given program.
See glProgramUniform[1234]ui at OpenGL ES 3.1 Section 7.6.1, and man page

void programUniform[1234]uiv(WebGLProgram? program, WebGLUniformLocation? location, ...)

Set uniform value for a given program.
See glProgramUniform[1234]uiv at OpenGL ES 3.1 Section 7.6.1, and man page

void programUniformMatrix[234][f]v(WebGLProgram? program, WebGLUniformLocation? location, GLsizei count, GLboolean transpose, ...)

Set uniform value for a given program.
See glProgramUniform[234][f]v at OpenGL ES 3.1 Section 7.6.1, and man page

void programUniformMatrix[2x3, 3x2, 2x4, 4x2, 3x4, 4x3][f]v(WebGLProgram? program, WebGLUniformLocation? location, GLsizei count, GLboolean transpose, ...)

Set uniform value for a given program.
See glProgramUniformMatirx[2x3, 3x2, 2x4, 4x2, 3x4, 4x3][f]v at OpenGL ES 3.1 Section 7.6.1, and man page

void bindVertexBuffer(GLuint bindingindex, WebGLBuffer? buffer, GLintptr offset, GLsizei stride)

Bind vertex buffer to the binding point bindingindex.
See glBindVertexBuffer at OpenGL ES 3.1 Section 10.3.1, and man page

void vertexAttribFormat(GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset)

Describe the orgnization of vertex arrays.
See glVertexAttribFormat at OpenGL ES 3.1 Section 10.3.1, and man page

void vertexAttribIFormat(GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset)

Describe the orgnization of vertex arrays.
See glVertexAttribIFormat at OpenGL ES 3.1 Section 10.3.1, and man page

void vertexAttribBinding(GLuint attribindex, GLuint bindingindex)

Set the association between a vertex attribute and the vertex buffer binding.
See glVertexAttribBinding at OpenGL ES 3.1 Section 10.3.1, and man page

void vertexBindingDivisor(GLuint bindingindex, GLuint divisor)

Set the divisor value for attributes taken from the buffer bound to bindingindex between a vertex attribute and the vertex buffer binding.
See glVertexBindingDivisor at OpenGL ES 3.1 Section 10.3.2, and man page

3.1.5. Writing to the Drawing Buffers

void drawArraysIndirect(GLenum mode, GLintptr offset)

Draw geometry with vertices by reading parameters via indirect buffer.
See glDrawArraysIndirect at OpenGL ES 3.1 Section 10.5, and man page

void drawElementsIndirect(GLenum mode, GLenum type, GLintptr offset)

Draw geometry with indexed vertices by reading parameters via indirect buffer.
See glDrawElementsIndirect at OpenGL ES 3.1 Section 10.5, and man page

3.1.6. Program Interface Query

any getProgramInterfaceParameter(WebGLProgram program, GLenum programInterface, GLenum pname)

Query a property of the interface programInterface in program program.
See glGetProgramInterfaceiv at OpenGL ES 3.1 Section 7.3.1.1, and man page

sequence? getProgramResource(WebGLProgram program, GLenum programInterface, GLuint index, sequence props)

Query multiple properties of the interface programInterface in program program.
See glGetProgramResourceiv at OpenGL ES 3.1 Section 7.3.1.1, and man page

DOMString? getProgramResourceName(WebGLProgram program, GLenum programInterface, GLuint index)

Query the name string assigned to the single active resource with an index of index in the interface programInterface in program program.
See glGetProgramResourceName at OpenGL ES 3.1 Section 7.3.1.1, and man page

GLuint getProgramResourceIndex(WebGLProgram program, GLenum programInterface, DOMString name)

Query the unsigned integer index assigned to a resource named name in the interface programInterface in program program.
See glGetProgramResourceIndex at OpenGL ES 3.1 Section 7.3.1.1, and man page

any getProgramResourceLocation(WebGLProgram program, GLenum programInterface, DOMString name)

Query the location assigned to a resource named name in the interface programInterface in program program.
See glGetProgramResourceLocation at OpenGL ES 3.1 Section 7.3.1.1, and man page

3.1.7. Image Binding

void bindImageTexture(GLuint unit, WebGLTexture? texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format)

Bind a texture to a image unit for image load and store.
See glBindImageTexture at OpenGL ES 3.1 Section 8.22, and man page

3.1.8. Memory Barrior

void memoryBarrior(GLbitfield barriers)

Define a barrier ordering the memory transactions issued prior to the command relative to those issued after the barrier.
See glMemoryBarrier at OpenGL ES 3.1 Section 7.11.2, and man page

void memoryBarriorByRegion(GLbitfield barriers)

With restrictions, define a barrier ordering the memory transactions issued prior to the command relative to those issued after the barrier.
See glMemoryBarrier at OpenGL ES 3.1 Section 7.11.2, and man page

3.1.9. Dispatch Compute

void dispatchCompute(GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z)

Launch one or more work groups and start compute pipeline.
See glDispatchCompute at OpenGL ES 3.1 Section 17, and man page

void dispatchComputeIndirect(GLintptr offset)

Launch one or more work groups and start compute pipeline, with parameter stored in a buffer from offset offset.
See glDispatchComputeIndirect at OpenGL ES 3.1 Section 17, and man page

3.1.10. More Shader Types

WebGLShader? createShader(GLenum type)

type accept the following parameters:

type
COMPUTE_SHADER
COMPUTE_SHADER is also supported by corresponding APIs like createShaderProgram, among other APIs.

3.1.11. More Binding Point

void bindBuffer(GLenum target, WebGLBuffer buffer)

target accept the following parameters:

target
ATOMIC_COUNTER_BUFFER
DISPATCH_INDIRECT_BUFFER
DRAW_INDIRECT_BUFFER
SHADER_STORAGE_BUFFER
For bindBufferRange and bindBufferBase, only ATOMIC_COUNTER_BUFFER and SHADER_STORAGE_BUFFER are supported.

3.1.12. Setting and Getting States

any getParameter(GLenum pname)

pname accept the following parameters. The return type of this method now depends on the parameter queried:

pname returned type
MAX_SAMPLE_MASK_WORDS GLuint
MAX_COLOR_TEXTURE_SAMPLES GLuint
MAX_DEPTH_TEXTURE_SAMPLES GLuint
MAX_INTEGER_SAMPLES GLuint
TEXTURE_BINDING_2D_MULTISAMPLE WebGLTexture
MAX_VERTEX_ATOMIC_COUNTER_BUFFERS GLuint
MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS GLuint
MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS GLuint
MAX_COMBINED_ATOMIC_COUNTER_BUFFERS GLuint
MAX_ATOMIC_COUNTER_BUFFER_BINDINGS GLuint
MAX_VERTEX_ATOMIC_COUNTERS GLuint
MAX_FRAGMENT_ATOMIC_COUNTERS GLuint
MAX_COMPUTE_ATOMIC_COUNTERS GLuint
MAX_COMBINED_ATOMIC_COUNTERS GLuint
ATOMIC_COUNTER_BUFFER_BINDING WebGLBuffer
MAX_COMBINED_SHADER_STORAGE_BLOCKS GLuint
MAX_COMPUTE_SHADER_STORAGE_BLOCKS GLuint
MAX_FRAGMENT_SHADER_STORAGE_BLOCKS GLuint
MAX_VERTEX_SHADER_STORAGE_BLOCKS GLuint
MAX_SHADER_STORAGE_BLOCK_SIZE GLuint
MAX_SHADER_STORAGE_BUFFER_BINDINGS GLuint
SHADER_STORAGE_BUFFER_BINDING WebGLBuffer

any getIndexedParameter(GLenum target, GLuint index)

target accept the following parameters. The return type of this method now depends on the parameter queried:

target returned type
VERTEX_BINDING_OFFSET GLintptr
VERTEX_BINDING_STRIDE GLint
VERTEX_BINDING_DIVISOR GLint
VERTEX_BINDING_BUFFER WebGLBuffer
SAMPLE_MASK_VALUE GLbitfield
ATOMIC_COUNTER_BUFFER_BINDING WebGLBuffer
ATOMIC_COUNTER_BUFFER_START GLintptr
ATOMIC_COUNTER_BUFFER_SIZE GLsizeiptr
IMAGE_BINDING_NAME WebGLTexture
IMAGE_BINDING_LEVEL GLint
IMAGE_BINDING_LAYERED GLboolean
IMAGE_BINDING_LAYER GLint
IMAGE_BINDING_ACCESS GLenum
IMAGE_BINDING_FORMAT GLenum
SHADER_STORAGE_BUFFER_BINDING WebGLBuffer
SHADER_STORAGE_BUFFER_START GLintptr
SHADER_STORAGE_BUFFER_SIZE GLsizeiptr
MAX_COMPUTE_WORK_GROUP_COUNT GLint
MAX_COMPUTE_WORK_GROUP_SIZE GLint

any getProgramParameter(WebGLProgram? program, GLenum pname)

Query program parameter pname give program.
See glGetProgramiv at OpenGL ES 3.1 Section 7.12, and man page The requested pname and its return type are given in the following table:

pname returned type
COMPUTE_WORK_GROUP_SIZE GLint
ACTIVE_ATOMIC_COUNTER_BUFFERS GLint

4. Other Differences Between WebGL 2.0 compute and WebGL 2.0

4.1. WebGL 2.0 compute can support GLSL ES 310


local size, group size, group ID, invocation ID and so on for compute shader
image
shared memory
barriers
shader storage buffer
atomics
multisample texture
new qualifier like coherent, volatile, restrict, readonly, writeonly, std430, early_fragment_test, etc
new math built-ins
array of arrays
texture gather

4.2. Integer Format Renderbuffer

Renderbuffer can support integer format via RenderbufferStorage()

4.3. Framebuffer without attachment can be complete

In WebGL 2.0, it is a must that there is at least one attached image in framebuffer. Otherwise, it is framebuffer incomplete. In WebGL 2.0 compute, this requirement is removed.

4.4. Extra restrictions for vertexAttrib*Pointer

In WebGL 2.0 compute, vertexAttrib*Pointer has an extra restriction on the maximum stride: MAX_VERTEX_ATTRIB_STRIDE.

5. Differences between WebGL 2.0 compute and OpenGL ES 3.1

5.1. Program pipeline is not supported in WebGL 2.0 compute

Program pipeline in OpenGL ES 3.1 is not supported in WebGL 2.0 compute. Program pipeline is irrelevant to compute shader and it is not very useful.

5.2. The same layer and level of texture cannot be bound to multiple image units

In OpenGL ES 3.1, the same layer and level of texture can be bound to multiple image units. But this feature is not allowed in D3D11, and it is not very useful. So this feature is disabled. It generates INVALID_OPERATION otherwise.

5.3. Multiple image variables can’t be used to access the same image unit

In OpenGL ES 3.1, Multiple image variables can be used to access the same image unit. But this feature is not allowed in D3D11, and it is not very useful. So this feature is disabled. It generates INVALID_OPERATION otherwise.

5.4. Multiple shader storage blocks are not allowed to bind to a single buffer

dispatchCompute generates an INVALID_OPERATION error if more than one shader storage block that are bound to a single buffer are statically used in that dispatch call.

This is a restriction from D3D11, where the same resource bound to different UAVs is not allowed.

5.5. gl_HelperInvocation is not supported

gl_HelperInvocation is a built-in input variable of fragment shader introduced in ESSL 310 (Chapter 7.1.2 Page 106). It needs at least GLSL 450 on desktop OpenGL, and it has no equivalent in HLSL system values in D3D11. So it is not supported in WebGL.

5.6. Presenting particular value in compute shader

Define the const and non-const behavior for some corner case like NaN, Inf, 0.0 in compute shader

5.7. std430 layout is requred for shared memory

OpenGL ES 3.1 SPEC does not define which memory layout we should follow to calculate the total memory consumption of shared variables.

This extension calculates the usage of shared memory in std430 layout. The total size of active shared variables may not exceed the largest block size that would be obtained if all active variables declared as shared were instead declared as arbitrarily ordered members of a shader storage block qualified with std430.

5.8. Clarify undefined behaviors

5.8.1. Rendering against compute program is not allowed

Rendering against compute program is not allowed

5.8.2. Shadow sampler in texture lookup function

Shadow sampler in texture lookup function has a lot of limitation, which will lead to undefined behavior. Find “shadow sam” in GLES spec.

5.8.3. Sampling from incomplete texture with integer or unsigned integer format

Sampling from incomplete texture with integer or unsigned integer format, it will return undefined value. See GLES spec 3.1 on page 275 (the 1st paragraph).

5.8.4. Sampling from stencil texture via non-unsigned integer sampler

Sampling from stencil texture should use a unsigned integer sampler (say usampler2D tex in shader). Otherwise, the result are undefined, see GLES spec 3.1 on page 274. (the last but one paragraph).

5.8.5. Out-of-bounds access to ssbo or atomic counter in shader

Out-of-bounds access to shader storage buffers or atomic counter buffers in shader cannot read from or write to data not owned by the application. See KHR_robust_buffer_access_behavior.

5.8.6. Uninitialized shared variables in shader

Variables declared as shared may not have initializers and their contents are all zero at the beginning of shader execution.

5.8.7. Image load or store

Read from an image unit with a texture bound as GL_WRITE_ONLY, or write to an image unit with a texture bound as GL_READ_ONLY, the results of that shader operation are undefined and may lead to application termination in OpenGL ES 3.1. It generates INVALID_OPERATION instead when dispatch compute in this spec.

If the individual texel identified for an image load or store operation doesn’t exist, the access is treated as invalid. An access is considered invalid if

It generates INVALID_OPERATION when dispatch compute in the cases above for both load and store in this spec.

If image load or store operations are considered to involve a format mismatch, undefined values will be returned by image load operations and undefined values will be written by stores in OpenGL ES 3.1 spec. A format mismatch will occur if:

It generates INVALID_OPERATION when dispatch compute in this spec;

Conformance

Conformance requirements are expressed with a combination of descriptive assertions and RFC 2119 terminology. The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in the normative parts of this document are to be interpreted as described in RFC 2119. However, for readability, these words do not appear in all uppercase letters in this specification.

All of the text of this specification is normative except sections explicitly marked as non-normative, examples, and notes. [RFC2119]

Examples in this specification are introduced with the words “for example” or are set apart from the normative text with class="example", like this:

This is an example of an informative example.

Informative notes begin with the word “Note” and are set apart from the normative text with class="note", like this:

Note, this is an informative note.

Index

Terms defined by this specification

Terms defined by reference

References

Normative References

[RFC2119]
S. Bradner. Key words for use in RFCs to Indicate Requirement Levels. March 1997. Best Current Practice. URL: https://tools.ietf.org/html/rfc2119
[WebIDL]
Boris Zbarsky. Web IDL. 15 December 2016. ED. URL: https://heycam.github.io/webidl/

IDL Index

interface WebGL2ComputeRenderingContextBase {
  const GLenum  COMPUTE_SHADER                             = 0x91B9;
  const GLenum  MAX_COMPUTE_UNIFORM_BLOCKS                 = 0x91BB;
  const GLenum  MAX_COMPUTE_TEXTURE_IMAGE_UNITS            = 0x91BC;
  const GLenum  MAX_COMPUTE_IMAGE_UNIFORMS                 = 0x91BD;
  const GLenum  MAX_COMPUTE_SHARED_MEMORY_SIZE             = 0x8262;
  const GLenum  MAX_COMPUTE_UNIFORM_COMPONENTS             = 0x8263;
  const GLenum  MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS         = 0x8264;
  const GLenum  MAX_COMPUTE_ATOMIC_COUNTERS                = 0x8265;
  const GLenum  MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS    = 0x8266;
  const GLenum  MAX_COMPUTE_WORK_GROUP_INVOCATIONS         = 0x90EB;
  const GLenum  MAX_COMPUTE_WORK_GROUP_COUNT               = 0x91BE;
  const GLenum  MAX_COMPUTE_WORK_GROUP_SIZE                = 0x91BF;
  const GLenum  COMPUTE_WORK_GROUP_SIZE                    = 0x8267;
  const GLenum  DISPATCH_INDIRECT_BUFFER                   = 0x90EE;
  const GLenum  DISPATCH_INDIRECT_BUFFER_BINDING           = 0x90EF;
  const GLenum  COMPUTE_SHADER_BIT                         = 0x00000020;
  const GLenum  DRAW_INDIRECT_BUFFER                       = 0x8F3F;
  const GLenum  DRAW_INDIRECT_BUFFER_BINDING               = 0x8F43;
  const GLenum  MAX_UNIFORM_LOCATIONS                      = 0x826E;
  const GLenum  FRAMEBUFFER_DEFAULT_WIDTH                  = 0x9310;
  const GLenum  FRAMEBUFFER_DEFAULT_HEIGHT                 = 0x9311;
  const GLenum  FRAMEBUFFER_DEFAULT_SAMPLES                = 0x9313;
  const GLenum  FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS = 0x9314;
  const GLenum  MAX_FRAMEBUFFER_WIDTH                      = 0x9315;
  const GLenum  MAX_FRAMEBUFFER_HEIGHT                     = 0x9316;
  const GLenum  MAX_FRAMEBUFFER_SAMPLES                    = 0x9318;
  const GLenum  UNIFORM                                    = 0x92E1;
  const GLenum  UNIFORM_BLOCK                              = 0x92E2;
  const GLenum  PROGRAM_INPUT                              = 0x92E3;
  const GLenum  PROGRAM_OUTPUT                             = 0x92E4;
  const GLenum  BUFFER_VARIABLE                            = 0x92E5;
  const GLenum  SHADER_STORAGE_BLOCK                       = 0x92E6;
  const GLenum  ATOMIC_COUNTER_BUFFER                      = 0x92C0;
  const GLenum  TRANSFORM_FEEDBACK_VARYING                 = 0x92F4;
  const GLenum  ACTIVE_RESOURCES                           = 0x92F5;
  const GLenum  MAX_NAME_LENGTH                            = 0x92F6;
  const GLenum  MAX_NUM_ACTIVE_VARIABLES                   = 0x92F7;
  const GLenum  NAME_LENGTH                                = 0x92F9;
  const GLenum  TYPE                                       = 0x92FA;
  const GLenum  ARRAY_SIZE                                 = 0x92FB;
  const GLenum  OFFSET                                     = 0x92FC;
  const GLenum  BLOCK_INDEX                                = 0x92FD;
  const GLenum  ARRAY_STRIDE                               = 0x92FE;
  const GLenum  MATRIX_STRIDE                              = 0x92FF;
  const GLenum  IS_ROW_MAJOR                               = 0x9300;
  const GLenum  ATOMIC_COUNTER_BUFFER_INDEX                = 0x9301;
  const GLenum  BUFFER_BINDING                             = 0x9302;
  const GLenum  BUFFER_DATA_SIZE                           = 0x9303;
  const GLenum  NUM_ACTIVE_VARIABLES                       = 0x9304;
  const GLenum  ACTIVE_VARIABLES                           = 0x9305;
  const GLenum  REFERENCED_BY_VERTEX_SHADER                = 0x9306;
  const GLenum  REFERENCED_BY_FRAGMENT_SHADER              = 0x930A;
  const GLenum  REFERENCED_BY_COMPUTE_SHADER               = 0x930B;
  const GLenum  TOP_LEVEL_ARRAY_SIZE                       = 0x930C;
  const GLenum  TOP_LEVEL_ARRAY_STRIDE                     = 0x930D;
  const GLenum  LOCATION                                   = 0x930E;
  const GLenum  VERTEX_SHADER_BIT                          = 0x00000001;
  const GLenum  FRAGMENT_SHADER_BIT                        = 0x00000002;
  const GLenum  ALL_SHADER_BITS                            = 0xFFFFFFFF;
  const GLenum  ATOMIC_COUNTER_BUFFER_BINDING              = 0x92C1;
  const GLenum  ATOMIC_COUNTER_BUFFER_START                = 0x92C2;
  const GLenum  ATOMIC_COUNTER_BUFFER_SIZE                 = 0x92C3;
  const GLenum  MAX_VERTEX_ATOMIC_COUNTER_BUFFERS          = 0x92CC;
  const GLenum  MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS        = 0x92D0;
  const GLenum  MAX_COMBINED_ATOMIC_COUNTER_BUFFERS        = 0x92D1;
  const GLenum  MAX_VERTEX_ATOMIC_COUNTERS                 = 0x92D2;
  const GLenum  MAX_FRAGMENT_ATOMIC_COUNTERS               = 0x92D6;
  const GLenum  MAX_COMBINED_ATOMIC_COUNTERS               = 0x92D7;
  const GLenum  MAX_ATOMIC_COUNTER_BUFFER_SIZE             = 0x92D8;
  const GLenum  MAX_ATOMIC_COUNTER_BUFFER_BINDINGS         = 0x92DC;
  const GLenum  ACTIVE_ATOMIC_COUNTER_BUFFERS              = 0x92D9;
  const GLenum  UNSIGNED_INT_ATOMIC_COUNTER                = 0x92DB;
  const GLenum  MAX_IMAGE_UNITS                            = 0x8F38;
  const GLenum  MAX_VERTEX_IMAGE_UNIFORMS                  = 0x90CA;
  const GLenum  MAX_FRAGMENT_IMAGE_UNIFORMS                = 0x90CE;
  const GLenum  MAX_COMBINED_IMAGE_UNIFORMS                = 0x90CF;
  const GLenum  IMAGE_BINDING_NAME                         = 0x8F3A;
  const GLenum  IMAGE_BINDING_LEVEL                        = 0x8F3B;
  const GLenum  IMAGE_BINDING_LAYERED                      = 0x8F3C;
  const GLenum  IMAGE_BINDING_LAYER                        = 0x8F3D;
  const GLenum  IMAGE_BINDING_ACCESS                       = 0x8F3E;
  const GLenum  IMAGE_BINDING_FORMAT                       = 0x906E;
  const GLenum  VERTEX_ATTRIB_ARRAY_BARRIER_BIT            = 0x00000001;
  const GLenum  ELEMENT_ARRAY_BARRIER_BIT                  = 0x00000002;
  const GLenum  UNIFORM_BARRIER_BIT                        = 0x00000004;
  const GLenum  TEXTURE_FETCH_BARRIER_BIT                  = 0x00000008;
  const GLenum  SHADER_IMAGE_ACCESS_BARRIER_BIT            = 0x00000020;
  const GLenum  COMMAND_BARRIER_BIT                        = 0x00000040;
  const GLenum  PIXEL_BUFFER_BARRIER_BIT                   = 0x00000080;
  const GLenum  TEXTURE_UPDATE_BARRIER_BIT                 = 0x00000100;
  const GLenum  BUFFER_UPDATE_BARRIER_BIT                  = 0x00000200;
  const GLenum  FRAMEBUFFER_BARRIER_BIT                    = 0x00000400;
  const GLenum  TRANSFORM_FEEDBACK_BARRIER_BIT             = 0x00000800;
  const GLenum  ATOMIC_COUNTER_BARRIER_BIT                 = 0x00001000;
  const GLenum  SHADER_STORAGE_BARRIER_BIT                 = 0x00002000;
  const GLenum  ALL_BARRIER_BITS                           = 0xFFFFFFFF;
  const GLenum  IMAGE_2D                                   = 0x904D;
  const GLenum  IMAGE_3D                                   = 0x904E;
  const GLenum  IMAGE_CUBE                                 = 0x9050;
  const GLenum  IMAGE_2D_ARRAY                             = 0x9053;
  const GLenum  INT_IMAGE_2D                               = 0x9058;
  const GLenum  INT_IMAGE_3D                               = 0x9059;
  const GLenum  INT_IMAGE_CUBE                             = 0x905B;
  const GLenum  INT_IMAGE_2D_ARRAY                         = 0x905E;
  const GLenum  UNSIGNED_INT_IMAGE_2D                      = 0x9063;
  const GLenum  UNSIGNED_INT_IMAGE_3D                      = 0x9064;
  const GLenum  UNSIGNED_INT_IMAGE_CUBE                    = 0x9066;
  const GLenum  UNSIGNED_INT_IMAGE_2D_ARRAY                = 0x9069;
  const GLenum  IMAGE_FORMAT_COMPATIBILITY_TYPE            = 0x90C7;
  const GLenum  IMAGE_FORMAT_COMPATIBILITY_BY_SIZE         = 0x90C8;
  const GLenum  IMAGE_FORMAT_COMPATIBILITY_BY_CLASS        = 0x90C9;
  const GLenum  READ_ONLY                                  = 0x88B8;
  const GLenum  WRITE_ONLY                                 = 0x88B9;
  const GLenum  READ_WRITE                                 = 0x88BA;
  const GLenum  SHADER_STORAGE_BUFFER                      = 0x90D2;
  const GLenum  SHADER_STORAGE_BUFFER_BINDING              = 0x90D3;
  const GLenum  SHADER_STORAGE_BUFFER_START                = 0x90D4;
  const GLenum  SHADER_STORAGE_BUFFER_SIZE                 = 0x90D5;
  const GLenum  MAX_VERTEX_SHADER_STORAGE_BLOCKS           = 0x90D6;
  const GLenum  MAX_FRAGMENT_SHADER_STORAGE_BLOCKS         = 0x90DA;
  const GLenum  MAX_COMPUTE_SHADER_STORAGE_BLOCKS          = 0x90DB;
  const GLenum  MAX_COMBINED_SHADER_STORAGE_BLOCKS         = 0x90DC;
  const GLenum  MAX_SHADER_STORAGE_BUFFER_BINDINGS         = 0x90DD;
  const GLenum  MAX_SHADER_STORAGE_BLOCK_SIZE              = 0x90DE;
  const GLenum  SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT     = 0x90DF;
  const GLenum  MAX_COMBINED_SHADER_OUTPUT_RESOURCES       = 0x8F39;
  const GLenum  DEPTH_STENCIL_TEXTURE_MODE                 = 0x90EA;
  const GLenum  STENCIL_INDEX                              = 0x1901;
  const GLenum  MIN_PROGRAM_TEXTURE_GATHER_OFFSET          = 0x8E5E;
  const GLenum  MAX_PROGRAM_TEXTURE_GATHER_OFFSET          = 0x8E5F;
  const GLenum  SAMPLE_POSITION                            = 0x8E50;
  const GLenum  SAMPLE_MASK                                = 0x8E51;
  const GLenum  SAMPLE_MASK_VALUE                          = 0x8E52;
  const GLenum  TEXTURE_2D_MULTISAMPLE                     = 0x9100;
  const GLenum  MAX_SAMPLE_MASK_WORDS                      = 0x8E59;
  const GLenum  MAX_COLOR_TEXTURE_SAMPLES                  = 0x910E;
  const GLenum  MAX_DEPTH_TEXTURE_SAMPLES                  = 0x910F;
  const GLenum  MAX_INTEGER_SAMPLES                        = 0x9110;
  const GLenum  TEXTURE_BINDING_2D_MULTISAMPLE             = 0x9104;
  const GLenum  TEXTURE_SAMPLES                            = 0x9106;
  const GLenum  TEXTURE_FIXED_SAMPLE_LOCATIONS             = 0x9107;
  const GLenum  TEXTURE_WIDTH                              = 0x1000;
  const GLenum  TEXTURE_HEIGHT                             = 0x1001;
  const GLenum  TEXTURE_DEPTH                              = 0x8071;
  const GLenum  TEXTURE_INTERNAL_FORMAT                    = 0x1003;
  const GLenum  TEXTURE_RED_SIZE                           = 0x805C;
  const GLenum  TEXTURE_GREEN_SIZE                         = 0x805D;
  const GLenum  TEXTURE_BLUE_SIZE                          = 0x805E;
  const GLenum  TEXTURE_ALPHA_SIZE                         = 0x805F;
  const GLenum  TEXTURE_DEPTH_SIZE                         = 0x884A;
  const GLenum  TEXTURE_STENCIL_SIZE                       = 0x88F1;
  const GLenum  TEXTURE_SHARED_SIZE                        = 0x8C3F;
  const GLenum  TEXTURE_RED_TYPE                           = 0x8C10;
  const GLenum  TEXTURE_GREEN_TYPE                         = 0x8C11;
  const GLenum  TEXTURE_BLUE_TYPE                          = 0x8C12;
  const GLenum  TEXTURE_ALPHA_TYPE                         = 0x8C13;
  const GLenum  TEXTURE_DEPTH_TYPE                         = 0x8C16;
  const GLenum  TEXTURE_COMPRESSED                         = 0x86A1;
  const GLenum  SAMPLER_2D_MULTISAMPLE                     = 0x9108;
  const GLenum  INT_SAMPLER_2D_MULTISAMPLE                 = 0x9109;
  const GLenum  UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE        = 0x910A;
  const GLenum  VERTEX_ATTRIB_BINDING                      = 0x82D4;
  const GLenum  VERTEX_ATTRIB_RELATIVE_OFFSET              = 0x82D5;
  const GLenum  VERTEX_BINDING_DIVISOR                     = 0x82D6;
  const GLenum  VERTEX_BINDING_OFFSET                      = 0x82D7;
  const GLenum  VERTEX_BINDING_STRIDE                      = 0x82D8;
  const GLenum  VERTEX_BINDING_BUFFER                      = 0x8F4F;
  const GLenum  MAX_VERTEX_ATTRIB_RELATIVE_OFFSET          = 0x82D9;
  const GLenum  MAX_VERTEX_ATTRIB_BINDINGS                 = 0x82DA;
  const GLenum  MAX_VERTEX_ATTRIB_STRIDE                   = 0x82E5;

  void dispatchCompute(GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z);
  void dispatchComputeIndirect(GLintptr offset);

  void drawArraysIndirect(GLenum mode, GLintptr offset);
  void drawElementsIndirect(GLenum mode, GLenum type, GLintptr offset);

  void framebufferParameter(GLenum target, GLenum pname, GLint param);
  any getFramebufferParameter(GLenum target, GLenum pname);

  any getProgramInterfaceParameter(WebGLProgram program, GLenum programInterface, GLenum pname);
  any getProgramResource(WebGLProgram program, GLenum programInterface, GLuint index, GLenum props);
  GLuint getProgramResourceIndex(WebGLProgram program, GLenum programInterface, DOMString name);
  DOMString? getProgramResourceName(WebGLProgram program, GLenum programInterface, GLuint index);
  any getProgramResourceLocation(WebGLProgram program, GLenum programInterface, DOMString name);

  void programUniform1i(WebGLProgram? program, WebGLUniformLocation? location, GLint v0);
  void programUniform2i(WebGLProgram? program, WebGLUniformLocation? location, GLint v0, GLint v1);
  void programUniform3i(WebGLProgram? program, WebGLUniformLocation? location, GLint v0, GLint v1, GLint v2);
  void programUniform4i(WebGLProgram? program, WebGLUniformLocation? location, GLint v0, GLint v1, GLint v2, GLint v3);

  void programUniform1ui(WebGLProgram? program, WebGLUniformLocation? location, GLuint v0);
  void programUniform2ui(WebGLProgram? program, WebGLUniformLocation? location, GLuint v0, GLuint v1);
  void programUniform3ui(WebGLProgram? program, WebGLUniformLocation? location, GLuint v0, GLuint v1, GLuint v2);
  void programUniform4ui(WebGLProgram? program, WebGLUniformLocation? location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);

  void programUniform1f(WebGLProgram? program, WebGLUniformLocation? location, GLfloat v0);
  void programUniform2f(WebGLProgram? program, WebGLUniformLocation? location, GLfloat v0, GLfloat v1);
  void programUniform3f(WebGLProgram? program, WebGLUniformLocation? location, GLfloat v0, GLfloat v1, GLfloat v2);
  void programUniform4f(WebGLProgram? program, WebGLUniformLocation? location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);

  void programUniform1iv(WebGLProgram? program, WebGLUniformLocation? location, GLsizei count, Int32List data);
  void programUniform2iv(WebGLProgram? program, WebGLUniformLocation? location, GLsizei count, Int32List data);
  void programUniform3iv(WebGLProgram? program, WebGLUniformLocation? location, GLsizei count, Int32List data);
  void programUniform4iv(WebGLProgram? program, WebGLUniformLocation? location, GLsizei count, Int32List data);

  void programUniform1uiv(WebGLProgram? program, WebGLUniformLocation? location, GLsizei count, Uint32List data);
  void programUniform2uiv(WebGLProgram? program, WebGLUniformLocation? location, GLsizei count, Uint32List data);
  void programUniform3uiv(WebGLProgram? program, WebGLUniformLocation? location, GLsizei count, Uint32List data);
  void programUniform4uiv(WebGLProgram? program, WebGLUniformLocation? location, GLsizei count, Uint32List data);

  void programUniform1fv(WebGLProgram? program, WebGLUniformLocation? location, GLsizei count, Float32List data);
  void programUniform2fv(WebGLProgram? program, WebGLUniformLocation? location, GLsizei count, Float32List data);
  void programUniform3fv(WebGLProgram? program, WebGLUniformLocation? location, GLsizei count, Float32List data);
  void programUniform4fv(WebGLProgram? program, WebGLUniformLocation? location, GLsizei count, Float32List data);

  void programUniformMatrix2fv(WebGLProgram? program, WebGLUniformLocation? location, GLsizei count,
                           GLboolean transpose, Float32List data);
  void programUniformMatrix3fv(WebGLProgram? program, WebGLUniformLocation? location, GLsizei count,
                           GLboolean transpose, Float32List data);
  void programUniformMatrix4fv(WebGLProgram? program, WebGLUniformLocation? location, GLsizei count,
                           GLboolean transpose, Float32List data);
  void programUniformMatrix2x3fv(WebGLProgram? program, WebGLUniformLocation? location, GLsizei count,
                             GLboolean transpose, Float32List data);
  void programUniformMatrix3x2fv(WebGLProgram? program, WebGLUniformLocation? location, GLsizei count,
                             GLboolean transpose, Float32List data);
  void programUniformMatrix2x4fv(WebGLProgram? program, WebGLUniformLocation? location, GLsizei count,
                             GLboolean transpose, Float32List data);
  void programUniformMatrix4x2fv(WebGLProgram? program, WebGLUniformLocation? location, GLsizei count,
                             GLboolean transpose, Float32List data);
  void programUniformMatrix3x4fv(WebGLProgram? program, WebGLUniformLocation? location, GLsizei count,
                             GLboolean transpose, Float32List data);
  void programUniformMatrix4x3fv(WebGLProgram? program, WebGLUniformLocation? location, GLsizei count,
                             GLboolean transpose, Float32List data);

  void bindImageTexture(GLuint unit, WebGLTexture? texture, GLint level,
                        GLboolean layered, GLint layer, GLenum access, GLenum format);

  void memoryBarrier(GLbitfield barriers);
  void memoryBarrierByRegion(GLbitfield barriers);

  void texStorage2DMultisample(GLenum target, GLsizei samples, GLenum internalformat,
                               GLsizei width, GLsizei height, GLboolean fixedsamplelocations);
  any getTexLevelParameter(GLenum target, GLint level, GLenum pname);
  any getMultisample(GLenum pname, GLuint index);
  void sampleMask(GLuint index, GLbitfield mask);

  void bindVertexBuffer(GLuint bindingindex, WebGLBuffer? buffer, GLintptr offset, GLsizei stride);
  void vertexAttribFormat(GLuint attribindex, GLint size, GLenum type,
                          GLboolean normalized, GLuint relativeoffset);
  void vertexAttribIFormat(GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);
  void vertexAttribBinding(GLuint attribindex, GLuint bindingindex);
  void vertexBindingDivisor(GLuint bindingindex, GLuint divisor);
};