Context:
-
We are using Rust on wasm32/wgpu.
-
We are uploading a vertex buffer object.
-
We are using:
impl DeviceExt for crate::Device {
fn create_buffer_init(&self, descriptor: &BufferInitDescriptor<'_>) -> crate::Buffer {
pub struct BufferInitDescriptor<'a> {
/// Debug label of a buffer. This will show up in graphics debuggers for easy identification.
pub label: crate::Label<'a>,
/// Contents of a buffer on creation.
pub contents: &'a [u8],
/// Usages of a buffer. If the buffer is used in any way that isn't specified here, the operation
/// will panic.
pub usage: crate::BufferUsages,
}
Notice the contents:
&'a [u8]`
Now, here is the thing. I loaded the data over the network. I already have the data in the format of JsArrayBuffer. Instead of (1) converitng JsArrayBuffer to Vec<u8>
, (2) passing &[u8] to wgpu, and (3) having wgpu convert the &[u8] back to a JsArrayBuffer -- instead of all that bs, can I just pass wgup a JsArrayBuffer intead ?
Thanks!