Added: trunk/LayoutTests/webgl/webgl-allow-shared.html (0 => 274438)
--- trunk/LayoutTests/webgl/webgl-allow-shared.html (rev 0)
+++ trunk/LayoutTests/webgl/webgl-allow-shared.html 2021-03-15 20:49:55 UTC (rev 274438)
@@ -0,0 +1,77 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>AllowShared in WebGL</title>
+<script src=""
+<script src=""
+</head>
+<body>
+<canvas width="100" height="100"></canvas>
+<canvas width="100" height="100"></canvas>
+<script>
+test(() => {
+ const canvas = document.querySelectorAll('canvas')[0];
+ const gl = canvas.getContext("webgl");
+ const buffer = gl.createBuffer();
+ const bufferData = new Float32Array(new SharedArrayBuffer(128))
+ gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
+
+ gl.bufferData(gl.ARRAY_BUFFER, bufferData, gl.STATIC_DRAW);
+
+ gl.bufferSubData(gl.ARRAY_BUFFER, bufferData.length, bufferData);
+
+ const texture = gl.createTexture();
+ const textureData = new Float32Array(new SharedArrayBuffer(128))
+ gl.bindTexture(gl.TEXTURE_2D, texture);
+
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.FLOAT, textureData);
+
+ gl.texSubImage2D(gl.TEXTURE_2D, 0, 30, 0, 4, 4, gl.RGBA, gl.FLOAT, textureData);
+
+ gl.compressedTexImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, textureData);
+
+ gl.compressedTexSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 1, 1, gl.RGBA, textureData);
+
+ gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.FLOAT, textureData);
+}, `WebGL AllowShared`);
+
+test(() => {
+ const canvas = document.querySelectorAll('canvas')[1];
+ const gl = canvas.getContext("webgl2");
+ const buffer = gl.createBuffer();
+ const bufferData = new Float32Array(new SharedArrayBuffer(128))
+ gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
+
+ gl.bufferData(gl.ARRAY_BUFFER, bufferData, gl.STATIC_DRAW, 0, 0);
+
+ gl.bufferSubData(gl.ARRAY_BUFFER, bufferData.length, bufferData, 0, 0);
+
+ gl.getBufferSubData(gl.ARRAY_BUFFER, 0, bufferData);
+
+ const texture = gl.createTexture();
+ const textureData = new Float32Array(new SharedArrayBuffer(128))
+ gl.bindTexture(gl.TEXTURE_2D, texture);
+
+ gl.texImage3D(gl.TEXTURE_3D, 0, gl.RGBA, 1, 1, 0, 0, gl.RGBA, gl.FLOAT, textureData);
+
+ gl.texImage3D(gl.TEXTURE_3D, 0, gl.RGBA, 1, 1, 0, 0, gl.RGBA, gl.FLOAT, textureData, 0);
+
+ gl.texSubImage3D(gl.TEXTURE_3D, 0, 0, 0, 0, 1, 0, 0, gl.RGBA, gl.FLOAT, textureData);
+
+ gl.compressedTexImage3D(gl.TEXTURE_2D_ARRAY, 0, gl.COMPRESSED_RGBA8_ETC2_EAC, 4, 4, 1, 0, textureData);
+
+ gl.compressedTexSubImage3D(gl.TEXTURE_2D_ARRAY, 0, 0, 0, 0, 4, 4, 1, gl.COMPRESSED_RGBA8_ETC2_EAC, textureData)
+
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.FLOAT, textureData, 0);
+
+ gl.texSubImage2D(gl.TEXTURE_2D, 0, 30, 0, 4, 4, gl.RGBA, gl.FLOAT, textureData, 0);
+
+ gl.compressedTexImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, textureData, 0);
+
+ gl.compressedTexSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 1, 1, gl.RGBA, textureData, 0);
+
+ gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.FLOAT, textureData, 0);
+}, `WebGL2 AllowShared`);
+</script>
+</body>
+</html>
Modified: trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.idl (274437 => 274438)
--- trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.idl 2021-03-15 20:45:45 UTC (rev 274437)
+++ trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.idl 2021-03-15 20:49:55 UTC (rev 274438)
@@ -40,9 +40,9 @@
typedef unrestricted float GLfloat;
typedef unrestricted float GLclampf;
typedef (ArrayBuffer or ArrayBufferView) BufferDataSource;
-typedef (Float32Array or sequence<GLfloat>) Float32List;
-typedef (Int32Array or sequence<GLint>) Int32List;
-typedef (Uint32Array or sequence<GLuint>) Uint32List;
+typedef ([AllowShared] Float32Array or sequence<GLfloat>) Float32List;
+typedef ([AllowShared] Int32Array or sequence<GLint>) Int32List;
+typedef ([AllowShared] Uint32Array or sequence<GLuint>) Uint32List;
#ifdef ENABLE_VIDEO
typedef (ImageBitmap or ImageData or HTMLImageElement or HTMLCanvasElement or HTMLVideoElement) TexImageSource;
@@ -337,11 +337,11 @@
const GLenum MAX_CLIENT_WAIT_TIMEOUT_WEBGL = 0x9247;
// Buffer objects.
- undefined bufferData(GLenum target, ArrayBufferView data, GLenum usage, GLuint srcOffset, optional GLuint length = 0);
- undefined bufferSubData(GLenum target, GLintptr dstByteOffset, ArrayBufferView srcData, GLuint srcOffset, optional GLuint length = 0);
+ undefined bufferData(GLenum target, [AllowShared] ArrayBufferView data, GLenum usage, GLuint srcOffset, optional GLuint length = 0);
+ undefined bufferSubData(GLenum target, GLintptr dstByteOffset, [AllowShared] ArrayBufferView srcData, GLuint srcOffset, optional GLuint length = 0);
undefined copyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
- undefined getBufferSubData(GLenum target, GLintptr srcByteOffset, ArrayBufferView dstData, optional GLuint dstOffset = 0, optional GLuint length = 0);
+ undefined getBufferSubData(GLenum target, GLintptr srcByteOffset, [AllowShared] ArrayBufferView dstData, optional GLuint dstOffset = 0, optional GLuint length = 0);
// Framebuffer objects.
undefined blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
@@ -360,19 +360,19 @@
undefined texImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, GLintptr pboOffset);
undefined texImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, TexImageSource source);
- undefined texImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, ArrayBufferView? pixels);
- undefined texImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, ArrayBufferView srcData, GLuint srcOffset);
+ undefined texImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, [AllowShared] ArrayBufferView? pixels);
+ undefined texImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, [AllowShared] ArrayBufferView srcData, GLuint srcOffset);
undefined texSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLintptr pboOffset);
undefined texSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, TexImageSource source);
- undefined texSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, ArrayBufferView? srcData, optional GLuint srcOffset = 0);
+ undefined texSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, [AllowShared] ArrayBufferView? srcData, optional GLuint srcOffset = 0);
undefined copyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
undefined compressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, GLintptr offset);
- undefined compressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, ArrayBufferView srcData, optional GLuint srcOffset = 0, optional GLuint srcLengthOverride = 0);
+ undefined compressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, [AllowShared] ArrayBufferView srcData, optional GLuint srcOffset = 0, optional GLuint srcLengthOverride = 0);
undefined compressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, GLintptr offset);
- undefined compressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, ArrayBufferView srcData, optional GLuint srcOffset = 0, optional GLuint srcLengthOverride = 0);
+ undefined compressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, [AllowShared] ArrayBufferView srcData, optional GLuint srcOffset = 0, optional GLuint srcLengthOverride = 0);
// Programs and shaders/
GLint getFragDataLocation(WebGLProgram program, DOMString name);
@@ -470,17 +470,17 @@
undefined texImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLintptr pboOffset);
[MayThrowException] undefined texImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, TexImageSource source);
- undefined texImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, ArrayBufferView srcData, GLuint srcOffset);
+ undefined texImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, [AllowShared] ArrayBufferView srcData, GLuint srcOffset);
undefined texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLintptr pboOffset);
[MayThrowException] undefined texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, TexImageSource source);
- undefined texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, ArrayBufferView srcData, GLuint srcOffset);
+ undefined texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, [AllowShared] ArrayBufferView srcData, GLuint srcOffset);
undefined compressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, GLintptr offset);
- undefined compressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, ArrayBufferView srcData, GLuint srcOffset, optional GLuint srcLengthOverride = 0);
+ undefined compressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, [AllowShared] ArrayBufferView srcData, GLuint srcOffset, optional GLuint srcLengthOverride = 0);
undefined compressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, GLintptr offset);
- undefined compressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, ArrayBufferView srcData, GLuint srcOffset, optional GLuint srcLengthOverride = 0);
+ undefined compressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, [AllowShared] ArrayBufferView srcData, GLuint srcOffset, optional GLuint srcLengthOverride = 0);
undefined uniform1fv(WebGLUniformLocation? location, Float32List data, GLuint srcOffset, optional GLuint srcLength = 0);
undefined uniform2fv(WebGLUniformLocation? location, Float32List data, GLuint srcOffset, optional GLuint srcLength = 0);
@@ -497,7 +497,7 @@
undefined uniformMatrix4fv(WebGLUniformLocation? location, GLboolean transpose, Float32List data, GLuint srcOffset, optional GLuint srcLength = 0);
undefined readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLintptr offset);
- undefined readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, ArrayBufferView dstData, GLuint dstOffset);
+ undefined readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, [AllowShared] ArrayBufferView dstData, GLuint dstOffset);
};
WebGL2RenderingContext includes WebGLRenderingContextBase;
Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.idl (274437 => 274438)
--- trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.idl 2021-03-15 20:45:45 UTC (rev 274437)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.idl 2021-03-15 20:49:55 UTC (rev 274438)
@@ -38,8 +38,11 @@
typedef unrestricted float GLfloat;
typedef unrestricted float GLclampf;
typedef (ArrayBuffer or ArrayBufferView) BufferDataSource;
-typedef (Float32Array or sequence<GLfloat>) Float32List;
-typedef (Int32Array or sequence<GLint>) Int32List;
+// FIXME: Currently `[AllowShared] BufferDataSource` is not built well in our compile-time IDL type converter. We need more template specialization for that.
+// But we should replace BufferDataSource to BufferSource since both are completely same time, and we already support `[AllowShared] BufferSource`.
+typedef ([AllowShared] ArrayBuffer or [AllowShared] ArrayBufferView) AllowSharedBufferDataSource;
+typedef ([AllowShared] Float32Array or sequence<GLfloat>) Float32List;
+typedef ([AllowShared] Int32Array or sequence<GLint>) Int32List;
#if defined(ENABLE_OFFSCREEN_CANVAS)
typedef (HTMLCanvasElement or OffscreenCanvas) WebGLCanvas;
@@ -492,9 +495,9 @@
undefined blendEquationSeparate(GLenum modeRGB, GLenum modeAlpha);
undefined blendFunc(GLenum sfactor, GLenum dfactor);
undefined blendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
- undefined bufferData(GLenum target, BufferDataSource? data, GLenum usage);
+ undefined bufferData(GLenum target, AllowSharedBufferDataSource? data, GLenum usage);
undefined bufferData(GLenum target, GLsizeiptr size, GLenum usage);
- undefined bufferSubData(GLenum target, GLintptr offset, BufferDataSource data);
+ undefined bufferSubData(GLenum target, GLintptr offset, AllowSharedBufferDataSource data);
GLenum checkFramebufferStatus(GLenum target);
undefined clear(GLbitfield mask);
@@ -504,14 +507,14 @@
undefined colorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
undefined compileShader(WebGLShader shader);
- undefined texImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, ArrayBufferView? pixels);
+ undefined texImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, [AllowShared] ArrayBufferView? pixels);
[MayThrowException] undefined texImage2D(GLenum target, GLint level, GLenum internalformat, GLenum format, GLenum type, TexImageSource source);
- undefined texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, ArrayBufferView? pixels);
+ undefined texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, [AllowShared] ArrayBufferView? pixels);
[MayThrowException] undefined texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLenum format, GLenum type, TexImageSource source);
- undefined compressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, ArrayBufferView data);
- undefined compressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, ArrayBufferView data);
+ undefined compressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, [AllowShared] ArrayBufferView data);
+ undefined compressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, [AllowShared] ArrayBufferView data);
undefined copyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
undefined copyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
@@ -607,7 +610,7 @@
undefined pixelStorei(GLenum pname, GLint param);
undefined polygonOffset(GLfloat factor, GLfloat units);
- undefined readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, ArrayBufferView pixels);
+ undefined readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, [AllowShared] ArrayBufferView pixels);
undefined renderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
undefined sampleCoverage(GLclampf value, GLboolean invert);