Skip to content

Custom Backend: No api to get custom buffer during create_bind_group. #7533

@raphaelhetzel

Description

@raphaelhetzel

Hi, I'm trying to build a custom WGPU backend based on the example: https://github.com/gfx-rs/wgpu/blob/trunk/examples/standalone/custom_backend/src/custom.rs. The backend aims to support WASM outside a browser and is backed by a instance of wgpu running on the host.
What I'm essentially doing is mapping all things to objects held externally and just storing an unique id inside WASM, e.g., a buffer is represented as a u64 inside WASM, which maps to a core buffer outside of the VM.
That custom Implementation lives in my own crate (no fork of wgpu, just depending on wgpu).

However, there apears to be no way to get to my custom buffer (and therefore the id needed for serialization) during create_bind_group(&self, desc: &wgpu::BindGroupDescriptor<'_>) -> wgpu::custom::DispatchBindGroup in the DeviceInterface. The crate-internal implementations rely on https://github.com/gfx-rs/wgpu/blob/trunk/wgpu/src/api/buffer.rs#L178, followed by e.g. https://github.com/gfx-rs/wgpu/blob/trunk/wgpu/src/dispatch.rs#L581, but that is crate-only public. There appears to be https://github.com/gfx-rs/wgpu/blob/trunk/wgpu/src/dispatch.rs#L600, but I can't get to that as the inner buffer is crate-public.

Is there any way to do this using the existing public API or should the inner buffer be fully public to support this?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions