Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix remaining webgl + CAN_ADDRESS_2GB issues #21306

Merged
merged 2 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,8 @@ jobs:
browser_2gb.test_cubegeom*
browser_2gb.test_html5_webgl_create_context*
browser_2gb.test_main_thread_async_em_asm
browser_2gb.test_webgl2_*
browser_2gb.test_webgl_*
"
test-browser-chrome-wasm64-4gb:
executor: bionic
Expand Down
62 changes: 31 additions & 31 deletions src/library_webgl.js
Original file line number Diff line number Diff line change
Expand Up @@ -2459,12 +2459,12 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
#if GL_ASSERTIONS
assert(GL.currentContext.version >= 2);
#endif
count && GLctx.uniform1iv(webglGetUniformLocation(location), HEAP32, value>>2, count);
count && GLctx.uniform1iv(webglGetUniformLocation(location), HEAP32, {{{ getHeapOffset('value', 'i32') }}}, count);
#else

#if MAX_WEBGL_VERSION >= 2
if ({{{ isCurrentContextWebGL2() }}}) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
count && GLctx.uniform1iv(webglGetUniformLocation(location), HEAP32, value>>2, count);
count && GLctx.uniform1iv(webglGetUniformLocation(location), HEAP32, {{{ getHeapOffset('value', 'i32') }}}, count);
return;
}
#endif
Expand Down Expand Up @@ -2500,12 +2500,12 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
#if GL_ASSERTIONS
assert(GL.currentContext.version >= 2);
#endif
count && GLctx.uniform2iv(webglGetUniformLocation(location), HEAP32, value>>2, count*2);
count && GLctx.uniform2iv(webglGetUniformLocation(location), HEAP32, {{{ getHeapOffset('value', 'i32') }}}, count*2);
#else

#if MAX_WEBGL_VERSION >= 2
if ({{{ isCurrentContextWebGL2() }}}) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
count && GLctx.uniform2iv(webglGetUniformLocation(location), HEAP32, value>>2, count*2);
count && GLctx.uniform2iv(webglGetUniformLocation(location), HEAP32, {{{ getHeapOffset('value', 'i32') }}}, count*2);
return;
}
#endif
Expand Down Expand Up @@ -2542,12 +2542,12 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
#if GL_ASSERTIONS
assert(GL.currentContext.version >= 2);
#endif
count && GLctx.uniform3iv(webglGetUniformLocation(location), HEAP32, value>>2, count*3);
count && GLctx.uniform3iv(webglGetUniformLocation(location), HEAP32, {{{ getHeapOffset('value', 'i32') }}}, count*3);
#else

#if MAX_WEBGL_VERSION >= 2
if ({{{ isCurrentContextWebGL2() }}}) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
count && GLctx.uniform3iv(webglGetUniformLocation(location), HEAP32, value>>2, count*3);
count && GLctx.uniform3iv(webglGetUniformLocation(location), HEAP32, {{{ getHeapOffset('value', 'i32') }}}, count*3);
return;
}
#endif
Expand Down Expand Up @@ -2585,14 +2585,14 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
#if GL_ASSERTIONS
assert(GL.currentContext.version >= 2);
#endif
count && GLctx.uniform4iv(webglGetUniformLocation(location), HEAP32, value>>2, count*4);
count && GLctx.uniform4iv(webglGetUniformLocation(location), HEAP32, {{{ getHeapOffset('value', 'i32') }}}, count*4);
#else

#if MAX_WEBGL_VERSION >= 2
// WebGL 2 provides new garbage-free entry points to call to WebGL. Use
// those always when possible.
if ({{{ isCurrentContextWebGL2() }}}) {
count && GLctx.uniform4iv(webglGetUniformLocation(location), HEAP32, value>>2, count*4);
count && GLctx.uniform4iv(webglGetUniformLocation(location), HEAP32, {{{ getHeapOffset('value', 'i32') }}}, count*4);
return;
}
#endif
Expand Down Expand Up @@ -2631,12 +2631,12 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
#if GL_ASSERTIONS
assert(GL.currentContext.version >= 2);
#endif
count && GLctx.uniform1fv(webglGetUniformLocation(location), HEAPF32, value>>2, count);
count && GLctx.uniform1fv(webglGetUniformLocation(location), HEAPF32, {{{ getHeapOffset('value', 'float') }}}, count);
#else

