Skip to content

Commit

Permalink
[wasm64] Enable more tests under wasm64 + 2gb+ modes
Browse files Browse the repository at this point in the history
  • Loading branch information
sbc100 committed Feb 1, 2024
1 parent a70a69f commit 736b764
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 3 deletions.
2 changes: 0 additions & 2 deletions src/library_html5_webgl.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,8 @@ var LibraryHtml5WebGL = {
},
emscripten_webgl_do_commit_frame: () => {
#if TRACE_WEBGL_CALLS
var threadId = (typeof _pthread_self != 'undefined') ? _pthread_self : () => 1;
err(`[Thread ${threadId()}, GL ctx: ${GL.currentContext.handle}]: emscripten_webgl_do_commit_frame()`);
#endif
if (!GL.currentContext || !GL.currentContext.GLctx) {
#if GL_DEBUG
dbg('emscripten_webgl_commit_frame() failed: no GL context set current via emscripten_webgl_make_context_current()!');
Expand Down
4 changes: 3 additions & 1 deletion src/library_webgl.js
Original file line number Diff line number Diff line change
Expand Up @@ -1617,6 +1617,7 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
#endif
],
glTexImage2D: (target, level, internalFormat, width, height, border, format, type, pixels) => {
err("glTexImage2D", pixels);
#if MAX_WEBGL_VERSION >= 2
#if WEBGL2_BACKWARDS_COMPATIBILITY_EMULATION
if ({{{ isCurrentContextWebGL2() }}}) {
Expand Down Expand Up @@ -2782,7 +2783,7 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
var view = miniTempWebGLFloatBuffers[4*count-1];
// hoist the heap out of the loop for size and for pthreads+growth.
var heap = HEAPF32;
value >>= 2;
value = {{{ getHeapOffset('value', 'float') }}};
for (var i = 0; i < 4 * count; i += 4) {
var dst = value + i;
view[i] = heap[dst];
Expand Down Expand Up @@ -3110,6 +3111,7 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
#if GL_ASSERTIONS
GL.validateGLObjectID(GL.shaders, shader, 'glShaderSource', 'shader');
#endif
out('glShaderSource', shader, count, string, length);
var source = GL.getSource(shader, count, string, length);
#if WEBGL2_BACKWARDS_COMPATIBILITY_EMULATION
Expand Down
77 changes: 77 additions & 0 deletions test/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ def setUp(self):
def require_wasm2js(self):
if self.is_wasm64():
self.skipTest('wasm2js is not compatible with MEMORY64')
if self.is_2gb():
self.skipTest('wasm2js is not support >2gb address space')

def require_jspi(self):
if not is_chrome():
Expand Down Expand Up @@ -1812,6 +1814,7 @@ def test_glgears_animation(self):
self.run_browser('something.html', '/report_gl_result?true')

@requires_graphics_hardware
@no_4gb('assertion fails')
def test_fulles2_sdlproc(self):
self.btest_exit('full_es2_sdlproc.c', assert_returncode=1, args=['-sGL_TESTING', '-DHAVE_BUILTIN_SINCOS', '-sFULL_ES2', '-lGL', '-lSDL', '-lglut', '-sGL_ENABLE_GET_PROC_ADDRESS'])

Expand All @@ -1822,6 +1825,7 @@ def test_glgears_deriv(self):
assert 'gl-matrix' not in read_file('test.html'), 'Should not include glMatrix when not needed'

@requires_graphics_hardware
@no_4gb('fails to render')
def test_glbook(self):
self.emcc_args.append('-Wno-int-conversion')
self.emcc_args.append('-Wno-pointer-sign')
Expand Down Expand Up @@ -2013,6 +2017,7 @@ def test_gl_glteximage(self):
})
@requires_graphics_hardware
@requires_threads
@no_4gb('assertion failure')
def test_gl_textures(self, args):
self.btest_exit('gl_textures.cpp', args=['-lGL', '-g', '-sSTACK_SIZE=1MB'] + args)

Expand Down Expand Up @@ -2047,14 +2052,17 @@ def test_gl_renderers(self):
self.btest('gl_renderers.c', reference='gl_renderers.png', args=['-sGL_UNSAFE_OPTS=0', '-sLEGACY_GL_EMULATION', '-lGL', '-lSDL'])

@requires_graphics_hardware
@no_4gb('render fails')
def test_gl_stride(self):
self.btest('gl_stride.c', reference='gl_stride.png', args=['-sGL_UNSAFE_OPTS=0', '-sLEGACY_GL_EMULATION', '-lGL', '-lSDL'])

@requires_graphics_hardware
@no_4gb('assertion failure')
def test_gl_vertex_buffer_pre(self):
self.btest('gl_vertex_buffer_pre.c', reference='gl_vertex_buffer_pre.png', args=['-sGL_UNSAFE_OPTS=0', '-sLEGACY_GL_EMULATION', '-lGL', '-lSDL'])

@requires_graphics_hardware
@no_4gb('assertion failure')
def test_gl_vertex_buffer(self):
self.btest('gl_vertex_buffer.c', reference='gl_vertex_buffer.png', args=['-sGL_UNSAFE_OPTS=0', '-sLEGACY_GL_EMULATION', '-lGL', '-lSDL'], reference_slack=1)

Expand All @@ -2071,36 +2079,48 @@ def test_matrix_identity(self):
self.btest('gl_matrix_identity.c', expected=['-1882984448', '460451840', '1588195328', '2411982848'], args=['-sLEGACY_GL_EMULATION', '-lGL', '-lSDL'])

@no_wasm64('wasm64 + LEGACY_GL_EMULATION')
@no_2gb('')
@no_4gb('')
@requires_graphics_hardware
@no_swiftshader
def test_cubegeom_pre(self):
self.btest('third_party/cubegeom/cubegeom_pre.c', reference='third_party/cubegeom/cubegeom_pre.png', args=['-sLEGACY_GL_EMULATION', '-lGL', '-lSDL'])

@no_wasm64('wasm64 + LEGACY_GL_EMULATION')
@no_2gb('')
@no_4gb('')
@requires_graphics_hardware
@no_swiftshader
def test_cubegeom_pre_regal(self):
self.btest('third_party/cubegeom/cubegeom_pre.c', reference='third_party/cubegeom/cubegeom_pre.png', args=['-sUSE_REGAL', '-DUSE_REGAL', '-lGL', '-lSDL'])

@no_wasm64('wasm64 + LEGACY_GL_EMULATION')
@no_2gb('')
@no_4gb('')
@requires_graphics_hardware
@no_swiftshader
def test_cubegeom_pre_relocatable(self):
self.btest('third_party/cubegeom/cubegeom_pre.c', reference='third_party/cubegeom/cubegeom_pre.png', args=['-sLEGACY_GL_EMULATION', '-lGL', '-lSDL', '-sRELOCATABLE'])

@no_wasm64('wasm64 + LEGACY_GL_EMULATION')
@no_2gb('')
@no_4gb('')
@requires_graphics_hardware
@no_swiftshader
def test_cubegeom_pre2(self):
self.btest('third_party/cubegeom/cubegeom_pre2.c', reference='third_party/cubegeom/cubegeom_pre2.png', args=['-sGL_DEBUG', '-sLEGACY_GL_EMULATION', '-lGL', '-lSDL']) # some coverage for GL_DEBUG not breaking the build

@no_wasm64('wasm64 + LEGACY_GL_EMULATION')
@no_2gb('')
@no_4gb('')
@requires_graphics_hardware
@no_swiftshader
def test_cubegeom_pre3(self):
self.btest('third_party/cubegeom/cubegeom_pre3.c', reference='third_party/cubegeom/cubegeom_pre2.png', args=['-sLEGACY_GL_EMULATION', '-lGL', '-lSDL'])

@no_wasm64('wasm64 + LEGACY_GL_EMULATION')
@no_2gb('')
@no_4gb('')
@parameterized({
'': ([],),
'tracing': (['-sTRACE_WEBGL_CALLS'],),
Expand All @@ -2113,17 +2133,23 @@ def test_cubegeom(self, args):

@no_wasm64('wasm64 + LEGACY_GL_EMULATION')
@requires_graphics_hardware
@no_2gb('')
@no_4gb('')
def test_cubegeom_regal(self):
self.btest('third_party/cubegeom/cubegeom.c', reference='third_party/cubegeom/cubegeom.png', args=['-O2', '-g', '-DUSE_REGAL', '-sUSE_REGAL', '-lGL', '-lSDL', '-lc++', '-lc++abi'], also_proxied=True)

@no_wasm64('wasm64 + LEGACY_GL_EMULATION')
@requires_threads
@requires_graphics_hardware
@no_2gb('')
@no_4gb('')
def test_cubegeom_regal_mt(self):
self.btest('third_party/cubegeom/cubegeom.c', reference='third_party/cubegeom/cubegeom.png', args=['-O2', '-g', '-pthread', '-DUSE_REGAL', '-pthread', '-sUSE_REGAL', '-lGL', '-lSDL', '-lc++', '-lc++abi'], also_proxied=False)

@no_wasm64('wasm64 + LEGACY_GL_EMULATION')
@requires_graphics_hardware
@no_2gb('')
@no_4gb('')
@parameterized({
'': ([],),
'O1': (['-O1'],),
Expand All @@ -2148,106 +2174,146 @@ def test_cubegeom_proc(self, opts):
@no_wasm64('wasm64 + LEGACY_GL_EMULATION')
@also_with_wasmfs
@requires_graphics_hardware
@no_2gb('')
@no_4gb('')
def test_cubegeom_glew(self):
self.btest('third_party/cubegeom/cubegeom_glew.c', reference='third_party/cubegeom/cubegeom.png', args=['-O2', '--closure=1', '-sLEGACY_GL_EMULATION', '-lGL', '-lGLEW', '-lSDL'])

@no_wasm64('wasm64 + LEGACY_GL_EMULATION')
@requires_graphics_hardware
@no_2gb('')
@no_4gb('')
def test_cubegeom_color(self):
self.btest('third_party/cubegeom/cubegeom_color.c', reference='third_party/cubegeom/cubegeom_color.png', args=['-sLEGACY_GL_EMULATION', '-lGL', '-lSDL'])

@no_wasm64('wasm64 + LEGACY_GL_EMULATION')
@requires_graphics_hardware
@no_2gb('')
@no_4gb('')
def test_cubegeom_normal(self):
self.btest('third_party/cubegeom/cubegeom_normal.c', reference='third_party/cubegeom/cubegeom_normal.png', args=['-sLEGACY_GL_EMULATION', '-lGL', '-lSDL'], also_proxied=True)

@no_wasm64('wasm64 + LEGACY_GL_EMULATION')
@requires_graphics_hardware
@no_2gb('')
@no_4gb('')
def test_cubegeom_normal_dap(self): # draw is given a direct pointer to clientside memory, no element array buffer
self.btest('third_party/cubegeom/cubegeom_normal_dap.c', reference='third_party/cubegeom/cubegeom_normal.png', args=['-sLEGACY_GL_EMULATION', '-lGL', '-lSDL'], also_proxied=True)

@no_wasm64('wasm64 + LEGACY_GL_EMULATION')
@requires_graphics_hardware
@no_2gb('')
@no_4gb('')
def test_cubegeom_normal_dap_far(self): # indices do nto start from 0
self.btest('third_party/cubegeom/cubegeom_normal_dap_far.c', reference='third_party/cubegeom/cubegeom_normal.png', args=['-sLEGACY_GL_EMULATION', '-lGL', '-lSDL'])

@no_wasm64('wasm64 + LEGACY_GL_EMULATION')
@requires_graphics_hardware
@no_2gb('')
@no_4gb('')
def test_cubegeom_normal_dap_far_range(self): # glDrawRangeElements
self.btest('third_party/cubegeom/cubegeom_normal_dap_far_range.c', reference='third_party/cubegeom/cubegeom_normal.png', args=['-sLEGACY_GL_EMULATION', '-lGL', '-lSDL'])

@no_wasm64('wasm64 + LEGACY_GL_EMULATION')
@requires_graphics_hardware
@no_2gb('')
@no_4gb('')
def test_cubegeom_normal_dap_far_glda(self): # use glDrawArrays
self.btest('third_party/cubegeom/cubegeom_normal_dap_far_glda.c', reference='third_party/cubegeom/cubegeom_normal_dap_far_glda.png', args=['-sLEGACY_GL_EMULATION', '-lGL', '-lSDL'])

@no_wasm64('wasm64 + LEGACY_GL_EMULATION')
@requires_graphics_hardware
@no_firefox('fails on CI but works locally')
@no_2gb('')
@no_4gb('')
def test_cubegeom_normal_dap_far_glda_quad(self): # with quad
self.btest('third_party/cubegeom/cubegeom_normal_dap_far_glda_quad.c', reference='third_party/cubegeom/cubegeom_normal_dap_far_glda_quad.png', args=['-sLEGACY_GL_EMULATION', '-lGL', '-lSDL'])

@no_wasm64('wasm64 + LEGACY_GL_EMULATION')
@requires_graphics_hardware
@no_2gb('')
@no_4gb('')
def test_cubegeom_mt(self):
self.btest('third_party/cubegeom/cubegeom_mt.c', reference='third_party/cubegeom/cubegeom_mt.png', args=['-sLEGACY_GL_EMULATION', '-lGL', '-lSDL']) # multitexture

@no_wasm64('wasm64 + LEGACY_GL_EMULATION')
@requires_graphics_hardware
@no_2gb('')
@no_4gb('')
def test_cubegeom_color2(self):
self.btest('third_party/cubegeom/cubegeom_color2.c', reference='third_party/cubegeom/cubegeom_color2.png', args=['-sLEGACY_GL_EMULATION', '-lGL', '-lSDL'], also_proxied=True)

@no_wasm64('wasm64 + LEGACY_GL_EMULATION')
@requires_graphics_hardware
@no_2gb('')
@no_4gb('')
def test_cubegeom_texturematrix(self):
self.btest('third_party/cubegeom/cubegeom_texturematrix.c', reference='third_party/cubegeom/cubegeom_texturematrix.png', args=['-sLEGACY_GL_EMULATION', '-lGL', '-lSDL'])

@no_wasm64('wasm64 + LEGACY_GL_EMULATION')
@requires_graphics_hardware
@no_2gb('')
@no_4gb('')
def test_cubegeom_fog(self):
self.btest('third_party/cubegeom/cubegeom_fog.c', reference='third_party/cubegeom/cubegeom_fog.png', args=['-sLEGACY_GL_EMULATION', '-lGL', '-lSDL'])

@no_wasm64('wasm64 + LEGACY_GL_EMULATION')
@requires_graphics_hardware
@no_swiftshader
@no_2gb('')
@no_4gb('')
def test_cubegeom_pre_vao(self):
self.btest('third_party/cubegeom/cubegeom_pre_vao.c', reference='third_party/cubegeom/cubegeom_pre_vao.png', args=['-sLEGACY_GL_EMULATION', '-lGL', '-lSDL'])

@no_wasm64('wasm64 + LEGACY_GL_EMULATION')
@requires_graphics_hardware
@no_swiftshader
@no_2gb('')
@no_4gb('')
def test_cubegeom_pre_vao_regal(self):
self.btest('third_party/cubegeom/cubegeom_pre_vao.c', reference='third_party/cubegeom/cubegeom_pre_vao.png', args=['-sUSE_REGAL', '-DUSE_REGAL', '-lGL', '-lSDL'])

@no_wasm64('wasm64 + LEGACY_GL_EMULATION')
@requires_graphics_hardware
@no_swiftshader
@no_2gb('')
@no_4gb('')
def test_cubegeom_pre2_vao(self):
self.btest('third_party/cubegeom/cubegeom_pre2_vao.c', reference='third_party/cubegeom/cubegeom_pre_vao.png', args=['-sLEGACY_GL_EMULATION', '-lGL', '-lSDL', '-sGL_ENABLE_GET_PROC_ADDRESS'])

@no_wasm64('wasm64 + LEGACY_GL_EMULATION')
@requires_graphics_hardware
@no_2gb('')
@no_4gb('')
def test_cubegeom_pre2_vao2(self):
self.btest('third_party/cubegeom/cubegeom_pre2_vao2.c', reference='third_party/cubegeom/cubegeom_pre2_vao2.png', args=['-sLEGACY_GL_EMULATION', '-lGL', '-lSDL', '-sGL_ENABLE_GET_PROC_ADDRESS'])

@no_wasm64('wasm64 + LEGACY_GL_EMULATION')
@requires_graphics_hardware
@no_swiftshader
@no_2gb('')
@no_4gb('')
def test_cubegeom_pre_vao_es(self):
self.btest('third_party/cubegeom/cubegeom_pre_vao_es.c', reference='third_party/cubegeom/cubegeom_pre_vao.png', args=['-sFULL_ES2', '-lGL', '-lSDL'])

@no_wasm64('wasm64 + LEGACY_GL_EMULATION')
@requires_graphics_hardware
@no_2gb('')
@no_4gb('')
def test_cubegeom_u4fv_2(self):
self.btest('third_party/cubegeom/cubegeom_u4fv_2.c', reference='third_party/cubegeom/cubegeom_u4fv_2.png', args=['-sLEGACY_GL_EMULATION', '-lGL', '-lSDL'])

@no_wasm64('wasm64 + LEGACY_GL_EMULATION')
@requires_graphics_hardware
@no_2gb('')
@no_4gb('')
def test_cube_explosion(self):
self.btest('cube_explosion.c', reference='cube_explosion.png', args=['-sLEGACY_GL_EMULATION', '-lGL', '-lSDL'], also_proxied=True)

@no_wasm64('wasm64 + LEGACY_GL_EMULATION')
@requires_graphics_hardware
@no_2gb('')
@no_4gb('')
def test_glgettexenv(self):
self.btest('glgettexenv.c', args=['-sLEGACY_GL_EMULATION', '-lGL', '-lSDL'], expected='1')

Expand Down Expand Up @@ -2337,6 +2403,7 @@ def test_tex_nonbyte(self):
self.btest('tex_nonbyte.c', reference='tex_nonbyte.png', args=['-sLEGACY_GL_EMULATION', '-lGL', '-lSDL'])

@requires_graphics_hardware
@no_4gb('fails to render')
def test_float_tex(self):
self.btest('float_tex.cpp', reference='float_tex.png', args=['-lGL', '-lglut'])

Expand Down Expand Up @@ -5592,6 +5659,7 @@ def test_4gb(self):

# Tests that emmalloc supports up to 4GB Wasm heaps.
@no_firefox('no 4GB support yet')
@no_4gb('depends on specific memory limits')
def test_emmalloc_4gb(self):
# For now, keep this in browser as this suite runs serially, which
# means we don't compete for memory with anything else (and run it
Expand All @@ -5602,6 +5670,8 @@ def test_emmalloc_4gb(self):
# Test that it is possible to malloc() a huge 3GB memory block in 4GB mode using emmalloc.
# Also test emmalloc-memvalidate and emmalloc-memvalidate-verbose build configurations.
@no_firefox('no 4GB support yet')
@no_2gb('depends on specific memory limits')
@no_4gb('depends on specific memory limits')
@parameterized({
'': (['-sMALLOC=emmalloc'],),
'debug': (['-sMALLOC=emmalloc-debug'],),
Expand All @@ -5614,6 +5684,8 @@ def test_emmalloc_3gb(self, args):

# Test that it is possible to malloc() a huge 3GB memory block in 4GB mode using dlmalloc.
@no_firefox('no 4GB support yet')
@no_2gb('depends on specific memory limits')
@no_4gb('depends on specific memory limits')
def test_dlmalloc_3gb(self):
self.btest_exit('alloc_3gb.c',
args=['-sMALLOC=dlmalloc', '-sMAXIMUM_MEMORY=4GB', '-sALLOW_MEMORY_GROWTH=1'])
Expand Down Expand Up @@ -5669,6 +5741,7 @@ def test_wasmfs_opfs_errors(self):
self.btest(test, args=args, expected="0")

@no_firefox('no 4GB support yet')
@no_4gb('depends on specific memory limits')
def test_emmalloc_memgrowth(self, *args):
self.btest('emmalloc_memgrowth.cpp', expected='0', args=['-sMALLOC=emmalloc', '-sALLOW_MEMORY_GROWTH=1', '-sABORTING_MALLOC=0', '-sASSERTIONS=2', '-sMINIMAL_RUNTIME=1', '-sMAXIMUM_MEMORY=4GB'])

Expand Down Expand Up @@ -5923,6 +5996,8 @@ def setUp(self):
self.set_setting('INITIAL_MEMORY', '4200mb')
self.set_setting('GLOBAL_BASE', '4gb')
self.emcc_args.append('-Wno-experimental')
# Without this we get a warning about GLOBAL_BASE being ignored when used with SIDE_MODULE
self.emcc_args.append('-Wno-unused-command-line-argument')
self.require_wasm64()


Expand All @@ -5931,3 +6006,5 @@ def setUp(self):
super().setUp()
self.set_setting('INITIAL_MEMORY', '2200mb')
self.set_setting('GLOBAL_BASE', '2gb')
# Without this we get a warning about GLOBAL_BASE being ignored when used with SIDE_MODULE
self.emcc_args.append('-Wno-unused-command-line-argument')

0 comments on commit 736b764

Please sign in to comment.