-
Notifications
You must be signed in to change notification settings - Fork 193
glsl-out: Call proper memory barrier functions #1680
Conversation
src/back/glsl/mod.rs
Outdated
writeln!(self.out, "{}groupMemoryBarrier();", level)?; | ||
if flags.contains(crate::Barrier::STORAGE) { | ||
writeln!(self.out, "{}memoryBarrierBuffer();", level)?; | ||
writeln!(self.out, "{}memoryBarrierImage();", level)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the current semantics of crate::Barrier::STORAGE
doesn't include images. Trying to clarify that with the group. So we should probably remove it for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decided to add the Image
barrier after taking a look at the naga HLSL-out writer, which produces a DeviceMemoryBarrier()
function call. Then I looked for more information and found this: https://github.com/microsoft/DirectXShaderCompiler/blob/master/docs/SPIR-V.rst#synchronization-intrinsics
Anyway, I will remove this for now.
* glsl-out: Call proper memory barrier functions * glsl-out: Change test for control flow * Removed two unnecessary calls
* glsl-out: Call proper memory barrier functions * glsl-out: Change test for control flow * Removed two unnecessary calls
published in 0.8.4 |
This should fix #1677
OpenGL memory barriers and visibility are really confusing to me, but I spent some time researching to the best of my ability to make this correct: I started from https://www.khronos.org/opengl/wiki/Memory_Model#Ensuring_visibility and then read some extra questions/answers/blog posts around the net to confirm that I understood the khronos wiki correctly.
After the code change I did run
cargo test --all-features --workspace
and it reported no error, then I ranmake validate-glsl
and finally committed the new (modified) test output.Edit: P.S: the
barrier()
GLSL function can only be called in a compute shader, but I am pretty sure this is fine because WGSL synchronization built-in functions can only be called in compute shaders anyway.