mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
Implicitly add COPY_DST when using create_texture_with_data (#1622)
* Implicitly add `COPY_DST` when using `create_texture_with_data` * Always clone texture descriptor
This commit is contained in:
@@ -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,
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user