From 959b9bb13e6426331af8cfff9abc017f5413c464 Mon Sep 17 00:00:00 2001 From: Raph Levien Date: Thu, 26 Jan 2023 14:32:34 -0800 Subject: [PATCH] Implement `clear_buffer` on web (#3426) --- CHANGELOG.md | 8 ++++++++ wgpu/src/backend/web.rs | 18 +++++++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1270c935f7..23572c4c69 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,14 @@ Bottom level categories: - Hal --> +## Unreleased + +### Changes + +#### WebGPU + +- Implement `CommandEncoder::clear_buffer`. By @raphlinus in [#3426](https://github.com/gfx-rs/wgpu/pull/3426) + ## wgpu-0.15.0 (2023-01-25) ### Major Changes diff --git a/wgpu/src/backend/web.rs b/wgpu/src/backend/web.rs index b4365449ee..0b79c8b4d3 100644 --- a/wgpu/src/backend/web.rs +++ b/wgpu/src/backend/web.rs @@ -2187,13 +2187,21 @@ impl crate::context::Context for Context { fn command_encoder_clear_buffer( &self, - _encoder: &Self::CommandEncoderId, + encoder: &Self::CommandEncoderId, _encoder_data: &Self::CommandEncoderData, - _buffer: &crate::Buffer, - _offset: wgt::BufferAddress, - _size: Option, + buffer: &crate::Buffer, + offset: wgt::BufferAddress, + size: Option, ) { - //TODO + let buffer_id = &<::BufferId>::from(buffer.id).0; + match size { + Some(size) => { + encoder + .0 + .clear_buffer_with_f64_and_f64(buffer_id, offset as f64, size.get() as f64) + } + None => encoder.0.clear_buffer_with_f64(buffer_id, offset as f64), + } } fn command_encoder_insert_debug_marker(