From cd8b547bcc20cfbd0b958bb48b63771a8ecc9a51 Mon Sep 17 00:00:00 2001 From: UpsettingBoy Date: Sun, 14 Nov 2021 13:32:03 +0100 Subject: [PATCH 1/3] Renamed clear_buffer to fill_buffer (keeping up with spec) * fill_buffer does not require CLEAR_BUFFER feature --- wgpu-core/src/command/clear.rs | 10 +++------- wgpu/src/backend/direct.rs | 6 +++--- wgpu/src/lib.rs | 7 +++---- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/wgpu-core/src/command/clear.rs b/wgpu-core/src/command/clear.rs index 845122f492..5974997b66 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(); @@ -90,10 +90,6 @@ impl Global { list.push(TraceCommand::ClearBuffer { dst, offset, size }); } - if !cmd_buf.support_clear_buffer_texture { - return Err(ClearError::MissingClearCommandsFeature); - } - let (dst_buffer, dst_pending) = cmd_buf .trackers .buffers @@ -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/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/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, From 63d4bbfab946b032440069c3b09888e369b07e50 Mon Sep 17 00:00:00 2001 From: UpsettingBoy Date: Sun, 14 Nov 2021 13:49:36 +0100 Subject: [PATCH 2/3] Changed ClearBuffer to FillBuffer for `trace` feature --- player/src/lib.rs | 4 ++-- wgpu-core/src/command/clear.rs | 2 +- wgpu-core/src/device/trace.rs | 2 +- 3 files changed, 4 insertions(+), 4 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 5974997b66..876163f565 100644 --- a/wgpu-core/src/command/clear.rs +++ b/wgpu-core/src/command/clear.rs @@ -87,7 +87,7 @@ impl Global { #[cfg(feature = "trace")] if let Some(ref mut list) = cmd_buf.commands { - list.push(TraceCommand::ClearBuffer { dst, offset, size }); + list.push(TraceCommand::FillBuffer { dst, offset, size }); } let (dst_buffer, dst_pending) = cmd_buf 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, From a775e89f3485be927487dd964e47d8e4b37397e7 Mon Sep 17 00:00:00 2001 From: UpsettingBoy Date: Sun, 14 Nov 2021 13:53:37 +0100 Subject: [PATCH 3/3] Renamed clearBuffer for web backend --- wgpu/src/backend/web.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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,