#if MAX_WEBGL_VERSION >= 2
if ({{{ isCurrentContextWebGL2() }}}) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
count && GLctx.uniform1fv(webglGetUniformLocation(location), HEAPF32, value>>2, count);
count && GLctx.uniform1fv(webglGetUniformLocation(location), HEAPF32, {{{ getHeapOffset('value', 'float') }}}, count);
return;
}
#endif
Expand Down Expand Up @@ -2672,14 +2672,14 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
#if GL_ASSERTIONS
assert(GL.currentContext.version >= 2);
#endif
count && GLctx.uniform2fv(webglGetUniformLocation(location), HEAPF32, value>>2, count*2);
count && GLctx.uniform2fv(webglGetUniformLocation(location), HEAPF32, {{{ getHeapOffset('value', 'float') }}}, count*2);
#else

#if MAX_WEBGL_VERSION >= 2
// WebGL 2 provides new garbage-free entry points to call to WebGL. Use
// those always when possible.
if ({{{ isCurrentContextWebGL2() }}}) {
count && GLctx.uniform2fv(webglGetUniformLocation(location), HEAPF32, value>>2, count*2);
count && GLctx.uniform2fv(webglGetUniformLocation(location), HEAPF32, {{{ getHeapOffset('value', 'float') }}}, count*2);
return;
}
#endif
Expand Down Expand Up @@ -2709,21 +2709,21 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
glUniform3fv: (location, count, value) => {
#if GL_ASSERTIONS
GL.validateGLObjectID(GLctx.currentProgram.uniformLocsById, location, 'glUniform3fv', 'location');
assert((value & 3) == 0, 'Pointer to float data passed to glUniform3fv must be aligned to four bytes!' + value);
assert((value % 4) == 0, 'Pointer to float data passed to glUniform3fv must be aligned to four bytes!' + value);
#endif

#if MIN_WEBGL_VERSION >= 2
#if GL_ASSERTIONS
assert(GL.currentContext.version >= 2);
#endif
count && GLctx.uniform3fv(webglGetUniformLocation(location), HEAPF32, value>>2, count*3);
count && GLctx.uniform3fv(webglGetUniformLocation(location), HEAPF32, {{{ getHeapOffset('value', 'float') }}}, count*3);
#else

#if MAX_WEBGL_VERSION >= 2
// WebGL 2 provides new garbage-free entry points to call to WebGL. Use
// those always when possible.
if ({{{ isCurrentContextWebGL2() }}}) {
count && GLctx.uniform3fv(webglGetUniformLocation(location), HEAPF32, value>>2, count*3);
count && GLctx.uniform3fv(webglGetUniformLocation(location), HEAPF32, {{{ getHeapOffset('value', 'float') }}}, count*3);
return;
}
#endif
Expand Down Expand Up @@ -2761,14 +2761,14 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
#if GL_ASSERTIONS
assert(GL.currentContext.version >= 2);
#endif
count && GLctx.uniform4fv(webglGetUniformLocation(location), HEAPF32, value>>2, count*4);
count && GLctx.uniform4fv(webglGetUniformLocation(location), HEAPF32, {{{ getHeapOffset('value', 'float') }}}, count*4);
#else

#if MAX_WEBGL_VERSION >= 2
// WebGL 2 provides new garbage-free entry points to call to WebGL. Use
// those always when possible.
if ({{{ isCurrentContextWebGL2() }}}) {
count && GLctx.uniform4fv(webglGetUniformLocation(location), HEAPF32, value>>2, count*4);
count && GLctx.uniform4fv(webglGetUniformLocation(location), HEAPF32, {{{ getHeapOffset('value', 'float') }}}, count*4);
return;
}
#endif
Expand Down Expand Up @@ -2811,14 +2811,14 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
#if GL_ASSERTIONS
assert(GL.currentContext.version >= 2);
#endif
count && GLctx.uniformMatrix2fv(webglGetUniformLocation(location), !!transpose, HEAPF32, value>>2, count*4);
count && GLctx.uniformMatrix2fv(webglGetUniformLocation(location), !!transpose, HEAPF32, {{{ getHeapOffset('value', 'float') }}}, count*4);
#else

#if MAX_WEBGL_VERSION >= 2
// WebGL 2 provides new garbage-free entry points to call to WebGL. Use
// those always when possible.
if ({{{ isCurrentContextWebGL2() }}}) {
count && GLctx.uniformMatrix2fv(webglGetUniformLocation(location), !!transpose, HEAPF32, value>>2, count*4);
count && GLctx.uniformMatrix2fv(webglGetUniformLocation(location), !!transpose, HEAPF32, {{{ getHeapOffset('value', 'float') }}}, count*4);
return;
}
#endif
Expand Down Expand Up @@ -2857,14 +2857,14 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
#if GL_ASSERTIONS
assert(GL.currentContext.version >= 2);
#endif
count && GLctx.uniformMatrix3fv(webglGetUniformLocation(location), !!transpose, HEAPF32, value>>2, count*9);
count && GLctx.uniformMatrix3fv(webglGetUniformLocation(location), !!transpose, HEAPF32, {{{ getHeapOffset('value', 'float') }}}, count*9);
#else

#if MAX_WEBGL_VERSION >= 2
// WebGL 2 provides new garbage-free entry points to call to WebGL. Use
// those always when possible.
if ({{{ isCurrentContextWebGL2() }}}) {
count && GLctx.uniformMatrix3fv(webglGetUniformLocation(location), !!transpose, HEAPF32, value>>2, count*9);
count && GLctx.uniformMatrix3fv(webglGetUniformLocation(location), !!transpose, HEAPF32, {{{ getHeapOffset('value', 'float') }}}, count*9);
return;
}
#endif
Expand Down Expand Up @@ -3966,9 +3966,9 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
GLctx.multiDrawWebgl['multiDrawArraysWEBGL'](
mode,
HEAP32,
firsts >> 2,
{{{ getHeapOffset('firsts', 'i32') }}},
HEAP32,
counts >> 2,
{{{ getHeapOffset('counts', 'i32') }}},
drawcount);
},

