-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ExternalTexture in WASM #232
Comments
Hi. Any delivery time estimation for this feature? Need it badly to communicate with WebCodecs's VideoFrame from wasm, |
Unfortunately I don't have an estimate right now. If you are interested in proposing something I would be happy to take an experimental API in Emscripten. Alternatively, you can use JavaScript / EM_ASM to do what you need in JS. Take a look at JsValStore to get objects between JS and WASM: https://github.com/emscripten-core/emscripten/blob/main/test/webgpu_jsvalstore.cpp |
April 25th meeting:
|
Here is what that would look like: +/**
+ * There is no standard way to create a WGPUExternalTexture.
+ * Use an extension method provided by the implementation you are targeting.
+ */
+typedef struct WGPUExternalTextureImpl* WGPUExternalTexture WGPU_OBJECT_ATTRIBUTE;
+typedef struct WGPUExternalTextureBindingLayout {
+ WGPUChainedStruct const * nextInChain;
+} WGPUExternalTextureBindingLayout WGPU_STRUCTURE_ATTRIBUTE;
typedef struct WGPUBindGroupLayoutEntry {
WGPUChainedStruct const * nextInChain;
uint32_t binding;
WGPUShaderStageFlags visibility;
WGPUBufferBindingLayout buffer;
WGPUSamplerBindingLayout sampler;
WGPUTextureBindingLayout texture;
WGPUStorageTextureBindingLayout storageTexture;
+ // TODO: Open question of how you can tell that this one is selected.
+ // Make it a pointer? Add a boolean to it?
+ WGPUExternalTextureBindingLayout externalTexture;
} WGPUBindGroupLayoutEntry WGPU_STRUCTURE_ATTRIBUTE;
typedef struct WGPUBindGroupEntry {
WGPUChainedStruct const * nextInChain;
uint32_t binding;
WGPU_NULLABLE WGPUBuffer buffer;
uint64_t offset;
uint64_t size;
WGPU_NULLABLE WGPUSampler sampler;
WGPU_NULLABLE WGPUTextureView textureView;
+ WGPU_NULLABLE WGPUExternalTexture externalTexture;
} WGPUBindGroupEntry WGPU_STRUCTURE_ATTRIBUTE; |
IMHO the external texture is niche enough that we can use an extension struct on the binding layout. If it is present, then the entry is for an external texture. |
That's true, it would solve that open question (which we hadn't realized yet during the meeting). Would this be the first time the presence of an extension struct does something on its own, with all of its contents set to the defaults? I can imagine that some bindings might want to do things like, allocate all of the known extension structs and wire up the full chain, regardless of whether they're used...? (Though this is kind of inefficient. Also it would not actually work well though, because I think we said we are generating an error for any chained struct associated with a feature that's not enabled? Or was that only for out-structs?) |
All structs I believe. We could also pass WGPUExternalTextureBindingLayout by pointer? It's effectively the same as the chained struct, but looks more like an optional value. I do think it's slightly odd to use the chained struct for something that is not actually an extension/feature. If the concept of WGPUExternalTexture exists in the core API (even if there is no way to actually create it in core), it would be better IMO if the layout could be passed without an extension struct. Alternatively, if we think that there is no actual way to specify the layout without extension chains, we could also make it so the only thing that exists is: |
May 9 meeting:
|
WASM-specific part of #188.
We need a way to expose the JS GPUExternalTexture API.
I think most likely this will share code with its native equivalent #192 (cc @Kangz): use the same WGPUExternalTexture type, same bind group/bind group layout parts, but different WGPUExternalTextureDescriptors. If so it'll be easiest to do this one first, and the native one later.
I think this will all be via chained structs making it non-breaking / post-v1, but it's also needed for completeness of the API in WASM, so I'm going to not add the
non-breaking
label. Also just in case any core changes are needed.The text was updated successfully, but these errors were encountered: