From bb0430c7e71f170681b4e2bb33972ea8ab7bff94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Tue, 8 Sep 2015 21:52:32 +0300 Subject: [PATCH 01/27] Add WebGL 2 functions glVertexAttribI4iv and glVertexAttribI4uiv. --- src/library_gl.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/library_gl.js b/src/library_gl.js index 1f9e786ee7898..70007bef460bf 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -2447,6 +2447,20 @@ var LibraryGL = { GLctx.vertexAttrib4fv(index, v); }, +#if USE_WEBGL2 + glVertexAttribI4iv__sig: 'vii', + glVertexAttribI4iv: function(index, v) { + v = {{{ makeHEAPView('32', 'v', 'v+' + (4*4)) }}}; + GLctx.vertexAttribI4iv(index, v); + }, + + glVertexAttribI4uiv__sig: 'vii', + glVertexAttribI4uiv: function(index, v) { + v = {{{ makeHEAPView('U32', 'v', 'v+' + (4*4)) }}}; + GLctx.vertexAttribI4uiv(index, v); + }, +#endif + glGetAttribLocation__sig: 'vii', glGetAttribLocation: function(program, name) { program = GL.programs[program]; From 0690a55af6e282d45fc2d556c703c1ff78f0df29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Tue, 8 Sep 2015 21:54:42 +0300 Subject: [PATCH 02/27] Add WebGL 2 functions glVertexAttribI4i and glVertexAttribI4ui. --- src/library_gl.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/library_gl.js b/src/library_gl.js index 70007bef460bf..2a7e897a451a1 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -6536,6 +6536,10 @@ var LibraryGL = { glVertexAttrib2f__sig: 'viii', glVertexAttrib3f__sig: 'viiii', glVertexAttrib4f__sig: 'viiiii', +#if USE_WEBGL2 + glVertexAttribI4i__sig: 'viiiii', + glVertexAttribI4ui_sig: 'viiiii', +#endif glCullFace__sig: 'vi', glBlendFunc__sig: 'vii', glBlendFuncSeparate__sig: 'viiii', @@ -6561,13 +6565,21 @@ var LibraryGL = { // Simple pass-through functions. Starred ones have return values. [X] ones have X in the C name but not in the JS name -[[0, 'finish flush'], +var glFuncs = [[0, 'finish flush'], [1, 'clearDepth clearDepth[f] depthFunc enable disable frontFace cullFace clear lineWidth clearStencil depthMask stencilMask checkFramebufferStatus* generateMipmap activeTexture blendEquation isEnabled*'], [2, 'blendFunc blendEquationSeparate depthRange depthRange[f] stencilMaskSeparate hint polygonOffset vertexAttrib1f sampleCoverage'], [3, 'texParameteri texParameterf vertexAttrib2f stencilFunc stencilOp'], [4, 'viewport clearColor scissor vertexAttrib3f colorMask renderbufferStorage blendFuncSeparate blendColor stencilFuncSeparate stencilOpSeparate'], [5, 'vertexAttrib4f'], - [8, 'copyTexImage2D copyTexSubImage2D']].forEach(function(data) { + [6], + [7], + [8, 'copyTexImage2D copyTexSubImage2D']]; + +#if USE_WEBGL2 +glFuncs[5] = glFuncs[5].concat(['glVertexAttribI4i', 'glVertexAttribI4ui']); +#endif + +glFuncs.forEach(function(data) { var num = data[0]; var names = data[1]; var args = range(num).map(function(i) { return 'x' + i }).join(', '); From c446152e7e827326efbcdb54db20de0c4ea3faeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Tue, 8 Sep 2015 21:56:43 +0300 Subject: [PATCH 03/27] Update instanced rendering/ANGLE_instanced_arrays extension to work on WebGL 2. --- src/library_gl.js | 44 +++++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/src/library_gl.js b/src/library_gl.js index 2a7e897a451a1..1dc4ff92a1b19 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -6463,35 +6463,53 @@ var LibraryGL = { return GLctx.getError(); } }, - - // ANGLE_instanced_arrays WebGL extension related functions - + + // ANGLE_instanced_arrays WebGL extension related functions (in core in WebGL 2) + glVertexAttribDivisor__sig: 'vii', glVertexAttribDivisor: function(index, divisor) { -#if GL_ASSERTIONS - assert(GL.currentContext.instancedArraysExt, 'Must have ANGLE_instanced_arrays extension to use WebGL instancing'); +#if USE_WEBGL2 + if (GL.currentContext.vertexAttribDivisor) { + GL.currentContext.vertexAttribDivisor(index, divisor); + return; + } #endif - GL.currentContext.instancedArraysExt.vertexAttribDivisorANGLE(index, divisor); +#if GL_ASSERTIONS + assert(GL.currentContext.instancedArraysExt, 'Must have ANGLE_instanced_arrays extension or WebGL 2 to use WebGL instancing'); +#endif + GL.currentContext.instancedArraysExt.vertexAttribDivisorANGLE(index, divisor); }, glDrawArraysInstanced__sig: 'viiii', glDrawArraysInstanced: function(mode, first, count, primcount) { -#if GL_ASSERTIONS - assert(GL.currentContext.instancedArraysExt, 'Must have ANGLE_instanced_arrays extension to use WebGL instancing'); +#if USE_WEBGL2 + if (GL.currentContext.drawArraysInstanced) { + GL.currentContext.drawArraysInstanced(mode, first, count, primcount); + return; + } +#endif +#if GL_ASSERTIONS + assert(GL.currentContext.instancedArraysExt, 'Must have ANGLE_instanced_arrays extension or WebGL 2 to use WebGL instancing'); #endif GL.currentContext.instancedArraysExt.drawArraysInstancedANGLE(mode, first, count, primcount); }, - + glDrawElementsInstanced__sig: 'viiiii', glDrawElementsInstanced: function(mode, count, type, indices, primcount) { -#if GL_ASSERTIONS - assert(GL.currentContext.instancedArraysExt, 'Must have ANGLE_instanced_arrays extension to use WebGL instancing'); +#if USE_WEBGL2 + if (GL.currentContext.glDrawElementsInstanced) { + GL.currentContext.glDrawElementsInstanced(mode, count, type, indices, primcount); + return; + } +#endif +#if GL_ASSERTIONS + assert(GL.currentContext.instancedArraysExt, 'Must have ANGLE_instanced_arrays extension or WebGL 2 to use WebGL instancing'); #endif GL.currentContext.instancedArraysExt.drawElementsInstancedANGLE(mode, count, type, indices, primcount); }, - + // OpenGL Desktop/ES 2.0 instancing extensions compatibility - + glVertexAttribDivisorNV: 'glVertexAttribDivisor', glDrawArraysInstancedNV: 'glDrawArraysInstanced', glDrawElementsInstancedNV: 'glDrawElementsInstanced', From b6d04f5e19a6bb0c9d1df24744f9ccca0ca5aa55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Tue, 8 Sep 2015 22:05:55 +0300 Subject: [PATCH 04/27] Implement WebGL2 glDrawRangeElements(), with a workaround. --- src/library_gl.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/library_gl.js b/src/library_gl.js index 1dc4ff92a1b19..b228f7ffff9f7 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -6439,6 +6439,17 @@ var LibraryGL = { #endif }, +#if USE_WEBGL2 + glDrawRangeElements__sig: 'viiiiii', + glDrawRangeElements__deps: ['glDrawElements'], + glDrawRangeElements: function(mode, start, end, count, type, indices) { + // TODO: This should be a trivial pass-though function, but due to https://bugzilla.mozilla.org/show_bug.cgi?id=1202427, + // we work around by ignoring the range. + _glDrawElements(mode, count, type, indices); + GLctx.drawElements(mode, count, type, indices); + }, +#endif + glShaderBinary__sig: 'v', glShaderBinary: function() { GL.recordError(0x0500/*GL_INVALID_ENUM*/); @@ -6595,6 +6606,8 @@ var glFuncs = [[0, 'finish flush'], #if USE_WEBGL2 glFuncs[5] = glFuncs[5].concat(['glVertexAttribI4i', 'glVertexAttribI4ui']); +// TODO: Removed as a workaround, see https://bugzilla.mozilla.org/show_bug.cgi?id=1202427 +//glFuncs[6] = glfuncs[6].concat(['glDrawRangeElements']); #endif glFuncs.forEach(function(data) { From d41630c91f7ee5079618c3b53d9c9eb5f90018b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Tue, 8 Sep 2015 22:09:34 +0300 Subject: [PATCH 05/27] Add WebGL 2 passthrough to glCopyBufferSubData, fix typo in glVertexAttribI4ui__sig. --- src/library_gl.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/library_gl.js b/src/library_gl.js index b228f7ffff9f7..e3b67c42b4a14 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -6567,7 +6567,8 @@ var LibraryGL = { glVertexAttrib4f__sig: 'viiiii', #if USE_WEBGL2 glVertexAttribI4i__sig: 'viiiii', - glVertexAttribI4ui_sig: 'viiiii', + glVertexAttribI4ui__sig: 'viiiii', + glCopyBufferSubData__sig: 'viiiii', #endif glCullFace__sig: 'vi', glBlendFunc__sig: 'vii', @@ -6605,7 +6606,7 @@ var glFuncs = [[0, 'finish flush'], [8, 'copyTexImage2D copyTexSubImage2D']]; #if USE_WEBGL2 -glFuncs[5] = glFuncs[5].concat(['glVertexAttribI4i', 'glVertexAttribI4ui']); +glFuncs[5] = glFuncs[5].concat(['glVertexAttribI4i', 'glVertexAttribI4ui', 'glCopyBufferSubData']); // TODO: Removed as a workaround, see https://bugzilla.mozilla.org/show_bug.cgi?id=1202427 //glFuncs[6] = glfuncs[6].concat(['glDrawRangeElements']); #endif From ba076444f1b434fa510c4c633d2138244e65bdc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Tue, 8 Sep 2015 22:16:54 +0300 Subject: [PATCH 06/27] Enable using vertex array objects in WebGL 2 mode. --- src/library_gl.js | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/library_gl.js b/src/library_gl.js index e3b67c42b4a14..0b967d3217a08 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -2855,11 +2855,16 @@ var LibraryGL = { _emulGlGenVertexArrays(n, arrays); #else #if GL_ASSERTIONS - assert(GL.currentContext.vaoExt, 'Must have OES_vertex_array_object to use vao'); + assert(GL.currentContext.vaoExt, 'Must have WebGL2 or OES_vertex_array_object to use vao'); #endif for(var i = 0; i < n; i++) { - var vao = GL.currentContext.vaoExt.createVertexArrayOES(); + var vao; +#if USE_WEBGL2 + if (GL.currentContext.createVertexArray) vao = GL.currentContext.createVertexArray(); + if (!vao) +#endif + vao = GL.currentContext.vaoExt.createVertexArrayOES(); if (!vao) { GL.recordError(0x0502 /* GL_INVALID_OPERATION */); #if GL_ASSERTIONS @@ -2885,11 +2890,15 @@ var LibraryGL = { _emulGlDeleteVertexArrays(n, vaos); #else #if GL_ASSERTIONS - assert(GL.currentContext.vaoExt, 'Must have OES_vertex_array_object to use vao'); + assert(GL.currentContext.vaoExt, 'Must have WebGL2 or OES_vertex_array_object to use vao'); #endif for(var i = 0; i < n; i++) { var id = {{{ makeGetValue('vaos', 'i*4', 'i32') }}}; - GL.currentContext.vaoExt.deleteVertexArrayOES(GL.vaos[id]); +#if USE_WEBGL2 + if (GL.currentContext.deleteVertexArray) GL.currentContext.deleteVertexArray(GL.vaos[id]); + else +#endif + GL.currentContext.vaoExt.deleteVertexArrayOES(GL.vaos[id]); GL.vaos[id] = null; } #endif @@ -2904,10 +2913,13 @@ var LibraryGL = { _emulGlBindVertexArray(vao); #else #if GL_ASSERTIONS - assert(GL.currentContext.vaoExt, 'Must have OES_vertex_array_object to use vao'); + assert(GL.currentContext.vaoExt, 'Must have WebGL2 or OES_vertex_array_object to use vao'); #endif - - GL.currentContext.vaoExt.bindVertexArrayOES(GL.vaos[vao]); +#if USE_WEBGL2 + if (GL.currentContext.bindVertexArray) GL.currentContext.bindVertexArray(GL.vaos[vao]); + else +#endif + GL.currentContext.vaoExt.bindVertexArrayOES(GL.vaos[vao]); #endif }, From 72a64c233601d058bd52fe8699819659524550ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Tue, 8 Sep 2015 22:27:15 +0300 Subject: [PATCH 07/27] Add no-op stubs of GLES3 entry points glProgramParameteri(), glGetProgramBinary() and glProgramBinary(). --- src/library_gl.js | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/library_gl.js b/src/library_gl.js index 0b967d3217a08..37a22897a9218 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -2767,6 +2767,33 @@ var LibraryGL = { return GLctx.isProgram(program); }, +#if USE_WEBGL2 + glProgramParameteri__sig: 'viii', + glProgramParameteri: function(program, pname, value) { + GL.recordError(0x0500/*GL_INVALID_ENUM*/); +#if GL_ASSERTIONS + Module.printErr("GL_INVALID_ENUM in glProgramParameteri: WebGL does not support binary shader formats! Calls to glProgramParameteri always fail. See https://www.khronos.org/registry/webgl/specs/latest/2.0/#5.4"); +#endif + }, + + glGetProgramBinary__sig: 'viiiii', + glGetProgramBinary: function(program, bufSize, length, binaryFormat, binary) { + GL.recordError(0x0502/*GL_INVALID_OPERATION*/); +#if GL_ASSERTIONS + Module.printErr("GL_INVALID_OPERATION in glGetProgramBinary: WebGL does not support binary shader formats! Calls to glGetProgramBinary always fail. See https://www.khronos.org/registry/webgl/specs/latest/2.0/#5.4"); +#endif + }, + + glProgramBinary__sig: 'viiii', + glProgramBinary: function(program, binaryFormat, binary, length) { + GL.recordError(0x0500/*GL_INVALID_ENUM*/); +#if GL_ASSERTIONS + Module.printErr("GL_INVALID_ENUM in glProgramBinary: WebGL does not support binary shader formats! Calls to glProgramBinary always fail. See https://www.khronos.org/registry/webgl/specs/latest/2.0/#5.4"); +#endif + }, + +#endif + glBindAttribLocation__sig: 'viii', glBindAttribLocation: function(program, index, name) { #if GL_ASSERTIONS @@ -6467,7 +6494,7 @@ var LibraryGL = { GL.recordError(0x0500/*GL_INVALID_ENUM*/); #if GL_ASSERTIONS Module.printErr("GL_INVALID_ENUM in glShaderBinary: WebGL does not support binary shader formats! Calls to glShaderBinary always fail."); -#endif +#endif }, glReleaseShaderCompiler__sig: 'v', From a380a75c193fe87cfe4fcf250ae763bd6734f8d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Tue, 8 Sep 2015 22:34:06 +0300 Subject: [PATCH 08/27] Add WebGL 2 functions glUniform{1234}ui and glUniform{1234}uiv. --- src/library_gl.js | 81 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/src/library_gl.js b/src/library_gl.js index 37a22897a9218..2119422a7f753 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -2345,6 +2345,87 @@ var LibraryGL = { GLctx.uniform4fv(location, view); }, +#if USE_WEBGL2 + glUniform1ui__sig: 'vii', + glUniform1ui: function(location, v0) { +#if GL_ASSERTIONS + GL.validateGLObjectID(GL.uniforms, location, 'glUniform1ui', 'location'); +#endif + location = GL.uniforms[location]; + GLctx.uniform1ui(location, v0); + }, + + glUniform2ui__sig: 'viii', + glUniform2ui: function(location, v0, v1) { +#if GL_ASSERTIONS + GL.validateGLObjectID(GL.uniforms, location, 'glUniform2ui', 'location'); +#endif + location = GL.uniforms[location]; + GLctx.uniform2ui(location, v0, v1); + }, + + glUniform3ui__sig: 'viiii', + glUniform3ui: function(location, v0, v1, v2) { +#if GL_ASSERTIONS + GL.validateGLObjectID(GL.uniforms, location, 'glUniform3ui', 'location'); +#endif + location = GL.uniforms[location]; + GLctx.uniform3ui(location, v0, v1, v2); + }, + + glUniform4ui__sig: 'viiiii', + glUniform4ui: function(location, v0, v1, v2, v3) { +#if GL_ASSERTIONS + GL.validateGLObjectID(GL.uniforms, location, 'glUniform4ui', 'location'); +#endif + location = GL.uniforms[location]; + GLctx.uniform4ui(location, v0, v1, v2, v3); + }, + + glUniform1uiv__sig: 'viii', + glUniform1uiv: function(location, count, value) { +#if GL_ASSERTIONS + GL.validateGLObjectID(GL.uniforms, location, 'glUniform1uiv', 'location'); +#endif + location = GL.uniforms[location]; + value = {{{ makeHEAPView('32', 'value', 'value+count*4') }}}; + GLctx.uniform1uiv(location, value); + }, + + glUniform2uiv__sig: 'viii', + glUniform2uiv: function(location, count, value) { +#if GL_ASSERTIONS + GL.validateGLObjectID(GL.uniforms, location, 'glUniform2uiv', 'location'); +#endif + location = GL.uniforms[location]; + count *= 2; + value = {{{ makeHEAPView('32', 'value', 'value+count*4') }}}; + GLctx.uniform2uiv(location, value); + }, + + glUniform3uiv__sig: 'viii', + glUniform3uiv: function(location, count, value) { +#if GL_ASSERTIONS + GL.validateGLObjectID(GL.uniforms, location, 'glUniform3uiv', 'location'); +#endif + location = GL.uniforms[location]; + count *= 3; + value = {{{ makeHEAPView('32', 'value', 'value+count*4') }}}; + GLctx.uniform3uiv(location, value); + }, + + glUniform4uiv__sig: 'viii', + glUniform4uiv: function(location, count, value) { +#if GL_ASSERTIONS + GL.validateGLObjectID(GL.uniforms, location, 'glUniform4uiv', 'location'); +#endif + location = GL.uniforms[location]; + count *= 4; + value = {{{ makeHEAPView('32', 'value', 'value+count*4') }}}; + GLctx.uniform4uiv(location, value); + }, +#endif + glUniformMatrix2fv__sig: 'viiii', glUniformMatrix2fv: function(location, count, transpose, value) { #if GL_ASSERTIONS From e272894ae83e3e19840508d8a7539d282363d2af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Tue, 8 Sep 2015 22:46:22 +0300 Subject: [PATCH 09/27] Fix syntax error in the handling of addition of WebGL 2 pass through entry points. --- src/library_gl.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/library_gl.js b/src/library_gl.js index 2119422a7f753..68a3f71f2d211 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -6721,14 +6721,14 @@ var glFuncs = [[0, 'finish flush'], [3, 'texParameteri texParameterf vertexAttrib2f stencilFunc stencilOp'], [4, 'viewport clearColor scissor vertexAttrib3f colorMask renderbufferStorage blendFuncSeparate blendColor stencilFuncSeparate stencilOpSeparate'], [5, 'vertexAttrib4f'], - [6], - [7], + [6, ''], + [7, ''], [8, 'copyTexImage2D copyTexSubImage2D']]; #if USE_WEBGL2 -glFuncs[5] = glFuncs[5].concat(['glVertexAttribI4i', 'glVertexAttribI4ui', 'glCopyBufferSubData']); +glFuncs[5][1] += ' glVertexAttribI4i glVertexAttribI4ui glCopyBufferSubData'; // TODO: Removed as a workaround, see https://bugzilla.mozilla.org/show_bug.cgi?id=1202427 -//glFuncs[6] = glfuncs[6].concat(['glDrawRangeElements']); +glFuncs[6][1] += ' glDrawRangeElements'; #endif glFuncs.forEach(function(data) { @@ -6739,6 +6739,7 @@ glFuncs.forEach(function(data) { var returnStub = '(function(' + args + ') { return GLctx.NAME(' + args + ') })'; var sigEnd = range(num).map(function() { return 'i' }).join(''); names.split(' ').forEach(function(name) { + if (name.length == 0) return; var stub = plainStub; var sig; if (name[name.length-1] == '*') { From 3fb8b1ab7d233c08be4ad04a0d1ab550e562bc3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Tue, 8 Sep 2015 22:53:28 +0300 Subject: [PATCH 10/27] Add WebGL 2 entry points for nonsquare matrices. --- src/library_gl.js | 116 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) diff --git a/src/library_gl.js b/src/library_gl.js index 68a3f71f2d211..ff80eae469c24 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -2483,6 +2483,122 @@ var LibraryGL = { GLctx.uniformMatrix4fv(location, transpose, view); }, +#if USE_WEBGL2 + glUniformMatrix2x3fv__sig: 'viiii', + glUniformMatrix2x3fv: function(location, count, transpose, value) { +#if GL_ASSERTIONS + GL.validateGLObjectID(GL.uniforms, location, 'glUniformMatrix2x3fv', 'location'); +#endif + location = GL.uniforms[location]; + var view; + if (count === 1) { + // avoid allocation for the common case of uploading one uniform matrix + view = GL.miniTempBufferViews[5]; + for (var i = 0; i < 6; i++) { + view[i] = {{{ makeGetValue('value', 'i*4', 'float') }}}; + } + } else { + view = {{{ makeHEAPView('F32', 'value', 'value+count*24') }}}; + } + GLctx.uniformMatrix2x3fv(location, transpose, view); + }, + + glUniformMatrix3x2fv__sig: 'viiii', + glUniformMatrix3x2fv: function(location, count, transpose, value) { +#if GL_ASSERTIONS + GL.validateGLObjectID(GL.uniforms, location, 'glUniformMatrix3x2fv', 'location'); +#endif + location = GL.uniforms[location]; + var view; + if (count === 1) { + // avoid allocation for the common case of uploading one uniform matrix + view = GL.miniTempBufferViews[5]; + for (var i = 0; i < 6; i++) { + view[i] = {{{ makeGetValue('value', 'i*4', 'float') }}}; + } + } else { + view = {{{ makeHEAPView('F32', 'value', 'value+count*24') }}}; + } + GLctx.uniformMatrix3x2fv(location, transpose, view); + }, + + glUniformMatrix2x4fv__sig: 'viiii', + glUniformMatrix2x4fv: function(location, count, transpose, value) { +#if GL_ASSERTIONS + GL.validateGLObjectID(GL.uniforms, location, 'glUniformMatrix2x4fv', 'location'); +#endif + location = GL.uniforms[location]; + var view; + if (count === 1) { + // avoid allocation for the common case of uploading one uniform matrix + view = GL.miniTempBufferViews[7]; + for (var i = 0; i < 8; i++) { + view[i] = {{{ makeGetValue('value', 'i*4', 'float') }}}; + } + } else { + view = {{{ makeHEAPView('F32', 'value', 'value+count*32') }}}; + } + GLctx.uniformMatrix2x4fv(location, transpose, view); + }, + + glUniformMatrix4x2fv__sig: 'viiii', + glUniformMatrix4x2fv: function(location, count, transpose, value) { +#if GL_ASSERTIONS + GL.validateGLObjectID(GL.uniforms, location, 'glUniformMatrix4x2fv', 'location'); +#endif + location = GL.uniforms[location]; + var view; + if (count === 1) { + // avoid allocation for the common case of uploading one uniform matrix + view = GL.miniTempBufferViews[7]; + for (var i = 0; i < 8; i++) { + view[i] = {{{ makeGetValue('value', 'i*4', 'float') }}}; + } + } else { + view = {{{ makeHEAPView('F32', 'value', 'value+count*32') }}}; + } + GLctx.uniformMatrix4x2fv(location, transpose, view); + }, + + glUniformMatrix3x4fv__sig: 'viiii', + glUniformMatrix3x4fv: function(location, count, transpose, value) { +#if GL_ASSERTIONS + GL.validateGLObjectID(GL.uniforms, location, 'glUniformMatrix3x4fv', 'location'); +#endif + location = GL.uniforms[location]; + var view; + if (count === 1) { + // avoid allocation for the common case of uploading one uniform matrix + view = GL.miniTempBufferViews[11]; + for (var i = 0; i < 12; i++) { + view[i] = {{{ makeGetValue('value', 'i*4', 'float') }}}; + } + } else { + view = {{{ makeHEAPView('F32', 'value', 'value+count*48') }}}; + } + GLctx.uniformMatrix3x4fv(location, transpose, view); + }, + + glUniformMatrix3x4fv__sig: 'viiii', + glUniformMatrix4x3fv: function(location, count, transpose, value) { +#if GL_ASSERTIONS + GL.validateGLObjectID(GL.uniforms, location, 'glUniformMatrix4x3fv', 'location'); +#endif + location = GL.uniforms[location]; + var view; + if (count === 1) { + // avoid allocation for the common case of uploading one uniform matrix + view = GL.miniTempBufferViews[11]; + for (var i = 0; i < 12; i++) { + view[i] = {{{ makeGetValue('value', 'i*4', 'float') }}}; + } + } else { + view = {{{ makeHEAPView('F32', 'value', 'value+count*48') }}}; + } + GLctx.uniformMatrix4x3fv(location, transpose, view); + }, +#endif + glBindBuffer__sig: 'vii', glBindBuffer: function(target, buffer) { #if GL_ASSERTIONS From 503c0da9e09e2decfb2fcc6dc9cb46d55325b2dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Tue, 8 Sep 2015 22:58:31 +0300 Subject: [PATCH 11/27] Move WebGL 2 transform feedback functions to the list of autogenerated passthroughs. --- src/library_gl.js | 36 +++++++++++------------------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/src/library_gl.js b/src/library_gl.js index ff80eae469c24..61334b6ad3ded 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -1661,26 +1661,6 @@ var LibraryGL = { GLctx['bindTransformFeedback'](target, transformFeedback); }, - glBeginTransformFeedback__sig: 'vi', - glBeginTransformFeedback: function(primitiveMode) { - GLctx['beginTransformFeedback'](primitiveMode); - }, - - glEndTransformFeedback__sig: 'v', - glEndTransformFeedback: function() { - GLctx['endTransformFeedback'](); - }, - - glPauseTransformFeedback__sig: 'v', - glPauseTransformFeedback: function() { - GLctx['pauseTransformFeedback'](); - }, - - glResumeTransformFeedback__sig: 'v', - glResumeTransformFeedback: function() { - GLctx['resumeTransformFeedback'](); - }, - glTransformFeedbackVaryings__sig: 'viiii', glTransformFeedbackVaryings: function(program, count, varyings, bufferMode) { #if GL_ASSERTIONS @@ -6801,11 +6781,6 @@ var LibraryGL = { glVertexAttrib2f__sig: 'viii', glVertexAttrib3f__sig: 'viiii', glVertexAttrib4f__sig: 'viiiii', -#if USE_WEBGL2 - glVertexAttribI4i__sig: 'viiiii', - glVertexAttribI4ui__sig: 'viiiii', - glCopyBufferSubData__sig: 'viiiii', -#endif glCullFace__sig: 'vi', glBlendFunc__sig: 'vii', glBlendFuncSeparate__sig: 'viiii', @@ -6827,6 +6802,15 @@ var LibraryGL = { glIsEnabled__sig: 'ii', glFrontFace__sig: 'vi', glSampleCoverage__sig: 'vii', +#if USE_WEBGL2 + glVertexAttribI4i__sig: 'viiiii', + glVertexAttribI4ui__sig: 'viiiii', + glCopyBufferSubData__sig: 'viiiii', + glBeginTransformFeedback__sig: 'vi', + glEndTransformFeedback__sig: 'v', + glPauseTransformFeedback__sig: 'v', + glResumeTransformFeedback__sig: 'v', +#endif }; @@ -6842,6 +6826,8 @@ var glFuncs = [[0, 'finish flush'], [8, 'copyTexImage2D copyTexSubImage2D']]; #if USE_WEBGL2 +glFuncs[0][1] += ' glEndTransformFeedback glPauseTransformFeedback glResumeTransformFeedback'; +glFuncs[1][1] += ' glBeginTransformFeedback'; glFuncs[5][1] += ' glVertexAttribI4i glVertexAttribI4ui glCopyBufferSubData'; // TODO: Removed as a workaround, see https://bugzilla.mozilla.org/show_bug.cgi?id=1202427 glFuncs[6][1] += ' glDrawRangeElements'; From 58b75dbd365f3098bb74a7c112b5afb4c6ca191d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Tue, 8 Sep 2015 23:27:28 +0300 Subject: [PATCH 12/27] Move more trivial WebGL 2 passthrough functions to being autogenerated. --- src/library_gl.js | 51 +++++++++++++---------------------------------- 1 file changed, 14 insertions(+), 37 deletions(-) diff --git a/src/library_gl.js b/src/library_gl.js index 61334b6ad3ded..34a02b1fab79e 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -1370,16 +1370,6 @@ var LibraryGL = { GLctx['invalidateSubFramebuffer'](target, list, x, y, width, height); }, - glTexStorage2D__sig: 'viiiii', - glTexStorage2D: function(target, levels, internalformat, width, height) { - GLctx['texStorage2D'](target, levels, internalformat, width, height); - }, - - glTexStorage3D__sig: 'viiiiii', - glTexStorage3D: function(target, levels, internalformat, width, height, depth) { - GLctx['texStorage3D'](target, levels, internalformat, width, height, depth); - }, - glTexImage3D__sig: 'viiiiiiiiii', glTexImage3D: function(target, level, internalFormat, width, height, depth, border, format, type, data) { GLctx['texImage3D'](target, level, internalFormat, width, height, depth, border, format, type, @@ -1392,17 +1382,6 @@ var LibraryGL = { HEAPU8.subarray(data)); }, - // Framebuffer objects - glBlitFramebuffer__sig: 'viiiiiiiiii', - glBlitFramebuffer: function(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter) { - GLctx['blitFramebuffer'](srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); - }, - - glReadBuffer__sig: 'vi', - glReadBuffer: function(src) { - GLctx['readBuffer'](src); - }, - // Queries glGenQueries__sig: 'vii', glGenQueries: function(n, ids) { @@ -1450,11 +1429,6 @@ var LibraryGL = { GLctx['beginQuery'](target, id ? GL.queries[id] : null); }, - glEndQuery__sig: 'vi', - glEndQuery: function(target) { - GLctx['endQuery'](target); - }, - glGetQueryiv__sig: 'viii', glGetQueryiv: function(target, pname, params) { #if GL_ASSERTIONS @@ -1492,12 +1466,6 @@ var LibraryGL = { {{{ makeSetValue('params', '0', 'ret', 'i32') }}}; }, - // Renderbuffer objects - glRenderbufferStorageMultisample__sig: 'viiiii', - glRenderbufferStorageMultisample: function(target, samples, internalformat, width, height) { - GLctx['renderbufferStorageMultisample'](target, samples, internalformat, width, height); - }, - // Sampler objects glGenSamplers__sig: 'vii', glGenSamplers: function(n, samplers) { @@ -6806,14 +6774,19 @@ var LibraryGL = { glVertexAttribI4i__sig: 'viiiii', glVertexAttribI4ui__sig: 'viiiii', glCopyBufferSubData__sig: 'viiiii', + glTexStorage2D__sig: 'viiiii', + glTexStorage3D__sig: 'viiiiii', glBeginTransformFeedback__sig: 'vi', glEndTransformFeedback__sig: 'v', glPauseTransformFeedback__sig: 'v', glResumeTransformFeedback__sig: 'v', + glBlitFramebuffer__sig: 'viiiiiiiiii', + glReadBuffer__sig: 'vi', + glEndQuery__sig: 'vi', + glRenderbufferStorageMultisample__sig: 'viiiii', #endif }; - // Simple pass-through functions. Starred ones have return values. [X] ones have X in the C name but not in the JS name var glFuncs = [[0, 'finish flush'], [1, 'clearDepth clearDepth[f] depthFunc enable disable frontFace cullFace clear lineWidth clearStencil depthMask stencilMask checkFramebufferStatus* generateMipmap activeTexture blendEquation isEnabled*'], @@ -6823,14 +6796,18 @@ var glFuncs = [[0, 'finish flush'], [5, 'vertexAttrib4f'], [6, ''], [7, ''], - [8, 'copyTexImage2D copyTexSubImage2D']]; + [8, 'copyTexImage2D copyTexSubImage2D'], + [9, ''], + [10, '']]; #if USE_WEBGL2 glFuncs[0][1] += ' glEndTransformFeedback glPauseTransformFeedback glResumeTransformFeedback'; -glFuncs[1][1] += ' glBeginTransformFeedback'; -glFuncs[5][1] += ' glVertexAttribI4i glVertexAttribI4ui glCopyBufferSubData'; +glFuncs[1][1] += ' glBeginTransformFeedback glReadBuffer glEndQuery'; +glFuncs[5][1] += ' glVertexAttribI4i glVertexAttribI4ui glCopyBufferSubData glTexStorage2D glRenderbufferStorageMultisample'; // TODO: Removed as a workaround, see https://bugzilla.mozilla.org/show_bug.cgi?id=1202427 -glFuncs[6][1] += ' glDrawRangeElements'; +//glFuncs[6][1] += ' glDrawRangeElements'; +glFuncs[6][1] += ' glTexStorage3D'; +glFuncs[10][1] += ' glBlitFramebuffer'; #endif glFuncs.forEach(function(data) { From 7b7e0433d78ea26e7a261dd1cdf2c2ba6229f399 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Tue, 8 Sep 2015 23:33:21 +0300 Subject: [PATCH 13/27] Add WebGL2 glCopyTexSubImage3D() function entry point. --- src/library_gl.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/library_gl.js b/src/library_gl.js index 34a02b1fab79e..b3ff9527f8f2a 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -6784,6 +6784,7 @@ var LibraryGL = { glReadBuffer__sig: 'vi', glEndQuery__sig: 'vi', glRenderbufferStorageMultisample__sig: 'viiiii', + glCopyTexSubImage3D__sig: ['viiiiiiiii'], #endif }; @@ -6807,6 +6808,7 @@ glFuncs[5][1] += ' glVertexAttribI4i glVertexAttribI4ui glCopyBufferSubData glTe // TODO: Removed as a workaround, see https://bugzilla.mozilla.org/show_bug.cgi?id=1202427 //glFuncs[6][1] += ' glDrawRangeElements'; glFuncs[6][1] += ' glTexStorage3D'; +glFuncs[9][1] += ' glCopyTexSubImage3D'; glFuncs[10][1] += ' glBlitFramebuffer'; #endif From 7eeedb9cd8029f7b6d0193f9bc4c384e91feb076 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Tue, 8 Sep 2015 23:35:41 +0300 Subject: [PATCH 14/27] Fix WebGL 2 passthrough entry points to omit the gl- prefix. --- src/library_gl.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/library_gl.js b/src/library_gl.js index b3ff9527f8f2a..095e4814cb77e 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -6802,14 +6802,14 @@ var glFuncs = [[0, 'finish flush'], [10, '']]; #if USE_WEBGL2 -glFuncs[0][1] += ' glEndTransformFeedback glPauseTransformFeedback glResumeTransformFeedback'; -glFuncs[1][1] += ' glBeginTransformFeedback glReadBuffer glEndQuery'; -glFuncs[5][1] += ' glVertexAttribI4i glVertexAttribI4ui glCopyBufferSubData glTexStorage2D glRenderbufferStorageMultisample'; +glFuncs[0][1] += ' endTransformFeedback pauseTransformFeedback resumeTransformFeedback'; +glFuncs[1][1] += ' beginTransformFeedback readBuffer endQuery'; +glFuncs[5][1] += ' vertexAttribI4i vertexAttribI4ui copyBufferSubData texStorage2D renderbufferStorageMultisample'; // TODO: Removed as a workaround, see https://bugzilla.mozilla.org/show_bug.cgi?id=1202427 -//glFuncs[6][1] += ' glDrawRangeElements'; -glFuncs[6][1] += ' glTexStorage3D'; -glFuncs[9][1] += ' glCopyTexSubImage3D'; -glFuncs[10][1] += ' glBlitFramebuffer'; +//glFuncs[6][1] += ' drawRangeElements'; +glFuncs[6][1] += ' texStorage3D'; +glFuncs[9][1] += ' copyTexSubImage3D'; +glFuncs[10][1] += ' blitFramebuffer'; #endif glFuncs.forEach(function(data) { From 632f30a44ea518524de77a02282b3577bce7068a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Tue, 8 Sep 2015 23:48:10 +0300 Subject: [PATCH 15/27] Remove bad asserts in glCompressedTexImage2D() and glCompressedTexSubImage2D(). Remove automatic enabling of extensions that are assumed only legacy GL emulation mode. --- src/library_gl.js | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/library_gl.js b/src/library_gl.js index 095e4814cb77e..027cbff6baa61 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -807,7 +807,6 @@ var LibraryGL = { // In GLES2, all extensions are enabled by default without additional operations. Init all extensions we need to give to GLES2 user // code here, so that GLES2 code can operate without changing behavior. initExtensions: function(context) { - // If this function is called without a specific context object, init the extensions of the currently active context. if (!context) context = GL.currentContext; @@ -827,10 +826,10 @@ var LibraryGL = { #endif // Detect the presence of a few extensions manually, this GL interop layer itself will need to know if they exist. +#if LEGACY_GL_EMULATION context.compressionExt = GLctx.getExtension('WEBGL_compressed_texture_s3tc'); context.anisotropicExt = GLctx.getExtension('EXT_texture_filter_anisotropic'); - context.floatExt = GLctx.getExtension('OES_texture_float'); - +#endif // Extension available from Firefox 26 and Google Chrome 30 context.instancedArraysExt = GLctx.getExtension('ANGLE_instanced_arrays'); @@ -1074,9 +1073,6 @@ var LibraryGL = { glCompressedTexImage2D__sig: 'viiiiiiii', glCompressedTexImage2D: function(target, level, internalFormat, width, height, border, imageSize, data) { -#if ASSERTIONS - assert(GL.currentContext.compressionExt); -#endif if (data) { data = {{{ makeHEAPView('U8', 'data', 'data+imageSize') }}}; } else { @@ -1088,9 +1084,6 @@ var LibraryGL = { glCompressedTexSubImage2D__sig: 'viiiiiiiii', glCompressedTexSubImage2D: function(target, level, xoffset, yoffset, width, height, format, imageSize, data) { -#if ASSERTIONS - assert(GL.currentContext.compressionExt); -#endif if (data) { data = {{{ makeHEAPView('U8', 'data', 'data+imageSize') }}}; } else { From 7b675d80b82add6469993b54caab155c9e2df132 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Tue, 8 Sep 2015 23:51:18 +0300 Subject: [PATCH 16/27] Add WebGL 2 entry points glCompressedTexImage3D() and glCompressedTexSubImage3D(). Change the texture upload code to avoid polymorphic code pattern (out of habit/style). --- src/library_gl.js | 56 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 14 deletions(-) diff --git a/src/library_gl.js b/src/library_gl.js index 027cbff6baa61..e0af86c634871 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -1073,46 +1073,74 @@ var LibraryGL = { glCompressedTexImage2D__sig: 'viiiiiiii', glCompressedTexImage2D: function(target, level, internalFormat, width, height, border, imageSize, data) { + var heapView; if (data) { - data = {{{ makeHEAPView('U8', 'data', 'data+imageSize') }}}; + heapView = {{{ makeHEAPView('U8', 'data', 'data+imageSize') }}}; } else { - data = null; + heapView = null; } - // N.b. using array notation explicitly to not confuse Closure minification. - GLctx['compressedTexImage2D'](target, level, internalFormat, width, height, border, data); + GLctx['compressedTexImage2D'](target, level, internalFormat, width, height, border, heapView); }, +#if USE_WEBGL2 + glCompressedTexImage3D__sig: 'viiiiiiiii', + glCompressedTexImage3D: function(target, level, internalFormat, width, height, depth, border, imageSize, data) { + var heapView; + if (data) { + heapView = {{{ makeHEAPView('U8', 'data', 'data+imageSize') }}}; + } else { + heapView = null; + } + GLctx['compressedTexImage3D'](target, level, internalFormat, width, height, depth, border, heapView); + }, +#endif + glCompressedTexSubImage2D__sig: 'viiiiiiiii', glCompressedTexSubImage2D: function(target, level, xoffset, yoffset, width, height, format, imageSize, data) { + var heapView; if (data) { - data = {{{ makeHEAPView('U8', 'data', 'data+imageSize') }}}; + heapView = {{{ makeHEAPView('U8', 'data', 'data+imageSize') }}}; } else { - data = null; + heapView = null; } - GLctx['compressedTexSubImage2D'](target, level, xoffset, yoffset, width, height, format, data); + GLctx['compressedTexSubImage2D'](target, level, xoffset, yoffset, width, height, format, heapView); }, +#if USE_WEBGL2 + glCompressedTexSubImage3D__sig: 'viiiiiiiiiii', + glCompressedTexSubImage3D: function(target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data) { + var heapView; + if (data) { + heapView = {{{ makeHEAPView('U8', 'data', 'data+imageSize') }}}; + } else { + heapView = null; + } + GLctx['compressedTexSubImage2D'](target, level, xoffset, yoffset, zoffset, width, height, depth, format, heapView); + }, +#endif + glTexImage2D__sig: 'viiiiiiiii', glTexImage2D: function(target, level, internalFormat, width, height, border, format, type, pixels) { + var pixelData; if (pixels) { var data = GL.getTexPixelData(type, format, width, height, pixels, internalFormat); - pixels = data.pixels; + pixelData = data.pixels; internalFormat = data.internalFormat; } else { - pixels = null; + pixelData = null; } - GLctx.texImage2D(target, level, internalFormat, width, height, border, format, type, pixels); + GLctx.texImage2D(target, level, internalFormat, width, height, border, format, type, pixelData); }, glTexSubImage2D__sig: 'viiiiiiiii', glTexSubImage2D: function(target, level, xoffset, yoffset, width, height, format, type, pixels) { + var pixelData; if (pixels) { - var data = GL.getTexPixelData(type, format, width, height, pixels, -1); - pixels = data.pixels; + pixelData = GL.getTexPixelData(type, format, width, height, pixels, -1).pixels; } else { - pixels = null; + pixelData = null; } - GLctx.texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); + GLctx.texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixelData); }, glReadPixels__sig: 'viiiiiii', From 000fac6e612668c3b0f085e83e17a5a301b9b2f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Tue, 8 Sep 2015 23:59:43 +0300 Subject: [PATCH 17/27] Add WebGL 2 function glGetFragDataLocation(). --- src/library_gl.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/library_gl.js b/src/library_gl.js index e0af86c634871..1592d97e87612 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -2033,6 +2033,16 @@ var LibraryGL = { } }, +#if USE_WEBGL2 + glGetFragDataLocation__sig: 'iii', + glGetFragDataLocation: function(program, name) { +#if GL_ASSERTIONS + GL.validateGLObjectID(GL.programs, program, 'glGetFragDataLocation', 'program'); +#endif + return GL.currentContext.getFragDataLocation(GL.programs[program], Pointer_stringify(name)); + }, +#endif + glGetVertexAttribfv__sig: 'viii', glGetVertexAttribfv: function(index, pname, params) { #if GL_ASSERTIONS @@ -2957,7 +2967,6 @@ var LibraryGL = { Module.printErr("GL_INVALID_ENUM in glProgramBinary: WebGL does not support binary shader formats! Calls to glProgramBinary always fail. See https://www.khronos.org/registry/webgl/specs/latest/2.0/#5.4"); #endif }, - #endif glBindAttribLocation__sig: 'viii', From 89e24cc00fade8758de44b7b31a78533943c53ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Wed, 9 Sep 2015 00:02:30 +0300 Subject: [PATCH 18/27] Add missing WebGL1 glBlendColor__sig field. --- src/library_gl.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/library_gl.js b/src/library_gl.js index 1592d97e87612..b9bdf89b39a79 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -6782,6 +6782,7 @@ var LibraryGL = { glCullFace__sig: 'vi', glBlendFunc__sig: 'vii', glBlendFuncSeparate__sig: 'viiii', + glBlendColor__sig: 'vffff', glPolygonOffset__sig: 'vii', glColorMask__sig: 'viiii', glStencilOp__sig: 'viii', From 5723c102f5aaa3129bb1ce63b59119aee37ab488 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Wed, 9 Sep 2015 00:15:38 +0300 Subject: [PATCH 19/27] Add WebGL 2 entry points glClearBufferiv(), glClearBufferuiv(), glClearBufferfv() and glClearBufferfi(). Fix typo in glCopyTexSubImage3D__sig. --- src/library_gl.js | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/library_gl.js b/src/library_gl.js index b9bdf89b39a79..b497257a9519e 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -1883,6 +1883,27 @@ var LibraryGL = { GLctx['uniformBlockBinding'](program, uniformBlockIndex, uniformBlockBinding); }, + glClearBufferiv__sig: 'viii', + glClearBufferiv: function(buffer, drawbuffer, value) { + var view = {{{ makeHEAPView('32', 'value', 'value+16') }}}; + GLctx['clearBufferiv'](buffer, drawbuffer, view); + }, + + glClearBufferuiv__sig: 'viii', + glClearBufferuiv: function(buffer, drawbuffer, value) { + var view = {{{ makeHEAPView('32', 'value', 'value+16') }}}; + GLctx['clearBufferuiv'](buffer, drawbuffer, view); + }, + + glClearBufferfv__sig: 'viii', + glClearBufferfv: function(buffer, drawbuffer, value) { + view = GL.miniTempBufferViews[3]; + view[0] = {{{ makeGetValue('value', '0', 'float') }}}; + view[1] = {{{ makeGetValue('value', '4', 'float') }}}; + view[2] = {{{ makeGetValue('value', '8', 'float') }}}; + view[3] = {{{ makeGetValue('value', '12', 'float') }}}; + GLctx['clearBufferuiv'](buffer, drawbuffer, view); + }, // ~USE_WEBGL2 #endif @@ -6815,7 +6836,8 @@ var LibraryGL = { glReadBuffer__sig: 'vi', glEndQuery__sig: 'vi', glRenderbufferStorageMultisample__sig: 'viiiii', - glCopyTexSubImage3D__sig: ['viiiiiiiii'], + glCopyTexSubImage3D__sig: 'viiiiiiiii', + glClearBufferfi__sig: 'viifi', #endif }; @@ -6835,6 +6857,7 @@ var glFuncs = [[0, 'finish flush'], #if USE_WEBGL2 glFuncs[0][1] += ' endTransformFeedback pauseTransformFeedback resumeTransformFeedback'; glFuncs[1][1] += ' beginTransformFeedback readBuffer endQuery'; +glFuncs[4][1] += ' clearBufferfi'; glFuncs[5][1] += ' vertexAttribI4i vertexAttribI4ui copyBufferSubData texStorage2D renderbufferStorageMultisample'; // TODO: Removed as a workaround, see https://bugzilla.mozilla.org/show_bug.cgi?id=1202427 //glFuncs[6][1] += ' drawRangeElements'; From 2d360ce556aa5d35870a41114a560277d3272acf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Wed, 9 Sep 2015 00:21:02 +0300 Subject: [PATCH 20/27] Add WebGL 2 function glFramebufferTextureLayer. --- src/library_gl.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/library_gl.js b/src/library_gl.js index b497257a9519e..08e73d9e3b0bb 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -6838,6 +6838,7 @@ var LibraryGL = { glRenderbufferStorageMultisample__sig: 'viiiii', glCopyTexSubImage3D__sig: 'viiiiiiiii', glClearBufferfi__sig: 'viifi', + glFramebufferTextureLayer__sig: 'viiiii', #endif }; @@ -6858,7 +6859,7 @@ var glFuncs = [[0, 'finish flush'], glFuncs[0][1] += ' endTransformFeedback pauseTransformFeedback resumeTransformFeedback'; glFuncs[1][1] += ' beginTransformFeedback readBuffer endQuery'; glFuncs[4][1] += ' clearBufferfi'; -glFuncs[5][1] += ' vertexAttribI4i vertexAttribI4ui copyBufferSubData texStorage2D renderbufferStorageMultisample'; +glFuncs[5][1] += ' vertexAttribI4i vertexAttribI4ui copyBufferSubData texStorage2D renderbufferStorageMultisample framebufferTextureLayer'; // TODO: Removed as a workaround, see https://bugzilla.mozilla.org/show_bug.cgi?id=1202427 //glFuncs[6][1] += ' drawRangeElements'; glFuncs[6][1] += ' texStorage3D'; From 0f3c67928d754eacd57c66beb9c200a00608f900 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Wed, 9 Sep 2015 00:31:18 +0300 Subject: [PATCH 21/27] Improve WebGL 2 handling of VAOs: Since VAOs are in core, they are no longer necessarily available as an extension. --- src/library_gl.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/library_gl.js b/src/library_gl.js index 08e73d9e3b0bb..1bcb9eb56aebd 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -834,7 +834,9 @@ var LibraryGL = { context.instancedArraysExt = GLctx.getExtension('ANGLE_instanced_arrays'); // Extension available from Firefox 25 and WebKit - context.vaoExt = GLctx.getExtension('OES_vertex_array_object'); + if (context.version < 2) { + context.vaoExt = GLctx.getExtension('OES_vertex_array_object'); + } if (context.version === 2) { // drawBuffers is available in WebGL2 by default. @@ -3078,7 +3080,7 @@ var LibraryGL = { _emulGlGenVertexArrays(n, arrays); #else #if GL_ASSERTIONS - assert(GL.currentContext.vaoExt, 'Must have WebGL2 or OES_vertex_array_object to use vao'); + assert(GL.currentContext.createVertexArray || GL.currentContext.vaoExt, 'Must have WebGL2 or OES_vertex_array_object to use vao'); #endif for(var i = 0; i < n; i++) { @@ -3113,7 +3115,7 @@ var LibraryGL = { _emulGlDeleteVertexArrays(n, vaos); #else #if GL_ASSERTIONS - assert(GL.currentContext.vaoExt, 'Must have WebGL2 or OES_vertex_array_object to use vao'); + assert(GL.currentContext.deleteVertexArray || GL.currentContext.vaoExt, 'Must have WebGL2 or OES_vertex_array_object to use vao'); #endif for(var i = 0; i < n; i++) { var id = {{{ makeGetValue('vaos', 'i*4', 'i32') }}}; @@ -3136,7 +3138,7 @@ var LibraryGL = { _emulGlBindVertexArray(vao); #else #if GL_ASSERTIONS - assert(GL.currentContext.vaoExt, 'Must have WebGL2 or OES_vertex_array_object to use vao'); + assert(GL.currentContext.bindVertexArray || GL.currentContext.vaoExt, 'Must have WebGL2 or OES_vertex_array_object to use vao'); #endif #if USE_WEBGL2 if (GL.currentContext.bindVertexArray) GL.currentContext.bindVertexArray(GL.vaos[vao]); @@ -3155,12 +3157,16 @@ var LibraryGL = { return _emulGlIsVertexArray(array); #else #if GL_ASSERTIONS - assert(GL.currentContext.vaoExt, 'Must have OES_vertex_array_object to use vao'); + assert(GL.currentContext.isVertexArray || GL.currentContext.vaoExt, 'Must have WebGL2 or OES_vertex_array_object to use vao'); #endif var vao = GL.vaos[array]; if (!vao) return 0; - return GL.currentContext.vaoExt.isVertexArrayOES(vao); +#if USE_WEBGL2 + if (GL.currentContext.isVertexArray) return GL.currentContext.isVertexArray(vao); + else +#endif + return GL.currentContext.vaoExt.isVertexArrayOES(vao); #endif }, From 32df7808a0a72c2c24d41d30deb433b4fd602131 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Wed, 9 Sep 2015 00:35:29 +0300 Subject: [PATCH 22/27] Fix handling of instancing when running in WebGL 2: -s USE_WEBGL2=1 does not statically guarantee that we will have a WebGL 2 context, and WebGL 2 context has instancing in core without necessarily exposing the extension, so adapt to handle both cases. --- src/library_gl.js | 51 +++++++++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/src/library_gl.js b/src/library_gl.js index 1bcb9eb56aebd..7dbfadfedad75 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -830,11 +830,12 @@ var LibraryGL = { context.compressionExt = GLctx.getExtension('WEBGL_compressed_texture_s3tc'); context.anisotropicExt = GLctx.getExtension('EXT_texture_filter_anisotropic'); #endif - // Extension available from Firefox 26 and Google Chrome 30 - context.instancedArraysExt = GLctx.getExtension('ANGLE_instanced_arrays'); - - // Extension available from Firefox 25 and WebKit + if (context.version < 2) { + // Extension available from Firefox 26 and Google Chrome 30 + context.instancedArraysExt = GLctx.getExtension('ANGLE_instanced_arrays'); + + // Extension available from Firefox 25 and WebKit context.vaoExt = GLctx.getExtension('OES_vertex_array_object'); } @@ -6720,44 +6721,38 @@ var LibraryGL = { glVertexAttribDivisor__sig: 'vii', glVertexAttribDivisor: function(index, divisor) { -#if USE_WEBGL2 - if (GL.currentContext.vertexAttribDivisor) { - GL.currentContext.vertexAttribDivisor(index, divisor); - return; - } -#endif #if GL_ASSERTIONS - assert(GL.currentContext.instancedArraysExt, 'Must have ANGLE_instanced_arrays extension or WebGL 2 to use WebGL instancing'); + assert(GL.currentContext.vertexAttribDivisor || GL.currentContext.instancedArraysExt, 'Must have ANGLE_instanced_arrays extension or WebGL 2 to use WebGL instancing'); #endif - GL.currentContext.instancedArraysExt.vertexAttribDivisorANGLE(index, divisor); +#if USE_WEBGL2 + if (GL.currentContext.vertexAttribDivisor) GL.currentContext.vertexAttribDivisor(index, divisor); + else +#endif + GL.currentContext.instancedArraysExt.vertexAttribDivisorANGLE(index, divisor); }, glDrawArraysInstanced__sig: 'viiii', glDrawArraysInstanced: function(mode, first, count, primcount) { -#if USE_WEBGL2 - if (GL.currentContext.drawArraysInstanced) { - GL.currentContext.drawArraysInstanced(mode, first, count, primcount); - return; - } -#endif #if GL_ASSERTIONS - assert(GL.currentContext.instancedArraysExt, 'Must have ANGLE_instanced_arrays extension or WebGL 2 to use WebGL instancing'); + assert(GL.currentContext.drawArraysInstanced || GL.currentContext.instancedArraysExt, 'Must have ANGLE_instanced_arrays extension or WebGL 2 to use WebGL instancing'); +#endif +#if USE_WEBGL2 + if (GL.currentContext.drawArraysInstanced) GL.currentContext.drawArraysInstanced(mode, first, count, primcount); + else #endif - GL.currentContext.instancedArraysExt.drawArraysInstancedANGLE(mode, first, count, primcount); + GL.currentContext.instancedArraysExt.drawArraysInstancedANGLE(mode, first, count, primcount); }, glDrawElementsInstanced__sig: 'viiiii', glDrawElementsInstanced: function(mode, count, type, indices, primcount) { -#if USE_WEBGL2 - if (GL.currentContext.glDrawElementsInstanced) { - GL.currentContext.glDrawElementsInstanced(mode, count, type, indices, primcount); - return; - } -#endif #if GL_ASSERTIONS - assert(GL.currentContext.instancedArraysExt, 'Must have ANGLE_instanced_arrays extension or WebGL 2 to use WebGL instancing'); + assert(GL.currentContext.glDrawElementsInstanced || GL.currentContext.instancedArraysExt, 'Must have ANGLE_instanced_arrays extension or WebGL 2 to use WebGL instancing'); +#endif +#if USE_WEBGL2 + if (GL.currentContext.glDrawElementsInstanced) GL.currentContext.glDrawElementsInstanced(mode, count, type, indices, primcount); + else #endif - GL.currentContext.instancedArraysExt.drawElementsInstancedANGLE(mode, count, type, indices, primcount); + GL.currentContext.instancedArraysExt.drawElementsInstancedANGLE(mode, count, type, indices, primcount); }, // OpenGL Desktop/ES 2.0 instancing extensions compatibility From f4f64617362249c6553cf965060a2ae8d6f8dfe3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Wed, 9 Sep 2015 01:17:13 +0300 Subject: [PATCH 23/27] Simplify VAO extension vs core WebGL 2 entry point handling. --- src/library_gl.js | 41 +++++++++++++++-------------------------- 1 file changed, 15 insertions(+), 26 deletions(-) diff --git a/src/library_gl.js b/src/library_gl.js index 7dbfadfedad75..a8568d53f2125 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -836,7 +836,13 @@ var LibraryGL = { context.instancedArraysExt = GLctx.getExtension('ANGLE_instanced_arrays'); // Extension available from Firefox 25 and WebKit - context.vaoExt = GLctx.getExtension('OES_vertex_array_object'); + var vaoExt = GLctx.getExtension('OES_vertex_array_object'); + if (vaoExt) { + GLctx.createVertexArray = function() { return vaoExt.createVertexArrayOES(); } + GLctx.deleteVertexArray = function(vao) { return vaoExt.deleteVertexArrayOES(vao); } + GLctx.bindVertexArray = function(vao) { return vaoExt.bindVertexArrayOES(vao); } + GLctx.isVertexArray = function(vao) { return vaoExt.isVertexArrayOES(vao); } + } } if (context.version === 2) { @@ -3081,16 +3087,11 @@ var LibraryGL = { _emulGlGenVertexArrays(n, arrays); #else #if GL_ASSERTIONS - assert(GL.currentContext.createVertexArray || GL.currentContext.vaoExt, 'Must have WebGL2 or OES_vertex_array_object to use vao'); + assert(GL.currentContext.createVertexArray, 'Must have WebGL2 or OES_vertex_array_object to use vao'); #endif for(var i = 0; i < n; i++) { - var vao; -#if USE_WEBGL2 - if (GL.currentContext.createVertexArray) vao = GL.currentContext.createVertexArray(); - if (!vao) -#endif - vao = GL.currentContext.vaoExt.createVertexArrayOES(); + var vao = GL.currentContext.createVertexArray(); if (!vao) { GL.recordError(0x0502 /* GL_INVALID_OPERATION */); #if GL_ASSERTIONS @@ -3116,15 +3117,11 @@ var LibraryGL = { _emulGlDeleteVertexArrays(n, vaos); #else #if GL_ASSERTIONS - assert(GL.currentContext.deleteVertexArray || GL.currentContext.vaoExt, 'Must have WebGL2 or OES_vertex_array_object to use vao'); + assert(GL.currentContext.deleteVertexArray, 'Must have WebGL2 or OES_vertex_array_object to use vao'); #endif for(var i = 0; i < n; i++) { var id = {{{ makeGetValue('vaos', 'i*4', 'i32') }}}; -#if USE_WEBGL2 - if (GL.currentContext.deleteVertexArray) GL.currentContext.deleteVertexArray(GL.vaos[id]); - else -#endif - GL.currentContext.vaoExt.deleteVertexArrayOES(GL.vaos[id]); + GL.currentContext.deleteVertexArray(GL.vaos[id]); GL.vaos[id] = null; } #endif @@ -3139,13 +3136,9 @@ var LibraryGL = { _emulGlBindVertexArray(vao); #else #if GL_ASSERTIONS - assert(GL.currentContext.bindVertexArray || GL.currentContext.vaoExt, 'Must have WebGL2 or OES_vertex_array_object to use vao'); + assert(GL.currentContext.bindVertexArray, 'Must have WebGL2 or OES_vertex_array_object to use vao'); #endif -#if USE_WEBGL2 - if (GL.currentContext.bindVertexArray) GL.currentContext.bindVertexArray(GL.vaos[vao]); - else -#endif - GL.currentContext.vaoExt.bindVertexArrayOES(GL.vaos[vao]); + GL.currentContext.bindVertexArray(GL.vaos[vao]); #endif }, @@ -3158,16 +3151,12 @@ var LibraryGL = { return _emulGlIsVertexArray(array); #else #if GL_ASSERTIONS - assert(GL.currentContext.isVertexArray || GL.currentContext.vaoExt, 'Must have WebGL2 or OES_vertex_array_object to use vao'); + assert(GL.currentContext.isVertexArray, 'Must have WebGL2 or OES_vertex_array_object to use vao'); #endif var vao = GL.vaos[array]; if (!vao) return 0; -#if USE_WEBGL2 - if (GL.currentContext.isVertexArray) return GL.currentContext.isVertexArray(vao); - else -#endif - return GL.currentContext.vaoExt.isVertexArrayOES(vao); + return GL.currentContext.isVertexArray(vao); #endif }, From f45f4eaed11e4522532b32a6fd71b04f0564d490 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Wed, 9 Sep 2015 01:20:54 +0300 Subject: [PATCH 24/27] Simplify WebGL instancing entrypoints handling with extension vs WebGL 2 core. --- src/library_gl.js | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/src/library_gl.js b/src/library_gl.js index a8568d53f2125..aeb98cf9f90bc 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -833,7 +833,12 @@ var LibraryGL = { if (context.version < 2) { // Extension available from Firefox 26 and Google Chrome 30 - context.instancedArraysExt = GLctx.getExtension('ANGLE_instanced_arrays'); + var instancedArraysExt = GLctx.getExtension('ANGLE_instanced_arrays'); + if (instancedArraysExt) { + GLctx.vertexAttribDivisor = function(index, divisor) { instancedArraysExt.vertexAttribDivisorANGLE(index, divisor); } + GLctx.drawArraysInstanced = function(mode, first, count, primcount) { instancedArraysExt.drawArraysInstancedANGLE(mode, first, count, primcount); } + GLctx.drawElementsInstanced = function(mode, count, type, indices, primcount) { instancedArraysExt.drawElementsInstancedANGLE(mode, count, type, indices, primcount); } + } // Extension available from Firefox 25 and WebKit var vaoExt = GLctx.getExtension('OES_vertex_array_object'); @@ -6711,37 +6716,25 @@ var LibraryGL = { glVertexAttribDivisor__sig: 'vii', glVertexAttribDivisor: function(index, divisor) { #if GL_ASSERTIONS - assert(GL.currentContext.vertexAttribDivisor || GL.currentContext.instancedArraysExt, 'Must have ANGLE_instanced_arrays extension or WebGL 2 to use WebGL instancing'); -#endif -#if USE_WEBGL2 - if (GL.currentContext.vertexAttribDivisor) GL.currentContext.vertexAttribDivisor(index, divisor); - else + assert(GL.currentContext.vertexAttribDivisor, 'Must have ANGLE_instanced_arrays extension or WebGL 2 to use WebGL instancing'); #endif - GL.currentContext.instancedArraysExt.vertexAttribDivisorANGLE(index, divisor); + GL.currentContext.vertexAttribDivisor(index, divisor); }, glDrawArraysInstanced__sig: 'viiii', glDrawArraysInstanced: function(mode, first, count, primcount) { #if GL_ASSERTIONS - assert(GL.currentContext.drawArraysInstanced || GL.currentContext.instancedArraysExt, 'Must have ANGLE_instanced_arrays extension or WebGL 2 to use WebGL instancing'); + assert(GL.currentContext.drawArraysInstanced, 'Must have ANGLE_instanced_arrays extension or WebGL 2 to use WebGL instancing'); #endif -#if USE_WEBGL2 - if (GL.currentContext.drawArraysInstanced) GL.currentContext.drawArraysInstanced(mode, first, count, primcount); - else -#endif - GL.currentContext.instancedArraysExt.drawArraysInstancedANGLE(mode, first, count, primcount); + GL.currentContext.drawArraysInstanced(mode, first, count, primcount); }, glDrawElementsInstanced__sig: 'viiiii', glDrawElementsInstanced: function(mode, count, type, indices, primcount) { #if GL_ASSERTIONS - assert(GL.currentContext.glDrawElementsInstanced || GL.currentContext.instancedArraysExt, 'Must have ANGLE_instanced_arrays extension or WebGL 2 to use WebGL instancing'); -#endif -#if USE_WEBGL2 - if (GL.currentContext.glDrawElementsInstanced) GL.currentContext.glDrawElementsInstanced(mode, count, type, indices, primcount); - else + assert(GL.currentContext.glDrawElementsInstanced, 'Must have ANGLE_instanced_arrays extension or WebGL 2 to use WebGL instancing'); #endif - GL.currentContext.instancedArraysExt.drawElementsInstancedANGLE(mode, count, type, indices, primcount); + GL.currentContext.glDrawElementsInstanced(mode, count, type, indices, primcount); }, // OpenGL Desktop/ES 2.0 instancing extensions compatibility From b479f043e5ab15661522500d0cda2020fb5ea6cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Wed, 9 Sep 2015 01:23:53 +0300 Subject: [PATCH 25/27] Simplify entrypoint handling to WebGL draw buffers extension vs core WebGL2. --- src/library_gl.js | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/library_gl.js b/src/library_gl.js index aeb98cf9f90bc..b117b7b8148f2 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -848,19 +848,10 @@ var LibraryGL = { GLctx.bindVertexArray = function(vao) { return vaoExt.bindVertexArrayOES(vao); } GLctx.isVertexArray = function(vao) { return vaoExt.isVertexArrayOES(vao); } } - } - if (context.version === 2) { - // drawBuffers is available in WebGL2 by default. - context.drawBuffersExt = function(n, bufs) { - GLctx['drawBuffers'](n, bufs); - }; - } else { - var ext = GLctx.getExtension('WEBGL_draw_buffers'); - if (ext) { - context.drawBuffersExt = function(n, bufs) { - ext.drawBuffersWEBGL(n, bufs); - }; + var drawBuffersExt = GLctx.getExtension('WEBGL_draw_buffers'); + if (drawBuffersExt) { + GLctx.drawBuffers = function(n, bufs) { drawBuffersExt.drawBuffersWEBGL(n, bufs); } } } @@ -6756,13 +6747,13 @@ var LibraryGL = { glDrawBuffers__sig: 'vii', glDrawBuffers: function(n, bufs) { #if GL_ASSERTIONS - assert(GL.currentContext.drawBuffersExt, 'Must have WebGL2 or WEBGL_draw_buffers extension to use drawBuffers'); + assert(GL.currentContext.drawBuffers, 'Must have WebGL2 or WEBGL_draw_buffers extension to use drawBuffers'); #endif var bufArray = []; for (var i = 0; i < n; i++) bufArray.push({{{ makeGetValue('bufs', 'i*4', 'i32') }}}); - GL.currentContext.drawBuffersExt(bufArray); + GL.currentContext.drawBuffers(bufArray); }, // OpenGL ES 2.0 draw buffer extensions compatibility From 571f3e31ac281e9d36c42dedcbe29ba0f9144910 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Wed, 9 Sep 2015 01:26:32 +0300 Subject: [PATCH 26/27] Remove unnecessary returns. --- src/library_gl.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/library_gl.js b/src/library_gl.js index b117b7b8148f2..0855b06cecedf 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -844,8 +844,8 @@ var LibraryGL = { var vaoExt = GLctx.getExtension('OES_vertex_array_object'); if (vaoExt) { GLctx.createVertexArray = function() { return vaoExt.createVertexArrayOES(); } - GLctx.deleteVertexArray = function(vao) { return vaoExt.deleteVertexArrayOES(vao); } - GLctx.bindVertexArray = function(vao) { return vaoExt.bindVertexArrayOES(vao); } + GLctx.deleteVertexArray = function(vao) { vaoExt.deleteVertexArrayOES(vao); } + GLctx.bindVertexArray = function(vao) { vaoExt.bindVertexArrayOES(vao); } GLctx.isVertexArray = function(vao) { return vaoExt.isVertexArrayOES(vao); } } From 5d57a9af8cba02cf2491b72660a1e2dbc34cc193 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Wed, 9 Sep 2015 15:08:26 +0300 Subject: [PATCH 27/27] Add semicolons. --- src/library_gl.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/library_gl.js b/src/library_gl.js index 0855b06cecedf..e611c9882c48e 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -835,23 +835,23 @@ var LibraryGL = { // Extension available from Firefox 26 and Google Chrome 30 var instancedArraysExt = GLctx.getExtension('ANGLE_instanced_arrays'); if (instancedArraysExt) { - GLctx.vertexAttribDivisor = function(index, divisor) { instancedArraysExt.vertexAttribDivisorANGLE(index, divisor); } - GLctx.drawArraysInstanced = function(mode, first, count, primcount) { instancedArraysExt.drawArraysInstancedANGLE(mode, first, count, primcount); } - GLctx.drawElementsInstanced = function(mode, count, type, indices, primcount) { instancedArraysExt.drawElementsInstancedANGLE(mode, count, type, indices, primcount); } + GLctx.vertexAttribDivisor = function(index, divisor) { instancedArraysExt.vertexAttribDivisorANGLE(index, divisor); }; + GLctx.drawArraysInstanced = function(mode, first, count, primcount) { instancedArraysExt.drawArraysInstancedANGLE(mode, first, count, primcount); }; + GLctx.drawElementsInstanced = function(mode, count, type, indices, primcount) { instancedArraysExt.drawElementsInstancedANGLE(mode, count, type, indices, primcount); }; } // Extension available from Firefox 25 and WebKit var vaoExt = GLctx.getExtension('OES_vertex_array_object'); if (vaoExt) { - GLctx.createVertexArray = function() { return vaoExt.createVertexArrayOES(); } - GLctx.deleteVertexArray = function(vao) { vaoExt.deleteVertexArrayOES(vao); } - GLctx.bindVertexArray = function(vao) { vaoExt.bindVertexArrayOES(vao); } - GLctx.isVertexArray = function(vao) { return vaoExt.isVertexArrayOES(vao); } + GLctx.createVertexArray = function() { return vaoExt.createVertexArrayOES(); }; + GLctx.deleteVertexArray = function(vao) { vaoExt.deleteVertexArrayOES(vao); }; + GLctx.bindVertexArray = function(vao) { vaoExt.bindVertexArrayOES(vao); }; + GLctx.isVertexArray = function(vao) { return vaoExt.isVertexArrayOES(vao); }; } var drawBuffersExt = GLctx.getExtension('WEBGL_draw_buffers'); if (drawBuffersExt) { - GLctx.drawBuffers = function(n, bufs) { drawBuffersExt.drawBuffersWEBGL(n, bufs); } + GLctx.drawBuffers = function(n, bufs) { drawBuffersExt.drawBuffersWEBGL(n, bufs); }; } }