From 052cb3da39346b6a38dd3f662349fb5cc4b87b65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jer=C3=B3nimo=20S=C3=A1nchez?= Date: Mon, 15 Nov 2021 00:16:10 +0000 Subject: [PATCH] Renaming CommandEncoder::clearBuffer to CommandEncoder::fillBuffer (#2174) * Renamed clear_buffer to fill_buffer (keeping up with spec) * fill_buffer does not require CLEAR_BUFFER feature * Changed ClearBuffer to FillBuffer for `trace` feature * Renamed clearBuffer for web backend --- player/src/lib.rs | 4 ++-- wgpu-core/src/command/clear.rs | 12 ++++-------- wgpu-core/src/device/trace.rs | 2 +- wgpu/src/backend/direct.rs | 6 +++--- wgpu/src/backend/web.rs | 2 +- wgpu/src/lib.rs | 7 +++---- 6 files changed, 14 insertions(+), 19 deletions(-) diff --git a/player/src/lib.rs b/player/src/lib.rs index 597cf11dde..3ad4605d7e 100644 --- a/player/src/lib.rs +++ b/player/src/lib.rs @@ -77,8 +77,8 @@ impl GlobalPlay for wgc::hub::Global { trace::Command::CopyTextureToTexture { src, dst, size } => self .command_encoder_copy_texture_to_texture::(encoder, &src, &dst, &size) .unwrap(), - trace::Command::ClearBuffer { dst, offset, size } => self - .command_encoder_clear_buffer::(encoder, dst, offset, size) + trace::Command::FillBuffer { dst, offset, size } => self + .command_encoder_fill_buffer::(encoder, dst, offset, size) .unwrap(), trace::Command::ClearTexture { dst, diff --git a/wgpu-core/src/command/clear.rs b/wgpu-core/src/command/clear.rs index 845122f492..876163f565 100644 --- a/wgpu-core/src/command/clear.rs +++ b/wgpu-core/src/command/clear.rs @@ -69,14 +69,14 @@ whereas subesource range specified start {subresource_base_array_layer} and coun } impl Global { - pub fn command_encoder_clear_buffer( + pub fn command_encoder_fill_buffer( &self, command_encoder_id: CommandEncoderId, dst: BufferId, offset: BufferAddress, size: Option, ) -> Result<(), ClearError> { - profiling::scope!("CommandEncoder::clear_buffer"); + profiling::scope!("CommandEncoder::fill_buffer"); let hub = A::hub(self); let mut token = Token::root(); @@ -87,11 +87,7 @@ impl Global { #[cfg(feature = "trace")] if let Some(ref mut list) = cmd_buf.commands { - list.push(TraceCommand::ClearBuffer { dst, offset, size }); - } - - if !cmd_buf.support_clear_buffer_texture { - return Err(ClearError::MissingClearCommandsFeature); + list.push(TraceCommand::FillBuffer { dst, offset, size }); } let (dst_buffer, dst_pending) = cmd_buf @@ -130,7 +126,7 @@ impl Global { None => dst_buffer.size, }; if offset == end { - log::trace!("Ignoring clear_buffer of size 0"); + log::trace!("Ignoring fill_buffer of size 0"); return Ok(()); } diff --git a/wgpu-core/src/device/trace.rs b/wgpu-core/src/device/trace.rs index b97323bd23..21f5ebc595 100644 --- a/wgpu-core/src/device/trace.rs +++ b/wgpu-core/src/device/trace.rs @@ -147,7 +147,7 @@ pub enum Command { dst: crate::command::ImageCopyTexture, size: wgt::Extent3d, }, - ClearBuffer { + FillBuffer { dst: id::BufferId, offset: wgt::BufferAddress, size: Option, diff --git a/wgpu/src/backend/direct.rs b/wgpu/src/backend/direct.rs index 609992d237..fa3e24c254 100644 --- a/wgpu/src/backend/direct.rs +++ b/wgpu/src/backend/direct.rs @@ -2008,7 +2008,7 @@ impl crate::Context for Context { } } - fn command_encoder_clear_buffer( + fn command_encoder_fill_buffer( &self, encoder: &Self::CommandEncoderId, buffer: &crate::Buffer, @@ -2016,12 +2016,12 @@ impl crate::Context for Context { size: Option, ) { let global = &self.0; - if let Err(cause) = wgc::gfx_select!(encoder.id => global.command_encoder_clear_buffer( + if let Err(cause) = wgc::gfx_select!(encoder.id => global.command_encoder_fill_buffer( encoder.id, buffer.id.id, offset, size )) { - self.handle_error_nolabel(&encoder.error_sink, cause, "CommandEncoder::clear_buffer"); + self.handle_error_nolabel(&encoder.error_sink, cause, "CommandEncoder::fill_buffer"); } } diff --git a/wgpu/src/backend/web.rs b/wgpu/src/backend/web.rs index 744c124c34..42cbb73556 100644 --- a/wgpu/src/backend/web.rs +++ b/wgpu/src/backend/web.rs @@ -1990,7 +1990,7 @@ impl crate::Context for Context { ) { } - fn command_encoder_clear_buffer( + fn command_encoder_fill_buffer( &self, _encoder: &Self::CommandEncoderId, _buffer: &crate::Buffer, diff --git a/wgpu/src/lib.rs b/wgpu/src/lib.rs index f80ba29145..6bb078bc01 100644 --- a/wgpu/src/lib.rs +++ b/wgpu/src/lib.rs @@ -424,7 +424,7 @@ trait Context: Debug + Send + Sized + Sync { texture: &Texture, subresource_range: &ImageSubresourceRange, ); - fn command_encoder_clear_buffer( + fn command_encoder_fill_buffer( &self, encoder: &Self::CommandEncoderId, buffer: &Buffer, @@ -2357,16 +2357,15 @@ impl CommandEncoder { /// /// # Panics /// - /// - `CLEAR_COMMANDS` extension not enabled /// - Buffer does not have `COPY_DST` usage. /// - Range it out of bounds - pub fn clear_buffer( + pub fn fill_buffer( &mut self, buffer: &Buffer, offset: BufferAddress, size: Option, ) { - Context::command_encoder_clear_buffer( + Context::command_encoder_fill_buffer( &*self.context, self.id.as_ref().unwrap(), buffer,