Nuby Joe
Nuby Joe

Reputation: 67

order independent transparency - memory barrier

The example I was reading comes from the opengl red book. Source code is here: https://github.com/openglredbook/examples/blob/master/src/11-oit/11-oit.cpp

I read about image load store is incoherent memory access, and does not guarantee ordering between 2 rendering command. https://www.khronos.org/opengl/wiki/Memory_Model When I read source code for this algorithm, I see no mentioning of memory barrier. So do I actually need to call memory barrier between the rendering command that sort the fragments and store them, and the rendering command that renders the quad?

Upvotes: 0

Views: 144

Answers (1)

Nicol Bolas
Nicol Bolas

Reputation: 473627

For your general question, yes, you need an explicit memory barrier between the two operations.

On a more personal note, please stop looking at that code. I'm seeing many dubious things beyond just the lack of a barrier: the mapping of a buffer for the sole purpose of writing a single integer, a call to glTexSubImage2D that's sure to give an error because NULL is not a valid pointer parameter, etc.

Upvotes: 4

Related Questions