Skip to content

Commit

Permalink
copyTextureToTexture src/dst aspects must both refer to all aspects…
Browse files Browse the repository at this point in the history
… of src/dst format (#3431)

* src/dst aspects must both refer to all aspects of src/dst format

* add changelog entry
  • Loading branch information
teoxoy authored Jan 28, 2023
1 parent b31069f commit 98ea350
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ Bottom level categories:

- Improve format MSAA capabilities detection. By @jinleili in [#3429](https://github.com/gfx-rs/wgpu/pull/3429)

### Bug Fixes

#### General

- `copyTextureToTexture` src/dst aspects must both refer to all aspects of src/dst format. By @teoxoy in [#3431](https://github.com/gfx-rs/wgpu/pull/3431)

## wgpu-0.15.0 (2023-01-25)

### Major Changes
Expand Down Expand Up @@ -156,7 +162,7 @@ You can choose which compiler to use at `Instance` creation using the `dx12_shad

#### Suballocate DX12 buffers and textures

The DX12 backend can now suballocate buffers and textures from larger chunks of memory, which can give a significant increase in performance (in testing a 100x improvement has been seen in a simple scene with 200 `write_buffer` calls per frame, and a 1.4x improvement in [Bistro using Bevy](https://github.com/vleue/bevy_bistro_playground)).
The DX12 backend can now suballocate buffers and textures from larger chunks of memory, which can give a significant increase in performance (in testing a 100x improvement has been seen in a simple scene with 200 `write_buffer` calls per frame, and a 1.4x improvement in [Bistro using Bevy](https://github.com/vleue/bevy_bistro_playground)).

Previously `wgpu-hal`'s DX12 backend created a new heap on the GPU every time you called `write_buffer` (by calling `CreateCommittedResource`), whereas now it uses [`gpu_allocator`](https://crates.io/crates/gpu-allocator) to manage GPU memory (and calls `CreatePlacedResource` with a suballocated heap). By @Elabajaba in [#3163](https://github.com/gfx-rs/wgpu/pull/3163)

Expand Down
17 changes: 13 additions & 4 deletions wgpu-core/src/command/transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,12 @@ pub enum TransferError {
InvalidCopySize,
#[error("number of rows per image is invalid")]
InvalidRowsPerImage,
#[error("source and destination layers have different aspects")]
MismatchedAspects,
#[error("copy source aspects must refer to all aspects of the source texture format")]
CopySrcMissingAspects,
#[error(
"copy destination aspects must refer to all aspects of the destination texture format"
)]
CopyDstMissingAspects,
#[error("copying from textures with format {format:?} and aspect {aspect:?} is forbidden")]
CopyFromForbiddenTextureFormat {
format: wgt::TextureFormat,
Expand Down Expand Up @@ -1053,8 +1057,13 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
extract_texture_selector(source, copy_size, src_texture)?;
let (dst_range, dst_tex_base, _) =
extract_texture_selector(destination, copy_size, dst_texture)?;
if src_tex_base.aspect != dst_tex_base.aspect {
return Err(TransferError::MismatchedAspects.into());
let src_texture_aspects = hal::FormatAspects::from(src_texture.desc.format);
let dst_texture_aspects = hal::FormatAspects::from(dst_texture.desc.format);
if src_tex_base.aspect != src_texture_aspects {
return Err(TransferError::CopySrcMissingAspects.into());
}
if dst_tex_base.aspect != dst_texture_aspects {
return Err(TransferError::CopyDstMissingAspects.into());
}

// Handle texture init *before* dealing with barrier transitions so we
Expand Down

0 comments on commit 98ea350

Please sign in to comment.