diff --git a/src/library_html5_webgpu.js b/src/library_html5_webgpu.js index 3da5f12874d99..d0307fe3517da 100644 --- a/src/library_html5_webgpu.js +++ b/src/library_html5_webgpu.js @@ -90,4 +90,8 @@ var LibraryHTML5WebGPU = { {{{ html5_gpu.makeImportExport('render_bundle_encoder', 'RenderBundleEncoder') }}} {{{ html5_gpu.makeImportExport('render_bundle', 'RenderBundle') }}} +for (const key of Object.keys(LibraryHTML5WebGPU)) { + LibraryHTML5WebGPU[key + '__proxy'] = 'sync'; +} + addToLibrary(LibraryHTML5WebGPU); diff --git a/src/library_webgpu.js b/src/library_webgpu.js index 01a1d7137ebae..b3920f5d3007b 100644 --- a/src/library_webgpu.js +++ b/src/library_webgpu.js @@ -2198,7 +2198,7 @@ var LibraryWebGPU = { #endif var bundles = Array.from(HEAP32.subarray(bundlesPtr >> 2, (bundlesPtr >> 2) + count), - function(id) { return WebGPU.mgrRenderBundle.get(id); }); + (id) => WebGPU.mgrRenderBundle.get(id)); pass["executeBundles"](bundles); }, @@ -2586,23 +2586,22 @@ var LibraryWebGPU = { var device = WebGPU.mgrDevice.get(deviceId); var context = WebGPU.mgrSurface.get(surfaceId); - #if ASSERTIONS assert({{{ gpu.PresentMode.Fifo }}} === {{{ gpu.makeGetU32('descriptor', C_STRUCTS.WGPUSwapChainDescriptor.presentMode) }}}); #endif var canvasSize = [ - {{{ gpu.makeGetU32('descriptor', C_STRUCTS.WGPUSwapChainDescriptor.width) }}}, - {{{ gpu.makeGetU32('descriptor', C_STRUCTS.WGPUSwapChainDescriptor.height) }}} + {{{ gpu.makeGetU32('descriptor', C_STRUCTS.WGPUSwapChainDescriptor.width) }}}, + {{{ gpu.makeGetU32('descriptor', C_STRUCTS.WGPUSwapChainDescriptor.height) }}} ]; if (canvasSize[0] !== 0) { - context["canvas"]["width"] = canvasSize[0]; + context["canvas"]["width"] = canvasSize[0]; } if (canvasSize[1] !== 0) { - context["canvas"]["height"] = canvasSize[1]; + context["canvas"]["height"] = canvasSize[1]; } var configuration = { @@ -2646,6 +2645,7 @@ for (var value in LibraryWebGPU.$WebGPU.FeatureName) { for (const key of Object.keys(LibraryWebGPU)) { LibraryWebGPU[key + '__i53abi'] = true; + LibraryWebGPU[key + '__proxy'] = 'sync'; } autoAddDeps(LibraryWebGPU, '$WebGPU'); diff --git a/test/test_browser.py b/test/test_browser.py index 12bd6420e3d21..ee34bafa681cf 100644 --- a/test/test_browser.py +++ b/test/test_browser.py @@ -4664,9 +4664,18 @@ def test_webgl_simple_enable_extensions(self): def test_webgpu_basic_rendering(self, args): self.btest_exit('webgpu_basic_rendering.cpp', args=['-sUSE_WEBGPU'] + args) + @requires_graphics_hardware + @requires_threads + def test_webgpu_basic_rendering_pthreads(self): + self.btest_exit('webgpu_basic_rendering.cpp', args=['-sUSE_WEBGPU', '-pthread', '-sPROXY_TO_PTHREAD']) + def test_webgpu_get_device(self): self.btest_exit('webgpu_get_device.cpp', args=['-sUSE_WEBGPU', '-sASSERTIONS', '--closure=1']) + @requires_threads + def test_webgpu_get_device_pthreads(self): + self.btest_exit('webgpu_get_device.cpp', args=['-sUSE_WEBGPU', '-pthread', '-sPROXY_TO_PTHREAD']) + # Tests the feature that shell html page can preallocate the typed array and place it # to Module.buffer before loading the script page. # In this build mode, the -sINITIAL_MEMORY=xxx option will be ignored. diff --git a/test/webgpu_get_device.cpp b/test/webgpu_get_device.cpp index 80ef054bf3c66..a5861042059f7 100644 --- a/test/webgpu_get_device.cpp +++ b/test/webgpu_get_device.cpp @@ -1,9 +1,16 @@ -#include +#include + +#include #include -int main() { +__attribute__((constructor)) void init() { EM_ASM({ Module['preinitializedWebGPUDevice'] = { this_is: 'a_dummy_object' }; }); - emscripten_webgpu_get_device(); +} + +int main() { + WGPUDevice d = emscripten_webgpu_get_device(); + printf("emscripten_webgpu_get_device: %p\n", d); + return 0; }