Skip to content

Commit

Permalink
add webgpu canvas support
Browse files Browse the repository at this point in the history
  • Loading branch information
kainino0x committed Sep 28, 2019
1 parent ef164cf commit 44a16c5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/library_html5.js
Original file line number Diff line number Diff line change
Expand Up @@ -2598,6 +2598,16 @@ var LibraryJSEvents = {
WebGPU.initManagers();
return WebGPU.mgrDevice.create(Module['preinitializedWebGPUDevice']);
},

emscripten_webgpu_get_current_texture__sig: 'i',
emscripten_webgpu_get_current_texture: 'emscripten_webgpu_do_get_current_texture',
emscripten_webgpu_do_get_current_texture__deps: ['$WebGPU'],
emscripten_webgpu_do_get_current_texture: function() {
var swapchain = Module['preinitializedWebGPUSwapChain'];
assert(swapchain);
WebGPU.initManagers();
return WebGPU.mgrTexture.create(swapchain.getCurrentTexture());
},
#endif

#if USE_PTHREADS
Expand Down
2 changes: 2 additions & 0 deletions src/library_webgpu.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
var LibraryWebGPU = {
$WebGPU: {
initManagers: function() {
if (this.mgrDevice) return;

function makeManager() {
return {
objects: [undefined],
Expand Down
2 changes: 2 additions & 0 deletions system/include/emscripten/html5.h
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,9 @@ extern void *emscripten_webgl2_get_proc_address(const char *name);
extern void *emscripten_webgl_get_proc_address(const char *name);

typedef struct DawnDeviceImpl* DawnDevice;
typedef struct DawnTextureImpl* DawnTexture;
extern DawnDevice emscripten_webgpu_get_device();
extern DawnTexture emscripten_webgpu_get_current_texture();

extern EMSCRIPTEN_RESULT emscripten_set_canvas_element_size(const char *target, int width, int height);
extern EMSCRIPTEN_RESULT emscripten_get_canvas_element_size(const char *target, int *width, int *height);
Expand Down

0 comments on commit 44a16c5

Please sign in to comment.