Skip to content
Discussion options

You must be logged in to vote

Apologies we haven't really documented this! Emdawnwebgpu has - for all objects, but with Texture as an example:

  • WebGPU.importJsTexture(obj) takes a JS object, puts it in the Wasm object table, and returns its ID which you need to cast to WGPUTexture. (Imports it with a C refcount of 1 and, once we implement auto-destroy, imported objects probably won't be auto-destroyed.) Then if you want that in C++, use wgpu::Texture::Acquire(WGPUTexture).
  • WebGPU.getJsObject(id) for getting the JS object from a Wasm WGPUTexture ID. (Doesn't affect the C refcount.)

These are both called from JS - you no longer need to explicitly call any C API to export something before getting it from JS.

We haven't …

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@Schlabbermampf
Comment options

Answer selected by kainino0x
Comment options

You must be logged in to vote
1 reply
@Schlabbermampf
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants