diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp index ecb8b1e4f94fdf6bbb855e79e41bcf5e2223b21e..f933a043961a47df048aabc6960a61798c906632 100755 --- a/SPIRV/GlslangToSpv.cpp +++ b/SPIRV/GlslangToSpv.cpp @@ -1762,8 +1762,9 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt case glslang::EOpMemoryBarrierImage: case glslang::EOpMemoryBarrierShared: case glslang::EOpGroupMemoryBarrier: + case glslang::EOpDeviceMemoryBarrier: case glslang::EOpAllMemoryBarrierWithGroupSync: - case glslang::EOpGroupMemoryBarrierWithGroupSync: + case glslang::EOpDeviceMemoryBarrierWithGroupSync: case glslang::EOpWorkgroupMemoryBarrier: case glslang::EOpWorkgroupMemoryBarrierWithGroupSync: noReturnValue = true; @@ -5466,21 +5467,28 @@ spv::Id TGlslangToSpvTraverser::createNoArgOperation(glslang::TOperator op, spv: spv::MemorySemanticsAcquireReleaseMask); return 0; case glslang::EOpAllMemoryBarrierWithGroupSync: - // Control barrier with non-"None" semantic is also a memory barrier. - builder.createControlBarrier(spv::ScopeDevice, spv::ScopeDevice, + builder.createControlBarrier(spv::ScopeWorkgroup, spv::ScopeDevice, spv::MemorySemanticsAllMemory | - spv::MemorySemanticsSequentiallyConsistentMask); + spv::MemorySemanticsAcquireReleaseMask); return 0; - case glslang::EOpGroupMemoryBarrierWithGroupSync: - // Control barrier with non-"None" semantic is also a memory barrier. - builder.createControlBarrier(spv::ScopeDevice, spv::ScopeDevice, spv::MemorySemanticsCrossWorkgroupMemoryMask); + case glslang::EOpDeviceMemoryBarrier: + builder.createMemoryBarrier(spv::ScopeDevice, spv::MemorySemanticsUniformMemoryMask | + spv::MemorySemanticsImageMemoryMask | + spv::MemorySemanticsAcquireReleaseMask); + return 0; + case glslang::EOpDeviceMemoryBarrierWithGroupSync: + builder.createControlBarrier(spv::ScopeWorkgroup, spv::ScopeDevice, spv::MemorySemanticsUniformMemoryMask | + spv::MemorySemanticsImageMemoryMask | + spv::MemorySemanticsAcquireReleaseMask); return 0; case glslang::EOpWorkgroupMemoryBarrier: - builder.createMemoryBarrier(spv::ScopeWorkgroup, spv::MemorySemanticsWorkgroupMemoryMask); + builder.createMemoryBarrier(spv::ScopeWorkgroup, spv::MemorySemanticsWorkgroupMemoryMask | + spv::MemorySemanticsAcquireReleaseMask); return 0; case glslang::EOpWorkgroupMemoryBarrierWithGroupSync: - // Control barrier with non-"None" semantic is also a memory barrier. - builder.createControlBarrier(spv::ScopeWorkgroup, spv::ScopeWorkgroup, spv::MemorySemanticsWorkgroupMemoryMask); + builder.createControlBarrier(spv::ScopeWorkgroup, spv::ScopeWorkgroup, + spv::MemorySemanticsWorkgroupMemoryMask | + spv::MemorySemanticsAcquireReleaseMask); return 0; #ifdef AMD_EXTENSIONS case glslang::EOpTime: diff --git a/Test/baseResults/hlsl.intrinsics.barriers.comp.out b/Test/baseResults/hlsl.intrinsics.barriers.comp.out index b525c3ef4bc273acdcdb765bbf94393ce8d56baf..f5b4814b023b438b843474dec4f03cd94ad2a8ed 100644 --- a/Test/baseResults/hlsl.intrinsics.barriers.comp.out +++ b/Test/baseResults/hlsl.intrinsics.barriers.comp.out @@ -7,8 +7,8 @@ local_size = (1, 1, 1) 0:? Sequence 0:4 MemoryBarrier ( temp void) 0:5 AllMemoryBarrierWithGroupSync ( temp void) -0:6 GroupMemoryBarrier ( temp void) -0:7 GroupMemoryBarrierWithGroupSync ( temp void) +0:6 DeviceMemoryBarrier ( temp void) +0:7 DeviceMemoryBarrierWithGroupSync ( temp void) 0:8 WorkgroupMemoryBarrier ( temp void) 0:9 WorkgroupMemoryBarrierWithGroupSync ( temp void) 0:11 Branch: Return with expression @@ -35,8 +35,8 @@ local_size = (1, 1, 1) 0:? Sequence 0:4 MemoryBarrier ( temp void) 0:5 AllMemoryBarrierWithGroupSync ( temp void) -0:6 GroupMemoryBarrier ( temp void) -0:7 GroupMemoryBarrierWithGroupSync ( temp void) +0:6 DeviceMemoryBarrier ( temp void) +0:7 DeviceMemoryBarrierWithGroupSync ( temp void) 0:8 WorkgroupMemoryBarrier ( temp void) 0:9 WorkgroupMemoryBarrierWithGroupSync ( temp void) 0:11 Branch: Return with expression @@ -53,18 +53,18 @@ local_size = (1, 1, 1) // Module Version 10000 // Generated by (magic number): 80003 -// Id's are bound by 23 +// Id's are bound by 22 Capability Shader 1: ExtInstImport "GLSL.std.450" MemoryModel Logical GLSL450 - EntryPoint GLCompute 4 "ComputeShaderFunction" 21 + EntryPoint GLCompute 4 "ComputeShaderFunction" 20 ExecutionMode 4 LocalSize 1 1 1 Source HLSL 500 Name 4 "ComputeShaderFunction" Name 8 "@ComputeShaderFunction(" - Name 21 "@entryPointOutput" - Decorate 21(@entryPointOutput) Location 0 + Name 20 "@entryPointOutput" + Decorate 20(@entryPointOutput) Location 0 2: TypeVoid 3: TypeFunction 2 6: TypeFloat 32 @@ -72,26 +72,25 @@ local_size = (1, 1, 1) 10: TypeInt 32 0 11: 10(int) Constant 1 12: 10(int) Constant 4040 - 13: 10(int) Constant 4048 - 14: 10(int) Constant 2 - 15: 10(int) Constant 512 - 16: 10(int) Constant 256 - 17: 6(float) Constant 0 - 20: TypePointer Output 6(float) -21(@entryPointOutput): 20(ptr) Variable Output + 13: 10(int) Constant 2 + 14: 10(int) Constant 2120 + 15: 10(int) Constant 264 + 16: 6(float) Constant 0 + 19: TypePointer Output 6(float) +20(@entryPointOutput): 19(ptr) Variable Output 4(ComputeShaderFunction): 2 Function None 3 5: Label - 22: 6(float) FunctionCall 8(@ComputeShaderFunction() - Store 21(@entryPointOutput) 22 + 21: 6(float) FunctionCall 8(@ComputeShaderFunction() + Store 20(@entryPointOutput) 21 Return FunctionEnd 8(@ComputeShaderFunction(): 6(float) Function None 7 9: Label MemoryBarrier 11 12 - ControlBarrier 11 11 13 - MemoryBarrier 14 12 - ControlBarrier 11 11 15 - MemoryBarrier 14 16 - ControlBarrier 14 14 16 - ReturnValue 17 + ControlBarrier 13 11 12 + MemoryBarrier 11 14 + ControlBarrier 13 11 14 + MemoryBarrier 13 15 + ControlBarrier 13 13 15 + ReturnValue 16 FunctionEnd diff --git a/glslang/Include/intermediate.h b/glslang/Include/intermediate.h index 4a28e35672d830e0b3a832e931f8ff96f7e54009..58760195731dd152aff57c9e9255a900bdfbed81 100644 --- a/glslang/Include/intermediate.h +++ b/glslang/Include/intermediate.h @@ -722,7 +722,8 @@ enum TOperator { EOpInterlockedOr, // ... EOpInterlockedXor, // ... EOpAllMemoryBarrierWithGroupSync, // memory barriers without non-hlsl AST equivalents - EOpGroupMemoryBarrierWithGroupSync, // ... + EOpDeviceMemoryBarrier, // ... + EOpDeviceMemoryBarrierWithGroupSync, // ... EOpWorkgroupMemoryBarrier, // ... EOpWorkgroupMemoryBarrierWithGroupSync, // ... EOpEvaluateAttributeSnapped, // InterpolateAtOffset with int position on 16x16 grid diff --git a/glslang/MachineIndependent/intermOut.cpp b/glslang/MachineIndependent/intermOut.cpp index 7e15392da682c1772346a55ff869456c26b56836..dd2cdc89f035442f9e331856fe8466bf452130a5 100644 --- a/glslang/MachineIndependent/intermOut.cpp +++ b/glslang/MachineIndependent/intermOut.cpp @@ -791,7 +791,8 @@ bool TOutputTraverser::visitAggregate(TVisit /* visit */, TIntermAggregate* node case EOpGenMul: out.debug << "mul"; break; case EOpAllMemoryBarrierWithGroupSync: out.debug << "AllMemoryBarrierWithGroupSync"; break; - case EOpGroupMemoryBarrierWithGroupSync: out.debug << "GroupMemoryBarrierWithGroupSync"; break; + case EOpDeviceMemoryBarrier: out.debug << "DeviceMemoryBarrier"; break; + case EOpDeviceMemoryBarrierWithGroupSync: out.debug << "DeviceMemoryBarrierWithGroupSync"; break; case EOpWorkgroupMemoryBarrier: out.debug << "WorkgroupMemoryBarrier"; break; case EOpWorkgroupMemoryBarrierWithGroupSync: out.debug << "WorkgroupMemoryBarrierWithGroupSync"; break; diff --git a/hlsl/hlslParseables.cpp b/hlsl/hlslParseables.cpp index bae9e6e8c6493bbf0d87cf168cdab06a0bffa46d..7a46e805d71bc9107a6c6b56ad087cd2ebdc723d 100755 --- a/hlsl/hlslParseables.cpp +++ b/hlsl/hlslParseables.cpp @@ -1087,8 +1087,8 @@ void TBuiltInParseablesHlsl::identifyBuiltIns(int /*version*/, EProfile /*profil symbolTable.relateToOperator("ddy_fine", EOpDPdyFine); symbolTable.relateToOperator("degrees", EOpDegrees); symbolTable.relateToOperator("determinant", EOpDeterminant); - symbolTable.relateToOperator("DeviceMemoryBarrier", EOpGroupMemoryBarrier); - symbolTable.relateToOperator("DeviceMemoryBarrierWithGroupSync", EOpGroupMemoryBarrierWithGroupSync); // ... + symbolTable.relateToOperator("DeviceMemoryBarrier", EOpDeviceMemoryBarrier); + symbolTable.relateToOperator("DeviceMemoryBarrierWithGroupSync", EOpDeviceMemoryBarrierWithGroupSync); symbolTable.relateToOperator("distance", EOpDistance); symbolTable.relateToOperator("dot", EOpDot); symbolTable.relateToOperator("dst", EOpDst);