diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp index 3c869bc96..b61a6420a 100644 --- a/SPIRV/GlslangToSpv.cpp +++ b/SPIRV/GlslangToSpv.cpp @@ -5581,10 +5581,12 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO operands.push_back(sample); spv::Id resultTypeId; + glslang::TBasicType typeProxy = node->getBasicType(); // imageAtomicStore has a void return type so base the pointer type on // the type of the value operand. if (node->getOp() == glslang::EOpImageAtomicStore) { resultTypeId = builder.makePointer(spv::StorageClassImage, builder.getTypeId(*opIt)); + typeProxy = node->getAsAggregate()->getSequence()[0]->getAsTyped()->getType().getSampler().type; } else { resultTypeId = builder.makePointer(spv::StorageClassImage, resultType()); } @@ -5598,7 +5600,7 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO for (; opIt != arguments.end(); ++opIt) operands.push_back(*opIt); - return createAtomicOperation(node->getOp(), precision, resultType(), operands, node->getBasicType(), + return createAtomicOperation(node->getOp(), precision, resultType(), operands, typeProxy, lvalueCoherentFlags); } } diff --git a/Test/baseResults/spv.imageAtomic64.comp.out b/Test/baseResults/spv.imageAtomic64.comp.out new file mode 100644 index 000000000..0b1a0939c --- /dev/null +++ b/Test/baseResults/spv.imageAtomic64.comp.out @@ -0,0 +1,58 @@ +spv.imageAtomic64.comp +// Module Version 10000 +// Generated by (magic number): 8000a +// Id's are bound by 28 + + Capability Shader + Capability Int64 + Capability Int64Atomics + Capability Int64ImageEXT + Extension "SPV_EXT_shader_image_int64" + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint GLCompute 4 "main" + ExecutionMode 4 LocalSize 1 1 1 + Source GLSL 450 + SourceExtension "GL_EXT_shader_explicit_arithmetic_types_int64" + SourceExtension "GL_EXT_shader_image_int64" + SourceExtension "GL_KHR_memory_scope_semantics" + Name 4 "main" + Name 9 "z" + Name 14 "ssbo" + MemberName 14(ssbo) 0 "y" + Name 16 "" + Decorate 9(z) DescriptorSet 0 + Decorate 9(z) Binding 1 + MemberDecorate 14(ssbo) 0 Offset 0 + Decorate 14(ssbo) BufferBlock + Decorate 16 DescriptorSet 0 + Decorate 16 Binding 0 + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeInt 64 0 + 7: TypeImage 6(int64_t) 2D nonsampled format:R64ui + 8: TypePointer UniformConstant 7 + 9(z): 8(ptr) Variable UniformConstant + 10: TypeInt 32 1 + 11: TypeVector 10(int) 2 + 12: 10(int) Constant 1 + 13: 11(ivec2) ConstantComposite 12 12 + 14(ssbo): TypeStruct 6(int64_t) + 15: TypePointer Uniform 14(ssbo) + 16: 15(ptr) Variable Uniform + 17: 10(int) Constant 0 + 18: TypePointer Uniform 6(int64_t) + 21: 10(int) Constant 2048 + 22: TypeInt 32 0 + 23: 22(int) Constant 0 + 24: TypePointer Image 6(int64_t) + 26: 22(int) Constant 1 + 27: 22(int) Constant 2048 + 4(main): 2 Function None 3 + 5: Label + 19: 18(ptr) AccessChain 16 17 + 20: 6(int64_t) Load 19 + 25: 24(ptr) ImageTexelPointer 9(z) 13 23 + AtomicStore 25 12 27 20 + Return + FunctionEnd diff --git a/Test/spv.imageAtomic64.comp b/Test/spv.imageAtomic64.comp new file mode 100644 index 000000000..f09abf777 --- /dev/null +++ b/Test/spv.imageAtomic64.comp @@ -0,0 +1,12 @@ +#version 450 +#extension GL_EXT_shader_explicit_arithmetic_types_int64 : enable +#extension GL_EXT_shader_image_int64 : enable +#extension GL_KHR_memory_scope_semantics : enable + +layout(set = 0, binding = 0) buffer ssbo { uint64_t y; }; +layout(set = 0, binding = 1, r64ui) uniform u64image2D z; + +void main() { + // Test imageAtomicStore exclusively. Do NOT add other atomic operations to this test. + imageAtomicStore(z, ivec2(1, 1), y, gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsRelaxed); +} diff --git a/gtests/Spv.FromFile.cpp b/gtests/Spv.FromFile.cpp index 300d6642f..571025685 100644 --- a/gtests/Spv.FromFile.cpp +++ b/gtests/Spv.FromFile.cpp @@ -444,6 +444,7 @@ INSTANTIATE_TEST_SUITE_P( "spv.textureBuffer.vert", "spv.image.frag", "spv.imageAtomic64.frag", + "spv.imageAtomic64.comp", "spv.types.frag", "spv.uint.frag", "spv.uniformArray.frag",