-
Hi, I want to copy a texture to a buffer. The texture I use doesn't respect the COPY_BYTES_PER_ROW_ALIGNMENT. let mut encoder = self
.device
.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: None });
encoder.copy_texture_to_buffer(
wgpu::ImageCopyTexture {
aspect: wgpu::TextureAspect::All,
texture: &self.texture,
mip_level: 0,
origin: wgpu::Origin3d::ZERO,
},
wgpu::ImageCopyBuffer {
buffer: &self.output_buffer,
layout: wgpu::ImageDataLayout {
offset: 0,
bytes_per_row: Some(NonZeroU32::new(U32_SIZE * self.texture_size.0).unwrap()),
rows_per_image: Some(NonZeroU32::new(self.texture_size.1).unwrap()),
},
},
self.texture_desc.size,
);
self.queue.submit(Some(encoder.finish())); How can I copy a texture with an arbitrary size to a buffer? |
Beta Was this translation helpful? Give feedback.
Answered by
kvark
Apr 23, 2022
Replies: 1 comment
-
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
COPY_BYTES_PER_ROW_ALIGNMENT
is not for a texture, it's for the buffer. You have to adjustbytes_per_row
accordingly when placing this copy into a buffer.