Skip to content

Commit 2d8fcb2

Browse files
committed
Restore allowance of unaligned buffer-texture copies
This fixes a regression introduced by gfx-rs#7948. However, it makes it possible to reach a panic in initialize_buffer_memory if the copy requires initializing a region of memory that is not 4B aligned.
1 parent 5089063 commit 2d8fcb2

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

cts_runner/test.lst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
unittests:*
22
webgpu:api,operation,command_buffer,basic:*
33
webgpu:api,operation,command_buffer,copyBufferToBuffer:*
4+
webgpu:api,operation,command_buffer,image_copy:offsets_and_sizes:*
45
webgpu:api,operation,compute,basic:memcpy:*
56
//FAIL: webgpu:api,operation,compute,basic:large_dispatch:*
67
webgpu:api,operation,compute_pipeline,overrides:*
@@ -63,6 +64,7 @@ fails-if(dx12) webgpu:api,validation,image_copy,buffer_texture_copies:offset_and
6364
//mix of PASS and FAIL: other subtests of offset_and_bytesPerRow. Related bugs:
6465
// https://github.com/gfx-rs/wgpu/issues/7946, https://github.com/gfx-rs/wgpu/issues/7947
6566
webgpu:api,validation,image_copy,layout_related:copy_end_overflows_u64:*
67+
webgpu:api,validation,image_copy,layout_related:offset_alignment:*
6668
webgpu:api,validation,image_copy,texture_related:format:dimension="1d";*
6769
webgpu:api,validation,queue,submit:command_buffer,device_mismatch:*
6870
webgpu:api,validation,queue,submit:command_buffer,duplicate_buffers:*
@@ -92,6 +94,7 @@ webgpu:api,validation,encoding,queries,general:occlusion_query,query_type:*
9294
webgpu:shader,execution,expression,call,builtin,textureSample:sampled_1d_coords:*
9395
webgpu:shader,execution,expression,call,builtin,textureSampleBaseClampToEdge:2d_coords:stage="c";textureType="texture_2d<f32>";*
9496
webgpu:shader,execution,flow_control,return:*
97+
webgpu:shader,execution,robust_access_vertex:vertex_buffer_access:*
9598
webgpu:shader,validation,expression,call,builtin,max:values:*
9699
webgpu:shader,validation,statement,statement_behavior:invalid_statements:body="break"
97100
webgpu:shader,validation,statement,statement_behavior:invalid_statements:body="break_if"

wgpu-core/src/command/transfer.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ pub(crate) fn validate_texture_buffer_copy<T>(
399399
return Err(TransferError::CopyAspectNotOne);
400400
}
401401

402-
let mut offset_alignment = if desc.format.is_depth_stencil_format() {
402+
let offset_alignment = if desc.format.is_depth_stencil_format() {
403403
4
404404
} else {
405405
// The case where `block_copy_size` returns `None` is currently
@@ -411,17 +411,7 @@ pub(crate) fn validate_texture_buffer_copy<T>(
411411
.expect("non-copyable formats should have been rejected previously")
412412
};
413413

414-
// TODO(https://github.com/gfx-rs/wgpu/issues/7947): This does not match the spec.
415-
// The spec imposes no alignment requirement if `!aligned`, and otherwise
416-
// imposes only the `offset_alignment` as calculated above. wgpu currently
417-
// can panic on alignments <4B, so we reject them here to avoid a panic.
418-
if aligned {
419-
offset_alignment = offset_alignment.max(4);
420-
} else {
421-
offset_alignment = 4;
422-
}
423-
424-
if offset % u64::from(offset_alignment) != 0 {
414+
if aligned && offset % u64::from(offset_alignment) != 0 {
425415
return Err(TransferError::UnalignedBufferOffset(offset));
426416
}
427417

0 commit comments

Comments
 (0)