Skip to content

Commit

Permalink
[wasm64] Run all browser tests in 4gb mode
Browse files Browse the repository at this point in the history
  • Loading branch information
sbc100 committed Feb 13, 2024
1 parent 24697df commit cb39845
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/library_html5.js
Original file line number Diff line number Diff line change
Expand Up @@ -2273,7 +2273,7 @@ var LibraryHTML5 = {
}
#if OFFSCREENCANVAS_SUPPORT
} else if (canvas.canvasSharedPtr) {
var targetThread = {{{ makeGetValue('canvas.canvasSharedPtr', 8, 'i32') }}};
var targetThread = {{{ makeGetValue('canvas.canvasSharedPtr', 8, '*') }}};
setOffscreenCanvasSizeOnTargetThread(targetThread, target, width, height);
return {{{ cDefs.EMSCRIPTEN_RESULT_DEFERRED }}}; // This will have to be done asynchronously
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/library_idbstore.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ var LibraryIDBStore = {
}
var buffer = _malloc(byteArray.length); // must be freed by the caller!
HEAPU8.set(byteArray, buffer);
{{{ makeSetValue('pbuffer', 0, 'buffer', 'i32') }}};
{{{ makeSetValue('pbuffer', 0, 'buffer', '*') }}};
{{{ makeSetValue('pnum', 0, 'byteArray.length', 'i32') }}};
{{{ makeSetValue('perror', 0, '0', 'i32') }}};
wakeUp();
Expand Down
2 changes: 1 addition & 1 deletion src/library_pthread.js
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,7 @@ var LibraryPThread = {
// owns the OffscreenCanvas.
for (var canvas of Object.values(offscreenCanvases)) {
// pthread ptr to the thread that owns this canvas.
{{{ makeSetValue('canvas.canvasSharedPtr', 8, 'pthread_ptr', 'i32') }}};
{{{ makeSetValue('canvas.canvasSharedPtr', 8, 'pthread_ptr', '*') }}};
}
#endif

Expand Down
5 changes: 3 additions & 2 deletions src/library_webgl.js
Original file line number Diff line number Diff line change
Expand Up @@ -1731,7 +1731,8 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
GLctx.readPixels(x, y, width, height, format, type, pixels);
} else {
var heap = heapObjectForWebGLType(type);
GLctx.readPixels(x, y, width, height, format, type, heap, toTypedArrayIndex(pixels, heap));
var target = toTypedArrayIndex(pixels, heap);
GLctx.readPixels(x, y, width, height, format, type, heap, target);
}
return;
}
Expand Down Expand Up @@ -3310,7 +3311,7 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
if (length) {{{ makeSetValue('length', '0', 'numBytesWrittenExclNull', 'i32') }}};
},
glGetShaderiv : (shader, pname, p) => {
glGetShaderiv: (shader, pname, p) => {
if (!p) {
// GLES2 specification does not specify how to behave if p is a null
// pointer. Since calling this function does not make sense if p == null,
Expand Down
11 changes: 10 additions & 1 deletion test/browser/webgl2_get_buffer_sub_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,19 @@ int main()
glBindBuffer(GL_ARRAY_BUFFER, buffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(data), data, GL_STATIC_DRAW);

uint8_t data2[8] = {};
uint8_t data2[8] = { 1, 1, 1, 1, 1, 1, 1, 1 };

// Test full buffer read
glGetBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(data), data2);
printf("read data: %x %x %x %x %x %x %x %x\n",
data2[0],
data2[1],
data2[2],
data2[3],
data2[4],
data2[5],
data2[6],
data2[7]);
assert(!memcmp(data, data2, sizeof(data)));

// Test partial buffer read
Expand Down
19 changes: 7 additions & 12 deletions test/resize_offscreencanvas_from_main_thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
// If not defined, the pthread that owns the OffscreenCanvas is using emscripten_set_main_loop() so periodically yields back to the event loop.
// #define TEST_SYNC_BLOCKING_LOOP

void thread_local_main_loop()
{
void thread_local_main_loop() {
int w = 0, h = 0;
emscripten_get_canvas_element_size("#canvas", &w, &h);
if (w == 699 && h == 299) {
Expand All @@ -27,11 +26,10 @@ void thread_local_main_loop()

emscripten_force_exit(0);
}
printf("%dx%d\n", w, h);
printf("thread_local_main_loop: %dx%d\n", w, h);
}

void *thread_main(void *arg)
{
void *thread_main(void *arg) {
EmscriptenWebGLContextAttributes attr;
emscripten_webgl_init_context_attributes(&attr);
attr.explicitSwapControl = EM_TRUE;
Expand All @@ -57,31 +55,28 @@ void *thread_main(void *arg)
return 0;
}

void resize_canvas(void *)
{
void resize_canvas(void* arg) {
// Test that on the main thread, we can observe size changes to the canvas size.
int w, h;
emscripten_get_canvas_element_size("#canvas", &w, &h);
printf("Main thread saw canvas to get resized to %dx%d.\n", w, h);
assert(w == 355 && "We did not observe the effect of pthread having resized OffscreenCanvas");
assert(h == 233);
printf("Main thread saw canvas to get resized to %dx%d.\n", w, h);

// Test that on the main thread, we can also change the size. (pthread listens to see this)
printf("Main thread resizing OffscreenCanvas to size 699x299.\n");
emscripten_set_canvas_element_size("#canvas", 699, 299);
}

//should be able to do this regardless of offscreen canvas support
void get_canvas_size()
{
void get_canvas_size() {
int w, h;
emscripten_get_canvas_element_size("#canvas", &w, &h);
assert(h == 150);
assert(w == 300);
}

int main()
{
int main() {
get_canvas_size();
if (!emscripten_supports_offscreencanvas()) {
printf("Current browser does not support OffscreenCanvas. Skipping the rest of the tests.\n");
Expand Down
25 changes: 18 additions & 7 deletions test/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1343,6 +1343,7 @@ def test_webgl_parallel_shader_compile(self):
self.btest_exit('webgl_parallel_shader_compile.cpp')

@requires_graphics_hardware
@no_4gb('readPixels fails: https://crbug.com/324992397')
def test_webgl_explicit_uniform_location(self):
self.btest_exit('webgl_explicit_uniform_location.c', args=['-sGL_EXPLICIT_UNIFORM_LOCATION', '-sMIN_WEBGL_VERSION=2'])

Expand All @@ -1351,6 +1352,7 @@ def test_webgl_sampler_layout_binding(self):
self.btest_exit('webgl_sampler_layout_binding.c', args=['-sGL_EXPLICIT_UNIFORM_BINDING'])

@requires_graphics_hardware
@no_4gb('readPixels fails: https://crbug.com/324992397')
def test_webgl2_ubo_layout_binding(self):
self.btest_exit('webgl2_ubo_layout_binding.c', args=['-sGL_EXPLICIT_UNIFORM_BINDING', '-sMIN_WEBGL_VERSION=2'])

Expand Down Expand Up @@ -1552,6 +1554,7 @@ def test_sdl_gl_read(self):
self.btest_exit('test_sdl_gl_read.c', args=['-lSDL', '-lGL'])

@requires_graphics_hardware
@no_4gb('readPixels fails: https://crbug.com/324992397')
def test_sdl_gl_mapbuffers(self):
self.btest_exit('test_sdl_gl_mapbuffers.c', args=['-sFULL_ES3', '-lSDL', '-lGL'])

Expand Down Expand Up @@ -2522,7 +2525,7 @@ def test_runtime_misuse(self, mode):
var xhr = new XMLHttpRequest();
out('done timeout noted = ' + Module.noted);
assert(Module.noted);
xhr.open('GET', 'http://localhost:%s/report_result?' + HEAP32[Module.noted>>2]);
xhr.open('GET', 'http://localhost:%s/report_result?' + HEAP32[Module.noted/4]);
xhr.send();
setTimeout(function() { window.close() }, 1000);
}, 0);
Expand Down Expand Up @@ -2768,6 +2771,7 @@ def test_webgl2(self, args):

# Tests the WebGL 2 glGetBufferSubData() functionality.
@requires_graphics_hardware
@no_4gb('getBufferSubData fails: https://crbug.com/325090165')
def test_webgl2_get_buffer_sub_data(self):
self.btest_exit('webgl2_get_buffer_sub_data.cpp', args=['-sMAX_WEBGL_VERSION=2', '-lGL'])

Expand Down Expand Up @@ -2840,30 +2844,36 @@ def test_webgl2_packed_types(self):
self.btest_exit('webgl2_draw_packed_triangle.c', args=['-lGL', '-sMAX_WEBGL_VERSION=2', '-sGL_ASSERTIONS'])

@requires_graphics_hardware
@no_4gb('compressedTexSubImage2D fails: https://crbug.com/324562920')
def test_webgl2_pbo(self):
self.btest_exit('webgl2_pbo.cpp', args=['-sMAX_WEBGL_VERSION=2', '-lGL'])

@no_firefox('fails on CI likely due to GPU drivers there')
@requires_graphics_hardware
@no_4gb('fails to render')
def test_webgl2_sokol_mipmap(self):
self.btest('third_party/sokol/mipmap-emsc.c', args=['-sMAX_WEBGL_VERSION=2', '-lGL', '-O1'],
reference='third_party/sokol/mipmap-emsc.png', reference_slack=2)

@no_firefox('fails on CI likely due to GPU drivers there')
@no_4gb('fails to render')
@requires_graphics_hardware
def test_webgl2_sokol_mrt(self):
self.btest('third_party/sokol/mrt-emcc.c', args=['-sMAX_WEBGL_VERSION=2', '-lGL'],
reference='third_party/sokol/mrt-emcc.png')

@requires_graphics_hardware
@no_4gb('fails to render')
def test_webgl2_sokol_arraytex(self):
self.btest('third_party/sokol/arraytex-emsc.c', args=['-sMAX_WEBGL_VERSION=2', '-lGL'],
reference='third_party/sokol/arraytex-emsc.png')

def test_sdl_touch(self):
for opts in [[], ['-O2', '-g1', '--closure=1']]:
print(opts)
self.btest_exit('test_sdl_touch.c', args=opts + ['-DAUTOMATE_SUCCESS=1', '-lSDL', '-lGL'])
@parameterized({
'': ([],),
'closure': (['-O2', '-g1', '--closure=1'],),
})
def test_sdl_touch(self, opts):
self.btest_exit('test_sdl_touch.c', args=opts + ['-DAUTOMATE_SUCCESS=1', '-lSDL', '-lGL'])

def test_html5_mouse(self):
for opts in [[], ['-O2', '-g1', '--closure=1']]:
Expand Down Expand Up @@ -4700,9 +4710,9 @@ def test_webgl_draw_base_vertex_base_instance(self):
'-DWEBGL_CONTEXT_VERSION=2'])

@requires_graphics_hardware
@no_4gb('fails to render')
def test_webgl_sample_query(self):
cmd = ['-sMAX_WEBGL_VERSION=2', '-lGL']
self.btest_exit('webgl_sample_query.cpp', args=cmd)
self.btest_exit('webgl_sample_query.cpp', args=['-sMAX_WEBGL_VERSION=2', '-lGL'])

@requires_graphics_hardware
@parameterized({
Expand Down Expand Up @@ -4758,6 +4768,7 @@ def test_webgl_offscreen_framebuffer_state_restoration(self):

# Tests that using an array of structs in GL uniforms works.
@requires_graphics_hardware
@no_4gb('fails to render')
def test_webgl_array_of_structs_uniform(self):
self.btest('webgl_array_of_structs_uniform.c', args=['-lGL', '-sMAX_WEBGL_VERSION=2'], reference='browser/webgl_array_of_structs_uniform.png')

Expand Down

0 comments on commit cb39845

Please sign in to comment.