summaryrefslogtreecommitdiffstats
path: root/wgpu/src/buffer.rs
diff options
context:
space:
mode:
Diffstat (limited to 'wgpu/src/buffer.rs')
-rw-r--r--wgpu/src/buffer.rs14
1 files changed, 12 insertions, 2 deletions
diff --git a/wgpu/src/buffer.rs b/wgpu/src/buffer.rs
index ef00c58f..f8828d46 100644
--- a/wgpu/src/buffer.rs
+++ b/wgpu/src/buffer.rs
@@ -61,12 +61,22 @@ impl<T: bytemuck::Pod> Buffer<T> {
/// Returns the size of the written bytes.
pub fn write(
&mut self,
- queue: &wgpu::Queue,
+ device: &wgpu::Device,
+ encoder: &mut wgpu::CommandEncoder,
+ belt: &mut wgpu::util::StagingBelt,
offset: usize,
contents: &[T],
) -> usize {
let bytes: &[u8] = bytemuck::cast_slice(contents);
- queue.write_buffer(&self.raw, offset as u64, bytes);
+
+ belt.write_buffer(
+ encoder,
+ &self.raw,
+ offset as u64,
+ (bytes.len() as u64).try_into().expect("Non-empty write"),
+ device,
+ )
+ .copy_from_slice(bytes);
self.offsets.push(offset as u64);