I am getting some validation errors using the Vulkan backend due to some buffers being destroyed while bound to a command buffer.
I got an API trace (Full log here) and it seems that multiple command buffers are created under the hood for what I'd consider a pretty simple call. It may be that I'm screwing up something without realizing, but if that's the case, it should probably fail some internal validation.
This is the code snippet (I can provide full source if necessary, it's a pretty small project):
let mut encoder = session
.device
.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: None });
{
let mut rpass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
color_attachments: &[wgpu::RenderPassColorAttachmentDescriptor {
attachment: &frame.view,
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color::BLACK),
store: true,
},
}],
depth_stencil_attachment: None,
});
rpass.set_pipeline(&hexagon_renderinfo.render_pipeline);
rpass.set_push_constants(
wgpu::ShaderStage::VERTEX,
0,
bytemuck::bytes_of(&[time]),
);
rpass.push_debug_group("Prepare data for drawcall");
rpass.set_vertex_buffer(0, hexagon_renderinfo.vertex_buffer.slice(..));
rpass.set_vertex_buffer(1, hexagon_renderinfo.texcoord_buffer.slice(..));
rpass.set_vertex_buffer(2, hexagon_renderinfo.tiling_buffer.slice(..));
rpass.set_bind_group(0, &hexagon_renderinfo.uniform_bindgroup, &[]);
rpass.set_bind_group(1, &hexagon_renderinfo.texture_bindgroup, &[]);
rpass.set_index_buffer(hexagon_renderinfo.index_buffer.slice(..));
rpass.pop_debug_group();
rpass.insert_debug_marker("Draw command");
rpass.draw_indexed(
0..hexagon_renderinfo.index_count,
0,
0..hexagon_renderinfo.num_hexagons,
);
rpass.insert_debug_marker("Draw command finished");
}
println!("Getting command buffer");
let cmd_buf = encoder.finish();
println!("Calling queue submit");
session.queue.submit(vec!(cmd_buf));
println!("End of scope");
}
Thank you for filing! Note that wgpu has its own API tracing that is more useful than a Vulkan trace.
You can record one by following https://github.com/gfx-rs/wgpu/wiki/Debugging-wgpu-Applications#tracing-infrastructure, or just provide the full repro case for us.
It would also help if you label the buffers used in the application (by filling XxxDescriptor::label fields) and post the exact validation error, since it should contain the label of the buffer.
Sure, I was unaware of that - my bad, didn't read the whole page carefully enough.
Here you are! All the buffers should be named now, I missed some.
Did you try the setting the labels to the buffers? How would the validation error look like in this case?
Sure, like this
Interesting, I'm replaying your trace with no validation errors about destroyed buffers. I only see errors related to swapchain extent, which are on our side.
Could you share a buildable repro case, perhaps?
Also, please provide information about your Vulkan validation layers version. I'm using:
Name : vulkan-validation-layers, version: 1.2.154.0, release: 10
Sure! Here's my repo. I removed some logging in the latest commit, you may want to checkout 4e8b17536d19f74b365d212cd276464a21714b46 which is what I generated the logs from
I'm using wgpu-rs revision dff97b0eb5f41cd9b2ed65c52ca0ea74cdb30f8f.
My current vulkaninfo, and the vulkaninfo for another machine I've seen the error on.
Thank you, I'm able to reproduce now!
Synchronization issues with resource destruction is one of the few things where API tracing doesn't help.
Most helpful comment
Thank you, I'm able to reproduce now!
Synchronization issues with resource destruction is one of the few things where API tracing doesn't help.