Skip to content

Commit

Permalink
when create tex with data, add copy_dst flag
Browse files Browse the repository at this point in the history
  • Loading branch information
lyricwulf committed Nov 28, 2021
1 parent 8058dfd commit 80467f4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 0 additions & 1 deletion examples/wgpu-cube.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ fn main() -> Result<(), BoxError> {
.new_texture("Texture")
.with_format(TextureFormat::R8Uint)
.allow_binding()
.allow_copy_to()
.create(&texels, &[size, size]);

// Create other resources
Expand Down
4 changes: 4 additions & 0 deletions src/graphics/texture/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ impl TextureBuilder<'_> {
}
}

/// Create the buffer with the given data as its contents.
/// 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.
pub fn create<T>(mut self, data: &[T], size: &[u32]) -> crate::Texture
where
T: bytemuck::Pod,
Expand All @@ -38,6 +41,7 @@ impl TextureBuilder<'_> {
)
};

self.texture.usage |= wgpu::TextureUsages::COPY_DST;
self.texture.size = wgpu::Extent3d {
width,
height,
Expand Down

0 comments on commit 80467f4

Please sign in to comment.