-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Copying CPU buffer to GPU buffer bug on Linux/Vulkan #2480
Copy link
Copy link
Closed as not planned
Labels
backend: vulkanIssues with VulkanIssues with Vulkanexternal: driver-bugA driver is causing the bug, though we may still want to work around itA driver is causing the bug, though we may still want to work around it
Description
Description
Copying an image buffer from CPU to GPU texture with write_texture gives unexpected result on linux.
Repro steps
- Create texture
let frame_buffer = device.create_texture(&wgpu::TextureDescriptor {
label: None,
size: Extent3d {
width: 100,
height: 100,
depth_or_array_layers: 1,
},
mip_level_count: 1,
sample_count: 1,
dimension: wgpu::TextureDimension::D2,
format: wgpu::TextureFormat::Rgba8Unorm,
usage: wgpu::TextureUsages::TEXTURE_BINDING | wgpu::TextureUsages::COPY_DST,
});- Create CPU buffer and write some data into it
let mut cpu_buffer = vec![0u8;100*100*4];
for i in 0..100{
for i in 0..100{
let index = (i*100+j)*4;
// write some data here
cpu_buffer[index] = i as u8;
cpu_buffer[index+1] = 0;
cpu_buffer[index+2] = 0;
cpu_buffer[index+3] = 255;
}
}- copy data to GPU buffer with
write_texture
queue.write_texture(
frame_buffer.as_image_copy(),
&cpu_buffer,
wgpu::ImageDataLayout {
offset: 0,
bytes_per_row: Some(std::num::NonZeroU32::new(100 * 4).unwrap()),
rows_per_image: None,
},
wgpu::Extent3d {
width: 100,
height: 100,
depth_or_array_layers: 1,
},
);- Render texture to screen
Expected vs observed behavior
Image on linux looks like on macOS.
But image on linux is distorted.
Extra materials
I used only the column number as red value:
I used only the row number as red value:
Platform
Linux (Ubuntu 21.10)
macOS (12.2.1)
wgpu (0.12.0)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
backend: vulkanIssues with VulkanIssues with Vulkanexternal: driver-bugA driver is causing the bug, though we may still want to work around itA driver is causing the bug, though we may still want to work around it