Expand All @@ -3978,11 +3978,11 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
GLctx.multiDrawWebgl['multiDrawArraysInstancedWEBGL'](
mode,
HEAP32,
firsts >> 2,
{{{ getHeapOffset('firsts', 'i32') }}},
HEAP32,
counts >> 2,
{{{ getHeapOffset('counts', 'i32') }}},
HEAP32,
instanceCounts >> 2,
{{{ getHeapOffset('instanceCounts', 'i32') }}},
drawcount);
},

Expand Down Expand Up @@ -4017,10 +4017,10 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
GLctx.multiDrawWebgl['multiDrawElementsWEBGL'](
mode,
HEAP32,
counts >> 2,
{{{ getHeapOffset('counts', 'i32') }}},
type,
HEAP32,
offsets >> 2,
{{{ getHeapOffset('offsets', 'i32') }}},
drawcount);
#if MEMORY64
stackRestore(stack);
Expand All @@ -4040,12 +4040,12 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
GLctx.multiDrawWebgl['multiDrawElementsInstancedWEBGL'](
mode,
HEAP32,
counts >> 2,
{{{ getHeapOffset('counts', 'i32') }}},
type,
HEAP32,
offsets >> 2,
{{{ getHeapOffset('offsets', 'i32') }}},
HEAP32,
instanceCounts >> 2,
{{{ getHeapOffset('instanceCounts', 'i32') }}},
drawcount);
#if MEMORY64
stackRestore(stack);
Expand Down
44 changes: 22 additions & 22 deletions src/library_webgl2.js
Original file line number Diff line number Diff line change
Expand Up @@ -622,23 +622,23 @@ var LibraryWebGL2 = {
assert((value & 3) == 0, 'Pointer to integer data passed to glClearBufferiv must be aligned to four bytes!');
#endif

GLctx.clearBufferiv(buffer, drawbuffer, HEAP32, value>>2);
GLctx.clearBufferiv(buffer, drawbuffer, HEAP32, {{{ getHeapOffset('value', 'i32') }}});
},

glClearBufferuiv: (buffer, drawbuffer, value) => {
#if GL_ASSERTIONS
assert((value & 3) == 0, 'Pointer to integer data passed to glClearBufferuiv must be aligned to four bytes!');
#endif

GLctx.clearBufferuiv(buffer, drawbuffer, HEAPU32, value>>2);
GLctx.clearBufferuiv(buffer, drawbuffer, HEAPU32, {{{ getHeapOffset('value', 'u32') }}});
},

glClearBufferfv: (buffer, drawbuffer, value) => {
#if GL_ASSERTIONS
assert((value & 3) == 0, 'Pointer to float data passed to glClearBufferfv must be aligned to four bytes!');
#endif

GLctx.clearBufferfv(buffer, drawbuffer, HEAPF32, value>>2);
GLctx.clearBufferfv(buffer, drawbuffer, HEAPF32, {{{ getHeapOffset('value', 'float') }}});
},

