Provide physical dimensions to wgpu Device::create_texture_with_data (#19129)

# Objective

- Make errors in #19124 #13289 clearer, and opt for option 1. of
https://github.com/gfx-rs/wgpu/issues/7677

## Solution

Remove the round to block size `.physical_size(texture_format);`

Error message now becomes much clearer:
```
thread 'Compute Task Pool (5)' panicked at E:\r\wgpu\wgpu\src\backend\wgpu_core.rs:1423:26:
wgpu error: Validation Error

Caused by:
  In Device::create_texture
    Width 2050 is not a multiple of Bc7RgbaUnormSrgb's block width (4)
```

## Testing

- Tested using the repro in #19124
This commit is contained in:
atlv 2025-05-26 13:36:47 -04:00 committed by GitHub
parent 6341ae4158
commit 7bb97a7eec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -267,6 +267,9 @@ pub fn ktx2_buffer_to_image(
let mut image = Image::default();
image.texture_descriptor.format = texture_format;
image.data = Some(wgpu_data.into_iter().flatten().collect::<Vec<_>>());
// Note: we must give wgpu the logical texture dimensions, so it can correctly compute mip sizes.
// However this currently causes wgpu to panic if the dimensions arent a multiple of blocksize.
// See https://github.com/gfx-rs/wgpu/issues/7677 for more context.
image.texture_descriptor.size = Extent3d {
width,
height,
@ -276,8 +279,7 @@ pub fn ktx2_buffer_to_image(
depth
}
.max(1),
}
.physical_size(texture_format);
};
image.texture_descriptor.mip_level_count = level_count;
image.texture_descriptor.dimension = if depth > 1 {
TextureDimension::D3