From 996c5d312399581792583b1724837567dc9cb670 Mon Sep 17 00:00:00 2001 From: Arcady Goldmints-Orlov Date: Mon, 11 Mar 2024 18:24:45 -0400 Subject: [PATCH 01/14] Add support for OpExtInstWithForwardRefs --- SPIRV/GLSL.ext.KHR.h | 1 + SPIRV/doc.cpp | 5 +++++ SPIRV/spirv.hpp | 2 ++ known_good.json | 26 +++++++++++++------------- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/SPIRV/GLSL.ext.KHR.h b/SPIRV/GLSL.ext.KHR.h index ba26708d..38d3b974 100644 --- a/SPIRV/GLSL.ext.KHR.h +++ b/SPIRV/GLSL.ext.KHR.h @@ -62,5 +62,6 @@ static const char* const E_SPV_KHR_maximal_reconvergence = "SPV_KHR_maxim static const char* const E_SPV_KHR_subgroup_rotate = "SPV_KHR_subgroup_rotate"; static const char* const E_SPV_KHR_expect_assume = "SPV_KHR_expect_assume"; static const char* const E_SPV_EXT_replicated_composites = "SPV_EXT_replicated_composites"; +static const char* const E_SPV_KHR_relaxed_extended_instruction = "SPV_KHR_relaxed_extended_instruction"; #endif // #ifndef GLSLextKHR_H diff --git a/SPIRV/doc.cpp b/SPIRV/doc.cpp index f60a8949..141fb5b7 100755 --- a/SPIRV/doc.cpp +++ b/SPIRV/doc.cpp @@ -1445,6 +1445,7 @@ const char* OpcodeString(int op) case 4429: return "OpSubgroupAnyKHR"; case 4430: return "OpSubgroupAllEqualKHR"; case 4432: return "OpSubgroupReadInvocationKHR"; + case 4433: return "OpExtInstWithForwardRefs"; case OpGroupNonUniformQuadAllKHR: return "OpGroupNonUniformQuadAllKHR"; case OpGroupNonUniformQuadAnyKHR: return "OpGroupNonUniformQuadAnyKHR"; @@ -1896,6 +1897,10 @@ void Parameterize() InstructionDesc[OpExtInst].operands.push(OperandLiteralNumber, "'Instruction'"); InstructionDesc[OpExtInst].operands.push(OperandVariableIds, "'Operand 1', +\n'Operand 2', +\n..."); + InstructionDesc[OpExtInstWithForwardRefs].operands.push(OperandId, "'Set'"); + InstructionDesc[OpExtInstWithForwardRefs].operands.push(OperandLiteralNumber, "'Instruction'"); + InstructionDesc[OpExtInstWithForwardRefs].operands.push(OperandVariableIds, "'Operand 1', +\n'Operand 2', +\n..."); + InstructionDesc[OpLoad].operands.push(OperandId, "'Pointer'"); InstructionDesc[OpLoad].operands.push(OperandMemoryAccess, "", true); InstructionDesc[OpLoad].operands.push(OperandLiteralNumber, "", true); diff --git a/SPIRV/spirv.hpp b/SPIRV/spirv.hpp index 5821eced..0d93ba96 100644 --- a/SPIRV/spirv.hpp +++ b/SPIRV/spirv.hpp @@ -1668,6 +1668,7 @@ enum Op { OpSubgroupAllEqualKHR = 4430, OpGroupNonUniformRotateKHR = 4431, OpSubgroupReadInvocationKHR = 4432, + OpExtInstWithForwardRefs = 4433, OpTraceRayKHR = 4445, OpExecuteCallableKHR = 4446, OpConvertUToAccelerationStructureKHR = 4447, @@ -2395,6 +2396,7 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) { case OpPtrEqual: *hasResult = true; *hasResultType = true; break; case OpPtrNotEqual: *hasResult = true; *hasResultType = true; break; case OpPtrDiff: *hasResult = true; *hasResultType = true; break; + case OpExtInstWithForwardRefs: *hasResult = true; *hasResultType = true; break; case OpColorAttachmentReadEXT: *hasResult = true; *hasResultType = true; break; case OpDepthAttachmentReadEXT: *hasResult = true; *hasResultType = true; break; case OpStencilAttachmentReadEXT: *hasResult = true; *hasResultType = true; break; diff --git a/known_good.json b/known_good.json index 8dbe973d..a87331c8 100644 --- a/known_good.json +++ b/known_good.json @@ -1,19 +1,19 @@ { "commits" : [ { - "name" : "spirv-tools", - "site" : "github", - "subrepo" : "KhronosGroup/SPIRV-Tools", - "subdir" : "External/spirv-tools", - "commit": "148c97f6876e427efd76d2328122c3075eab4b8f" - }, - { - "name" : "spirv-tools/external/spirv-headers", - "site" : "github", - "subrepo" : "KhronosGroup/SPIRV-Headers", - "subdir" : "External/spirv-tools/external/spirv-headers", - "commit" : "ea77f2a826bc820cb8f57f9b2a7c7eccb681c731" - }, + "name" : "spirv-tools", + "site" : "github", + "subrepo" : "KhronosGroup/SPIRV-Tools", + "subdir" : "External/spirv-tools", + "commit": "6a2bdeee75eb35e5349c6993d33c9afe30237d79" + }, + { + "name" : "spirv-tools/external/spirv-headers", + "site" : "github", + "subrepo" : "KhronosGroup/SPIRV-Headers", + "subdir" : "External/spirv-tools/external/spirv-headers", + "commit" : "ff2afc3afc48dff4eec2a10f0212402a80708e38" + }, { "name": "googletest", "site": "github", From 81f7045aa00e1122a05b19a1fabf0ab22ddabb7b Mon Sep 17 00:00:00 2001 From: Arcady Goldmints-Orlov Date: Mon, 11 Mar 2024 18:53:37 -0400 Subject: [PATCH 02/14] Emit debug info for buffer references Using OpExtInstWithForwardRefs, the debug type information for buffer reference types can be emitted alongside the OpFowardPointer opcode. --- SPIRV/SpvBuilder.cpp | 36 +++ SPIRV/SpvBuilder.h | 1 + .../spv.debuginfo.bufferref.glsl.frag.out | 297 +++++++++--------- 3 files changed, 188 insertions(+), 146 deletions(-) diff --git a/SPIRV/SpvBuilder.cpp b/SPIRV/SpvBuilder.cpp index f07460d2..42fca364 100644 --- a/SPIRV/SpvBuilder.cpp +++ b/SPIRV/SpvBuilder.cpp @@ -182,6 +182,10 @@ Id Builder::makeForwardPointer(StorageClass storageClass) constantsTypesGlobals.push_back(std::unique_ptr(type)); module.mapInstruction(type); + if (emitNonSemanticShaderDebugInfo) { + const Id debugResultId = makeForwardPointerDebugType(storageClass); + debugId[type->getResultId()] = debugResultId; + } return type->getResultId(); } @@ -204,6 +208,15 @@ Id Builder::makePointerFromForwardPointer(StorageClass storageClass, Id forwardP constantsTypesGlobals.push_back(std::unique_ptr(type)); module.mapInstruction(type); + // If we are emitting nonsemantic debuginfo, we need to patch the debug pointer type + // that was emitted alongside the forward pointer, now that we have a pointee debug + // type for it to point to. + if (emitNonSemanticShaderDebugInfo) { + Instruction *debugForwardPointer = module.getInstruction(debugId[forwardPointerType]); + assert(debugId[pointee]); + debugForwardPointer->setIdOperand(2, debugId[pointee]); + } + return type->getResultId(); } @@ -1045,6 +1058,29 @@ Id Builder::makePointerDebugType(StorageClass storageClass, Id const baseType) return type->getResultId(); } +// Emit a OpExtInstWithForwardRefs nonsemantic instruction for a pointer debug type +// where we don't have the pointee yet. Since we don't have the pointee yet, it just +// points to itself and we rely on patching it later. +Id Builder::makeForwardPointerDebugType(StorageClass storageClass) +{ + const Id scID = makeUintConstant(storageClass); + + this->addExtension(spv::E_SPV_KHR_relaxed_extended_instruction); + + Instruction *type = new Instruction(getUniqueId(), makeVoidType(), OpExtInstWithForwardRefs); + type->addIdOperand(nonSemanticShaderDebugInfo); + type->addImmediateOperand(NonSemanticShaderDebugInfo100DebugTypePointer); + type->addIdOperand(type->getResultId()); + type->addIdOperand(scID); + type->addIdOperand(makeUintConstant(0)); + + groupedDebugTypes[NonSemanticShaderDebugInfo100DebugTypePointer].push_back(type); + constantsTypesGlobals.push_back(std::unique_ptr(type)); + module.mapInstruction(type); + + return type->getResultId(); +} + Id Builder::makeDebugSource(const Id fileName) { if (debugSourceId.find(fileName) != debugSourceId.end()) return debugSourceId[fileName]; diff --git a/SPIRV/SpvBuilder.h b/SPIRV/SpvBuilder.h index fd04f630..35327d6e 100644 --- a/SPIRV/SpvBuilder.h +++ b/SPIRV/SpvBuilder.h @@ -235,6 +235,7 @@ public: Id makeCompositeDebugType(std::vector const& memberTypes, char const*const name, NonSemanticShaderDebugInfo100DebugCompositeType const tag, bool const isOpaqueType = false); Id makePointerDebugType(StorageClass storageClass, Id const baseType); + Id makeForwardPointerDebugType(StorageClass storageClass); Id makeDebugSource(const Id fileName); Id makeDebugCompilationUnit(); Id createDebugGlobalVariable(Id const type, char const*const name, Id const variable); diff --git a/Test/baseResults/spv.debuginfo.bufferref.glsl.frag.out b/Test/baseResults/spv.debuginfo.bufferref.glsl.frag.out index f4628811..6b877bf5 100644 --- a/Test/baseResults/spv.debuginfo.bufferref.glsl.frag.out +++ b/Test/baseResults/spv.debuginfo.bufferref.glsl.frag.out @@ -1,17 +1,18 @@ spv.debuginfo.bufferref.glsl.frag // Module Version 10000 // Generated by (magic number): 8000b -// Id's are bound by 142 +// Id's are bound by 146 Capability Shader Capability PhysicalStorageBufferAddressesEXT Extension "SPV_KHR_non_semantic_info" Extension "SPV_KHR_physical_storage_buffer" + Extension "SPV_KHR_relaxed_extended_instruction" Extension "SPV_KHR_storage_buffer_storage_class" 1: ExtInstImport "NonSemantic.Shader.DebugInfo.100" 3: ExtInstImport "GLSL.std.450" MemoryModel PhysicalStorageBuffer64EXT GLSL450 - EntryPoint Fragment 14 "main" 76 131 + EntryPoint Fragment 14 "main" 82 135 ExecutionMode 14 OriginUpperLeft 2: String "spv.debuginfo.bufferref.glsl.frag" 8: String "uint" @@ -52,46 +53,47 @@ void main() { out_fragColor = vec4(vertex_pos0, 1.0); } " - 31: String "Mesh" - 34: String "float" - 40: String "data" - 44: String "MeshVertexPositions" - 50: String "meshData" - 63: String "PerPass_meshes" - 69: String "perPass_meshes" - 71: String "int" - 78: String "tri_idx0" - 94: String "vertex_pos0" - 133: String "out_fragColor" + 33: String "positions" + 37: String "Mesh" + 40: String "float" + 46: String "data" + 49: String "MeshVertexPositions" + 55: String "meshData" + 69: String "PerPass_meshes" + 75: String "perPass_meshes" + 77: String "int" + 84: String "tri_idx0" + 100: String "vertex_pos0" + 137: String "out_fragColor" SourceExtension "GL_EXT_buffer_reference" Name 14 "main" - Name 29 "Mesh" - MemberName 29(Mesh) 0 "positions" - Name 38 "MeshVertexPositions" - MemberName 38(MeshVertexPositions) 0 "data" - Name 48 "meshData" - Name 54 "Mesh" - MemberName 54(Mesh) 0 "positions" - Name 58 "PerPass_meshes" - MemberName 58(PerPass_meshes) 0 "data" - Name 67 "perPass_meshes" - Name 76 "tri_idx0" - Name 92 "vertex_pos0" - Name 131 "out_fragColor" - Decorate 36 ArrayStride 4 - MemberDecorate 38(MeshVertexPositions) 0 Offset 0 - Decorate 38(MeshVertexPositions) Block - MemberDecorate 54(Mesh) 0 Offset 0 - Decorate 56 ArrayStride 8 - MemberDecorate 58(PerPass_meshes) 0 NonWritable - MemberDecorate 58(PerPass_meshes) 0 Offset 0 - Decorate 58(PerPass_meshes) Block - Decorate 67(perPass_meshes) DescriptorSet 0 - Decorate 67(perPass_meshes) Binding 0 - Decorate 76(tri_idx0) Flat - Decorate 76(tri_idx0) Location 0 - Decorate 131(out_fragColor) Location 0 - Decorate 48(meshData) DecorationAliasedPointerEXT + Name 31 "Mesh" + MemberName 31(Mesh) 0 "positions" + Name 44 "MeshVertexPositions" + MemberName 44(MeshVertexPositions) 0 "data" + Name 53 "meshData" + Name 59 "Mesh" + MemberName 59(Mesh) 0 "positions" + Name 64 "PerPass_meshes" + MemberName 64(PerPass_meshes) 0 "data" + Name 73 "perPass_meshes" + Name 82 "tri_idx0" + Name 98 "vertex_pos0" + Name 135 "out_fragColor" + Decorate 42 ArrayStride 4 + MemberDecorate 44(MeshVertexPositions) 0 Offset 0 + Decorate 44(MeshVertexPositions) Block + MemberDecorate 59(Mesh) 0 Offset 0 + Decorate 62 ArrayStride 8 + MemberDecorate 64(PerPass_meshes) 0 NonWritable + MemberDecorate 64(PerPass_meshes) 0 Offset 0 + Decorate 64(PerPass_meshes) Block + Decorate 73(perPass_meshes) DescriptorSet 0 + Decorate 73(perPass_meshes) Binding 0 + Decorate 82(tri_idx0) Flat + Decorate 82(tri_idx0) Location 0 + Decorate 135(out_fragColor) Location 0 + Decorate 53(meshData) DecorationAliasedPointerEXT 4: TypeVoid 5: TypeFunction 4 7: TypeInt 32 0 @@ -109,116 +111,119 @@ void main() { 21: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 1(DebugCompilationUnit) 22 23 18 24 17: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 20(DebugFunction) 16 6 18 20 12 21 16 13 20 TypeForwardPointer 28 PhysicalStorageBufferEXT - 29(Mesh): TypeStruct 28 - 32: 7(int) Constant 21 - 30: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 10(DebugTypeComposite) 31 22 18 32 12 21 31 12 13 - 33: TypeFloat 32 - 35: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 2(DebugTypeBasic) 34 10 13 12 - 36: TypeRuntimeArray 33(float) - 37: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 5(DebugTypeArray) 35 12 -38(MeshVertexPositions): TypeStruct 36 - 41: 7(int) Constant 5 - 42: 7(int) Constant 9 - 39: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 11(DebugTypeMember) 40 37 18 41 42 12 12 13 - 43: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 10(DebugTypeComposite) 44 22 18 32 12 21 44 12 13 39 - 28: TypePointer PhysicalStorageBufferEXT 38(MeshVertexPositions) - 45: TypePointer Function 29(Mesh) - 46: 7(int) Constant 7 - 47: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 3(DebugTypePointer) 30 46 12 - 49: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 26(DebugLocalVariable) 50 30 18 32 12 17 23 - 52: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 31(DebugExpression) - 54(Mesh): TypeStruct 28(ptr) - 55: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 10(DebugTypeComposite) 31 22 18 32 12 21 31 12 13 - 56: TypeRuntimeArray 54(Mesh) - 57: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 5(DebugTypeArray) 55 12 -58(PerPass_meshes): TypeStruct 56 - 60: 7(int) Constant 13 - 61: 7(int) Constant 8 - 59: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 11(DebugTypeMember) 40 57 18 60 61 12 12 13 - 62: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 10(DebugTypeComposite) 63 22 18 32 12 21 63 12 13 59 - 64: TypePointer StorageBuffer 58(PerPass_meshes) - 65: 7(int) Constant 12 - 66: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 3(DebugTypePointer) 62 65 12 -67(perPass_meshes): 64(ptr) Variable StorageBuffer - 68: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 18(DebugGlobalVariable) 69 62 18 32 12 21 69 67(perPass_meshes) 61 - 70: TypeInt 32 1 - 72: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 2(DebugTypeBasic) 71 10 23 12 - 73: 70(int) Constant 0 - 74: TypePointer Input 7(int) - 75: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 3(DebugTypePointer) 9 22 12 - 76(tri_idx0): 74(ptr) Variable Input - 77: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 18(DebugGlobalVariable) 78 9 18 32 12 21 78 76(tri_idx0) 61 - 80: TypePointer StorageBuffer 54(Mesh) - 81: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 3(DebugTypePointer) 55 65 12 - 85: TypePointer Function 28(ptr) - 86: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 0(DebugInfoNone) - 88: TypeVector 33(float) 3 - 89: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 6(DebugTypeVector) 35 13 - 90: TypePointer Function 88(fvec3) - 91: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 3(DebugTypePointer) 89 46 12 - 95: 7(int) Constant 23 - 93: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 26(DebugLocalVariable) 94 89 18 95 12 17 23 - 102: TypePointer PhysicalStorageBufferEXT 33(float) - 103: 7(int) Constant 5349 - 104: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 3(DebugTypePointer) 35 103 12 - 109: 7(int) Constant 24 - 118: 7(int) Constant 25 - 127: TypeVector 33(float) 4 - 128: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 6(DebugTypeVector) 35 23 - 129: TypePointer Output 127(fvec4) - 130: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 3(DebugTypePointer) 128 13 12 -131(out_fragColor): 129(ptr) Variable Output - 134: 7(int) Constant 27 - 132: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 18(DebugGlobalVariable) 133 128 18 134 12 21 133 131(out_fragColor) 61 - 137: 33(float) Constant 1065353216 + 29: 7(int) Constant 5349 + 30: 4 ExtInstWithForwardRefs 1(NonSemantic.Shader.DebugInfo.100) 3 48 29 12 + 31(Mesh): TypeStruct 28 + 34: 7(int) Constant 9 + 35: 7(int) Constant 23 + 32: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 11(DebugTypeMember) 33 30 18 34 35 12 12 13 + 38: 7(int) Constant 21 + 36: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 10(DebugTypeComposite) 37 22 18 38 12 21 37 12 13 32 + 39: TypeFloat 32 + 41: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 2(DebugTypeBasic) 40 10 13 12 + 42: TypeRuntimeArray 39(float) + 43: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 5(DebugTypeArray) 41 12 +44(MeshVertexPositions): TypeStruct 42 + 47: 7(int) Constant 5 + 45: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 11(DebugTypeMember) 46 43 18 47 34 12 12 13 + 48: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 10(DebugTypeComposite) 49 22 18 38 12 21 49 12 13 45 + 28: TypePointer PhysicalStorageBufferEXT 44(MeshVertexPositions) + 50: TypePointer Function 31(Mesh) + 51: 7(int) Constant 7 + 52: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 3(DebugTypePointer) 36 51 12 + 54: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 26(DebugLocalVariable) 55 36 18 38 12 17 23 + 57: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 31(DebugExpression) + 59(Mesh): TypeStruct 28(ptr) + 60: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 11(DebugTypeMember) 33 30 18 34 35 12 12 13 + 61: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 10(DebugTypeComposite) 37 22 18 38 12 21 37 12 13 60 + 62: TypeRuntimeArray 59(Mesh) + 63: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 5(DebugTypeArray) 61 12 +64(PerPass_meshes): TypeStruct 62 + 66: 7(int) Constant 13 + 67: 7(int) Constant 8 + 65: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 11(DebugTypeMember) 46 63 18 66 67 12 12 13 + 68: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 10(DebugTypeComposite) 69 22 18 38 12 21 69 12 13 65 + 70: TypePointer StorageBuffer 64(PerPass_meshes) + 71: 7(int) Constant 12 + 72: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 3(DebugTypePointer) 68 71 12 +73(perPass_meshes): 70(ptr) Variable StorageBuffer + 74: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 18(DebugGlobalVariable) 75 68 18 38 12 21 75 73(perPass_meshes) 67 + 76: TypeInt 32 1 + 78: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 2(DebugTypeBasic) 77 10 23 12 + 79: 76(int) Constant 0 + 80: TypePointer Input 7(int) + 81: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 3(DebugTypePointer) 9 22 12 + 82(tri_idx0): 80(ptr) Variable Input + 83: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 18(DebugGlobalVariable) 84 9 18 38 12 21 84 82(tri_idx0) 67 + 86: TypePointer StorageBuffer 59(Mesh) + 87: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 3(DebugTypePointer) 61 71 12 + 91: TypePointer Function 28(ptr) + 92: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 3(DebugTypePointer) 30 51 12 + 94: TypeVector 39(float) 3 + 95: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 6(DebugTypeVector) 41 13 + 96: TypePointer Function 94(fvec3) + 97: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 3(DebugTypePointer) 95 51 12 + 99: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 26(DebugLocalVariable) 100 95 18 35 12 17 23 + 107: TypePointer PhysicalStorageBufferEXT 39(float) + 108: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 3(DebugTypePointer) 41 29 12 + 113: 7(int) Constant 24 + 122: 7(int) Constant 25 + 131: TypeVector 39(float) 4 + 132: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 6(DebugTypeVector) 41 23 + 133: TypePointer Output 131(fvec4) + 134: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 3(DebugTypePointer) 132 13 12 +135(out_fragColor): 133(ptr) Variable Output + 138: 7(int) Constant 27 + 136: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 18(DebugGlobalVariable) 137 132 18 138 12 21 137 135(out_fragColor) 67 + 141: 39(float) Constant 1065353216 14(main): 4 Function None 5 15: Label - 48(meshData): 45(ptr) Variable Function - 92(vertex_pos0): 90(ptr) Variable Function + 53(meshData): 50(ptr) Variable Function + 98(vertex_pos0): 96(ptr) Variable Function 26: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 17 27: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 20 20 12 12 25: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 101(DebugFunctionDefinition) 17 14(main) - 53: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 32 32 12 12 - 51: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 28(DebugDeclare) 49 48(meshData) 52 - 79: 7(int) Load 76(tri_idx0) - 82: 80(ptr) AccessChain 67(perPass_meshes) 73 79 - 83: 54(Mesh) Load 82 - 84: 28(ptr) CompositeExtract 83 0 - 87: 85(ptr) AccessChain 48(meshData) 73 - Store 87 84 - 97: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 95 95 12 12 - 96: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 28(DebugDeclare) 93 92(vertex_pos0) 52 - 98: 85(ptr) AccessChain 48(meshData) 73 - 99: 28(ptr) Load 98 - 100: 7(int) Load 76(tri_idx0) - 101: 7(int) IMul 13 100 - 105: 102(ptr) AccessChain 99 73 101 - 106: 33(float) Load 105 Aligned 4 - 108: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 109 109 12 12 - 107: 85(ptr) AccessChain 48(meshData) 73 - 110: 28(ptr) Load 107 - 111: 7(int) Load 76(tri_idx0) - 112: 7(int) IMul 13 111 - 113: 7(int) IAdd 112 22 - 114: 102(ptr) AccessChain 110 73 113 - 115: 33(float) Load 114 Aligned 4 - 117: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 118 118 12 12 - 116: 85(ptr) AccessChain 48(meshData) 73 - 119: 28(ptr) Load 116 - 120: 7(int) Load 76(tri_idx0) - 121: 7(int) IMul 13 120 - 122: 7(int) IAdd 121 24 - 123: 102(ptr) AccessChain 119 73 122 - 124: 33(float) Load 123 Aligned 4 - 125: 88(fvec3) CompositeConstruct 106 115 124 - 126: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 95 95 12 12 - Store 92(vertex_pos0) 125 - 136: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 134 134 12 12 - 135: 88(fvec3) Load 92(vertex_pos0) - 138: 33(float) CompositeExtract 135 0 - 139: 33(float) CompositeExtract 135 1 - 140: 33(float) CompositeExtract 135 2 - 141: 127(fvec4) CompositeConstruct 138 139 140 137 - Store 131(out_fragColor) 141 + 58: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 38 38 12 12 + 56: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 28(DebugDeclare) 54 53(meshData) 57 + 85: 7(int) Load 82(tri_idx0) + 88: 86(ptr) AccessChain 73(perPass_meshes) 79 85 + 89: 59(Mesh) Load 88 + 90: 28(ptr) CompositeExtract 89 0 + 93: 91(ptr) AccessChain 53(meshData) 79 + Store 93 90 + 102: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 35 35 12 12 + 101: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 28(DebugDeclare) 99 98(vertex_pos0) 57 + 103: 91(ptr) AccessChain 53(meshData) 79 + 104: 28(ptr) Load 103 + 105: 7(int) Load 82(tri_idx0) + 106: 7(int) IMul 13 105 + 109: 107(ptr) AccessChain 104 79 106 + 110: 39(float) Load 109 Aligned 4 + 112: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 113 113 12 12 + 111: 91(ptr) AccessChain 53(meshData) 79 + 114: 28(ptr) Load 111 + 115: 7(int) Load 82(tri_idx0) + 116: 7(int) IMul 13 115 + 117: 7(int) IAdd 116 22 + 118: 107(ptr) AccessChain 114 79 117 + 119: 39(float) Load 118 Aligned 4 + 121: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 122 122 12 12 + 120: 91(ptr) AccessChain 53(meshData) 79 + 123: 28(ptr) Load 120 + 124: 7(int) Load 82(tri_idx0) + 125: 7(int) IMul 13 124 + 126: 7(int) IAdd 125 24 + 127: 107(ptr) AccessChain 123 79 126 + 128: 39(float) Load 127 Aligned 4 + 129: 94(fvec3) CompositeConstruct 110 119 128 + 130: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 35 35 12 12 + Store 98(vertex_pos0) 129 + 140: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 138 138 12 12 + 139: 94(fvec3) Load 98(vertex_pos0) + 142: 39(float) CompositeExtract 139 0 + 143: 39(float) CompositeExtract 139 1 + 144: 39(float) CompositeExtract 139 2 + 145: 131(fvec4) CompositeConstruct 142 143 144 141 + Store 135(out_fragColor) 145 Return FunctionEnd From 73eccd4b67985d344578cade8958214cee0a3f6e Mon Sep 17 00:00:00 2001 From: Arcady Goldmints-Orlov Date: Thu, 6 Jun 2024 18:07:12 -0400 Subject: [PATCH 03/14] Add the KHR suffix for OpExtInstWithForwardRefsKHR instruction --- SPIRV/SpvBuilder.cpp | 4 ++-- SPIRV/doc.cpp | 8 ++++---- SPIRV/spirv.hpp | 4 ++-- Test/baseResults/spv.debuginfo.bufferref.glsl.frag.out | 2 +- known_good.json | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/SPIRV/SpvBuilder.cpp b/SPIRV/SpvBuilder.cpp index 42fca364..51c6bc21 100644 --- a/SPIRV/SpvBuilder.cpp +++ b/SPIRV/SpvBuilder.cpp @@ -1058,7 +1058,7 @@ Id Builder::makePointerDebugType(StorageClass storageClass, Id const baseType) return type->getResultId(); } -// Emit a OpExtInstWithForwardRefs nonsemantic instruction for a pointer debug type +// Emit a OpExtInstWithForwardRefsKHR nonsemantic instruction for a pointer debug type // where we don't have the pointee yet. Since we don't have the pointee yet, it just // points to itself and we rely on patching it later. Id Builder::makeForwardPointerDebugType(StorageClass storageClass) @@ -1067,7 +1067,7 @@ Id Builder::makeForwardPointerDebugType(StorageClass storageClass) this->addExtension(spv::E_SPV_KHR_relaxed_extended_instruction); - Instruction *type = new Instruction(getUniqueId(), makeVoidType(), OpExtInstWithForwardRefs); + Instruction *type = new Instruction(getUniqueId(), makeVoidType(), OpExtInstWithForwardRefsKHR); type->addIdOperand(nonSemanticShaderDebugInfo); type->addImmediateOperand(NonSemanticShaderDebugInfo100DebugTypePointer); type->addIdOperand(type->getResultId()); diff --git a/SPIRV/doc.cpp b/SPIRV/doc.cpp index 141fb5b7..de465e1d 100755 --- a/SPIRV/doc.cpp +++ b/SPIRV/doc.cpp @@ -1445,7 +1445,7 @@ const char* OpcodeString(int op) case 4429: return "OpSubgroupAnyKHR"; case 4430: return "OpSubgroupAllEqualKHR"; case 4432: return "OpSubgroupReadInvocationKHR"; - case 4433: return "OpExtInstWithForwardRefs"; + case 4433: return "OpExtInstWithForwardRefsKHR"; case OpGroupNonUniformQuadAllKHR: return "OpGroupNonUniformQuadAllKHR"; case OpGroupNonUniformQuadAnyKHR: return "OpGroupNonUniformQuadAnyKHR"; @@ -1897,9 +1897,9 @@ void Parameterize() InstructionDesc[OpExtInst].operands.push(OperandLiteralNumber, "'Instruction'"); InstructionDesc[OpExtInst].operands.push(OperandVariableIds, "'Operand 1', +\n'Operand 2', +\n..."); - InstructionDesc[OpExtInstWithForwardRefs].operands.push(OperandId, "'Set'"); - InstructionDesc[OpExtInstWithForwardRefs].operands.push(OperandLiteralNumber, "'Instruction'"); - InstructionDesc[OpExtInstWithForwardRefs].operands.push(OperandVariableIds, "'Operand 1', +\n'Operand 2', +\n..."); + InstructionDesc[OpExtInstWithForwardRefsKHR].operands.push(OperandId, "'Set'"); + InstructionDesc[OpExtInstWithForwardRefsKHR].operands.push(OperandLiteralNumber, "'Instruction'"); + InstructionDesc[OpExtInstWithForwardRefsKHR].operands.push(OperandVariableIds, "'Operand 1', +\n'Operand 2', +\n..."); InstructionDesc[OpLoad].operands.push(OperandId, "'Pointer'"); InstructionDesc[OpLoad].operands.push(OperandMemoryAccess, "", true); diff --git a/SPIRV/spirv.hpp b/SPIRV/spirv.hpp index 0d93ba96..bb3d715e 100644 --- a/SPIRV/spirv.hpp +++ b/SPIRV/spirv.hpp @@ -1668,7 +1668,7 @@ enum Op { OpSubgroupAllEqualKHR = 4430, OpGroupNonUniformRotateKHR = 4431, OpSubgroupReadInvocationKHR = 4432, - OpExtInstWithForwardRefs = 4433, + OpExtInstWithForwardRefsKHR = 4433, OpTraceRayKHR = 4445, OpExecuteCallableKHR = 4446, OpConvertUToAccelerationStructureKHR = 4447, @@ -2396,7 +2396,7 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) { case OpPtrEqual: *hasResult = true; *hasResultType = true; break; case OpPtrNotEqual: *hasResult = true; *hasResultType = true; break; case OpPtrDiff: *hasResult = true; *hasResultType = true; break; - case OpExtInstWithForwardRefs: *hasResult = true; *hasResultType = true; break; + case OpExtInstWithForwardRefsKHR: *hasResult = true; *hasResultType = true; break; case OpColorAttachmentReadEXT: *hasResult = true; *hasResultType = true; break; case OpDepthAttachmentReadEXT: *hasResult = true; *hasResultType = true; break; case OpStencilAttachmentReadEXT: *hasResult = true; *hasResultType = true; break; diff --git a/Test/baseResults/spv.debuginfo.bufferref.glsl.frag.out b/Test/baseResults/spv.debuginfo.bufferref.glsl.frag.out index 6b877bf5..c47f0e66 100644 --- a/Test/baseResults/spv.debuginfo.bufferref.glsl.frag.out +++ b/Test/baseResults/spv.debuginfo.bufferref.glsl.frag.out @@ -112,7 +112,7 @@ void main() { 17: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 20(DebugFunction) 16 6 18 20 12 21 16 13 20 TypeForwardPointer 28 PhysicalStorageBufferEXT 29: 7(int) Constant 5349 - 30: 4 ExtInstWithForwardRefs 1(NonSemantic.Shader.DebugInfo.100) 3 48 29 12 + 30: 4 ExtInstWithForwardRefsKHR 1(NonSemantic.Shader.DebugInfo.100) 3 48 29 12 31(Mesh): TypeStruct 28 34: 7(int) Constant 9 35: 7(int) Constant 23 diff --git a/known_good.json b/known_good.json index a87331c8..c6de6b18 100644 --- a/known_good.json +++ b/known_good.json @@ -5,14 +5,14 @@ "site" : "github", "subrepo" : "KhronosGroup/SPIRV-Tools", "subdir" : "External/spirv-tools", - "commit": "6a2bdeee75eb35e5349c6993d33c9afe30237d79" + "commit": "ce46482db7ab3ea9c52fce832d27ca40b14f8e87" }, { "name" : "spirv-tools/external/spirv-headers", "site" : "github", "subrepo" : "KhronosGroup/SPIRV-Headers", "subdir" : "External/spirv-tools/external/spirv-headers", - "commit" : "ff2afc3afc48dff4eec2a10f0212402a80708e38" + "commit" : "eb49bb7b1136298b77945c52b4bbbc433f7885de" }, { "name": "googletest", From d2b2a3d0577def276ff2805934b32893ef3e9a01 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Jun 2024 06:56:58 +0000 Subject: [PATCH 04/14] Bump lukka/get-cmake from 3.29.3 to 3.29.5 Bumps [lukka/get-cmake](https://github.com/lukka/get-cmake) from 3.29.3 to 3.29.5. - [Release notes](https://github.com/lukka/get-cmake/releases) - [Commits](https://github.com/lukka/get-cmake/compare/c57ffe818cee3ee5f08fc1cc78c8bbede1cbbe59...18d87816d12dd87ec1449d47b9b3a587e0a1cc19) --- updated-dependencies: - dependency-name: lukka/get-cmake dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/continuous_deployment.yml | 6 +++--- .github/workflows/continuous_integration.yml | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/continuous_deployment.yml b/.github/workflows/continuous_deployment.yml index cd106e15..aee4a305 100644 --- a/.github/workflows/continuous_deployment.yml +++ b/.github/workflows/continuous_deployment.yml @@ -42,7 +42,7 @@ jobs: cmake_build_type: [Debug, Release] steps: - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - - uses: lukka/get-cmake@c57ffe818cee3ee5f08fc1cc78c8bbede1cbbe59 # v3.29.3 + - uses: lukka/get-cmake@18d87816d12dd87ec1449d47b9b3a587e0a1cc19 # v3.29.5 - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 with: python-version: '3.7' @@ -106,7 +106,7 @@ jobs: cmake_build_type: [Debug, Release] steps: - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - - uses: lukka/get-cmake@c57ffe818cee3ee5f08fc1cc78c8bbede1cbbe59 # v3.29.3 + - uses: lukka/get-cmake@18d87816d12dd87ec1449d47b9b3a587e0a1cc19 # v3.29.5 - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 with: python-version: '3.7' @@ -163,7 +163,7 @@ jobs: cmake_build_type: [Debug, Release] steps: - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - - uses: lukka/get-cmake@c57ffe818cee3ee5f08fc1cc78c8bbede1cbbe59 # v3.29.3 + - uses: lukka/get-cmake@18d87816d12dd87ec1449d47b9b3a587e0a1cc19 # v3.29.5 - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 with: python-version: '3.7' diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index f93556f2..38ebdc0d 100644 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -18,7 +18,7 @@ jobs: cmake_build_type: [Debug, Release] steps: - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - - uses: lukka/get-cmake@c57ffe818cee3ee5f08fc1cc78c8bbede1cbbe59 # v3.29.3 + - uses: lukka/get-cmake@18d87816d12dd87ec1449d47b9b3a587e0a1cc19 # v3.29.5 - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 with: python-version: '3.7' @@ -54,7 +54,7 @@ jobs: flags: ['-fsanitize=address', '-fsanitize=thread'] steps: - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - - uses: lukka/get-cmake@c57ffe818cee3ee5f08fc1cc78c8bbede1cbbe59 # v3.29.3 + - uses: lukka/get-cmake@18d87816d12dd87ec1449d47b9b3a587e0a1cc19 # v3.29.5 - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 with: python-version: '3.7' @@ -95,7 +95,7 @@ jobs: - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 with: python-version: '3.7' - - uses: lukka/get-cmake@c57ffe818cee3ee5f08fc1cc78c8bbede1cbbe59 # v3.29.3 + - uses: lukka/get-cmake@18d87816d12dd87ec1449d47b9b3a587e0a1cc19 # v3.29.5 with: cmakeVersion: 3.17.2 - name: Setup ccache @@ -127,7 +127,7 @@ jobs: cmake_build_type: [Debug, Release] steps: - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - - uses: lukka/get-cmake@c57ffe818cee3ee5f08fc1cc78c8bbede1cbbe59 # v3.29.3 + - uses: lukka/get-cmake@18d87816d12dd87ec1449d47b9b3a587e0a1cc19 # v3.29.5 - run: ./update_glslang_sources.py - run: cmake -S . -B build -D CMAKE_BUILD_TYPE=${{matrix.cmake_build_type}} -G Ninja -DBUILD_WERROR=ON -D GLSLANG_TESTS=ON env: @@ -151,7 +151,7 @@ jobs: cmake_build_type: [Debug, Release] steps: - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - - uses: lukka/get-cmake@c57ffe818cee3ee5f08fc1cc78c8bbede1cbbe59 # v3.29.3 + - uses: lukka/get-cmake@18d87816d12dd87ec1449d47b9b3a587e0a1cc19 # v3.29.5 - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 with: python-version: '3.7' @@ -169,7 +169,7 @@ jobs: runs-on: macos-13 steps: - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - - uses: lukka/get-cmake@c57ffe818cee3ee5f08fc1cc78c8bbede1cbbe59 # v3.29.3 + - uses: lukka/get-cmake@18d87816d12dd87ec1449d47b9b3a587e0a1cc19 # v3.29.5 - name: Setup ccache uses: hendrikmuhs/ccache-action@c92f40bee50034e84c763e33b317c77adaa81c92 # v1.2.13 with: @@ -198,7 +198,7 @@ jobs: LEGACY: [ON, OFF] steps: - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - - uses: lukka/get-cmake@c57ffe818cee3ee5f08fc1cc78c8bbede1cbbe59 # v3.29.3 + - uses: lukka/get-cmake@18d87816d12dd87ec1449d47b9b3a587e0a1cc19 # v3.29.5 - name: Setup ccache uses: hendrikmuhs/ccache-action@c92f40bee50034e84c763e33b317c77adaa81c92 # v1.2.13 with: @@ -224,7 +224,7 @@ jobs: - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 with: python-version: '3.7' - - uses: lukka/get-cmake@c57ffe818cee3ee5f08fc1cc78c8bbede1cbbe59 # v3.29.3 + - uses: lukka/get-cmake@18d87816d12dd87ec1449d47b9b3a587e0a1cc19 # v3.29.5 - name: Setup ccache uses: hendrikmuhs/ccache-action@c92f40bee50034e84c763e33b317c77adaa81c92 # v1.2.13 with: From 68821c4da8189262228bbd51e56ed75971b2d2c9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Jun 2024 06:57:04 +0000 Subject: [PATCH 05/14] Bump github/codeql-action from 3.25.7 to 3.25.8 Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.25.7 to 3.25.8. - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/f079b8493333aace61c81488f8bd40919487bd9f...2e230e8fe0ad3a14a340ad0815ddb96d599d2aff) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/scorecard.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml index 1d6da9b1..3aa30b68 100644 --- a/.github/workflows/scorecard.yml +++ b/.github/workflows/scorecard.yml @@ -48,6 +48,6 @@ jobs: # Upload the results to GitHub's code scanning dashboard. - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@f079b8493333aace61c81488f8bd40919487bd9f # v3.25.7 + uses: github/codeql-action/upload-sarif@2e230e8fe0ad3a14a340ad0815ddb96d599d2aff # v3.25.8 with: sarif_file: results.sarif From 02263efcd602a255e3da13f46c873e2242ae2919 Mon Sep 17 00:00:00 2001 From: Pedro Olsen Ferreira Date: Fri, 7 Jun 2024 12:48:05 +0100 Subject: [PATCH 06/14] Add support for the ARM extended matrix layout --- SPIRV/GLSL.ext.EXT.h | 1 + SPIRV/GlslangToSpv.cpp | 12 + SPIRV/doc.cpp | 2 + SPIRV/spirv.hpp | 3 + .../spv.coopmat_armlayout.comp.out | 406 ++++++++++++++++++ Test/spv.coopmat_armlayout.comp | 121 ++++++ glslang/MachineIndependent/Initialize.cpp | 2 + gtests/Spv.FromFile.cpp | 1 + 8 files changed, 548 insertions(+) create mode 100644 Test/baseResults/spv.coopmat_armlayout.comp.out create mode 100644 Test/spv.coopmat_armlayout.comp diff --git a/SPIRV/GLSL.ext.EXT.h b/SPIRV/GLSL.ext.EXT.h index caab2793..07f3c302 100644 --- a/SPIRV/GLSL.ext.EXT.h +++ b/SPIRV/GLSL.ext.EXT.h @@ -41,5 +41,6 @@ static const char* const E_SPV_EXT_shader_atomic_float_min_max = "SPV_EXT_shader static const char* const E_SPV_EXT_shader_image_int64 = "SPV_EXT_shader_image_int64"; static const char* const E_SPV_EXT_shader_tile_image = "SPV_EXT_shader_tile_image"; static const char* const E_SPV_EXT_mesh_shader = "SPV_EXT_mesh_shader"; +static const char* const E_SPV_ARM_cooperative_matrix_layouts = "SPV_ARM_cooperative_matrix_layouts"; #endif // #ifndef GLSLextEXT_H diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp index 16e22466..0fd79b1a 100755 --- a/SPIRV/GlslangToSpv.cpp +++ b/SPIRV/GlslangToSpv.cpp @@ -3705,6 +3705,12 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt idImmOps.push_back(spv::IdImmediate(true, operands[1])); // buf if (node->getOp() == glslang::EOpCooperativeMatrixLoad) { idImmOps.push_back(spv::IdImmediate(true, operands[3])); // matrixLayout + auto layout = builder.getConstantScalar(operands[3]); + if (layout == spv::CooperativeMatrixLayoutRowBlockedInterleavedARM || + layout == spv::CooperativeMatrixLayoutColumnBlockedInterleavedARM) { + builder.addExtension(spv::E_SPV_ARM_cooperative_matrix_layouts); + builder.addCapability(spv::CapabilityCooperativeMatrixLayoutsARM); + } idImmOps.push_back(spv::IdImmediate(true, operands[2])); // stride } else { idImmOps.push_back(spv::IdImmediate(true, operands[2])); // stride @@ -3729,6 +3735,12 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt idImmOps.push_back(spv::IdImmediate(true, operands[0])); // object if (node->getOp() == glslang::EOpCooperativeMatrixStore) { idImmOps.push_back(spv::IdImmediate(true, operands[3])); // matrixLayout + auto layout = builder.getConstantScalar(operands[3]); + if (layout == spv::CooperativeMatrixLayoutRowBlockedInterleavedARM || + layout == spv::CooperativeMatrixLayoutColumnBlockedInterleavedARM) { + builder.addExtension(spv::E_SPV_ARM_cooperative_matrix_layouts); + builder.addCapability(spv::CapabilityCooperativeMatrixLayoutsARM); + } idImmOps.push_back(spv::IdImmediate(true, operands[2])); // stride } else { idImmOps.push_back(spv::IdImmediate(true, operands[2])); // stride diff --git a/SPIRV/doc.cpp b/SPIRV/doc.cpp index de465e1d..0105caa2 100755 --- a/SPIRV/doc.cpp +++ b/SPIRV/doc.cpp @@ -1035,6 +1035,8 @@ const char* CapabilityString(int info) case CapabilityTileImageDepthReadAccessEXT: return "TileImageDepthReadAccessEXT"; case CapabilityTileImageStencilReadAccessEXT: return "TileImageStencilReadAccessEXT"; + case CapabilityCooperativeMatrixLayoutsARM: return "CooperativeMatrixLayoutsARM"; + case CapabilityFragmentShadingRateKHR: return "FragmentShadingRateKHR"; case CapabilityDemoteToHelperInvocationEXT: return "DemoteToHelperInvocationEXT"; diff --git a/SPIRV/spirv.hpp b/SPIRV/spirv.hpp index bb3d715e..afa89a58 100644 --- a/SPIRV/spirv.hpp +++ b/SPIRV/spirv.hpp @@ -1002,6 +1002,7 @@ enum Capability { CapabilityTileImageColorReadAccessEXT = 4166, CapabilityTileImageDepthReadAccessEXT = 4167, CapabilityTileImageStencilReadAccessEXT = 4168, + CapabilityCooperativeMatrixLayoutsARM = 4201, CapabilityFragmentShadingRateKHR = 4422, CapabilitySubgroupBallotKHR = 4423, CapabilityDrawParameters = 4427, @@ -1302,6 +1303,8 @@ enum CooperativeMatrixOperandsMask { enum CooperativeMatrixLayout { CooperativeMatrixLayoutRowMajorKHR = 0, CooperativeMatrixLayoutColumnMajorKHR = 1, + CooperativeMatrixLayoutRowBlockedInterleavedARM = 4202, + CooperativeMatrixLayoutColumnBlockedInterleavedARM = 4203, CooperativeMatrixLayoutMax = 0x7fffffff, }; diff --git a/Test/baseResults/spv.coopmat_armlayout.comp.out b/Test/baseResults/spv.coopmat_armlayout.comp.out new file mode 100644 index 00000000..1af49f29 --- /dev/null +++ b/Test/baseResults/spv.coopmat_armlayout.comp.out @@ -0,0 +1,406 @@ +spv.coopmat_armlayout.comp +Validation failed +// Module Version 10000 +// Generated by (magic number): 8000b +// Id's are bound by 251 + + Capability Shader + Capability Float16 + Capability Int16 + Capability Int8 + Capability CooperativeMatrixLayoutsARM + Capability StorageUniformBufferBlock16 + Capability VulkanMemoryModelKHR + Capability PhysicalStorageBufferAddressesEXT + Capability CooperativeMatrixKHR + Extension "SPV_ARM_cooperative_matrix_layouts" + Extension "SPV_KHR_16bit_storage" + Extension "SPV_KHR_cooperative_matrix" + Extension "SPV_KHR_physical_storage_buffer" + Extension "SPV_KHR_storage_buffer_storage_class" + Extension "SPV_KHR_vulkan_memory_model" + 1: ExtInstImport "GLSL.std.450" + MemoryModel PhysicalStorageBuffer64EXT VulkanKHR + EntryPoint GLCompute 4 "main" + ExecutionMode 4 LocalSize 64 1 1 + Source GLSL 450 + SourceExtension "GL_EXT_buffer_reference" + SourceExtension "GL_EXT_shader_explicit_arithmetic_types" + SourceExtension "GL_KHR_cooperative_matrix" + SourceExtension "GL_KHR_memory_scope_semantics" + Name 4 "main" + Name 15 "f16(f161;" + Name 14 "m" + Name 22 "f32(f1;" + Name 21 "m" + Name 35 "m" + Name 53 "m2" + Name 57 "x" + Name 65 "tempArg" + Name 69 "Block" + MemberName 69(Block) 0 "y" + MemberName 69(Block) 1 "x" + Name 71 "block" + Name 81 "tempArg" + Name 86 "Block16" + MemberName 86(Block16) 0 "y" + MemberName 86(Block16) 1 "x" + MemberName 86(Block16) 2 "b" + Name 89 "Block" + MemberName 89(Block) 0 "y" + MemberName 89(Block) 1 "x" + Name 91 "block16" + Name 98 "tempArg" + Name 111 "D" + Name 115 "A" + Name 119 "B" + Name 121 "C" + Name 125 "l" + Name 129 "Y" + Name 130 "Z" + Name 133 "F" + Name 138 "a" + Name 142 "md1" + Name 153 "mC2" + Name 158 "tempArg" + Name 164 "tempArg" + Name 170 "p1" + Name 171 "param" + Name 174 "p2" + Name 175 "param" + Name 189 "tempArg" + Name 194 "shmatrix" + Name 198 "ms" + Name 205 "ms8A" + Name 209 "ms8B" + Name 213 "ms8C" + Name 228 "m16" + Name 234 "mC" + Name 235 "F" + Name 240 "S" + MemberName 240(S) 0 "a" + MemberName 240(S) 1 "b" + MemberName 240(S) 2 "c" + Name 245 "SC" + Name 250 "scm" + Decorate 67 ArrayStride 4 + Decorate 68 ArrayStride 4 + MemberDecorate 69(Block) 0 Offset 0 + MemberDecorate 69(Block) 1 Offset 4194304 + Decorate 69(Block) Block + Decorate 71(block) DescriptorSet 0 + Decorate 71(block) Binding 0 + Decorate 82 ArrayStride 2 + Decorate 84 ArrayStride 2 + MemberDecorate 86(Block16) 0 Offset 0 + MemberDecorate 86(Block16) 1 Offset 2097152 + MemberDecorate 86(Block16) 2 Offset 2097160 + Decorate 86(Block16) Block + Decorate 87 ArrayStride 4 + Decorate 88 ArrayStride 4 + MemberDecorate 89(Block) 0 Offset 0 + MemberDecorate 89(Block) 1 Offset 4194304 + Decorate 89(Block) Block + Decorate 91(block16) DescriptorSet 0 + Decorate 91(block16) Binding 0 + Decorate 129(Y) SpecId 0 + Decorate 233 BuiltIn WorkgroupSize + Decorate 235(F) SpecId 1 + Decorate 245(SC) SpecId 2 + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeFloat 16 + 7: TypeInt 32 0 + 8: 7(int) Constant 3 + 9: 7(int) Constant 8 + 10: 7(int) Constant 2 + 11: TypeCooperativeMatrixKHR 6(float16_t) 8 9 9 10 + 12: TypePointer Function 11 + 13: TypeFunction 11 12(ptr) + 17: TypeFloat 32 + 18: TypeCooperativeMatrixKHR 17(float) 8 9 9 10 + 19: TypePointer Function 18 + 20: TypeFunction 18 19(ptr) + 32: 7(int) Constant 16 + 33: TypeCooperativeMatrixKHR 17(float) 8 32 9 10 + 34: TypePointer Function 33 + 36: 17(float) Constant 0 + 37: 33 ConstantComposite 36 + 46: 17(float) Constant 1073741824 + 51: TypeCooperativeMatrixKHR 6(float16_t) 8 32 9 10 + 52: TypePointer Function 51 + 56: TypePointer Function 17(float) + 58: TypeInt 32 1 + 59: 58(int) Constant 1 + 62: 58(int) Constant 0 + 66: 7(int) Constant 1048576 + 67: TypeArray 17(float) 66 + 68: TypeRuntimeArray 17(float) + 69(Block): TypeStruct 67 68 + 70: TypePointer StorageBuffer 69(Block) + 71(block): 70(ptr) Variable StorageBuffer + 72: 7(int) Constant 5 + 73: TypePointer StorageBuffer 17(float) + 75: 7(int) Constant 128 + 76: 58(int) Constant 4202 + 82: TypeArray 6(float16_t) 66 + 83: 7(int) Constant 1 + 84: TypeArray 6(float16_t) 83 + TypeForwardPointer 85 PhysicalStorageBufferEXT + 86(Block16): TypeStruct 82 84 85 + 87: TypeArray 17(float) 66 + 88: TypeRuntimeArray 17(float) + 89(Block): TypeStruct 87 88 + 85: TypePointer PhysicalStorageBufferEXT 89(Block) + 90: TypePointer StorageBuffer 86(Block16) + 91(block16): 90(ptr) Variable StorageBuffer + 92: TypePointer StorageBuffer 6(float16_t) + 99: 58(int) Constant 2 + 100: TypePointer StorageBuffer 85(ptr) + 103: TypePointer PhysicalStorageBufferEXT 17(float) + 112: 7(int) Constant 0 + 113: TypeCooperativeMatrixKHR 6(float16_t) 8 32 9 112 + 114: TypePointer Function 113 + 117: TypeCooperativeMatrixKHR 6(float16_t) 8 9 9 83 + 118: TypePointer Function 117 + 124: TypePointer Function 58(int) + 128: 58(int) Constant 8 + 129(Y): 58(int) SpecConstant 2 + 130(Z): 58(int) SpecConstantOp 132 128 129(Y) + 131: TypeCooperativeMatrixKHR 6(float16_t) 8 130(Z) 130(Z) 10 + 132: TypePointer Function 131 + 134:6(float16_t) Constant 0 + 135: 131 ConstantComposite 134 + 136: TypeArray 33 72 + 137: TypePointer Function 136 + 139: 58(int) Constant 3 + 140: 17(float) Constant 1065353216 + 146: 58(int) Constant 1234 + 150: TypeCooperativeMatrixKHR 6(float16_t) 8 130(Z) 9 10 + 151: TypeArray 150 8 + 152: TypePointer Private 151 + 153(mC2): 152(ptr) Variable Private + 154: TypePointer Private 150 + 178: 11 ConstantComposite 134 + 179: 18 ConstantComposite 36 + 183:6(float16_t) Constant 16384 + 186: 17(float) Constant 1082130432 + 190: TypeVector 7(int) 4 + 191: 7(int) Constant 32 + 192: TypeArray 190(ivec4) 191 + 193: TypePointer Workgroup 192 + 194(shmatrix): 193(ptr) Variable Workgroup + 195: TypePointer Workgroup 190(ivec4) + 202: TypeInt 8 1 + 203: TypeCooperativeMatrixKHR 202(int8_t) 8 9 9 112 + 204: TypePointer Function 203 + 207: TypeCooperativeMatrixKHR 202(int8_t) 8 9 9 83 + 208: TypePointer Function 207 + 211: TypeCooperativeMatrixKHR 202(int8_t) 8 9 9 10 + 212: TypePointer Function 211 + 223: 58(int) Constant 16 + 225: TypeInt 16 1 + 226: TypeCooperativeMatrixKHR 225(int16_t) 8 9 9 112 + 227: TypePointer Function 226 + 231: TypeVector 7(int) 3 + 232: 7(int) Constant 64 + 233: 231(ivec3) ConstantComposite 232 83 83 + 234(mC): 154(ptr) Variable Private + 235(F): 17(float) SpecConstant 1077936128 + 236: TypeCooperativeMatrixKHR 17(float) 8 130(Z) 9 10 + 237: 236 ConstantComposite 36 + 238:6(float16_t) Constant 15360 + 239: 11 ConstantComposite 238 + 240(S): TypeStruct 58(int) 58(int) 58(int) + 241: 58(int) Constant 12 + 242: 58(int) Constant 23 + 243: 58(int) Constant 34 + 244: 240(S) ConstantComposite 241 242 243 + 245(SC): 58(int) SpecConstant 1 + 246: TypeCooperativeMatrixKHR 6(float16_t) 8 245(SC) 245(SC) 10 + 247: TypeArray 246 245(SC) + 248: TypeArray 247 245(SC) + 249: TypePointer Private 248 + 250(scm): 249(ptr) Variable Private + 4(main): 2 Function None 3 + 5: Label + 35(m): 34(ptr) Variable Function + 53(m2): 52(ptr) Variable Function + 57(x): 56(ptr) Variable Function + 65(tempArg): 34(ptr) Variable Function + 81(tempArg): 52(ptr) Variable Function + 98(tempArg): 34(ptr) Variable Function + 111(D): 34(ptr) Variable Function + 115(A): 114(ptr) Variable Function + 119(B): 118(ptr) Variable Function + 121(C): 34(ptr) Variable Function + 125(l): 124(ptr) Variable Function + 133(F): 132(ptr) Variable Function + 138(a): 137(ptr) Variable Function + 142(md1): 56(ptr) Variable Function + 158(tempArg): 34(ptr) Variable Function + 164(tempArg): 52(ptr) Variable Function + 170(p1): 12(ptr) Variable Function + 171(param): 12(ptr) Variable Function + 174(p2): 19(ptr) Variable Function + 175(param): 19(ptr) Variable Function + 189(tempArg): 52(ptr) Variable Function + 198(ms): 52(ptr) Variable Function + 205(ms8A): 204(ptr) Variable Function + 209(ms8B): 208(ptr) Variable Function + 213(ms8C): 212(ptr) Variable Function + 228(m16): 227(ptr) Variable Function + Store 35(m) 37 + 38: 33 Load 35(m) + 39: 33 Load 35(m) + 40: 33 FAdd 38 39 + Store 35(m) 40 + 41: 33 Load 35(m) + 42: 33 Load 35(m) + 43: 33 FSub 41 42 + Store 35(m) 43 + 44: 33 Load 35(m) + 45: 33 FNegate 44 + Store 35(m) 45 + 47: 33 Load 35(m) + 48: 33 MatrixTimesScalar 47 46 + Store 35(m) 48 + 49: 33 Load 35(m) + 50: 33 MatrixTimesScalar 49 46 + Store 35(m) 50 + 54: 33 Load 35(m) + 55: 51 FConvert 54 + Store 53(m2) 55 + 60: 56(ptr) AccessChain 35(m) 59 + 61: 17(float) Load 60 + Store 57(x) 61 + 63: 17(float) Load 57(x) + 64: 56(ptr) AccessChain 35(m) 62 + Store 64 63 + 74: 73(ptr) AccessChain 71(block) 59 32 + 77: 33 CooperativeMatrixLoadKHR 74 76 75 MakePointerVisibleKHR NonPrivatePointerKHR 72 + Store 65(tempArg) 77 + 78: 33 Load 65(tempArg) + Store 35(m) 78 + 79: 33 Load 35(m) + 80: 73(ptr) AccessChain 71(block) 59 32 + CooperativeMatrixStoreKHR 80 79 76 75 MakePointerAvailableKHR NonPrivatePointerKHR 72 + 93: 92(ptr) AccessChain 91(block16) 59 32 + 94: 51 CooperativeMatrixLoadKHR 93 76 75 MakePointerVisibleKHR NonPrivatePointerKHR 72 + Store 81(tempArg) 94 + 95: 51 Load 81(tempArg) + Store 53(m2) 95 + 96: 51 Load 53(m2) + 97: 92(ptr) AccessChain 91(block16) 59 32 + CooperativeMatrixStoreKHR 97 96 76 75 MakePointerAvailableKHR NonPrivatePointerKHR 72 + 101: 100(ptr) AccessChain 91(block16) 99 + 102: 85(ptr) Load 101 MakePointerVisibleKHR NonPrivatePointerKHR 72 + 104: 103(ptr) AccessChain 102 59 32 + 105: 33 CooperativeMatrixLoadKHR 104 76 75 Aligned MakePointerVisibleKHR NonPrivatePointerKHR 16 72 + Store 98(tempArg) 105 + 106: 33 Load 98(tempArg) + Store 35(m) 106 + 107: 33 Load 35(m) + 108: 100(ptr) AccessChain 91(block16) 99 + 109: 85(ptr) Load 108 MakePointerVisibleKHR NonPrivatePointerKHR 72 + 110: 103(ptr) AccessChain 109 59 32 + CooperativeMatrixStoreKHR 110 107 76 75 Aligned MakePointerAvailableKHR NonPrivatePointerKHR 16 72 + 116: 113 Load 115(A) + 120: 117 Load 119(B) + 122: 33 Load 121(C) + 123: 33 CooperativeMatrixMulAddKHR 116 120 122 + Store 111(D) 123 + 126: 7(int) CooperativeMatrixLengthKHR 33 + 127: 58(int) Bitcast 126 + Store 125(l) 127 + Store 133(F) 135 + 141: 56(ptr) AccessChain 138(a) 139 62 + Store 141 140 + Store 142(md1) 36 + 143: 33 Load 35(m) + 144: 33 Load 35(m) + 145: 33 FAdd 144 143 + Store 35(m) 145 + 147: 17(float) CompositeExtract 145 1234 + 148: 17(float) Load 142(md1) + 149: 17(float) FAdd 148 147 + Store 142(md1) 149 + 155: 154(ptr) AccessChain 153(mC2) 99 + 156: 150 Load 155 + 157: 154(ptr) AccessChain 153(mC2) 59 + Store 157 156 + 159: 73(ptr) AccessChain 71(block) 62 32 + 160: 33 CooperativeMatrixLoadKHR 159 76 75 MakePointerVisibleKHR NonPrivatePointerKHR 72 + Store 158(tempArg) 160 + 161: 33 Load 158(tempArg) + Store 35(m) 161 + 162: 33 Load 35(m) + 163: 73(ptr) AccessChain 71(block) 62 32 + CooperativeMatrixStoreKHR 163 162 76 75 MakePointerAvailableKHR NonPrivatePointerKHR 72 + 165: 92(ptr) AccessChain 91(block16) 62 32 + 166: 51 CooperativeMatrixLoadKHR 165 76 75 MakePointerVisibleKHR NonPrivatePointerKHR 72 + Store 164(tempArg) 166 + 167: 51 Load 164(tempArg) + Store 53(m2) 167 + 168: 51 Load 53(m2) + 169: 92(ptr) AccessChain 91(block16) 62 32 + CooperativeMatrixStoreKHR 169 168 76 75 MakePointerAvailableKHR NonPrivatePointerKHR 72 + 172: 11 Load 170(p1) + Store 171(param) 172 + 173: 11 FunctionCall 15(f16(f161;) 171(param) + Store 170(p1) 173 + 176: 18 Load 174(p2) + Store 175(param) 176 + 177: 18 FunctionCall 22(f32(f1;) 175(param) + Store 174(p2) 177 + Store 170(p1) 178 + Store 174(p2) 179 + 180: 11 Load 170(p1) + 181: 11 Load 170(p1) + 182: 11 FDiv 181 180 + Store 170(p1) 182 + 184: 11 Load 170(p1) + 185: 11 MatrixTimesScalar 184 183 + Store 170(p1) 185 + 187: 18 Load 174(p2) + 188: 18 MatrixTimesScalar 187 186 + Store 174(p2) 188 + 196: 195(ptr) AccessChain 194(shmatrix) 83 + 197: 51 CooperativeMatrixLoadKHR 196 76 10 MakePointerVisibleKHR NonPrivatePointerKHR 10 + Store 189(tempArg) 197 + 199: 51 Load 189(tempArg) + Store 198(ms) 199 + 200: 51 Load 198(ms) + 201: 195(ptr) AccessChain 194(shmatrix) 83 + CooperativeMatrixStoreKHR 201 200 76 10 MakePointerAvailableKHR NonPrivatePointerKHR 10 + 206: 203 Load 205(ms8A) + 210: 207 Load 209(ms8B) + 214: 211 Load 213(ms8C) + 215: 211 CooperativeMatrixMulAddKHR 206 210 214 ASignedComponentsKHR BSignedComponentsKHR CSignedComponentsKHR ResultSignedComponentsKHR + 216: 203 Load 205(ms8A) + 217: 207 Load 209(ms8B) + 218: 211 Load 213(ms8C) + 219: 211 CooperativeMatrixMulAddKHR 216 217 218 ASignedComponentsKHR BSignedComponentsKHR CSignedComponentsKHR ResultSignedComponentsKHR + 220: 203 Load 205(ms8A) + 221: 207 Load 209(ms8B) + 222: 211 Load 213(ms8C) + 224: 211 CooperativeMatrixMulAddKHR 220 221 222 ASignedComponentsKHR BSignedComponentsKHR CSignedComponentsKHR ResultSignedComponentsKHR SaturatingAccumulationKHR + 229: 226 Load 228(m16) + 230: 195(ptr) AccessChain 194(shmatrix) 83 + CooperativeMatrixStoreKHR 230 229 76 10 MakePointerAvailableKHR NonPrivatePointerKHR 10 + Return + FunctionEnd + 15(f16(f161;): 11 Function None 13 + 14(m): 12(ptr) FunctionParameter + 16: Label + 24: 11 Load 14(m) + 25: 11 FNegate 24 + ReturnValue 25 + FunctionEnd + 22(f32(f1;): 18 Function None 20 + 21(m): 19(ptr) FunctionParameter + 23: Label + 28: 18 Load 21(m) + 29: 18 FNegate 28 + ReturnValue 29 + FunctionEnd diff --git a/Test/spv.coopmat_armlayout.comp b/Test/spv.coopmat_armlayout.comp new file mode 100644 index 00000000..b63ea5e7 --- /dev/null +++ b/Test/spv.coopmat_armlayout.comp @@ -0,0 +1,121 @@ +#version 450 core +#extension GL_KHR_memory_scope_semantics : enable +#extension GL_KHR_cooperative_matrix : enable +#extension GL_EXT_shader_explicit_arithmetic_types : enable +#extension GL_EXT_buffer_reference : enable + +layout (local_size_x = 64, local_size_y = 1, local_size_z = 1) in; + +const int X = 8; +layout(constant_id = 0) const int Y = 2; +const int Z = X*Y; + +coopmat mC; +coopmat mC2[3]; + +layout(constant_id = 1) const float F = 3.0; + +const coopmat mD = coopmat(0.0); +const coopmat mD2 = coopmat(1); + +struct S { int a; int b; int c; }; + +const S s = S(12, 23, 34); + +layout(set = 0, binding = 0, buffer_reference) coherent buffer Block { + float y[1024*1024]; + float x[]; +} block; + +layout(set = 0, binding = 0) coherent buffer Block16 { + float16_t y[1024*1024]; + float16_t x[]; + + Block b; +} block16; + +coopmat f16(coopmat m) { return -m; } +coopmat f32(coopmat m) { return -m; } + +layout(constant_id = 2) const int SC = 1; +coopmat scm[SC][SC]; + +// sized for coopmat +shared uvec4 shmatrix[16*16*2/16]; + +void main() +{ + coopmat1?8:4), gl_MatrixUseAccumulator> m = coopmat1?8:4), gl_MatrixUseAccumulator>(0.0); + + m = m + m; + m = m - m; + m = -m; + m = 2.0*m; + m = m*2.0; + + coopmat m2 = coopmat(m); + + float x = m[1]; + m[0] = x; + + coopMatLoad(m, block.x, 16, 128, gl_CooperativeMatrixLayoutRowBlockedInterleavedARM); + coopMatStore(m, block.x, 16, 128, gl_CooperativeMatrixLayoutRowBlockedInterleavedARM); + coopMatLoad(m2, block16.x, 16, 128, gl_CooperativeMatrixLayoutRowBlockedInterleavedARM); + coopMatStore(m2, block16.x, 16, 128, gl_CooperativeMatrixLayoutRowBlockedInterleavedARM); + coopMatLoad(m, block16.b.x, 16, 128, gl_CooperativeMatrixLayoutRowBlockedInterleavedARM); + coopMatStore(m, block16.b.x, 16, 128, gl_CooperativeMatrixLayoutRowBlockedInterleavedARM); + + coopmat A; + coopmat B; + coopmat C; + coopmat D; + D = coopMatMulAdd(A, B, C); + + int l = D.length(); + + coopmat E; + + coopmat F = coopmat(0.0); + + coopmat1?8:4), gl_MatrixUseAccumulator> a[5]; + a[3][0] = 1.0; + + float md1 = mD[1]; + + md1 += (m += m)[1234]; + + mC2[1] = mC2[2]; + + coopMatLoad(m, block.y, 16, 128, gl_CooperativeMatrixLayoutRowBlockedInterleavedARM); + coopMatStore(m, block.y, 16, 128, gl_CooperativeMatrixLayoutRowBlockedInterleavedARM); + coopMatLoad(m2, block16.y, 16, 128, gl_CooperativeMatrixLayoutRowBlockedInterleavedARM); + coopMatStore(m2, block16.y, 16, 128, gl_CooperativeMatrixLayoutRowBlockedInterleavedARM); + + coopmat p1; + coopmat p2; + + p1 = f16(p1); + p2 = f32(p2); + + p1 = coopmat(0.0); + p2 = coopmat(0.0); + + p1 /= p1; + + p1 *= float16_t(2.0); + p2 *= 4.0; + + coopmat ms; + coopMatLoad(ms, shmatrix, 1, 2, gl_CooperativeMatrixLayoutRowBlockedInterleavedARM); + coopMatStore(ms, shmatrix, 1, 2, gl_CooperativeMatrixLayoutRowBlockedInterleavedARM); + + coopmat ms8A; + coopmat ms8B; + coopmat ms8C; + coopMatMulAdd(ms8A, ms8B, ms8C); + coopMatMulAdd(ms8A, ms8B, ms8C, 0); + coopMatMulAdd(ms8A, ms8B, ms8C, gl_MatrixOperandsSaturatingAccumulation); + + coopmat m16; + coopMatStore(m16, shmatrix, 1, 2, gl_CooperativeMatrixLayoutRowBlockedInterleavedARM); +} diff --git a/glslang/MachineIndependent/Initialize.cpp b/glslang/MachineIndependent/Initialize.cpp index a6ec6897..d8a969d7 100755 --- a/glslang/MachineIndependent/Initialize.cpp +++ b/glslang/MachineIndependent/Initialize.cpp @@ -4558,6 +4558,8 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV "const int gl_MatrixOperandsSaturatingAccumulation = 0x10;\n" "const int gl_CooperativeMatrixLayoutRowMajor = 0;\n" "const int gl_CooperativeMatrixLayoutColumnMajor = 1;\n" + "const int gl_CooperativeMatrixLayoutRowBlockedInterleavedARM = 4202;\n" + "const int gl_CooperativeMatrixLayoutColumnBlockedInterleavedARM = 4203;\n" "\n" ); } diff --git a/gtests/Spv.FromFile.cpp b/gtests/Spv.FromFile.cpp index b1279932..4ea2485c 100644 --- a/gtests/Spv.FromFile.cpp +++ b/gtests/Spv.FromFile.cpp @@ -367,6 +367,7 @@ INSTANTIATE_TEST_SUITE_P( "spv.coopmat.comp", "spv.coopmat_Error.comp", "spv.coopmatKHR.comp", + "spv.coopmat_armlayout.comp", "spv.coopmatKHR_arithmetic.comp", "spv.coopmatKHR_arithmeticError.comp", "spv.coopmatKHR_Error.comp", From a92c61f8456fa9731c0b000a2c6fc52a740c2be7 Mon Sep 17 00:00:00 2001 From: AnyOldName3 Date: Wed, 14 Feb 2024 16:38:44 +0000 Subject: [PATCH 07/14] Add aliases for the public libraries This makes things consistent between when glslang is installed and imported versus when it's included as nested CMake project. You can now use `glslang::glslang` in both cases instead of needing the non-namespaced version sometimes and the namespaced one other times. Resolves one of the problems discussed in https://github.com/KhronosGroup/glslang/issues/3509 --- SPIRV/CMakeLists.txt | 2 ++ glslang/CMakeLists.txt | 2 ++ 2 files changed, 4 insertions(+) diff --git a/SPIRV/CMakeLists.txt b/SPIRV/CMakeLists.txt index 3b6bfb45..66808812 100644 --- a/SPIRV/CMakeLists.txt +++ b/SPIRV/CMakeLists.txt @@ -79,6 +79,7 @@ set(PUBLIC_HEADERS SPVRemapper.h) add_library(SPIRV ${LIB_TYPE} ${SOURCES} ${HEADERS}) +add_library(glslang::SPIRV ALIAS SPIRV) set_target_properties(SPIRV PROPERTIES FOLDER glslang POSITION_INDEPENDENT_CODE ON @@ -92,6 +93,7 @@ glslang_add_build_info_dependency(SPIRV) if (ENABLE_SPVREMAPPER) add_library(SPVRemapper ${LIB_TYPE} ${SPVREMAP_SOURCES} ${SPVREMAP_HEADERS}) + add_library(glslang::SPVRemapper ALIAS SPVRemapper) set_target_properties(SPVRemapper PROPERTIES FOLDER glslang POSITION_INDEPENDENT_CODE ON diff --git a/glslang/CMakeLists.txt b/glslang/CMakeLists.txt index e4690f09..8d4b1e9c 100644 --- a/glslang/CMakeLists.txt +++ b/glslang/CMakeLists.txt @@ -169,6 +169,7 @@ set(GLSLANG_HEADERS Include/Types.h) add_library(glslang ${LIB_TYPE} ${GLSLANG_SOURCES} ${GLSLANG_HEADERS}) +add_library(glslang::glslang ALIAS glslang) set_target_properties(glslang PROPERTIES FOLDER glslang POSITION_INDEPENDENT_CODE ON @@ -201,6 +202,7 @@ set(RESOURCELIMITS_HEADERS ) add_library(glslang-default-resource-limits ${RESOURCELIMITS_SOURCES} ${RESOURCELIMITS_HEADERS}) +add_library(glslang::glslang-default-resource-limits ALIAS glslang-default-resource-limits) set_target_properties(glslang-default-resource-limits PROPERTIES VERSION "${GLSLANG_VERSION}" SOVERSION "${GLSLANG_VERSION_MAJOR}" From d8f5681ec0bbf48384f6c96e837214abba34f0b8 Mon Sep 17 00:00:00 2001 From: Qingyuan Zheng Date: Fri, 1 Mar 2024 13:09:15 -0800 Subject: [PATCH 08/14] Add includer to gtest for include file tests. Turn on debug info flag for non-semantic debug test. --- Test/baseResults/spv.debugInfo.1.1.frag.out | 422 ------------------ Test/baseResults/spv.debugInfo.frag.out | 19 +- .../spv.debuginfo.include.glsl.frag.out | 166 +++++++ Test/runtests | 6 - Test/spv.debugInfo.frag | 164 +++---- Test/spv.debuginfo.include.glsl.frag | 12 + Test/spv.debuginfo.include.glsl.h | 10 + gtests/Spv.FromFile.cpp | 51 +-- gtests/TestFixture.h | 40 +- 9 files changed, 338 insertions(+), 552 deletions(-) delete mode 100644 Test/baseResults/spv.debugInfo.1.1.frag.out create mode 100644 Test/baseResults/spv.debuginfo.include.glsl.frag.out create mode 100644 Test/spv.debuginfo.include.glsl.frag create mode 100644 Test/spv.debuginfo.include.glsl.h diff --git a/Test/baseResults/spv.debugInfo.1.1.frag.out b/Test/baseResults/spv.debugInfo.1.1.frag.out deleted file mode 100644 index 12726756..00000000 --- a/Test/baseResults/spv.debugInfo.1.1.frag.out +++ /dev/null @@ -1,422 +0,0 @@ -spv.debugInfo.frag -// Module Version 10300 -// Generated by (magic number): 8000b -// Id's are bound by 187 - - Capability Shader - 2: ExtInstImport "GLSL.std.450" - MemoryModel Logical GLSL450 - EntryPoint Fragment 5 "main" 30 104 - ExecutionMode 5 OriginUpperLeft - 1: String "spv.debugInfo.frag" - Source GLSL 450 1 "#version 450 - -struct S { - int a; -}; - -uniform ubuf { - S s; -}; - -uniform sampler2D s2d; - -layout(location = 0) in vec4 inv; -layout(location = 0) out vec4 outv; - -vec4 foo(S s) -{ - vec4 r = s.a * inv; - ++r; - if (r.x > 3.0) - --r; - else - r *= 2; - - return r; -} - -float testBranch(float x, float y) -{ - float result = 0; - bool b = x > 0; - - // branch with load - if (b) { - result += 1; - } - else { - result -= 1; - } - - // branch with expression - if (x > y) { - result += x - y; - } - - // selection with load - result += b ? - 1 : -1; - - // selection with expression - result += x < y ? - y : - float(b); - - return result; -} - -void main() -{ - outv = foo(s); - outv += testBranch(inv.x, inv.y); - outv += texture(s2d, vec2(0.5)); - - switch (s.a) { - case 10: - ++outv; - break; - case 20: - outv = 2 * outv; - ++outv; - break; - default: - --outv; - break; - } - - for (int i = 0; i < 10; ++i) - outv *= 3.0; - - outv.x < 10.0 ? - outv = sin(outv) : - outv = cos(outv); -}" - Name 5 "main" - Name 8 "S" - MemberName 8(S) 0 "a" - Name 14 "foo(struct-S-i11;" - Name 13 "s" - Name 20 "testBranch(f1;f1;" - Name 18 "x" - Name 19 "y" - Name 23 "r" - Name 30 "inv" - Name 56 "result" - Name 59 "b" - Name 104 "outv" - Name 105 "S" - MemberName 105(S) 0 "a" - Name 106 "ubuf" - MemberName 106(ubuf) 0 "s" - Name 108 "" - Name 109 "param" - Name 116 "param" - Name 120 "param" - Name 131 "s2d" - Name 161 "i" - ModuleProcessed "no-storage-format" - ModuleProcessed "resource-set-binding 3" - ModuleProcessed "auto-map-bindings" - ModuleProcessed "auto-map-locations" - ModuleProcessed "client vulkan100" - ModuleProcessed "target-env spirv1.3" - ModuleProcessed "target-env vulkan1.1" - ModuleProcessed "relaxed-errors" - ModuleProcessed "suppress-warnings" - ModuleProcessed "hlsl-offsets" - ModuleProcessed "entry-point main" - Decorate 30(inv) Location 0 - Decorate 104(outv) Location 0 - MemberDecorate 105(S) 0 Offset 0 - MemberDecorate 106(ubuf) 0 Offset 0 - Decorate 106(ubuf) Block - Decorate 108 DescriptorSet 3 - Decorate 108 Binding 0 - Decorate 131(s2d) DescriptorSet 3 - Decorate 131(s2d) Binding 1 - 3: TypeVoid - 4: TypeFunction 3 - 7: TypeInt 32 1 - 8(S): TypeStruct 7(int) - 9: TypePointer Function 8(S) - 10: TypeFloat 32 - 11: TypeVector 10(float) 4 - 12: TypeFunction 11(fvec4) 9(ptr) - 16: TypePointer Function 10(float) - 17: TypeFunction 10(float) 16(ptr) 16(ptr) - 22: TypePointer Function 11(fvec4) - 24: 7(int) Constant 0 - 25: TypePointer Function 7(int) - 29: TypePointer Input 11(fvec4) - 30(inv): 29(ptr) Variable Input - 34: 10(float) Constant 1065353216 - 37: TypeInt 32 0 - 38: 37(int) Constant 0 - 41: 10(float) Constant 1077936128 - 42: TypeBool - 50: 10(float) Constant 1073741824 - 57: 10(float) Constant 0 - 58: TypePointer Function 42(bool) - 81: 7(int) Constant 1 - 82: 7(int) Constant 4294967295 - 103: TypePointer Output 11(fvec4) - 104(outv): 103(ptr) Variable Output - 105(S): TypeStruct 7(int) - 106(ubuf): TypeStruct 105(S) - 107: TypePointer Uniform 106(ubuf) - 108: 107(ptr) Variable Uniform - 110: TypePointer Uniform 105(S) - 117: TypePointer Input 10(float) - 121: 37(int) Constant 1 - 128: TypeImage 10(float) 2D sampled format:Unknown - 129: TypeSampledImage 128 - 130: TypePointer UniformConstant 129 - 131(s2d): 130(ptr) Variable UniformConstant - 133: TypeVector 10(float) 2 - 134: 10(float) Constant 1056964608 - 135: 133(fvec2) ConstantComposite 134 134 - 139: TypePointer Uniform 7(int) - 168: 7(int) Constant 10 - 174: TypePointer Output 10(float) - 177: 10(float) Constant 1092616192 - Line 1 58 11 - 5(main): 3 Function None 4 - 6: Label - 109(param): 9(ptr) Variable Function - 116(param): 16(ptr) Variable Function - 120(param): 16(ptr) Variable Function - 161(i): 25(ptr) Variable Function - 179: 22(ptr) Variable Function - Line 1 60 0 - 111: 110(ptr) AccessChain 108 24 - 112: 105(S) Load 111 - 113: 7(int) CompositeExtract 112 0 - 114: 25(ptr) AccessChain 109(param) 24 - Store 114 113 - 115: 11(fvec4) FunctionCall 14(foo(struct-S-i11;) 109(param) - Store 104(outv) 115 - Line 1 61 0 - 118: 117(ptr) AccessChain 30(inv) 38 - 119: 10(float) Load 118 - Store 116(param) 119 - 122: 117(ptr) AccessChain 30(inv) 121 - 123: 10(float) Load 122 - Store 120(param) 123 - 124: 10(float) FunctionCall 20(testBranch(f1;f1;) 116(param) 120(param) - 125: 11(fvec4) Load 104(outv) - 126: 11(fvec4) CompositeConstruct 124 124 124 124 - 127: 11(fvec4) FAdd 125 126 - Store 104(outv) 127 - Line 1 62 0 - 132: 129 Load 131(s2d) - 136: 11(fvec4) ImageSampleImplicitLod 132 135 - 137: 11(fvec4) Load 104(outv) - 138: 11(fvec4) FAdd 137 136 - Store 104(outv) 138 - Line 1 64 0 - 140: 139(ptr) AccessChain 108 24 24 - 141: 7(int) Load 140 - SelectionMerge 145 None - Switch 141 144 - case 10: 142 - case 20: 143 - 144: Label - Line 1 73 0 - 156: 11(fvec4) Load 104(outv) - 157: 11(fvec4) CompositeConstruct 34 34 34 34 - 158: 11(fvec4) FSub 156 157 - Store 104(outv) 158 - Line 1 74 0 - Branch 145 - 142: Label - Line 1 66 0 - 146: 11(fvec4) Load 104(outv) - 147: 11(fvec4) CompositeConstruct 34 34 34 34 - 148: 11(fvec4) FAdd 146 147 - Store 104(outv) 148 - Line 1 67 0 - Branch 145 - 143: Label - Line 1 69 0 - 150: 11(fvec4) Load 104(outv) - 151: 11(fvec4) VectorTimesScalar 150 50 - Store 104(outv) 151 - Line 1 70 0 - 152: 11(fvec4) Load 104(outv) - 153: 11(fvec4) CompositeConstruct 34 34 34 34 - 154: 11(fvec4) FAdd 152 153 - Store 104(outv) 154 - Line 1 71 0 - Branch 145 - 145: Label - Line 1 77 0 - Store 161(i) 24 - Branch 162 - 162: Label - Line 1 77 0 - LoopMerge 164 165 None - Branch 166 - 166: Label - Line 1 77 0 - 167: 7(int) Load 161(i) - 169: 42(bool) SLessThan 167 168 - BranchConditional 169 163 164 - 163: Label - Line 1 78 0 - 170: 11(fvec4) Load 104(outv) - 171: 11(fvec4) VectorTimesScalar 170 41 - Store 104(outv) 171 - Branch 165 - 165: Label - Line 1 77 0 - 172: 7(int) Load 161(i) - 173: 7(int) IAdd 172 81 - Store 161(i) 173 - Branch 162 - 164: Label - Line 1 80 0 - 175: 174(ptr) AccessChain 104(outv) 38 - 176: 10(float) Load 175 - 178: 42(bool) FOrdLessThan 176 177 - SelectionMerge 181 None - BranchConditional 178 180 184 - 180: Label - Line 1 81 0 - 182: 11(fvec4) Load 104(outv) - 183: 11(fvec4) ExtInst 2(GLSL.std.450) 13(Sin) 182 - Store 104(outv) 183 - Store 179 183 - Branch 181 - 184: Label - Line 1 82 0 - 185: 11(fvec4) Load 104(outv) - 186: 11(fvec4) ExtInst 2(GLSL.std.450) 14(Cos) 185 - Store 104(outv) 186 - Store 179 186 - Branch 181 - 181: Label - Return - FunctionEnd - Line 1 16 13 -14(foo(struct-S-i11;): 11(fvec4) Function None 12 - 13(s): 9(ptr) FunctionParameter - 15: Label - 23(r): 22(ptr) Variable Function - Line 1 18 0 - 26: 25(ptr) AccessChain 13(s) 24 - 27: 7(int) Load 26 - 28: 10(float) ConvertSToF 27 - 31: 11(fvec4) Load 30(inv) - 32: 11(fvec4) VectorTimesScalar 31 28 - Store 23(r) 32 - Line 1 19 0 - 33: 11(fvec4) Load 23(r) - 35: 11(fvec4) CompositeConstruct 34 34 34 34 - 36: 11(fvec4) FAdd 33 35 - Store 23(r) 36 - Line 1 20 0 - 39: 16(ptr) AccessChain 23(r) 38 - 40: 10(float) Load 39 - 43: 42(bool) FOrdGreaterThan 40 41 - SelectionMerge 45 None - BranchConditional 43 44 49 - 44: Label - Line 1 21 0 - 46: 11(fvec4) Load 23(r) - 47: 11(fvec4) CompositeConstruct 34 34 34 34 - 48: 11(fvec4) FSub 46 47 - Store 23(r) 48 - Branch 45 - 49: Label - Line 1 23 0 - 51: 11(fvec4) Load 23(r) - 52: 11(fvec4) VectorTimesScalar 51 50 - Store 23(r) 52 - Branch 45 - 45: Label - Line 1 25 0 - 53: 11(fvec4) Load 23(r) - ReturnValue 53 - FunctionEnd - Line 1 28 34 -20(testBranch(f1;f1;): 10(float) Function None 17 - 18(x): 16(ptr) FunctionParameter - 19(y): 16(ptr) FunctionParameter - 21: Label - 56(result): 16(ptr) Variable Function - 59(b): 58(ptr) Variable Function - 90: 16(ptr) Variable Function - Line 1 30 0 - Store 56(result) 57 - Line 1 31 0 - 60: 10(float) Load 18(x) - 61: 42(bool) FOrdGreaterThan 60 57 - Store 59(b) 61 - Line 1 34 0 - 62: 42(bool) Load 59(b) - SelectionMerge 64 None - BranchConditional 62 63 67 - 63: Label - Line 1 35 0 - 65: 10(float) Load 56(result) - 66: 10(float) FAdd 65 34 - Store 56(result) 66 - Branch 64 - 67: Label - Line 1 38 0 - 68: 10(float) Load 56(result) - 69: 10(float) FSub 68 34 - Store 56(result) 69 - Branch 64 - 64: Label - Line 1 42 0 - 70: 10(float) Load 18(x) - 71: 10(float) Load 19(y) - 72: 42(bool) FOrdGreaterThan 70 71 - SelectionMerge 74 None - BranchConditional 72 73 74 - 73: Label - Line 1 43 0 - 75: 10(float) Load 18(x) - 76: 10(float) Load 19(y) - 77: 10(float) FSub 75 76 - 78: 10(float) Load 56(result) - 79: 10(float) FAdd 78 77 - Store 56(result) 79 - Branch 74 - 74: Label - Line 1 47 0 - 80: 42(bool) Load 59(b) - 83: 7(int) Select 80 81 82 - 84: 10(float) ConvertSToF 83 - 85: 10(float) Load 56(result) - 86: 10(float) FAdd 85 84 - Store 56(result) 86 - Line 1 51 0 - 87: 10(float) Load 18(x) - 88: 10(float) Load 19(y) - 89: 42(bool) FOrdLessThan 87 88 - SelectionMerge 92 None - BranchConditional 89 91 94 - 91: Label - Line 1 52 0 - 93: 10(float) Load 19(y) - Store 90 93 - Branch 92 - 94: Label - Line 1 53 0 - 95: 42(bool) Load 59(b) - 96: 10(float) Select 95 34 57 - Store 90 96 - Branch 92 - 92: Label - 97: 10(float) Load 90 - Line 1 51 0 - 98: 10(float) Load 56(result) - 99: 10(float) FAdd 98 97 - Store 56(result) 99 - Line 1 55 0 - 100: 10(float) Load 56(result) - ReturnValue 100 - FunctionEnd diff --git a/Test/baseResults/spv.debugInfo.frag.out b/Test/baseResults/spv.debugInfo.frag.out index 8bacd74d..475187d9 100644 --- a/Test/baseResults/spv.debugInfo.frag.out +++ b/Test/baseResults/spv.debugInfo.frag.out @@ -7,17 +7,13 @@ spv.debugInfo.frag 2: ExtInstImport "GLSL.std.450" MemoryModel Logical GLSL450 EntryPoint Fragment 5 "main" 30 104 - ExecutionMode 5 OriginLowerLeft + ExecutionMode 5 OriginUpperLeft 1: String "spv.debugInfo.frag" - Source GLSL 450 1 "// OpModuleProcessed no-storage-format -// OpModuleProcessed resource-set-binding 3 + Source GLSL 450 1 "// OpModuleProcessed auto-map-locations // OpModuleProcessed auto-map-bindings -// OpModuleProcessed auto-map-locations -// OpModuleProcessed client opengl100 -// OpModuleProcessed target-env opengl -// OpModuleProcessed relaxed-errors -// OpModuleProcessed suppress-warnings -// OpModuleProcessed hlsl-offsets +// OpModuleProcessed client vulkan100 +// OpModuleProcessed target-env vulkan1.0 +// OpModuleProcessed keep-uncalled // OpModuleProcessed entry-point main #line 1 #version 450 @@ -131,10 +127,9 @@ void main() MemberDecorate 105(S) 0 Offset 0 MemberDecorate 106(ubuf) 0 Offset 0 Decorate 106(ubuf) Block - Decorate 108 DescriptorSet 3 + Decorate 108 DescriptorSet 0 Decorate 108 Binding 0 - Decorate 131(s2d) Location 0 - Decorate 131(s2d) DescriptorSet 3 + Decorate 131(s2d) DescriptorSet 0 Decorate 131(s2d) Binding 1 3: TypeVoid 4: TypeFunction 3 diff --git a/Test/baseResults/spv.debuginfo.include.glsl.frag.out b/Test/baseResults/spv.debuginfo.include.glsl.frag.out new file mode 100644 index 00000000..22453950 --- /dev/null +++ b/Test/baseResults/spv.debuginfo.include.glsl.frag.out @@ -0,0 +1,166 @@ +spv.debuginfo.include.glsl.frag +// Module Version 10000 +// Generated by (magic number): 8000b +// Id's are bound by 109 + + Capability Shader + Extension "SPV_KHR_non_semantic_info" + 1: ExtInstImport "NonSemantic.Shader.DebugInfo.100" + 4: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Fragment 15 "main" 81 + ExecutionMode 15 OriginUpperLeft + 2: String "spv.debuginfo.include.glsl.frag" + 3: String "spv.debuginfo.include.glsl.h" + 9: String "uint" + 18: String "float" + 31: String "headerFunction" + 34: String "// OpModuleProcessed auto-map-locations +// OpModuleProcessed auto-map-bindings +// OpModuleProcessed client vulkan100 +// OpModuleProcessed target-env vulkan1.0 +// OpModuleProcessed keep-uncalled +// OpModuleProcessed entry-point main +#line 1 +#version 450 + +#extension GL_GOOGLE_include_directive : require +#include "spv.debuginfo.include.glsl.h" + +vec4 mainFileFunction(vec4 v) { + return -v; +} + +void main() { + headerOut = headerFunction(mainFileFunction(headerUboItem)); +}" + 40: String "a" + 48: String "mainFileFunction" + 51: String "v" + 54: String "main" + 60: String " +out vec4 headerOut; + +uniform UBO { + vec4 headerUboItem; +}; + +vec4 headerFunction(vec4 a) { + return -a; +}" + 83: String "headerOut" + 87: String "headerUboItem" + 90: String "UBO" + 95: String "" + 97: String "int" + SourceExtension "GL_GOOGLE_cpp_style_line_directive" + SourceExtension "GL_GOOGLE_include_directive" + Name 15 "main" + Name 29 "headerFunction(vf4;" + Name 28 "a" + Name 46 "mainFileFunction(vf4;" + Name 45 "v" + Name 81 "headerOut" + Name 85 "UBO" + MemberName 85(UBO) 0 "headerUboItem" + Name 93 "" + Name 100 "param" + Name 107 "param" + Decorate 81(headerOut) Location 0 + MemberDecorate 85(UBO) 0 Offset 0 + Decorate 85(UBO) Block + Decorate 93 DescriptorSet 0 + Decorate 93 Binding 0 + 5: TypeVoid + 6: TypeFunction 5 + 8: TypeInt 32 0 + 11: 8(int) Constant 32 + 12: 8(int) Constant 6 + 13: 8(int) Constant 0 + 10: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 2(DebugTypeBasic) 9 11 12 13 + 14: 8(int) Constant 3 + 7: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 8(DebugTypeFunction) 14 5 + 17: TypeFloat 32 + 19: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 2(DebugTypeBasic) 18 11 14 13 + 20: TypeVector 17(float) 4 + 21: 8(int) Constant 4 + 22: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 6(DebugTypeVector) 19 21 + 23: TypePointer Function 20(fvec4) + 24: 8(int) Constant 7 + 25: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 3(DebugTypePointer) 22 24 13 + 26: TypeFunction 20(fvec4) 23(ptr) + 27: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 8(DebugTypeFunction) 14 22 22 + 33: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 35(DebugSource) 2 34 + 35: 8(int) Constant 8 + 37: 8(int) Constant 1 + 38: 8(int) Constant 2 + 36: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 1(DebugCompilationUnit) 37 21 33 38 + 32: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 20(DebugFunction) 31 27 33 35 13 36 31 14 35 + 39: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 26(DebugLocalVariable) 40 22 33 35 13 32 21 37 + 42: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 31(DebugExpression) + 49: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 20(DebugFunction) 48 27 33 12 13 36 48 14 12 + 50: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 26(DebugLocalVariable) 51 22 33 12 13 49 21 37 + 56: 8(int) Constant 10 + 55: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 20(DebugFunction) 54 7 33 56 13 36 54 14 56 + 59: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 35(DebugSource) 3 60 + 63: 8(int) Constant 9 + 79: TypePointer Output 20(fvec4) + 80: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 3(DebugTypePointer) 22 14 13 + 81(headerOut): 79(ptr) Variable Output + 84: 8(int) Constant 11 + 82: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 18(DebugGlobalVariable) 83 22 33 84 13 36 83 81(headerOut) 35 + 85(UBO): TypeStruct 20(fvec4) + 88: 8(int) Constant 5 + 86: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 11(DebugTypeMember) 87 22 33 88 24 13 13 14 + 89: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 10(DebugTypeComposite) 90 37 33 84 13 36 90 13 14 86 + 91: TypePointer Uniform 85(UBO) + 92: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 3(DebugTypePointer) 89 38 13 + 93: 91(ptr) Variable Uniform + 94: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 18(DebugGlobalVariable) 95 89 33 84 13 36 95 93 35 + 96: TypeInt 32 1 + 98: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 2(DebugTypeBasic) 97 11 21 13 + 99: 96(int) Constant 0 + 101: TypePointer Uniform 20(fvec4) + 102: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 3(DebugTypePointer) 22 38 13 + 15(main): 5 Function None 6 + 16: Label + 100(param): 23(ptr) Variable Function + 107(param): 23(ptr) Variable Function + 77: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 55 + 78: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 33 56 56 13 13 + 76: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 101(DebugFunctionDefinition) 55 15(main) + 104: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 33 84 84 13 13 + 103: 101(ptr) AccessChain 93 99 + 105: 20(fvec4) Load 103 + Store 100(param) 105 + 106: 20(fvec4) FunctionCall 46(mainFileFunction(vf4;) 100(param) + Store 107(param) 106 + 108: 20(fvec4) FunctionCall 29(headerFunction(vf4;) 107(param) + Store 81(headerOut) 108 + Return + FunctionEnd +29(headerFunction(vf4;): 20(fvec4) Function None 26 + 28(a): 23(ptr) FunctionParameter + 30: Label + 43: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 32 + 44: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 33 35 35 13 13 + 41: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 28(DebugDeclare) 39 28(a) 42 + 58: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 59 35 35 13 13 + 57: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 101(DebugFunctionDefinition) 32 29(headerFunction(vf4;) + 62: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 59 63 63 13 13 + 61: 20(fvec4) Load 28(a) + 64: 20(fvec4) FNegate 61 + ReturnValue 64 + FunctionEnd +46(mainFileFunction(vf4;): 20(fvec4) Function None 26 + 45(v): 23(ptr) FunctionParameter + 47: Label + 53: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 49 + 52: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 28(DebugDeclare) 50 45(v) 42 + 69: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 33 12 12 13 13 + 68: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 101(DebugFunctionDefinition) 49 46(mainFileFunction(vf4;) + 71: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 33 24 24 13 13 + 70: 20(fvec4) Load 45(v) + 72: 20(fvec4) FNegate 70 + ReturnValue 72 + FunctionEnd diff --git a/Test/runtests b/Test/runtests index 00c2babd..52898e06 100755 --- a/Test/runtests +++ b/Test/runtests @@ -169,12 +169,6 @@ diff -b $BASEDIR/spv.looseUniformNoLoc.vert.out "$TARGETDIR/spv.looseUniformNoLo # Testing debug information # echo Testing SPV Debug Information -run -g --relaxed-errors --suppress-warnings --aml --amb --hlsl-offsets --nsf --spirv-val \ - -G -H spv.debugInfo.frag --rsb frag 3 > "$TARGETDIR/spv.debugInfo.frag.out" -diff -b $BASEDIR/spv.debugInfo.frag.out "$TARGETDIR/spv.debugInfo.frag.out" || HASERROR=1 -run -g -Od --target-env vulkan1.1 --relaxed-errors --suppress-warnings --aml --amb --hlsl-offsets --nsf --spirv-val \ - -V -H spv.debugInfo.frag --rsb frag 3 > "$TARGETDIR/spv.debugInfo.1.1.frag.out" -diff -b $BASEDIR/spv.debugInfo.1.1.frag.out "$TARGETDIR/spv.debugInfo.1.1.frag.out" || HASERROR=1 run -g -D -Od -e newMain -g --amb --aml --fua --hlsl-iomap --nsf --spirv-val --sib 1 --ssb 2 --sbb 3 --stb 4 --suavb 5 --sub 6 \ --sep origMain -H -Od spv.hlslDebugInfo.vert --rsb vert t0 0 0 > "$TARGETDIR/spv.hlslDebugInfo.frag.out" diff -b $BASEDIR/spv.hlslDebugInfo.frag.out "$TARGETDIR/spv.hlslDebugInfo.frag.out" || HASERROR=1 diff --git a/Test/spv.debugInfo.frag b/Test/spv.debugInfo.frag index 31b63341..5bcf87fa 100644 --- a/Test/spv.debugInfo.frag +++ b/Test/spv.debugInfo.frag @@ -1,83 +1,83 @@ -#version 450 - -struct S { - int a; -}; - -uniform ubuf { - S s; -}; - -uniform sampler2D s2d; - -layout(location = 0) in vec4 inv; -layout(location = 0) out vec4 outv; - -vec4 foo(S s) -{ - vec4 r = s.a * inv; - ++r; - if (r.x > 3.0) - --r; - else - r *= 2; - - return r; -} - -float testBranch(float x, float y) -{ - float result = 0; - bool b = x > 0; - - // branch with load - if (b) { - result += 1; - } - else { - result -= 1; - } - - // branch with expression - if (x > y) { - result += x - y; - } - - // selection with load - result += b ? - 1 : -1; - - // selection with expression - result += x < y ? - y : - float(b); - - return result; -} - -void main() -{ - outv = foo(s); - outv += testBranch(inv.x, inv.y); - outv += texture(s2d, vec2(0.5)); - - switch (s.a) { - case 10: - ++outv; - break; - case 20: - outv = 2 * outv; - ++outv; - break; - default: - --outv; - break; - } - - for (int i = 0; i < 10; ++i) - outv *= 3.0; - - outv.x < 10.0 ? - outv = sin(outv) : - outv = cos(outv); +#version 450 + +struct S { + int a; +}; + +uniform ubuf { + S s; +}; + +uniform sampler2D s2d; + +layout(location = 0) in vec4 inv; +layout(location = 0) out vec4 outv; + +vec4 foo(S s) +{ + vec4 r = s.a * inv; + ++r; + if (r.x > 3.0) + --r; + else + r *= 2; + + return r; +} + +float testBranch(float x, float y) +{ + float result = 0; + bool b = x > 0; + + // branch with load + if (b) { + result += 1; + } + else { + result -= 1; + } + + // branch with expression + if (x > y) { + result += x - y; + } + + // selection with load + result += b ? + 1 : -1; + + // selection with expression + result += x < y ? + y : + float(b); + + return result; +} + +void main() +{ + outv = foo(s); + outv += testBranch(inv.x, inv.y); + outv += texture(s2d, vec2(0.5)); + + switch (s.a) { + case 10: + ++outv; + break; + case 20: + outv = 2 * outv; + ++outv; + break; + default: + --outv; + break; + } + + for (int i = 0; i < 10; ++i) + outv *= 3.0; + + outv.x < 10.0 ? + outv = sin(outv) : + outv = cos(outv); } \ No newline at end of file diff --git a/Test/spv.debuginfo.include.glsl.frag b/Test/spv.debuginfo.include.glsl.frag new file mode 100644 index 00000000..f2c95a3e --- /dev/null +++ b/Test/spv.debuginfo.include.glsl.frag @@ -0,0 +1,12 @@ +#version 450 + +#extension GL_GOOGLE_include_directive : require +#include "spv.debuginfo.include.glsl.h" + +vec4 mainFileFunction(vec4 v) { + return -v; +} + +void main() { + headerOut = headerFunction(mainFileFunction(headerUboItem)); +} \ No newline at end of file diff --git a/Test/spv.debuginfo.include.glsl.h b/Test/spv.debuginfo.include.glsl.h new file mode 100644 index 00000000..51df8469 --- /dev/null +++ b/Test/spv.debuginfo.include.glsl.h @@ -0,0 +1,10 @@ + +out vec4 headerOut; + +uniform UBO { + vec4 headerUboItem; +}; + +vec4 headerFunction(vec4 a) { + return -a; +} \ No newline at end of file diff --git a/gtests/Spv.FromFile.cpp b/gtests/Spv.FromFile.cpp index 4ea2485c..627b3aa4 100644 --- a/gtests/Spv.FromFile.cpp +++ b/gtests/Spv.FromFile.cpp @@ -67,7 +67,6 @@ std::string FileNameAsCustomTestSuffixIoMap( using CompileVulkanToSpirvTest = GlslangTest<::testing::TestWithParam>; using CompileVulkanToSpirvTestNoLink = GlslangTest<::testing::TestWithParam>; using CompileVulkanToSpirvDeadCodeElimTest = GlslangTest<::testing::TestWithParam>; -using CompileVulkanToDebugSpirvTest = GlslangTest<::testing::TestWithParam>; using CompileVulkan1_1ToSpirvTest = GlslangTest<::testing::TestWithParam>; using CompileToSpirv14Test = GlslangTest<::testing::TestWithParam>; using CompileToSpirv16Test = GlslangTest<::testing::TestWithParam>; @@ -82,7 +81,8 @@ using CompileVulkanToSpirvTestAMD = GlslangTest<::testing::TestWithParam>; using CompileVulkanToSpirv14TestNV = GlslangTest<::testing::TestWithParam>; using CompileUpgradeTextureToSampledTextureAndDropSamplersTest = GlslangTest<::testing::TestWithParam>; -using CompileVulkanToNonSemanticShaderDebugInfoTest = GlslangTest<::testing::TestWithParam>; +using GlslSpirvDebugInfoTest = GlslangTest<::testing::TestWithParam>; +using GlslNonSemanticShaderDebugInfoTest = GlslangTest<::testing::TestWithParam>; // Compiling GLSL to SPIR-V under Vulkan semantics. Expected to successfully // generate SPIR-V. @@ -110,17 +110,6 @@ TEST_P(CompileVulkanToSpirvDeadCodeElimTest, FromFile) Target::Spv); } -// Compiling GLSL to SPIR-V with debug info under Vulkan semantics. Expected -// to successfully generate SPIR-V. -TEST_P(CompileVulkanToDebugSpirvTest, FromFile) -{ - loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(), - Source::GLSL, Semantics::Vulkan, - glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0, - Target::Spv, true, "", - "/baseResults/", false, true); -} - TEST_P(CompileVulkan1_1ToSpirvTest, FromFile) { @@ -251,11 +240,18 @@ TEST_P(CompileUpgradeTextureToSampledTextureAndDropSamplersTest, FromFile) Target::Spv); } -TEST_P(CompileVulkanToNonSemanticShaderDebugInfoTest, FromFile) +TEST_P(GlslSpirvDebugInfoTest, FromFile) { - loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(), - Source::GLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0, - Target::Spv, true, "", "/baseResults/", false, true, true); + loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(), Source::GLSL, Semantics::Vulkan, + glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0, Target::Spv, true, "", + "/baseResults/", false, true, false); +} + +TEST_P(GlslNonSemanticShaderDebugInfoTest, FromFile) +{ + loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(), Source::GLSL, Semantics::Vulkan, + glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0, Target::Spv, true, "", + "/baseResults/", false, true, true); } // clang-format off @@ -584,15 +580,6 @@ INSTANTIATE_TEST_SUITE_P( FileNameAsCustomTestSuffix ); -// clang-format off -INSTANTIATE_TEST_SUITE_P( - Glsl, CompileVulkanToDebugSpirvTest, - ::testing::ValuesIn(std::vector({ - "spv.pp.line.frag", - })), - FileNameAsCustomTestSuffix -); - // clang-format off INSTANTIATE_TEST_SUITE_P( Glsl, CompileVulkan1_1ToSpirvTest, @@ -945,7 +932,16 @@ INSTANTIATE_TEST_SUITE_P( ); INSTANTIATE_TEST_SUITE_P( - Glsl, CompileVulkanToNonSemanticShaderDebugInfoTest, + Glsl, GlslSpirvDebugInfoTest, + ::testing::ValuesIn(std::vector({ + "spv.pp.line.frag", + "spv.debugInfo.frag", + })), + FileNameAsCustomTestSuffix +); + +INSTANTIATE_TEST_SUITE_P( + Glsl, GlslNonSemanticShaderDebugInfoTest, ::testing::ValuesIn(std::vector({ "spv.debuginfo.glsl.vert", "spv.debuginfo.glsl.frag", @@ -957,6 +953,7 @@ INSTANTIATE_TEST_SUITE_P( "spv.debuginfo.const_params.glsl.comp", "spv.debuginfo.scalar_types.glsl.frag", "spv.debuginfo.rt_types.glsl.rgen", + "spv.debuginfo.include.glsl.frag", })), FileNameAsCustomTestSuffix ); diff --git a/gtests/TestFixture.h b/gtests/TestFixture.h index b23ba304..315fdaec 100644 --- a/gtests/TestFixture.h +++ b/gtests/TestFixture.h @@ -35,6 +35,7 @@ #ifndef GLSLANG_GTESTS_TEST_FIXTURE_H #define GLSLANG_GTESTS_TEST_FIXTURE_H +#include #include #include #include @@ -199,9 +200,42 @@ public: } else shader->setStringsWithLengths(&shaderStrings, &shaderLengths, 1); if (!entryPointName.empty()) shader->setEntryPoint(entryPointName.c_str()); - return shader->parse( - (resources ? resources : GetDefaultResources()), - defaultVersion, isForwardCompatible, controls); + + // A includer that always assumes header name is a relative path to the test folder. + class GlslangTestIncluder : public glslang::TShader::Includer { + public: + virtual IncludeResult* includeLocal(const char* headerName, const char* /*includerName*/, + size_t /*inclusionDepth*/) override + { + std::string path = GLSLANG_TEST_DIRECTORY; + path += '/'; + path += headerName; + std::replace(path.begin(), path.end(), '\\', '/'); + + auto [success, fileContent] = ReadFile(path); + if (success) { + auto buffer = new char[fileContent.size() + 1]; + std::copy(fileContent.begin(), fileContent.end(), buffer); + buffer[fileContent.size()] = '\0'; + + return new IncludeResult(headerName, buffer, fileContent.size(), buffer); + } + + return nullptr; + } + + virtual void releaseInclude(IncludeResult* result) override + { + if (result != nullptr) { + delete[] static_cast(result->userData); + delete result; + } + } + }; + + GlslangTestIncluder includer; + return shader->parse((resources ? resources : GetDefaultResources()), defaultVersion, isForwardCompatible, + controls, includer); } // Compiles and links the given source |code| of the given shader From 19efb4ec60febf569ad3cf2f2fd71bbd20ff4617 Mon Sep 17 00:00:00 2001 From: Arcady Goldmints-Orlov Date: Fri, 14 Jun 2024 18:17:21 -0400 Subject: [PATCH 09/14] Move the spv.debugInfo.frag test back into runtests --- Test/baseResults/spv.debugInfo.1.1.frag.out | 422 ++++++++++++++++++++ Test/baseResults/spv.debugInfo.frag.out | 19 +- Test/runtests | 6 + gtests/Spv.FromFile.cpp | 1 - 4 files changed, 440 insertions(+), 8 deletions(-) create mode 100644 Test/baseResults/spv.debugInfo.1.1.frag.out diff --git a/Test/baseResults/spv.debugInfo.1.1.frag.out b/Test/baseResults/spv.debugInfo.1.1.frag.out new file mode 100644 index 00000000..12726756 --- /dev/null +++ b/Test/baseResults/spv.debugInfo.1.1.frag.out @@ -0,0 +1,422 @@ +spv.debugInfo.frag +// Module Version 10300 +// Generated by (magic number): 8000b +// Id's are bound by 187 + + Capability Shader + 2: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Fragment 5 "main" 30 104 + ExecutionMode 5 OriginUpperLeft + 1: String "spv.debugInfo.frag" + Source GLSL 450 1 "#version 450 + +struct S { + int a; +}; + +uniform ubuf { + S s; +}; + +uniform sampler2D s2d; + +layout(location = 0) in vec4 inv; +layout(location = 0) out vec4 outv; + +vec4 foo(S s) +{ + vec4 r = s.a * inv; + ++r; + if (r.x > 3.0) + --r; + else + r *= 2; + + return r; +} + +float testBranch(float x, float y) +{ + float result = 0; + bool b = x > 0; + + // branch with load + if (b) { + result += 1; + } + else { + result -= 1; + } + + // branch with expression + if (x > y) { + result += x - y; + } + + // selection with load + result += b ? + 1 : -1; + + // selection with expression + result += x < y ? + y : + float(b); + + return result; +} + +void main() +{ + outv = foo(s); + outv += testBranch(inv.x, inv.y); + outv += texture(s2d, vec2(0.5)); + + switch (s.a) { + case 10: + ++outv; + break; + case 20: + outv = 2 * outv; + ++outv; + break; + default: + --outv; + break; + } + + for (int i = 0; i < 10; ++i) + outv *= 3.0; + + outv.x < 10.0 ? + outv = sin(outv) : + outv = cos(outv); +}" + Name 5 "main" + Name 8 "S" + MemberName 8(S) 0 "a" + Name 14 "foo(struct-S-i11;" + Name 13 "s" + Name 20 "testBranch(f1;f1;" + Name 18 "x" + Name 19 "y" + Name 23 "r" + Name 30 "inv" + Name 56 "result" + Name 59 "b" + Name 104 "outv" + Name 105 "S" + MemberName 105(S) 0 "a" + Name 106 "ubuf" + MemberName 106(ubuf) 0 "s" + Name 108 "" + Name 109 "param" + Name 116 "param" + Name 120 "param" + Name 131 "s2d" + Name 161 "i" + ModuleProcessed "no-storage-format" + ModuleProcessed "resource-set-binding 3" + ModuleProcessed "auto-map-bindings" + ModuleProcessed "auto-map-locations" + ModuleProcessed "client vulkan100" + ModuleProcessed "target-env spirv1.3" + ModuleProcessed "target-env vulkan1.1" + ModuleProcessed "relaxed-errors" + ModuleProcessed "suppress-warnings" + ModuleProcessed "hlsl-offsets" + ModuleProcessed "entry-point main" + Decorate 30(inv) Location 0 + Decorate 104(outv) Location 0 + MemberDecorate 105(S) 0 Offset 0 + MemberDecorate 106(ubuf) 0 Offset 0 + Decorate 106(ubuf) Block + Decorate 108 DescriptorSet 3 + Decorate 108 Binding 0 + Decorate 131(s2d) DescriptorSet 3 + Decorate 131(s2d) Binding 1 + 3: TypeVoid + 4: TypeFunction 3 + 7: TypeInt 32 1 + 8(S): TypeStruct 7(int) + 9: TypePointer Function 8(S) + 10: TypeFloat 32 + 11: TypeVector 10(float) 4 + 12: TypeFunction 11(fvec4) 9(ptr) + 16: TypePointer Function 10(float) + 17: TypeFunction 10(float) 16(ptr) 16(ptr) + 22: TypePointer Function 11(fvec4) + 24: 7(int) Constant 0 + 25: TypePointer Function 7(int) + 29: TypePointer Input 11(fvec4) + 30(inv): 29(ptr) Variable Input + 34: 10(float) Constant 1065353216 + 37: TypeInt 32 0 + 38: 37(int) Constant 0 + 41: 10(float) Constant 1077936128 + 42: TypeBool + 50: 10(float) Constant 1073741824 + 57: 10(float) Constant 0 + 58: TypePointer Function 42(bool) + 81: 7(int) Constant 1 + 82: 7(int) Constant 4294967295 + 103: TypePointer Output 11(fvec4) + 104(outv): 103(ptr) Variable Output + 105(S): TypeStruct 7(int) + 106(ubuf): TypeStruct 105(S) + 107: TypePointer Uniform 106(ubuf) + 108: 107(ptr) Variable Uniform + 110: TypePointer Uniform 105(S) + 117: TypePointer Input 10(float) + 121: 37(int) Constant 1 + 128: TypeImage 10(float) 2D sampled format:Unknown + 129: TypeSampledImage 128 + 130: TypePointer UniformConstant 129 + 131(s2d): 130(ptr) Variable UniformConstant + 133: TypeVector 10(float) 2 + 134: 10(float) Constant 1056964608 + 135: 133(fvec2) ConstantComposite 134 134 + 139: TypePointer Uniform 7(int) + 168: 7(int) Constant 10 + 174: TypePointer Output 10(float) + 177: 10(float) Constant 1092616192 + Line 1 58 11 + 5(main): 3 Function None 4 + 6: Label + 109(param): 9(ptr) Variable Function + 116(param): 16(ptr) Variable Function + 120(param): 16(ptr) Variable Function + 161(i): 25(ptr) Variable Function + 179: 22(ptr) Variable Function + Line 1 60 0 + 111: 110(ptr) AccessChain 108 24 + 112: 105(S) Load 111 + 113: 7(int) CompositeExtract 112 0 + 114: 25(ptr) AccessChain 109(param) 24 + Store 114 113 + 115: 11(fvec4) FunctionCall 14(foo(struct-S-i11;) 109(param) + Store 104(outv) 115 + Line 1 61 0 + 118: 117(ptr) AccessChain 30(inv) 38 + 119: 10(float) Load 118 + Store 116(param) 119 + 122: 117(ptr) AccessChain 30(inv) 121 + 123: 10(float) Load 122 + Store 120(param) 123 + 124: 10(float) FunctionCall 20(testBranch(f1;f1;) 116(param) 120(param) + 125: 11(fvec4) Load 104(outv) + 126: 11(fvec4) CompositeConstruct 124 124 124 124 + 127: 11(fvec4) FAdd 125 126 + Store 104(outv) 127 + Line 1 62 0 + 132: 129 Load 131(s2d) + 136: 11(fvec4) ImageSampleImplicitLod 132 135 + 137: 11(fvec4) Load 104(outv) + 138: 11(fvec4) FAdd 137 136 + Store 104(outv) 138 + Line 1 64 0 + 140: 139(ptr) AccessChain 108 24 24 + 141: 7(int) Load 140 + SelectionMerge 145 None + Switch 141 144 + case 10: 142 + case 20: 143 + 144: Label + Line 1 73 0 + 156: 11(fvec4) Load 104(outv) + 157: 11(fvec4) CompositeConstruct 34 34 34 34 + 158: 11(fvec4) FSub 156 157 + Store 104(outv) 158 + Line 1 74 0 + Branch 145 + 142: Label + Line 1 66 0 + 146: 11(fvec4) Load 104(outv) + 147: 11(fvec4) CompositeConstruct 34 34 34 34 + 148: 11(fvec4) FAdd 146 147 + Store 104(outv) 148 + Line 1 67 0 + Branch 145 + 143: Label + Line 1 69 0 + 150: 11(fvec4) Load 104(outv) + 151: 11(fvec4) VectorTimesScalar 150 50 + Store 104(outv) 151 + Line 1 70 0 + 152: 11(fvec4) Load 104(outv) + 153: 11(fvec4) CompositeConstruct 34 34 34 34 + 154: 11(fvec4) FAdd 152 153 + Store 104(outv) 154 + Line 1 71 0 + Branch 145 + 145: Label + Line 1 77 0 + Store 161(i) 24 + Branch 162 + 162: Label + Line 1 77 0 + LoopMerge 164 165 None + Branch 166 + 166: Label + Line 1 77 0 + 167: 7(int) Load 161(i) + 169: 42(bool) SLessThan 167 168 + BranchConditional 169 163 164 + 163: Label + Line 1 78 0 + 170: 11(fvec4) Load 104(outv) + 171: 11(fvec4) VectorTimesScalar 170 41 + Store 104(outv) 171 + Branch 165 + 165: Label + Line 1 77 0 + 172: 7(int) Load 161(i) + 173: 7(int) IAdd 172 81 + Store 161(i) 173 + Branch 162 + 164: Label + Line 1 80 0 + 175: 174(ptr) AccessChain 104(outv) 38 + 176: 10(float) Load 175 + 178: 42(bool) FOrdLessThan 176 177 + SelectionMerge 181 None + BranchConditional 178 180 184 + 180: Label + Line 1 81 0 + 182: 11(fvec4) Load 104(outv) + 183: 11(fvec4) ExtInst 2(GLSL.std.450) 13(Sin) 182 + Store 104(outv) 183 + Store 179 183 + Branch 181 + 184: Label + Line 1 82 0 + 185: 11(fvec4) Load 104(outv) + 186: 11(fvec4) ExtInst 2(GLSL.std.450) 14(Cos) 185 + Store 104(outv) 186 + Store 179 186 + Branch 181 + 181: Label + Return + FunctionEnd + Line 1 16 13 +14(foo(struct-S-i11;): 11(fvec4) Function None 12 + 13(s): 9(ptr) FunctionParameter + 15: Label + 23(r): 22(ptr) Variable Function + Line 1 18 0 + 26: 25(ptr) AccessChain 13(s) 24 + 27: 7(int) Load 26 + 28: 10(float) ConvertSToF 27 + 31: 11(fvec4) Load 30(inv) + 32: 11(fvec4) VectorTimesScalar 31 28 + Store 23(r) 32 + Line 1 19 0 + 33: 11(fvec4) Load 23(r) + 35: 11(fvec4) CompositeConstruct 34 34 34 34 + 36: 11(fvec4) FAdd 33 35 + Store 23(r) 36 + Line 1 20 0 + 39: 16(ptr) AccessChain 23(r) 38 + 40: 10(float) Load 39 + 43: 42(bool) FOrdGreaterThan 40 41 + SelectionMerge 45 None + BranchConditional 43 44 49 + 44: Label + Line 1 21 0 + 46: 11(fvec4) Load 23(r) + 47: 11(fvec4) CompositeConstruct 34 34 34 34 + 48: 11(fvec4) FSub 46 47 + Store 23(r) 48 + Branch 45 + 49: Label + Line 1 23 0 + 51: 11(fvec4) Load 23(r) + 52: 11(fvec4) VectorTimesScalar 51 50 + Store 23(r) 52 + Branch 45 + 45: Label + Line 1 25 0 + 53: 11(fvec4) Load 23(r) + ReturnValue 53 + FunctionEnd + Line 1 28 34 +20(testBranch(f1;f1;): 10(float) Function None 17 + 18(x): 16(ptr) FunctionParameter + 19(y): 16(ptr) FunctionParameter + 21: Label + 56(result): 16(ptr) Variable Function + 59(b): 58(ptr) Variable Function + 90: 16(ptr) Variable Function + Line 1 30 0 + Store 56(result) 57 + Line 1 31 0 + 60: 10(float) Load 18(x) + 61: 42(bool) FOrdGreaterThan 60 57 + Store 59(b) 61 + Line 1 34 0 + 62: 42(bool) Load 59(b) + SelectionMerge 64 None + BranchConditional 62 63 67 + 63: Label + Line 1 35 0 + 65: 10(float) Load 56(result) + 66: 10(float) FAdd 65 34 + Store 56(result) 66 + Branch 64 + 67: Label + Line 1 38 0 + 68: 10(float) Load 56(result) + 69: 10(float) FSub 68 34 + Store 56(result) 69 + Branch 64 + 64: Label + Line 1 42 0 + 70: 10(float) Load 18(x) + 71: 10(float) Load 19(y) + 72: 42(bool) FOrdGreaterThan 70 71 + SelectionMerge 74 None + BranchConditional 72 73 74 + 73: Label + Line 1 43 0 + 75: 10(float) Load 18(x) + 76: 10(float) Load 19(y) + 77: 10(float) FSub 75 76 + 78: 10(float) Load 56(result) + 79: 10(float) FAdd 78 77 + Store 56(result) 79 + Branch 74 + 74: Label + Line 1 47 0 + 80: 42(bool) Load 59(b) + 83: 7(int) Select 80 81 82 + 84: 10(float) ConvertSToF 83 + 85: 10(float) Load 56(result) + 86: 10(float) FAdd 85 84 + Store 56(result) 86 + Line 1 51 0 + 87: 10(float) Load 18(x) + 88: 10(float) Load 19(y) + 89: 42(bool) FOrdLessThan 87 88 + SelectionMerge 92 None + BranchConditional 89 91 94 + 91: Label + Line 1 52 0 + 93: 10(float) Load 19(y) + Store 90 93 + Branch 92 + 94: Label + Line 1 53 0 + 95: 42(bool) Load 59(b) + 96: 10(float) Select 95 34 57 + Store 90 96 + Branch 92 + 92: Label + 97: 10(float) Load 90 + Line 1 51 0 + 98: 10(float) Load 56(result) + 99: 10(float) FAdd 98 97 + Store 56(result) 99 + Line 1 55 0 + 100: 10(float) Load 56(result) + ReturnValue 100 + FunctionEnd diff --git a/Test/baseResults/spv.debugInfo.frag.out b/Test/baseResults/spv.debugInfo.frag.out index 475187d9..8bacd74d 100644 --- a/Test/baseResults/spv.debugInfo.frag.out +++ b/Test/baseResults/spv.debugInfo.frag.out @@ -7,13 +7,17 @@ spv.debugInfo.frag 2: ExtInstImport "GLSL.std.450" MemoryModel Logical GLSL450 EntryPoint Fragment 5 "main" 30 104 - ExecutionMode 5 OriginUpperLeft + ExecutionMode 5 OriginLowerLeft 1: String "spv.debugInfo.frag" - Source GLSL 450 1 "// OpModuleProcessed auto-map-locations + Source GLSL 450 1 "// OpModuleProcessed no-storage-format +// OpModuleProcessed resource-set-binding 3 // OpModuleProcessed auto-map-bindings -// OpModuleProcessed client vulkan100 -// OpModuleProcessed target-env vulkan1.0 -// OpModuleProcessed keep-uncalled +// OpModuleProcessed auto-map-locations +// OpModuleProcessed client opengl100 +// OpModuleProcessed target-env opengl +// OpModuleProcessed relaxed-errors +// OpModuleProcessed suppress-warnings +// OpModuleProcessed hlsl-offsets // OpModuleProcessed entry-point main #line 1 #version 450 @@ -127,9 +131,10 @@ void main() MemberDecorate 105(S) 0 Offset 0 MemberDecorate 106(ubuf) 0 Offset 0 Decorate 106(ubuf) Block - Decorate 108 DescriptorSet 0 + Decorate 108 DescriptorSet 3 Decorate 108 Binding 0 - Decorate 131(s2d) DescriptorSet 0 + Decorate 131(s2d) Location 0 + Decorate 131(s2d) DescriptorSet 3 Decorate 131(s2d) Binding 1 3: TypeVoid 4: TypeFunction 3 diff --git a/Test/runtests b/Test/runtests index 52898e06..00c2babd 100755 --- a/Test/runtests +++ b/Test/runtests @@ -169,6 +169,12 @@ diff -b $BASEDIR/spv.looseUniformNoLoc.vert.out "$TARGETDIR/spv.looseUniformNoLo # Testing debug information # echo Testing SPV Debug Information +run -g --relaxed-errors --suppress-warnings --aml --amb --hlsl-offsets --nsf --spirv-val \ + -G -H spv.debugInfo.frag --rsb frag 3 > "$TARGETDIR/spv.debugInfo.frag.out" +diff -b $BASEDIR/spv.debugInfo.frag.out "$TARGETDIR/spv.debugInfo.frag.out" || HASERROR=1 +run -g -Od --target-env vulkan1.1 --relaxed-errors --suppress-warnings --aml --amb --hlsl-offsets --nsf --spirv-val \ + -V -H spv.debugInfo.frag --rsb frag 3 > "$TARGETDIR/spv.debugInfo.1.1.frag.out" +diff -b $BASEDIR/spv.debugInfo.1.1.frag.out "$TARGETDIR/spv.debugInfo.1.1.frag.out" || HASERROR=1 run -g -D -Od -e newMain -g --amb --aml --fua --hlsl-iomap --nsf --spirv-val --sib 1 --ssb 2 --sbb 3 --stb 4 --suavb 5 --sub 6 \ --sep origMain -H -Od spv.hlslDebugInfo.vert --rsb vert t0 0 0 > "$TARGETDIR/spv.hlslDebugInfo.frag.out" diff -b $BASEDIR/spv.hlslDebugInfo.frag.out "$TARGETDIR/spv.hlslDebugInfo.frag.out" || HASERROR=1 diff --git a/gtests/Spv.FromFile.cpp b/gtests/Spv.FromFile.cpp index 627b3aa4..77e9cccf 100644 --- a/gtests/Spv.FromFile.cpp +++ b/gtests/Spv.FromFile.cpp @@ -935,7 +935,6 @@ INSTANTIATE_TEST_SUITE_P( Glsl, GlslSpirvDebugInfoTest, ::testing::ValuesIn(std::vector({ "spv.pp.line.frag", - "spv.debugInfo.frag", })), FileNameAsCustomTestSuffix ); From eadafe80edb6719cdffd77cc2792ac2b46baf8f1 Mon Sep 17 00:00:00 2001 From: Romaric Jodin Date: Mon, 17 Jun 2024 11:47:50 +0200 Subject: [PATCH 10/14] Update known_good.json Also update test that is now passing --- Test/baseResults/spv.coopmat_armlayout.comp.out | 1 - known_good.json | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Test/baseResults/spv.coopmat_armlayout.comp.out b/Test/baseResults/spv.coopmat_armlayout.comp.out index 1af49f29..fbeb6555 100644 --- a/Test/baseResults/spv.coopmat_armlayout.comp.out +++ b/Test/baseResults/spv.coopmat_armlayout.comp.out @@ -1,5 +1,4 @@ spv.coopmat_armlayout.comp -Validation failed // Module Version 10000 // Generated by (magic number): 8000b // Id's are bound by 251 diff --git a/known_good.json b/known_good.json index c6de6b18..03d5a0f5 100644 --- a/known_good.json +++ b/known_good.json @@ -5,14 +5,14 @@ "site" : "github", "subrepo" : "KhronosGroup/SPIRV-Tools", "subdir" : "External/spirv-tools", - "commit": "ce46482db7ab3ea9c52fce832d27ca40b14f8e87" + "commit": "bc28ac7c195f59b14535edec8472d97fd32a91ad" }, { "name" : "spirv-tools/external/spirv-headers", "site" : "github", "subrepo" : "KhronosGroup/SPIRV-Headers", "subdir" : "External/spirv-tools/external/spirv-headers", - "commit" : "eb49bb7b1136298b77945c52b4bbbc433f7885de" + "commit" : "2acb319af38d43be3ea76bfabf3998e5281d8d12" }, { "name": "googletest", From d275ea6c528cd860eafc0505a963b888148784d4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 06:16:06 +0000 Subject: [PATCH 11/14] Bump github/codeql-action from 3.25.8 to 3.25.10 Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.25.8 to 3.25.10. - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/2e230e8fe0ad3a14a340ad0815ddb96d599d2aff...23acc5c183826b7a8a97bce3cecc52db901f8251) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/scorecard.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml index 3aa30b68..36394ad5 100644 --- a/.github/workflows/scorecard.yml +++ b/.github/workflows/scorecard.yml @@ -48,6 +48,6 @@ jobs: # Upload the results to GitHub's code scanning dashboard. - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@2e230e8fe0ad3a14a340ad0815ddb96d599d2aff # v3.25.8 + uses: github/codeql-action/upload-sarif@23acc5c183826b7a8a97bce3cecc52db901f8251 # v3.25.10 with: sarif_file: results.sarif From 68a17eb72182d3dcfac834eed3512ea205eac9d1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 06:16:11 +0000 Subject: [PATCH 12/14] Bump actions/checkout from 4.1.6 to 4.1.7 Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.6 to 4.1.7. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/a5ac7e51b41094c92402da3b24376905380afc29...692973e3d937129bcbf40652eb9f2f61becf3332) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/continuous_deployment.yml | 6 +++--- .github/workflows/continuous_integration.yml | 16 ++++++++-------- .github/workflows/scorecard.yml | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/continuous_deployment.yml b/.github/workflows/continuous_deployment.yml index aee4a305..ac7e3d1c 100644 --- a/.github/workflows/continuous_deployment.yml +++ b/.github/workflows/continuous_deployment.yml @@ -41,7 +41,7 @@ jobs: compiler: [{cc: clang, cxx: clang++}, {cc: gcc, cxx: g++}] cmake_build_type: [Debug, Release] steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - uses: lukka/get-cmake@18d87816d12dd87ec1449d47b9b3a587e0a1cc19 # v3.29.5 - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 with: @@ -105,7 +105,7 @@ jobs: compiler: [{cc: clang, cxx: clang++}] cmake_build_type: [Debug, Release] steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - uses: lukka/get-cmake@18d87816d12dd87ec1449d47b9b3a587e0a1cc19 # v3.29.5 - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 with: @@ -162,7 +162,7 @@ jobs: os: [{genus: windows-2019, family: windows}] cmake_build_type: [Debug, Release] steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - uses: lukka/get-cmake@18d87816d12dd87ec1449d47b9b3a587e0a1cc19 # v3.29.5 - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 with: diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index 38ebdc0d..642eef10 100644 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -17,7 +17,7 @@ jobs: compiler: [{cc: clang, cxx: clang++}, {cc: gcc, cxx: g++}] cmake_build_type: [Debug, Release] steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - uses: lukka/get-cmake@18d87816d12dd87ec1449d47b9b3a587e0a1cc19 # v3.29.5 - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 with: @@ -53,7 +53,7 @@ jobs: cmake_build_type: [Debug] flags: ['-fsanitize=address', '-fsanitize=thread'] steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - uses: lukka/get-cmake@18d87816d12dd87ec1449d47b9b3a587e0a1cc19 # v3.29.5 - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 with: @@ -91,7 +91,7 @@ jobs: name: Linux Backcompat runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 with: python-version: '3.7' @@ -126,7 +126,7 @@ jobs: compiler: [{cc: clang, cxx: clang++}, {cc: gcc, cxx: g++}] cmake_build_type: [Debug, Release] steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - uses: lukka/get-cmake@18d87816d12dd87ec1449d47b9b3a587e0a1cc19 # v3.29.5 - run: ./update_glslang_sources.py - run: cmake -S . -B build -D CMAKE_BUILD_TYPE=${{matrix.cmake_build_type}} -G Ninja -DBUILD_WERROR=ON -D GLSLANG_TESTS=ON @@ -150,7 +150,7 @@ jobs: os: [{genus: windows-2019, family: windows}] cmake_build_type: [Debug, Release] steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - uses: lukka/get-cmake@18d87816d12dd87ec1449d47b9b3a587e0a1cc19 # v3.29.5 - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 with: @@ -168,7 +168,7 @@ jobs: iOS: runs-on: macos-13 steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - uses: lukka/get-cmake@18d87816d12dd87ec1449d47b9b3a587e0a1cc19 # v3.29.5 - name: Setup ccache uses: hendrikmuhs/ccache-action@c92f40bee50034e84c763e33b317c77adaa81c92 # v1.2.13 @@ -197,7 +197,7 @@ jobs: # Test both to ensure we are compatible with either approach. LEGACY: [ON, OFF] steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - uses: lukka/get-cmake@18d87816d12dd87ec1449d47b9b3a587e0a1cc19 # v3.29.5 - name: Setup ccache uses: hendrikmuhs/ccache-action@c92f40bee50034e84c763e33b317c77adaa81c92 # v1.2.13 @@ -220,7 +220,7 @@ jobs: emscripten: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 with: python-version: '3.7' diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml index 36394ad5..06ba4a06 100644 --- a/.github/workflows/scorecard.yml +++ b/.github/workflows/scorecard.yml @@ -23,7 +23,7 @@ jobs: steps: - name: "Checkout code" - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: persist-credentials: false From a05c4eca74b3a5306080a9aaca54d215dec8c7b3 Mon Sep 17 00:00:00 2001 From: RP Singh Date: Fri, 21 Jun 2024 02:04:59 +0530 Subject: [PATCH 13/14] Skip identity conversions for 8-bit and 16-bit types (#3622) [BugFix] Do not generate any conversion for 8-bit and 16-bit types if it is an identity conversion. Earlier (before this fix), it generated incorrect SPIR-V convert instructions, as SPIR-V requires that the types being converted differ. --- glslang/MachineIndependent/ParseHelper.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp index 98a7d268..c5f0e63f 100644 --- a/glslang/MachineIndependent/ParseHelper.cpp +++ b/glslang/MachineIndependent/ParseHelper.cpp @@ -4,6 +4,7 @@ // Copyright (C) 2015-2018 Google, Inc. // Copyright (C) 2017, 2019 ARM Limited. // Modifications Copyright (C) 2020 Advanced Micro Devices, Inc. All rights reserved. +// Modifications Copyright (C) 2024 Ravi Prakash Singh. // // All rights reserved. // @@ -8540,7 +8541,8 @@ TIntermTyped* TParseContext::constructBuiltIn(const TType& type, TOperator op, T basicOp = EOpConstructFloat16; // 8/16-bit storage extensions don't support constructing composites of 8/16-bit types, // so construct a 32-bit type and convert - if (!intermediate.getArithemeticFloat16Enabled()) { + // and do not generate any conversion if it is an identity conversion, i.e. float16_t( var) + if (!intermediate.getArithemeticFloat16Enabled() && (node->getBasicType() != EbtFloat16)) { TType tempType(EbtFloat, EvqTemporary, type.getVectorSize()); newNode = node; if (tempType != newNode->getType()) { @@ -8563,7 +8565,8 @@ TIntermTyped* TParseContext::constructBuiltIn(const TType& type, TOperator op, T basicOp = EOpConstructInt8; // 8/16-bit storage extensions don't support constructing composites of 8/16-bit types, // so construct a 32-bit type and convert - if (!intermediate.getArithemeticInt8Enabled()) { + // and do not generate any conversion if it is an identity conversion, i.e. int8_t( var) + if (!intermediate.getArithemeticInt8Enabled() && (node->getBasicType() != EbtInt8)) { TType tempType(EbtInt, EvqTemporary, type.getVectorSize()); newNode = node; if (tempType != newNode->getType()) { @@ -8586,7 +8589,8 @@ TIntermTyped* TParseContext::constructBuiltIn(const TType& type, TOperator op, T basicOp = EOpConstructUint8; // 8/16-bit storage extensions don't support constructing composites of 8/16-bit types, // so construct a 32-bit type and convert - if (!intermediate.getArithemeticInt8Enabled()) { + // and do not generate any conversion if it is an identity conversion, i.e. uint8_t( var) + if (!intermediate.getArithemeticInt8Enabled() && (node->getBasicType() != EbtUint8)) { TType tempType(EbtUint, EvqTemporary, type.getVectorSize()); newNode = node; if (tempType != newNode->getType()) { @@ -8609,7 +8613,8 @@ TIntermTyped* TParseContext::constructBuiltIn(const TType& type, TOperator op, T basicOp = EOpConstructInt16; // 8/16-bit storage extensions don't support constructing composites of 8/16-bit types, // so construct a 32-bit type and convert - if (!intermediate.getArithemeticInt16Enabled()) { + // and do not generate any conversion if it is an identity conversion, i.e. int16_t( var) + if (!intermediate.getArithemeticInt16Enabled() && (node->getBasicType() != EbtInt16)) { TType tempType(EbtInt, EvqTemporary, type.getVectorSize()); newNode = node; if (tempType != newNode->getType()) { @@ -8632,7 +8637,8 @@ TIntermTyped* TParseContext::constructBuiltIn(const TType& type, TOperator op, T basicOp = EOpConstructUint16; // 8/16-bit storage extensions don't support constructing composites of 8/16-bit types, // so construct a 32-bit type and convert - if (!intermediate.getArithemeticInt16Enabled()) { + // and do not generate any conversion if it is an identity conversion, i.e. uint16_t( var) + if (!intermediate.getArithemeticInt16Enabled() && (node->getBasicType() != EbtUint16)) { TType tempType(EbtUint, EvqTemporary, type.getVectorSize()); newNode = node; if (tempType != newNode->getType()) { From 2d8b71fc63578a93726c05e0565c3ef064bdc1ba Mon Sep 17 00:00:00 2001 From: Arcady Goldmints-Orlov Date: Thu, 20 Jun 2024 17:13:09 -0400 Subject: [PATCH 14/14] Add test cases for redundant type conversions These redundant type conversions were generating illegal SPIR-V when only the 8-bit/16-bit storage extensions and not the corresponding arithmetic extensions were enabled. --- .../baseResults/spv.16bitstorage-int.frag.out | 22 ++++++++++++++++++- .../spv.16bitstorage-uint.frag.out | 22 ++++++++++++++++++- Test/baseResults/spv.16bitstorage.frag.out | 22 ++++++++++++++++++- Test/baseResults/spv.8bitstorage-int.frag.out | 22 ++++++++++++++++++- .../baseResults/spv.8bitstorage-uint.frag.out | 22 ++++++++++++++++++- Test/spv.16bitstorage-int.frag | 3 +++ Test/spv.16bitstorage-uint.frag | 3 +++ Test/spv.16bitstorage.frag | 3 +++ Test/spv.8bitstorage-int.frag | 3 +++ Test/spv.8bitstorage-uint.frag | 3 +++ 10 files changed, 120 insertions(+), 5 deletions(-) diff --git a/Test/baseResults/spv.16bitstorage-int.frag.out b/Test/baseResults/spv.16bitstorage-int.frag.out index d14519b9..143983cb 100644 --- a/Test/baseResults/spv.16bitstorage-int.frag.out +++ b/Test/baseResults/spv.16bitstorage-int.frag.out @@ -1,9 +1,10 @@ spv.16bitstorage-int.frag // Module Version 10000 // Generated by (magic number): 8000b -// Id's are bound by 171 +// Id's are bound by 187 Capability Shader + Capability Int16 Capability StorageUniformBufferBlock16 Capability StorageUniform16 Extension "SPV_KHR_16bit_storage" @@ -335,5 +336,24 @@ spv.16bitstorage-int.frag 169: 6(int16_t) SConvert 58 170: 28(ptr) AccessChain 19(b2) 21 Store 170 169 + 171: 28(ptr) AccessChain 27(b1) 21 + 172: 6(int16_t) Load 171 + 173: 28(ptr) AccessChain 19(b2) 21 + Store 173 172 + 174: 42(ptr) AccessChain 27(b1) 32 + 175: 7(i16vec2) Load 174 + 176: 6(int16_t) CompositeExtract 175 0 + 177: 6(int16_t) CompositeExtract 175 1 + 178: 7(i16vec2) CompositeConstruct 176 177 + 179: 42(ptr) AccessChain 19(b2) 32 + Store 179 178 + 180: 34(ptr) AccessChain 27(b1) 33 + 181: 8(i16vec3) Load 180 + 182: 6(int16_t) CompositeExtract 181 0 + 183: 6(int16_t) CompositeExtract 181 1 + 184: 6(int16_t) CompositeExtract 181 2 + 185: 8(i16vec3) CompositeConstruct 182 183 184 + 186: 34(ptr) AccessChain 19(b2) 33 + Store 186 185 Return FunctionEnd diff --git a/Test/baseResults/spv.16bitstorage-uint.frag.out b/Test/baseResults/spv.16bitstorage-uint.frag.out index ea935ce6..4b30c297 100644 --- a/Test/baseResults/spv.16bitstorage-uint.frag.out +++ b/Test/baseResults/spv.16bitstorage-uint.frag.out @@ -1,9 +1,10 @@ spv.16bitstorage-uint.frag // Module Version 10000 // Generated by (magic number): 8000b -// Id's are bound by 173 +// Id's are bound by 189 Capability Shader + Capability Int16 Capability StorageUniformBufferBlock16 Capability StorageUniform16 Extension "SPV_KHR_16bit_storage" @@ -337,5 +338,24 @@ spv.16bitstorage-uint.frag 171: 6(int16_t) UConvert 170 172: 28(ptr) AccessChain 19(b2) 21 Store 172 171 + 173: 28(ptr) AccessChain 27(b1) 21 + 174: 6(int16_t) Load 173 + 175: 28(ptr) AccessChain 19(b2) 21 + Store 175 174 + 176: 42(ptr) AccessChain 27(b1) 32 + 177: 7(i16vec2) Load 176 + 178: 6(int16_t) CompositeExtract 177 0 + 179: 6(int16_t) CompositeExtract 177 1 + 180: 7(i16vec2) CompositeConstruct 178 179 + 181: 42(ptr) AccessChain 19(b2) 32 + Store 181 180 + 182: 34(ptr) AccessChain 27(b1) 33 + 183: 8(i16vec3) Load 182 + 184: 6(int16_t) CompositeExtract 183 0 + 185: 6(int16_t) CompositeExtract 183 1 + 186: 6(int16_t) CompositeExtract 183 2 + 187: 8(i16vec3) CompositeConstruct 184 185 186 + 188: 34(ptr) AccessChain 19(b2) 33 + Store 188 187 Return FunctionEnd diff --git a/Test/baseResults/spv.16bitstorage.frag.out b/Test/baseResults/spv.16bitstorage.frag.out index c19f607c..7e186809 100644 --- a/Test/baseResults/spv.16bitstorage.frag.out +++ b/Test/baseResults/spv.16bitstorage.frag.out @@ -1,9 +1,10 @@ spv.16bitstorage.frag // Module Version 10000 // Generated by (magic number): 8000b -// Id's are bound by 173 +// Id's are bound by 189 Capability Shader + Capability Float16 Capability StorageUniformBufferBlock16 Capability StorageUniform16 Extension "SPV_KHR_16bit_storage" @@ -337,5 +338,24 @@ spv.16bitstorage.frag 171:6(float16_t) FConvert 170 172: 28(ptr) AccessChain 19(b2) 21 Store 172 171 + 173: 28(ptr) AccessChain 27(b1) 21 + 174:6(float16_t) Load 173 + 175: 28(ptr) AccessChain 19(b2) 21 + Store 175 174 + 176: 43(ptr) AccessChain 27(b1) 32 + 177: 7(f16vec2) Load 176 + 178:6(float16_t) CompositeExtract 177 0 + 179:6(float16_t) CompositeExtract 177 1 + 180: 7(f16vec2) CompositeConstruct 178 179 + 181: 43(ptr) AccessChain 19(b2) 32 + Store 181 180 + 182: 34(ptr) AccessChain 27(b1) 33 + 183: 8(f16vec3) Load 182 + 184:6(float16_t) CompositeExtract 183 0 + 185:6(float16_t) CompositeExtract 183 1 + 186:6(float16_t) CompositeExtract 183 2 + 187: 8(f16vec3) CompositeConstruct 184 185 186 + 188: 34(ptr) AccessChain 19(b2) 33 + Store 188 187 Return FunctionEnd diff --git a/Test/baseResults/spv.8bitstorage-int.frag.out b/Test/baseResults/spv.8bitstorage-int.frag.out index 830b3e32..da8fe267 100644 --- a/Test/baseResults/spv.8bitstorage-int.frag.out +++ b/Test/baseResults/spv.8bitstorage-int.frag.out @@ -1,9 +1,10 @@ spv.8bitstorage-int.frag // Module Version 10000 // Generated by (magic number): 8000b -// Id's are bound by 171 +// Id's are bound by 187 Capability Shader + Capability Int8 Capability UniformAndStorageBuffer8BitAccess Extension "SPV_KHR_8bit_storage" 1: ExtInstImport "GLSL.std.450" @@ -334,5 +335,24 @@ spv.8bitstorage-int.frag 169: 6(int8_t) SConvert 58 170: 28(ptr) AccessChain 19(b2) 21 Store 170 169 + 171: 28(ptr) AccessChain 27(b1) 21 + 172: 6(int8_t) Load 171 + 173: 28(ptr) AccessChain 19(b2) 21 + Store 173 172 + 174: 42(ptr) AccessChain 27(b1) 32 + 175: 7(i8vec2) Load 174 + 176: 6(int8_t) CompositeExtract 175 0 + 177: 6(int8_t) CompositeExtract 175 1 + 178: 7(i8vec2) CompositeConstruct 176 177 + 179: 42(ptr) AccessChain 19(b2) 32 + Store 179 178 + 180: 34(ptr) AccessChain 27(b1) 33 + 181: 8(i8vec3) Load 180 + 182: 6(int8_t) CompositeExtract 181 0 + 183: 6(int8_t) CompositeExtract 181 1 + 184: 6(int8_t) CompositeExtract 181 2 + 185: 8(i8vec3) CompositeConstruct 182 183 184 + 186: 34(ptr) AccessChain 19(b2) 33 + Store 186 185 Return FunctionEnd diff --git a/Test/baseResults/spv.8bitstorage-uint.frag.out b/Test/baseResults/spv.8bitstorage-uint.frag.out index f372baf1..eb1ecca5 100644 --- a/Test/baseResults/spv.8bitstorage-uint.frag.out +++ b/Test/baseResults/spv.8bitstorage-uint.frag.out @@ -1,9 +1,10 @@ spv.8bitstorage-uint.frag // Module Version 10000 // Generated by (magic number): 8000b -// Id's are bound by 173 +// Id's are bound by 189 Capability Shader + Capability Int8 Capability UniformAndStorageBuffer8BitAccess Extension "SPV_KHR_8bit_storage" 1: ExtInstImport "GLSL.std.450" @@ -336,5 +337,24 @@ spv.8bitstorage-uint.frag 171: 6(int8_t) UConvert 170 172: 28(ptr) AccessChain 19(b2) 21 Store 172 171 + 173: 28(ptr) AccessChain 27(b1) 21 + 174: 6(int8_t) Load 173 + 175: 28(ptr) AccessChain 19(b2) 21 + Store 175 174 + 176: 42(ptr) AccessChain 27(b1) 32 + 177: 7(i8vec2) Load 176 + 178: 6(int8_t) CompositeExtract 177 0 + 179: 6(int8_t) CompositeExtract 177 1 + 180: 7(i8vec2) CompositeConstruct 178 179 + 181: 42(ptr) AccessChain 19(b2) 32 + Store 181 180 + 182: 34(ptr) AccessChain 27(b1) 33 + 183: 8(i8vec3) Load 182 + 184: 6(int8_t) CompositeExtract 183 0 + 185: 6(int8_t) CompositeExtract 183 1 + 186: 6(int8_t) CompositeExtract 183 2 + 187: 8(i8vec3) CompositeConstruct 184 185 186 + 188: 34(ptr) AccessChain 19(b2) 33 + Store 188 187 Return FunctionEnd diff --git a/Test/spv.16bitstorage-int.frag b/Test/spv.16bitstorage-int.frag index 57be67ee..7252bfeb 100644 --- a/Test/spv.16bitstorage-int.frag +++ b/Test/spv.16bitstorage-int.frag @@ -86,5 +86,8 @@ void main() b2.o = b2.p.x; b2.p = i16vec2(ivec2(1, 2)); b2.o = int16_t(3); + b2.o = int16_t(b1.a); + b2.p = i16vec2(b1.b); + b2.q = i16vec3(b1.c); } diff --git a/Test/spv.16bitstorage-uint.frag b/Test/spv.16bitstorage-uint.frag index aeecd041..104aaf5f 100644 --- a/Test/spv.16bitstorage-uint.frag +++ b/Test/spv.16bitstorage-uint.frag @@ -86,5 +86,8 @@ void main() b2.o = b2.p.x; b2.p = u16vec2(uvec2(1, 2)); b2.o = uint16_t(3u); + b2.o = uint16_t(b1.a); + b2.p = u16vec2(b1.b); + b2.q = u16vec3(b1.c); } diff --git a/Test/spv.16bitstorage.frag b/Test/spv.16bitstorage.frag index b821be1e..032629b0 100644 --- a/Test/spv.16bitstorage.frag +++ b/Test/spv.16bitstorage.frag @@ -86,5 +86,8 @@ void main() b2.o = b2.p.x; b2.p = f16vec2(vec2(1.0, 2.0)); b2.o = float16_t(3.0); + b2.o = float16_t(b1.a); + b2.p = f16vec2(b1.b); + b2.q = f16vec3(b1.c); } diff --git a/Test/spv.8bitstorage-int.frag b/Test/spv.8bitstorage-int.frag index 93203c36..09d95b99 100644 --- a/Test/spv.8bitstorage-int.frag +++ b/Test/spv.8bitstorage-int.frag @@ -86,5 +86,8 @@ void main() b2.o = b2.p.x; b2.p = i8vec2(ivec2(1, 2)); b2.o = int8_t(3); + b2.o = int8_t(b1.a); + b2.p = i8vec2(b1.b); + b2.q = i8vec3(b1.c); } diff --git a/Test/spv.8bitstorage-uint.frag b/Test/spv.8bitstorage-uint.frag index 574d088e..3a3b1816 100644 --- a/Test/spv.8bitstorage-uint.frag +++ b/Test/spv.8bitstorage-uint.frag @@ -86,5 +86,8 @@ void main() b2.o = b2.p.x; b2.p = u8vec2(uvec2(1, 2)); b2.o = uint8_t(3u); + b2.o = uint8_t(b1.a); + b2.p = u8vec2(b1.b); + b2.q = u8vec3(b1.c); }