Skip to content

Commit

Permalink
[wasm64] Fix reading/writing of gl attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
sbc100 committed Jan 31, 2024
1 parent fe01b30 commit bd67eb9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/library_html5_webgl.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,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
2 changes: 2 additions & 0 deletions src/library_webgl.js
Original file line number Diff line number Diff line change
Expand Up @@ -1614,6 +1614,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 @@ -3107,6 +3108,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
13 changes: 13 additions & 0 deletions test/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1812,6 +1812,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 +1823,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 +2015,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 +2050,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 Down Expand Up @@ -2337,6 +2343,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 @@ -5587,6 +5594,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 @@ -5597,6 +5605,7 @@ 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_4gb('depends on specific memory limits')
@parameterized({
'': (['-sMALLOC=emmalloc'],),
'debug': (['-sMALLOC=emmalloc-debug'],),
Expand All @@ -5609,6 +5618,7 @@ 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_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 @@ -5664,6 +5674,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 @@ -5916,4 +5927,6 @@ 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()

0 comments on commit bd67eb9

Please sign in to comment.