From 0464ff4515296ee13a1ecb95931906c2cd10c48c Mon Sep 17 00:00:00 2001 From: Gilad Ben-Yossef Date: Mon, 5 Dec 2022 14:02:22 +0200 Subject: [PATCH] GL_ARM_shader_core_builtins support Add support for GL_ARM_shader_core_builtins and SPV_ARM_core_builtins, including initial tests --- BUILD.bazel | 2 + BUILD.gn | 1 + SPIRV/CMakeLists.txt | 1 + SPIRV/GLSL.ext.ARM.h | 35 +++++++ SPIRV/GlslangToSpv.cpp | 23 +++++ SPIRV/SpvPostProcess.cpp | 1 + SPIRV/disassemble.cpp | 1 + SPIRV/doc.cpp | 7 ++ SPIRV/spirv.hpp | 6 ++ Test/baseResults/spv.ARMCoreBuiltIns.frag.out | 61 ++++++++++++ Test/baseResults/spv.ARMCoreBuiltIns.vert.out | 65 +++++++++++++ Test/spv.ARMCoreBuiltIns.frag | 8 ++ Test/spv.ARMCoreBuiltIns.vert | 12 +++ glslang/Include/BaseTypes.h | 7 ++ glslang/MachineIndependent/Initialize.cpp | 96 +++++++++++++++++++ glslang/MachineIndependent/Versions.cpp | 4 + glslang/MachineIndependent/Versions.h | 3 + gtests/Spv.FromFile.cpp | 2 + 18 files changed, 335 insertions(+) create mode 100644 SPIRV/GLSL.ext.ARM.h create mode 100644 Test/baseResults/spv.ARMCoreBuiltIns.frag.out create mode 100644 Test/baseResults/spv.ARMCoreBuiltIns.vert.out create mode 100644 Test/spv.ARMCoreBuiltIns.frag create mode 100644 Test/spv.ARMCoreBuiltIns.vert diff --git a/BUILD.bazel b/BUILD.bazel index 45efbd353..d7a65787d 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -144,6 +144,7 @@ genrule( "SPIRV/GLSL.ext.EXT.h", "SPIRV/GLSL.ext.KHR.h", "SPIRV/GLSL.ext.NV.h", + "SPIRV/GLSL.ext.ARM.h", "SPIRV/GLSL.std.450.h", "SPIRV/NonSemanticDebugPrintf.h", "SPIRV/NonSemanticShaderDebugInfo100.h", @@ -154,6 +155,7 @@ genrule( "include/SPIRV/GLSL.ext.EXT.h", "include/SPIRV/GLSL.ext.KHR.h", "include/SPIRV/GLSL.ext.NV.h", + "include/SPIRV/GLSL.ext.ARM.h", "include/SPIRV/GLSL.std.450.h", "include/SPIRV/NonSemanticDebugPrintf.h", "include/SPIRV/NonSemanticShaderDebugInfo100.h", diff --git a/BUILD.gn b/BUILD.gn index 4987c7004..0aacbf5ab 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -123,6 +123,7 @@ template("glslang_sources_common") { "SPIRV/GLSL.ext.EXT.h", "SPIRV/GLSL.ext.KHR.h", "SPIRV/GLSL.ext.NV.h", + "SPIRV/GLSL.ext.ARM.h", "SPIRV/GLSL.std.450.h", "SPIRV/GlslangToSpv.cpp", "SPIRV/GlslangToSpv.h", diff --git a/SPIRV/CMakeLists.txt b/SPIRV/CMakeLists.txt index 9a3a6a020..62ffbc458 100644 --- a/SPIRV/CMakeLists.txt +++ b/SPIRV/CMakeLists.txt @@ -62,6 +62,7 @@ set(HEADERS disassemble.h GLSL.ext.AMD.h GLSL.ext.NV.h + GLSL.ext.ARM.h NonSemanticDebugPrintf.h NonSemanticShaderDebugInfo100.h) diff --git a/SPIRV/GLSL.ext.ARM.h b/SPIRV/GLSL.ext.ARM.h new file mode 100644 index 000000000..14425be1e --- /dev/null +++ b/SPIRV/GLSL.ext.ARM.h @@ -0,0 +1,35 @@ +/* +** Copyright (c) 2022 ARM Limited +** +** Permission is hereby granted, free of charge, to any person obtaining a copy +** of this software and/or associated documentation files (the "Materials"), +** to deal in the Materials without restriction, including without limitation +** the rights to use, copy, modify, merge, publish, distribute, sublicense, +** and/or sell copies of the Materials, and to permit persons to whom the +** Materials are furnished to do so, subject to the following conditions: +** +** The above copyright notice and this permission notice shall be included in +** all copies or substantial portions of the Materials. +** +** MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS +** STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND +** HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/ +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +** OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +** THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +** FROM,OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS +** IN THE MATERIALS. +*/ + +#ifndef GLSLextARM_H +#define GLSLextARM_H + +static const int GLSLextARMVersion = 100; +static const int GLSLextARMRevision = 1; + +static const char * const E_SPV_ARM_core_builtins = "SPV_ARM_core_builtins"; + +#endif // #ifndef GLSLextARM_H diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp index 11fc70c25..17be96833 100644 --- a/SPIRV/GlslangToSpv.cpp +++ b/SPIRV/GlslangToSpv.cpp @@ -49,6 +49,7 @@ namespace spv { #include "GLSL.ext.EXT.h" #include "GLSL.ext.AMD.h" #include "GLSL.ext.NV.h" + #include "GLSL.ext.ARM.h" #include "NonSemanticDebugPrintf.h" } @@ -1106,6 +1107,28 @@ spv::BuiltIn TGlslangToSpvTraverser::TranslateBuiltInDecoration(glslang::TBuiltI builder.addExtension(spv::E_SPV_NV_shader_sm_builtins); builder.addCapability(spv::CapabilityShaderSMBuiltinsNV); return spv::BuiltInSMIDNV; + + // ARM builtins + case glslang::EbvCoreCountARM: + builder.addExtension(spv::E_SPV_ARM_core_builtins); + builder.addCapability(spv::CapabilityCoreBuiltinsARM); + return spv::BuiltInCoreCountARM; + case glslang::EbvCoreIDARM: + builder.addExtension(spv::E_SPV_ARM_core_builtins); + builder.addCapability(spv::CapabilityCoreBuiltinsARM); + return spv::BuiltInCoreIDARM; + case glslang::EbvCoreMaxIDARM: + builder.addExtension(spv::E_SPV_ARM_core_builtins); + builder.addCapability(spv::CapabilityCoreBuiltinsARM); + return spv::BuiltInCoreMaxIDARM; + case glslang::EbvWarpIDARM: + builder.addExtension(spv::E_SPV_ARM_core_builtins); + builder.addCapability(spv::CapabilityCoreBuiltinsARM); + return spv::BuiltInWarpIDARM; + case glslang::EbvWarpMaxIDARM: + builder.addExtension(spv::E_SPV_ARM_core_builtins); + builder.addCapability(spv::CapabilityCoreBuiltinsARM); + return spv::BuiltInWarpMaxIDARM; #endif default: diff --git a/SPIRV/SpvPostProcess.cpp b/SPIRV/SpvPostProcess.cpp index dd6dabce0..b185f61bb 100644 --- a/SPIRV/SpvPostProcess.cpp +++ b/SPIRV/SpvPostProcess.cpp @@ -52,6 +52,7 @@ namespace spv { #include "GLSL.ext.EXT.h" #include "GLSL.ext.AMD.h" #include "GLSL.ext.NV.h" + #include "GLSL.ext.ARM.h" } namespace spv { diff --git a/SPIRV/disassemble.cpp b/SPIRV/disassemble.cpp index 74dd60540..387376d88 100644 --- a/SPIRV/disassemble.cpp +++ b/SPIRV/disassemble.cpp @@ -54,6 +54,7 @@ namespace spv { #include "GLSL.std.450.h" #include "GLSL.ext.AMD.h" #include "GLSL.ext.NV.h" + #include "GLSL.ext.ARM.h" } } const char* GlslStd450DebugNames[spv::GLSLstd450Count]; diff --git a/SPIRV/doc.cpp b/SPIRV/doc.cpp index b6cc42db8..1534c6895 100644 --- a/SPIRV/doc.cpp +++ b/SPIRV/doc.cpp @@ -53,6 +53,7 @@ namespace spv { #include "GLSL.ext.EXT.h" #include "GLSL.ext.AMD.h" #include "GLSL.ext.NV.h" + #include "GLSL.ext.ARM.h" } } @@ -439,6 +440,11 @@ const char* BuiltInString(int builtIn) case BuiltInPrimitiveLineIndicesEXT: return "PrimitiveLineIndicesEXT"; case BuiltInPrimitiveTriangleIndicesEXT: return "PrimitiveTriangleIndicesEXT"; case BuiltInCullPrimitiveEXT: return "CullPrimitiveEXT"; + case BuiltInCoreCountARM: return "CoreCountARM"; + case BuiltInCoreIDARM: return "CoreIDARM"; + case BuiltInCoreMaxIDARM: return "CoreMaxIDARM"; + case BuiltInWarpIDARM: return "WarpIDARM"; + case BuiltInWarpMaxIDARM: return "BuiltInWarpMaxIDARM"; default: return "Bad"; } @@ -998,6 +1004,7 @@ const char* CapabilityString(int info) case CapabilityWorkgroupMemoryExplicitLayoutKHR: return "CapabilityWorkgroupMemoryExplicitLayoutKHR"; case CapabilityWorkgroupMemoryExplicitLayout8BitAccessKHR: return "CapabilityWorkgroupMemoryExplicitLayout8BitAccessKHR"; case CapabilityWorkgroupMemoryExplicitLayout16BitAccessKHR: return "CapabilityWorkgroupMemoryExplicitLayout16BitAccessKHR"; + case CapabilityCoreBuiltinsARM: return "CoreBuiltinsARM"; default: return "Bad"; } diff --git a/SPIRV/spirv.hpp b/SPIRV/spirv.hpp index f85469d44..73c372b29 100644 --- a/SPIRV/spirv.hpp +++ b/SPIRV/spirv.hpp @@ -607,6 +607,11 @@ enum BuiltIn { BuiltInSubgroupLocalInvocationId = 41, BuiltInVertexIndex = 42, BuiltInInstanceIndex = 43, + BuiltInCoreCountARM = 4161, + BuiltInCoreIDARM = 4160, + BuiltInCoreMaxIDARM = 4162, + BuiltInWarpIDARM = 4163, + BuiltInWarpMaxIDARM = 4164, BuiltInSubgroupEqMask = 4416, BuiltInSubgroupEqMaskKHR = 4416, BuiltInSubgroupGeMask = 4417, @@ -946,6 +951,7 @@ enum Capability { CapabilityShaderLayer = 69, CapabilityShaderViewportIndex = 70, CapabilityUniformDecoration = 71, + CapabilityCoreBuiltinsARM = 4165, CapabilityFragmentShadingRateKHR = 4422, CapabilitySubgroupBallotKHR = 4423, CapabilityDrawParameters = 4427, diff --git a/Test/baseResults/spv.ARMCoreBuiltIns.frag.out b/Test/baseResults/spv.ARMCoreBuiltIns.frag.out new file mode 100644 index 000000000..ccfb40936 --- /dev/null +++ b/Test/baseResults/spv.ARMCoreBuiltIns.frag.out @@ -0,0 +1,61 @@ +spv.ARMCoreBuiltIns.frag +// Module Version 10000 +// Generated by (magic number): 8000b +// Id's are bound by 26 + + Capability Shader + Capability CoreBuiltinsARM + Extension "SPV_ARM_core_builtins" + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Fragment 4 "main" 10 14 15 17 19 21 + ExecutionMode 4 OriginUpperLeft + Source GLSL 450 + SourceExtension "GL_ARM_shader_core_builtins" + Name 4 "main" + Name 8 "temp" + Name 10 "gl_WarpMaxIDARM" + Name 14 "data" + Name 15 "gl_CoreIDARM" + Name 17 "gl_CoreCountARM" + Name 19 "gl_CoreMaxIDARM" + Name 21 "gl_WarpIDARM" + Decorate 10(gl_WarpMaxIDARM) Flat + Decorate 10(gl_WarpMaxIDARM) BuiltIn BuiltInWarpMaxIDARM + Decorate 14(data) Location 0 + Decorate 15(gl_CoreIDARM) Flat + Decorate 15(gl_CoreIDARM) BuiltIn CoreIDARM + Decorate 17(gl_CoreCountARM) Flat + Decorate 17(gl_CoreCountARM) BuiltIn CoreCountARM + Decorate 19(gl_CoreMaxIDARM) Flat + Decorate 19(gl_CoreMaxIDARM) BuiltIn CoreMaxIDARM + Decorate 21(gl_WarpIDARM) Flat + Decorate 21(gl_WarpIDARM) BuiltIn WarpIDARM + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeInt 32 0 + 7: TypePointer Function 6(int) + 9: TypePointer Input 6(int) +10(gl_WarpMaxIDARM): 9(ptr) Variable Input + 12: TypeVector 6(int) 4 + 13: TypePointer Output 12(ivec4) + 14(data): 13(ptr) Variable Output +15(gl_CoreIDARM): 9(ptr) Variable Input +17(gl_CoreCountARM): 9(ptr) Variable Input +19(gl_CoreMaxIDARM): 9(ptr) Variable Input +21(gl_WarpIDARM): 9(ptr) Variable Input + 4(main): 2 Function None 3 + 5: Label + 8(temp): 7(ptr) Variable Function + 11: 6(int) Load 10(gl_WarpMaxIDARM) + Store 8(temp) 11 + 16: 6(int) Load 15(gl_CoreIDARM) + 18: 6(int) Load 17(gl_CoreCountARM) + 20: 6(int) Load 19(gl_CoreMaxIDARM) + 22: 6(int) Load 21(gl_WarpIDARM) + 23: 6(int) Load 8(temp) + 24: 6(int) IAdd 22 23 + 25: 12(ivec4) CompositeConstruct 16 18 20 24 + Store 14(data) 25 + Return + FunctionEnd diff --git a/Test/baseResults/spv.ARMCoreBuiltIns.vert.out b/Test/baseResults/spv.ARMCoreBuiltIns.vert.out new file mode 100644 index 000000000..5419be454 --- /dev/null +++ b/Test/baseResults/spv.ARMCoreBuiltIns.vert.out @@ -0,0 +1,65 @@ +spv.ARMCoreBuiltIns.vert +// Module Version 10000 +// Generated by (magic number): 8000b +// Id's are bound by 31 + + Capability Shader + Capability CoreBuiltinsARM + Extension "SPV_ARM_core_builtins" + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Vertex 4 "main" 10 18 20 22 24 + Source GLSL 450 + SourceExtension "GL_ARM_shader_core_builtins" + Name 4 "main" + Name 8 "temp" + Name 10 "gl_WarpMaxIDARM" + Name 13 "Output" + MemberName 13(Output) 0 "result" + Name 15 "" + Name 18 "gl_CoreIDARM" + Name 20 "gl_CoreCountARM" + Name 22 "gl_CoreMaxIDARM" + Name 24 "gl_WarpIDARM" + Decorate 10(gl_WarpMaxIDARM) BuiltIn BuiltInWarpMaxIDARM + MemberDecorate 13(Output) 0 Offset 0 + Decorate 13(Output) BufferBlock + Decorate 15 DescriptorSet 0 + Decorate 15 Binding 0 + Decorate 18(gl_CoreIDARM) BuiltIn CoreIDARM + Decorate 20(gl_CoreCountARM) BuiltIn CoreCountARM + Decorate 22(gl_CoreMaxIDARM) BuiltIn CoreMaxIDARM + Decorate 24(gl_WarpIDARM) BuiltIn WarpIDARM + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeInt 32 0 + 7: TypePointer Function 6(int) + 9: TypePointer Input 6(int) +10(gl_WarpMaxIDARM): 9(ptr) Variable Input + 12: TypeVector 6(int) 4 + 13(Output): TypeStruct 12(ivec4) + 14: TypePointer Uniform 13(Output) + 15: 14(ptr) Variable Uniform + 16: TypeInt 32 1 + 17: 16(int) Constant 0 +18(gl_CoreIDARM): 9(ptr) Variable Input +20(gl_CoreCountARM): 9(ptr) Variable Input +22(gl_CoreMaxIDARM): 9(ptr) Variable Input +24(gl_WarpIDARM): 9(ptr) Variable Input + 29: TypePointer Uniform 12(ivec4) + 4(main): 2 Function None 3 + 5: Label + 8(temp): 7(ptr) Variable Function + 11: 6(int) Load 10(gl_WarpMaxIDARM) + Store 8(temp) 11 + 19: 6(int) Load 18(gl_CoreIDARM) + 21: 6(int) Load 20(gl_CoreCountARM) + 23: 6(int) Load 22(gl_CoreMaxIDARM) + 25: 6(int) Load 24(gl_WarpIDARM) + 26: 6(int) Load 8(temp) + 27: 6(int) IAdd 25 26 + 28: 12(ivec4) CompositeConstruct 19 21 23 27 + 30: 29(ptr) AccessChain 15 17 + Store 30 28 + Return + FunctionEnd diff --git a/Test/spv.ARMCoreBuiltIns.frag b/Test/spv.ARMCoreBuiltIns.frag new file mode 100644 index 000000000..deb3e5539 --- /dev/null +++ b/Test/spv.ARMCoreBuiltIns.frag @@ -0,0 +1,8 @@ +#version 450 +#extension GL_ARM_shader_core_builtins: enable +layout(location = 0) out uvec4 data; +void main (void) +{ + uint temp = gl_WarpMaxIDARM; + data = uvec4(gl_CoreIDARM, gl_CoreCountARM, gl_CoreMaxIDARM, gl_WarpIDARM + temp); +} diff --git a/Test/spv.ARMCoreBuiltIns.vert b/Test/spv.ARMCoreBuiltIns.vert new file mode 100644 index 000000000..2bed18e89 --- /dev/null +++ b/Test/spv.ARMCoreBuiltIns.vert @@ -0,0 +1,12 @@ +#version 450 +#extension GL_ARM_shader_core_builtins: enable +layout(set = 0, binding = 0, std430) buffer Output +{ + uvec4 result; +}; + +void main (void) +{ + uint temp = gl_WarpMaxIDARM; + result = uvec4(gl_CoreIDARM, gl_CoreCountARM, gl_CoreMaxIDARM, gl_WarpIDARM + temp); +} diff --git a/glslang/Include/BaseTypes.h b/glslang/Include/BaseTypes.h index 156d98b9a..e21865662 100644 --- a/glslang/Include/BaseTypes.h +++ b/glslang/Include/BaseTypes.h @@ -316,6 +316,13 @@ enum TBuiltInVariable { EbvByteAddressBuffer, EbvRWByteAddressBuffer, + // ARM specific core builtins + EbvCoreCountARM, + EbvCoreIDARM, + EbvCoreMaxIDARM, + EbvWarpIDARM, + EbvWarpMaxIDARM, + EbvLast }; diff --git a/glslang/MachineIndependent/Initialize.cpp b/glslang/MachineIndependent/Initialize.cpp index 5a9e5003d..53078ec7d 100644 --- a/glslang/MachineIndependent/Initialize.cpp +++ b/glslang/MachineIndependent/Initialize.cpp @@ -5737,6 +5737,12 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV "in highp uint gl_SMCountNV;" "in highp uint gl_WarpIDNV;" "in highp uint gl_SMIDNV;" + // GL_ARM_shader_core_builtins + "in highp uint gl_CoreIDARM;" + "in highp uint gl_CoreCountARM;" + "in highp uint gl_CoreMaxIDARM;" + "in highp uint gl_WarpIDARM;" + "in highp uint gl_WarpMaxIDARM;" "\n"; const char* fragmentSubgroupDecls = "flat in mediump uint gl_SubgroupSize;" @@ -5751,6 +5757,12 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV "flat in highp uint gl_SMCountNV;" "flat in highp uint gl_WarpIDNV;" "flat in highp uint gl_SMIDNV;" + // GL_ARM_shader_core_builtins + "flat in highp uint gl_CoreIDARM;" + "flat in highp uint gl_CoreCountARM;" + "flat in highp uint gl_CoreMaxIDARM;" + "flat in highp uint gl_WarpIDARM;" + "flat in highp uint gl_WarpMaxIDARM;" "\n"; const char* computeSubgroupDecls = "in highp uint gl_NumSubgroups;" @@ -5770,6 +5782,12 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV "in highp uint gl_SMCountNV;" "in highp volatile uint gl_WarpIDNV;" "in highp volatile uint gl_SMIDNV;" + // GL_ARM_shader_core_builtins + "in highp uint gl_CoreIDARM;" + "in highp uint gl_CoreCountARM;" + "in highp uint gl_CoreMaxIDARM;" + "in highp uint gl_WarpIDARM;" + "in highp uint gl_WarpMaxIDARM;" "\n"; stageBuiltins[EShLangVertex] .append(subgroupDecls); @@ -8036,6 +8054,19 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion BuiltInVariable("gl_SMCountNV", EbvSMCount, symbolTable); BuiltInVariable("gl_WarpIDNV", EbvWarpID, symbolTable); BuiltInVariable("gl_SMIDNV", EbvSMID, symbolTable); + + // GL_ARM_shader_core_builtins + symbolTable.setVariableExtensions("gl_CoreCountARM", 1, &E_GL_ARM_shader_core_builtins); + symbolTable.setVariableExtensions("gl_CoreIDARM", 1, &E_GL_ARM_shader_core_builtins); + symbolTable.setVariableExtensions("gl_CoreMaxIDARM", 1, &E_GL_ARM_shader_core_builtins); + symbolTable.setVariableExtensions("gl_WarpIDARM", 1, &E_GL_ARM_shader_core_builtins); + symbolTable.setVariableExtensions("gl_WarpMaxIDARM", 1, &E_GL_ARM_shader_core_builtins); + + BuiltInVariable("gl_CoreCountARM", EbvCoreCountARM, symbolTable); + BuiltInVariable("gl_CoreIDARM", EbvCoreIDARM, symbolTable); + BuiltInVariable("gl_CoreMaxIDARM", EbvCoreMaxIDARM, symbolTable); + BuiltInVariable("gl_WarpIDARM", EbvWarpIDARM, symbolTable); + BuiltInVariable("gl_WarpMaxIDARM", EbvWarpMaxIDARM, symbolTable); } if (language == EShLangGeometry || language == EShLangVertex) { @@ -8551,6 +8582,19 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion BuiltInVariable("gl_SMCountNV", EbvSMCount, symbolTable); BuiltInVariable("gl_WarpIDNV", EbvWarpID, symbolTable); BuiltInVariable("gl_SMIDNV", EbvSMID, symbolTable); + + // GL_ARM_shader_core_builtins + symbolTable.setVariableExtensions("gl_CoreCountARM", 1, &E_GL_ARM_shader_core_builtins); + symbolTable.setVariableExtensions("gl_CoreIDARM", 1, &E_GL_ARM_shader_core_builtins); + symbolTable.setVariableExtensions("gl_CoreMaxIDARM", 1, &E_GL_ARM_shader_core_builtins); + symbolTable.setVariableExtensions("gl_WarpIDARM", 1, &E_GL_ARM_shader_core_builtins); + symbolTable.setVariableExtensions("gl_WarpMaxIDARM", 1, &E_GL_ARM_shader_core_builtins); + + BuiltInVariable("gl_CoreCountARM", EbvCoreCountARM, symbolTable); + BuiltInVariable("gl_CoreIDARM", EbvCoreIDARM, symbolTable); + BuiltInVariable("gl_CoreMaxIDARM", EbvCoreMaxIDARM, symbolTable); + BuiltInVariable("gl_WarpIDARM", EbvWarpIDARM, symbolTable); + BuiltInVariable("gl_WarpMaxIDARM", EbvWarpMaxIDARM, symbolTable); } if (profile == EEsProfile) { @@ -8694,6 +8738,19 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion BuiltInVariable("gl_SMCountNV", EbvSMCount, symbolTable); BuiltInVariable("gl_WarpIDNV", EbvWarpID, symbolTable); BuiltInVariable("gl_SMIDNV", EbvSMID, symbolTable); + + // GL_ARM_shader_core_builtins + symbolTable.setVariableExtensions("gl_CoreCountARM", 1, &E_GL_ARM_shader_core_builtins); + symbolTable.setVariableExtensions("gl_CoreIDARM", 1, &E_GL_ARM_shader_core_builtins); + symbolTable.setVariableExtensions("gl_CoreMaxIDARM", 1, &E_GL_ARM_shader_core_builtins); + symbolTable.setVariableExtensions("gl_WarpIDARM", 1, &E_GL_ARM_shader_core_builtins); + symbolTable.setVariableExtensions("gl_WarpMaxIDARM", 1, &E_GL_ARM_shader_core_builtins); + + BuiltInVariable("gl_CoreCountARM", EbvCoreCountARM, symbolTable); + BuiltInVariable("gl_CoreIDARM", EbvCoreIDARM, symbolTable); + BuiltInVariable("gl_CoreMaxIDARM", EbvCoreMaxIDARM, symbolTable); + BuiltInVariable("gl_WarpIDARM", EbvWarpIDARM, symbolTable); + BuiltInVariable("gl_WarpMaxIDARM", EbvWarpMaxIDARM, symbolTable); } // GL_KHR_shader_subgroup @@ -8888,6 +8945,19 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion BuiltInVariable("gl_SMCountNV", EbvSMCount, symbolTable); BuiltInVariable("gl_WarpIDNV", EbvWarpID, symbolTable); BuiltInVariable("gl_SMIDNV", EbvSMID, symbolTable); + + // GL_ARM_shader_core_builtins + symbolTable.setVariableExtensions("gl_CoreCountARM", 1, &E_GL_ARM_shader_core_builtins); + symbolTable.setVariableExtensions("gl_CoreIDARM", 1, &E_GL_ARM_shader_core_builtins); + symbolTable.setVariableExtensions("gl_CoreMaxIDARM", 1, &E_GL_ARM_shader_core_builtins); + symbolTable.setVariableExtensions("gl_WarpIDARM", 1, &E_GL_ARM_shader_core_builtins); + symbolTable.setVariableExtensions("gl_WarpMaxIDARM", 1, &E_GL_ARM_shader_core_builtins); + + BuiltInVariable("gl_CoreCountARM", EbvCoreCountARM, symbolTable); + BuiltInVariable("gl_CoreIDARM", EbvCoreIDARM, symbolTable); + BuiltInVariable("gl_CoreMaxIDARM", EbvCoreMaxIDARM, symbolTable); + BuiltInVariable("gl_WarpIDARM", EbvWarpIDARM, symbolTable); + BuiltInVariable("gl_WarpMaxIDARM", EbvWarpMaxIDARM, symbolTable); } if ((profile == EEsProfile && version >= 310) || (profile != EEsProfile && version >= 450)) { @@ -9094,6 +9164,19 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion BuiltInVariable("gl_SMCountNV", EbvSMCount, symbolTable); BuiltInVariable("gl_WarpIDNV", EbvWarpID, symbolTable); BuiltInVariable("gl_SMIDNV", EbvSMID, symbolTable); + + // GL_ARM_shader_core_builtins + symbolTable.setVariableExtensions("gl_CoreCountARM", 1, &E_GL_ARM_shader_core_builtins); + symbolTable.setVariableExtensions("gl_CoreIDARM", 1, &E_GL_ARM_shader_core_builtins); + symbolTable.setVariableExtensions("gl_CoreMaxIDARM", 1, &E_GL_ARM_shader_core_builtins); + symbolTable.setVariableExtensions("gl_WarpIDARM", 1, &E_GL_ARM_shader_core_builtins); + symbolTable.setVariableExtensions("gl_WarpMaxIDARM", 1, &E_GL_ARM_shader_core_builtins); + + BuiltInVariable("gl_CoreCountARM", EbvCoreCountARM, symbolTable); + BuiltInVariable("gl_CoreIDARM", EbvCoreIDARM, symbolTable); + BuiltInVariable("gl_CoreMaxIDARM", EbvCoreMaxIDARM, symbolTable); + BuiltInVariable("gl_WarpIDARM", EbvWarpIDARM, symbolTable); + BuiltInVariable("gl_WarpMaxIDARM", EbvWarpMaxIDARM, symbolTable); } if ((profile == EEsProfile && version >= 310) || @@ -9224,6 +9307,19 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion BuiltInVariable("gl_SMCountNV", EbvSMCount, symbolTable); BuiltInVariable("gl_WarpIDNV", EbvWarpID, symbolTable); BuiltInVariable("gl_SMIDNV", EbvSMID, symbolTable); + + // GL_ARM_shader_core_builtins + symbolTable.setVariableExtensions("gl_CoreCountARM", 1, &E_GL_ARM_shader_core_builtins); + symbolTable.setVariableExtensions("gl_CoreIDARM", 1, &E_GL_ARM_shader_core_builtins); + symbolTable.setVariableExtensions("gl_CoreMaxIDARM", 1, &E_GL_ARM_shader_core_builtins); + symbolTable.setVariableExtensions("gl_WarpIDARM", 1, &E_GL_ARM_shader_core_builtins); + symbolTable.setVariableExtensions("gl_WarpMaxIDARM", 1, &E_GL_ARM_shader_core_builtins); + + BuiltInVariable("gl_CoreCountARM", EbvCoreCountARM, symbolTable); + BuiltInVariable("gl_CoreIDARM", EbvCoreIDARM, symbolTable); + BuiltInVariable("gl_CoreMaxIDARM", EbvCoreMaxIDARM, symbolTable); + BuiltInVariable("gl_WarpIDARM", EbvWarpIDARM, symbolTable); + BuiltInVariable("gl_WarpMaxIDARM", EbvWarpMaxIDARM, symbolTable); } if ((profile == EEsProfile && version >= 310) || (profile != EEsProfile && version >= 450)) { diff --git a/glslang/MachineIndependent/Versions.cpp b/glslang/MachineIndependent/Versions.cpp index 154180258..b43f2b865 100644 --- a/glslang/MachineIndependent/Versions.cpp +++ b/glslang/MachineIndependent/Versions.cpp @@ -301,6 +301,10 @@ void TParseVersions::initializeExtensionBehavior() extensionBehavior[E_GL_NV_shader_sm_builtins] = EBhDisable; extensionBehavior[E_GL_NV_integer_cooperative_matrix] = EBhDisable; + // ARM + extensionBehavior[E_GL_ARM_shader_core_builtins] = EBhDisable; + + // AEP extensionBehavior[E_GL_ANDROID_extension_pack_es31a] = EBhDisable; extensionBehavior[E_GL_KHR_blend_equation_advanced] = EBhDisable; diff --git a/glslang/MachineIndependent/Versions.h b/glslang/MachineIndependent/Versions.h index f06abdd6f..d0a3effb2 100644 --- a/glslang/MachineIndependent/Versions.h +++ b/glslang/MachineIndependent/Versions.h @@ -265,6 +265,9 @@ const char* const E_GL_NV_compute_shader_derivatives = "GL_NV_compute const char* const E_GL_NV_shader_texture_footprint = "GL_NV_shader_texture_footprint"; const char* const E_GL_NV_mesh_shader = "GL_NV_mesh_shader"; +// ARM +const char* const E_GL_ARM_shader_core_builtins = "GL_ARM_shader_core_builtins"; + // Arrays of extensions for the above viewportEXTs duplications const char* const viewportEXTs[] = { E_GL_ARB_shader_viewport_layer_array, E_GL_NV_viewport_array2 }; diff --git a/gtests/Spv.FromFile.cpp b/gtests/Spv.FromFile.cpp index e1b7a257a..a3dc8db29 100644 --- a/gtests/Spv.FromFile.cpp +++ b/gtests/Spv.FromFile.cpp @@ -493,6 +493,8 @@ INSTANTIATE_TEST_SUITE_P( "spv.samplerlessTextureFunctions.frag", "spv.smBuiltins.vert", "spv.smBuiltins.frag", + "spv.ARMCoreBuiltIns.vert", + "spv.ARMCoreBuiltIns.frag", "spv.builtin.PrimitiveShadingRateEXT.vert", "spv.builtin.ShadingRateEXT.frag", "spv.atomicAdd.bufferReference.comp",