From 0c95291e353f98e7c094adc8dce721147a17afb0 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Thu, 14 Dec 2023 15:59:10 -0800 Subject: [PATCH] Remove WORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG (#20925) See #7459 --- ChangeLog.md | 3 ++ src/library_webgl.js | 68 -------------------------------------------- src/settings.js | 9 +----- test/test_browser.py | 7 +---- tools/link.py | 4 --- 5 files changed, 5 insertions(+), 86 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index eca32557c83f..889780b76d59 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -20,6 +20,9 @@ See docs/process.md for more on how version tagging works. 3.1.52 (in development) ----------------------- +- The WORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG setting was + removed. This was a workaround from 2018 (#7459) that should no longer be + needed. (#20925) - The `--default-obj-ext` command line flag was removed. (#20917) - emcc will now treat `.bc` files as source files. These means that will get compiled by clang before being passed to the linker. This matches the diff --git a/src/library_webgl.js b/src/library_webgl.js index 45713722acaa..9829fdc58bb9 100644 --- a/src/library_webgl.js +++ b/src/library_webgl.js @@ -1065,41 +1065,6 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}}; GLctx: ctx }; -#if WORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG - context.cannotHandleOffsetsInUniformArrayViews = (function(g) { - function b(c, t) { - var s = g.createShader(t); - g.shaderSource(s, c); - g.compileShader(s); - return s; - } - try { - // Note: we do not delete this program so it stays part of the context - // we created, but that is ok - it does not do anything and we want to - // keep this detection size minimal. - var p = g.createProgram(); - g.attachShader(p, b("attribute vec4 p;void main(){gl_Position=p;}", 0x8B31 /*GL_VERTEX_SHADER*/)); - g.attachShader(p, b("precision lowp float;uniform vec4 u;void main(){gl_FragColor=u;}", 0x8B30 /*GL_FRAGMENT_SHADER*/)); - g.linkProgram(p); - var h = new Float32Array(8); - h[4] = 1; - g.useProgram(p); - var l = g.getUniformLocation(p, "u"); - // Uploading a 4-vector GL uniform from last four elements of array - // [0,0,0,0,1,0,0,0], i.e. uploading vec4=(1,0,0,0) at offset=4. - g.uniform4fv(l, h.subarray(4, 8)); - // in proper WebGL we expect to read back the vector we just uploaded: - // (1,0,0,0). On buggy browser would instead have uploaded offset=0 of - // above array, i.e. vec4=(0,0,0,0) - return !g.getUniform(p, l)[0];i - } catch(e) { - // If we get an exception, we assume we got some other error, and do - // not trigger this workaround. - return false; - } - })(); -#endif - // Store the created context object so that we can access the context // given a canvas without having to pass the parameters again. if (ctx.canvas) ctx.canvas.GLctxObject = context; @@ -2515,9 +2480,6 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}}; #endif { var view = {{{ makeHEAPView('32', 'value', 'value+count*4') }}}; -#if WORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG - if (GL.currentContext.cannotHandleOffsetsInUniformArrayViews) view = new Int32Array(view); -#endif } GLctx.uniform1iv(webglGetUniformLocation(location), view); #endif // MIN_WEBGL_VERSION >= 2 @@ -2560,9 +2522,6 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}}; #endif { var view = {{{ makeHEAPView('32', 'value', 'value+count*8') }}}; -#if WORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG - if (GL.currentContext.cannotHandleOffsetsInUniformArrayViews) view = new Int32Array(view); -#endif } GLctx.uniform2iv(webglGetUniformLocation(location), view); #endif // MIN_WEBGL_VERSION >= 2 @@ -2606,9 +2565,6 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}}; #endif { var view = {{{ makeHEAPView('32', 'value', 'value+count*12') }}}; -#if WORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG - if (GL.currentContext.cannotHandleOffsetsInUniformArrayViews) view = new Int32Array(view); -#endif } GLctx.uniform3iv(webglGetUniformLocation(location), view); #endif // MIN_WEBGL_VERSION >= 2 @@ -2655,9 +2611,6 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}}; #endif { var view = {{{ makeHEAPView('32', 'value', 'value+count*16') }}}; -#if WORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG - if (GL.currentContext.cannotHandleOffsetsInUniformArrayViews) view = new Int32Array(view); -#endif } GLctx.uniform4iv(webglGetUniformLocation(location), view); #endif // MIN_WEBGL_VERSION >= 2 @@ -2699,9 +2652,6 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}}; #endif { var view = {{{ makeHEAPView('F32', 'value', 'value+count*4') }}}; -#if WORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG - if (GL.currentContext.cannotHandleOffsetsInUniformArrayViews) view = new Float32Array(view); -#endif } GLctx.uniform1fv(webglGetUniformLocation(location), view); #endif // MIN_WEBGL_VERSION >= 2 @@ -2746,9 +2696,6 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}}; #endif { var view = {{{ makeHEAPView('F32', 'value', 'value+count*8') }}}; -#if WORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG - if (GL.currentContext.cannotHandleOffsetsInUniformArrayViews) view = new Float32Array(view); -#endif } GLctx.uniform2fv(webglGetUniformLocation(location), view); #endif // MIN_WEBGL_VERSION >= 2 @@ -2794,9 +2741,6 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}}; #endif { var view = {{{ makeHEAPView('F32', 'value', 'value+count*12') }}}; -#if WORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG - if (GL.currentContext.cannotHandleOffsetsInUniformArrayViews) view = new Float32Array(view); -#endif } GLctx.uniform3fv(webglGetUniformLocation(location), view); #endif // MIN_WEBGL_VERSION >= 2 @@ -2847,9 +2791,6 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}}; #endif { var view = {{{ makeHEAPView('F32', 'value', 'value+count*16') }}}; -#if WORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG - if (GL.currentContext.cannotHandleOffsetsInUniformArrayViews) view = new Float32Array(view); -#endif } GLctx.uniform4fv(webglGetUniformLocation(location), view); #endif // MIN_WEBGL_VERSION >= 2 @@ -2896,9 +2837,6 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}}; #endif { var view = {{{ makeHEAPView('F32', 'value', 'value+count*16') }}}; -#if WORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG - if (GL.currentContext.cannotHandleOffsetsInUniformArrayViews) view = new Float32Array(view); -#endif } GLctx.uniformMatrix2fv(webglGetUniformLocation(location), !!transpose, view); #endif // MIN_WEBGL_VERSION >= 2 @@ -2950,9 +2888,6 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}}; #endif { var view = {{{ makeHEAPView('F32', 'value', 'value+count*36') }}}; -#if WORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG - if (GL.currentContext.cannotHandleOffsetsInUniformArrayViews) view = new Float32Array(view); -#endif } GLctx.uniformMatrix3fv(webglGetUniformLocation(location), !!transpose, view); #endif // MIN_WEBGL_VERSION >= 2 @@ -3015,9 +2950,6 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}}; #endif { var view = {{{ makeHEAPView('F32', 'value', 'value+count*64') }}}; -#if WORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG - if (GL.currentContext.cannotHandleOffsetsInUniformArrayViews) view = new Float32Array(view); -#endif } GLctx.uniformMatrix4fv(webglGetUniformLocation(location), !!transpose, view); #endif // MIN_WEBGL_VERSION >= 2 diff --git a/src/settings.js b/src/settings.js index 2ff4e643e7a8..1689ebb9eddd 100644 --- a/src/settings.js +++ b/src/settings.js @@ -492,13 +492,6 @@ var GL_SUPPORT_EXPLICIT_SWAP_CONTROL = false; // [link] var GL_POOL_TEMP_BUFFERS = true; -// Some old Android WeChat (Chromium 37?) browser has a WebGL bug that it ignores -// the offset of a typed array view pointing to an ArrayBuffer. Set this to -// 1 to enable a polyfill that works around the issue when it appears. This -// bug is only relevant to WebGL 1, the affected browsers do not support WebGL 2. -// [link] -var WORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG = false; - // If true, enables support for the EMSCRIPTEN_explicit_uniform_location WebGL // extension. See docs/EMSCRIPTEN_explicit_uniform_location.txt var GL_EXPLICIT_UNIFORM_LOCATION = false; @@ -611,7 +604,6 @@ var POLYFILL_OLD_MATH_FUNCTIONS = false; // the highest possible probability of the code working everywhere, even in rare old // browsers and shell environments. Specifically: // * Add polyfilling for Math.clz32, Math.trunc, Math.imul, Math.fround. (-sPOLYFILL_OLD_MATH_FUNCTIONS) -// * Work around old Chromium WebGL 1 bug (-sWORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG) // * Disable WebAssembly. (Must be paired with -sWASM=0) // * Adjusts MIN_X_VERSION settings to 0 to include support for all browser versions. // * Avoid TypedArray.fill, if necessary, in zeroMemory utility function. @@ -2159,4 +2151,5 @@ var LEGACY_SETTINGS = [ ['RUNTIME_LOGGING', 'RUNTIME_DEBUG'], ['MIN_EDGE_VERSION', [0x7FFFFFFF], 'No longer supported'], ['MIN_IE_VERSION', [0x7FFFFFFF], 'No longer supported'], + ['WORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG', [0], 'No longer supported'], ]; diff --git a/test/test_browser.py b/test/test_browser.py index aab1eaa0e1fb..62a05ca97ebd 100644 --- a/test/test_browser.py +++ b/test/test_browser.py @@ -2794,7 +2794,7 @@ def test_webgl_unmasked_vendor_webgl(self): @requires_graphics_hardware @parameterized({ 'legacy_browser': (['-sMIN_CHROME_VERSION=0', '-Wno-transpile'],), - 'closure': (['-O2', '-g1', '--closure=1', '-sWORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG'],), + 'closure': (['-O2', '-g1', '--closure=1'],), 'full_es2': (['-sFULL_ES2'],), }) def test_webgl2(self, args): @@ -4750,11 +4750,6 @@ def test_webgl_offscreen_framebuffer_state_restoration(self): cmd = args + ['-lGL', '-sOFFSCREEN_FRAMEBUFFER', '-DEXPLICIT_SWAP=1'] self.btest_exit('webgl_offscreen_framebuffer_swap_with_bad_state.c', args=cmd) - # Tests that -sWORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG rendering works. - @requires_graphics_hardware - def test_webgl_workaround_webgl_uniform_upload_bug(self): - self.btest_exit('webgl_draw_triangle_with_uniform_color.c', args=['-lGL', '-sWORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG']) - # Tests that using an array of structs in GL uniforms works. @requires_graphics_hardware def test_webgl_array_of_structs_uniform(self): diff --git a/tools/link.py b/tools/link.py index 1f2a6489a571..3b2af47008d5 100644 --- a/tools/link.py +++ b/tools/link.py @@ -1101,9 +1101,6 @@ def phase_linker_setup(options, state, newargs): settings.MIN_CHROME_VERSION = 0 settings.MIN_NODE_VERSION = 0 - if settings.MIN_CHROME_VERSION <= 37: - settings.WORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG = 1 - # 10.19.0 is the oldest version of node that we do any testing with. # Keep this in sync with the test-node-compat in .circleci/config.yml # and MINIMUM_NODE_VERSION in tools/shared.py @@ -1153,7 +1150,6 @@ def phase_linker_setup(options, state, newargs): # Silently drop any individual backwards compatibility emulation flags that are known never to occur on browsers that support WebAssembly. if not settings.WASM2JS: settings.POLYFILL_OLD_MATH_FUNCTIONS = 0 - settings.WORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG = 0 if settings.STB_IMAGE and final_suffix in EXECUTABLE_ENDINGS: state.forced_stdlibs.append('libstb_image')