Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions wgpu-core/src/command/clear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ pub(super) fn clear_buffer(
});
}

// This must happen after parameter validation (so that errors are reported
// as required by the spec), but before any side effects.
if offset == end_offset {
log::trace!("Ignoring fill_buffer of size 0");
return Ok(());
Expand Down
18 changes: 12 additions & 6 deletions wgpu-core/src/command/transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,8 @@ pub(super) fn copy_buffer_to_buffer(
.into());
}

// This must happen after parameter validation (so that errors are reported
// as required by the spec), but before any side effects.
if size == 0 {
log::trace!("Ignoring copy_buffer_to_buffer of size 0");
return Ok(());
Expand Down Expand Up @@ -1255,6 +1257,8 @@ pub(super) fn copy_texture_to_buffer(
.check_usage(BufferUsages::COPY_DST)
.map_err(TransferError::MissingBufferUsage)?;

// This must happen after parameter validation (so that errors are reported
// as required by the spec), but before any side effects.
if copy_size.width == 0 || copy_size.height == 0 || copy_size.depth_or_array_layers == 0 {
log::trace!("Ignoring copy_texture_to_buffer of size 0");
return Ok(());
Expand Down Expand Up @@ -1376,12 +1380,6 @@ pub(super) fn copy_texture_to_texture(
.into());
}

// Handle texture init *before* dealing with barrier transitions so we
// have an easier time inserting "immediate-inits" that may be required
// by prior discards in rare cases.
handle_src_texture_init(state, source, copy_size, src_texture)?;
handle_dst_texture_init(state, destination, copy_size, dst_texture)?;

let src_raw = src_texture.try_raw(state.snatch_guard)?;
src_texture
.check_usage(TextureUsages::COPY_SRC)
Expand All @@ -1391,11 +1389,19 @@ pub(super) fn copy_texture_to_texture(
.check_usage(TextureUsages::COPY_DST)
.map_err(TransferError::MissingTextureUsage)?;

// This must happen after parameter validation (so that errors are reported
// as required by the spec), but before any side effects.
if copy_size.width == 0 || copy_size.height == 0 || copy_size.depth_or_array_layers == 0 {
log::trace!("Ignoring copy_texture_to_texture of size 0");
return Ok(());
}

// Handle texture init *before* dealing with barrier transitions so we
// have an easier time inserting "immediate-inits" that may be required
// by prior discards in rare cases.
handle_src_texture_init(state, source, copy_size, src_texture)?;
handle_dst_texture_init(state, destination, copy_size, dst_texture)?;

let src_pending =
state
.tracker
Expand Down
16 changes: 11 additions & 5 deletions wgpu-core/src/device/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,8 @@ impl Queue {
let data_size = if let Some(data_size) = wgt::BufferSize::new(data_size) {
data_size
} else {
// This must happen after parameter validation (so that errors are reported
// as required by the spec), but before any side effects.
log::trace!("Ignoring write_buffer of size 0");
return Ok(());
};
Expand Down Expand Up @@ -791,6 +793,8 @@ impl Queue {

let dst_raw = dst.try_raw(&snatch_guard)?;

// This must happen after parameter validation (so that errors are reported
// as required by the spec), but before any side effects.
if size.width == 0 || size.height == 0 || size.depth_or_array_layers == 0 {
log::trace!("Ignoring write_texture of size 0");
return Ok(());
Expand Down Expand Up @@ -963,11 +967,6 @@ impl Queue {

self.device.check_is_valid()?;

if size.width == 0 || size.height == 0 || size.depth_or_array_layers == 0 {
log::trace!("Ignoring write_texture of size 0");
return Ok(());
}

let mut needs_flag = false;
needs_flag |= matches!(source.source, wgt::ExternalImageSource::OffscreenCanvas(_));
needs_flag |= source.origin != wgt::Origin2d::ZERO;
Expand Down Expand Up @@ -1051,6 +1050,13 @@ impl Queue {

let (selector, dst_base) = extract_texture_selector(&destination, &size, &dst)?;

// This must happen after parameter validation (so that errors are reported
// as required by the spec), but before any side effects.
if size.width == 0 || size.height == 0 || size.depth_or_array_layers == 0 {
log::trace!("Ignoring copy_external_image_to_texture of size 0");
return Ok(());
}

let mut pending_writes = self.pending_writes.lock();
let encoder = pending_writes.activate();

Expand Down
Loading