mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-21 06:50:59 +01:00
[core] Make Global methods thin in clear (#9822)
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
1 file changed
+40
-27
@@ -110,6 +110,44 @@ impl WebGpuError for ClearError {
|
||||
}
|
||||
}
|
||||
|
||||
impl super::CommandEncoder {
|
||||
pub fn clear_buffer(
|
||||
self: &Arc<Self>,
|
||||
dst: Arc<Buffer>,
|
||||
offset: BufferAddress,
|
||||
size: Option<BufferAddress>,
|
||||
) -> Result<(), EncoderStateError> {
|
||||
profiling::scope!("CommandEncoder::clear_buffer");
|
||||
api_log!("CommandEncoder::clear_buffer {:?}", Arc::as_ptr(&dst));
|
||||
|
||||
let mut cmd_buf_data = self.data.lock();
|
||||
|
||||
cmd_buf_data.push_with(|| -> Result<_, ClearError> {
|
||||
dst.check_is_valid()?;
|
||||
Ok(ArcCommand::ClearBuffer { dst, offset, size })
|
||||
})
|
||||
}
|
||||
|
||||
pub fn clear_texture(
|
||||
self: &Arc<Self>,
|
||||
dst: Arc<Texture>,
|
||||
subresource_range: &ImageSubresourceRange,
|
||||
) -> Result<(), EncoderStateError> {
|
||||
profiling::scope!("CommandEncoder::clear_texture");
|
||||
api_log!("CommandEncoder::clear_texture {:?}", Arc::as_ptr(&dst));
|
||||
|
||||
let mut cmd_buf_data = self.data.lock();
|
||||
|
||||
cmd_buf_data.push_with(|| -> Result<_, ClearError> {
|
||||
dst.check_valid()?;
|
||||
Ok(ArcCommand::ClearTexture {
|
||||
dst,
|
||||
subresource_range: *subresource_range,
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl Global {
|
||||
pub fn command_encoder_clear_buffer(
|
||||
&self,
|
||||
@@ -118,23 +156,10 @@ impl Global {
|
||||
offset: BufferAddress,
|
||||
size: Option<BufferAddress>,
|
||||
) -> Result<(), EncoderStateError> {
|
||||
profiling::scope!("CommandEncoder::clear_buffer");
|
||||
api_log!("CommandEncoder::clear_buffer {dst:?}");
|
||||
|
||||
let hub = &self.hub;
|
||||
|
||||
let cmd_enc = hub.command_encoders.get(command_encoder_id);
|
||||
let mut cmd_buf_data = cmd_enc.data.lock();
|
||||
|
||||
cmd_buf_data.push_with(|| -> Result<_, ClearError> {
|
||||
let buffer = self.resolve_buffer_id(dst);
|
||||
buffer.check_is_valid()?;
|
||||
Ok(ArcCommand::ClearBuffer {
|
||||
dst: buffer,
|
||||
offset,
|
||||
size,
|
||||
})
|
||||
})
|
||||
cmd_enc.clear_buffer(hub.buffers.get(dst), offset, size)
|
||||
}
|
||||
|
||||
pub fn command_encoder_clear_texture(
|
||||
@@ -143,23 +168,11 @@ impl Global {
|
||||
dst: TextureId,
|
||||
subresource_range: &ImageSubresourceRange,
|
||||
) -> Result<(), EncoderStateError> {
|
||||
profiling::scope!("CommandEncoder::clear_texture");
|
||||
api_log!("CommandEncoder::clear_texture {dst:?}");
|
||||
|
||||
let hub = &self.hub;
|
||||
|
||||
let cmd_enc = hub.command_encoders.get(command_encoder_id);
|
||||
|
||||
let mut cmd_buf_data = cmd_enc.data.lock();
|
||||
|
||||
cmd_buf_data.push_with(|| -> Result<_, ClearError> {
|
||||
let texture = self.resolve_texture_id(dst);
|
||||
texture.check_valid()?;
|
||||
Ok(ArcCommand::ClearTexture {
|
||||
dst: texture,
|
||||
subresource_range: *subresource_range,
|
||||
})
|
||||
})
|
||||
cmd_enc.clear_texture(hub.textures.get(dst), subresource_range)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user