I don't have an immediate repro (and I can't seem to repro in a straightforward manner on cube example) but I have a function like this:
pub fn draw(&self, bind_group: &wgpu::BindGroup, rpass: &mut wgpu::RenderPass) {
rpass.set_pipeline(&self.pipeline);
rpass.set_bind_group(0, bind_group, &[]);
rpass.set_vertex_buffers(&[(&self.buf, 0)]);
rpass.draw(0..(self.buf.len()) as u32, 0..1);
if self.strips_buf.len() != 0 {
// this is required because of a bug in wgpu which causes flickering unless we reset teh pipeline and bind group
rpass.set_pipeline(&self.pipeline); // <------ must re-set this otherwise flickers
rpass.set_bind_group(0, bind_group, &[]);
rpass.set_vertex_buffers(&[(&self.strips_buf, 0)]);
rpass.draw(0..(self.strips_buf.len()) as u32, 0..1);
}
}
E.g., I have to re-set_pipeline (but not the bind group), for the same pipeline (and bindgroup), otherwise i see flickering on the resultant triangle from the vertices in self.strips_buf.
I don't immediately know why this would happen, and I use the above workaround, but @kvark suggested I should file anyway so it's here and that it's probably a bug in wgpu.
I don't have any validation errors, etc., this is on vulkan backend, archlinux os, intel integrated gpu.
Are you seeing validation errors in general on this setup? Would you see them if something was clearly incorrect?
Yes I always see validation errors if something is wrong, eg wrong flags, etc. only time I haven鈥檛 is previous issue where I passed too many elements to a draw call, but that is now fixed in master.
There have been times where I think a shader was writing/reading to points in a buffer, and I did not receive any crashes or warnings (on both metal and vulkan backends) but I don鈥檛 know if validation errors can catch that gpu side issue ?
Our validation is still WIP, so it can easily miss some cases, especially if they are related to shader reflection/sanitation (which we haven't gotten hooked up yet).
Ok I鈥檒l double check but I don鈥檛 think I鈥檓 reading or writing any invalid memory anymore, and as far as I can see there aren鈥檛 any major issues remaining.
Do you have other pipelines or bind groups? Could this be a case of the bind group being "disturbed" by another bind?
https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#descriptorsets-compatibility
When binding a descriptor set (see Descriptor Set Binding) to set number N, if the previously bound descriptor sets for sets zero through N-1 were all bound using compatible pipeline layouts, then performing this binding does not disturb any of the lower numbered sets. If, additionally, the previous bound descriptor set for set N was bound using a pipeline layout compatible for set N, then the bindings in sets numbered greater than N are also not disturbed.
Hmm yes I have other pipelines and bind groups. But I think the cube demo does too ? If not would be interesting to see if having multiple pipelines and bind groups and the reusing one could cause this issue
The bindings are only disturbed if the pipelines are considered incompatible.
Yea I was rereading that. But in my example above why would that cause flickering? I rebind the exact same pipeline just to avoid flickering when I change the bound vertex buffer, which also has the same layout as the previous vertex buffer.
This is definitely related to https://github.com/gfx-rs/wgpu-rs/issues/49
@m4b I tried your workaround of re-setting the pipeline before the second draw call and that stops the flickering.
In my modified cube example (https://github.com/dragly/wgpu-rs/commit/cc36db229b416390892457c0bd0d3bb430dbec2a), the following conditions need to be met to reproduce flickering:
Let me know if there is anything I can do to help debug this issue.
Awesome thanks for checking ! Great detail too, thanks!
As mentioned in https://github.com/gfx-rs/wgpu-rs/issues/49, I filed a bug report to Mesa and it was immediately reported as a duplicate of a similar issue in vkQuake. Seems like this could be a graphics driver bug.
@m4b a patch that solved the issue for me was just posted here, in case you want to try it out and see if it also fixes your issue: https://gitlab.freedesktop.org/mesa/mesa/merge_requests/1526
I wonder if this is related to the problems #319 is fixing. I know that Mesa patch saves the day, but re-setting the pipeline could also make an effect on our binding code.
Rebased on top of the latest version of wgpu-rs and the problem persists. Seems like the Mesa patch is still necessary.
Most helpful comment
This is definitely related to https://github.com/gfx-rs/wgpu-rs/issues/49
@m4b I tried your workaround of re-setting the pipeline before the second draw call and that stops the flickering.
In my modified cube example (https://github.com/dragly/wgpu-rs/commit/cc36db229b416390892457c0bd0d3bb430dbec2a), the following conditions need to be met to reproduce flickering:
Let me know if there is anything I can do to help debug this issue.