Skip to content

Commit 1ddb5f2

Browse files
Fix early out placement for CopyB2T (#8690)
1 parent ab8f9ad commit 1ddb5f2

File tree

2 files changed

+35
-32
lines changed

2 files changed

+35
-32
lines changed

cts_runner/test.lst

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,9 @@ webgpu:api,validation,encoding,programmable,pipeline_bind_group_compat:buffer_bi
8585
webgpu:api,validation,encoding,programmable,pipeline_bind_group_compat:sampler_binding,render_pipeline:*
8686
webgpu:api,validation,encoding,queries,general:occlusion_query,query_index:*
8787
webgpu:shader,validation,extension,dual_source_blending:blend_src_syntax_validation:*
88+
webgpu:api,validation,image_copy,buffer_related:*
8889
webgpu:api,validation,image_copy,buffer_texture_copies:depth_stencil_format,copy_usage_and_aspect:*
8990
webgpu:api,validation,image_copy,buffer_texture_copies:depth_stencil_format,copy_buffer_size:*
90-
// `vulkan` failure: https://github.com/gfx-rs/wgpu/issues/????
91-
fails-if(vulkan) webgpu:api,validation,queue,buffer_mapped:writeBuffer:*
92-
webgpu:api,validation,queue,buffer_mapped:copyBufferToBuffer:*
93-
webgpu:api,validation,queue,buffer_mapped:copyBufferToTexture:*
94-
webgpu:api,validation,queue,buffer_mapped:copyTextureToBuffer:*
95-
webgpu:api,validation,queue,buffer_mapped:map_command_recording_order:*
9691
// image_copy depth/stencil failures on dx12: https://github.com/gfx-rs/wgpu/issues/8133
9792
fails-if(dx12) webgpu:api,validation,image_copy,buffer_texture_copies:depth_stencil_format,copy_buffer_offset:format="stencil8";aspect="stencil-only";copyType="CopyB2T"
9893
fails-if(dx12) webgpu:api,validation,image_copy,buffer_texture_copies:depth_stencil_format,copy_buffer_offset:format="stencil8";aspect="stencil-only";copyType="CopyT2B"
@@ -124,6 +119,12 @@ webgpu:api,validation,image_copy,layout_related:copy_end_overflows_u64:*
124119
// Fails with OOM in CI.
125120
fails-if(dx12) webgpu:api,validation,image_copy,layout_related:offset_alignment:*
126121
webgpu:api,validation,image_copy,texture_related:format:dimension="1d";*
122+
// `vulkan` failure: https://github.com/gfx-rs/wgpu/issues/????
123+
fails-if(vulkan) webgpu:api,validation,queue,buffer_mapped:writeBuffer:*
124+
webgpu:api,validation,queue,buffer_mapped:copyBufferToBuffer:*
125+
webgpu:api,validation,queue,buffer_mapped:copyBufferToTexture:*
126+
webgpu:api,validation,queue,buffer_mapped:copyTextureToBuffer:*
127+
webgpu:api,validation,queue,buffer_mapped:map_command_recording_order:*
127128
webgpu:api,validation,queue,submit:command_buffer,*
128129
webgpu:api,validation,render_pass,render_pass_descriptor:attachments,*
129130
webgpu:api,validation,render_pass,render_pass_descriptor:color_attachments,depthSlice,*

wgpu-core/src/command/transfer.rs

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,39 +1101,14 @@ pub(super) fn copy_buffer_to_texture(
11011101
let (dst_range, dst_base) = extract_texture_selector(destination, copy_size, dst_texture)?;
11021102

11031103
let src_raw = src_buffer.try_raw(state.snatch_guard)?;
1104-
let dst_raw = dst_texture.try_raw(state.snatch_guard)?;
1105-
1106-
if copy_size.width == 0 || copy_size.height == 0 || copy_size.depth_or_array_layers == 0 {
1107-
log::trace!("Ignoring copy_buffer_to_texture of size 0");
1108-
return Ok(());
1109-
}
1110-
1111-
// Handle texture init *before* dealing with barrier transitions so we
1112-
// have an easier time inserting "immediate-inits" that may be required
1113-
// by prior discards in rare cases.
1114-
handle_dst_texture_init(state, destination, copy_size, dst_texture)?;
1115-
1116-
let src_pending = state
1117-
.tracker
1118-
.buffers
1119-
.set_single(src_buffer, wgt::BufferUses::COPY_SRC);
1120-
11211104
src_buffer
11221105
.check_usage(BufferUsages::COPY_SRC)
11231106
.map_err(TransferError::MissingBufferUsage)?;
1124-
let src_barrier = src_pending.map(|pending| pending.into_hal(src_buffer, state.snatch_guard));
11251107

1126-
let dst_pending =
1127-
state
1128-
.tracker
1129-
.textures
1130-
.set_single(dst_texture, dst_range, wgt::TextureUses::COPY_DST);
1108+
let dst_raw = dst_texture.try_raw(state.snatch_guard)?;
11311109
dst_texture
11321110
.check_usage(TextureUsages::COPY_DST)
11331111
.map_err(TransferError::MissingTextureUsage)?;
1134-
let dst_barrier = dst_pending
1135-
.map(|pending| pending.into_hal(dst_raw))
1136-
.collect::<Vec<_>>();
11371112

11381113
validate_texture_copy_dst_format(dst_texture.desc.format, destination.aspect)?;
11391114

@@ -1162,6 +1137,33 @@ pub(super) fn copy_buffer_to_texture(
11621137
.map_err(TransferError::from)?;
11631138
}
11641139

1140+
// This must happen after parameter validation (so that errors are reported
1141+
// as required by the spec), but before any side effects.
1142+
if copy_size.width == 0 || copy_size.height == 0 || copy_size.depth_or_array_layers == 0 {
1143+
log::trace!("Ignoring copy_buffer_to_texture of size 0");
1144+
return Ok(());
1145+
}
1146+
1147+
// Handle texture init *before* dealing with barrier transitions so we
1148+
// have an easier time inserting "immediate-inits" that may be required
1149+
// by prior discards in rare cases.
1150+
handle_dst_texture_init(state, destination, copy_size, dst_texture)?;
1151+
1152+
let src_pending = state
1153+
.tracker
1154+
.buffers
1155+
.set_single(src_buffer, wgt::BufferUses::COPY_SRC);
1156+
let src_barrier = src_pending.map(|pending| pending.into_hal(src_buffer, state.snatch_guard));
1157+
1158+
let dst_pending =
1159+
state
1160+
.tracker
1161+
.textures
1162+
.set_single(dst_texture, dst_range, wgt::TextureUses::COPY_DST);
1163+
let dst_barrier = dst_pending
1164+
.map(|pending| pending.into_hal(dst_raw))
1165+
.collect::<Vec<_>>();
1166+
11651167
handle_buffer_init(
11661168
state,
11671169
source,

0 commit comments

Comments
 (0)