Skip to content

Commit

Permalink
Implicitly add COPY_DST when using create_texture_with_data (#1622)
Browse files Browse the repository at this point in the history
* Implicitly add `COPY_DST` when using `create_texture_with_data`

* Always clone texture descriptor
  • Loading branch information
HalfVoxel committed Jul 13, 2021
1 parent 226694c commit c434b94
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion wgpu/src/util/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ pub trait DeviceExt {
///
/// Example:
/// Layer0Mip0 Layer0Mip1 Layer0Mip2 ... Layer1Mip0 Layer1Mip1 Layer1Mip2 ...
///
/// Implicitly adds the `COPY_DST` usage if it is not present in the descriptor,
/// as it is required to be able to upload the data to the gpu.
fn create_texture_with_data(
&self,
queue: &crate::Queue,
Expand Down Expand Up @@ -79,7 +82,10 @@ impl DeviceExt for crate::Device {
desc: &crate::TextureDescriptor,
data: &[u8],
) -> crate::Texture {
let texture = self.create_texture(desc);
// Implicitly add the COPY_DST usage
let mut desc = desc.to_owned();
desc.usage |= crate::TextureUsages::COPY_DST;
let texture = self.create_texture(&desc);

let format_info = desc.format.describe();
let layer_iterations = desc.array_layer_count();
Expand Down

0 comments on commit c434b94

Please sign in to comment.