glFenceSync: (condition, flags) => {
Expand Down Expand Up @@ -776,7 +776,7 @@ var LibraryWebGL2 = {
GL.validateGLObjectID(GLctx.currentProgram.uniformLocsById, location, 'glUniform1uiv', 'location');
assert((value & 3) == 0, 'Pointer to integer data passed to glUniform1uiv must be aligned to four bytes!');
#endif
count && GLctx.uniform1uiv(webglGetUniformLocation(location), HEAPU32, value>>2, count);
count && GLctx.uniform1uiv(webglGetUniformLocation(location), HEAPU32, {{{ getHeapOffset('value', 'u32') }}}, count);
},

glUniform2uiv__deps: ['$webglGetUniformLocation'],
Expand All @@ -785,7 +785,7 @@ var LibraryWebGL2 = {
GL.validateGLObjectID(GLctx.currentProgram.uniformLocsById, location, 'glUniform2uiv', 'location');
assert((value & 3) == 0, 'Pointer to integer data passed to glUniform2uiv must be aligned to four bytes!');
#endif
count && GLctx.uniform2uiv(webglGetUniformLocation(location), HEAPU32, value>>2, count*2);
count && GLctx.uniform2uiv(webglGetUniformLocation(location), HEAPU32, {{{ getHeapOffset('value', 'u32') }}}, count*2);
},

glUniform3uiv__deps: ['$webglGetUniformLocation'],
Expand All @@ -794,7 +794,7 @@ var LibraryWebGL2 = {
GL.validateGLObjectID(GLctx.currentProgram.uniformLocsById, location, 'glUniform3uiv', 'location');
assert((value & 3) == 0, 'Pointer to integer data passed to glUniform3uiv must be aligned to four bytes!');
#endif
count && GLctx.uniform3uiv(webglGetUniformLocation(location), HEAPU32, value>>2, count*3);
count && GLctx.uniform3uiv(webglGetUniformLocation(location), HEAPU32, {{{ getHeapOffset('value', 'u32') }}}, count*3);
},

glUniform4uiv__deps: ['$webglGetUniformLocation'],
Expand All @@ -803,7 +803,7 @@ var LibraryWebGL2 = {
GL.validateGLObjectID(GLctx.currentProgram.uniformLocsById, location, 'glUniform4uiv', 'location');
assert((value & 3) == 0, 'Pointer to integer data passed to glUniform4uiv must be aligned to four bytes!');
#endif
count && GLctx.uniform4uiv(webglGetUniformLocation(location), HEAPU32, value>>2, count*4);
count && GLctx.uniform4uiv(webglGetUniformLocation(location), HEAPU32, {{{ getHeapOffset('value', 'u32') }}}, count*4);
},

glUniformMatrix2x3fv__deps: ['$webglGetUniformLocation'],
Expand All @@ -812,7 +812,7 @@ var LibraryWebGL2 = {
GL.validateGLObjectID(GLctx.currentProgram.uniformLocsById, location, 'glUniformMatrix2x3fv', 'location');
assert((value & 3) == 0, 'Pointer to float data passed to glUniformMatrix2x3fv must be aligned to four bytes!');
#endif
count && GLctx.uniformMatrix2x3fv(webglGetUniformLocation(location), !!transpose, HEAPF32, value>>2, count*6);
count && GLctx.uniformMatrix2x3fv(webglGetUniformLocation(location), !!transpose, HEAPF32, {{{ getHeapOffset('value', 'float') }}}, count*6);
},

glUniformMatrix3x2fv__deps: ['$webglGetUniformLocation'],
Expand All @@ -821,7 +821,7 @@ var LibraryWebGL2 = {
GL.validateGLObjectID(GLctx.currentProgram.uniformLocsById, location, 'glUniformMatrix3x2fv', 'location');
assert((value & 3) == 0, 'Pointer to float data passed to glUniformMatrix3x2fv must be aligned to four bytes!');
#endif
count && GLctx.uniformMatrix3x2fv(webglGetUniformLocation(location), !!transpose, HEAPF32, value>>2, count*6);
count && GLctx.uniformMatrix3x2fv(webglGetUniformLocation(location), !!transpose, HEAPF32, {{{ getHeapOffset('value', 'float') }}}, count*6);
},

glUniformMatrix2x4fv__deps: ['$webglGetUniformLocation'],
Expand All @@ -830,7 +830,7 @@ var LibraryWebGL2 = {
GL.validateGLObjectID(GLctx.currentProgram.uniformLocsById, location, 'glUniformMatrix2x4fv', 'location');
assert((value & 3) == 0, 'Pointer to float data passed to glUniformMatrix2x4fv must be aligned to four bytes!');
#endif
count && GLctx.uniformMatrix2x4fv(webglGetUniformLocation(location), !!transpose, HEAPF32, value>>2, count*8);
count && GLctx.uniformMatrix2x4fv(webglGetUniformLocation(location), !!transpose, HEAPF32, {{{ getHeapOffset('value', 'float') }}}, count*8);
},

glUniformMatrix4x2fv__deps: ['$webglGetUniformLocation'],
Expand All @@ -839,7 +839,7 @@ var LibraryWebGL2 = {
GL.validateGLObjectID(GLctx.currentProgram.uniformLocsById, location, 'glUniformMatrix4x2fv', 'location');
assert((value & 3) == 0, 'Pointer to float data passed to glUniformMatrix4x2fv must be aligned to four bytes!');
#endif
count && GLctx.uniformMatrix4x2fv(webglGetUniformLocation(location), !!transpose, HEAPF32, value>>2, count*8);
count && GLctx.uniformMatrix4x2fv(webglGetUniformLocation(location), !!transpose, HEAPF32, {{{ getHeapOffset('value', 'float') }}}, count*8);
},

glUniformMatrix3x4fv__deps: ['$webglGetUniformLocation'],
Expand All @@ -848,7 +848,7 @@ var LibraryWebGL2 = {
GL.validateGLObjectID(GLctx.currentProgram.uniformLocsById, location, 'glUniformMatrix3x4fv', 'location');
assert((value & 3) == 0, 'Pointer to float data passed to glUniformMatrix3x4fv must be aligned to four bytes!');
#endif
count && GLctx.uniformMatrix3x4fv(webglGetUniformLocation(location), !!transpose, HEAPF32, value>>2, count*12);
count && GLctx.uniformMatrix3x4fv(webglGetUniformLocation(location), !!transpose, HEAPF32, {{{ getHeapOffset('value', 'float') }}}, count*12);
},

glUniformMatrix4x3fv__deps: ['$webglGetUniformLocation'],
Expand All @@ -857,7 +857,7 @@ var LibraryWebGL2 = {
GL.validateGLObjectID(GLctx.currentProgram.uniformLocsById, location, 'glUniformMatrix4x3fv', 'location');
assert((value & 3) == 0, 'Pointer to float data passed to glUniformMatrix4x3fv must be aligned to four bytes!');
#endif
count && GLctx.uniformMatrix4x3fv(webglGetUniformLocation(location), !!transpose, HEAPF32, value>>2, count*12);
count && GLctx.uniformMatrix4x3fv(webglGetUniformLocation(location), !!transpose, HEAPF32, {{{ getHeapOffset('value', 'float') }}}, count*12);
},

glVertexAttribI4iv: (index, v) => {
Expand Down Expand Up @@ -968,13 +968,13 @@ var LibraryWebGL2 = {
GLctx.mdibvbi['multiDrawArraysInstancedBaseInstanceWEBGL'](
mode,
HEAP32,
firsts >> 2,
{{{ getHeapOffset('firsts', 'i32') }}},
HEAP32,
counts >> 2,
{{{ getHeapOffset('counts', 'i32') }}},
HEAP32,
instanceCounts >> 2,
{{{ getHeapOffset('instanceCounts', 'i32') }}},
HEAPU32,
baseInstances >> 2,
{{{ getHeapOffset('baseInstances', 'i32') }}},
drawCount);
},
glMultiDrawArraysInstancedBaseInstanceANGLE: 'glMultiDrawArraysInstancedBaseInstanceWEBGL',
Expand All @@ -984,16 +984,16 @@ var LibraryWebGL2 = {
GLctx.mdibvbi['multiDrawElementsInstancedBaseVertexBaseInstanceWEBGL'](
mode,
HEAP32,
counts >> 2,
{{{ getHeapOffset('counts', 'i32') }}},
type,
HEAP32,
offsets >> 2,
{{{ getHeapOffset('offsets', 'i32') }}},
HEAP32,
instanceCounts >> 2,
{{{ getHeapOffset('instanceCounts', 'i32') }}},
HEAP32,
baseVertices >> 2,
{{{ getHeapOffset('baseVertices', 'i32') }}},
HEAPU32,
baseInstances >> 2,
{{{ getHeapOffset('baseInstances', 'i32') }}},
drawCount);
},
glMultiDrawElementsInstancedBaseVertexBaseInstanceANGLE: 'glMultiDrawElementsInstancedBaseVertexBaseInstanceWEBGL',
Expand Down
Loading
Loading