Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions chapters/high_level_shader_language_comparison.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -843,22 +843,15 @@ groupshared float4 sharedData[1024];

==== Barriers

[NOTE]
====
Barriers heavily differ between GLSL and HLSL. With one exception there is no direct mapping. To match HLSL in GLSL you often need to call multiple different barrier types in glsl.
====

Example:

GLSL:
[source,glsl]
----
groupMemoryBarrier();
barrier();
for (int j = 0; j < 256; j++) {
doSomething;
}
groupMemoryBarrier();
barrier();
----

Expand All @@ -872,17 +865,26 @@ for (int j = 0; j < 256; j++) {
GroupMemoryBarrierWithGroupSync();
----

[NOTE]
====
Barriers heavily differ between GLSL and HLSL. Some HLSL barriers don't have direct mapping to GLSL (such functions are in __italics__, and GLSL barriers have been used for them as accurately as possible).
====

|====
| *GLSL* | *HLSL*
| groupMemoryBarrier | GroupMemoryBarrier
| groupMemoryBarrier + barrier | GroupMemoryBarrierWithGroupSync
| memoryBarrier + memoryBarrierImage + memoryBarrierImage | DeviceMemoryBarrier
| memoryBarrier + memoryBarrierImage + memoryBarrierImage + barrier | DeviceMemoryBarrierWithGroupSync
| All above barriers + barrier | AllMemoryBarrierWithGroupSync
| All above barriers | AllMemoryBarrier
| memoryBarrierShared (only) | n.a.
| memoryBarrierShared | __GroupMemoryBarrier__
| barrier | GroupMemoryBarrierWithGroupSync
| memoryBarrierImage + memoryBarrierBuffer | DeviceMemoryBarrier
| memoryBarrierImage + memoryBarrierBuffer + barrier | __DeviceMemoryBarrierWithGroupSync__
| memoryBarrier + barrier | AllMemoryBarrierWithGroupSync
| memoryBarrier | AllMemoryBarrier
|====

[NOTE]
====
`barrier` implicitly sets a memory barrier for `shared`/`groupshared` memory. Roughly speaking, the `barrier` contains the `memoryBarrierShared`/`GroupMemoryBarrier`.
====

=== Mesh, task (amplification) and geometry shaders

These shader stages share several functions and built-ins
Expand Down