glsl-out: Call proper memory barrier functions (#1680)

* glsl-out: Call proper memory barrier functions

* glsl-out: Change test for control flow

* Removed two unnecessary calls
This commit is contained in:
francesco-cattoglio authored and Dzmitry Malyshau committed 2022-01-24 10:54:55 -05:00
1 parent a3b1c13151
commit 86282ddac4
2 files changed
+14 -7

No files matched your search

+10 -5
View File
@@ -1723,13 +1723,18 @@ impl<'a, W: Write> Writer<'a, W> {
// keyword which ceases all further processing in a fragment shader, it's called OpKill
// in spir-v that's why it's called `Statement::Kill`
Statement::Kill => writeln!(self.out, "{}discard;", level)?,
// Issue an execution or a memory barrier.
// Issue a memory barrier. Please note that to ensure visibility,
// OpenGL always requires a call to the `barrier()` function after a `memoryBarrier*()`
Statement::Barrier(flags) => {
if flags.is_empty() {
writeln!(self.out, "{}barrier();", level)?;
} else {
writeln!(self.out, "{}groupMemoryBarrier();", level)?;
if flags.contains(crate::Barrier::STORAGE) {
writeln!(self.out, "{}memoryBarrierBuffer();", level)?;
}
if flags.contains(crate::Barrier::WORK_GROUP) {
writeln!(self.out, "{}memoryBarrierShared();", level)?;
}
writeln!(self.out, "{}barrier();", level)?;
}
// Stores in glsl are just variable assignments written as `pointer = value;`
Statement::Store { pointer, value } => {
@@ -38,8 +38,10 @@ void loop_switch_continue(int x) {
void main() {
uvec3 global_id = gl_GlobalInvocationID;
int pos = 0;
groupMemoryBarrier();
groupMemoryBarrier();
memoryBarrierBuffer();
barrier();
memoryBarrierShared();
barrier();
switch(1) {
default:
pos = 1;