Skip to content

Commit 0c95291

Browse files
authored
Remove WORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG (#20925)
See #7459
1 parent 79ac328 commit 0c95291

File tree

5 files changed

+5
-86
lines changed

5 files changed

+5
-86
lines changed

ChangeLog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ See docs/process.md for more on how version tagging works.
2020

2121
3.1.52 (in development)
2222
-----------------------
23+
- The WORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG setting was
24+
removed. This was a workaround from 2018 (#7459) that should no longer be
25+
needed. (#20925)
2326
- The `--default-obj-ext` command line flag was removed. (#20917)
2427
- emcc will now treat `.bc` files as source files. These means that will get
2528
compiled by clang before being passed to the linker. This matches the

src/library_webgl.js

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,41 +1065,6 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
10651065
GLctx: ctx
10661066
};
10671067

1068-
#if WORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG
1069-
context.cannotHandleOffsetsInUniformArrayViews = (function(g) {
1070-
function b(c, t) {
1071-
var s = g.createShader(t);
1072-
g.shaderSource(s, c);
1073-
g.compileShader(s);
1074-
return s;
1075-
}
1076-
try {
1077-
// Note: we do not delete this program so it stays part of the context
1078-
// we created, but that is ok - it does not do anything and we want to
1079-
// keep this detection size minimal.
1080-
var p = g.createProgram();
1081-
g.attachShader(p, b("attribute vec4 p;void main(){gl_Position=p;}", 0x8B31 /*GL_VERTEX_SHADER*/));
1082-
g.attachShader(p, b("precision lowp float;uniform vec4 u;void main(){gl_FragColor=u;}", 0x8B30 /*GL_FRAGMENT_SHADER*/));
1083-
g.linkProgram(p);
1084-
var h = new Float32Array(8);
1085-
h[4] = 1;
1086-
g.useProgram(p);
1087-
var l = g.getUniformLocation(p, "u");
1088-
// Uploading a 4-vector GL uniform from last four elements of array
1089-
// [0,0,0,0,1,0,0,0], i.e. uploading vec4=(1,0,0,0) at offset=4.
1090-
g.uniform4fv(l, h.subarray(4, 8));
1091-
// in proper WebGL we expect to read back the vector we just uploaded:
1092-
// (1,0,0,0). On buggy browser would instead have uploaded offset=0 of
1093-
// above array, i.e. vec4=(0,0,0,0)
1094-
return !g.getUniform(p, l)[0];i
1095-
} catch(e) {
1096-
// If we get an exception, we assume we got some other error, and do
1097-
// not trigger this workaround.
1098-
return false;
1099-
}
1100-
})();
1101-
#endif
1102-
11031068
// Store the created context object so that we can access the context
11041069
// given a canvas without having to pass the parameters again.
11051070
if (ctx.canvas) ctx.canvas.GLctxObject = context;
@@ -2515,9 +2480,6 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
25152480
#endif
25162481
{
25172482
var view = {{{ makeHEAPView('32', 'value', 'value+count*4') }}};
2518-
#if WORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG
2519-
if (GL.currentContext.cannotHandleOffsetsInUniformArrayViews) view = new Int32Array(view);
2520-
#endif
25212483
}
25222484
GLctx.uniform1iv(webglGetUniformLocation(location), view);
25232485
#endif // MIN_WEBGL_VERSION >= 2
@@ -2560,9 +2522,6 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
25602522
#endif
25612523
{
25622524
var view = {{{ makeHEAPView('32', 'value', 'value+count*8') }}};
2563-
#if WORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG
2564-
if (GL.currentContext.cannotHandleOffsetsInUniformArrayViews) view = new Int32Array(view);
2565-
#endif
25662525
}
25672526
GLctx.uniform2iv(webglGetUniformLocation(location), view);
25682527
#endif // MIN_WEBGL_VERSION >= 2
@@ -2606,9 +2565,6 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
26062565
#endif
26072566
{
26082567
var view = {{{ makeHEAPView('32', 'value', 'value+count*12') }}};
2609-
#if WORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG
2610-
if (GL.currentContext.cannotHandleOffsetsInUniformArrayViews) view = new Int32Array(view);
2611-
#endif
26122568
}
26132569
GLctx.uniform3iv(webglGetUniformLocation(location), view);
26142570
#endif // MIN_WEBGL_VERSION >= 2
@@ -2655,9 +2611,6 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
26552611
#endif
26562612
{
26572613
var view = {{{ makeHEAPView('32', 'value', 'value+count*16') }}};
2658-
#if WORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG
2659-
if (GL.currentContext.cannotHandleOffsetsInUniformArrayViews) view = new Int32Array(view);
2660-
#endif
26612614
}
26622615
GLctx.uniform4iv(webglGetUniformLocation(location), view);
26632616
#endif // MIN_WEBGL_VERSION >= 2
@@ -2699,9 +2652,6 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
26992652
#endif
27002653
{
27012654
var view = {{{ makeHEAPView('F32', 'value', 'value+count*4') }}};
2702-
#if WORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG
2703-
if (GL.currentContext.cannotHandleOffsetsInUniformArrayViews) view = new Float32Array(view);
2704-
#endif
27052655
}
27062656
GLctx.uniform1fv(webglGetUniformLocation(location), view);
27072657
#endif // MIN_WEBGL_VERSION >= 2
@@ -2746,9 +2696,6 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
27462696
#endif
27472697
{
27482698
var view = {{{ makeHEAPView('F32', 'value', 'value+count*8') }}};
2749-
#if WORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG
2750-
if (GL.currentContext.cannotHandleOffsetsInUniformArrayViews) view = new Float32Array(view);
2751-
#endif
27522699
}
27532700
GLctx.uniform2fv(webglGetUniformLocation(location), view);
27542701
#endif // MIN_WEBGL_VERSION >= 2
@@ -2794,9 +2741,6 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
27942741
#endif
27952742
{
27962743
var view = {{{ makeHEAPView('F32', 'value', 'value+count*12') }}};
2797-
#if WORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG
2798-
if (GL.currentContext.cannotHandleOffsetsInUniformArrayViews) view = new Float32Array(view);
2799-
#endif
28002744
}
28012745
GLctx.uniform3fv(webglGetUniformLocation(location), view);
28022746
#endif // MIN_WEBGL_VERSION >= 2
@@ -2847,9 +2791,6 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
28472791
#endif
28482792
{
28492793
var view = {{{ makeHEAPView('F32', 'value', 'value+count*16') }}};
2850-
#if WORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG
2851-
if (GL.currentContext.cannotHandleOffsetsInUniformArrayViews) view = new Float32Array(view);
2852-
#endif
28532794
}
28542795
GLctx.uniform4fv(webglGetUniformLocation(location), view);
28552796
#endif // MIN_WEBGL_VERSION >= 2
@@ -2896,9 +2837,6 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
28962837
#endif
28972838
{
28982839
var view = {{{ makeHEAPView('F32', 'value', 'value+count*16') }}};
2899-
#if WORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG
2900-
if (GL.currentContext.cannotHandleOffsetsInUniformArrayViews) view = new Float32Array(view);
2901-
#endif
29022840
}
29032841
GLctx.uniformMatrix2fv(webglGetUniformLocation(location), !!transpose, view);
29042842
#endif // MIN_WEBGL_VERSION >= 2
@@ -2950,9 +2888,6 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
29502888
#endif
29512889
{
29522890
var view = {{{ makeHEAPView('F32', 'value', 'value+count*36') }}};
2953-
#if WORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG
2954-
if (GL.currentContext.cannotHandleOffsetsInUniformArrayViews) view = new Float32Array(view);
2955-
#endif
29562891
}
29572892
GLctx.uniformMatrix3fv(webglGetUniformLocation(location), !!transpose, view);
29582893
#endif // MIN_WEBGL_VERSION >= 2
@@ -3015,9 +2950,6 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
30152950
#endif
30162951
{
30172952
var view = {{{ makeHEAPView('F32', 'value', 'value+count*64') }}};
3018-
#if WORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG
3019-
if (GL.currentContext.cannotHandleOffsetsInUniformArrayViews) view = new Float32Array(view);
3020-
#endif
30212953
}
30222954
GLctx.uniformMatrix4fv(webglGetUniformLocation(location), !!transpose, view);
30232955
#endif // MIN_WEBGL_VERSION >= 2

src/settings.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -492,13 +492,6 @@ var GL_SUPPORT_EXPLICIT_SWAP_CONTROL = false;
492492
// [link]
493493
var GL_POOL_TEMP_BUFFERS = true;
494494

495-
// Some old Android WeChat (Chromium 37?) browser has a WebGL bug that it ignores
496-
// the offset of a typed array view pointing to an ArrayBuffer. Set this to
497-
// 1 to enable a polyfill that works around the issue when it appears. This
498-
// bug is only relevant to WebGL 1, the affected browsers do not support WebGL 2.
499-
// [link]
500-
var WORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG = false;
501-
502495
// If true, enables support for the EMSCRIPTEN_explicit_uniform_location WebGL
503496
// extension. See docs/EMSCRIPTEN_explicit_uniform_location.txt
504497
var GL_EXPLICIT_UNIFORM_LOCATION = false;
@@ -611,7 +604,6 @@ var POLYFILL_OLD_MATH_FUNCTIONS = false;
611604
// the highest possible probability of the code working everywhere, even in rare old
612605
// browsers and shell environments. Specifically:
613606
// * Add polyfilling for Math.clz32, Math.trunc, Math.imul, Math.fround. (-sPOLYFILL_OLD_MATH_FUNCTIONS)
614-
// * Work around old Chromium WebGL 1 bug (-sWORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG)
615607
// * Disable WebAssembly. (Must be paired with -sWASM=0)
616608
// * Adjusts MIN_X_VERSION settings to 0 to include support for all browser versions.
617609
// * Avoid TypedArray.fill, if necessary, in zeroMemory utility function.
@@ -2159,4 +2151,5 @@ var LEGACY_SETTINGS = [
21592151
['RUNTIME_LOGGING', 'RUNTIME_DEBUG'],
21602152
['MIN_EDGE_VERSION', [0x7FFFFFFF], 'No longer supported'],
21612153
['MIN_IE_VERSION', [0x7FFFFFFF], 'No longer supported'],
2154+
['WORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG', [0], 'No longer supported'],
21622155
];

test/test_browser.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2794,7 +2794,7 @@ def test_webgl_unmasked_vendor_webgl(self):
27942794
@requires_graphics_hardware
27952795
@parameterized({
27962796
'legacy_browser': (['-sMIN_CHROME_VERSION=0', '-Wno-transpile'],),
2797-
'closure': (['-O2', '-g1', '--closure=1', '-sWORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG'],),
2797+
'closure': (['-O2', '-g1', '--closure=1'],),
27982798
'full_es2': (['-sFULL_ES2'],),
27992799
})
28002800
def test_webgl2(self, args):
@@ -4750,11 +4750,6 @@ def test_webgl_offscreen_framebuffer_state_restoration(self):
47504750
cmd = args + ['-lGL', '-sOFFSCREEN_FRAMEBUFFER', '-DEXPLICIT_SWAP=1']
47514751
self.btest_exit('webgl_offscreen_framebuffer_swap_with_bad_state.c', args=cmd)
47524752

4753-
# Tests that -sWORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG rendering works.
4754-
@requires_graphics_hardware
4755-
def test_webgl_workaround_webgl_uniform_upload_bug(self):
4756-
self.btest_exit('webgl_draw_triangle_with_uniform_color.c', args=['-lGL', '-sWORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG'])
4757-
47584753
# Tests that using an array of structs in GL uniforms works.
47594754
@requires_graphics_hardware
47604755
def test_webgl_array_of_structs_uniform(self):

tools/link.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,9 +1101,6 @@ def phase_linker_setup(options, state, newargs):
11011101
settings.MIN_CHROME_VERSION = 0
11021102
settings.MIN_NODE_VERSION = 0
11031103

1104-
if settings.MIN_CHROME_VERSION <= 37:
1105-
settings.WORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG = 1
1106-
11071104
# 10.19.0 is the oldest version of node that we do any testing with.
11081105
# Keep this in sync with the test-node-compat in .circleci/config.yml
11091106
# and MINIMUM_NODE_VERSION in tools/shared.py
@@ -1153,7 +1150,6 @@ def phase_linker_setup(options, state, newargs):
11531150
# Silently drop any individual backwards compatibility emulation flags that are known never to occur on browsers that support WebAssembly.
11541151
if not settings.WASM2JS:
11551152
settings.POLYFILL_OLD_MATH_FUNCTIONS = 0
1156-
settings.WORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG = 0
11571153

11581154
if settings.STB_IMAGE and final_suffix in EXECUTABLE_ENDINGS:
11591155
state.forced_stdlibs.append('libstb_image')

0 commit comments

Comments
 (0)