update glslang

This commit is contained in:
Sasha Szpakowski
2024-01-07 21:14:01 -04:00
parent 501c41e10f
commit a99d5afc57
92 changed files with 17686 additions and 13149 deletions
+10 -7
View File
@@ -1391,6 +1391,7 @@ set(LOVE_SRC_3P_GLSLANG_GLSLANG_MACHINEINDEPENDENT
src/libraries/glslang/glslang/MachineIndependent/Scan.h
src/libraries/glslang/glslang/MachineIndependent/ScanContext.h
src/libraries/glslang/glslang/MachineIndependent/ShaderLang.cpp
src/libraries/glslang/glslang/MachineIndependent/span.h
src/libraries/glslang/glslang/MachineIndependent/SpirvIntrinsics.cpp
src/libraries/glslang/glslang/MachineIndependent/SymbolTable.cpp
src/libraries/glslang/glslang/MachineIndependent/SymbolTable.h
@@ -1405,7 +1406,6 @@ set(LOVE_SRC_3P_GLSLANG_GLSLANG_OSDEPENDENT
if(MSVC OR MINGW)
set(LOVE_SRC_3P_GLSLANG_GLSLANG_OSDEPENDENT
${LOVE_SRC_3P_GLSLANG_GLSLANG_OSDEPENDENT}
src/libraries/glslang/glslang/OSDependent/Windows/main.cpp
src/libraries/glslang/glslang/OSDependent/Windows/ossource.cpp
)
else()
@@ -1416,9 +1416,14 @@ else()
endif()
set(LOVE_SRC_3P_GLSLANG_GLSLANG_PUBLIC
src/libraries/glslang/glslang/Public/ResourceLimits.h
src/libraries/glslang/glslang/Public/ShaderLang.h
)
set(LOVE_SRC_3P_GLSLANG_GLSLANG_RESOURCELIMITS
src/libraries/glslang/glslang/ResourceLimits/ResourceLimits.cpp
)
set(LOVE_SRC_3P_GLSLANG_GLSLANG
src/libraries/glslang/glslang/build_info.h
${LOVE_SRC_3P_GLSLANG_GLSLANG_GENERICCODEGEN}
@@ -1426,11 +1431,7 @@ set(LOVE_SRC_3P_GLSLANG_GLSLANG
${LOVE_SRC_3P_GLSLANG_GLSLANG_MACHINEINDEPENDENT}
${LOVE_SRC_3P_GLSLANG_GLSLANG_OSDEPENDENT}
${LOVE_SRC_3P_GLSLANG_GLSLANG_PUBLIC}
)
set(LOVE_SRC_3P_GLSLANG_OGLCOMPILERSDLL
src/libraries/glslang/OGLCompilersDLL/InitializeDll.cpp
src/libraries/glslang/OGLCompilersDLL/InitializeDll.h
${LOVE_SRC_3P_GLSLANG_GLSLANG_RESOURCELIMITS}
)
set(LOVE_SRC_3P_GLSLANG_SPIRV
@@ -1440,9 +1441,11 @@ set(LOVE_SRC_3P_GLSLANG_SPIRV
src/libraries/glslang/SPIRV/doc.cpp
src/libraries/glslang/SPIRV/doc.h
src/libraries/glslang/SPIRV/GLSL.ext.AMD.h
src/libraries/glslang/SPIRV/GLSL.ext.ARM.h
src/libraries/glslang/SPIRV/GLSL.ext.EXT.h
src/libraries/glslang/SPIRV/GLSL.ext.KHR.h
src/libraries/glslang/SPIRV/GLSL.ext.NV.h
src/libraries/glslang/SPIRV/GLSL.ext.QCOM.h
src/libraries/glslang/SPIRV/GLSL.std.450.h
src/libraries/glslang/SPIRV/GlslangToSpv.cpp
src/libraries/glslang/SPIRV/GlslangToSpv.h
@@ -1451,6 +1454,7 @@ set(LOVE_SRC_3P_GLSLANG_SPIRV
src/libraries/glslang/SPIRV/Logger.cpp
src/libraries/glslang/SPIRV/Logger.h
src/libraries/glslang/SPIRV/NonSemanticDebugPrintf.h
src/libraries/glslang/SPIRV/NonSemanticShaderDebugInfo100.h
src/libraries/glslang/SPIRV/spirv.hpp
src/libraries/glslang/SPIRV/SpvBuilder.cpp
src/libraries/glslang/SPIRV/SpvBuilder.h
@@ -1464,7 +1468,6 @@ set(LOVE_SRC_3P_GLSLANG_SPIRV
set(LOVE_SRC_3P_GLSLANG
${LOVE_SRC_3P_GLSLANG_GLSLANG}
${LOVE_SRC_3P_GLSLANG_OGLCOMPILERSDLL}
${LOVE_SRC_3P_GLSLANG_SPIRV}
)
@@ -64,6 +64,15 @@
D9DAB92D2961F10000C64820 /* TextShaper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D9DAB9282961F10000C64820 /* TextShaper.cpp */; };
D9DAB92E2961F10000C64820 /* TextShaper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D9DAB9282961F10000C64820 /* TextShaper.cpp */; };
D9DAB9322963CD7500C64820 /* harfbuzz.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D9DAB9312963CD7500C64820 /* harfbuzz.framework */; };
D9DB6E272B4B40660037A1F6 /* ResourceLimits.h in Headers */ = {isa = PBXBuildFile; fileRef = D9DB6E252B4B40660037A1F6 /* ResourceLimits.h */; };
D9DB6E292B4B40970037A1F6 /* span.h in Headers */ = {isa = PBXBuildFile; fileRef = D9DB6E282B4B40970037A1F6 /* span.h */; };
D9DB6E362B4B41100037A1F6 /* ResourceLimits.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D9DB6E332B4B41100037A1F6 /* ResourceLimits.cpp */; };
D9DB6E372B4B41100037A1F6 /* ResourceLimits.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D9DB6E332B4B41100037A1F6 /* ResourceLimits.cpp */; };
D9DB6E3E2B4B41580037A1F6 /* NonSemanticDebugPrintf.h in Headers */ = {isa = PBXBuildFile; fileRef = D9DB6E382B4B41570037A1F6 /* NonSemanticDebugPrintf.h */; };
D9DB6E3F2B4B41580037A1F6 /* NonSemanticShaderDebugInfo100.h in Headers */ = {isa = PBXBuildFile; fileRef = D9DB6E392B4B41570037A1F6 /* NonSemanticShaderDebugInfo100.h */; };
D9DB6E402B4B41580037A1F6 /* GLSL.ext.ARM.h in Headers */ = {isa = PBXBuildFile; fileRef = D9DB6E3A2B4B41570037A1F6 /* GLSL.ext.ARM.h */; };
D9DB6E412B4B41580037A1F6 /* GLSL.ext.QCOM.h in Headers */ = {isa = PBXBuildFile; fileRef = D9DB6E3B2B4B41580037A1F6 /* GLSL.ext.QCOM.h */; };
D9DB6E452B4B80E80037A1F6 /* build_info.h in Headers */ = {isa = PBXBuildFile; fileRef = D9DB6E442B4B80E80037A1F6 /* build_info.h */; };
FA0A3A5F23366CE9001C269E /* floattypes.h in Headers */ = {isa = PBXBuildFile; fileRef = FA0A3A5D23366CE9001C269E /* floattypes.h */; };
FA0A3A6023366CE9001C269E /* floattypes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA0A3A5E23366CE9001C269E /* floattypes.cpp */; };
FA0A3A6123366CE9001C269E /* floattypes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA0A3A5E23366CE9001C269E /* floattypes.cpp */; };
@@ -1288,9 +1297,6 @@
FAF140BB1E20934C00F898D2 /* ossource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FAF140211E20934C00F898D2 /* ossource.cpp */; };
FAF140BC1E20934C00F898D2 /* ossource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FAF140211E20934C00F898D2 /* ossource.cpp */; };
FAF140C41E20934C00F898D2 /* ShaderLang.h in Headers */ = {isa = PBXBuildFile; fileRef = FAF140291E20934C00F898D2 /* ShaderLang.h */; };
FAF140DB1E20934C00F898D2 /* InitializeDll.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FAF1403B1E20934C00F898D2 /* InitializeDll.cpp */; };
FAF140DC1E20934C00F898D2 /* InitializeDll.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FAF1403B1E20934C00F898D2 /* InitializeDll.cpp */; };
FAF140DD1E20934C00F898D2 /* InitializeDll.h in Headers */ = {isa = PBXBuildFile; fileRef = FAF1403C1E20934C00F898D2 /* InitializeDll.h */; };
FAF6C9DA23C2DE2900D7B5BC /* SPVRemapper.h in Headers */ = {isa = PBXBuildFile; fileRef = FAF6C9C123C2DE2900D7B5BC /* SPVRemapper.h */; };
FAF6C9DB23C2DE2900D7B5BC /* SpvBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = FAF6C9C223C2DE2900D7B5BC /* SpvBuilder.h */; };
FAF6C9DC23C2DE2900D7B5BC /* SpvPostProcess.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FAF6C9C323C2DE2900D7B5BC /* SpvPostProcess.cpp */; };
@@ -1409,6 +1415,14 @@
D9DAB9272961F0FF00C64820 /* TextShaper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextShaper.h; sourceTree = "<group>"; };
D9DAB9282961F10000C64820 /* TextShaper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextShaper.cpp; sourceTree = "<group>"; };
D9DAB9312963CD7500C64820 /* harfbuzz.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = harfbuzz.framework; path = macosx/Frameworks/harfbuzz.framework; sourceTree = "<group>"; };
D9DB6E252B4B40660037A1F6 /* ResourceLimits.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLimits.h; sourceTree = "<group>"; };
D9DB6E282B4B40970037A1F6 /* span.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = span.h; sourceTree = "<group>"; };
D9DB6E332B4B41100037A1F6 /* ResourceLimits.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceLimits.cpp; sourceTree = "<group>"; };
D9DB6E382B4B41570037A1F6 /* NonSemanticDebugPrintf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NonSemanticDebugPrintf.h; sourceTree = "<group>"; };
D9DB6E392B4B41570037A1F6 /* NonSemanticShaderDebugInfo100.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NonSemanticShaderDebugInfo100.h; sourceTree = "<group>"; };
D9DB6E3A2B4B41570037A1F6 /* GLSL.ext.ARM.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GLSL.ext.ARM.h; sourceTree = "<group>"; };
D9DB6E3B2B4B41580037A1F6 /* GLSL.ext.QCOM.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GLSL.ext.QCOM.h; sourceTree = "<group>"; };
D9DB6E442B4B80E80037A1F6 /* build_info.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = build_info.h; sourceTree = "<group>"; };
FA08F5AE16C7525600F007B5 /* liblove-macosx.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "liblove-macosx.plist"; path = "macosx/liblove-macosx.plist"; sourceTree = "<group>"; };
FA0A3A5D23366CE9001C269E /* floattypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = floattypes.h; sourceTree = "<group>"; };
FA0A3A5E23366CE9001C269E /* floattypes.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = floattypes.cpp; sourceTree = "<group>"; };
@@ -1945,8 +1959,6 @@
FA7DA04C1C16874A0056B200 /* wrap_Math.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = wrap_Math.lua; sourceTree = "<group>"; };
FA7E9206277E120900C24CB2 /* theora.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = theora.xcframework; path = ios/libraries/theora.xcframework; sourceTree = "<group>"; };
FA84DE5D2778D7DB002674C6 /* SpirvIntrinsics.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SpirvIntrinsics.h; sourceTree = "<group>"; };
FA84DE5E2778D7DC002674C6 /* glslang_c_interface.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = glslang_c_interface.h; sourceTree = "<group>"; };
FA84DE5F2778D7DC002674C6 /* glslang_c_shader_types.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = glslang_c_shader_types.h; sourceTree = "<group>"; };
FA84DE602778D7F3002674C6 /* SpirvIntrinsics.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SpirvIntrinsics.cpp; sourceTree = "<group>"; };
FA84DE6427791C36002674C6 /* GraphicsReadback.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsReadback.cpp; sourceTree = "<group>"; };
FA84DE6527791C36002674C6 /* GraphicsReadback.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GraphicsReadback.h; sourceTree = "<group>"; };
@@ -2199,7 +2211,6 @@
FADF543A1E3DAFF700012CC0 /* wrap_Graphics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wrap_Graphics.h; sourceTree = "<group>"; };
FAE272501C05A15B00A67640 /* ParticleSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParticleSystem.cpp; sourceTree = "<group>"; };
FAE272511C05A15B00A67640 /* ParticleSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParticleSystem.h; sourceTree = "<group>"; };
FAEC229F2534F25100EBD925 /* build_info.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = build_info.h; sourceTree = "<group>"; };
FAECA1B01F3164700095D008 /* CompressedSlice.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CompressedSlice.cpp; sourceTree = "<group>"; };
FAECA1B11F3164700095D008 /* CompressedSlice.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CompressedSlice.h; sourceTree = "<group>"; };
FAF13FC21E20934C00F898D2 /* CodeGen.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CodeGen.cpp; sourceTree = "<group>"; };
@@ -2261,8 +2272,6 @@
FAF140031E20934C00F898D2 /* osinclude.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = osinclude.h; sourceTree = "<group>"; };
FAF140211E20934C00F898D2 /* ossource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ossource.cpp; sourceTree = "<group>"; };
FAF140291E20934C00F898D2 /* ShaderLang.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShaderLang.h; sourceTree = "<group>"; };
FAF1403B1E20934C00F898D2 /* InitializeDll.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InitializeDll.cpp; sourceTree = "<group>"; };
FAF1403C1E20934C00F898D2 /* InitializeDll.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InitializeDll.h; sourceTree = "<group>"; };
FAF1889C1E9DA834008C1479 /* Optional.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Optional.h; sourceTree = "<group>"; };
FAF6C9C123C2DE2900D7B5BC /* SPVRemapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPVRemapper.h; sourceTree = "<group>"; };
FAF6C9C223C2DE2900D7B5BC /* SpvBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpvBuilder.h; sourceTree = "<group>"; };
@@ -2371,6 +2380,14 @@
sourceTree = "<group>";
usesTabs = 1;
};
D9DB6E312B4B41100037A1F6 /* ResourceLimits */ = {
isa = PBXGroup;
children = (
D9DB6E332B4B41100037A1F6 /* ResourceLimits.cpp */,
);
path = ResourceLimits;
sourceTree = "<group>";
};
FA08F5AC16C751BA00F007B5 /* Resources */ = {
isa = PBXGroup;
children = (
@@ -3870,7 +3887,6 @@
isa = PBXGroup;
children = (
FAF13FC01E20934C00F898D2 /* glslang */,
FAF1403A1E20934C00F898D2 /* OGLCompilersDLL */,
FAF6C9C023C2DE2900D7B5BC /* SPIRV */,
);
path = glslang;
@@ -3879,12 +3895,13 @@
FAF13FC01E20934C00F898D2 /* glslang */ = {
isa = PBXGroup;
children = (
FAEC229F2534F25100EBD925 /* build_info.h */,
D9DB6E442B4B80E80037A1F6 /* build_info.h */,
FAF13FC11E20934C00F898D2 /* GenericCodeGen */,
FAF13FC41E20934C00F898D2 /* Include */,
FAF13FD21E20934C00F898D2 /* MachineIndependent */,
FAF140021E20934C00F898D2 /* OSDependent */,
FAF140281E20934C00F898D2 /* Public */,
D9DB6E312B4B41100037A1F6 /* ResourceLimits */,
);
path = glslang;
sourceTree = "<group>";
@@ -3905,8 +3922,6 @@
FAF13FC61E20934C00F898D2 /* BaseTypes.h */,
FAF13FC71E20934C00F898D2 /* Common.h */,
FAF13FC81E20934C00F898D2 /* ConstantUnion.h */,
FA84DE5E2778D7DC002674C6 /* glslang_c_interface.h */,
FA84DE5F2778D7DC002674C6 /* glslang_c_shader_types.h */,
FAF13FC91E20934C00F898D2 /* InfoSink.h */,
FAF13FCA1E20934C00F898D2 /* InitializeGlobals.h */,
FAF13FCB1E20934C00F898D2 /* intermediate.h */,
@@ -3958,6 +3973,7 @@
FAF13FFB1E20934C00F898D2 /* Scan.h */,
FAF13FFC1E20934C00F898D2 /* ScanContext.h */,
FAF13FFD1E20934C00F898D2 /* ShaderLang.cpp */,
D9DB6E282B4B40970037A1F6 /* span.h */,
FA84DE602778D7F3002674C6 /* SpirvIntrinsics.cpp */,
FAF13FFE1E20934C00F898D2 /* SymbolTable.cpp */,
FAF13FFF1E20934C00F898D2 /* SymbolTable.h */,
@@ -4001,20 +4017,12 @@
FAF140281E20934C00F898D2 /* Public */ = {
isa = PBXGroup;
children = (
D9DB6E252B4B40660037A1F6 /* ResourceLimits.h */,
FAF140291E20934C00F898D2 /* ShaderLang.h */,
);
path = Public;
sourceTree = "<group>";
};
FAF1403A1E20934C00F898D2 /* OGLCompilersDLL */ = {
isa = PBXGroup;
children = (
FAF1403B1E20934C00F898D2 /* InitializeDll.cpp */,
FAF1403C1E20934C00F898D2 /* InitializeDll.h */,
);
path = OGLCompilersDLL;
sourceTree = "<group>";
};
FAF6C9C023C2DE2900D7B5BC /* SPIRV */ = {
isa = PBXGroup;
children = (
@@ -4024,9 +4032,11 @@
FAF6C9D823C2DE2900D7B5BC /* doc.cpp */,
FAF6C9C823C2DE2900D7B5BC /* doc.h */,
FAF6C9C723C2DE2900D7B5BC /* GLSL.ext.AMD.h */,
D9DB6E3A2B4B41570037A1F6 /* GLSL.ext.ARM.h */,
FAF6C9CB23C2DE2900D7B5BC /* GLSL.ext.EXT.h */,
FAF6C9CC23C2DE2900D7B5BC /* GLSL.ext.KHR.h */,
FAF6C9CD23C2DE2900D7B5BC /* GLSL.ext.NV.h */,
D9DB6E3B2B4B41580037A1F6 /* GLSL.ext.QCOM.h */,
FAF6C9D323C2DE2900D7B5BC /* GLSL.std.450.h */,
FAF6C9CE23C2DE2900D7B5BC /* GlslangToSpv.cpp */,
FAF6C9D223C2DE2900D7B5BC /* GlslangToSpv.h */,
@@ -4034,6 +4044,8 @@
FAF6C9C623C2DE2900D7B5BC /* InReadableOrder.cpp */,
FAF6C9D523C2DE2900D7B5BC /* Logger.cpp */,
FAF6C9D723C2DE2900D7B5BC /* Logger.h */,
D9DB6E382B4B41570037A1F6 /* NonSemanticDebugPrintf.h */,
D9DB6E392B4B41570037A1F6 /* NonSemanticShaderDebugInfo100.h */,
FAF6C9C923C2DE2900D7B5BC /* spirv.hpp */,
FAF6C9CA23C2DE2900D7B5BC /* SpvBuilder.cpp */,
FAF6C9C223C2DE2900D7B5BC /* SpvBuilder.h */,
@@ -4091,6 +4103,7 @@
FAF6C9EF23C2DE2900D7B5BC /* disassemble.h in Headers */,
FA18CF4123DCF67900263725 /* spirv_common.hpp in Headers */,
FAC7CD901FE35E95006A60C7 /* physfs_miniz.h in Headers */,
D9DB6E3F2B4B41580037A1F6 /* NonSemanticShaderDebugInfo100.h in Headers */,
FA0B791D1A958E3B000E1D17 /* b64.h in Headers */,
FA0B7DC61A95902C000E1D17 /* wrap_JoystickModule.h in Headers */,
FA0B7D201A95902C000E1D17 /* ImageRasterizer.h in Headers */,
@@ -4109,6 +4122,7 @@
FAF140871E20934C00F898D2 /* parseVersions.h in Headers */,
FA0B7AC61A958EA3000E1D17 /* types.h in Headers */,
FA0B7DBD1A95902C000E1D17 /* Joystick.h in Headers */,
D9DB6E452B4B80E80037A1F6 /* build_info.h in Headers */,
FA0B7D0E1A95902C000E1D17 /* wrap_Filesystem.h in Headers */,
FA0B7EE41A95902D000E1D17 /* Window.h in Headers */,
FA0B7CFC1A95902C000E1D17 /* Filesystem.h in Headers */,
@@ -4297,12 +4311,14 @@
FA0B7AC81A958EA3000E1D17 /* utility.h in Headers */,
FABDA9BA2552448300B5C523 /* b2_weld_joint.h in Headers */,
FA522D5323F9FF2A0059EE3C /* dr_mp3.h in Headers */,
D9DB6E272B4B40660037A1F6 /* ResourceLimits.h in Headers */,
FA0B791F1A958E3B000E1D17 /* Data.h in Headers */,
FA18CF4523DD1A8100263725 /* ShaderStage.h in Headers */,
217DFBE41D9F6D490055D849 /* headers.lua.h in Headers */,
FA0B7D021A95902C000E1D17 /* Filesystem.h in Headers */,
FA0B7E471A95902C000E1D17 /* wrap_Contact.h in Headers */,
FA0B7E021A95902C000E1D17 /* CircleShape.h in Headers */,
D9DB6E3E2B4B41580037A1F6 /* NonSemanticDebugPrintf.h in Headers */,
FABDA9E92552448300B5C523 /* b2_timer.h in Headers */,
FA0B7E111A95902C000E1D17 /* FrictionJoint.h in Headers */,
FA0B7AE01A958EA3000E1D17 /* lodepng.h in Headers */,
@@ -4362,6 +4378,7 @@
FA0B7DC31A95902C000E1D17 /* wrap_Joystick.h in Headers */,
FA18CF3B23DCF67900263725 /* spirv_cross_util.hpp in Headers */,
FAF140631E20934C00F898D2 /* Types.h in Headers */,
D9DB6E292B4B40970037A1F6 /* span.h in Headers */,
FACA06AF293EE5CD001A2557 /* Sensor.h in Headers */,
FA4F2BE61DE6650600CA37D7 /* wrap_Transform.h in Headers */,
FA0B7EE71A95902D000E1D17 /* Window.h in Headers */,
@@ -4378,7 +4395,6 @@
FABDA9DD2552448300B5C523 /* b2_contact.h in Headers */,
FABDA9802552448200B5C523 /* b2_circle_contact.h in Headers */,
217DFC101D9F6D490055D849 /* url.lua.h in Headers */,
FAF140DD1E20934C00F898D2 /* InitializeDll.h in Headers */,
FA0B7DF31A95902C000E1D17 /* wrap_Cursor.h in Headers */,
FA18CF2023DCF67900263725 /* spirv_hlsl.hpp in Headers */,
FA0B7D271A95902C000E1D17 /* wrap_Font.h in Headers */,
@@ -4437,6 +4453,7 @@
217DFC021D9F6D490055D849 /* tcp.h in Headers */,
FA3C5E441F8C368C0003C579 /* ShaderStage.h in Headers */,
FA0B79261A958E3B000E1D17 /* Exception.h in Headers */,
D9DB6E402B4B41580037A1F6 /* GLSL.ext.ARM.h in Headers */,
FA0B7D4D1A95902C000E1D17 /* Shader.h in Headers */,
FA0B793D1A958E3B000E1D17 /* runtime.h in Headers */,
FAF6C9E323C2DE2900D7B5BC /* GLSL.ext.AMD.h in Headers */,
@@ -4463,6 +4480,7 @@
FA6BDF90281219E900240F2A /* DataStream.h in Headers */,
FAF6C9DB23C2DE2900D7B5BC /* SpvBuilder.h in Headers */,
FA0B7EA21A95902C000E1D17 /* Sound.h in Headers */,
D9DB6E412B4B41580037A1F6 /* GLSL.ext.QCOM.h in Headers */,
FA0B7B331A958EA3000E1D17 /* wuff_config.h in Headers */,
FA0B7D3B1A95902C000E1D17 /* Graphics.h in Headers */,
FA0B7E6E1A95902C000E1D17 /* wrap_RevoluteJoint.h in Headers */,
@@ -4636,6 +4654,7 @@
FAF140A81E20934C00F898D2 /* ShaderLang.cpp in Sources */,
FA1BA09E1E16CFCE00AA2803 /* Font.cpp in Sources */,
FABDA9A12552448300B5C523 /* b2_gear_joint.cpp in Sources */,
D9DB6E372B4B41100037A1F6 /* ResourceLimits.cpp in Sources */,
FAE64A8A2071363100BC7981 /* physfs_archiver_wad.c in Sources */,
FA18CF4723DD1A8100263725 /* ShaderStage.mm in Sources */,
FA0B7ECC1A95902C000E1D17 /* wrap_Channel.cpp in Sources */,
@@ -4746,7 +4765,6 @@
FAF140AD1E20934C00F898D2 /* Versions.cpp in Sources */,
FA0B793C1A958E3B000E1D17 /* runtime.cpp in Sources */,
FA6BDF8A280B62A000240F2A /* GraphicsReadback.mm in Sources */,
FAF140DC1E20934C00F898D2 /* InitializeDll.cpp in Sources */,
FA0B7DBC1A95902C000E1D17 /* Joystick.cpp in Sources */,
FA0B7DAF1A95902C000E1D17 /* wrap_CompressedImageData.cpp in Sources */,
FA0B7AD51A958EA3000E1D17 /* unix.c in Sources */,
@@ -5065,6 +5083,7 @@
FA0B7D7C1A95902C000E1D17 /* Texture.cpp in Sources */,
FAF140BB1E20934C00F898D2 /* ossource.cpp in Sources */,
FA0B7ECB1A95902C000E1D17 /* wrap_Channel.cpp in Sources */,
D9DB6E362B4B41100037A1F6 /* ResourceLimits.cpp in Sources */,
FACA02F21F5E396B0084B28F /* HashFunction.cpp in Sources */,
FABDA9A02552448300B5C523 /* b2_gear_joint.cpp in Sources */,
FAF140A71E20934C00F898D2 /* ShaderLang.cpp in Sources */,
@@ -5186,7 +5205,6 @@
FAC7CD811FE35E95006A60C7 /* physfs_platform_os2.c in Sources */,
FABDA9962552448300B5C523 /* b2_distance_joint.cpp in Sources */,
FA0B7DBB1A95902C000E1D17 /* Joystick.cpp in Sources */,
FAF140DB1E20934C00F898D2 /* InitializeDll.cpp in Sources */,
FA0B7DAE1A95902C000E1D17 /* wrap_CompressedImageData.cpp in Sources */,
FA6A2B701F5F845F0074C308 /* wrap_DataView.cpp in Sources */,
FAB17BE61ABFAA9000F9BA27 /* lz4.c in Sources */,
@@ -1,165 +0,0 @@
//
// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
#define SH_EXPORTING
#include <cassert>
#include "InitializeDll.h"
#include "../glslang/Include/InitializeGlobals.h"
#include "../glslang/Public/ShaderLang.h"
#include "../glslang/Include/PoolAlloc.h"
namespace glslang {
OS_TLSIndex ThreadInitializeIndex = OS_INVALID_TLS_INDEX;
// Per-process initialization.
// Needs to be called at least once before parsing, etc. is done.
// Will also do thread initialization for the calling thread; other
// threads will need to do that explicitly.
bool InitProcess()
{
glslang::GetGlobalLock();
if (ThreadInitializeIndex != OS_INVALID_TLS_INDEX) {
//
// Function is re-entrant.
//
glslang::ReleaseGlobalLock();
return true;
}
ThreadInitializeIndex = OS_AllocTLSIndex();
if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX) {
assert(0 && "InitProcess(): Failed to allocate TLS area for init flag");
glslang::ReleaseGlobalLock();
return false;
}
if (! InitializePoolIndex()) {
assert(0 && "InitProcess(): Failed to initialize global pool");
glslang::ReleaseGlobalLock();
return false;
}
if (! InitThread()) {
assert(0 && "InitProcess(): Failed to initialize thread");
glslang::ReleaseGlobalLock();
return false;
}
glslang::ReleaseGlobalLock();
return true;
}
// Per-thread scoped initialization.
// Must be called at least once by each new thread sharing the
// symbol tables, etc., needed to parse.
bool InitThread()
{
//
// This function is re-entrant
//
if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX) {
assert(0 && "InitThread(): Process hasn't been initalised.");
return false;
}
if (OS_GetTLSValue(ThreadInitializeIndex) != 0)
return true;
if (! OS_SetTLSValue(ThreadInitializeIndex, (void *)1)) {
assert(0 && "InitThread(): Unable to set init flag.");
return false;
}
glslang::SetThreadPoolAllocator(nullptr);
return true;
}
// Not necessary to call this: InitThread() is reentrant, and the need
// to do per thread tear down has been removed.
//
// This is kept, with memory management removed, to satisfy any exiting
// calls to it that rely on it.
bool DetachThread()
{
bool success = true;
if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX)
return true;
//
// Function is re-entrant and this thread may not have been initialized.
//
if (OS_GetTLSValue(ThreadInitializeIndex) != 0) {
if (!OS_SetTLSValue(ThreadInitializeIndex, (void *)0)) {
assert(0 && "DetachThread(): Unable to clear init flag.");
success = false;
}
}
return success;
}
// Not necessary to call this: InitProcess() is reentrant.
//
// This is kept, with memory management removed, to satisfy any exiting
// calls to it that rely on it.
//
// Users of glslang should call shFinalize() or glslang::FinalizeProcess() for
// process-scoped memory tear down.
bool DetachProcess()
{
bool success = true;
if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX)
return true;
success = DetachThread();
OS_FreeTLSIndex(ThreadInitializeIndex);
ThreadInitializeIndex = OS_INVALID_TLS_INDEX;
return success;
}
} // end namespace glslang
@@ -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
@@ -39,5 +39,7 @@ static const char* const E_SPV_EXT_shader_atomic_float_add = "SPV_EXT_shader_ato
static const char* const E_SPV_EXT_shader_atomic_float16_add = "SPV_EXT_shader_atomic_float16_add";
static const char* const E_SPV_EXT_shader_atomic_float_min_max = "SPV_EXT_shader_atomic_float_min_max";
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";
#endif // #ifndef GLSLextEXT_H
+5 -1
View File
@@ -29,7 +29,7 @@
#define GLSLextKHR_H
static const int GLSLextKHRVersion = 100;
static const int GLSLextKHRRevision = 2;
static const int GLSLextKHRRevision = 3;
static const char* const E_SPV_KHR_shader_ballot = "SPV_KHR_shader_ballot";
static const char* const E_SPV_KHR_subgroup_vote = "SPV_KHR_subgroup_vote";
@@ -52,5 +52,9 @@ static const char* const E_SPV_KHR_fragment_shading_rate = "SPV_KHR_fragm
static const char* const E_SPV_KHR_terminate_invocation = "SPV_KHR_terminate_invocation";
static const char* const E_SPV_KHR_workgroup_memory_explicit_layout = "SPV_KHR_workgroup_memory_explicit_layout";
static const char* const E_SPV_KHR_subgroup_uniform_control_flow = "SPV_KHR_subgroup_uniform_control_flow";
static const char* const E_SPV_KHR_fragment_shader_barycentric = "SPV_KHR_fragment_shader_barycentric";
static const char* const E_SPV_AMD_shader_early_and_late_fragment_tests = "SPV_AMD_shader_early_and_late_fragment_tests";
static const char* const E_SPV_KHR_ray_tracing_position_fetch = "SPV_KHR_ray_tracing_position_fetch";
static const char* const E_SPV_KHR_cooperative_matrix = "SPV_KHR_cooperative_matrix";
#endif // #ifndef GLSLextKHR_H
@@ -81,4 +81,10 @@ const char* const E_SPV_NV_cooperative_matrix = "SPV_NV_cooperative_matrix";
//SPV_NV_shader_sm_builtins
const char* const E_SPV_NV_shader_sm_builtins = "SPV_NV_shader_sm_builtins";
//SPV_NV_shader_execution_reorder
const char* const E_SPV_NV_shader_invocation_reorder = "SPV_NV_shader_invocation_reorder";
//SPV_NV_displacement_micromap
const char* const E_SPV_NV_displacement_micromap = "SPV_NV_displacement_micromap";
#endif // #ifndef GLSLextNV_H
@@ -0,0 +1,41 @@
/*
** Copyright (c) 2021 The Khronos Group Inc.
**
** 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 GLSLextQCOM_H
#define GLSLextQCOM_H
enum BuiltIn;
enum Decoration;
enum Op;
enum Capability;
static const int GLSLextQCOMVersion = 100;
static const int GLSLextQCOMRevision = 1;
//SPV_QCOM_image_processing
const char* const E_SPV_QCOM_image_processing = "SPV_QCOM_image_processing";
#endif // #ifndef GLSLextQCOM_H
+1 -1
View File
@@ -13,7 +13,7 @@
**
** 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/
** 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,
+1243 -485
View File
File diff suppressed because it is too large Load Diff
+15 -9
View File
@@ -35,19 +35,25 @@
#pragma once
#if defined(_MSC_VER) && _MSC_VER >= 1900
#pragma warning(disable : 4464) // relative include path contains '..'
#endif
#include "SpvTools.h"
#include "../glslang/Include/intermediate.h"
#include <string>
#include <vector>
#include "Logger.h"
namespace glslang {
class TIntermediate;
struct SpvOptions {
bool generateDebugInfo {false};
bool stripDebugInfo {false};
bool disableOptimizer {true};
bool optimizeSize {false};
bool disassemble {false};
bool validate {false};
bool emitNonSemanticShaderDebugInfo {false};
bool emitNonSemanticShaderDebugSource{ false };
bool compileOnly{false};
};
void GetSpirvVersion(std::string&);
int GetSpirvGeneratorVersion();
@@ -55,7 +61,7 @@ void GlslangToSpv(const glslang::TIntermediate& intermediate, std::vector<unsign
SpvOptions* options = nullptr);
void GlslangToSpv(const glslang::TIntermediate& intermediate, std::vector<unsigned int>& spirv,
spv::SpvBuildLogger* logger, SpvOptions* options = nullptr);
void OutputSpvBin(const std::vector<unsigned int>& spirv, const char* baseName);
void OutputSpvHex(const std::vector<unsigned int>& spirv, const char* baseName, const char* varName);
bool OutputSpvBin(const std::vector<unsigned int>& spirv, const char* baseName);
bool OutputSpvHex(const std::vector<unsigned int>& spirv, const char* baseName, const char* varName);
}
-4
View File
@@ -32,8 +32,6 @@
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
#ifndef GLSLANG_WEB
#include "Logger.h"
#include <algorithm>
@@ -68,5 +66,3 @@ std::string SpvBuildLogger::getAllMessages() const {
}
} // end spv namespace
#endif
-9
View File
@@ -46,14 +46,6 @@ class SpvBuildLogger {
public:
SpvBuildLogger() {}
#ifdef GLSLANG_WEB
void tbdFunctionality(const std::string& f) { }
void missingFunctionality(const std::string& f) { }
void warning(const std::string& w) { }
void error(const std::string& e) { errors.push_back(e); }
std::string getAllMessages() { return ""; }
#else
// Registers a TBD functionality.
void tbdFunctionality(const std::string& f);
// Registers a missing functionality.
@@ -67,7 +59,6 @@ public:
// Returns all messages accumulated in the order of:
// TBD functionalities, missing functionalities, warnings, errors.
std::string getAllMessages() const;
#endif
private:
SpvBuildLogger(const SpvBuildLogger&);
@@ -1,5 +1,5 @@
// Copyright (c) 2020 The Khronos Group Inc.
//
//
// 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
@@ -7,15 +7,15 @@
// 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.
@@ -23,7 +23,7 @@
// 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 SPIRV_UNIFIED1_NonSemanticDebugPrintf_H_
#define SPIRV_UNIFIED1_NonSemanticDebugPrintf_H_
@@ -0,0 +1,171 @@
// Copyright (c) 2018 The Khronos Group Inc.
//
// 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 SPIRV_UNIFIED1_NonSemanticShaderDebugInfo100_H_
#define SPIRV_UNIFIED1_NonSemanticShaderDebugInfo100_H_
#ifdef __cplusplus
extern "C" {
#endif
enum {
NonSemanticShaderDebugInfo100Version = 100,
NonSemanticShaderDebugInfo100Version_BitWidthPadding = 0x7fffffff
};
enum {
NonSemanticShaderDebugInfo100Revision = 6,
NonSemanticShaderDebugInfo100Revision_BitWidthPadding = 0x7fffffff
};
enum NonSemanticShaderDebugInfo100Instructions {
NonSemanticShaderDebugInfo100DebugInfoNone = 0,
NonSemanticShaderDebugInfo100DebugCompilationUnit = 1,
NonSemanticShaderDebugInfo100DebugTypeBasic = 2,
NonSemanticShaderDebugInfo100DebugTypePointer = 3,
NonSemanticShaderDebugInfo100DebugTypeQualifier = 4,
NonSemanticShaderDebugInfo100DebugTypeArray = 5,
NonSemanticShaderDebugInfo100DebugTypeVector = 6,
NonSemanticShaderDebugInfo100DebugTypedef = 7,
NonSemanticShaderDebugInfo100DebugTypeFunction = 8,
NonSemanticShaderDebugInfo100DebugTypeEnum = 9,
NonSemanticShaderDebugInfo100DebugTypeComposite = 10,
NonSemanticShaderDebugInfo100DebugTypeMember = 11,
NonSemanticShaderDebugInfo100DebugTypeInheritance = 12,
NonSemanticShaderDebugInfo100DebugTypePtrToMember = 13,
NonSemanticShaderDebugInfo100DebugTypeTemplate = 14,
NonSemanticShaderDebugInfo100DebugTypeTemplateParameter = 15,
NonSemanticShaderDebugInfo100DebugTypeTemplateTemplateParameter = 16,
NonSemanticShaderDebugInfo100DebugTypeTemplateParameterPack = 17,
NonSemanticShaderDebugInfo100DebugGlobalVariable = 18,
NonSemanticShaderDebugInfo100DebugFunctionDeclaration = 19,
NonSemanticShaderDebugInfo100DebugFunction = 20,
NonSemanticShaderDebugInfo100DebugLexicalBlock = 21,
NonSemanticShaderDebugInfo100DebugLexicalBlockDiscriminator = 22,
NonSemanticShaderDebugInfo100DebugScope = 23,
NonSemanticShaderDebugInfo100DebugNoScope = 24,
NonSemanticShaderDebugInfo100DebugInlinedAt = 25,
NonSemanticShaderDebugInfo100DebugLocalVariable = 26,
NonSemanticShaderDebugInfo100DebugInlinedVariable = 27,
NonSemanticShaderDebugInfo100DebugDeclare = 28,
NonSemanticShaderDebugInfo100DebugValue = 29,
NonSemanticShaderDebugInfo100DebugOperation = 30,
NonSemanticShaderDebugInfo100DebugExpression = 31,
NonSemanticShaderDebugInfo100DebugMacroDef = 32,
NonSemanticShaderDebugInfo100DebugMacroUndef = 33,
NonSemanticShaderDebugInfo100DebugImportedEntity = 34,
NonSemanticShaderDebugInfo100DebugSource = 35,
NonSemanticShaderDebugInfo100DebugFunctionDefinition = 101,
NonSemanticShaderDebugInfo100DebugSourceContinued = 102,
NonSemanticShaderDebugInfo100DebugLine = 103,
NonSemanticShaderDebugInfo100DebugNoLine = 104,
NonSemanticShaderDebugInfo100DebugBuildIdentifier = 105,
NonSemanticShaderDebugInfo100DebugStoragePath = 106,
NonSemanticShaderDebugInfo100DebugEntryPoint = 107,
NonSemanticShaderDebugInfo100DebugTypeMatrix = 108,
NonSemanticShaderDebugInfo100InstructionsMax = 0x7fffffff
};
enum NonSemanticShaderDebugInfo100DebugInfoFlags {
NonSemanticShaderDebugInfo100None = 0x0000,
NonSemanticShaderDebugInfo100FlagIsProtected = 0x01,
NonSemanticShaderDebugInfo100FlagIsPrivate = 0x02,
NonSemanticShaderDebugInfo100FlagIsPublic = 0x03,
NonSemanticShaderDebugInfo100FlagIsLocal = 0x04,
NonSemanticShaderDebugInfo100FlagIsDefinition = 0x08,
NonSemanticShaderDebugInfo100FlagFwdDecl = 0x10,
NonSemanticShaderDebugInfo100FlagArtificial = 0x20,
NonSemanticShaderDebugInfo100FlagExplicit = 0x40,
NonSemanticShaderDebugInfo100FlagPrototyped = 0x80,
NonSemanticShaderDebugInfo100FlagObjectPointer = 0x100,
NonSemanticShaderDebugInfo100FlagStaticMember = 0x200,
NonSemanticShaderDebugInfo100FlagIndirectVariable = 0x400,
NonSemanticShaderDebugInfo100FlagLValueReference = 0x800,
NonSemanticShaderDebugInfo100FlagRValueReference = 0x1000,
NonSemanticShaderDebugInfo100FlagIsOptimized = 0x2000,
NonSemanticShaderDebugInfo100FlagIsEnumClass = 0x4000,
NonSemanticShaderDebugInfo100FlagTypePassByValue = 0x8000,
NonSemanticShaderDebugInfo100FlagTypePassByReference = 0x10000,
NonSemanticShaderDebugInfo100FlagUnknownPhysicalLayout = 0x20000,
NonSemanticShaderDebugInfo100DebugInfoFlagsMax = 0x7fffffff
};
enum NonSemanticShaderDebugInfo100BuildIdentifierFlags {
NonSemanticShaderDebugInfo100IdentifierPossibleDuplicates = 0x01,
NonSemanticShaderDebugInfo100BuildIdentifierFlagsMax = 0x7fffffff
};
enum NonSemanticShaderDebugInfo100DebugBaseTypeAttributeEncoding {
NonSemanticShaderDebugInfo100Unspecified = 0,
NonSemanticShaderDebugInfo100Address = 1,
NonSemanticShaderDebugInfo100Boolean = 2,
NonSemanticShaderDebugInfo100Float = 3,
NonSemanticShaderDebugInfo100Signed = 4,
NonSemanticShaderDebugInfo100SignedChar = 5,
NonSemanticShaderDebugInfo100Unsigned = 6,
NonSemanticShaderDebugInfo100UnsignedChar = 7,
NonSemanticShaderDebugInfo100DebugBaseTypeAttributeEncodingMax = 0x7fffffff
};
enum NonSemanticShaderDebugInfo100DebugCompositeType {
NonSemanticShaderDebugInfo100Class = 0,
NonSemanticShaderDebugInfo100Structure = 1,
NonSemanticShaderDebugInfo100Union = 2,
NonSemanticShaderDebugInfo100DebugCompositeTypeMax = 0x7fffffff
};
enum NonSemanticShaderDebugInfo100DebugTypeQualifier {
NonSemanticShaderDebugInfo100ConstType = 0,
NonSemanticShaderDebugInfo100VolatileType = 1,
NonSemanticShaderDebugInfo100RestrictType = 2,
NonSemanticShaderDebugInfo100AtomicType = 3,
NonSemanticShaderDebugInfo100DebugTypeQualifierMax = 0x7fffffff
};
enum NonSemanticShaderDebugInfo100DebugOperation {
NonSemanticShaderDebugInfo100Deref = 0,
NonSemanticShaderDebugInfo100Plus = 1,
NonSemanticShaderDebugInfo100Minus = 2,
NonSemanticShaderDebugInfo100PlusUconst = 3,
NonSemanticShaderDebugInfo100BitPiece = 4,
NonSemanticShaderDebugInfo100Swap = 5,
NonSemanticShaderDebugInfo100Xderef = 6,
NonSemanticShaderDebugInfo100StackValue = 7,
NonSemanticShaderDebugInfo100Constu = 8,
NonSemanticShaderDebugInfo100Fragment = 9,
NonSemanticShaderDebugInfo100DebugOperationMax = 0x7fffffff
};
enum NonSemanticShaderDebugInfo100DebugImportedEntity {
NonSemanticShaderDebugInfo100ImportedModule = 0,
NonSemanticShaderDebugInfo100ImportedDeclaration = 1,
NonSemanticShaderDebugInfo100DebugImportedEntityMax = 0x7fffffff
};
#ifdef __cplusplus
}
#endif
#endif // SPIRV_UNIFIED1_NonSemanticShaderDebugInfo100_H_
+43 -17
View File
@@ -36,10 +36,6 @@
#include "SPVRemapper.h"
#include "doc.h"
#if !defined (use_cpp11)
// ... not supported before C++11
#else // defined (use_cpp11)
#include <algorithm>
#include <cassert>
#include "../glslang/Include/Common.h"
@@ -160,15 +156,29 @@ namespace spv {
}
// Is this an opcode we should remove when using --strip?
bool spirvbin_t::isStripOp(spv::Op opCode) const
bool spirvbin_t::isStripOp(spv::Op opCode, unsigned start) const
{
switch (opCode) {
case spv::OpSource:
case spv::OpSourceExtension:
case spv::OpName:
case spv::OpMemberName:
case spv::OpLine: return true;
default: return false;
case spv::OpLine :
{
const std::string name = literalString(start + 2);
std::vector<std::string>::const_iterator it;
for (it = stripWhiteList.begin(); it < stripWhiteList.end(); it++)
{
if (name.find(*it) != std::string::npos) {
return false;
}
}
return true;
}
default :
return false;
}
}
@@ -297,15 +307,21 @@ namespace spv {
std::string spirvbin_t::literalString(unsigned word) const
{
std::string literal;
const spirword_t * pos = spv.data() + word;
literal.reserve(16);
const char* bytes = reinterpret_cast<const char*>(spv.data() + word);
while (bytes && *bytes)
literal += *bytes++;
return literal;
do {
spirword_t word = *pos;
for (int i = 0; i < 4; i++) {
char c = word & 0xff;
if (c == '\0')
return literal;
literal += c;
word >>= 8;
}
pos++;
} while (true);
}
void spirvbin_t::applyMap()
@@ -366,7 +382,7 @@ namespace spv {
process(
[&](spv::Op opCode, unsigned start) {
// remember opcodes we want to strip later
if (isStripOp(opCode))
if (isStripOp(opCode, start))
stripInst(start);
return true;
},
@@ -664,6 +680,7 @@ namespace spv {
case spv::OperandKernelEnqueueFlags:
case spv::OperandKernelProfilingInfo:
case spv::OperandCapability:
case spv::OperandCooperativeMatrixOperands:
++word;
break;
@@ -1488,14 +1505,23 @@ namespace spv {
}
// remap from a memory image
void spirvbin_t::remap(std::vector<std::uint32_t>& in_spv, std::uint32_t opts)
void spirvbin_t::remap(std::vector<std::uint32_t>& in_spv, const std::vector<std::string>& whiteListStrings,
std::uint32_t opts)
{
stripWhiteList = whiteListStrings;
spv.swap(in_spv);
remap(opts);
spv.swap(in_spv);
}
// remap from a memory image - legacy interface without white list
void spirvbin_t::remap(std::vector<std::uint32_t>& in_spv, std::uint32_t opts)
{
stripWhiteList.clear();
spv.swap(in_spv);
remap(opts);
spv.swap(in_spv);
}
} // namespace SPV
#endif // defined (use_cpp11)
+9 -29
View File
@@ -43,12 +43,6 @@
namespace spv {
// MSVC defines __cplusplus as an older value, even when it supports almost all of 11.
// We handle that here by making our own symbol.
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1700)
# define use_cpp11 1
#endif
class spirvbin_base_t
{
public:
@@ -74,27 +68,6 @@ public:
} // namespace SPV
#if !defined (use_cpp11)
#include <cstdio>
#include <cstdint>
namespace spv {
class spirvbin_t : public spirvbin_base_t
{
public:
spirvbin_t(int /*verbose = 0*/) { }
void remap(std::vector<std::uint32_t>& /*spv*/, unsigned int /*opts = 0*/)
{
printf("Tool not compiled for C++11, which is required for SPIR-V remapping.\n");
exit(5);
}
};
} // namespace SPV
#else // defined (use_cpp11)
#include <functional>
#include <cstdint>
#include <unordered_map>
@@ -104,9 +77,9 @@ public:
#include <cassert>
#include "spirv.hpp"
#include "spvIR.h"
namespace spv {
const Id NoResult = 0;
// class to hold SPIR-V binary data for remapping, DCE, and debug stripping
class spirvbin_t : public spirvbin_base_t
@@ -118,6 +91,10 @@ public:
virtual ~spirvbin_t() { }
// remap on an existing binary in memory
void remap(std::vector<std::uint32_t>& spv, const std::vector<std::string>& whiteListStrings,
std::uint32_t opts = DO_EVERYTHING);
// remap on an existing binary in memory - legacy interface without white list
void remap(std::vector<std::uint32_t>& spv, std::uint32_t opts = DO_EVERYTHING);
// Type for error/log handler functions
@@ -180,6 +157,8 @@ private:
unsigned typeSizeInWords(spv::Id id) const;
unsigned idTypeSizeInWords(spv::Id id) const;
bool isStripOp(spv::Op opCode, unsigned start) const;
spv::Id& asId(unsigned word) { return spv[word]; }
const spv::Id& asId(unsigned word) const { return spv[word]; }
spv::Op asOpCode(unsigned word) const { return opOpCode(spv[word]); }
@@ -249,6 +228,8 @@ private:
std::vector<spirword_t> spv; // SPIR words
std::vector<std::string> stripWhiteList;
namemap_t nameMap; // ID names from OpName
// Since we want to also do binary ops, we can't use std::vector<bool>. we could use
@@ -300,5 +281,4 @@ private:
} // namespace SPV
#endif // defined (use_cpp11)
#endif // SPIRVREMAPPER_H
File diff suppressed because it is too large Load Diff
+121 -24
View File
@@ -50,6 +50,10 @@
#include "Logger.h"
#include "spirv.hpp"
#include "spvIR.h"
namespace spv {
#include "GLSL.ext.KHR.h"
#include "NonSemanticShaderDebugInfo100.h"
}
#include <algorithm>
#include <map>
@@ -82,7 +86,7 @@ public:
void setSource(spv::SourceLanguage lang, int version)
{
source = lang;
sourceLang = lang;
sourceVersion = version;
}
spv::Id getStringId(const std::string& str)
@@ -99,14 +103,32 @@ public:
stringIds[file_c_str] = strId;
return strId;
}
spv::Id getSourceFile() const
{
return sourceFileStringId;
}
void setSourceFile(const std::string& file)
{
sourceFileStringId = getStringId(file);
currentFileId = sourceFileStringId;
}
void setSourceText(const std::string& text) { sourceText = text; }
void addSourceExtension(const char* ext) { sourceExtensions.push_back(ext); }
void addModuleProcessed(const std::string& p) { moduleProcesses.push_back(p.c_str()); }
void setEmitOpLines() { emitOpLines = true; }
void setEmitNonSemanticShaderDebugInfo(bool const emit)
{
emitNonSemanticShaderDebugInfo = emit;
if(emit)
{
importNonSemanticShaderDebugInfoInstructions();
}
}
void setEmitNonSemanticShaderDebugSource(bool const src)
{
emitNonSemanticShaderDebugSource = src;
}
void addExtension(const char* ext) { extensions.insert(ext); }
void removeExtension(const char* ext)
{
@@ -159,6 +181,7 @@ public:
void setLine(int line, const char* filename);
// Low-level OpLine. See setLine() for a layered helper.
void addLine(Id fileName, int line, int column);
void addDebugScopeAndLine(Id fileName, int line, int column);
// For creating new types (will return old type if the requested one was already made).
Id makeVoidType();
@@ -170,7 +193,7 @@ public:
Id makeIntType(int width) { return makeIntegerType(width, true); }
Id makeUintType(int width) { return makeIntegerType(width, false); }
Id makeFloatType(int width);
Id makeStructType(const std::vector<Id>& members, const char*);
Id makeStructType(const std::vector<Id>& members, const char* name, bool const compilerGenerated = true);
Id makeStructResultType(Id type0, Id type1);
Id makeVectorType(Id component, int size);
Id makeMatrixType(Id component, int cols, int rows);
@@ -180,13 +203,51 @@ public:
Id makeImageType(Id sampledType, Dim, bool depth, bool arrayed, bool ms, unsigned sampled, ImageFormat format);
Id makeSamplerType();
Id makeSampledImageType(Id imageType);
Id makeCooperativeMatrixType(Id component, Id scope, Id rows, Id cols);
Id makeCooperativeMatrixTypeKHR(Id component, Id scope, Id rows, Id cols, Id use);
Id makeCooperativeMatrixTypeNV(Id component, Id scope, Id rows, Id cols);
Id makeCooperativeMatrixTypeWithSameShape(Id component, Id otherType);
Id makeGenericType(spv::Op opcode, std::vector<spv::IdImmediate>& operands);
// SPIR-V NonSemantic Shader DebugInfo Instructions
struct DebugTypeLoc {
std::string name {};
int line {0};
int column {0};
};
std::unordered_map<Id, DebugTypeLoc> debugTypeLocs;
Id makeDebugInfoNone();
Id makeBoolDebugType(int const size);
Id makeIntegerDebugType(int const width, bool const hasSign);
Id makeFloatDebugType(int const width);
Id makeSequentialDebugType(Id const baseType, Id const componentCount, NonSemanticShaderDebugInfo100Instructions const sequenceType);
Id makeArrayDebugType(Id const baseType, Id const componentCount);
Id makeVectorDebugType(Id const baseType, int const componentCount);
Id makeMatrixDebugType(Id const vectorType, int const vectorCount, bool columnMajor = true);
Id makeMemberDebugType(Id const memberType, DebugTypeLoc const& debugTypeLoc);
Id makeCompositeDebugType(std::vector<Id> const& memberTypes, char const*const name,
NonSemanticShaderDebugInfo100DebugCompositeType const tag, bool const isOpaqueType = false);
Id makePointerDebugType(StorageClass storageClass, Id const baseType);
Id makeDebugSource(const Id fileName);
Id makeDebugCompilationUnit();
Id createDebugGlobalVariable(Id const type, char const*const name, Id const variable);
Id createDebugLocalVariable(Id type, char const*const name, size_t const argNumber = 0);
Id makeDebugExpression();
Id makeDebugDeclare(Id const debugLocalVariable, Id const pointer);
Id makeDebugValue(Id const debugLocalVariable, Id const value);
Id makeDebugFunctionType(Id returnType, const std::vector<Id>& paramTypes);
Id makeDebugFunction(Function* function, Id nameId, Id funcTypeId);
Id makeDebugLexicalBlock(uint32_t line);
std::string unmangleFunctionName(std::string const& name) const;
void setupDebugFunctionEntry(Function* function, const char* name, int line,
const std::vector<Id>& paramTypes,
const std::vector<char const*>& paramNames);
// accelerationStructureNV type
Id makeAccelerationStructureType();
// rayQueryEXT type
Id makeRayQueryType();
// hitObjectNV type
Id makeHitObjectNVType();
// For querying about types.
Id getTypeId(Id resultId) const { return module.getTypeId(resultId); }
@@ -204,6 +265,7 @@ public:
ImageFormat getImageTypeFormat(Id typeId) const
{ return (ImageFormat)module.getInstruction(typeId)->getImmediateOperand(6); }
Id getResultingAccessChainType() const;
Id getIdOperand(Id resultId, int idx) { return module.getInstruction(resultId)->getIdOperand(idx); }
bool isPointer(Id resultId) const { return isPointerType(getTypeId(resultId)); }
bool isScalar(Id resultId) const { return isScalarType(getTypeId(resultId)); }
@@ -228,11 +290,10 @@ public:
bool isMatrixType(Id typeId) const { return getTypeClass(typeId) == OpTypeMatrix; }
bool isStructType(Id typeId) const { return getTypeClass(typeId) == OpTypeStruct; }
bool isArrayType(Id typeId) const { return getTypeClass(typeId) == OpTypeArray; }
#ifdef GLSLANG_WEB
bool isCooperativeMatrixType(Id typeId)const { return false; }
#else
bool isCooperativeMatrixType(Id typeId)const { return getTypeClass(typeId) == OpTypeCooperativeMatrixNV; }
#endif
bool isCooperativeMatrixType(Id typeId)const
{
return getTypeClass(typeId) == OpTypeCooperativeMatrixKHR || getTypeClass(typeId) == OpTypeCooperativeMatrixNV;
}
bool isAggregateType(Id typeId) const
{ return isArrayType(typeId) || isStructType(typeId) || isCooperativeMatrixType(typeId); }
bool isImageType(Id typeId) const { return getTypeClass(typeId) == OpTypeImage; }
@@ -257,6 +318,8 @@ public:
// See if a resultId is valid for use as an initializer.
bool isValidInitializer(Id resultId) const { return isConstant(resultId) || isGlobalVariable(resultId); }
bool isRayTracingOpCode(Op opcode) const;
int getScalarTypeWidth(Id typeId) const
{
Id scalarTypeId = getScalarTypeId(typeId);
@@ -318,6 +381,8 @@ public:
Id makeFloat16Constant(float f16, bool specConstant = false);
Id makeFpConstant(Id type, double d, bool specConstant = false);
Id importNonSemanticShaderDebugInfoInstructions();
// Turn the array of constants into a proper spv constant of the requested type.
Id makeCompositeConstant(Id type, const std::vector<Id>& comps, bool specConst = false);
@@ -332,6 +397,7 @@ public:
void addDecoration(Id, Decoration, const char*);
void addDecoration(Id, Decoration, const std::vector<unsigned>& literals);
void addDecoration(Id, Decoration, const std::vector<const char*>& strings);
void addLinkageDecoration(Id id, const char* name, spv::LinkageType linkType);
void addDecorationId(Id id, Decoration, Id idDecoration);
void addDecorationId(Id id, Decoration, const std::vector<Id>& operandIds);
void addMemberDecoration(Id, unsigned int member, Decoration, int num = -1);
@@ -340,7 +406,12 @@ public:
void addMemberDecoration(Id, unsigned int member, Decoration, const std::vector<const char*>& strings);
// At the end of what block do the next create*() instructions go?
void setBuildPoint(Block* bp) { buildPoint = bp; }
// Also reset current last DebugScope and current source line to unknown
void setBuildPoint(Block* bp) {
buildPoint = bp;
lastDebugScopeId = NoResult;
currentLine = 0;
}
Block* getBuildPoint() const { return buildPoint; }
// Make the entry-point function. The returned pointer is only valid
@@ -350,13 +421,23 @@ public:
// Make a shader-style function, and create its entry block if entry is non-zero.
// Return the function, pass back the entry.
// The returned pointer is only valid for the lifetime of this builder.
Function* makeFunctionEntry(Decoration precision, Id returnType, const char* name,
const std::vector<Id>& paramTypes, const std::vector<std::vector<Decoration>>& precisions, Block **entry = 0);
Function* makeFunctionEntry(Decoration precision, Id returnType, const char* name, LinkageType linkType,
const std::vector<Id>& paramTypes,
const std::vector<std::vector<Decoration>>& precisions, Block** entry = nullptr);
// Create a return. An 'implicit' return is one not appearing in the source
// code. In the case of an implicit return, no post-return block is inserted.
void makeReturn(bool implicit, Id retVal = 0);
// Initialize state and generate instructions for new lexical scope
void enterScope(uint32_t line);
// Set state and generate instructions to exit current lexical scope
void leaveScope();
// Prepare builder for generation of instructions for a function.
void enterFunction(Function const* function);
// Generate all the code needed to finish up a function.
void leaveFunction();
@@ -364,9 +445,13 @@ public:
// discard, terminate-invocation, terminateRayEXT, or ignoreIntersectionEXT
void makeStatementTerminator(spv::Op opcode, const char *name);
// Create block terminator instruction for statements that have input operands
// such as OpEmitMeshTasksEXT
void makeStatementTerminator(spv::Op opcode, const std::vector<Id>& operands, const char* name);
// Create a global or function local or IO variable.
Id createVariable(Decoration precision, StorageClass, Id type, const char* name = nullptr,
Id initializer = NoResult);
Id createVariable(Decoration precision, StorageClass storageClass, Id type, const char* name = nullptr,
Id initializer = NoResult, bool const compilerGenerated = true);
// Create an intermediate with an undefined value.
Id createUndefined(Id type);
@@ -386,8 +471,10 @@ public:
// Create an OpArrayLength instruction
Id createArrayLength(Id base, unsigned int member);
// Create an OpCooperativeMatrixLengthKHR instruction
Id createCooperativeMatrixLengthKHR(Id type);
// Create an OpCooperativeMatrixLengthNV instruction
Id createCooperativeMatrixLength(Id type);
Id createCooperativeMatrixLengthNV(Id type);
// Create an OpCompositeExtract instruction
Id createCompositeExtract(Id composite, Id typeId, unsigned index);
@@ -622,11 +709,6 @@ public:
// Accumulate whether anything in the chain of structures has coherent decorations.
struct CoherentFlags {
CoherentFlags() { clear(); }
#ifdef GLSLANG_WEB
void clear() { }
bool isVolatile() const { return false; }
CoherentFlags operator |=(const CoherentFlags &other) { return *this; }
#else
bool isVolatile() const { return volatil; }
bool isNonUniform() const { return nonUniform; }
bool anyCoherent() const {
@@ -671,7 +753,6 @@ public:
nonUniform |= other.nonUniform;
return *this;
}
#endif
};
CoherentFlags coherentFlags;
};
@@ -752,19 +833,17 @@ public:
// Add capabilities, extensions, remove unneeded decorations, etc.,
// based on the resulting SPIR-V.
void postProcess();
void postProcess(bool compileOnly);
// Prune unreachable blocks in the CFG and remove unneeded decorations.
void postProcessCFG();
#ifndef GLSLANG_WEB
// Add capabilities, extensions based on instructions in the module.
void postProcessFeatures();
// Hook to visit each instruction in a block in a function
void postProcess(Instruction&);
// Hook to visit each non-32-bit sized float/int operation in a block.
void postProcessType(const Instruction&, spv::Id typeId);
#endif
void dump(std::vector<unsigned int>&) const;
@@ -801,13 +880,23 @@ public:
const;
unsigned int spvVersion; // the version of SPIR-V to emit in the header
SourceLanguage source;
SourceLanguage sourceLang;
int sourceVersion;
spv::Id sourceFileStringId;
spv::Id nonSemanticShaderCompilationUnitId {0};
spv::Id nonSemanticShaderDebugInfo {0};
spv::Id debugInfoNone {0};
spv::Id debugExpression {0}; // Debug expression with zero operations.
std::string sourceText;
int currentLine;
const char* currentFile;
spv::Id currentFileId;
std::stack<spv::Id> currentDebugScopeId;
spv::Id lastDebugScopeId;
bool emitOpLines;
bool emitNonSemanticShaderDebugInfo;
bool restoreNonSemanticShaderDebugInfo;
bool emitNonSemanticShaderDebugSource;
std::set<std::string> extensions;
std::vector<const char*> sourceExtensions;
std::vector<const char*> moduleProcesses;
@@ -841,6 +930,8 @@ public:
std::unordered_map<unsigned int, std::vector<Instruction*>> groupedStructConstants;
// map type opcodes to type instructions
std::unordered_map<unsigned int, std::vector<Instruction*>> groupedTypes;
// map type opcodes to debug type instructions
std::unordered_map<unsigned int, std::vector<Instruction*>> groupedDebugTypes;
// list of OpConstantNull instructions
std::vector<Instruction*> nullConstants;
@@ -856,6 +947,12 @@ public:
// map from include file name ids to their contents
std::map<spv::Id, const std::string*> includeFiles;
// map from core id to debug id
std::map <spv::Id, spv::Id> debugId;
// map from file name string id to DebugSource id
std::unordered_map<spv::Id, spv::Id> debugSourceId;
// The stream for outputting warnings and errors.
SpvBuildLogger* logger;
}; // end Builder class
@@ -52,11 +52,12 @@ namespace spv {
#include "GLSL.ext.EXT.h"
#include "GLSL.ext.AMD.h"
#include "GLSL.ext.NV.h"
#include "GLSL.ext.ARM.h"
#include "GLSL.ext.QCOM.h"
}
namespace spv {
#ifndef GLSLANG_WEB
// Hook to visit each operand type and result type of an instruction.
// Will be called multiple times for one instruction, once for each typed
// operand and the result.
@@ -333,7 +334,6 @@ void Builder::postProcess(Instruction& inst)
}
}
}
#endif
// comment in header
void Builder::postProcessCFG()
@@ -394,7 +394,6 @@ void Builder::postProcessCFG()
decorations.end());
}
#ifndef GLSLANG_WEB
// comment in header
void Builder::postProcessFeatures() {
// Add per-instruction capabilities, extensions, etc.,
@@ -482,14 +481,15 @@ void Builder::postProcessFeatures() {
}
}
}
#endif
// comment in header
void Builder::postProcess() {
postProcessCFG();
#ifndef GLSLANG_WEB
postProcessFeatures();
#endif
void Builder::postProcess(bool compileOnly)
{
// postProcessCFG needs an entrypoint to determine what is reachable, but if we are not creating an "executable" shader, we don't have an entrypoint
if (!compileOnly)
postProcessCFG();
postProcessFeatures();
}
}; // end spv namespace
+53 -20
View File
@@ -68,26 +68,8 @@ spv_target_env MapToSpirvToolsEnv(const SpvVersion& spvVersion, spv::SpvBuildLog
}
case glslang::EShTargetVulkan_1_2:
return spv_target_env::SPV_ENV_VULKAN_1_2;
case glslang::EShTargetUniversal:
switch (spvVersion.spv) {
case EShTargetSpv_1_0:
return spv_target_env::SPV_ENV_UNIVERSAL_1_0;
case EShTargetSpv_1_1:
return spv_target_env::SPV_ENV_UNIVERSAL_1_1;
case EShTargetSpv_1_2:
return spv_target_env::SPV_ENV_UNIVERSAL_1_2;
case EShTargetSpv_1_3:
return spv_target_env::SPV_ENV_UNIVERSAL_1_3;
case EShTargetSpv_1_4:
return spv_target_env::SPV_ENV_UNIVERSAL_1_4;
case EShTargetSpv_1_5:
return spv_target_env::SPV_ENV_UNIVERSAL_1_5;
case EShTargetSpv_1_6:
return spv_target_env::SPV_ENV_UNIVERSAL_1_6;
default:
logger->missingFunctionality("Target version for SPIRV-Tools validator");
return spv_target_env::SPV_ENV_UNIVERSAL_1_6;
}
case glslang::EShTargetVulkan_1_3:
return spv_target_env::SPV_ENV_VULKAN_1_3;
default:
break;
}
@@ -230,6 +212,7 @@ void SpirvToolsTransform(const glslang::TIntermediate& intermediate, std::vector
optimizer.RegisterPass(spvtools::CreateInterpolateFixupPass());
if (options->optimizeSize) {
optimizer.RegisterPass(spvtools::CreateRedundancyEliminationPass());
optimizer.RegisterPass(spvtools::CreateEliminateDeadInputComponentsSafePass());
}
optimizer.RegisterPass(spvtools::CreateAggressiveDCEPass());
optimizer.RegisterPass(spvtools::CreateCFGCleanupPass());
@@ -240,6 +223,56 @@ void SpirvToolsTransform(const glslang::TIntermediate& intermediate, std::vector
optimizer.Run(spirv.data(), spirv.size(), &spirv, spvOptOptions);
}
bool SpirvToolsAnalyzeDeadOutputStores(spv_target_env target_env, std::vector<unsigned int>& spirv,
std::unordered_set<uint32_t>* live_locs,
std::unordered_set<uint32_t>* live_builtins,
spv::SpvBuildLogger*)
{
spvtools::Optimizer optimizer(target_env);
optimizer.SetMessageConsumer(OptimizerMesssageConsumer);
optimizer.RegisterPass(spvtools::CreateAnalyzeLiveInputPass(live_locs, live_builtins));
spvtools::OptimizerOptions spvOptOptions;
optimizer.SetTargetEnv(target_env);
spvOptOptions.set_run_validator(false);
return optimizer.Run(spirv.data(), spirv.size(), &spirv, spvOptOptions);
}
void SpirvToolsEliminateDeadOutputStores(spv_target_env target_env, std::vector<unsigned int>& spirv,
std::unordered_set<uint32_t>* live_locs,
std::unordered_set<uint32_t>* live_builtins,
spv::SpvBuildLogger*)
{
spvtools::Optimizer optimizer(target_env);
optimizer.SetMessageConsumer(OptimizerMesssageConsumer);
optimizer.RegisterPass(spvtools::CreateEliminateDeadOutputStoresPass(live_locs, live_builtins));
optimizer.RegisterPass(spvtools::CreateAggressiveDCEPass(false, true));
optimizer.RegisterPass(spvtools::CreateEliminateDeadOutputComponentsPass());
optimizer.RegisterPass(spvtools::CreateAggressiveDCEPass(false, true));
spvtools::OptimizerOptions spvOptOptions;
optimizer.SetTargetEnv(target_env);
spvOptOptions.set_run_validator(false);
optimizer.Run(spirv.data(), spirv.size(), &spirv, spvOptOptions);
}
void SpirvToolsEliminateDeadInputComponents(spv_target_env target_env, std::vector<unsigned int>& spirv,
spv::SpvBuildLogger*)
{
spvtools::Optimizer optimizer(target_env);
optimizer.SetMessageConsumer(OptimizerMesssageConsumer);
optimizer.RegisterPass(spvtools::CreateEliminateDeadInputComponentsPass());
optimizer.RegisterPass(spvtools::CreateAggressiveDCEPass());
spvtools::OptimizerOptions spvOptOptions;
optimizer.SetTargetEnv(target_env);
spvOptOptions.set_run_validator(false);
optimizer.Run(spirv.data(), spirv.size(), &spirv, spvOptOptions);
}
// Apply the SPIRV-Tools optimizer to strip debug info from SPIR-V. This is implicitly done by
// SpirvToolsTransform if spvOptions->stripDebugInfo is set, but can be called separately if
// optimization is disabled.
+20 -11
View File
@@ -48,23 +48,16 @@
#endif
#include "../glslang/MachineIndependent/localintermediate.h"
#include "GlslangToSpv.h"
#include "Logger.h"
namespace glslang {
struct SpvOptions {
SpvOptions() : generateDebugInfo(false), stripDebugInfo(false), disableOptimizer(true),
optimizeSize(false), disassemble(false), validate(false) { }
bool generateDebugInfo;
bool stripDebugInfo;
bool disableOptimizer;
bool optimizeSize;
bool disassemble;
bool validate;
};
#if ENABLE_OPT
// Translate glslang's view of target versioning to what SPIRV-Tools uses.
spv_target_env MapToSpirvToolsEnv(const SpvVersion& spvVersion, spv::SpvBuildLogger* logger);
// Use the SPIRV-Tools disassembler to print SPIR-V using a SPV_ENV_UNIVERSAL_1_3 environment.
void SpirvToolsDisassemble(std::ostream& out, const std::vector<unsigned int>& spirv);
@@ -80,6 +73,22 @@ void SpirvToolsValidate(const glslang::TIntermediate& intermediate, std::vector<
void SpirvToolsTransform(const glslang::TIntermediate& intermediate, std::vector<unsigned int>& spirv,
spv::SpvBuildLogger*, const SpvOptions*);
// Apply the SPIRV-Tools EliminateDeadInputComponents pass to generated SPIR-V. Put result in |spirv|.
void SpirvToolsEliminateDeadInputComponents(spv_target_env target_env, std::vector<unsigned int>& spirv,
spv::SpvBuildLogger*);
// Apply the SPIRV-Tools AnalyzeDeadOutputStores pass to generated SPIR-V. Put result in |live_locs|.
// Return true if the result is valid.
bool SpirvToolsAnalyzeDeadOutputStores(spv_target_env target_env, std::vector<unsigned int>& spirv,
std::unordered_set<uint32_t>* live_locs,
std::unordered_set<uint32_t>* live_builtins, spv::SpvBuildLogger*);
// Apply the SPIRV-Tools EliminateDeadOutputStores and AggressiveDeadCodeElimination passes to generated SPIR-V using
// |live_locs|. Put result in |spirv|.
void SpirvToolsEliminateDeadOutputStores(spv_target_env target_env, std::vector<unsigned int>& spirv,
std::unordered_set<uint32_t>* live_locs,
std::unordered_set<uint32_t>* live_builtins, spv::SpvBuildLogger*);
// Apply the SPIRV-Tools optimizer to strip debug info from SPIR-V. This is implicitly done by
// SpirvToolsTransform if spvOptions->stripDebugInfo is set, but can be called separately if
// optimization is disabled.
+94 -17
View File
@@ -43,6 +43,7 @@
#include <stack>
#include <sstream>
#include <cstring>
#include <utility>
#include "disassemble.h"
#include "doc.h"
@@ -53,6 +54,9 @@ namespace spv {
#include "GLSL.std.450.h"
#include "GLSL.ext.AMD.h"
#include "GLSL.ext.NV.h"
#include "GLSL.ext.ARM.h"
#include "NonSemanticShaderDebugInfo100.h"
#include "GLSL.ext.QCOM.h"
}
}
const char* GlslStd450DebugNames[spv::GLSLstd450Count];
@@ -61,6 +65,7 @@ namespace spv {
static const char* GLSLextAMDGetDebugNames(const char*, unsigned);
static const char* GLSLextNVGetDebugNames(const char*, unsigned);
static const char* NonSemanticShaderDebugInfo100GetDebugNames(unsigned);
static void Kill(std::ostream& out, const char* message)
{
@@ -75,6 +80,7 @@ enum ExtInstSet {
GLSLextNVInst,
OpenCLExtInst,
NonSemanticDebugPrintfExtInst,
NonSemanticShaderDebugInfo100
};
// Container class for a single instance of a SPIR-V stream, with methods for disassembly.
@@ -100,6 +106,7 @@ protected:
void outputMask(OperandClass operandClass, unsigned mask);
void disassembleImmediates(int numOperands);
void disassembleIds(int numOperands);
std::pair<int, std::string> decodeString();
int disassembleString();
void disassembleInstruction(Id resultId, Id typeId, Op opCode, int numOperands);
@@ -290,31 +297,44 @@ void SpirvStream::disassembleIds(int numOperands)
}
}
// return the number of operands consumed by the string
int SpirvStream::disassembleString()
// decode string from words at current position (non-consuming)
std::pair<int, std::string> SpirvStream::decodeString()
{
int startWord = word;
out << " \"";
const char* wordString;
std::string res;
int wordPos = word;
char c;
bool done = false;
do {
unsigned int content = stream[word];
wordString = (const char*)&content;
unsigned int content = stream[wordPos];
for (int charCount = 0; charCount < 4; ++charCount) {
if (*wordString == 0) {
c = content & 0xff;
content >>= 8;
if (c == '\0') {
done = true;
break;
}
out << *(wordString++);
res += c;
}
++word;
} while (! done);
++wordPos;
} while(! done);
return std::make_pair(wordPos - word, res);
}
// return the number of operands consumed by the string
int SpirvStream::disassembleString()
{
out << " \"";
std::pair<int, std::string> decoderes = decodeString();
out << decoderes.second;
out << "\"";
return word - startWord;
word += decoderes.first;
return decoderes.first;
}
void SpirvStream::disassembleInstruction(Id resultId, Id /*typeId*/, Op opCode, int numOperands)
@@ -331,7 +351,7 @@ void SpirvStream::disassembleInstruction(Id resultId, Id /*typeId*/, Op opCode,
nextNestedControl = 0;
}
} else if (opCode == OpExtInstImport) {
idDescriptor[resultId] = (const char*)(&stream[word]);
idDescriptor[resultId] = decodeString().second;
}
else {
if (resultId != 0 && idDescriptor[resultId].size() == 0) {
@@ -428,7 +448,7 @@ void SpirvStream::disassembleInstruction(Id resultId, Id /*typeId*/, Op opCode,
--numOperands;
// Get names for printing "(XXX)" for readability, *after* this id
if (opCode == OpName)
idDescriptor[stream[word - 1]] = (const char*)(&stream[word]);
idDescriptor[stream[word - 1]] = decodeString().second;
break;
case OperandVariableIds:
disassembleIds(numOperands);
@@ -486,6 +506,8 @@ void SpirvStream::disassembleInstruction(Id resultId, Id /*typeId*/, Op opCode,
extInstSet = OpenCLExtInst;
} else if (strcmp("NonSemantic.DebugPrintf", name) == 0) {
extInstSet = NonSemanticDebugPrintfExtInst;
} else if (strcmp("NonSemantic.Shader.DebugInfo.100", name) == 0) {
extInstSet = NonSemanticShaderDebugInfo100;
} else if (strcmp(spv::E_SPV_AMD_shader_ballot, name) == 0 ||
strcmp(spv::E_SPV_AMD_shader_trinary_minmax, name) == 0 ||
strcmp(spv::E_SPV_AMD_shader_explicit_vertex_parameter, name) == 0 ||
@@ -494,7 +516,7 @@ void SpirvStream::disassembleInstruction(Id resultId, Id /*typeId*/, Op opCode,
} else if (strcmp(spv::E_SPV_NV_sample_mask_override_coverage, name) == 0 ||
strcmp(spv::E_SPV_NV_geometry_shader_passthrough, name) == 0 ||
strcmp(spv::E_SPV_NV_viewport_array2, name) == 0 ||
strcmp(spv::E_SPV_NVX_multiview_per_view_attributes, name) == 0 ||
strcmp(spv::E_SPV_NVX_multiview_per_view_attributes, name) == 0 ||
strcmp(spv::E_SPV_NV_fragment_shader_barycentric, name) == 0 ||
strcmp(spv::E_SPV_NV_mesh_shader, name) == 0) {
extInstSet = GLSLextNVInst;
@@ -511,6 +533,8 @@ void SpirvStream::disassembleInstruction(Id resultId, Id /*typeId*/, Op opCode,
out << "(" << GLSLextNVGetDebugNames(name, entrypoint) << ")";
} else if (extInstSet == NonSemanticDebugPrintfExtInst) {
out << "(DebugPrintf)";
} else if (extInstSet == NonSemanticShaderDebugInfo100) {
out << "(" << NonSemanticShaderDebugInfo100GetDebugNames(entrypoint) << ")";
}
}
break;
@@ -734,6 +758,59 @@ static const char* GLSLextNVGetDebugNames(const char* name, unsigned entrypoint)
return "Bad";
}
static const char* NonSemanticShaderDebugInfo100GetDebugNames(unsigned entrypoint)
{
switch (entrypoint) {
case NonSemanticShaderDebugInfo100DebugInfoNone: return "DebugInfoNone";
case NonSemanticShaderDebugInfo100DebugCompilationUnit: return "DebugCompilationUnit";
case NonSemanticShaderDebugInfo100DebugTypeBasic: return "DebugTypeBasic";
case NonSemanticShaderDebugInfo100DebugTypePointer: return "DebugTypePointer";
case NonSemanticShaderDebugInfo100DebugTypeQualifier: return "DebugTypeQualifier";
case NonSemanticShaderDebugInfo100DebugTypeArray: return "DebugTypeArray";
case NonSemanticShaderDebugInfo100DebugTypeVector: return "DebugTypeVector";
case NonSemanticShaderDebugInfo100DebugTypedef: return "DebugTypedef";
case NonSemanticShaderDebugInfo100DebugTypeFunction: return "DebugTypeFunction";
case NonSemanticShaderDebugInfo100DebugTypeEnum: return "DebugTypeEnum";
case NonSemanticShaderDebugInfo100DebugTypeComposite: return "DebugTypeComposite";
case NonSemanticShaderDebugInfo100DebugTypeMember: return "DebugTypeMember";
case NonSemanticShaderDebugInfo100DebugTypeInheritance: return "DebugTypeInheritance";
case NonSemanticShaderDebugInfo100DebugTypePtrToMember: return "DebugTypePtrToMember";
case NonSemanticShaderDebugInfo100DebugTypeTemplate: return "DebugTypeTemplate";
case NonSemanticShaderDebugInfo100DebugTypeTemplateParameter: return "DebugTypeTemplateParameter";
case NonSemanticShaderDebugInfo100DebugTypeTemplateTemplateParameter: return "DebugTypeTemplateTemplateParameter";
case NonSemanticShaderDebugInfo100DebugTypeTemplateParameterPack: return "DebugTypeTemplateParameterPack";
case NonSemanticShaderDebugInfo100DebugGlobalVariable: return "DebugGlobalVariable";
case NonSemanticShaderDebugInfo100DebugFunctionDeclaration: return "DebugFunctionDeclaration";
case NonSemanticShaderDebugInfo100DebugFunction: return "DebugFunction";
case NonSemanticShaderDebugInfo100DebugLexicalBlock: return "DebugLexicalBlock";
case NonSemanticShaderDebugInfo100DebugLexicalBlockDiscriminator: return "DebugLexicalBlockDiscriminator";
case NonSemanticShaderDebugInfo100DebugScope: return "DebugScope";
case NonSemanticShaderDebugInfo100DebugNoScope: return "DebugNoScope";
case NonSemanticShaderDebugInfo100DebugInlinedAt: return "DebugInlinedAt";
case NonSemanticShaderDebugInfo100DebugLocalVariable: return "DebugLocalVariable";
case NonSemanticShaderDebugInfo100DebugInlinedVariable: return "DebugInlinedVariable";
case NonSemanticShaderDebugInfo100DebugDeclare: return "DebugDeclare";
case NonSemanticShaderDebugInfo100DebugValue: return "DebugValue";
case NonSemanticShaderDebugInfo100DebugOperation: return "DebugOperation";
case NonSemanticShaderDebugInfo100DebugExpression: return "DebugExpression";
case NonSemanticShaderDebugInfo100DebugMacroDef: return "DebugMacroDef";
case NonSemanticShaderDebugInfo100DebugMacroUndef: return "DebugMacroUndef";
case NonSemanticShaderDebugInfo100DebugImportedEntity: return "DebugImportedEntity";
case NonSemanticShaderDebugInfo100DebugSource: return "DebugSource";
case NonSemanticShaderDebugInfo100DebugFunctionDefinition: return "DebugFunctionDefinition";
case NonSemanticShaderDebugInfo100DebugSourceContinued: return "DebugSourceContinued";
case NonSemanticShaderDebugInfo100DebugLine: return "DebugLine";
case NonSemanticShaderDebugInfo100DebugNoLine: return "DebugNoLine";
case NonSemanticShaderDebugInfo100DebugBuildIdentifier: return "DebugBuildIdentifier";
case NonSemanticShaderDebugInfo100DebugStoragePath: return "DebugStoragePath";
case NonSemanticShaderDebugInfo100DebugEntryPoint: return "DebugEntryPoint";
case NonSemanticShaderDebugInfo100DebugTypeMatrix: return "DebugTypeMatrix";
default: return "Bad";
}
return "Bad";
}
void Disassemble(std::ostream& out, const std::vector<unsigned int>& stream)
{
SpirvStream SpirvStream(out, stream);
+1772 -1371
View File
File diff suppressed because it is too large Load Diff
+6 -5
View File
@@ -156,6 +156,7 @@ enum OperandClass {
OperandKernelEnqueueFlags,
OperandKernelProfilingInfo,
OperandCapability,
OperandCooperativeMatrixOperands,
OperandOpcode,
@@ -190,15 +191,15 @@ protected:
// Parameterize an enumerant
class EnumParameters {
public:
EnumParameters() : desc(0) { }
EnumParameters() : desc(nullptr) { }
const char* desc;
};
// Parameterize a set of enumerants that form an enum
class EnumDefinition : public EnumParameters {
public:
EnumDefinition() :
ceiling(0), bitmask(false), getName(0), enumParams(0), operandParams(0) { }
EnumDefinition() :
ceiling(0), bitmask(false), getName(nullptr), enumParams(nullptr), operandParams(nullptr) { }
void set(int ceil, const char* (*name)(int), EnumParameters* ep, bool mask = false)
{
ceiling = ceil;
@@ -239,8 +240,8 @@ public:
OperandParameters operands;
protected:
int typePresent : 1;
int resultPresent : 1;
bool typePresent : 1;
bool resultPresent : 1;
};
// The set of objects that hold all the instruction/operand
-13
View File
@@ -23,19 +23,6 @@
#include <limits>
#include <sstream>
#if defined(_MSC_VER) && _MSC_VER < 1800
namespace std {
bool isnan(double f)
{
return ::_isnan(f) != 0;
}
bool isinf(double f)
{
return ::_finite(f) == 0;
}
}
#endif
#include "bitutils.h"
namespace spvutils {
File diff suppressed because it is too large Load Diff
+43 -17
View File
@@ -97,6 +97,8 @@ public:
explicit Instruction(Op opCode) : resultId(NoResult), typeId(NoType), opCode(opCode), block(nullptr) { }
virtual ~Instruction() {}
void addIdOperand(Id id) {
// ids can't be 0
assert(id);
operands.push_back(id);
idOperand.push_back(true);
}
@@ -111,27 +113,23 @@ public:
void addStringOperand(const char* str)
{
unsigned int word;
char* wordString = (char*)&word;
char* wordPtr = wordString;
int charCount = 0;
unsigned int word = 0;
unsigned int shiftAmount = 0;
char c;
do {
c = *(str++);
*(wordPtr++) = c;
++charCount;
if (charCount == 4) {
word |= ((unsigned int)c) << shiftAmount;
shiftAmount += 8;
if (shiftAmount == 32) {
addImmediateOperand(word);
wordPtr = wordString;
charCount = 0;
word = 0;
shiftAmount = 0;
}
} while (c != 0);
// deal with partial last word
if (charCount > 0) {
// pad with 0s
for (; charCount < 4; ++charCount)
*(wordPtr++) = 0;
if (shiftAmount > 0) {
addImmediateOperand(word);
}
}
@@ -325,7 +323,7 @@ void inReadableOrder(Block* root, std::function<void(Block*, ReachReason, Block*
class Function {
public:
Function(Id id, Id resultType, Id functionType, Id firstParam, Module& parent);
Function(Id id, Id resultType, Id functionType, Id firstParam, LinkageType linkage, const std::string& name, Module& parent);
virtual ~Function()
{
for (int i = 0; i < (int)parameterInstructions.size(); ++i)
@@ -353,6 +351,8 @@ public:
const std::vector<Block*>& getBlocks() const { return blocks; }
void addLocalVariable(std::unique_ptr<Instruction> inst);
Id getReturnType() const { return functionInstruction.getTypeId(); }
Id getFuncId() const { return functionInstruction.getResultId(); }
Id getFuncTypeId() const { return functionInstruction.getIdOperand(1); }
void setReturnPrecision(Decoration precision)
{
if (precision == DecorationRelaxedPrecision)
@@ -361,6 +361,14 @@ public:
Decoration getReturnPrecision() const
{ return reducedPrecisionReturn ? DecorationRelaxedPrecision : NoPrecision; }
void setDebugLineInfo(Id fileName, int line, int column) {
lineInstruction = std::unique_ptr<Instruction>{new Instruction(OpLine)};
lineInstruction->addIdOperand(fileName);
lineInstruction->addImmediateOperand(line);
lineInstruction->addImmediateOperand(column);
}
bool hasDebugLineInfo() const { return lineInstruction != nullptr; }
void setImplicitThis() { implicitThis = true; }
bool hasImplicitThis() const { return implicitThis; }
@@ -377,6 +385,11 @@ public:
void dump(std::vector<unsigned int>& out) const
{
// OpLine
if (lineInstruction != nullptr) {
lineInstruction->dump(out);
}
// OpFunction
functionInstruction.dump(out);
@@ -390,17 +403,23 @@ public:
end.dump(out);
}
LinkageType getLinkType() const { return linkType; }
const char* getExportName() const { return exportName.c_str(); }
protected:
Function(const Function&);
Function& operator=(Function&);
Module& parent;
std::unique_ptr<Instruction> lineInstruction;
Instruction functionInstruction;
std::vector<Instruction*> parameterInstructions;
std::vector<Block*> blocks;
bool implicitThis; // true if this is a member function expecting to be passed a 'this' as the first argument
bool reducedPrecisionReturn;
std::set<int> reducedPrecisionParams; // list of parameter indexes that need a relaxed precision arg
LinkageType linkType;
std::string exportName;
};
//
@@ -460,9 +479,11 @@ protected:
// Add both
// - the OpFunction instruction
// - all the OpFunctionParameter instructions
__inline Function::Function(Id id, Id resultType, Id functionType, Id firstParamId, Module& parent)
: parent(parent), functionInstruction(id, resultType, OpFunction), implicitThis(false),
reducedPrecisionReturn(false)
__inline Function::Function(Id id, Id resultType, Id functionType, Id firstParamId, LinkageType linkage, const std::string& name, Module& parent)
: parent(parent), lineInstruction(nullptr),
functionInstruction(id, resultType, OpFunction), implicitThis(false),
reducedPrecisionReturn(false),
linkType(linkage)
{
// OpFunction
functionInstruction.addImmediateOperand(FunctionControlMaskNone);
@@ -478,6 +499,11 @@ __inline Function::Function(Id id, Id resultType, Id functionType, Id firstParam
parent.mapInstruction(param);
parameterInstructions.push_back(param);
}
// If importing/exporting, save the function name (without the mangled parameters) for the linkage decoration
if (linkType != LinkageTypeMax) {
exportName = name.substr(0, name.find_first_of('('));
}
}
__inline void Function::addLocalVariable(std::unique_ptr<Instruction> inst)
@@ -1,5 +1,9 @@
//
// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
// Copyright (C) 2013-2016 LunarG, Inc.
// Copyright (C) 2016-2020 Google, Inc.
// Modifications Copyright(C) 2021 Advanced Micro Devices, Inc.All rights reserved.
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@@ -31,19 +35,4 @@
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
#ifndef __INITIALIZEDLL_H
#define __INITIALIZEDLL_H
#include "../glslang/OSDependent/osinclude.h"
namespace glslang {
bool InitProcess();
bool InitThread();
bool DetachThread(); // not called from standalone, perhaps other tools rely on parts of it
bool DetachProcess(); // not called from standalone, perhaps other tools rely on parts of it
} // end namespace glslang
#endif // __INITIALIZEDLL_H
@@ -41,10 +41,9 @@
//
class TGenericCompiler : public TCompiler {
public:
TGenericCompiler(EShLanguage l, int dOptions) : TCompiler(l, infoSink), debugOptions(dOptions) { }
TGenericCompiler(EShLanguage l) : TCompiler(l, infoSink) {}
virtual bool compile(TIntermNode* root, int version = 0, EProfile profile = ENoProfile);
TInfoSink infoSink;
int debugOptions;
};
//
@@ -52,10 +51,7 @@ public:
// compile object used by higher level code. It returns
// a subclass of TCompiler.
//
TCompiler* ConstructCompiler(EShLanguage language, int debugOptions)
{
return new TGenericCompiler(language, debugOptions);
}
TCompiler* ConstructCompiler(EShLanguage language, int) { return new TGenericCompiler(language); }
//
// Delete the compiler made by ConstructCompiler
@@ -44,11 +44,10 @@
//
class TGenericLinker : public TLinker {
public:
TGenericLinker(EShExecutable e, int dOptions) : TLinker(e, infoSink), debugOptions(dOptions) { }
TGenericLinker(EShExecutable e) : TLinker(e, infoSink) {}
bool link(TCompilerList&, TUniformMap*) { return true; }
void getAttributeBindings(ShBindingTable const **) const { }
TInfoSink infoSink;
int debugOptions;
};
//
@@ -60,10 +59,7 @@ public:
virtual int getLocation(const char*) { return 0; }
};
TShHandleBase* ConstructLinker(EShExecutable executable, int debugOptions)
{
return new TGenericLinker(executable, debugOptions);
}
TShHandleBase* ConstructLinker(EShExecutable executable, int) { return new TGenericLinker(executable); }
void DeleteLinker(TShHandleBase* linker)
{
@@ -82,7 +78,7 @@ void DeleteUniformMap(TUniformMap* map)
TShHandleBase* ConstructBindings()
{
return 0;
return nullptr;
}
void DeleteBindingList(TShHandleBase* bindingList)
+46 -13
View File
@@ -65,10 +65,10 @@ enum TBasicType {
EbtAccStruct,
EbtReference,
EbtRayQuery,
#ifndef GLSLANG_WEB
EbtHitObjectNV,
EbtCoopmat,
// SPIR-V type defined by spirv_type
EbtSpirvType,
#endif
// HLSL types that live only temporarily.
EbtString,
@@ -95,15 +95,16 @@ enum TStorageQualifier {
EvqUniform, // read only, shared with app
EvqBuffer, // read/write, shared with app
EvqShared, // compute shader's read/write 'shared' qualifier
#ifndef GLSLANG_WEB
EvqSpirvStorageClass, // spirv_storage_class
#endif
EvqPayload,
EvqPayloadIn,
EvqHitAttr,
EvqCallableData,
EvqCallableDataIn,
EvqHitObjectAttrNV,
EvqtaskPayloadSharedEXT,
// parameters
EvqIn, // also, for 'in' in the grammar before we know if it's a pipeline input or an 'in' parameter
@@ -128,6 +129,9 @@ enum TStorageQualifier {
// built-ins written by fragment shader
EvqFragColor,
EvqFragDepth,
EvqFragStencil,
EvqTileImageEXT,
// end of list
EvqLast
@@ -263,6 +267,7 @@ enum TBuiltInVariable {
EbvObjectRayDirection,
EbvRayTmin,
EbvRayTmax,
EbvCullMask,
EbvHitT,
EbvHitKind,
EbvObjectToWorld,
@@ -274,6 +279,8 @@ enum TBuiltInVariable {
// barycentrics
EbvBaryCoordNV,
EbvBaryCoordNoPerspNV,
EbvBaryCoordEXT,
EbvBaryCoordNoPerspEXT,
// mesh shaders
EbvTaskCountNV,
EbvPrimitiveCountNV,
@@ -284,6 +291,17 @@ enum TBuiltInVariable {
EbvMeshViewCountNV,
EbvMeshViewIndicesNV,
EbvMicroTrianglePositionNV,
EbvMicroTriangleBaryNV,
EbvHitKindFrontFacingMicroTriangleNV,
EbvHitKindBackFacingMicroTriangleNV,
//GL_EXT_mesh_shader
EbvPrimitivePointIndicesEXT,
EbvPrimitiveLineIndicesEXT,
EbvPrimitiveTriangleIndicesEXT,
EbvCullPrimitiveEXT,
// sm builtins
EbvWarpsPerSM,
EbvSMCount,
@@ -305,6 +323,15 @@ enum TBuiltInVariable {
EbvByteAddressBuffer,
EbvRWByteAddressBuffer,
// ARM specific core builtins
EbvCoreCountARM,
EbvCoreIDARM,
EbvCoreMaxIDARM,
EbvWarpIDARM,
EbvWarpMaxIDARM,
EbvPositionFetch,
EbvLast
};
@@ -317,10 +344,6 @@ enum TPrecisionQualifier {
EpqHigh
};
#ifdef GLSLANG_WEB
__inline const char* GetStorageQualifierString(TStorageQualifier q) { return ""; }
__inline const char* GetPrecisionQualifierString(TPrecisionQualifier p) { return ""; }
#else
// These will show up in error messages
__inline const char* GetStorageQualifierString(TStorageQualifier q)
{
@@ -329,9 +352,7 @@ __inline const char* GetStorageQualifierString(TStorageQualifier q)
case EvqGlobal: return "global"; break;
case EvqConst: return "const"; break;
case EvqConstReadOnly: return "const (read only)"; break;
#ifndef GLSLANG_WEB
case EvqSpirvStorageClass: return "spirv_storage_class"; break;
#endif
case EvqVaryingIn: return "in"; break;
case EvqVaryingOut: return "out"; break;
case EvqUniform: return "uniform"; break;
@@ -350,11 +371,14 @@ __inline const char* GetStorageQualifierString(TStorageQualifier q)
case EvqPointCoord: return "gl_PointCoord"; break;
case EvqFragColor: return "fragColor"; break;
case EvqFragDepth: return "gl_FragDepth"; break;
case EvqFragStencil: return "gl_FragStencilRefARB"; break;
case EvqPayload: return "rayPayloadNV"; break;
case EvqPayloadIn: return "rayPayloadInNV"; break;
case EvqHitAttr: return "hitAttributeNV"; break;
case EvqCallableData: return "callableDataNV"; break;
case EvqCallableDataIn: return "callableDataInNV"; break;
case EvqtaskPayloadSharedEXT: return "taskPayloadSharedEXT"; break;
case EvqHitObjectAttrNV:return "hitObjectAttributeNV"; break;
default: return "unknown qualifier";
}
}
@@ -478,8 +502,10 @@ __inline const char* GetBuiltInVariableString(TBuiltInVariable v)
case EbvWorldToObject: return "WorldToObjectNV";
case EbvCurrentRayTimeNV: return "CurrentRayTimeNV";
case EbvBaryCoordNV: return "BaryCoordNV";
case EbvBaryCoordNoPerspNV: return "BaryCoordNoPerspNV";
case EbvBaryCoordEXT:
case EbvBaryCoordNV: return "BaryCoordKHR";
case EbvBaryCoordNoPerspEXT:
case EbvBaryCoordNoPerspNV: return "BaryCoordNoPerspKHR";
case EbvTaskCountNV: return "TaskCountNV";
case EbvPrimitiveCountNV: return "PrimitiveCountNV";
@@ -489,6 +515,11 @@ __inline const char* GetBuiltInVariableString(TBuiltInVariable v)
case EbvLayerPerViewNV: return "LayerPerViewNV";
case EbvMeshViewCountNV: return "MeshViewCountNV";
case EbvMeshViewIndicesNV: return "MeshViewIndicesNV";
// GL_EXT_mesh_shader
case EbvPrimitivePointIndicesEXT: return "PrimitivePointIndicesEXT";
case EbvPrimitiveLineIndicesEXT: return "PrimitiveLineIndicesEXT";
case EbvPrimitiveTriangleIndicesEXT: return "PrimitiveTriangleIndicesEXT";
case EbvCullPrimitiveEXT: return "CullPrimitiveEXT";
case EbvWarpsPerSM: return "WarpsPerSMNV";
case EbvSMCount: return "SMCountNV";
@@ -498,6 +529,9 @@ __inline const char* GetBuiltInVariableString(TBuiltInVariable v)
case EbvShadingRateKHR: return "ShadingRateKHR";
case EbvPrimitiveShadingRateKHR: return "PrimitiveShadingRateKHR";
case EbvHitKindFrontFacingMicroTriangleNV: return "HitKindFrontFacingMicroTriangleNV";
case EbvHitKindBackFacingMicroTriangleNV: return "HitKindBackFacingMicroTriangleNV";
default: return "unknown built-in variable";
}
}
@@ -512,7 +546,6 @@ __inline const char* GetPrecisionQualifierString(TPrecisionQualifier p)
default: return "unknown precision qualifier";
}
}
#endif
__inline bool isTypeSignedInt(TBasicType type)
{
+4 -47
View File
@@ -44,6 +44,7 @@
#else
#include <cmath>
#endif
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <list>
@@ -54,7 +55,7 @@
#include <unordered_set>
#include <vector>
#if defined(__ANDROID__) || (defined(_MSC_VER) && _MSC_VER < 1700)
#if defined(__ANDROID__)
#include <sstream>
namespace std {
template<typename T>
@@ -66,7 +67,7 @@ std::string to_string(const T& val) {
}
#endif
#if (defined(_MSC_VER) && _MSC_VER < 1900 /*vs2015*/) || MINGW_HAS_SECURE_API
#if defined(MINGW_HAS_SECURE_API) && MINGW_HAS_SECURE_API
#include <basetsd.h>
#ifndef snprintf
#define snprintf sprintf_s
@@ -82,22 +83,6 @@ std::string to_string(const T& val) {
#define UINT_PTR uintptr_t
#endif
#if defined(_MSC_VER) && _MSC_VER < 1800
#include <stdlib.h>
inline long long int strtoll (const char* str, char** endptr, int base)
{
return _strtoi64(str, endptr, base);
}
inline unsigned long long int strtoull (const char* str, char** endptr, int base)
{
return _strtoui64(str, endptr, base);
}
inline long long int atoll (const char* str)
{
return strtoll(str, NULL, 10);
}
#endif
#if defined(_MSC_VER)
#define strdup _strdup
#endif
@@ -218,7 +203,7 @@ template <class T> T Max(const T a, const T b) { return a > b ? a : b; }
//
// Create a TString object from an integer.
//
#if defined _MSC_VER || MINGW_HAS_SECURE_API
#if defined(_MSC_VER) || (defined(MINGW_HAS_SECURE_API) && MINGW_HAS_SECURE_API)
inline const TString String(const int i, const int base = 10)
{
char text[16]; // 32 bit ints are at most 10 digits in base 10
@@ -307,34 +292,6 @@ template <class T> int IntLog2(T n)
return result;
}
inline bool IsInfinity(double x) {
#ifdef _MSC_VER
switch (_fpclass(x)) {
case _FPCLASS_NINF:
case _FPCLASS_PINF:
return true;
default:
return false;
}
#else
return std::isinf(x);
#endif
}
inline bool IsNan(double x) {
#ifdef _MSC_VER
switch (_fpclass(x)) {
case _FPCLASS_SNAN:
case _FPCLASS_QNAN:
return true;
default:
return false;
}
#else
return std::isnan(x);
#endif
}
} // end namespace glslang
#endif // _COMMON_INCLUDED_
@@ -234,7 +234,6 @@ public:
break;
#ifndef GLSLANG_WEB
case EbtInt16:
if (constant.i16Const == i16Const)
return true;
@@ -265,7 +264,6 @@ public:
return true;
break;
#endif
default:
assert(false && "Default missing");
}
@@ -347,7 +345,6 @@ public:
return true;
return false;
#ifndef GLSLANG_WEB
case EbtInt8:
if (i8Const > constant.i8Const)
return true;
@@ -378,7 +375,6 @@ public:
return true;
return false;
#endif
default:
assert(false && "Default missing");
return false;
@@ -389,7 +385,6 @@ public:
{
assert(type == constant.type);
switch (type) {
#ifndef GLSLANG_WEB
case EbtInt8:
if (i8Const < constant.i8Const)
return true;
@@ -419,7 +414,6 @@ public:
return true;
return false;
#endif
case EbtDouble:
if (dConst < constant.dConst)
return true;
@@ -449,14 +443,12 @@ public:
case EbtInt: returnValue.setIConst(iConst + constant.iConst); break;
case EbtUint: returnValue.setUConst(uConst + constant.uConst); break;
case EbtDouble: returnValue.setDConst(dConst + constant.dConst); break;
#ifndef GLSLANG_WEB
case EbtInt8: returnValue.setI8Const(i8Const + constant.i8Const); break;
case EbtInt16: returnValue.setI16Const(i16Const + constant.i16Const); break;
case EbtInt64: returnValue.setI64Const(i64Const + constant.i64Const); break;
case EbtUint8: returnValue.setU8Const(u8Const + constant.u8Const); break;
case EbtUint16: returnValue.setU16Const(u16Const + constant.u16Const); break;
case EbtUint64: returnValue.setU64Const(u64Const + constant.u64Const); break;
#endif
default: assert(false && "Default missing");
}
@@ -471,14 +463,12 @@ public:
case EbtInt: returnValue.setIConst(iConst - constant.iConst); break;
case EbtUint: returnValue.setUConst(uConst - constant.uConst); break;
case EbtDouble: returnValue.setDConst(dConst - constant.dConst); break;
#ifndef GLSLANG_WEB
case EbtInt8: returnValue.setI8Const(i8Const - constant.i8Const); break;
case EbtInt16: returnValue.setI16Const(i16Const - constant.i16Const); break;
case EbtInt64: returnValue.setI64Const(i64Const - constant.i64Const); break;
case EbtUint8: returnValue.setU8Const(u8Const - constant.u8Const); break;
case EbtUint16: returnValue.setU16Const(u16Const - constant.u16Const); break;
case EbtUint64: returnValue.setU64Const(u64Const - constant.u64Const); break;
#endif
default: assert(false && "Default missing");
}
@@ -493,14 +483,12 @@ public:
case EbtInt: returnValue.setIConst(iConst * constant.iConst); break;
case EbtUint: returnValue.setUConst(uConst * constant.uConst); break;
case EbtDouble: returnValue.setDConst(dConst * constant.dConst); break;
#ifndef GLSLANG_WEB
case EbtInt8: returnValue.setI8Const(i8Const * constant.i8Const); break;
case EbtInt16: returnValue.setI16Const(i16Const * constant.i16Const); break;
case EbtInt64: returnValue.setI64Const(i64Const * constant.i64Const); break;
case EbtUint8: returnValue.setU8Const(u8Const * constant.u8Const); break;
case EbtUint16: returnValue.setU16Const(u16Const * constant.u16Const); break;
case EbtUint64: returnValue.setU64Const(u64Const * constant.u64Const); break;
#endif
default: assert(false && "Default missing");
}
@@ -514,14 +502,12 @@ public:
switch (type) {
case EbtInt: returnValue.setIConst(iConst % constant.iConst); break;
case EbtUint: returnValue.setUConst(uConst % constant.uConst); break;
#ifndef GLSLANG_WEB
case EbtInt8: returnValue.setI8Const(i8Const % constant.i8Const); break;
case EbtInt16: returnValue.setI8Const(i8Const % constant.i16Const); break;
case EbtInt16: returnValue.setI16Const(i16Const % constant.i16Const); break;
case EbtInt64: returnValue.setI64Const(i64Const % constant.i64Const); break;
case EbtUint8: returnValue.setU8Const(u8Const % constant.u8Const); break;
case EbtUint16: returnValue.setU16Const(u16Const % constant.u16Const); break;
case EbtUint64: returnValue.setU64Const(u64Const % constant.u64Const); break;
#endif
default: assert(false && "Default missing");
}
@@ -532,7 +518,6 @@ public:
{
TConstUnion returnValue;
switch (type) {
#ifndef GLSLANG_WEB
case EbtInt8:
switch (constant.type) {
case EbtInt8: returnValue.setI8Const(i8Const >> constant.i8Const); break;
@@ -585,19 +570,16 @@ public:
default: assert(false && "Default missing");
}
break;
#endif
case EbtInt:
switch (constant.type) {
case EbtInt: returnValue.setIConst(iConst >> constant.iConst); break;
case EbtUint: returnValue.setIConst(iConst >> constant.uConst); break;
#ifndef GLSLANG_WEB
case EbtInt8: returnValue.setIConst(iConst >> constant.i8Const); break;
case EbtUint8: returnValue.setIConst(iConst >> constant.u8Const); break;
case EbtInt16: returnValue.setIConst(iConst >> constant.i16Const); break;
case EbtUint16: returnValue.setIConst(iConst >> constant.u16Const); break;
case EbtInt64: returnValue.setIConst(iConst >> constant.i64Const); break;
case EbtUint64: returnValue.setIConst(iConst >> constant.u64Const); break;
#endif
default: assert(false && "Default missing");
}
break;
@@ -605,18 +587,15 @@ public:
switch (constant.type) {
case EbtInt: returnValue.setUConst(uConst >> constant.iConst); break;
case EbtUint: returnValue.setUConst(uConst >> constant.uConst); break;
#ifndef GLSLANG_WEB
case EbtInt8: returnValue.setUConst(uConst >> constant.i8Const); break;
case EbtUint8: returnValue.setUConst(uConst >> constant.u8Const); break;
case EbtInt16: returnValue.setUConst(uConst >> constant.i16Const); break;
case EbtUint16: returnValue.setUConst(uConst >> constant.u16Const); break;
case EbtInt64: returnValue.setUConst(uConst >> constant.i64Const); break;
case EbtUint64: returnValue.setUConst(uConst >> constant.u64Const); break;
#endif
default: assert(false && "Default missing");
}
break;
#ifndef GLSLANG_WEB
case EbtInt64:
switch (constant.type) {
case EbtInt8: returnValue.setI64Const(i64Const >> constant.i8Const); break;
@@ -643,7 +622,6 @@ public:
default: assert(false && "Default missing");
}
break;
#endif
default: assert(false && "Default missing");
}
@@ -654,7 +632,6 @@ public:
{
TConstUnion returnValue;
switch (type) {
#ifndef GLSLANG_WEB
case EbtInt8:
switch (constant.type) {
case EbtInt8: returnValue.setI8Const(i8Const << constant.i8Const); break;
@@ -733,19 +710,16 @@ public:
default: assert(false && "Default missing");
}
break;
#endif
case EbtInt:
switch (constant.type) {
case EbtInt: returnValue.setIConst(iConst << constant.iConst); break;
case EbtUint: returnValue.setIConst(iConst << constant.uConst); break;
#ifndef GLSLANG_WEB
case EbtInt8: returnValue.setIConst(iConst << constant.i8Const); break;
case EbtUint8: returnValue.setIConst(iConst << constant.u8Const); break;
case EbtInt16: returnValue.setIConst(iConst << constant.i16Const); break;
case EbtUint16: returnValue.setIConst(iConst << constant.u16Const); break;
case EbtInt64: returnValue.setIConst(iConst << constant.i64Const); break;
case EbtUint64: returnValue.setIConst(iConst << constant.u64Const); break;
#endif
default: assert(false && "Default missing");
}
break;
@@ -753,14 +727,12 @@ public:
switch (constant.type) {
case EbtInt: returnValue.setUConst(uConst << constant.iConst); break;
case EbtUint: returnValue.setUConst(uConst << constant.uConst); break;
#ifndef GLSLANG_WEB
case EbtInt8: returnValue.setUConst(uConst << constant.i8Const); break;
case EbtUint8: returnValue.setUConst(uConst << constant.u8Const); break;
case EbtInt16: returnValue.setUConst(uConst << constant.i16Const); break;
case EbtUint16: returnValue.setUConst(uConst << constant.u16Const); break;
case EbtInt64: returnValue.setUConst(uConst << constant.i64Const); break;
case EbtUint64: returnValue.setUConst(uConst << constant.u64Const); break;
#endif
default: assert(false && "Default missing");
}
break;
@@ -777,14 +749,12 @@ public:
switch (type) {
case EbtInt: returnValue.setIConst(iConst & constant.iConst); break;
case EbtUint: returnValue.setUConst(uConst & constant.uConst); break;
#ifndef GLSLANG_WEB
case EbtInt8: returnValue.setI8Const(i8Const & constant.i8Const); break;
case EbtUint8: returnValue.setU8Const(u8Const & constant.u8Const); break;
case EbtInt16: returnValue.setI16Const(i16Const & constant.i16Const); break;
case EbtUint16: returnValue.setU16Const(u16Const & constant.u16Const); break;
case EbtInt64: returnValue.setI64Const(i64Const & constant.i64Const); break;
case EbtUint64: returnValue.setU64Const(u64Const & constant.u64Const); break;
#endif
default: assert(false && "Default missing");
}
@@ -798,14 +768,12 @@ public:
switch (type) {
case EbtInt: returnValue.setIConst(iConst | constant.iConst); break;
case EbtUint: returnValue.setUConst(uConst | constant.uConst); break;
#ifndef GLSLANG_WEB
case EbtInt8: returnValue.setI8Const(i8Const | constant.i8Const); break;
case EbtUint8: returnValue.setU8Const(u8Const | constant.u8Const); break;
case EbtInt16: returnValue.setI16Const(i16Const | constant.i16Const); break;
case EbtUint16: returnValue.setU16Const(u16Const | constant.u16Const); break;
case EbtInt64: returnValue.setI64Const(i64Const | constant.i64Const); break;
case EbtUint64: returnValue.setU64Const(u64Const | constant.u64Const); break;
#endif
default: assert(false && "Default missing");
}
@@ -819,14 +787,12 @@ public:
switch (type) {
case EbtInt: returnValue.setIConst(iConst ^ constant.iConst); break;
case EbtUint: returnValue.setUConst(uConst ^ constant.uConst); break;
#ifndef GLSLANG_WEB
case EbtInt8: returnValue.setI8Const(i8Const ^ constant.i8Const); break;
case EbtUint8: returnValue.setU8Const(u8Const ^ constant.u8Const); break;
case EbtInt16: returnValue.setI16Const(i16Const ^ constant.i16Const); break;
case EbtUint16: returnValue.setU16Const(u16Const ^ constant.u16Const); break;
case EbtInt64: returnValue.setI64Const(i64Const ^ constant.i64Const); break;
case EbtUint64: returnValue.setU64Const(u64Const ^ constant.u64Const); break;
#endif
default: assert(false && "Default missing");
}
@@ -839,14 +805,12 @@ public:
switch (type) {
case EbtInt: returnValue.setIConst(~iConst); break;
case EbtUint: returnValue.setUConst(~uConst); break;
#ifndef GLSLANG_WEB
case EbtInt8: returnValue.setI8Const(~i8Const); break;
case EbtUint8: returnValue.setU8Const(~u8Const); break;
case EbtInt16: returnValue.setI16Const(~i16Const); break;
case EbtUint16: returnValue.setU16Const(~u16Const); break;
case EbtInt64: returnValue.setI64Const(~i64Const); break;
case EbtUint64: returnValue.setU64Const(~u64Const); break;
#endif
default: assert(false && "Default missing");
}
@@ -37,7 +37,7 @@
namespace glslang {
bool InitializePoolIndex();
inline bool InitializePoolIndex() { return true; } // DEPRECATED: No need to call
} // end namespace glslang
@@ -37,7 +37,7 @@
#ifndef _POOLALLOC_INCLUDED_
#define _POOLALLOC_INCLUDED_
#ifdef _DEBUG
#ifndef NDEBUG
# define GUARD_BLOCKS // define to enable guard block sanity checking
#endif
@@ -74,7 +74,7 @@ namespace glslang {
class TAllocation {
public:
TAllocation(size_t size, unsigned char* mem, TAllocation* prev = 0) :
TAllocation(size_t size, unsigned char* mem, TAllocation* prev = nullptr) :
size(size), mem(mem), prevAlloc(prev) {
// Allocations are bracketed:
// [allocationHeader][initialGuardBlock][userData][finalGuardBlock]
@@ -118,11 +118,16 @@ private:
unsigned char* mem; // beginning of our allocation (pts to header)
TAllocation* prevAlloc; // prior allocation in the chain
const static unsigned char guardBlockBeginVal;
const static unsigned char guardBlockEndVal;
const static unsigned char userDataFill;
static inline constexpr unsigned char guardBlockBeginVal = 0xfb;
static inline constexpr unsigned char guardBlockEndVal = 0xfe;
static inline constexpr unsigned char userDataFill = 0xcd;
# ifdef GUARD_BLOCKS
static inline constexpr size_t guardBlockSize = 16;
# else
static inline constexpr size_t guardBlockSize = 0;
# endif
const static size_t guardBlockSize;
# ifdef GUARD_BLOCKS
inline static size_t headerSize() { return sizeof(TAllocation); }
# else
@@ -171,7 +176,7 @@ public:
void popAll();
//
// Call allocate() to actually acquire memory. Returns 0 if no memory
// Call allocate() to actually acquire memory. Returns nullptr if no memory
// available, otherwise a properly aligned pointer to 'numBytes' of memory.
//
void* allocate(size_t numBytes);
@@ -189,7 +194,7 @@ protected:
struct tHeader {
tHeader(tHeader* nextPage, size_t pageCount) :
#ifdef GUARD_BLOCKS
lastAllocation(0),
lastAllocation(nullptr),
#endif
nextPage(nextPage), pageCount(pageCount) { }
@@ -142,6 +142,15 @@ struct TBuiltInResource {
int maxTaskWorkGroupSizeY_NV;
int maxTaskWorkGroupSizeZ_NV;
int maxMeshViewCountNV;
int maxMeshOutputVerticesEXT;
int maxMeshOutputPrimitivesEXT;
int maxMeshWorkGroupSizeX_EXT;
int maxMeshWorkGroupSizeY_EXT;
int maxMeshWorkGroupSizeZ_EXT;
int maxTaskWorkGroupSizeX_EXT;
int maxTaskWorkGroupSizeY_EXT;
int maxTaskWorkGroupSizeZ_EXT;
int maxMeshViewCountEXT;
int maxDualSourceDrawBuffersEXT;
TLimits limits;
@@ -58,9 +58,9 @@ class TShHandleBase {
public:
TShHandleBase() { pool = new glslang::TPoolAllocator; }
virtual ~TShHandleBase() { delete pool; }
virtual TCompiler* getAsCompiler() { return 0; }
virtual TLinker* getAsLinker() { return 0; }
virtual TUniformMap* getAsUniformMap() { return 0; }
virtual TCompiler* getAsCompiler() { return nullptr; }
virtual TLinker* getAsLinker() { return nullptr; }
virtual TUniformMap* getAsUniformMap() { return nullptr; }
virtual glslang::TPoolAllocator* getPool() const { return pool; }
private:
glslang::TPoolAllocator* pool;
@@ -123,11 +123,11 @@ public:
infoSink(iSink),
executable(e),
haveReturnableObjectCode(false),
appAttributeBindings(0),
fixedAttributeBindings(0),
excludedAttributes(0),
appAttributeBindings(nullptr),
fixedAttributeBindings(nullptr),
excludedAttributes(nullptr),
excludedCount(0),
uniformBindings(0) { }
uniformBindings(nullptr) { }
virtual TLinker* getAsLinker() { return this; }
virtual ~TLinker() { }
virtual bool link(TCompilerList&, TUniformMap*) = 0;
@@ -137,7 +137,7 @@ public:
virtual void getAttributeBindings(ShBindingTable const **t) const = 0;
virtual void setExcludedAttributes(const int* attributes, int count) { excludedAttributes = attributes; excludedCount = count; }
virtual ShBindingTable* getUniformBindings() const { return uniformBindings; }
virtual const void* getObjectCode() const { return 0; } // a real compiler would be returning object code here
virtual const void* getObjectCode() const { return nullptr; } // a real compiler would be returning object code here
virtual TInfoSink& getInfoSink() { return infoSink; }
TInfoSink& infoSink;
protected:
@@ -35,12 +35,11 @@
#pragma once
#ifndef GLSLANG_WEB
//
// GL_EXT_spirv_intrinsics
//
#include "Common.h"
#include <variant>
namespace glslang {
@@ -98,12 +97,27 @@ struct TSpirvInstruction {
struct TSpirvTypeParameter {
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
TSpirvTypeParameter(const TIntermConstantUnion* arg) { constant = arg; }
TSpirvTypeParameter(const TIntermConstantUnion* arg) { value = arg; }
TSpirvTypeParameter(const TType* arg) { value = arg; }
bool operator==(const TSpirvTypeParameter& rhs) const { return constant == rhs.constant; }
const TIntermConstantUnion* getAsConstant() const
{
if (value.index() == 0)
return std::get<const TIntermConstantUnion*>(value);
return nullptr;
}
const TType* getAsType() const
{
if (value.index() == 1)
return std::get<const TType*>(value);
return nullptr;
}
bool operator==(const TSpirvTypeParameter& rhs) const;
bool operator!=(const TSpirvTypeParameter& rhs) const { return !operator==(rhs); }
const TIntermConstantUnion* constant;
// Parameter value: constant expression or type specifier
std::variant<const TIntermConstantUnion*, const TType*> value;
};
typedef TVector<TSpirvTypeParameter> TSpirvTypeParameters;
@@ -124,5 +138,3 @@ struct TSpirvType {
};
} // end namespace glslang
#endif // GLSLANG_WEB
File diff suppressed because it is too large Load Diff
+25 -4
View File
@@ -147,6 +147,15 @@ struct TSmallArrayVector {
sizes->erase(sizes->begin());
}
void pop_back()
{
assert(sizes != nullptr && sizes->size() > 0);
if (sizes->size() == 1)
dealloc();
else
sizes->resize(sizes->size() - 1);
}
// 'this' should currently not be holding anything, and copyNonFront
// will make it hold a copy of all but the first element of rhs.
// (This would be useful for making a type that is dereferenced by
@@ -222,7 +231,7 @@ protected:
struct TArraySizes {
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
TArraySizes() : implicitArraySize(1), variablyIndexed(false) { }
TArraySizes() : implicitArraySize(0), implicitlySized(true), variablyIndexed(false){ }
// For breaking into two non-shared copies, independently modifiable.
TArraySizes& operator=(const TArraySizes& from)
@@ -230,6 +239,7 @@ struct TArraySizes {
implicitArraySize = from.implicitArraySize;
variablyIndexed = from.variablyIndexed;
sizes = from.sizes;
implicitlySized = from.implicitlySized;
return *this;
}
@@ -256,11 +266,17 @@ struct TArraySizes {
void addInnerSize(int s, TIntermTyped* n) { sizes.push_back((unsigned)s, n); }
void addInnerSize(TArraySize pair) {
sizes.push_back(pair.size, pair.node);
implicitlySized = false;
}
void addInnerSizes(const TArraySizes& s) { sizes.push_back(s.sizes); }
void changeOuterSize(int s) { sizes.changeFront((unsigned)s); }
int getImplicitSize() const { return implicitArraySize; }
void updateImplicitSize(int s) { implicitArraySize = std::max(implicitArraySize, s); }
void changeOuterSize(int s) {
sizes.changeFront((unsigned)s);
implicitlySized = false;
}
int getImplicitSize() const { return implicitArraySize > 0 ? implicitArraySize : 1; }
void updateImplicitSize(int s) {
implicitArraySize = (std::max)(implicitArraySize, s);
}
bool isInnerUnsized() const
{
for (int d = 1; d < sizes.size(); ++d) {
@@ -295,7 +311,11 @@ struct TArraySizes {
bool hasUnsized() const { return getOuterSize() == UnsizedArraySize || isInnerUnsized(); }
bool isSized() const { return getOuterSize() != UnsizedArraySize; }
bool isImplicitlySized() const { return implicitlySized; }
bool isDefaultImplicitlySized() const { return implicitlySized && implicitArraySize == 0; }
void setImplicitlySized(bool isImplicitSizing) { implicitlySized = isImplicitSizing; }
void dereference() { sizes.pop_front(); }
void removeLastSize() { sizes.pop_back(); }
void copyDereferenced(const TArraySizes& rhs)
{
assert(sizes.size() == 0);
@@ -333,6 +353,7 @@ protected:
// the implicit size of the array, if not variably indexed and
// otherwise legal.
int implicitArraySize;
bool implicitlySized;
bool variablyIndexed; // true if array is indexed with a non compile-time constant
};
@@ -1,253 +0,0 @@
/**
This code is based on the glslang_c_interface implementation by Viktor Latypov
**/
/**
BSD 2-Clause License
Copyright (c) 2019, Viktor Latypov
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**/
#ifndef GLSLANG_C_IFACE_H_INCLUDED
#define GLSLANG_C_IFACE_H_INCLUDED
#include <stdbool.h>
#include <stdlib.h>
#include "glslang_c_shader_types.h"
typedef struct glslang_shader_s glslang_shader_t;
typedef struct glslang_program_s glslang_program_t;
/* TLimits counterpart */
typedef struct glslang_limits_s {
bool non_inductive_for_loops;
bool while_loops;
bool do_while_loops;
bool general_uniform_indexing;
bool general_attribute_matrix_vector_indexing;
bool general_varying_indexing;
bool general_sampler_indexing;
bool general_variable_indexing;
bool general_constant_matrix_vector_indexing;
} glslang_limits_t;
/* TBuiltInResource counterpart */
typedef struct glslang_resource_s {
int max_lights;
int max_clip_planes;
int max_texture_units;
int max_texture_coords;
int max_vertex_attribs;
int max_vertex_uniform_components;
int max_varying_floats;
int max_vertex_texture_image_units;
int max_combined_texture_image_units;
int max_texture_image_units;
int max_fragment_uniform_components;
int max_draw_buffers;
int max_vertex_uniform_vectors;
int max_varying_vectors;
int max_fragment_uniform_vectors;
int max_vertex_output_vectors;
int max_fragment_input_vectors;
int min_program_texel_offset;
int max_program_texel_offset;
int max_clip_distances;
int max_compute_work_group_count_x;
int max_compute_work_group_count_y;
int max_compute_work_group_count_z;
int max_compute_work_group_size_x;
int max_compute_work_group_size_y;
int max_compute_work_group_size_z;
int max_compute_uniform_components;
int max_compute_texture_image_units;
int max_compute_image_uniforms;
int max_compute_atomic_counters;
int max_compute_atomic_counter_buffers;
int max_varying_components;
int max_vertex_output_components;
int max_geometry_input_components;
int max_geometry_output_components;
int max_fragment_input_components;
int max_image_units;
int max_combined_image_units_and_fragment_outputs;
int max_combined_shader_output_resources;
int max_image_samples;
int max_vertex_image_uniforms;
int max_tess_control_image_uniforms;
int max_tess_evaluation_image_uniforms;
int max_geometry_image_uniforms;
int max_fragment_image_uniforms;
int max_combined_image_uniforms;
int max_geometry_texture_image_units;
int max_geometry_output_vertices;
int max_geometry_total_output_components;
int max_geometry_uniform_components;
int max_geometry_varying_components;
int max_tess_control_input_components;
int max_tess_control_output_components;
int max_tess_control_texture_image_units;
int max_tess_control_uniform_components;
int max_tess_control_total_output_components;
int max_tess_evaluation_input_components;
int max_tess_evaluation_output_components;
int max_tess_evaluation_texture_image_units;
int max_tess_evaluation_uniform_components;
int max_tess_patch_components;
int max_patch_vertices;
int max_tess_gen_level;
int max_viewports;
int max_vertex_atomic_counters;
int max_tess_control_atomic_counters;
int max_tess_evaluation_atomic_counters;
int max_geometry_atomic_counters;
int max_fragment_atomic_counters;
int max_combined_atomic_counters;
int max_atomic_counter_bindings;
int max_vertex_atomic_counter_buffers;
int max_tess_control_atomic_counter_buffers;
int max_tess_evaluation_atomic_counter_buffers;
int max_geometry_atomic_counter_buffers;
int max_fragment_atomic_counter_buffers;
int max_combined_atomic_counter_buffers;
int max_atomic_counter_buffer_size;
int max_transform_feedback_buffers;
int max_transform_feedback_interleaved_components;
int max_cull_distances;
int max_combined_clip_and_cull_distances;
int max_samples;
int max_mesh_output_vertices_nv;
int max_mesh_output_primitives_nv;
int max_mesh_work_group_size_x_nv;
int max_mesh_work_group_size_y_nv;
int max_mesh_work_group_size_z_nv;
int max_task_work_group_size_x_nv;
int max_task_work_group_size_y_nv;
int max_task_work_group_size_z_nv;
int max_mesh_view_count_nv;
int maxDualSourceDrawBuffersEXT;
glslang_limits_t limits;
} glslang_resource_t;
typedef struct glslang_input_s {
glslang_source_t language;
glslang_stage_t stage;
glslang_client_t client;
glslang_target_client_version_t client_version;
glslang_target_language_t target_language;
glslang_target_language_version_t target_language_version;
/** Shader source code */
const char* code;
int default_version;
glslang_profile_t default_profile;
int force_default_version_and_profile;
int forward_compatible;
glslang_messages_t messages;
const glslang_resource_t* resource;
} glslang_input_t;
/* Inclusion result structure allocated by C include_local/include_system callbacks */
typedef struct glsl_include_result_s {
/* Header file name or NULL if inclusion failed */
const char* header_name;
/* Header contents or NULL */
const char* header_data;
size_t header_length;
} glsl_include_result_t;
/* Callback for local file inclusion */
typedef glsl_include_result_t* (*glsl_include_local_func)(void* ctx, const char* header_name, const char* includer_name,
size_t include_depth);
/* Callback for system file inclusion */
typedef glsl_include_result_t* (*glsl_include_system_func)(void* ctx, const char* header_name,
const char* includer_name, size_t include_depth);
/* Callback for include result destruction */
typedef int (*glsl_free_include_result_func)(void* ctx, glsl_include_result_t* result);
/* Collection of callbacks for GLSL preprocessor */
typedef struct glsl_include_callbacks_s {
glsl_include_system_func include_system;
glsl_include_local_func include_local;
glsl_free_include_result_func free_include_result;
} glsl_include_callbacks_t;
#ifdef __cplusplus
extern "C" {
#endif
#ifdef GLSLANG_IS_SHARED_LIBRARY
#ifdef _WIN32
#ifdef GLSLANG_EXPORTING
#define GLSLANG_EXPORT __declspec(dllexport)
#else
#define GLSLANG_EXPORT __declspec(dllimport)
#endif
#elif __GNUC__ >= 4
#define GLSLANG_EXPORT __attribute__((visibility("default")))
#endif
#endif // GLSLANG_IS_SHARED_LIBRARY
#ifndef GLSLANG_EXPORT
#define GLSLANG_EXPORT
#endif
GLSLANG_EXPORT int glslang_initialize_process();
GLSLANG_EXPORT void glslang_finalize_process();
GLSLANG_EXPORT glslang_shader_t* glslang_shader_create(const glslang_input_t* input);
GLSLANG_EXPORT void glslang_shader_delete(glslang_shader_t* shader);
GLSLANG_EXPORT void glslang_shader_shift_binding(glslang_shader_t* shader, glslang_resource_type_t res, unsigned int base);
GLSLANG_EXPORT void glslang_shader_shift_binding_for_set(glslang_shader_t* shader, glslang_resource_type_t res, unsigned int base, unsigned int set);
GLSLANG_EXPORT void glslang_shader_set_options(glslang_shader_t* shader, int options); // glslang_shader_options_t
GLSLANG_EXPORT int glslang_shader_preprocess(glslang_shader_t* shader, const glslang_input_t* input);
GLSLANG_EXPORT int glslang_shader_parse(glslang_shader_t* shader, const glslang_input_t* input);
GLSLANG_EXPORT const char* glslang_shader_get_preprocessed_code(glslang_shader_t* shader);
GLSLANG_EXPORT const char* glslang_shader_get_info_log(glslang_shader_t* shader);
GLSLANG_EXPORT const char* glslang_shader_get_info_debug_log(glslang_shader_t* shader);
GLSLANG_EXPORT glslang_program_t* glslang_program_create();
GLSLANG_EXPORT void glslang_program_delete(glslang_program_t* program);
GLSLANG_EXPORT void glslang_program_add_shader(glslang_program_t* program, glslang_shader_t* shader);
GLSLANG_EXPORT int glslang_program_link(glslang_program_t* program, int messages); // glslang_messages_t
GLSLANG_EXPORT int glslang_program_map_io(glslang_program_t* program);
GLSLANG_EXPORT void glslang_program_SPIRV_generate(glslang_program_t* program, glslang_stage_t stage);
GLSLANG_EXPORT size_t glslang_program_SPIRV_get_size(glslang_program_t* program);
GLSLANG_EXPORT void glslang_program_SPIRV_get(glslang_program_t* program, unsigned int*);
GLSLANG_EXPORT unsigned int* glslang_program_SPIRV_get_ptr(glslang_program_t* program);
GLSLANG_EXPORT const char* glslang_program_SPIRV_get_messages(glslang_program_t* program);
GLSLANG_EXPORT const char* glslang_program_get_info_log(glslang_program_t* program);
GLSLANG_EXPORT const char* glslang_program_get_info_debug_log(glslang_program_t* program);
#ifdef __cplusplus
}
#endif
#endif /* #ifdef GLSLANG_C_IFACE_INCLUDED */
@@ -1,207 +0,0 @@
/**
This code is based on the glslang_c_interface implementation by Viktor Latypov
**/
/**
BSD 2-Clause License
Copyright (c) 2019, Viktor Latypov
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**/
#ifndef C_SHADER_TYPES_H_INCLUDED
#define C_SHADER_TYPES_H_INCLUDED
#define LAST_ELEMENT_MARKER(x) x
/* EShLanguage counterpart */
typedef enum {
GLSLANG_STAGE_VERTEX,
GLSLANG_STAGE_TESSCONTROL,
GLSLANG_STAGE_TESSEVALUATION,
GLSLANG_STAGE_GEOMETRY,
GLSLANG_STAGE_FRAGMENT,
GLSLANG_STAGE_COMPUTE,
GLSLANG_STAGE_RAYGEN_NV,
GLSLANG_STAGE_INTERSECT_NV,
GLSLANG_STAGE_ANYHIT_NV,
GLSLANG_STAGE_CLOSESTHIT_NV,
GLSLANG_STAGE_MISS_NV,
GLSLANG_STAGE_CALLABLE_NV,
GLSLANG_STAGE_TASK_NV,
GLSLANG_STAGE_MESH_NV,
LAST_ELEMENT_MARKER(GLSLANG_STAGE_COUNT),
} glslang_stage_t; // would be better as stage, but this is ancient now
/* EShLanguageMask counterpart */
typedef enum {
GLSLANG_STAGE_VERTEX_MASK = (1 << GLSLANG_STAGE_VERTEX),
GLSLANG_STAGE_TESSCONTROL_MASK = (1 << GLSLANG_STAGE_TESSCONTROL),
GLSLANG_STAGE_TESSEVALUATION_MASK = (1 << GLSLANG_STAGE_TESSEVALUATION),
GLSLANG_STAGE_GEOMETRY_MASK = (1 << GLSLANG_STAGE_GEOMETRY),
GLSLANG_STAGE_FRAGMENT_MASK = (1 << GLSLANG_STAGE_FRAGMENT),
GLSLANG_STAGE_COMPUTE_MASK = (1 << GLSLANG_STAGE_COMPUTE),
GLSLANG_STAGE_RAYGEN_NV_MASK = (1 << GLSLANG_STAGE_RAYGEN_NV),
GLSLANG_STAGE_INTERSECT_NV_MASK = (1 << GLSLANG_STAGE_INTERSECT_NV),
GLSLANG_STAGE_ANYHIT_NV_MASK = (1 << GLSLANG_STAGE_ANYHIT_NV),
GLSLANG_STAGE_CLOSESTHIT_NV_MASK = (1 << GLSLANG_STAGE_CLOSESTHIT_NV),
GLSLANG_STAGE_MISS_NV_MASK = (1 << GLSLANG_STAGE_MISS_NV),
GLSLANG_STAGE_CALLABLE_NV_MASK = (1 << GLSLANG_STAGE_CALLABLE_NV),
GLSLANG_STAGE_TASK_NV_MASK = (1 << GLSLANG_STAGE_TASK_NV),
GLSLANG_STAGE_MESH_NV_MASK = (1 << GLSLANG_STAGE_MESH_NV),
LAST_ELEMENT_MARKER(GLSLANG_STAGE_MASK_COUNT),
} glslang_stage_mask_t;
/* EShSource counterpart */
typedef enum {
GLSLANG_SOURCE_NONE,
GLSLANG_SOURCE_GLSL,
GLSLANG_SOURCE_HLSL,
LAST_ELEMENT_MARKER(GLSLANG_SOURCE_COUNT),
} glslang_source_t;
/* EShClient counterpart */
typedef enum {
GLSLANG_CLIENT_NONE,
GLSLANG_CLIENT_VULKAN,
GLSLANG_CLIENT_OPENGL,
LAST_ELEMENT_MARKER(GLSLANG_CLIENT_COUNT),
} glslang_client_t;
/* EShTargetLanguage counterpart */
typedef enum {
GLSLANG_TARGET_NONE,
GLSLANG_TARGET_SPV,
LAST_ELEMENT_MARKER(GLSLANG_TARGET_COUNT),
} glslang_target_language_t;
/* SH_TARGET_ClientVersion counterpart */
typedef enum {
GLSLANG_TARGET_VULKAN_1_0 = (1 << 22),
GLSLANG_TARGET_VULKAN_1_1 = (1 << 22) | (1 << 12),
GLSLANG_TARGET_VULKAN_1_2 = (1 << 22) | (2 << 12),
GLSLANG_TARGET_OPENGL_450 = 450,
LAST_ELEMENT_MARKER(GLSLANG_TARGET_CLIENT_VERSION_COUNT = 4),
} glslang_target_client_version_t;
/* SH_TARGET_LanguageVersion counterpart */
typedef enum {
GLSLANG_TARGET_SPV_1_0 = (1 << 16),
GLSLANG_TARGET_SPV_1_1 = (1 << 16) | (1 << 8),
GLSLANG_TARGET_SPV_1_2 = (1 << 16) | (2 << 8),
GLSLANG_TARGET_SPV_1_3 = (1 << 16) | (3 << 8),
GLSLANG_TARGET_SPV_1_4 = (1 << 16) | (4 << 8),
GLSLANG_TARGET_SPV_1_5 = (1 << 16) | (5 << 8),
GLSLANG_TARGET_SPV_1_6 = (1 << 16) | (6 << 8),
LAST_ELEMENT_MARKER(GLSLANG_TARGET_LANGUAGE_VERSION_COUNT = 7),
} glslang_target_language_version_t;
/* EShExecutable counterpart */
typedef enum { GLSLANG_EX_VERTEX_FRAGMENT, GLSLANG_EX_FRAGMENT } glslang_executable_t;
/* EShOptimizationLevel counterpart */
typedef enum {
GLSLANG_OPT_NO_GENERATION,
GLSLANG_OPT_NONE,
GLSLANG_OPT_SIMPLE,
GLSLANG_OPT_FULL,
LAST_ELEMENT_MARKER(GLSLANG_OPT_LEVEL_COUNT),
} glslang_optimization_level_t;
/* EShTextureSamplerTransformMode counterpart */
typedef enum {
GLSLANG_TEX_SAMP_TRANS_KEEP,
GLSLANG_TEX_SAMP_TRANS_UPGRADE_TEXTURE_REMOVE_SAMPLER,
LAST_ELEMENT_MARKER(GLSLANG_TEX_SAMP_TRANS_COUNT),
} glslang_texture_sampler_transform_mode_t;
/* EShMessages counterpart */
typedef enum {
GLSLANG_MSG_DEFAULT_BIT = 0,
GLSLANG_MSG_RELAXED_ERRORS_BIT = (1 << 0),
GLSLANG_MSG_SUPPRESS_WARNINGS_BIT = (1 << 1),
GLSLANG_MSG_AST_BIT = (1 << 2),
GLSLANG_MSG_SPV_RULES_BIT = (1 << 3),
GLSLANG_MSG_VULKAN_RULES_BIT = (1 << 4),
GLSLANG_MSG_ONLY_PREPROCESSOR_BIT = (1 << 5),
GLSLANG_MSG_READ_HLSL_BIT = (1 << 6),
GLSLANG_MSG_CASCADING_ERRORS_BIT = (1 << 7),
GLSLANG_MSG_KEEP_UNCALLED_BIT = (1 << 8),
GLSLANG_MSG_HLSL_OFFSETS_BIT = (1 << 9),
GLSLANG_MSG_DEBUG_INFO_BIT = (1 << 10),
GLSLANG_MSG_HLSL_ENABLE_16BIT_TYPES_BIT = (1 << 11),
GLSLANG_MSG_HLSL_LEGALIZATION_BIT = (1 << 12),
GLSLANG_MSG_HLSL_DX9_COMPATIBLE_BIT = (1 << 13),
GLSLANG_MSG_BUILTIN_SYMBOL_TABLE_BIT = (1 << 14),
LAST_ELEMENT_MARKER(GLSLANG_MSG_COUNT),
} glslang_messages_t;
/* EShReflectionOptions counterpart */
typedef enum {
GLSLANG_REFLECTION_DEFAULT_BIT = 0,
GLSLANG_REFLECTION_STRICT_ARRAY_SUFFIX_BIT = (1 << 0),
GLSLANG_REFLECTION_BASIC_ARRAY_SUFFIX_BIT = (1 << 1),
GLSLANG_REFLECTION_INTERMEDIATE_IOO_BIT = (1 << 2),
GLSLANG_REFLECTION_SEPARATE_BUFFERS_BIT = (1 << 3),
GLSLANG_REFLECTION_ALL_BLOCK_VARIABLES_BIT = (1 << 4),
GLSLANG_REFLECTION_UNWRAP_IO_BLOCKS_BIT = (1 << 5),
GLSLANG_REFLECTION_ALL_IO_VARIABLES_BIT = (1 << 6),
GLSLANG_REFLECTION_SHARED_STD140_SSBO_BIT = (1 << 7),
GLSLANG_REFLECTION_SHARED_STD140_UBO_BIT = (1 << 8),
LAST_ELEMENT_MARKER(GLSLANG_REFLECTION_COUNT),
} glslang_reflection_options_t;
/* EProfile counterpart (from Versions.h) */
typedef enum {
GLSLANG_BAD_PROFILE = 0,
GLSLANG_NO_PROFILE = (1 << 0),
GLSLANG_CORE_PROFILE = (1 << 1),
GLSLANG_COMPATIBILITY_PROFILE = (1 << 2),
GLSLANG_ES_PROFILE = (1 << 3),
LAST_ELEMENT_MARKER(GLSLANG_PROFILE_COUNT),
} glslang_profile_t;
/* Shader options */
typedef enum {
GLSLANG_SHADER_DEFAULT_BIT = 0,
GLSLANG_SHADER_AUTO_MAP_BINDINGS = (1 << 0),
GLSLANG_SHADER_AUTO_MAP_LOCATIONS = (1 << 1),
GLSLANG_SHADER_VULKAN_RULES_RELAXED = (1 << 2),
LAST_ELEMENT_MARKER(GLSLANG_SHADER_COUNT),
} glslang_shader_options_t;
/* TResourceType counterpart */
typedef enum {
GLSLANG_RESOURCE_TYPE_SAMPLER,
GLSLANG_RESOURCE_TYPE_TEXTURE,
GLSLANG_RESOURCE_TYPE_IMAGE,
GLSLANG_RESOURCE_TYPE_UBO,
GLSLANG_RESOURCE_TYPE_SSBO,
GLSLANG_RESOURCE_TYPE_UAV,
LAST_ELEMENT_MARKER(GLSLANG_RESOURCE_TYPE_COUNT),
} glslang_resource_type_t;
#undef LAST_ELEMENT_MARKER
#endif
@@ -48,14 +48,9 @@
#ifndef __INTERMEDIATE_H
#define __INTERMEDIATE_H
#if defined(_MSC_VER) && _MSC_VER >= 1900
#pragma warning(disable : 4464) // relative include path contains '..'
#pragma warning(disable : 5026) // 'glslang::TIntermUnary': move constructor was implicitly defined as deleted
#endif
#include "../Include/Common.h"
#include "../Include/Types.h"
#include "../Include/ConstantUnion.h"
#include "Common.h"
#include "Types.h"
#include "ConstantUnion.h"
namespace glslang {
@@ -67,13 +62,12 @@ class TIntermediate;
enum TOperator {
EOpNull, // if in a node, should only mean a node is still being built
EOpSequence, // denotes a list of statements, or parameters, etc.
EOpScope, // Used by debugging to denote a scoped list of statements
EOpLinkerObjects, // for aggregate node of objects the linker may need, if not reference by the rest of the AST
EOpFunctionCall,
EOpFunction, // For function definition
EOpParameters, // an aggregate listing the parameters to a function
#ifndef GLSLANG_WEB
EOpSpirvInst,
#endif
//
// Unary operators
@@ -91,6 +85,8 @@ enum TOperator {
EOpCopyObject,
EOpDeclare, // Used by debugging to force declaration of variable in correct scope
// (u)int* -> bool
EOpConvInt8ToBool,
EOpConvUint8ToBool,
@@ -626,6 +622,9 @@ enum TOperator {
EOpCooperativeMatrixLoad,
EOpCooperativeMatrixStore,
EOpCooperativeMatrixMulAdd,
EOpCooperativeMatrixLoadNV,
EOpCooperativeMatrixStoreNV,
EOpCooperativeMatrixMulAddNV,
EOpBeginInvocationInterlock, // Fragment only
EOpEndInvocationInterlock, // Fragment only
@@ -763,7 +762,8 @@ enum TOperator {
EOpConstructTextureSampler,
EOpConstructNonuniform, // expected to be transformed away, not present in final AST
EOpConstructReference,
EOpConstructCooperativeMatrix,
EOpConstructCooperativeMatrixNV,
EOpConstructCooperativeMatrixKHR,
EOpConstructAccStruct,
EOpConstructGuardEnd,
@@ -824,6 +824,7 @@ enum TOperator {
EOpSubpassLoadMS,
EOpSparseImageLoad,
EOpSparseImageLoadLod,
EOpColorAttachmentReadEXT, // Fragment only
EOpImageGuardEnd,
@@ -934,6 +935,8 @@ enum TOperator {
EOpExecuteCallableNV,
EOpExecuteCallableKHR,
EOpWritePackedPrimitiveIndices4x8NV,
EOpEmitMeshTasksEXT,
EOpSetMeshOutputsEXT,
//
// GL_EXT_ray_query operations
@@ -963,7 +966,44 @@ enum TOperator {
EOpRayQueryGetIntersectionObjectToWorld,
EOpRayQueryGetIntersectionWorldToObject,
//
// GL_NV_shader_invocation_reorder
//
EOpHitObjectTraceRayNV,
EOpHitObjectTraceRayMotionNV,
EOpHitObjectRecordHitNV,
EOpHitObjectRecordHitMotionNV,
EOpHitObjectRecordHitWithIndexNV,
EOpHitObjectRecordHitWithIndexMotionNV,
EOpHitObjectRecordMissNV,
EOpHitObjectRecordMissMotionNV,
EOpHitObjectRecordEmptyNV,
EOpHitObjectExecuteShaderNV,
EOpHitObjectIsEmptyNV,
EOpHitObjectIsMissNV,
EOpHitObjectIsHitNV,
EOpHitObjectGetRayTMinNV,
EOpHitObjectGetRayTMaxNV,
EOpHitObjectGetObjectRayOriginNV,
EOpHitObjectGetObjectRayDirectionNV,
EOpHitObjectGetWorldRayOriginNV,
EOpHitObjectGetWorldRayDirectionNV,
EOpHitObjectGetWorldToObjectNV,
EOpHitObjectGetObjectToWorldNV,
EOpHitObjectGetInstanceCustomIndexNV,
EOpHitObjectGetInstanceIdNV,
EOpHitObjectGetGeometryIndexNV,
EOpHitObjectGetPrimitiveIndexNV,
EOpHitObjectGetHitKindNV,
EOpHitObjectGetShaderBindingTableRecordIndexNV,
EOpHitObjectGetShaderRecordBufferHandleNV,
EOpHitObjectGetAttributesNV,
EOpHitObjectGetCurrentTimeNV,
EOpReorderThreadNV,
EOpFetchMicroTriangleVertexPositionNV,
EOpFetchMicroTriangleVertexBarycentricNV,
// HLSL operations
//
@@ -1050,6 +1090,24 @@ enum TOperator {
// Shader Clock Ops
EOpReadClockSubgroupKHR,
EOpReadClockDeviceKHR,
// GL_EXT_ray_tracing_position_fetch
EOpRayQueryGetIntersectionTriangleVertexPositionsEXT,
// Shader tile image ops
EOpStencilAttachmentReadEXT, // Fragment only
EOpDepthAttachmentReadEXT, // Fragment only
// Image processing
EOpImageSampleWeightedQCOM,
EOpImageBoxFilterQCOM,
EOpImageBlockMatchSADQCOM,
EOpImageBlockMatchSSDQCOM,
};
enum TLinkType {
ELinkNone,
ELinkExport,
};
class TIntermTraverser;
@@ -1081,31 +1139,31 @@ public:
virtual const glslang::TSourceLoc& getLoc() const { return loc; }
virtual void setLoc(const glslang::TSourceLoc& l) { loc = l; }
virtual void traverse(glslang::TIntermTraverser*) = 0;
virtual glslang::TIntermTyped* getAsTyped() { return 0; }
virtual glslang::TIntermOperator* getAsOperator() { return 0; }
virtual glslang::TIntermConstantUnion* getAsConstantUnion() { return 0; }
virtual glslang::TIntermAggregate* getAsAggregate() { return 0; }
virtual glslang::TIntermUnary* getAsUnaryNode() { return 0; }
virtual glslang::TIntermBinary* getAsBinaryNode() { return 0; }
virtual glslang::TIntermSelection* getAsSelectionNode() { return 0; }
virtual glslang::TIntermSwitch* getAsSwitchNode() { return 0; }
virtual glslang::TIntermMethod* getAsMethodNode() { return 0; }
virtual glslang::TIntermSymbol* getAsSymbolNode() { return 0; }
virtual glslang::TIntermBranch* getAsBranchNode() { return 0; }
virtual glslang::TIntermLoop* getAsLoopNode() { return 0; }
virtual glslang::TIntermTyped* getAsTyped() { return nullptr; }
virtual glslang::TIntermOperator* getAsOperator() { return nullptr; }
virtual glslang::TIntermConstantUnion* getAsConstantUnion() { return nullptr; }
virtual glslang::TIntermAggregate* getAsAggregate() { return nullptr; }
virtual glslang::TIntermUnary* getAsUnaryNode() { return nullptr; }
virtual glslang::TIntermBinary* getAsBinaryNode() { return nullptr; }
virtual glslang::TIntermSelection* getAsSelectionNode() { return nullptr; }
virtual glslang::TIntermSwitch* getAsSwitchNode() { return nullptr; }
virtual glslang::TIntermMethod* getAsMethodNode() { return nullptr; }
virtual glslang::TIntermSymbol* getAsSymbolNode() { return nullptr; }
virtual glslang::TIntermBranch* getAsBranchNode() { return nullptr; }
virtual glslang::TIntermLoop* getAsLoopNode() { return nullptr; }
virtual const glslang::TIntermTyped* getAsTyped() const { return 0; }
virtual const glslang::TIntermOperator* getAsOperator() const { return 0; }
virtual const glslang::TIntermConstantUnion* getAsConstantUnion() const { return 0; }
virtual const glslang::TIntermAggregate* getAsAggregate() const { return 0; }
virtual const glslang::TIntermUnary* getAsUnaryNode() const { return 0; }
virtual const glslang::TIntermBinary* getAsBinaryNode() const { return 0; }
virtual const glslang::TIntermSelection* getAsSelectionNode() const { return 0; }
virtual const glslang::TIntermSwitch* getAsSwitchNode() const { return 0; }
virtual const glslang::TIntermMethod* getAsMethodNode() const { return 0; }
virtual const glslang::TIntermSymbol* getAsSymbolNode() const { return 0; }
virtual const glslang::TIntermBranch* getAsBranchNode() const { return 0; }
virtual const glslang::TIntermLoop* getAsLoopNode() const { return 0; }
virtual const glslang::TIntermTyped* getAsTyped() const { return nullptr; }
virtual const glslang::TIntermOperator* getAsOperator() const { return nullptr; }
virtual const glslang::TIntermConstantUnion* getAsConstantUnion() const { return nullptr; }
virtual const glslang::TIntermAggregate* getAsAggregate() const { return nullptr; }
virtual const glslang::TIntermUnary* getAsUnaryNode() const { return nullptr; }
virtual const glslang::TIntermBinary* getAsBinaryNode() const { return nullptr; }
virtual const glslang::TIntermSelection* getAsSelectionNode() const { return nullptr; }
virtual const glslang::TIntermSwitch* getAsSwitchNode() const { return nullptr; }
virtual const glslang::TIntermMethod* getAsMethodNode() const { return nullptr; }
virtual const glslang::TIntermSymbol* getAsSymbolNode() const { return nullptr; }
virtual const glslang::TIntermBranch* getAsBranchNode() const { return nullptr; }
virtual const glslang::TIntermLoop* getAsLoopNode() const { return nullptr; }
virtual ~TIntermNode() { }
protected:
@@ -1155,7 +1213,7 @@ public:
virtual bool isIntegerDomain() const { return type.isIntegerDomain(); }
bool isAtomic() const { return type.isAtomic(); }
bool isReference() const { return type.isReference(); }
TString getCompleteString() const { return type.getCompleteString(); }
TString getCompleteString(bool enhanced = false) const { return type.getCompleteString(enhanced); }
protected:
TIntermTyped& operator=(const TIntermTyped&);
@@ -1269,9 +1327,11 @@ public:
virtual const TString& getMethodName() const { return method; }
virtual TIntermTyped* getObject() const { return object; }
virtual void traverse(TIntermTraverser*);
void setExport() { linkType = ELinkExport; }
protected:
TIntermTyped* object;
TString method;
TLinkType linkType;
};
//
@@ -1283,12 +1343,7 @@ public:
// per process threadPoolAllocator, then it causes increased memory usage per compile
// it is essential to use "symbol = sym" to assign to symbol
TIntermSymbol(long long i, const TString& n, const TType& t)
: TIntermTyped(t), id(i),
#ifndef GLSLANG_WEB
flattenSubset(-1),
#endif
constSubtree(nullptr)
{ name = n; }
: TIntermTyped(t), id(i), flattenSubset(-1), constSubtree(nullptr) { name = n; }
virtual long long getId() const { return id; }
virtual void changeId(long long i) { id = i; }
virtual const TString& getName() const { return name; }
@@ -1299,12 +1354,10 @@ public:
const TConstUnionArray& getConstArray() const { return constArray; }
void setConstSubtree(TIntermTyped* subtree) { constSubtree = subtree; }
TIntermTyped* getConstSubtree() const { return constSubtree; }
#ifndef GLSLANG_WEB
void setFlattenSubset(int subset) { flattenSubset = subset; }
virtual const TString& getAccessName() const;
int getFlattenSubset() const { return flattenSubset; } // -1 means full object
#endif
// This is meant for cases where a node has already been constructed, and
// later on, it becomes necessary to switch to a different symbol.
@@ -1312,9 +1365,7 @@ public:
protected:
long long id; // the unique id of the symbol this node represents
#ifndef GLSLANG_WEB
int flattenSubset; // how deeply the flattened object rooted at id has been dereferenced
#endif
TString name; // the name of the symbol this node represents
TConstUnionArray constArray; // if the symbol is a front-end compile-time constant, this is its value
TIntermTyped* constSubtree;
@@ -1353,6 +1404,7 @@ struct TCrackedTextureOp {
bool subpass;
bool lodClamp;
bool fragMask;
bool attachmentEXT;
};
//
@@ -1368,19 +1420,11 @@ public:
bool isConstructor() const;
bool isTexture() const { return op > EOpTextureGuardBegin && op < EOpTextureGuardEnd; }
bool isSampling() const { return op > EOpSamplingGuardBegin && op < EOpSamplingGuardEnd; }
#ifdef GLSLANG_WEB
bool isImage() const { return false; }
bool isSparseTexture() const { return false; }
bool isImageFootprint() const { return false; }
bool isSparseImage() const { return false; }
bool isSubgroup() const { return false; }
#else
bool isImage() const { return op > EOpImageGuardBegin && op < EOpImageGuardEnd; }
bool isSparseTexture() const { return op > EOpSparseTextureGuardBegin && op < EOpSparseTextureGuardEnd; }
bool isImageFootprint() const { return op > EOpImageFootprintGuardBegin && op < EOpImageFootprintGuardEnd; }
bool isSparseImage() const { return op == EOpSparseImageLoad; }
bool isSubgroup() const { return op > EOpSubgroupGuardStart && op < EOpSubgroupGuardStop; }
#endif
void setOperationPrecision(TPrecisionQualifier p) { operationPrecision = p; }
TPrecisionQualifier getOperationPrecision() const { return operationPrecision != EpqNone ?
@@ -1409,6 +1453,7 @@ public:
cracked.gather = false;
cracked.grad = false;
cracked.subpass = false;
cracked.attachmentEXT = false;
cracked.lodClamp = false;
cracked.fragMask = false;
@@ -1485,7 +1530,6 @@ public:
cracked.offset = true;
cracked.proj = true;
break;
#ifndef GLSLANG_WEB
case EOpTextureClamp:
case EOpSparseTextureClamp:
cracked.lodClamp = true;
@@ -1569,7 +1613,9 @@ public:
case EOpSubpassLoadMS:
cracked.subpass = true;
break;
#endif
case EOpColorAttachmentReadEXT:
cracked.attachmentEXT = true;
break;
default:
break;
}
@@ -1611,8 +1657,8 @@ protected:
//
class TIntermUnary : public TIntermOperator {
public:
TIntermUnary(TOperator o, TType& t) : TIntermOperator(o, t), operand(0) {}
TIntermUnary(TOperator o) : TIntermOperator(o), operand(0) {}
TIntermUnary(TOperator o, TType& t) : TIntermOperator(o, t), operand(nullptr) {}
TIntermUnary(TOperator o) : TIntermOperator(o), operand(nullptr) {}
virtual void traverse(TIntermTraverser*);
virtual void setOperand(TIntermTyped* o) { operand = o; }
virtual TIntermTyped* getOperand() { return operand; }
@@ -1620,15 +1666,11 @@ public:
virtual TIntermUnary* getAsUnaryNode() { return this; }
virtual const TIntermUnary* getAsUnaryNode() const { return this; }
virtual void updatePrecision();
#ifndef GLSLANG_WEB
void setSpirvInstruction(const TSpirvInstruction& inst) { spirvInst = inst; }
const TSpirvInstruction& getSpirvInstruction() const { return spirvInst; }
#endif
protected:
TIntermTyped* operand;
#ifndef GLSLANG_WEB
TSpirvInstruction spirvInst;
#endif
};
typedef TVector<TIntermNode*> TIntermSequence;
@@ -1660,10 +1702,11 @@ public:
bool getDebug() const { return debug; }
void setPragmaTable(const TPragmaTable& pTable);
const TPragmaTable& getPragmaTable() const { return *pragmaTable; }
#ifndef GLSLANG_WEB
void setSpirvInstruction(const TSpirvInstruction& inst) { spirvInst = inst; }
const TSpirvInstruction& getSpirvInstruction() const { return spirvInst; }
#endif
void setLinkType(TLinkType l) { linkType = l; }
TLinkType getLinkType() const { return linkType; }
protected:
TIntermAggregate(const TIntermAggregate&); // disallow copy constructor
TIntermAggregate& operator=(const TIntermAggregate&); // disallow assignment operator
@@ -1674,9 +1717,8 @@ protected:
bool optimize;
bool debug;
TPragmaTable* pragmaTable;
#ifndef GLSLANG_WEB
TSpirvInstruction spirvInst;
#endif
TLinkType linkType = ELinkNone;
};
//
@@ -1814,7 +1856,7 @@ public:
TIntermNode *getParentNode()
{
return path.size() == 0 ? NULL : path.back();
return path.size() == 0 ? nullptr : path.back();
}
const bool preVisit;
@@ -177,7 +177,6 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TIntermTyped* right
newConstArray[i].setUConst(leftUnionArray[i].getUConst() / rightUnionArray[i].getUConst());
break;
#ifndef GLSLANG_WEB
case EbtInt8:
if (rightUnionArray[i] == (signed char)0)
newConstArray[i].setI8Const((signed char)0x7F);
@@ -212,9 +211,9 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TIntermTyped* right
case EbtInt64:
if (rightUnionArray[i] == 0ll)
newConstArray[i].setI64Const(0x7FFFFFFFFFFFFFFFll);
else if (rightUnionArray[i].getI64Const() == -1 && leftUnionArray[i].getI64Const() == (long long)-0x8000000000000000ll)
newConstArray[i].setI64Const((long long)-0x8000000000000000ll);
newConstArray[i].setI64Const(LLONG_MAX);
else if (rightUnionArray[i].getI64Const() == -1 && leftUnionArray[i].getI64Const() == LLONG_MIN)
newConstArray[i].setI64Const(LLONG_MIN);
else
newConstArray[i].setI64Const(leftUnionArray[i].getI64Const() / rightUnionArray[i].getI64Const());
break;
@@ -226,8 +225,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TIntermTyped* right
newConstArray[i].setU64Const(leftUnionArray[i].getU64Const() / rightUnionArray[i].getU64Const());
break;
default:
return 0;
#endif
return nullptr;
}
}
break;
@@ -266,7 +264,6 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TIntermTyped* right
newConstArray[i].setIConst(0);
break;
} else goto modulo_default;
#ifndef GLSLANG_WEB
case EbtInt64:
if (rightUnionArray[i].getI64Const() == -1 && leftUnionArray[i].getI64Const() == LLONG_MIN) {
newConstArray[i].setI64Const(0);
@@ -277,7 +274,6 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TIntermTyped* right
newConstArray[i].setIConst(0);
break;
} else goto modulo_default;
#endif
default:
modulo_default:
newConstArray[i] = leftUnionArray[i] % rightUnionArray[i];
@@ -354,7 +350,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TIntermTyped* right
break;
default:
return 0;
return nullptr;
}
TIntermConstantUnion *newNode = new TIntermConstantUnion(newConstArray, returnType);
@@ -507,14 +503,12 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TType& returnType)
: -unionArray[i].getIConst());
break;
case EbtUint: newConstArray[i].setUConst(static_cast<unsigned int>(-static_cast<int>(unionArray[i].getUConst()))); break;
#ifndef GLSLANG_WEB
case EbtInt8: newConstArray[i].setI8Const(-unionArray[i].getI8Const()); break;
case EbtUint8: newConstArray[i].setU8Const(static_cast<unsigned int>(-static_cast<signed int>(unionArray[i].getU8Const()))); break;
case EbtInt16: newConstArray[i].setI16Const(-unionArray[i].getI16Const()); break;
case EbtUint16:newConstArray[i].setU16Const(static_cast<unsigned int>(-static_cast<signed int>(unionArray[i].getU16Const()))); break;
case EbtInt64: newConstArray[i].setI64Const(-unionArray[i].getI64Const()); break;
case EbtUint64: newConstArray[i].setU64Const(static_cast<unsigned long long>(-static_cast<long long>(unionArray[i].getU64Const()))); break;
#endif
default:
return nullptr;
}
@@ -634,12 +628,12 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TType& returnType)
case EOpIsNan:
{
newConstArray[i].setBConst(IsNan(unionArray[i].getDConst()));
newConstArray[i].setBConst(std::isnan(unionArray[i].getDConst()));
break;
}
case EOpIsInf:
{
newConstArray[i].setBConst(IsInfinity(unionArray[i].getDConst()));
newConstArray[i].setBConst(std::isinf(unionArray[i].getDConst()));
break;
}
@@ -684,7 +678,6 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TType& returnType)
case EOpConvDoubleToInt:
newConstArray[i].setIConst(static_cast<int>(unionArray[i].getDConst())); break;
#ifndef GLSLANG_WEB
case EOpConvInt8ToBool:
newConstArray[i].setBConst(unionArray[i].getI8Const() != 0); break;
case EOpConvUint8ToBool:
@@ -696,7 +689,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TType& returnType)
case EOpConvInt64ToBool:
newConstArray[i].setBConst(unionArray[i].getI64Const() != 0); break;
case EOpConvUint64ToBool:
newConstArray[i].setBConst(unionArray[i].getI64Const() != 0); break;
newConstArray[i].setBConst(unionArray[i].getU64Const() != 0); break;
case EOpConvFloat16ToBool:
newConstArray[i].setBConst(unionArray[i].getDConst() != 0); break;
@@ -919,7 +912,6 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TType& returnType)
case EOpConvUint64ToPtr:
case EOpConstructReference:
newConstArray[i].setU64Const(unionArray[i].getU64Const()); break;
#endif
// TODO: 3.0 Functionality: unary constant folding: the rest of the ops have to be fleshed out
@@ -1066,7 +1058,6 @@ TIntermTyped* TIntermediate::fold(TIntermAggregate* aggrNode)
case EbtUint:
newConstArray[comp].setUConst(std::min(childConstUnions[0][arg0comp].getUConst(), childConstUnions[1][arg1comp].getUConst()));
break;
#ifndef GLSLANG_WEB
case EbtInt8:
newConstArray[comp].setI8Const(std::min(childConstUnions[0][arg0comp].getI8Const(), childConstUnions[1][arg1comp].getI8Const()));
break;
@@ -1085,7 +1076,6 @@ TIntermTyped* TIntermediate::fold(TIntermAggregate* aggrNode)
case EbtUint64:
newConstArray[comp].setU64Const(std::min(childConstUnions[0][arg0comp].getU64Const(), childConstUnions[1][arg1comp].getU64Const()));
break;
#endif
default: assert(false && "Default missing");
}
break;
@@ -1102,7 +1092,6 @@ TIntermTyped* TIntermediate::fold(TIntermAggregate* aggrNode)
case EbtUint:
newConstArray[comp].setUConst(std::max(childConstUnions[0][arg0comp].getUConst(), childConstUnions[1][arg1comp].getUConst()));
break;
#ifndef GLSLANG_WEB
case EbtInt8:
newConstArray[comp].setI8Const(std::max(childConstUnions[0][arg0comp].getI8Const(), childConstUnions[1][arg1comp].getI8Const()));
break;
@@ -1121,7 +1110,6 @@ TIntermTyped* TIntermediate::fold(TIntermAggregate* aggrNode)
case EbtUint64:
newConstArray[comp].setU64Const(std::max(childConstUnions[0][arg0comp].getU64Const(), childConstUnions[1][arg1comp].getU64Const()));
break;
#endif
default: assert(false && "Default missing");
}
break;
@@ -1137,7 +1125,6 @@ TIntermTyped* TIntermediate::fold(TIntermAggregate* aggrNode)
newConstArray[comp].setUConst(std::min(std::max(childConstUnions[0][arg0comp].getUConst(), childConstUnions[1][arg1comp].getUConst()),
childConstUnions[2][arg2comp].getUConst()));
break;
#ifndef GLSLANG_WEB
case EbtInt8:
newConstArray[comp].setI8Const(std::min(std::max(childConstUnions[0][arg0comp].getI8Const(), childConstUnions[1][arg1comp].getI8Const()),
childConstUnions[2][arg2comp].getI8Const()));
@@ -1166,7 +1153,6 @@ TIntermTyped* TIntermediate::fold(TIntermAggregate* aggrNode)
newConstArray[comp].setU64Const(std::min(std::max(childConstUnions[0][arg0comp].getU64Const(), childConstUnions[1][arg1comp].getU64Const()),
childConstUnions[2][arg2comp].getU64Const()));
break;
#endif
default: assert(false && "Default missing");
}
break;
@@ -1345,7 +1331,7 @@ TIntermTyped* TIntermediate::foldDereference(TIntermTyped* node, int index, cons
{
TType dereferencedType(node->getType(), index);
dereferencedType.getQualifier().storage = EvqConst;
TIntermTyped* result = 0;
TIntermTyped* result = nullptr;
int size = dereferencedType.computeNumComponents();
// arrays, vectors, matrices, all use simple multiplicative math
@@ -1365,7 +1351,7 @@ TIntermTyped* TIntermediate::foldDereference(TIntermTyped* node, int index, cons
result = addConstantUnion(TConstUnionArray(node->getAsConstantUnion()->getConstArray(), start, size), node->getType(), loc);
if (result == 0)
if (result == nullptr)
result = node;
else
result->setType(dereferencedType);
@@ -1387,7 +1373,7 @@ TIntermTyped* TIntermediate::foldSwizzle(TIntermTyped* node, TSwizzleSelectors<T
TIntermTyped* result = addConstantUnion(constArray, node->getType(), loc);
if (result == 0)
if (result == nullptr)
result = node;
else
result->setType(TType(node->getBasicType(), EvqConst, selectors.size()));
File diff suppressed because it is too large Load Diff
@@ -107,6 +107,9 @@ protected:
int dimMap[EsdNumDims];
};
// change this back to false if depending on textual spellings of texturing calls when consuming the AST
// Using PureOperatorBuiltins=false is deprecated.
constexpr bool PureOperatorBuiltins = true;
} // end namespace glslang
#endif // _INITIALIZE_INCLUDED_
@@ -352,7 +352,7 @@ TIntermTyped* TIntermediate::addIndex(TOperator op, TIntermTyped* base, TIntermT
TIntermTyped* TIntermediate::addUnaryMath(TOperator op, TIntermTyped* child,
const TSourceLoc& loc)
{
if (child == 0)
if (child == nullptr)
return nullptr;
if (child->getType().getBasicType() == EbtBlock)
@@ -388,7 +388,6 @@ TIntermTyped* TIntermediate::addUnaryMath(TOperator op, TIntermTyped* child,
case EOpConstructFloat: newType = EbtFloat; break;
case EOpConstructInt: newType = EbtInt; break;
case EOpConstructUint: newType = EbtUint; break;
#ifndef GLSLANG_WEB
case EOpConstructInt8: newType = EbtInt8; break;
case EOpConstructUint8: newType = EbtUint8; break;
case EOpConstructInt16: newType = EbtInt16; break;
@@ -397,7 +396,6 @@ TIntermTyped* TIntermediate::addUnaryMath(TOperator op, TIntermTyped* child,
case EOpConstructUint64: newType = EbtUint64; break;
case EOpConstructDouble: newType = EbtDouble; break;
case EOpConstructFloat16: newType = EbtFloat16; break;
#endif
default: break; // some compilers want this
}
@@ -569,7 +567,6 @@ bool TIntermediate::isConversionAllowed(TOperator op, TIntermTyped* node) const
bool TIntermediate::buildConvertOp(TBasicType dst, TBasicType src, TOperator& newOp) const
{
switch (dst) {
#ifndef GLSLANG_WEB
case EbtDouble:
switch (src) {
case EbtUint: newOp = EOpConvUintToDouble; break;
@@ -587,13 +584,11 @@ bool TIntermediate::buildConvertOp(TBasicType dst, TBasicType src, TOperator& ne
return false;
}
break;
#endif
case EbtFloat:
switch (src) {
case EbtInt: newOp = EOpConvIntToFloat; break;
case EbtUint: newOp = EOpConvUintToFloat; break;
case EbtBool: newOp = EOpConvBoolToFloat; break;
#ifndef GLSLANG_WEB
case EbtDouble: newOp = EOpConvDoubleToFloat; break;
case EbtInt8: newOp = EOpConvInt8ToFloat; break;
case EbtUint8: newOp = EOpConvUint8ToFloat; break;
@@ -602,12 +597,10 @@ bool TIntermediate::buildConvertOp(TBasicType dst, TBasicType src, TOperator& ne
case EbtFloat16: newOp = EOpConvFloat16ToFloat; break;
case EbtInt64: newOp = EOpConvInt64ToFloat; break;
case EbtUint64: newOp = EOpConvUint64ToFloat; break;
#endif
default:
return false;
}
break;
#ifndef GLSLANG_WEB
case EbtFloat16:
switch (src) {
case EbtInt8: newOp = EOpConvInt8ToFloat16; break;
@@ -625,13 +618,11 @@ bool TIntermediate::buildConvertOp(TBasicType dst, TBasicType src, TOperator& ne
return false;
}
break;
#endif
case EbtBool:
switch (src) {
case EbtInt: newOp = EOpConvIntToBool; break;
case EbtUint: newOp = EOpConvUintToBool; break;
case EbtFloat: newOp = EOpConvFloatToBool; break;
#ifndef GLSLANG_WEB
case EbtDouble: newOp = EOpConvDoubleToBool; break;
case EbtInt8: newOp = EOpConvInt8ToBool; break;
case EbtUint8: newOp = EOpConvUint8ToBool; break;
@@ -640,12 +631,10 @@ bool TIntermediate::buildConvertOp(TBasicType dst, TBasicType src, TOperator& ne
case EbtFloat16: newOp = EOpConvFloat16ToBool; break;
case EbtInt64: newOp = EOpConvInt64ToBool; break;
case EbtUint64: newOp = EOpConvUint64ToBool; break;
#endif
default:
return false;
}
break;
#ifndef GLSLANG_WEB
case EbtInt8:
switch (src) {
case EbtUint8: newOp = EOpConvUint8ToInt8; break;
@@ -715,14 +704,12 @@ bool TIntermediate::buildConvertOp(TBasicType dst, TBasicType src, TOperator& ne
return false;
}
break;
#endif
case EbtInt:
switch (src) {
case EbtUint: newOp = EOpConvUintToInt; break;
case EbtBool: newOp = EOpConvBoolToInt; break;
case EbtFloat: newOp = EOpConvFloatToInt; break;
#ifndef GLSLANG_WEB
case EbtInt8: newOp = EOpConvInt8ToInt; break;
case EbtUint8: newOp = EOpConvUint8ToInt; break;
case EbtInt16: newOp = EOpConvInt16ToInt; break;
@@ -731,7 +718,6 @@ bool TIntermediate::buildConvertOp(TBasicType dst, TBasicType src, TOperator& ne
case EbtFloat16: newOp = EOpConvFloat16ToInt; break;
case EbtInt64: newOp = EOpConvInt64ToInt; break;
case EbtUint64: newOp = EOpConvUint64ToInt; break;
#endif
default:
return false;
}
@@ -741,7 +727,6 @@ bool TIntermediate::buildConvertOp(TBasicType dst, TBasicType src, TOperator& ne
case EbtInt: newOp = EOpConvIntToUint; break;
case EbtBool: newOp = EOpConvBoolToUint; break;
case EbtFloat: newOp = EOpConvFloatToUint; break;
#ifndef GLSLANG_WEB
case EbtInt8: newOp = EOpConvInt8ToUint; break;
case EbtUint8: newOp = EOpConvUint8ToUint; break;
case EbtInt16: newOp = EOpConvInt16ToUint; break;
@@ -750,12 +735,15 @@ bool TIntermediate::buildConvertOp(TBasicType dst, TBasicType src, TOperator& ne
case EbtFloat16: newOp = EOpConvFloat16ToUint; break;
case EbtInt64: newOp = EOpConvInt64ToUint; break;
case EbtUint64: newOp = EOpConvUint64ToUint; break;
#endif
// For bindless texture type conversion, add a dummy convert op, just
// to generate a new TIntermTyped
// uvec2(any sampler type)
// uvec2(any image type)
case EbtSampler: newOp = EOpConvIntToUint; break;
default:
return false;
}
break;
#ifndef GLSLANG_WEB
case EbtInt64:
switch (src) {
case EbtInt8: newOp = EOpConvInt8ToInt64; break;
@@ -790,7 +778,6 @@ bool TIntermediate::buildConvertOp(TBasicType dst, TBasicType src, TOperator& ne
return false;
}
break;
#endif
default:
return false;
}
@@ -806,7 +793,6 @@ TIntermTyped* TIntermediate::createConversion(TBasicType convertTo, TIntermTyped
// Add a new newNode for the conversion.
//
#ifndef GLSLANG_WEB
bool convertToIntTypes = (convertTo == EbtInt8 || convertTo == EbtUint8 ||
convertTo == EbtInt16 || convertTo == EbtUint16 ||
convertTo == EbtInt || convertTo == EbtUint ||
@@ -843,7 +829,6 @@ TIntermTyped* TIntermediate::createConversion(TBasicType convertTo, TIntermTyped
return nullptr;
}
}
#endif
TIntermUnary* newNode = nullptr;
TOperator newOp = EOpNull;
@@ -855,13 +840,11 @@ TIntermTyped* TIntermediate::createConversion(TBasicType convertTo, TIntermTyped
newNode = addUnaryNode(newOp, node, node->getLoc(), newType);
if (node->getAsConstantUnion()) {
#ifndef GLSLANG_WEB
// 8/16-bit storage extensions don't support 8/16-bit constants, so don't fold conversions
// to those types
if ((getArithemeticInt8Enabled() || !(convertTo == EbtInt8 || convertTo == EbtUint8)) &&
(getArithemeticInt16Enabled() || !(convertTo == EbtInt16 || convertTo == EbtUint16)) &&
(getArithemeticFloat16Enabled() || !(convertTo == EbtFloat16)))
#endif
{
TIntermTyped* folded = node->getAsConstantUnion()->fold(newOp, newType);
if (folded)
@@ -1044,6 +1027,12 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
if (type.isArray() || node->getType().isArray())
return nullptr;
// Reject implicit conversions to cooperative matrix types
if (node->getType().isCoopMat() &&
op != EOpConstructCooperativeMatrixNV &&
op != EOpConstructCooperativeMatrixKHR)
return nullptr;
// Note: callers are responsible for other aspects of shape,
// like vector and matrix sizes.
@@ -1055,7 +1044,6 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
case EOpConstructFloat:
case EOpConstructInt:
case EOpConstructUint:
#ifndef GLSLANG_WEB
case EOpConstructDouble:
case EOpConstructFloat16:
case EOpConstructInt8:
@@ -1066,8 +1054,6 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
case EOpConstructUint64:
break;
#endif
//
// Implicit conversions
//
@@ -1112,7 +1098,8 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
case EOpSequence:
case EOpConstructStruct:
case EOpConstructCooperativeMatrix:
case EOpConstructCooperativeMatrixNV:
case EOpConstructCooperativeMatrixKHR:
if (type.isReference() || node->getType().isReference()) {
// types must match to assign a reference
@@ -1154,7 +1141,6 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
}
bool canPromoteConstant = true;
#ifndef GLSLANG_WEB
// GL_EXT_shader_16bit_storage can't do OpConstantComposite with
// 16-bit types, so disable promotion for those types.
// Many issues with this, from JohnK:
@@ -1182,7 +1168,6 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
default:
break;
}
#endif
if (canPromoteConstant && node->getAsConstantUnion())
return promoteConstantUnion(type.getBasicType(), node->getAsConstantUnion());
@@ -1479,10 +1464,6 @@ bool TIntermediate::isFPPromotion(TBasicType from, TBasicType to) const
bool TIntermediate::isIntegralConversion(TBasicType from, TBasicType to) const
{
#ifdef GLSLANG_WEB
return false;
#endif
switch (from) {
case EbtInt:
switch(to) {
@@ -1563,10 +1544,6 @@ bool TIntermediate::isIntegralConversion(TBasicType from, TBasicType to) const
bool TIntermediate::isFPConversion(TBasicType from, TBasicType to) const
{
#ifdef GLSLANG_WEB
return false;
#endif
if (to == EbtFloat && from == EbtFloat16) {
return true;
} else {
@@ -1587,7 +1564,6 @@ bool TIntermediate::isFPIntegralConversion(TBasicType from, TBasicType to) const
break;
}
break;
#ifndef GLSLANG_WEB
case EbtInt8:
case EbtUint8:
case EbtInt16:
@@ -1607,7 +1583,6 @@ bool TIntermediate::isFPIntegralConversion(TBasicType from, TBasicType to) const
return true;
}
break;
#endif
default:
break;
}
@@ -1809,10 +1784,6 @@ bool TIntermediate::canImplicitlyPromote(TBasicType from, TBasicType to, TOperat
static bool canSignedIntTypeRepresentAllUnsignedValues(TBasicType sintType, TBasicType uintType)
{
#ifdef GLSLANG_WEB
return false;
#endif
switch(sintType) {
case EbtInt8:
switch(uintType) {
@@ -1873,11 +1844,6 @@ static bool canSignedIntTypeRepresentAllUnsignedValues(TBasicType sintType, TBas
static TBasicType getCorrespondingUnsignedType(TBasicType type)
{
#ifdef GLSLANG_WEB
assert(type == EbtInt);
return EbtUint;
#endif
switch(type) {
case EbtInt8:
return EbtUint8;
@@ -2003,8 +1969,11 @@ TOperator TIntermediate::mapTypeToConstructorOp(const TType& type) const
if (type.getQualifier().isNonUniform())
return EOpConstructNonuniform;
if (type.isCoopMat())
return EOpConstructCooperativeMatrix;
if (type.isCoopMatNV())
return EOpConstructCooperativeMatrixNV;
if (type.isCoopMatKHR())
return EOpConstructCooperativeMatrixKHR;
switch (type.getBasicType()) {
case EbtStruct:
@@ -2167,7 +2136,6 @@ TOperator TIntermediate::mapTypeToConstructorOp(const TType& type) const
}
}
break;
#ifndef GLSLANG_WEB
case EbtDouble:
if (type.getMatrixCols()) {
switch (type.getMatrixCols()) {
@@ -2306,7 +2274,6 @@ TOperator TIntermediate::mapTypeToConstructorOp(const TType& type) const
case EbtAccStruct:
op = EOpConstructAccStruct;
break;
#endif
default:
break;
}
@@ -2350,6 +2317,40 @@ TIntermAggregate* TIntermediate::growAggregate(TIntermNode* left, TIntermNode* r
return aggNode;
}
TIntermAggregate* TIntermediate::mergeAggregate(TIntermNode* left, TIntermNode* right)
{
if (left == nullptr && right == nullptr)
return nullptr;
TIntermAggregate* aggNode = nullptr;
if (left != nullptr)
aggNode = left->getAsAggregate();
if (aggNode == nullptr || aggNode->getOp() != EOpNull) {
aggNode = new TIntermAggregate;
if (left != nullptr)
aggNode->getSequence().push_back(left);
}
TIntermAggregate* rhsagg = right->getAsAggregate();
if (rhsagg == nullptr || rhsagg->getOp() != EOpNull)
aggNode->getSequence().push_back(right);
else
aggNode->getSequence().insert(aggNode->getSequence().end(),
rhsagg->getSequence().begin(),
rhsagg->getSequence().end());
return aggNode;
}
TIntermAggregate* TIntermediate::mergeAggregate(TIntermNode* left, TIntermNode* right, const TSourceLoc& loc)
{
TIntermAggregate* aggNode = mergeAggregate(left, right);
if (aggNode)
aggNode->setLoc(loc);
return aggNode;
}
//
// Turn an existing node into an aggregate.
//
@@ -2623,6 +2624,18 @@ TIntermConstantUnion* TIntermediate::addConstantUnion(double d, TBasicType baseT
{
assert(baseType == EbtFloat || baseType == EbtDouble || baseType == EbtFloat16);
if (isEsProfile() && (baseType == EbtFloat || baseType == EbtFloat16)) {
int exponent = 0;
frexp(d, &exponent);
int minExp = baseType == EbtFloat ? -126 : -14;
int maxExp = baseType == EbtFloat ? 127 : 15;
if (exponent > maxExp) { //overflow, d = inf
d = std::numeric_limits<double>::infinity();
} else if (exponent < minExp) { //underflow, d = 0.0;
d = 0.0;
}
}
TConstUnionArray unionArray(1);
unionArray[0].setDConst(d);
@@ -2680,28 +2693,42 @@ TIntermTyped* TIntermediate::addSwizzle(TSwizzleSelectors<selectorType>& selecto
// 'swizzleOkay' says whether or not it is okay to consider a swizzle
// a valid part of the dereference chain.
//
// 'BufferReferenceOk' says if type is buffer_reference, the routine stop to find the most left node.
// 'bufferReferenceOk' says if type is buffer_reference, the routine will stop to find the most left node.
//
// 'proc' is an optional function to run on each node that is processed during the traversal. 'proc' must
// return true to continue the traversal, or false to end the traversal early.
//
const TIntermTyped* TIntermediate::findLValueBase(const TIntermTyped* node, bool swizzleOkay , bool bufferReferenceOk)
const TIntermTyped* TIntermediate::traverseLValueBase(const TIntermTyped* node, bool swizzleOkay,
bool bufferReferenceOk,
std::function<bool(const TIntermNode&)> proc)
{
do {
const TIntermBinary* binary = node->getAsBinaryNode();
if (binary == nullptr)
if (binary == nullptr) {
if (proc) {
proc(*node);
}
return node;
}
TOperator op = binary->getOp();
if (op != EOpIndexDirect && op != EOpIndexIndirect && op != EOpIndexDirectStruct && op != EOpVectorSwizzle && op != EOpMatrixSwizzle)
if (op != EOpIndexDirect && op != EOpIndexIndirect && op != EOpIndexDirectStruct && op != EOpVectorSwizzle &&
op != EOpMatrixSwizzle)
return nullptr;
if (! swizzleOkay) {
if (!swizzleOkay) {
if (op == EOpVectorSwizzle || op == EOpMatrixSwizzle)
return nullptr;
if ((op == EOpIndexDirect || op == EOpIndexIndirect) &&
(binary->getLeft()->getType().isVector() || binary->getLeft()->getType().isScalar()) &&
! binary->getLeft()->getType().isArray())
!binary->getLeft()->getType().isArray())
return nullptr;
}
node = node->getAsBinaryNode()->getLeft();
if (proc) {
if (!proc(*node)) {
return node;
}
}
node = binary->getLeft();
if (bufferReferenceOk && node->isReference())
return node;
} while (true);
@@ -2733,10 +2760,10 @@ TIntermAggregate* TIntermediate::addForLoop(TIntermNode* body, TIntermNode* init
TIntermAggregate* loopSequence = (initializer == nullptr ||
initializer->getAsAggregate() == nullptr) ? makeAggregate(initializer, loc)
: initializer->getAsAggregate();
if (loopSequence != nullptr && loopSequence->getOp() == EOpSequence)
if (loopSequence != nullptr && (loopSequence->getOp() == EOpSequence || loopSequence->getOp() == EOpScope))
loopSequence->setOp(EOpNull);
loopSequence = growAggregate(loopSequence, node);
loopSequence->setOperator(EOpSequence);
loopSequence->setOperator(getDebugInfo() ? EOpScope : EOpSequence);
return loopSequence;
}
@@ -2766,7 +2793,7 @@ void TIntermBranch::updatePrecision(TPrecisionQualifier parentPrecision)
return;
if (exp->getBasicType() == EbtInt || exp->getBasicType() == EbtUint ||
exp->getBasicType() == EbtFloat || exp->getBasicType() == EbtFloat16) {
exp->getBasicType() == EbtFloat) {
if (parentPrecision != EpqNone && exp->getQualifier().precision == EpqNone) {
exp->propagatePrecision(parentPrecision);
}
@@ -2787,7 +2814,6 @@ bool TIntermediate::postProcess(TIntermNode* root, EShLanguage /*language*/)
if (aggRoot && aggRoot->getOp() == EOpNull)
aggRoot->setOperator(EOpSequence);
#ifndef GLSLANG_WEB
// Propagate 'noContraction' label in backward from 'precise' variables.
glslang::PropagateNoContraction(*this);
@@ -2801,7 +2827,6 @@ bool TIntermediate::postProcess(TIntermNode* root, EShLanguage /*language*/)
assert(0);
break;
}
#endif
return true;
}
@@ -2830,10 +2855,9 @@ void TIntermediate::addSymbolLinkageNodes(TIntermAggregate*& linkage, EShLanguag
//}
if (language == EShLangVertex) {
// the names won't be found in the symbol table unless the versions are right,
// so version logic does not need to be repeated here
addSymbolLinkageNode(linkage, symbolTable, "gl_VertexID");
addSymbolLinkageNode(linkage, symbolTable, "gl_InstanceID");
if ((version < 140 && requestedExtensions.find(E_GL_EXT_draw_instanced) != requestedExtensions.end()) || version >= 140)
addSymbolLinkageNode(linkage, symbolTable, "gl_InstanceID");
}
// Add a child to the root node for the linker objects
@@ -3284,7 +3308,7 @@ bool TIntermediate::promoteUnary(TIntermUnary& node)
void TIntermUnary::updatePrecision()
{
if (getBasicType() == EbtInt || getBasicType() == EbtUint ||
getBasicType() == EbtFloat || getBasicType() == EbtFloat16) {
getBasicType() == EbtFloat) {
if (operand->getQualifier().precision > getQualifier().precision)
getQualifier().precision = operand->getQualifier().precision;
}
@@ -3521,20 +3545,28 @@ bool TIntermediate::promoteBinary(TIntermBinary& node)
}
if (left->getType().isCoopMat() || right->getType().isCoopMat()) {
// Operations on two cooperative matrices must have identical types
if (left->getType().isCoopMat() && right->getType().isCoopMat() &&
*left->getType().getTypeParameters() != *right->getType().getTypeParameters()) {
left->getType() != right->getType()) {
return false;
}
switch (op) {
case EOpMul:
case EOpMulAssign:
if (left->getType().isCoopMat() && right->getType().isCoopMat()) {
// Mul not supported in NV_cooperative_matrix
if (left->getType().isCoopMatNV() && right->getType().isCoopMatNV()) {
return false;
}
if (op == EOpMulAssign && right->getType().isCoopMat()) {
// NV_cooperative_matrix supports MulAssign is for mat*=scalar only.
// KHR_cooperative_matrix supports it for mat*=mat as well.
if (op == EOpMulAssign && right->getType().isCoopMatNV()) {
return false;
}
node.setOp(op == EOpMulAssign ? EOpMatrixTimesScalarAssign : EOpMatrixTimesScalar);
// Use MatrixTimesScalar if either operand is not a matrix. Otherwise use Mul.
if (!left->getType().isCoopMat() || !right->getType().isCoopMat()) {
node.setOp(op == EOpMulAssign ? EOpMatrixTimesScalarAssign : EOpMatrixTimesScalar);
}
// In case of scalar*matrix, take the result type from the matrix.
if (right->getType().isCoopMat()) {
node.setType(right->getType());
}
@@ -3785,7 +3817,7 @@ bool TIntermediate::promoteAggregate(TIntermAggregate& node)
void TIntermAggregate::updatePrecision()
{
if (getBasicType() == EbtInt || getBasicType() == EbtUint ||
getBasicType() == EbtFloat || getBasicType() == EbtFloat16) {
getBasicType() == EbtFloat) {
TPrecisionQualifier maxPrecision = EpqNone;
TIntermSequence operands = getSequence();
for (unsigned int i = 0; i < operands.size(); ++i) {
@@ -3807,7 +3839,7 @@ void TIntermAggregate::updatePrecision()
void TIntermBinary::updatePrecision()
{
if (getBasicType() == EbtInt || getBasicType() == EbtUint ||
getBasicType() == EbtFloat || getBasicType() == EbtFloat16) {
getBasicType() == EbtFloat) {
if (op == EOpRightShift || op == EOpLeftShift) {
// For shifts get precision from left side only and thus no need to propagate
getQualifier().precision = left->getQualifier().precision;
@@ -3887,16 +3919,6 @@ TIntermTyped* TIntermediate::promoteConstantUnion(TBasicType promoteTo, TIntermC
#define PROMOTE(Set, CType, Get) leftUnionArray[i].Set(static_cast<CType>(rightUnionArray[i].Get()))
#define PROMOTE_TO_BOOL(Get) leftUnionArray[i].setBConst(rightUnionArray[i].Get() != 0)
#ifdef GLSLANG_WEB
#define TO_ALL(Get) \
switch (promoteTo) { \
case EbtFloat: PROMOTE(setDConst, double, Get); break; \
case EbtInt: PROMOTE(setIConst, int, Get); break; \
case EbtUint: PROMOTE(setUConst, unsigned int, Get); break; \
case EbtBool: PROMOTE_TO_BOOL(Get); break; \
default: return node; \
}
#else
#define TO_ALL(Get) \
switch (promoteTo) { \
case EbtFloat16: PROMOTE(setDConst, double, Get); break; \
@@ -3913,14 +3935,12 @@ TIntermTyped* TIntermediate::promoteConstantUnion(TBasicType promoteTo, TIntermC
case EbtBool: PROMOTE_TO_BOOL(Get); break; \
default: return node; \
}
#endif
switch (node->getType().getBasicType()) {
case EbtFloat: TO_ALL(getDConst); break;
case EbtInt: TO_ALL(getIConst); break;
case EbtUint: TO_ALL(getUConst); break;
case EbtBool: TO_ALL(getBConst); break;
#ifndef GLSLANG_WEB
case EbtFloat16: TO_ALL(getDConst); break;
case EbtDouble: TO_ALL(getDConst); break;
case EbtInt8: TO_ALL(getI8Const); break;
@@ -3929,7 +3949,6 @@ TIntermTyped* TIntermediate::promoteConstantUnion(TBasicType promoteTo, TIntermC
case EbtUint8: TO_ALL(getU8Const); break;
case EbtUint16: TO_ALL(getU16Const); break;
case EbtUint64: TO_ALL(getU64Const); break;
#endif
default: return node;
}
}
@@ -67,13 +67,14 @@ void TParseContextBase::outputMessage(const TSourceLoc& loc, const char* szReaso
}
}
#if !defined(GLSLANG_WEB) || defined(GLSLANG_WEB_DEVEL)
void C_DECL TParseContextBase::error(const TSourceLoc& loc, const char* szReason, const char* szToken,
const char* szExtraInfoFormat, ...)
{
if (messages & EShMsgOnlyPreprocessor)
return;
// If enhanced msg readability, only print one error
if (messages & EShMsgEnhanced && numErrors > 0)
return;
va_list args;
va_start(args, szExtraInfoFormat);
outputMessage(loc, szReason, szToken, szExtraInfoFormat, EPrefixError, args);
@@ -115,8 +116,6 @@ void C_DECL TParseContextBase::ppWarn(const TSourceLoc& loc, const char* szReaso
va_end(args);
}
#endif
//
// Both test and if necessary, spit out an error, to see if the node is really
// an l-value that can be operated on this way.
@@ -137,7 +136,6 @@ bool TParseContextBase::lValueErrorCheck(const TSourceLoc& loc, const char* op,
case EvqConst: message = "can't modify a const"; break;
case EvqConstReadOnly: message = "can't modify a const"; break;
case EvqUniform: message = "can't modify a uniform"; break;
#ifndef GLSLANG_WEB
case EvqBuffer:
if (node->getQualifier().isReadOnly())
message = "can't modify a readonly buffer";
@@ -148,7 +146,6 @@ bool TParseContextBase::lValueErrorCheck(const TSourceLoc& loc, const char* op,
if (language != EShLangIntersect)
message = "cannot modify hitAttributeNV in this stage";
break;
#endif
default:
//
@@ -156,12 +153,12 @@ bool TParseContextBase::lValueErrorCheck(const TSourceLoc& loc, const char* op,
//
switch (node->getBasicType()) {
case EbtSampler:
message = "can't modify a sampler";
if (extensionTurnedOn(E_GL_ARB_bindless_texture) == false)
message = "can't modify a sampler";
break;
case EbtVoid:
message = "can't modify void";
break;
#ifndef GLSLANG_WEB
case EbtAtomicUint:
message = "can't modify an atomic_uint";
break;
@@ -171,7 +168,9 @@ bool TParseContextBase::lValueErrorCheck(const TSourceLoc& loc, const char* op,
case EbtRayQuery:
message = "can't modify rayQueryEXT";
break;
#endif
case EbtHitObjectNV:
message = "can't modify hitObjectNV";
break;
default:
break;
}
@@ -209,7 +208,7 @@ bool TParseContextBase::lValueErrorCheck(const TSourceLoc& loc, const char* op,
//
// If we get here, we have an error and a message.
//
const TIntermTyped* leftMostTypeNode = TIntermediate::findLValueBase(node, true);
const TIntermTyped* leftMostTypeNode = TIntermediate::traverseLValueBase(node, true);
if (symNode)
error(loc, " l-value required", op, "\"%s\" (%s)", symbol, message);
@@ -228,14 +227,14 @@ bool TParseContextBase::lValueErrorCheck(const TSourceLoc& loc, const char* op,
// Test for and give an error if the node can't be read from.
void TParseContextBase::rValueErrorCheck(const TSourceLoc& loc, const char* op, TIntermTyped* node)
{
TIntermBinary* binaryNode = node->getAsBinaryNode();
const TIntermSymbol* symNode = node->getAsSymbolNode();
if (! node)
return;
TIntermBinary* binaryNode = node->getAsBinaryNode();
const TIntermSymbol* symNode = node->getAsSymbolNode();
if (node->getQualifier().isWriteOnly()) {
const TIntermTyped* leftMostTypeNode = TIntermediate::findLValueBase(node, true);
const TIntermTyped* leftMostTypeNode = TIntermediate::traverseLValueBase(node, true);
if (symNode != nullptr)
error(loc, "can't read from writeonly object: ", op, symNode->getName().c_str());
@@ -627,10 +626,8 @@ void TParseContextBase::growGlobalUniformBlock(const TSourceLoc& loc, TType& mem
if (symbol) {
if (memberType != symbol->getType()) {
TString err;
err += "\"" + memberType.getCompleteString() + "\"";
err += " versus ";
err += "\"" + symbol->getType().getCompleteString() + "\"";
error(loc, "Types must match:", memberType.getFieldName().c_str(), err.c_str());
err += "Redeclaration: already declared as \"" + symbol->getType().getCompleteString() + "\"";
error(loc, "", memberName.c_str(), err.c_str());
}
return;
}
@@ -725,6 +722,24 @@ void TParseContextBase::finish()
if (parsingBuiltins)
return;
for (const TString& relaxedSymbol : relaxedSymbols)
{
TSymbol* symbol = symbolTable.find(relaxedSymbol);
TType& type = symbol->getWritableType();
for (const TTypeLoc& typeLoc : *type.getStruct())
{
if (typeLoc.type->isOpaque())
{
typeLoc.type->getSampler() = TSampler{};
typeLoc.type->setBasicType(EbtInt);
TString fieldName("/*");
fieldName.append(typeLoc.type->getFieldName());
fieldName.append("*/");
typeLoc.type->setFieldName(fieldName);
}
}
}
// Transfer the linkage symbols to AST nodes, preserving order.
TIntermAggregate* linkage = new TIntermAggregate;
for (auto i = linkageSymbols.begin(); i != linkageSymbols.end(); ++i)
File diff suppressed because it is too large Load Diff
@@ -95,12 +95,15 @@ public:
globalUniformSet(TQualifier::layoutSetEnd),
atomicCounterBlockSet(TQualifier::layoutSetEnd)
{
// use storage buffer on SPIR-V 1.3 and up
if (spvVersion.spv >= EShTargetSpv_1_3)
intermediate.setUseStorageBuffer();
if (entryPoint != nullptr)
sourceEntryPointName = *entryPoint;
}
virtual ~TParseContextBase() { }
#if !defined(GLSLANG_WEB) || defined(GLSLANG_WEB_DEVEL)
virtual void C_DECL error(const TSourceLoc&, const char* szReason, const char* szToken,
const char* szExtraInfoFormat, ...);
virtual void C_DECL warn(const TSourceLoc&, const char* szReason, const char* szToken,
@@ -109,7 +112,6 @@ public:
const char* szExtraInfoFormat, ...);
virtual void C_DECL ppWarn(const TSourceLoc&, const char* szReason, const char* szToken,
const char* szExtraInfoFormat, ...);
#endif
virtual void setLimits(const TBuiltInResource&) = 0;
@@ -178,6 +180,7 @@ public:
// Basic parsing state, easily accessible to the grammar
TSymbolTable& symbolTable; // symbol table that goes with the current language, version, and profile
TVector<TString> relaxedSymbols;
int statementNestingLevel; // 0 if outside all flow control or compound statements
int loopNestingLevel; // 0 if outside all loops
int structNestingLevel; // 0 if outside structures
@@ -194,6 +197,7 @@ public:
struct TPragma contextPragma;
int beginInvocationInterlockCount;
int endInvocationInterlockCount;
bool compileOnly = false;
protected:
TParseContextBase(TParseContextBase&);
@@ -327,10 +331,8 @@ public:
TIntermTyped* handleBracketDereference(const TSourceLoc&, TIntermTyped* base, TIntermTyped* index);
void handleIndexLimits(const TSourceLoc&, TIntermTyped* base, TIntermTyped* index);
#ifndef GLSLANG_WEB
void makeEditable(TSymbol*&) override;
void ioArrayCheck(const TSourceLoc&, const TType&, const TString& identifier);
#endif
bool isIoResizeArray(const TType&) const;
void fixIoArraySize(const TSourceLoc&, TType&);
void handleIoResizeArrayAccess(const TSourceLoc&, TIntermTyped* base);
@@ -366,6 +368,10 @@ public:
TIntermTyped* vkRelaxedRemapFunctionCall(const TSourceLoc&, TFunction*, TIntermNode*);
// returns true if the variable was remapped to something else
bool vkRelaxedRemapUniformVariable(const TSourceLoc&, TString&, const TPublicType&, TArraySizes*, TIntermTyped*, TType&);
void vkRelaxedRemapUniformMembers(const TSourceLoc&, const TPublicType&, const TType&, const TString&);
void vkRelaxedRemapFunctionParameter(TFunction*, TParameter&, std::vector<int>* newParams = nullptr);
TIntermNode* vkRelaxedRemapFunctionArgument(const TSourceLoc&, TFunction*, TIntermTyped*);
TIntermTyped* vkRelaxedRemapDotDereference(const TSourceLoc&, TIntermTyped&, const TType&, const TString&);
void assignError(const TSourceLoc&, const char* op, TString left, TString right);
void unaryOpError(const TSourceLoc&, const char* op, TString operand);
@@ -378,7 +384,7 @@ public:
void globalCheck(const TSourceLoc&, const char* token);
bool constructorError(const TSourceLoc&, TIntermNode*, TFunction&, TOperator, TType&);
bool constructorTextureSamplerError(const TSourceLoc&, const TFunction&);
void arraySizeCheck(const TSourceLoc&, TIntermTyped* expr, TArraySize&, const char *sizeType);
void arraySizeCheck(const TSourceLoc&, TIntermTyped* expr, TArraySize&, const char *sizeType, const bool allowZero = false);
bool arrayQualifierError(const TSourceLoc&, const TQualifier&);
bool arrayError(const TSourceLoc&, const TType&);
void arraySizeRequiredCheck(const TSourceLoc&, const TArraySizes&);
@@ -393,14 +399,14 @@ public:
void accStructCheck(const TSourceLoc & loc, const TType & type, const TString & identifier);
void transparentOpaqueCheck(const TSourceLoc&, const TType&, const TString& identifier);
void memberQualifierCheck(glslang::TPublicType&);
void globalQualifierFixCheck(const TSourceLoc&, TQualifier&, bool isMemberCheck = false);
void globalQualifierFixCheck(const TSourceLoc&, TQualifier&, bool isMemberCheck = false, const TPublicType* publicType = nullptr);
void globalQualifierTypeCheck(const TSourceLoc&, const TQualifier&, const TPublicType&);
bool structQualifierErrorCheck(const TSourceLoc&, const TPublicType& pType);
void mergeQualifiers(const TSourceLoc&, TQualifier& dst, const TQualifier& src, bool force);
void setDefaultPrecision(const TSourceLoc&, TPublicType&, TPrecisionQualifier);
int computeSamplerTypeIndex(TSampler&);
TPrecisionQualifier getDefaultPrecision(TPublicType&);
void precisionQualifierCheck(const TSourceLoc&, TBasicType, TQualifier&);
void precisionQualifierCheck(const TSourceLoc&, TBasicType, TQualifier&, bool isCoopMat);
void parameterTypeCheck(const TSourceLoc&, TStorageQualifier qualifier, const TType& type);
bool containsFieldWithBasicType(const TType& type ,TBasicType basicType);
TSymbol* redeclareBuiltinVariable(const TSourceLoc&, const TString&, const TQualifier&, const TShaderQualifiers&);
@@ -418,6 +424,7 @@ public:
void inductiveLoopCheck(const TSourceLoc&, TIntermNode* init, TIntermLoop* loop);
void arrayLimitCheck(const TSourceLoc&, const TString&, int size);
void limitCheck(const TSourceLoc&, int value, const char* limit, const char* feature);
void coopMatTypeParametersCheck(const TSourceLoc&, const TPublicType&);
void inductiveLoopBodyCheck(TIntermNode*, long long loopIndexId, TSymbolTable&);
void constantIndexExpressionCheck(TIntermNode*);
@@ -438,12 +445,12 @@ public:
const TFunction* findFunction400(const TSourceLoc& loc, const TFunction& call, bool& builtIn);
const TFunction* findFunctionExplicitTypes(const TSourceLoc& loc, const TFunction& call, bool& builtIn);
void declareTypeDefaults(const TSourceLoc&, const TPublicType&);
TIntermNode* declareVariable(const TSourceLoc&, TString& identifier, const TPublicType&, TArraySizes* typeArray = 0, TIntermTyped* initializer = 0);
TIntermNode* declareVariable(const TSourceLoc&, TString& identifier, const TPublicType&, TArraySizes* typeArray = nullptr, TIntermTyped* initializer = nullptr);
TIntermTyped* addConstructor(const TSourceLoc&, TIntermNode*, const TType&);
TIntermTyped* constructAggregate(TIntermNode*, const TType&, int, const TSourceLoc&);
TIntermTyped* constructBuiltIn(const TType&, TOperator, TIntermTyped*, const TSourceLoc&, bool subset);
void inheritMemoryQualifiers(const TQualifier& from, TQualifier& to);
void declareBlock(const TSourceLoc&, TTypeList& typeList, const TString* instanceName = 0, TArraySizes* arraySizes = 0);
void declareBlock(const TSourceLoc&, TTypeList& typeList, const TString* instanceName = nullptr, TArraySizes* arraySizes = nullptr);
void blockStorageRemap(const TSourceLoc&, const TString*, TQualifier&);
void blockStageIoCheck(const TSourceLoc&, const TQualifier&);
void blockQualifierCheck(const TSourceLoc&, const TQualifier&, bool instanceName);
@@ -456,11 +463,12 @@ public:
void addQualifierToExisting(const TSourceLoc&, TQualifier, TIdentifierList&);
void invariantCheck(const TSourceLoc&, const TQualifier&);
void updateStandaloneQualifierDefaults(const TSourceLoc&, const TPublicType&);
void updateBindlessQualifier(TType& memberType);
void wrapupSwitchSubsequence(TIntermAggregate* statements, TIntermNode* branchNode);
TIntermNode* addSwitch(const TSourceLoc&, TIntermTyped* expression, TIntermAggregate* body);
const TTypeList* recordStructCopy(TStructRecord&, const TType*, const TType*);
TLayoutFormat mapLegacyLayoutFormat(TLayoutFormat legacyLayoutFormat, TBasicType imageType);
#ifndef GLSLANG_WEB
TAttributeType attributeFromName(const TString& name) const;
TAttributes* makeAttributes(const TString& identifier) const;
TAttributes* makeAttributes(const TString& identifier, TIntermNode* node) const;
@@ -480,14 +488,13 @@ public:
TSpirvRequirement* mergeSpirvRequirements(const TSourceLoc& loc, TSpirvRequirement* spirvReq1,
TSpirvRequirement* spirvReq2);
TSpirvTypeParameters* makeSpirvTypeParameters(const TSourceLoc& loc, const TIntermConstantUnion* constant);
TSpirvTypeParameters* makeSpirvTypeParameters(const TSourceLoc& loc, const TPublicType& type);
TSpirvTypeParameters* mergeSpirvTypeParameters(TSpirvTypeParameters* spirvTypeParams1,
TSpirvTypeParameters* spirvTypeParams2);
TSpirvInstruction* makeSpirvInstruction(const TSourceLoc& loc, const TString& name, const TString& value);
TSpirvInstruction* makeSpirvInstruction(const TSourceLoc& loc, const TString& name, int value);
TSpirvInstruction* mergeSpirvInstruction(const TSourceLoc& loc, TSpirvInstruction* spirvInst1,
TSpirvInstruction* spirvInst2);
#endif
void checkAndResizeMeshViewDim(const TSourceLoc&, TType&, bool isBlockMember);
protected:
@@ -500,9 +507,7 @@ protected:
bool isRuntimeLength(const TIntermTyped&) const;
TIntermNode* executeInitializer(const TSourceLoc&, TIntermTyped* initializer, TVariable* variable);
TIntermTyped* convertInitializerList(const TSourceLoc&, const TType&, TIntermTyped* initializer);
#ifndef GLSLANG_WEB
void finish() override;
#endif
virtual const char* getGlobalUniformBlockName() const override;
virtual void finalizeGlobalUniformBlockLayout(TVariable&) override;
@@ -539,7 +544,6 @@ protected:
TQualifier globalOutputDefaults;
TQualifier globalSharedDefaults;
TString currentCaller; // name of last function body entered (not valid when at global scope)
#ifndef GLSLANG_WEB
int* atomicUintOffsets; // to become an array of the right size to hold an offset per binding point
bool anyIndexLimits;
TIdSetType inductiveLoopIds;
@@ -580,7 +584,6 @@ protected:
// array-sizing declarations
//
TVector<TSymbol*> ioArraySymbolResizeList;
#endif
};
} // end namespace glslang
@@ -35,34 +35,28 @@
#include "../Include/Common.h"
#include "../Include/PoolAlloc.h"
#include "../Include/InitializeGlobals.h"
#include "../OSDependent/osinclude.h"
namespace glslang {
// Process-wide TLS index
OS_TLSIndex PoolIndex;
namespace {
thread_local TPoolAllocator* threadPoolAllocator = nullptr;
TPoolAllocator* GetDefaultThreadPoolAllocator()
{
thread_local TPoolAllocator defaultAllocator;
return &defaultAllocator;
}
} // anonymous namespace
// Return the thread-specific current pool.
TPoolAllocator& GetThreadPoolAllocator()
{
return *static_cast<TPoolAllocator*>(OS_GetTLSValue(PoolIndex));
return *(threadPoolAllocator ? threadPoolAllocator : GetDefaultThreadPoolAllocator());
}
// Set the thread-specific current pool.
void SetThreadPoolAllocator(TPoolAllocator* poolAllocator)
{
OS_SetTLSValue(PoolIndex, poolAllocator);
}
// Process-wide set up of the TLS pool storage.
bool InitializePoolIndex()
{
// Allocate a TLS index.
if ((PoolIndex = OS_AllocTLSIndex()) == OS_INVALID_TLS_INDEX)
return false;
return true;
threadPoolAllocator = poolAllocator;
}
//
@@ -137,16 +131,6 @@ TPoolAllocator::~TPoolAllocator()
}
}
const unsigned char TAllocation::guardBlockBeginVal = 0xfb;
const unsigned char TAllocation::guardBlockEndVal = 0xfe;
const unsigned char TAllocation::userDataFill = 0xcd;
# ifdef GUARD_BLOCKS
const size_t TAllocation::guardBlockSize = 16;
# else
const size_t TAllocation::guardBlockSize = 0;
# endif
//
// Check a single guard block for damage
//
@@ -267,8 +251,8 @@ void* TPoolAllocator::allocate(size_t numBytes)
//
size_t numBytesToAlloc = allocationSize + headerSkip;
tHeader* memory = reinterpret_cast<tHeader*>(::new char[numBytesToAlloc]);
if (memory == 0)
return 0;
if (memory == nullptr)
return nullptr;
// Use placement-new to initialize header
new(memory) tHeader(inUseList, (numBytesToAlloc + pageSize - 1) / pageSize);
@@ -289,8 +273,8 @@ void* TPoolAllocator::allocate(size_t numBytes)
freeList = freeList->nextPage;
} else {
memory = reinterpret_cast<tHeader*>(::new char[pageSize]);
if (memory == 0)
return 0;
if (memory == nullptr)
return nullptr;
}
// Use placement-new to initialize header
@@ -308,7 +292,7 @@ void* TPoolAllocator::allocate(size_t numBytes)
//
void TAllocation::checkAllocList() const
{
for (const TAllocation* alloc = this; alloc != 0; alloc = alloc->prevAlloc)
for (const TAllocation* alloc = this; alloc != nullptr; alloc = alloc->prevAlloc)
alloc->check();
}
@@ -324,11 +324,9 @@ struct str_hash
// A single global usable by all threads, by all versions, by all languages.
// After a single process-level initialization, this is read only and thread safe
std::unordered_map<const char*, int, str_hash, str_eq>* KeywordMap = nullptr;
#ifndef GLSLANG_WEB
std::unordered_set<const char*, str_hash, str_eq>* ReservedSet = nullptr;
#endif
};
}
namespace glslang {
@@ -343,6 +341,7 @@ void TScanContext::fillInKeywordMap()
(*KeywordMap)["const"] = CONST;
(*KeywordMap)["uniform"] = UNIFORM;
(*KeywordMap)["tileImageEXT"] = TILEIMAGEEXT;
(*KeywordMap)["buffer"] = BUFFER;
(*KeywordMap)["in"] = IN;
(*KeywordMap)["out"] = OUT;
@@ -408,7 +407,6 @@ void TScanContext::fillInKeywordMap()
(*KeywordMap)["uvec3"] = UVEC3;
(*KeywordMap)["uvec4"] = UVEC4;
#ifndef GLSLANG_WEB
(*KeywordMap)["nonuniformEXT"] = NONUNIFORM;
(*KeywordMap)["demote"] = DEMOTE;
(*KeywordMap)["attribute"] = ATTRIBUTE;
@@ -598,7 +596,6 @@ void TScanContext::fillInKeywordMap()
(*KeywordMap)["spirv_storage_class"] = SPIRV_STORAGE_CLASS;
(*KeywordMap)["spirv_by_reference"] = SPIRV_BY_REFERENCE;
(*KeywordMap)["spirv_literal"] = SPIRV_LITERAL;
#endif
(*KeywordMap)["sampler2D"] = SAMPLER2D;
(*KeywordMap)["samplerCube"] = SAMPLERCUBE;
@@ -632,7 +629,6 @@ void TScanContext::fillInKeywordMap()
(*KeywordMap)["sampler"] = SAMPLER;
(*KeywordMap)["samplerShadow"] = SAMPLERSHADOW;
#ifndef GLSLANG_WEB
(*KeywordMap)["textureCubeArray"] = TEXTURECUBEARRAY;
(*KeywordMap)["itextureCubeArray"] = ITEXTURECUBEARRAY;
(*KeywordMap)["utextureCubeArray"] = UTEXTURECUBEARRAY;
@@ -685,6 +681,10 @@ void TScanContext::fillInKeywordMap()
(*KeywordMap)["texture2DRect"] = TEXTURE2DRECT;
(*KeywordMap)["texture1DArray"] = TEXTURE1DARRAY;
(*KeywordMap)["attachmentEXT"] = ATTACHMENTEXT;
(*KeywordMap)["iattachmentEXT"] = IATTACHMENTEXT;
(*KeywordMap)["uattachmentEXT"] = UATTACHMENTEXT;
(*KeywordMap)["subpassInput"] = SUBPASSINPUT;
(*KeywordMap)["subpassInputMS"] = SUBPASSINPUTMS;
(*KeywordMap)["isubpassInput"] = ISUBPASSINPUT;
@@ -739,6 +739,7 @@ void TScanContext::fillInKeywordMap()
(*KeywordMap)["f16subpassInputMS"] = F16SUBPASSINPUTMS;
(*KeywordMap)["__explicitInterpAMD"] = EXPLICITINTERPAMD;
(*KeywordMap)["pervertexNV"] = PERVERTEXNV;
(*KeywordMap)["pervertexEXT"] = PERVERTEXEXT;
(*KeywordMap)["precise"] = PRECISE;
(*KeywordMap)["rayPayloadNV"] = PAYLOADNV;
@@ -757,11 +758,18 @@ void TScanContext::fillInKeywordMap()
(*KeywordMap)["perprimitiveNV"] = PERPRIMITIVENV;
(*KeywordMap)["perviewNV"] = PERVIEWNV;
(*KeywordMap)["taskNV"] = PERTASKNV;
(*KeywordMap)["perprimitiveEXT"] = PERPRIMITIVEEXT;
(*KeywordMap)["taskPayloadSharedEXT"] = TASKPAYLOADWORKGROUPEXT;
(*KeywordMap)["fcoopmatNV"] = FCOOPMATNV;
(*KeywordMap)["icoopmatNV"] = ICOOPMATNV;
(*KeywordMap)["ucoopmatNV"] = UCOOPMATNV;
(*KeywordMap)["coopmat"] = COOPMAT;
(*KeywordMap)["hitObjectNV"] = HITOBJECTNV;
(*KeywordMap)["hitObjectAttributeNV"] = HITOBJECTATTRNV;
ReservedSet = new std::unordered_set<const char*, str_hash, str_eq>;
ReservedSet->insert("common");
@@ -801,17 +809,14 @@ void TScanContext::fillInKeywordMap()
ReservedSet->insert("cast");
ReservedSet->insert("namespace");
ReservedSet->insert("using");
#endif
}
void TScanContext::deleteKeywordMap()
{
delete KeywordMap;
KeywordMap = nullptr;
#ifndef GLSLANG_WEB
delete ReservedSet;
ReservedSet = nullptr;
#endif
}
// Called by yylex to get the next token.
@@ -892,14 +897,12 @@ int TScanContext::tokenize(TPpContext* pp, TParserToken& token)
case PpAtomConstInt: parserToken->sType.lex.i = ppToken.ival; return INTCONSTANT;
case PpAtomConstUint: parserToken->sType.lex.i = ppToken.ival; return UINTCONSTANT;
case PpAtomConstFloat: parserToken->sType.lex.d = ppToken.dval; return FLOATCONSTANT;
#ifndef GLSLANG_WEB
case PpAtomConstInt16: parserToken->sType.lex.i = ppToken.ival; return INT16CONSTANT;
case PpAtomConstUint16: parserToken->sType.lex.i = ppToken.ival; return UINT16CONSTANT;
case PpAtomConstInt64: parserToken->sType.lex.i64 = ppToken.i64val; return INT64CONSTANT;
case PpAtomConstUint64: parserToken->sType.lex.i64 = ppToken.i64val; return UINT64CONSTANT;
case PpAtomConstDouble: parserToken->sType.lex.d = ppToken.dval; return DOUBLECONSTANT;
case PpAtomConstFloat16: parserToken->sType.lex.d = ppToken.dval; return FLOAT16CONSTANT;
#endif
case PpAtomIdentifier:
{
int token = tokenizeIdentifier();
@@ -921,10 +924,8 @@ int TScanContext::tokenize(TPpContext* pp, TParserToken& token)
int TScanContext::tokenizeIdentifier()
{
#ifndef GLSLANG_WEB
if (ReservedSet->find(tokenText) != ReservedSet->end())
return reservedWord();
#endif
auto it = KeywordMap->find(tokenText);
if (it == KeywordMap->end()) {
@@ -936,6 +937,7 @@ int TScanContext::tokenizeIdentifier()
switch (keyword) {
case CONST:
case UNIFORM:
case TILEIMAGEEXT:
case IN:
case OUT:
case INOUT:
@@ -1046,7 +1048,6 @@ int TScanContext::tokenizeIdentifier()
return identifierOrReserved(reserved);
}
#ifndef GLSLANG_WEB
case NOPERSPECTIVE:
if (parseContext.extensionTurnedOn(E_GL_NV_shader_noperspective_interpolation))
return keyword;
@@ -1072,12 +1073,18 @@ int TScanContext::tokenizeIdentifier()
parseContext.extensionTurnedOn(E_GL_NV_ray_tracing))
return keyword;
return identifierOrType();
case ACCSTRUCTEXT:
if (parseContext.symbolTable.atBuiltInLevel() ||
parseContext.extensionTurnedOn(E_GL_EXT_ray_tracing) ||
parseContext.extensionTurnedOn(E_GL_EXT_ray_query) ||
parseContext.extensionTurnedOn(E_GL_NV_displacement_micromap))
return keyword;
return identifierOrType();
case PAYLOADEXT:
case PAYLOADINEXT:
case HITATTREXT:
case CALLDATAEXT:
case CALLDATAINEXT:
case ACCSTRUCTEXT:
if (parseContext.symbolTable.atBuiltInLevel() ||
parseContext.extensionTurnedOn(E_GL_EXT_ray_tracing) ||
parseContext.extensionTurnedOn(E_GL_EXT_ray_query))
@@ -1133,7 +1140,7 @@ int TScanContext::tokenizeIdentifier()
case SUBROUTINE:
return es30ReservedFromGLSL(400);
#endif
case SHARED:
if ((parseContext.isEsProfile() && parseContext.version < 300) ||
(!parseContext.isEsProfile() && parseContext.version < 140))
@@ -1168,7 +1175,6 @@ int TScanContext::tokenizeIdentifier()
case MAT4X4:
return matNxM();
#ifndef GLSLANG_WEB
case DMAT2:
case DMAT3:
case DMAT4:
@@ -1473,13 +1479,14 @@ int TScanContext::tokenizeIdentifier()
return keyword;
else
return identifierOrType();
#endif
case UINT:
case UVEC2:
case UVEC3:
case UVEC4:
case SAMPLERCUBESHADOW:
case SAMPLER2DARRAY:
case SAMPLER2DARRAYSHADOW:
case ISAMPLER2D:
case ISAMPLER3D:
case ISAMPLERCUBE:
@@ -1489,6 +1496,12 @@ int TScanContext::tokenizeIdentifier()
case USAMPLERCUBE:
case USAMPLER2DARRAY:
afterType = true;
if (keyword == SAMPLER2DARRAY || keyword == SAMPLER2DARRAYSHADOW) {
if ((keyword == SAMPLER2DARRAY || !parseContext.isEsProfile()) &&
(parseContext.extensionTurnedOn(E_GL_EXT_texture_array) || parseContext.symbolTable.atBuiltInLevel())) {
return keyword;
}
}
return nonreservedKeyword(300, 130);
case SAMPLER3D:
@@ -1526,12 +1539,18 @@ int TScanContext::tokenizeIdentifier()
else
return identifierOrType();
#ifndef GLSLANG_WEB
case ISAMPLER1D:
case ISAMPLER1DARRAY:
case SAMPLER1DARRAYSHADOW:
case USAMPLER1D:
case USAMPLER1DARRAY:
afterType = true;
if (keyword == SAMPLER1DARRAYSHADOW) {
if (!parseContext.isEsProfile() &&
(parseContext.extensionTurnedOn(E_GL_EXT_texture_array) || parseContext.symbolTable.atBuiltInLevel())) {
return keyword;
}
}
return es30ReservedFromGLSL(130);
case ISAMPLER2DRECT:
case USAMPLER2DRECT:
@@ -1583,19 +1602,6 @@ int TScanContext::tokenizeIdentifier()
reservedWord();
return keyword;
case SAMPLER2DARRAY:
case SAMPLER2DARRAYSHADOW:
afterType = true;
if (parseContext.symbolTable.atBuiltInLevel())
return keyword;
else if (parseContext.version < 130 && ((parseContext.isEsProfile() && keyword != SAMPLER2DARRAY) || !parseContext.extensionsTurnedOn(1, &E_GL_EXT_texture_array))) {
if (parseContext.forwardCompatible)
parseContext.warn(loc, "using future keyword", tokenText, "");
return identifierOrType();
}
return keyword;
case SAMPLER2DRECT:
case SAMPLER2DRECTSHADOW:
afterType = true;
@@ -1610,20 +1616,14 @@ int TScanContext::tokenizeIdentifier()
return keyword;
case SAMPLER1DARRAY:
case SAMPLER1DARRAYSHADOW:
afterType = true;
if (parseContext.symbolTable.atBuiltInLevel())
return keyword;
if (parseContext.isEsProfile()) {
if (parseContext.version >= 300)
reservedWord();
else
return identifierOrType();
} else if (parseContext.version < 130 && !parseContext.extensionsTurnedOn(1, &E_GL_EXT_texture_array)) {
if (parseContext.forwardCompatible)
parseContext.warn(loc, "using future keyword", tokenText, "");
return identifierOrType();
}
if (parseContext.isEsProfile() && parseContext.version == 300)
reservedWord();
else if ((parseContext.isEsProfile() && parseContext.version < 300) ||
((!parseContext.isEsProfile() && parseContext.version < 130) &&
!parseContext.symbolTable.atBuiltInLevel() &&
!parseContext.extensionTurnedOn(E_GL_EXT_texture_array)))
return identifierOrType();
return keyword;
case SAMPLEREXTERNALOES:
@@ -1670,6 +1670,9 @@ int TScanContext::tokenizeIdentifier()
case ISUBPASSINPUTMS:
case USUBPASSINPUT:
case USUBPASSINPUTMS:
case ATTACHMENTEXT:
case IATTACHMENTEXT:
case UATTACHMENTEXT:
if (parseContext.spvVersion.vulkan > 0)
return keyword;
else
@@ -1737,6 +1740,12 @@ int TScanContext::tokenizeIdentifier()
return keyword;
return identifierOrType();
case PERVERTEXEXT:
if ((!parseContext.isEsProfile() && parseContext.version >= 450) ||
parseContext.extensionTurnedOn(E_GL_EXT_fragment_shader_barycentric))
return keyword;
return identifierOrType();
case PRECISE:
if ((parseContext.isEsProfile() &&
(parseContext.version >= 320 || parseContext.extensionsTurnedOn(Num_AEP_gpu_shader5, AEP_gpu_shader5))) ||
@@ -1751,12 +1760,18 @@ int TScanContext::tokenizeIdentifier()
case PERPRIMITIVENV:
case PERVIEWNV:
case PERTASKNV:
if ((!parseContext.isEsProfile() && parseContext.version >= 450) ||
(parseContext.isEsProfile() && parseContext.version >= 320) ||
if (parseContext.symbolTable.atBuiltInLevel() ||
parseContext.extensionTurnedOn(E_GL_NV_mesh_shader))
return keyword;
return identifierOrType();
case PERPRIMITIVEEXT:
case TASKPAYLOADWORKGROUPEXT:
if (parseContext.symbolTable.atBuiltInLevel() ||
parseContext.extensionTurnedOn(E_GL_EXT_mesh_shader))
return keyword;
return identifierOrType();
case FCOOPMATNV:
afterType = true;
if (parseContext.symbolTable.atBuiltInLevel() ||
@@ -1772,6 +1787,13 @@ int TScanContext::tokenizeIdentifier()
return keyword;
return identifierOrType();
case COOPMAT:
afterType = true;
if (parseContext.symbolTable.atBuiltInLevel() ||
parseContext.extensionTurnedOn(E_GL_KHR_cooperative_matrix))
return keyword;
return identifierOrType();
case DEMOTE:
if (parseContext.extensionTurnedOn(E_GL_EXT_demote_to_helper_invocation))
return keyword;
@@ -1792,7 +1814,20 @@ int TScanContext::tokenizeIdentifier()
parseContext.extensionTurnedOn(E_GL_EXT_spirv_intrinsics))
return keyword;
return identifierOrType();
#endif
case HITOBJECTNV:
if (parseContext.symbolTable.atBuiltInLevel() ||
(!parseContext.isEsProfile() && parseContext.version >= 460
&& parseContext.extensionTurnedOn(E_GL_NV_shader_invocation_reorder)))
return keyword;
return identifierOrType();
case HITOBJECTATTRNV:
if (parseContext.symbolTable.atBuiltInLevel() ||
(!parseContext.isEsProfile() && parseContext.version >= 460
&& parseContext.extensionTurnedOn(E_GL_NV_shader_invocation_reorder)))
return keyword;
return identifierOrType();
default:
parseContext.infoSink.info.message(EPrefixInternalError, "Unknown glslang keyword", loc);
@@ -45,6 +45,7 @@
#include <iostream>
#include <sstream>
#include <memory>
#include <mutex>
#include "SymbolTable.h"
#include "ParseHelper.h"
#include "Scan.h"
@@ -57,7 +58,6 @@
#endif
#include "../Include/ShHandle.h"
#include "../../OGLCompilersDLL/InitializeDll.h"
#include "preprocessor/PpContext.h"
@@ -81,6 +81,9 @@ namespace { // anonymous namespace for file-local functions and symbols
// Shared global; access should be protected by a global mutex/critical section.
int NumberOfClients = 0;
// global initialization lock
std::mutex init_lock;
using namespace glslang;
// Create a language specific version of parseables.
@@ -295,14 +298,6 @@ void InitializeStageSymbolTable(TBuiltInParseables& builtInParseables, int versi
EShLanguage language, EShSource source, TInfoSink& infoSink, TSymbolTable** commonTable,
TSymbolTable** symbolTables)
{
#ifdef GLSLANG_WEB
profile = EEsProfile;
version = 310;
#elif defined(GLSLANG_ANGLE)
profile = ECoreProfile;
version = 450;
#endif
(*symbolTables[language]).adoptLevels(*commonTable[CommonIndex(profile, language)]);
InitializeSymbolTable(builtInParseables.getStageString(language), version, profile, spvVersion, language, source,
infoSink, *symbolTables[language]);
@@ -319,14 +314,6 @@ void InitializeStageSymbolTable(TBuiltInParseables& builtInParseables, int versi
//
bool InitializeSymbolTables(TInfoSink& infoSink, TSymbolTable** commonTable, TSymbolTable** symbolTables, int version, EProfile profile, const SpvVersion& spvVersion, EShSource source)
{
#ifdef GLSLANG_WEB
profile = EEsProfile;
version = 310;
#elif defined(GLSLANG_ANGLE)
profile = ECoreProfile;
version = 450;
#endif
std::unique_ptr<TBuiltInParseables> builtInParseables(CreateBuiltInParseables(infoSink, source));
if (builtInParseables == nullptr)
@@ -349,7 +336,6 @@ bool InitializeSymbolTables(TInfoSink& infoSink, TSymbolTable** commonTable, TS
InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangFragment, source,
infoSink, commonTable, symbolTables);
#ifndef GLSLANG_WEB
// check for tessellation
if ((profile != EEsProfile && version >= 150) ||
(profile == EEsProfile && version >= 310)) {
@@ -371,7 +357,6 @@ bool InitializeSymbolTables(TInfoSink& infoSink, TSymbolTable** commonTable, TS
InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangCompute, source,
infoSink, commonTable, symbolTables);
#ifndef GLSLANG_ANGLE
// check for ray tracing stages
if (profile != EEsProfile && version >= 450) {
InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangRayGen, source,
@@ -391,16 +376,14 @@ bool InitializeSymbolTables(TInfoSink& infoSink, TSymbolTable** commonTable, TS
// check for mesh
if ((profile != EEsProfile && version >= 450) ||
(profile == EEsProfile && version >= 320))
InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangMeshNV, source,
InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangMesh, source,
infoSink, commonTable, symbolTables);
// check for task
if ((profile != EEsProfile && version >= 450) ||
(profile == EEsProfile && version >= 320))
InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangTaskNV, source,
InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangTask, source,
infoSink, commonTable, symbolTables);
#endif // !GLSLANG_ANGLE
#endif // !GLSLANG_WEB
return true;
}
@@ -437,18 +420,15 @@ void SetupBuiltinSymbolTable(int version, EProfile profile, const SpvVersion& sp
TInfoSink infoSink;
// Make sure only one thread tries to do this at a time
glslang::GetGlobalLock();
const std::lock_guard<std::mutex> lock(init_lock);
// See if it's already been done for this version/profile combination
int versionIndex = MapVersionToIndex(version);
int spvVersionIndex = MapSpvVersionToIndex(spvVersion);
int profileIndex = MapProfileToIndex(profile);
int sourceIndex = MapSourceToIndex(source);
if (CommonSymbolTable[versionIndex][spvVersionIndex][profileIndex][sourceIndex][EPcGeneral]) {
glslang::ReleaseGlobalLock();
if (CommonSymbolTable[versionIndex][spvVersionIndex][profileIndex][sourceIndex][EPcGeneral])
return;
}
// Switch to a new pool
TPoolAllocator& previousAllocator = GetThreadPoolAllocator();
@@ -495,20 +475,16 @@ void SetupBuiltinSymbolTable(int version, EProfile profile, const SpvVersion& sp
delete builtInPoolAllocator;
SetThreadPoolAllocator(&previousAllocator);
glslang::ReleaseGlobalLock();
}
// Function to Print all builtins
void DumpBuiltinSymbolTable(TInfoSink& infoSink, const TSymbolTable& symbolTable)
{
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
infoSink.debug << "BuiltinSymbolTable {\n";
symbolTable.dump(infoSink, true);
infoSink.debug << "}\n";
#endif
}
// Return true if the shader was correctly specified for version/profile/stage.
@@ -606,7 +582,6 @@ bool DeduceVersionProfile(TInfoSink& infoSink, EShLanguage stage, bool versionNo
break;
}
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
// Correct for stage type...
switch (stage) {
case EShLangGeometry:
@@ -650,8 +625,8 @@ bool DeduceVersionProfile(TInfoSink& infoSink, EShLanguage stage, bool versionNo
version = 460;
}
break;
case EShLangMeshNV:
case EShLangTaskNV:
case EShLangMesh:
case EShLangTask:
if ((profile == EEsProfile && version < 320) ||
(profile != EEsProfile && version < 450)) {
correct = false;
@@ -694,7 +669,6 @@ bool DeduceVersionProfile(TInfoSink& infoSink, EShLanguage stage, bool versionNo
break;
}
}
#endif
return correct;
}
@@ -813,6 +787,7 @@ bool ProcessDeferred(
// set version/profile to defaultVersion/defaultProfile regardless of the #version
// directive in the source code
bool forceDefaultVersionAndProfile,
int overrideVersion, // overrides version specified by #verison or default version
bool forwardCompatible, // give errors for use of deprecated features
EShMessages messages, // warnings/errors/AST; things to print out
TIntermediate& intermediate, // returned tree, etc.
@@ -820,7 +795,8 @@ bool ProcessDeferred(
bool requireNonempty,
TShader::Includer& includer,
const std::string sourceEntryPointName = "",
const TEnvironment* environment = nullptr) // optional way of fully setting all versions, overriding the above
const TEnvironment* environment = nullptr, // optional way of fully setting all versions, overriding the above
bool compileOnly = false)
{
// This must be undone (.pop()) by the caller, after it finishes consuming the created tree.
GetThreadPoolAllocator().push();
@@ -883,7 +859,6 @@ bool ProcessDeferred(
: userInput.scanVersion(version, profile, versionNotFirstToken);
bool versionNotFound = version == 0;
if (forceDefaultVersionAndProfile && source == EShSourceGlsl) {
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
if (! (messages & EShMsgSuppressWarnings) && ! versionNotFound &&
(version != defaultVersion || profile != defaultProfile)) {
compiler->infoSink.info << "Warning, (version, profile) forced to be ("
@@ -891,7 +866,7 @@ bool ProcessDeferred(
<< "), while in source code it is ("
<< version << ", " << ProfileName(profile) << ")\n";
}
#endif
if (versionNotFound) {
versionNotFirstToken = false;
versionNotFirst = false;
@@ -900,19 +875,13 @@ bool ProcessDeferred(
version = defaultVersion;
profile = defaultProfile;
}
if (source == EShSourceGlsl && overrideVersion != 0) {
version = overrideVersion;
}
bool goodVersion = DeduceVersionProfile(compiler->infoSink, stage,
versionNotFirst, defaultVersion, source, version, profile, spvVersion);
#ifdef GLSLANG_WEB
profile = EEsProfile;
version = 310;
#elif defined(GLSLANG_ANGLE)
profile = ECoreProfile;
version = 450;
#endif
bool versionWillBeError = (versionNotFound || (profile == EEsProfile && version >= 300 && versionNotFirst));
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
bool warnVersionNotFirst = false;
if (! versionWillBeError && versionNotFirstToken) {
if (messages & EShMsgRelaxedErrors)
@@ -920,7 +889,6 @@ bool ProcessDeferred(
else
versionWillBeError = true;
}
#endif
intermediate.setSource(source);
intermediate.setVersion(version);
@@ -974,6 +942,7 @@ bool ProcessDeferred(
std::unique_ptr<TParseContextBase> parseContext(CreateParseContext(*symbolTable, intermediate, version, profile, source,
stage, compiler->infoSink,
spvVersion, forwardCompatible, messages, false, sourceEntryPointName));
parseContext->compileOnly = compileOnly;
TPpContext ppContext(*parseContext, names[numPre] ? names[numPre] : "", includer);
// only GLSL (bison triggered, really) needs an externally set scan context
@@ -985,13 +954,11 @@ bool ProcessDeferred(
parseContext->setLimits(*resources);
if (! goodVersion)
parseContext->addError();
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
if (warnVersionNotFirst) {
TSourceLoc loc;
loc.init();
parseContext->warn(loc, "Illegal to have non-comment, non-whitespace tokens before #version", "#version", "");
}
#endif
parseContext->initializeExtensionBehavior();
@@ -1023,8 +990,6 @@ bool ProcessDeferred(
return success;
}
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
// Responsible for keeping track of the most recent source string and line in
// the preprocessor and outputting newlines appropriately if the source string
// or line changes.
@@ -1102,8 +1067,8 @@ struct DoPreprocessing {
EShOptimizationLevel, EShMessages)
{
// This is a list of tokens that do not require a space before or after.
static const std::string unNeededSpaceTokens = ";()[]";
static const std::string noSpaceBeforeTokens = ",";
static const std::string noNeededSpaceBeforeTokens = ";)[].,";
static const std::string noNeededSpaceAfterTokens = ".([";
glslang::TPpToken ppToken;
parseContext.setScanner(&input);
@@ -1176,6 +1141,7 @@ struct DoPreprocessing {
});
int lastToken = EndOfInput; // lastToken records the last token processed.
std::string lastTokenName;
do {
int token = ppContext.tokenize(ppToken);
if (token == EndOfInput)
@@ -1194,12 +1160,23 @@ struct DoPreprocessing {
// Output a space in between tokens, but not at the start of a line,
// and also not around special tokens. This helps with readability
// and consistency.
if (!isNewString && !isNewLine && lastToken != EndOfInput &&
(unNeededSpaceTokens.find((char)token) == std::string::npos) &&
(unNeededSpaceTokens.find((char)lastToken) == std::string::npos) &&
(noSpaceBeforeTokens.find((char)token) == std::string::npos)) {
outputBuffer += ' ';
if (!isNewString && !isNewLine && lastToken != EndOfInput) {
// left parenthesis need a leading space, except it is in a function-call-like context.
// examples: `for (xxx)`, `a * (b + c)`, `vec(2.0)`, `foo(x, y, z)`
if (token == '(') {
if (lastToken != PpAtomIdentifier ||
lastTokenName == "if" ||
lastTokenName == "for" ||
lastTokenName == "while" ||
lastTokenName == "switch")
outputBuffer += ' ';
} else if ((noNeededSpaceBeforeTokens.find((char)token) == std::string::npos) &&
(noNeededSpaceAfterTokens.find((char)lastToken) == std::string::npos)) {
outputBuffer += ' ';
}
}
if (token == PpAtomIdentifier)
lastTokenName = ppToken.name;
lastToken = token;
if (token == PpAtomConstString)
outputBuffer += "\"";
@@ -1221,8 +1198,6 @@ struct DoPreprocessing {
std::string* outputString;
};
#endif
// DoFullParse is a valid ProcessingConext template argument for fully
// parsing the shader. It populates the "intermediate" with the AST.
struct DoFullParse{
@@ -1246,16 +1221,13 @@ struct DoFullParse{
parseContext.infoSink.info << parseContext.getNumErrors() << " compilation errors. No code generated.\n\n";
}
#ifndef GLSLANG_ANGLE
if (messages & EShMsgAST)
intermediate.output(parseContext.infoSink, true);
#endif
return success;
}
};
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
// Take a single compilation unit, and run the preprocessor on it.
// Return: True if there were no issues found in preprocessing,
// False if during preprocessing any unknown version, pragmas or
@@ -1275,6 +1247,7 @@ bool PreprocessDeferred(
int defaultVersion, // use 100 for ES environment, 110 for desktop
EProfile defaultProfile,
bool forceDefaultVersionAndProfile,
int overrideVersion, // use 0 if not overriding GLSL version
bool forwardCompatible, // give errors for use of deprecated features
EShMessages messages, // warnings/errors/AST; things to print out
TShader::Includer& includer,
@@ -1285,11 +1258,10 @@ bool PreprocessDeferred(
DoPreprocessing parser(outputString);
return ProcessDeferred(compiler, shaderStrings, numStrings, inputLengths, stringNames,
preamble, optLevel, resources, defaultVersion,
defaultProfile, forceDefaultVersionAndProfile,
defaultProfile, forceDefaultVersionAndProfile, overrideVersion,
forwardCompatible, messages, intermediate, parser,
false, includer, "", environment);
}
#endif
//
// do a partial compile on the given strings for a single compilation unit
@@ -1314,19 +1286,21 @@ bool CompileDeferred(
int defaultVersion, // use 100 for ES environment, 110 for desktop
EProfile defaultProfile,
bool forceDefaultVersionAndProfile,
int overrideVersion, // use 0 if not overriding GLSL version
bool forwardCompatible, // give errors for use of deprecated features
EShMessages messages, // warnings/errors/AST; things to print out
TIntermediate& intermediate,// returned tree, etc.
TShader::Includer& includer,
const std::string sourceEntryPointName = "",
TEnvironment* environment = nullptr)
TEnvironment* environment = nullptr,
bool compileOnly = false)
{
DoFullParse parser;
return ProcessDeferred(compiler, shaderStrings, numStrings, inputLengths, stringNames,
preamble, optLevel, resources, defaultVersion,
defaultProfile, forceDefaultVersionAndProfile,
defaultProfile, forceDefaultVersionAndProfile, overrideVersion,
forwardCompatible, messages, intermediate, parser,
true, includer, sourceEntryPointName, environment);
true, includer, sourceEntryPointName, environment, compileOnly);
}
} // end anonymous namespace for local functions
@@ -1336,12 +1310,7 @@ bool CompileDeferred(
//
int ShInitialize()
{
glslang::InitGlobalLock();
if (! InitProcess())
return 0;
glslang::GetGlobalLock();
const std::lock_guard<std::mutex> lock(init_lock);
++NumberOfClients;
if (PerProcessGPA == nullptr)
@@ -1352,7 +1321,6 @@ int ShInitialize()
glslang::HlslScanContext::fillInKeywordMap();
#endif
glslang::ReleaseGlobalLock();
return 1;
}
@@ -1361,31 +1329,22 @@ int ShInitialize()
// objects.
//
ShHandle ShConstructCompiler(const EShLanguage language, int debugOptions)
ShHandle ShConstructCompiler(const EShLanguage language, int /*debugOptions unused*/)
{
if (!InitThread())
return 0;
TShHandleBase* base = static_cast<TShHandleBase*>(ConstructCompiler(language, debugOptions));
TShHandleBase* base = static_cast<TShHandleBase*>(ConstructCompiler(language, 0));
return reinterpret_cast<void*>(base);
}
ShHandle ShConstructLinker(const EShExecutable executable, int debugOptions)
ShHandle ShConstructLinker(const EShExecutable executable, int /*debugOptions unused*/)
{
if (!InitThread())
return 0;
TShHandleBase* base = static_cast<TShHandleBase*>(ConstructLinker(executable, debugOptions));
TShHandleBase* base = static_cast<TShHandleBase*>(ConstructLinker(executable, 0));
return reinterpret_cast<void*>(base);
}
ShHandle ShConstructUniformMap()
{
if (!InitThread())
return 0;
TShHandleBase* base = static_cast<TShHandleBase*>(ConstructUniformMap());
return reinterpret_cast<void*>(base);
@@ -1393,7 +1352,7 @@ ShHandle ShConstructUniformMap()
void ShDestruct(ShHandle handle)
{
if (handle == 0)
if (handle == nullptr)
return;
TShHandleBase* base = static_cast<TShHandleBase*>(handle);
@@ -1411,14 +1370,11 @@ void ShDestruct(ShHandle handle)
//
int ShFinalize()
{
glslang::GetGlobalLock();
const std::lock_guard<std::mutex> lock(init_lock);
--NumberOfClients;
assert(NumberOfClients >= 0);
bool finalize = NumberOfClients == 0;
if (! finalize) {
glslang::ReleaseGlobalLock();
if (NumberOfClients > 0)
return 1;
}
for (int version = 0; version < VersionCount; ++version) {
for (int spvVersion = 0; spvVersion < SpvVersionCount; ++spvVersion) {
@@ -1426,7 +1382,7 @@ int ShFinalize()
for (int source = 0; source < SourceCount; ++source) {
for (int stage = 0; stage < EShLangCount; ++stage) {
delete SharedSymbolTables[version][spvVersion][p][source][stage];
SharedSymbolTables[version][spvVersion][p][source][stage] = 0;
SharedSymbolTables[version][spvVersion][p][source][stage] = nullptr;
}
}
}
@@ -1439,7 +1395,7 @@ int ShFinalize()
for (int source = 0; source < SourceCount; ++source) {
for (int pc = 0; pc < EPcCount; ++pc) {
delete CommonSymbolTable[version][spvVersion][p][source][pc];
CommonSymbolTable[version][spvVersion][p][source][pc] = 0;
CommonSymbolTable[version][spvVersion][p][source][pc] = nullptr;
}
}
}
@@ -1456,7 +1412,6 @@ int ShFinalize()
glslang::HlslScanContext::deleteKeywordMap();
#endif
glslang::ReleaseGlobalLock();
return 1;
}
@@ -1482,12 +1437,12 @@ int ShCompile(
)
{
// Map the generic handle to the C++ object
if (handle == 0)
if (handle == nullptr)
return 0;
TShHandleBase* base = reinterpret_cast<TShHandleBase*>(handle);
TCompiler* compiler = base->getAsCompiler();
if (compiler == 0)
if (compiler == nullptr)
return 0;
SetThreadPoolAllocator(compiler->getPool());
@@ -1498,7 +1453,7 @@ int ShCompile(
TIntermediate intermediate(compiler->getLanguage());
TShader::ForbidIncluder includer;
bool success = CompileDeferred(compiler, shaderStrings, numStrings, inputLengths, nullptr,
"", optLevel, resources, defaultVersion, ENoProfile, false,
"", optLevel, resources, defaultVersion, ENoProfile, false, 0,
forwardCompatible, messages, intermediate, includer);
//
@@ -1527,13 +1482,13 @@ int ShLinkExt(
const ShHandle compHandles[],
const int numHandles)
{
if (linkHandle == 0 || numHandles == 0)
if (linkHandle == nullptr || numHandles == 0)
return 0;
THandleList cObjects;
for (int i = 0; i < numHandles; ++i) {
if (compHandles[i] == 0)
if (compHandles[i] == nullptr)
return 0;
TShHandleBase* base = reinterpret_cast<TShHandleBase*>(compHandles[i]);
if (base->getAsLinker()) {
@@ -1542,18 +1497,17 @@ int ShLinkExt(
if (base->getAsCompiler())
cObjects.push_back(base->getAsCompiler());
if (cObjects[i] == 0)
if (cObjects[i] == nullptr)
return 0;
}
TShHandleBase* base = reinterpret_cast<TShHandleBase*>(linkHandle);
TLinker* linker = static_cast<TLinker*>(base->getAsLinker());
SetThreadPoolAllocator(linker->getPool());
if (linker == 0)
if (linker == nullptr)
return 0;
SetThreadPoolAllocator(linker->getPool());
linker->infoSink.info.erase();
for (int i = 0; i < numHandles; ++i) {
@@ -1576,7 +1530,7 @@ int ShLinkExt(
//
void ShSetEncryptionMethod(ShHandle handle)
{
if (handle == 0)
if (handle == nullptr)
return;
}
@@ -1585,8 +1539,8 @@ void ShSetEncryptionMethod(ShHandle handle)
//
const char* ShGetInfoLog(const ShHandle handle)
{
if (handle == 0)
return 0;
if (handle == nullptr)
return nullptr;
TShHandleBase* base = static_cast<TShHandleBase*>(handle);
TInfoSink* infoSink;
@@ -1596,7 +1550,7 @@ const char* ShGetInfoLog(const ShHandle handle)
else if (base->getAsLinker())
infoSink = &(base->getAsLinker()->getInfoSink());
else
return 0;
return nullptr;
infoSink->info << infoSink->debug.c_str();
return infoSink->info.c_str();
@@ -1608,14 +1562,14 @@ const char* ShGetInfoLog(const ShHandle handle)
//
const void* ShGetExecutable(const ShHandle handle)
{
if (handle == 0)
return 0;
if (handle == nullptr)
return nullptr;
TShHandleBase* base = reinterpret_cast<TShHandleBase*>(handle);
TLinker* linker = static_cast<TLinker*>(base->getAsLinker());
if (linker == 0)
return 0;
if (linker == nullptr)
return nullptr;
return linker->getObjectCode();
}
@@ -1630,13 +1584,13 @@ const void* ShGetExecutable(const ShHandle handle)
//
int ShSetVirtualAttributeBindings(const ShHandle handle, const ShBindingTable* table)
{
if (handle == 0)
if (handle == nullptr)
return 0;
TShHandleBase* base = reinterpret_cast<TShHandleBase*>(handle);
TLinker* linker = static_cast<TLinker*>(base->getAsLinker());
if (linker == 0)
if (linker == nullptr)
return 0;
linker->setAppAttributeBindings(table);
@@ -1649,13 +1603,13 @@ int ShSetVirtualAttributeBindings(const ShHandle handle, const ShBindingTable* t
//
int ShSetFixedAttributeBindings(const ShHandle handle, const ShBindingTable* table)
{
if (handle == 0)
if (handle == nullptr)
return 0;
TShHandleBase* base = reinterpret_cast<TShHandleBase*>(handle);
TLinker* linker = static_cast<TLinker*>(base->getAsLinker());
if (linker == 0)
if (linker == nullptr)
return 0;
linker->setFixedAttributeBindings(table);
@@ -1667,12 +1621,12 @@ int ShSetFixedAttributeBindings(const ShHandle handle, const ShBindingTable* tab
//
int ShExcludeAttributes(const ShHandle handle, int *attributes, int count)
{
if (handle == 0)
if (handle == nullptr)
return 0;
TShHandleBase* base = reinterpret_cast<TShHandleBase*>(handle);
TLinker* linker = static_cast<TLinker*>(base->getAsLinker());
if (linker == 0)
if (linker == nullptr)
return 0;
linker->setExcludedAttributes(attributes, count);
@@ -1688,12 +1642,12 @@ int ShExcludeAttributes(const ShHandle handle, int *attributes, int count)
//
int ShGetUniformLocation(const ShHandle handle, const char* name)
{
if (handle == 0)
if (handle == nullptr)
return -1;
TShHandleBase* base = reinterpret_cast<TShHandleBase*>(handle);
TUniformMap* uniformMap= base->getAsUniformMap();
if (uniformMap == 0)
if (uniformMap == nullptr)
return -1;
return uniformMap->getLocation(name);
@@ -1759,7 +1713,7 @@ public:
};
TShader::TShader(EShLanguage s)
: stage(s), lengths(nullptr), stringNames(nullptr), preamble("")
: stage(s), lengths(nullptr), stringNames(nullptr), preamble(""), overrideVersion(0)
{
pool = new TPoolAllocator;
infoSink = new TInfoSink;
@@ -1828,12 +1782,17 @@ void TShader::setUniqueId(unsigned long long id)
intermediate->setUniqueId(id);
}
void TShader::setOverrideVersion(int version)
{
overrideVersion = version;
}
void TShader::setDebugInfo(bool debugInfo) { intermediate->setDebugInfo(debugInfo); }
void TShader::setInvertY(bool invert) { intermediate->setInvertY(invert); }
void TShader::setDxPositionW(bool invert) { intermediate->setDxPositionW(invert); }
void TShader::setEnhancedMsgs() { intermediate->setEnhancedMsgs(); }
void TShader::setNanMinMaxClamp(bool useNonNan) { intermediate->setNanMinMaxClamp(useNonNan); }
#ifndef GLSLANG_WEB
// Set binding base for given resource type
void TShader::setShiftBinding(TResourceType res, unsigned int base) {
intermediate->setShiftBinding(res, base);
@@ -1875,7 +1834,6 @@ void TShader::setUniformLocationBase(int base)
void TShader::setNoStorageFormat(bool useUnknownFormat) { intermediate->setNoStorageFormat(useUnknownFormat); }
void TShader::setResourceSetBinding(const std::vector<std::string>& base) { intermediate->setResourceSetBinding(base); }
void TShader::setTextureSamplerTransformMode(EShTextureSamplerTransformMode mode) { intermediate->setTextureSamplerTransformMode(mode); }
#endif
void TShader::addBlockStorageOverride(const char* nameStr, TBlockStorageClass backing) { intermediate->addBlockStorageOverride(nameStr, backing); }
@@ -1900,8 +1858,6 @@ void TShader::setFlattenUniformArrays(bool flatten) { intermediate->setFlatt
bool TShader::parse(const TBuiltInResource* builtInResources, int defaultVersion, EProfile defaultProfile, bool forceDefaultVersionAndProfile,
bool forwardCompatible, EShMessages messages, Includer& includer)
{
if (! InitThread())
return false;
SetThreadPoolAllocator(pool);
if (! preamble)
@@ -1909,12 +1865,11 @@ bool TShader::parse(const TBuiltInResource* builtInResources, int defaultVersion
return CompileDeferred(compiler, strings, numStrings, lengths, stringNames,
preamble, EShOptNone, builtInResources, defaultVersion,
defaultProfile, forceDefaultVersionAndProfile,
defaultProfile, forceDefaultVersionAndProfile, overrideVersion,
forwardCompatible, messages, *intermediate, includer, sourceEntryPointName,
&environment);
&environment, compileOnly);
}
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
// Fill in a string with the result of preprocessing ShaderStrings
// Returns true if all extensions, pragmas and version strings were valid.
//
@@ -1927,8 +1882,6 @@ bool TShader::preprocess(const TBuiltInResource* builtInResources,
std::string* output_string,
Includer& includer)
{
if (! InitThread())
return false;
SetThreadPoolAllocator(pool);
if (! preamble)
@@ -1936,11 +1889,10 @@ bool TShader::preprocess(const TBuiltInResource* builtInResources,
return PreprocessDeferred(compiler, strings, numStrings, lengths, stringNames, preamble,
EShOptNone, builtInResources, defaultVersion,
defaultProfile, forceDefaultVersionAndProfile,
defaultProfile, forceDefaultVersionAndProfile, overrideVersion,
forwardCompatible, message, includer, *intermediate, output_string,
&environment);
}
#endif
const char* TShader::getInfoLog()
{
@@ -1952,16 +1904,12 @@ const char* TShader::getInfoDebugLog()
return infoSink->debug.c_str();
}
TProgram::TProgram() :
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
reflection(0),
#endif
linked(false)
TProgram::TProgram() : reflection(nullptr), linked(false)
{
pool = new TPoolAllocator;
infoSink = new TInfoSink;
for (int s = 0; s < EShLangCount; ++s) {
intermediate[s] = 0;
intermediate[s] = nullptr;
newedIntermediate[s] = false;
}
}
@@ -1969,9 +1917,7 @@ TProgram::TProgram() :
TProgram::~TProgram()
{
delete infoSink;
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
delete reflection;
#endif
for (int s = 0; s < EShLangCount; ++s)
if (newedIntermediate[s])
@@ -2019,7 +1965,6 @@ bool TProgram::linkStage(EShLanguage stage, EShMessages messages)
if (stages[stage].size() == 0)
return true;
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
int numEsShaders = 0, numNonEsShaders = 0;
for (auto it = stages[stage].begin(); it != stages[stage].end(); ++it) {
if ((*it)->intermediate->getProfile() == EEsProfile) {
@@ -2049,6 +1994,8 @@ bool TProgram::linkStage(EShLanguage stage, EShMessages messages)
firstIntermediate->getVersion(),
firstIntermediate->getProfile());
intermediate[stage]->setLimits(firstIntermediate->getLimits());
if (firstIntermediate->getEnhancedMsgs())
intermediate[stage]->setEnhancedMsgs();
// The new TIntermediate must use the same origin as the original TIntermediates.
// Otherwise linking will fail due to different coordinate systems.
@@ -2068,15 +2015,10 @@ bool TProgram::linkStage(EShLanguage stage, EShMessages messages)
for (it = stages[stage].begin(); it != stages[stage].end(); ++it)
intermediate[stage]->merge(*infoSink, *(*it)->intermediate);
}
#else
intermediate[stage] = stages[stage].front()->intermediate;
#endif
intermediate[stage]->finalCheck(*infoSink, (messages & EShMsgKeepUncalled) != 0);
#ifndef GLSLANG_ANGLE
if (messages & EShMsgAST)
intermediate[stage]->output(*infoSink, true);
#endif
return intermediate[stage]->getNumErrors() == 0;
}
@@ -2154,8 +2096,6 @@ const char* TProgram::getInfoDebugLog()
return infoSink->debug.c_str();
}
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
//
// Reflection implementation.
//
@@ -2236,6 +2176,4 @@ bool TProgram::mapIO(TIoMapResolver* pResolver, TIoMapper* pIoMapper)
return ioMapper->doMap(pResolver, *infoSink);
}
#endif // !GLSLANG_WEB && !GLSLANG_ANGLE
} // end namespace glslang
@@ -33,8 +33,6 @@
// POSSIBILITY OF SUCH DAMAGE.
//
#ifndef GLSLANG_WEB
//
// GL_EXT_spirv_intrinsics
//
@@ -45,6 +43,15 @@
namespace glslang {
bool TSpirvTypeParameter::operator==(const TSpirvTypeParameter& rhs) const
{
if (getAsConstant() != nullptr)
return getAsConstant()->getConstArray() == rhs.getAsConstant()->getConstArray();
assert(getAsType() != nullptr);
return *getAsType() == *rhs.getAsType();
}
//
// Handle SPIR-V requirements
//
@@ -67,7 +74,7 @@ TSpirvRequirement* TParseContext::makeSpirvRequirement(const TSourceLoc& loc, co
spirvReq->capabilities.insert(capability->getAsConstantUnion()->getConstArray()[0].getIConst());
}
} else
error(loc, "unknow SPIR-V requirement", name.c_str(), "");
error(loc, "unknown SPIR-V requirement", name.c_str(), "");
return spirvReq;
}
@@ -168,7 +175,7 @@ void TQualifier::setSpirvDecorateId(int decoration, const TIntermAggregate* args
TVector<const TIntermTyped*> extraOperands;
for (auto arg : args->getSequence()) {
auto extraOperand = arg->getAsTyped();
assert(extraOperand != nullptr && extraOperand->getQualifier().isConstant());
assert(extraOperand != nullptr);
extraOperands.push_back(extraOperand);
}
spirvDecorate->decorateIds[decoration] = extraOperands;
@@ -202,30 +209,29 @@ TString TQualifier::getSpirvDecorateQualifierString() const
const auto appendStr = [&](const char* s) { qualifierString.append(s); };
const auto appendDecorate = [&](const TIntermTyped* constant) {
auto& constArray = constant->getAsConstantUnion() != nullptr ? constant->getAsConstantUnion()->getConstArray()
: constant->getAsSymbolNode()->getConstArray();
if (constant->getBasicType() == EbtFloat) {
float value = static_cast<float>(constArray[0].getDConst());
appendFloat(value);
if (constant->getAsConstantUnion()) {
auto& constArray = constant->getAsConstantUnion()->getConstArray();
if (constant->getBasicType() == EbtFloat) {
float value = static_cast<float>(constArray[0].getDConst());
appendFloat(value);
} else if (constant->getBasicType() == EbtInt) {
int value = constArray[0].getIConst();
appendInt(value);
} else if (constant->getBasicType() == EbtUint) {
unsigned value = constArray[0].getUConst();
appendUint(value);
} else if (constant->getBasicType() == EbtBool) {
bool value = constArray[0].getBConst();
appendBool(value);
} else if (constant->getBasicType() == EbtString) {
const TString* value = constArray[0].getSConst();
appendStr(value->c_str());
} else
assert(0);
} else {
assert(constant->getAsSymbolNode());
appendStr(constant->getAsSymbolNode()->getName().c_str());
}
else if (constant->getBasicType() == EbtInt) {
int value = constArray[0].getIConst();
appendInt(value);
}
else if (constant->getBasicType() == EbtUint) {
unsigned value = constArray[0].getUConst();
appendUint(value);
}
else if (constant->getBasicType() == EbtBool) {
bool value = constArray[0].getBConst();
appendBool(value);
}
else if (constant->getBasicType() == EbtString) {
const TString* value = constArray[0].getSConst();
appendStr(value->c_str());
}
else
assert(0);
};
for (auto& decorate : spirvDecorate->decorates) {
@@ -284,14 +290,20 @@ TSpirvTypeParameters* TParseContext::makeSpirvTypeParameters(const TSourceLoc& l
constant->getBasicType() != EbtBool &&
constant->getBasicType() != EbtString)
error(loc, "this type not allowed", constant->getType().getBasicString(), "");
else {
assert(constant);
else
spirvTypeParams->push_back(TSpirvTypeParameter(constant));
}
return spirvTypeParams;
}
TSpirvTypeParameters* TParseContext::makeSpirvTypeParameters(const TSourceLoc& /* loc */,
const TPublicType& type)
{
TSpirvTypeParameters* spirvTypeParams = new TSpirvTypeParameters;
spirvTypeParams->push_back(TSpirvTypeParameter(new TType(type)));
return spirvTypeParams;
}
TSpirvTypeParameters* TParseContext::mergeSpirvTypeParameters(TSpirvTypeParameters* spirvTypeParams1, TSpirvTypeParameters* spirvTypeParams2)
{
// Merge SPIR-V type parameters of the second one to the first one
@@ -346,5 +358,3 @@ TSpirvInstruction* TParseContext::mergeSpirvInstruction(const TSourceLoc& loc, T
}
} // end namespace glslang
#endif // GLSLANG_WEB
@@ -65,7 +65,6 @@ void TType::buildMangledName(TString& mangledName) const
case EbtInt: mangledName += 'i'; break;
case EbtUint: mangledName += 'u'; break;
case EbtBool: mangledName += 'b'; break;
#ifndef GLSLANG_WEB
case EbtDouble: mangledName += 'd'; break;
case EbtFloat16: mangledName += "f16"; break;
case EbtInt8: mangledName += "i8"; break;
@@ -78,12 +77,10 @@ void TType::buildMangledName(TString& mangledName) const
case EbtAccStruct: mangledName += "as"; break;
case EbtRayQuery: mangledName += "rq"; break;
case EbtSpirvType: mangledName += "spv-t"; break;
#endif
case EbtHitObjectNV: mangledName += "ho"; break;
case EbtSampler:
switch (sampler.type) {
#ifndef GLSLANG_WEB
case EbtFloat16: mangledName += "f16"; break;
#endif
case EbtInt: mangledName += "i"; break;
case EbtUint: mangledName += "u"; break;
case EbtInt64: mangledName += "i64"; break;
@@ -110,12 +107,10 @@ void TType::buildMangledName(TString& mangledName) const
case Esd2D: mangledName += "2"; break;
case Esd3D: mangledName += "3"; break;
case EsdCube: mangledName += "C"; break;
#ifndef GLSLANG_WEB
case Esd1D: mangledName += "1"; break;
case EsdRect: mangledName += "R2"; break;
case EsdBuffer: mangledName += "B"; break;
case EsdSubpass: mangledName += "P"; break;
#endif
default: break; // some compilers want this
}
@@ -183,8 +178,6 @@ void TType::buildMangledName(TString& mangledName) const
}
}
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
//
// Dump functions.
//
@@ -263,8 +256,6 @@ void TSymbolTable::dump(TInfoSink& infoSink, bool complete) const
}
}
#endif
//
// Functions have buried pointers to delete.
//
@@ -327,6 +318,16 @@ void TSymbolTableLevel::setFunctionExtensions(const char* name, int num, const c
}
}
// Make a single function require an extension(s). i.e., this will only set the extensions for the symbol that matches 'name' exactly.
// This is different from setFunctionExtensions, which uses std::map::lower_bound to effectively set all symbols that start with 'name'.
// Should only be used for a version/profile that actually needs the extension(s).
void TSymbolTableLevel::setSingleFunctionExtensions(const char* name, int num, const char* const extensions[])
{
if (auto candidate = level.find(name); candidate != level.end()) {
candidate->second->setExtensions(num, extensions);
}
}
//
// Make all symbols in this table level read only.
//
@@ -381,9 +382,9 @@ TVariable* TVariable::clone() const
TFunction::TFunction(const TFunction& copyOf) : TSymbol(copyOf)
{
for (unsigned int i = 0; i < copyOf.parameters.size(); ++i) {
TParameter param;
TParameter param{};
parameters.push_back(param);
parameters.back().copyParam(copyOf.parameters[i]);
(void)parameters.back().copyParam(copyOf.parameters[i]);
}
extensions = nullptr;
@@ -397,9 +398,7 @@ TFunction::TFunction(const TFunction& copyOf) : TSymbol(copyOf)
implicitThis = copyOf.implicitThis;
illegalImplicitThis = copyOf.illegalImplicitThis;
defaultParamCount = copyOf.defaultParamCount;
#ifndef GLSLANG_WEB
spirvInst = copyOf.spirvInst;
#endif
}
TFunction* TFunction::clone() const
@@ -416,7 +415,7 @@ TAnonMember* TAnonMember::clone() const
// copy of the original container.
assert(0);
return 0;
return nullptr;
}
TSymbolTableLevel* TSymbolTableLevel::clone() const
@@ -84,7 +84,7 @@ typedef TVector<const char*> TExtensionList;
class TSymbol {
public:
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
explicit TSymbol(const TString *n) : name(n), uniqueId(0), extensions(0), writable(true) { }
explicit TSymbol(const TString *n) : name(n), uniqueId(0), extensions(nullptr), writable(true) { }
virtual TSymbol* clone() const = 0;
virtual ~TSymbol() { } // rely on all symbol owned memory coming from the pool
@@ -97,18 +97,18 @@ public:
changeName(NewPoolTString(newName.c_str()));
}
virtual const TString& getMangledName() const { return getName(); }
virtual TFunction* getAsFunction() { return 0; }
virtual const TFunction* getAsFunction() const { return 0; }
virtual TVariable* getAsVariable() { return 0; }
virtual const TVariable* getAsVariable() const { return 0; }
virtual const TAnonMember* getAsAnonMember() const { return 0; }
virtual TFunction* getAsFunction() { return nullptr; }
virtual const TFunction* getAsFunction() const { return nullptr; }
virtual TVariable* getAsVariable() { return nullptr; }
virtual const TVariable* getAsVariable() const { return nullptr; }
virtual const TAnonMember* getAsAnonMember() const { return nullptr; }
virtual const TType& getType() const = 0;
virtual TType& getWritableType() = 0;
virtual void setUniqueId(long long id) { uniqueId = id; }
virtual long long getUniqueId() const { return uniqueId; }
virtual void setExtensions(int numExts, const char* const exts[])
{
assert(extensions == 0);
assert(extensions == nullptr);
assert(numExts > 0);
extensions = NewPoolObject(extensions);
for (int e = 0; e < numExts; ++e)
@@ -117,10 +117,8 @@ public:
virtual int getNumExtensions() const { return extensions == nullptr ? 0 : (int)extensions->size(); }
virtual const char** getExtensions() const { return extensions->data(); }
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
virtual void dump(TInfoSink& infoSink, bool complete = false) const = 0;
void dumpExtensions(TInfoSink& infoSink) const;
#endif
virtual bool isReadOnly() const { return ! writable; }
virtual void makeReadOnly() { writable = false; }
@@ -196,9 +194,7 @@ public:
}
virtual const char** getMemberExtensions(int member) const { return (*memberExtensions)[member].data(); }
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
virtual void dump(TInfoSink& infoSink, bool complete = false) const;
#endif
protected:
explicit TVariable(const TVariable&);
@@ -224,14 +220,15 @@ struct TParameter {
TString *name;
TType* type;
TIntermTyped* defaultValue;
void copyParam(const TParameter& param)
TParameter& copyParam(const TParameter& param)
{
if (param.name)
name = NewPoolTString(param.name->c_str());
else
name = 0;
name = nullptr;
type = param.type->clone();
defaultValue = param.defaultValue;
return *this;
}
TBuiltInVariable getDeclaredBuiltIn() const { return type->getQualifier().declaredBuiltIn; }
};
@@ -242,14 +239,15 @@ struct TParameter {
class TFunction : public TSymbol {
public:
explicit TFunction(TOperator o) :
TSymbol(0),
TSymbol(nullptr),
op(o),
defined(false), prototyped(false), implicitThis(false), illegalImplicitThis(false), defaultParamCount(0) { }
TFunction(const TString *name, const TType& retType, TOperator tOp = EOpNull) :
TSymbol(name),
mangledName(*name + '('),
op(tOp),
defined(false), prototyped(false), implicitThis(false), illegalImplicitThis(false), defaultParamCount(0)
defined(false), prototyped(false), implicitThis(false), illegalImplicitThis(false), defaultParamCount(0),
linkType(ELinkNone)
{
returnType.shallowCopy(retType);
declaredBuiltIn = retType.getQualifier().builtIn;
@@ -318,19 +316,19 @@ public:
virtual TParameter& operator[](int i) { assert(writable); return parameters[i]; }
virtual const TParameter& operator[](int i) const { return parameters[i]; }
const TQualifier& getQualifier() const { return returnType.getQualifier(); }
#ifndef GLSLANG_WEB
virtual void setSpirvInstruction(const TSpirvInstruction& inst)
{
relateToOperator(EOpSpirvInst);
spirvInst = inst;
}
virtual const TSpirvInstruction& getSpirvInstruction() const { return spirvInst; }
#endif
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
virtual void dump(TInfoSink& infoSink, bool complete = false) const override;
#endif
void setExport() { linkType = ELinkExport; }
TLinkType getLinkType() const { return linkType; }
protected:
explicit TFunction(const TFunction&);
@@ -352,9 +350,8 @@ protected:
// but is not allowed to use them, or see hidden symbols instead.
int defaultParamCount;
#ifndef GLSLANG_WEB
TSpirvInstruction spirvInst; // SPIR-V instruction qualifiers
#endif
TLinkType linkType;
};
//
@@ -394,9 +391,7 @@ public:
virtual const char** getExtensions() const override { return anonContainer.getMemberExtensions(memberNumber); }
virtual int getAnonId() const { return anonId; }
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
virtual void dump(TInfoSink& infoSink, bool complete = false) const override;
#endif
protected:
explicit TAnonMember(const TAnonMember&);
@@ -410,7 +405,7 @@ protected:
class TSymbolTableLevel {
public:
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
TSymbolTableLevel() : defaultPrecision(0), anonId(0), thisLevel(false) { }
TSymbolTableLevel() : defaultPrecision(nullptr), anonId(0), thisLevel(false) { }
~TSymbolTableLevel();
bool insert(const TString& name, TSymbol* symbol) {
@@ -492,7 +487,7 @@ public:
{
tLevel::const_iterator it = level.find(name);
if (it == level.end())
return 0;
return nullptr;
else
return (*it).second;
}
@@ -560,7 +555,7 @@ public:
{
// can call multiple times at one scope, will only latch on first call,
// as we're tracking the previous scope's values, not the current values
if (defaultPrecision != 0)
if (defaultPrecision != nullptr)
return;
defaultPrecision = new TPrecisionQualifier[EbtNumTypes];
@@ -572,7 +567,7 @@ public:
{
// can be called for table level pops that didn't set the
// defaults
if (defaultPrecision == 0 || p == 0)
if (defaultPrecision == nullptr || p == nullptr)
return;
for (int t = 0; t < EbtNumTypes; ++t)
@@ -581,9 +576,8 @@ public:
void relateToOperator(const char* name, TOperator op);
void setFunctionExtensions(const char* name, int num, const char* const extensions[]);
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
void setSingleFunctionExtensions(const char* name, int num, const char* const extensions[]);
void dump(TInfoSink& infoSink, bool complete = false) const;
#endif
TSymbolTableLevel* clone() const;
void readOnly();
@@ -621,7 +615,7 @@ public:
// don't deallocate levels passed in from elsewhere
while (table.size() > adoptedLevels)
pop(0);
pop(nullptr);
}
void adoptLevels(TSymbolTable& symTable)
@@ -782,7 +776,7 @@ public:
// Normal find of a symbol, that can optionally say whether the symbol was found
// at a built-in level or the current top-scope level.
TSymbol* find(const TString& name, bool* builtIn = 0, bool* currentScope = 0, int* thisDepthP = 0)
TSymbol* find(const TString& name, bool* builtIn = nullptr, bool* currentScope = nullptr, int* thisDepthP = nullptr)
{
int level = currentLevel();
TSymbol* symbol;
@@ -826,7 +820,7 @@ public:
++thisDepth;
symbol = table[level]->find(name);
--level;
} while (symbol == 0 && level >= 0);
} while (symbol == nullptr && level >= 0);
if (! table[level + 1]->isThisLevel())
thisDepth = 0;
@@ -884,6 +878,12 @@ public:
table[level]->setFunctionExtensions(name, num, extensions);
}
void setSingleFunctionExtensions(const char* name, int num, const char* const extensions[])
{
for (unsigned int level = 0; level < table.size(); ++level)
table[level]->setSingleFunctionExtensions(name, num, extensions);
}
void setVariableExtensions(const char* name, int numExts, const char* const extensions[])
{
TSymbol* symbol = find(TString(name));
@@ -911,9 +911,7 @@ public:
}
long long getMaxSymbolId() { return uniqueId; }
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
void dump(TInfoSink& infoSink, bool complete = false) const;
#endif
void copyTable(const TSymbolTable& copyOf);
void setPreviousDefaultPrecisions(TPrecisionQualifier *p) { table[currentLevel()]->setPreviousDefaultPrecisions(p); }
@@ -151,8 +151,6 @@
namespace glslang {
#ifndef GLSLANG_WEB
//
// Initialize all extensions, almost always to 'disable', as once their features
// are incorporated into a core version, their features are supported through allowing that
@@ -166,7 +164,8 @@ void TParseVersions::initializeExtensionBehavior()
} extensionData;
const extensionData exts[] = { {E_GL_EXT_ray_tracing, EShTargetSpv_1_4},
{E_GL_NV_ray_tracing_motion_blur, EShTargetSpv_1_4}
{E_GL_NV_ray_tracing_motion_blur, EShTargetSpv_1_4},
{E_GL_EXT_mesh_shader, EShTargetSpv_1_4}
};
for (size_t ii = 0; ii < sizeof(exts) / sizeof(exts[0]); ii++) {
@@ -183,7 +182,6 @@ void TParseVersions::initializeExtensionBehavior()
extensionBehavior[E_GL_OES_EGL_image_external_essl3] = EBhDisable;
extensionBehavior[E_GL_EXT_YUV_target] = EBhDisable;
extensionBehavior[E_GL_EXT_shader_texture_lod] = EBhDisable;
extensionBehavior[E_GL_EXT_texture_array] = EBhDisable;
extensionBehavior[E_GL_EXT_shadow_samplers] = EBhDisable;
extensionBehavior[E_GL_ARB_texture_rectangle] = EBhDisable;
extensionBehavior[E_GL_3DL_array_objects] = EBhDisable;
@@ -227,6 +225,7 @@ void TParseVersions::initializeExtensionBehavior()
extensionBehavior[E_GL_ARB_texture_query_lod] = EBhDisable;
extensionBehavior[E_GL_ARB_vertex_attrib_64bit] = EBhDisable;
extensionBehavior[E_GL_ARB_draw_instanced] = EBhDisable;
extensionBehavior[E_GL_ARB_bindless_texture] = EBhDisable;
extensionBehavior[E_GL_ARB_fragment_coord_conventions] = EBhDisable;
@@ -260,6 +259,10 @@ void TParseVersions::initializeExtensionBehavior()
extensionBehavior[E_GL_EXT_shader_8bit_storage] = EBhDisable;
extensionBehavior[E_GL_EXT_subgroup_uniform_control_flow] = EBhDisable;
extensionBehavior[E_GL_EXT_fragment_shader_barycentric] = EBhDisable;
extensionBehavior[E_GL_KHR_cooperative_matrix] = EBhDisable;
// #line and #include
extensionBehavior[E_GL_GOOGLE_cpp_style_line_directive] = EBhDisable;
extensionBehavior[E_GL_GOOGLE_include_directive] = EBhDisable;
@@ -274,6 +277,7 @@ void TParseVersions::initializeExtensionBehavior()
extensionBehavior[E_GL_AMD_shader_image_load_store_lod] = EBhDisable;
extensionBehavior[E_GL_AMD_shader_fragment_mask] = EBhDisable;
extensionBehavior[E_GL_AMD_gpu_shader_half_float_fetch] = EBhDisable;
extensionBehavior[E_GL_AMD_shader_early_and_late_fragment_tests] = EBhDisable;
extensionBehavior[E_GL_INTEL_shader_integer_functions2] = EBhDisable;
@@ -293,10 +297,17 @@ void TParseVersions::initializeExtensionBehavior()
extensionBehavior[E_GL_NV_compute_shader_derivatives] = EBhDisable;
extensionBehavior[E_GL_NV_shader_texture_footprint] = EBhDisable;
extensionBehavior[E_GL_NV_mesh_shader] = EBhDisable;
extensionBehavior[E_GL_NV_cooperative_matrix] = EBhDisable;
extensionBehavior[E_GL_NV_shader_sm_builtins] = EBhDisable;
extensionBehavior[E_GL_NV_integer_cooperative_matrix] = EBhDisable;
extensionBehavior[E_GL_NV_shader_invocation_reorder] = EBhDisable;
extensionBehavior[E_GL_NV_displacement_micromap] = EBhDisable;
// ARM
extensionBehavior[E_GL_ARM_shader_core_builtins] = EBhDisable;
// QCOM
extensionBehavior[E_GL_QCOM_image_processing] = EBhDisable;
// AEP
extensionBehavior[E_GL_ANDROID_extension_pack_es31a] = EBhDisable;
@@ -335,13 +346,21 @@ void TParseVersions::initializeExtensionBehavior()
extensionBehavior[E_GL_EXT_ray_tracing] = EBhDisable;
extensionBehavior[E_GL_EXT_ray_query] = EBhDisable;
extensionBehavior[E_GL_EXT_ray_flags_primitive_culling] = EBhDisable;
extensionBehavior[E_GL_EXT_ray_cull_mask] = EBhDisable;
extensionBehavior[E_GL_EXT_blend_func_extended] = EBhDisable;
extensionBehavior[E_GL_EXT_shader_implicit_conversions] = EBhDisable;
extensionBehavior[E_GL_EXT_fragment_shading_rate] = EBhDisable;
extensionBehavior[E_GL_EXT_shader_image_int64] = EBhDisable;
extensionBehavior[E_GL_EXT_shader_image_int64] = EBhDisable;
extensionBehavior[E_GL_EXT_terminate_invocation] = EBhDisable;
extensionBehavior[E_GL_EXT_shared_memory_block] = EBhDisable;
extensionBehavior[E_GL_EXT_spirv_intrinsics] = EBhDisable;
extensionBehavior[E_GL_EXT_mesh_shader] = EBhDisable;
extensionBehavior[E_GL_EXT_opacity_micromap] = EBhDisable;
extensionBehavior[E_GL_EXT_ray_tracing_position_fetch] = EBhDisable;
extensionBehavior[E_GL_EXT_shader_tile_image] = EBhDisable;
extensionBehavior[E_GL_EXT_texture_shadow_lod] = EBhDisable;
extensionBehavior[E_GL_EXT_draw_instanced] = EBhDisable;
extensionBehavior[E_GL_EXT_texture_array] = EBhDisable;
// OVR extensions
extensionBehavior[E_GL_OVR_multiview] = EBhDisable;
@@ -364,9 +383,10 @@ void TParseVersions::initializeExtensionBehavior()
extensionBehavior[E_GL_EXT_shader_subgroup_extended_types_float16] = EBhDisable;
extensionBehavior[E_GL_EXT_shader_atomic_float] = EBhDisable;
extensionBehavior[E_GL_EXT_shader_atomic_float2] = EBhDisable;
}
#endif // GLSLANG_WEB
// Record extensions not for spv.
spvUnsupportedExt.push_back(E_GL_ARB_bindless_texture);
}
// Get code that is not part of a shared symbol table, is specific to this shader,
// or needed by the preprocessor (which does not use a shared symbol table).
@@ -376,10 +396,6 @@ void TParseVersions::getPreamble(std::string& preamble)
preamble =
"#define GL_ES 1\n"
"#define GL_FRAGMENT_PRECISION_HIGH 1\n"
#ifdef GLSLANG_WEB
;
#else
"#define GL_EXT_texture_array 1\n"
"#define GL_OES_texture_3D 1\n"
"#define GL_OES_standard_derivatives 1\n"
"#define GL_EXT_frag_depth 1\n"
@@ -389,6 +405,7 @@ void TParseVersions::getPreamble(std::string& preamble)
"#define GL_EXT_shader_texture_lod 1\n"
"#define GL_EXT_shadow_samplers 1\n"
"#define GL_EXT_fragment_shading_rate 1\n"
"#define GL_EXT_texture_array 1\n"
// AEP
"#define GL_ANDROID_extension_pack_es31a 1\n"
@@ -420,6 +437,8 @@ void TParseVersions::getPreamble(std::string& preamble)
"#define GL_OES_texture_buffer 1\n"
"#define GL_OES_texture_cube_map_array 1\n"
"#define GL_EXT_shader_non_constant_global_initializers 1\n"
"#define GL_QCOM_image_processing 1\n"
;
if (version >= 300) {
@@ -432,8 +451,6 @@ void TParseVersions::getPreamble(std::string& preamble)
} else { // !isEsProfile()
preamble =
"#define GL_FRAGMENT_PRECISION_HIGH 1\n"
"#define GL_EXT_texture_array 1\n"
"#define GL_ARB_texture_rectangle 1\n"
"#define GL_ARB_shading_language_420pack 1\n"
"#define GL_ARB_texture_gather 1\n"
@@ -473,6 +490,7 @@ void TParseVersions::getPreamble(std::string& preamble)
"#define GL_ARB_vertex_attrib_64bit 1\n"
"#define GL_ARB_draw_instanced 1\n"
"#define GL_ARB_fragment_coord_conventions 1\n"
"#define GL_EXT_shader_non_constant_global_initializers 1\n"
"#define GL_EXT_shader_image_load_formatted 1\n"
"#define GL_EXT_post_depth_coverage 1\n"
@@ -502,13 +520,18 @@ void TParseVersions::getPreamble(std::string& preamble)
"#define GL_KHR_shader_subgroup_clustered 1\n"
"#define GL_KHR_shader_subgroup_quad 1\n"
"#define GL_KHR_cooperative_matrix 1\n"
"#define GL_EXT_shader_image_int64 1\n"
"#define GL_EXT_shader_atomic_int64 1\n"
"#define GL_EXT_shader_realtime_clock 1\n"
"#define GL_EXT_ray_tracing 1\n"
"#define GL_EXT_ray_query 1\n"
"#define GL_EXT_ray_flags_primitive_culling 1\n"
"#define GL_EXT_ray_cull_mask 1\n"
"#define GL_EXT_ray_tracing_position_fetch 1\n"
"#define GL_EXT_spirv_intrinsics 1\n"
"#define GL_EXT_mesh_shader 1\n"
"#define GL_AMD_shader_ballot 1\n"
"#define GL_AMD_shader_trinary_minmax 1\n"
@@ -538,6 +561,9 @@ void TParseVersions::getPreamble(std::string& preamble)
"#define GL_NV_mesh_shader 1\n"
"#define GL_NV_cooperative_matrix 1\n"
"#define GL_NV_integer_cooperative_matrix 1\n"
"#define GL_NV_shader_invocation_reorder 1\n"
"#define GL_QCOM_image_processing 1\n"
"#define GL_EXT_shader_explicit_arithmetic_types 1\n"
"#define GL_EXT_shader_explicit_arithmetic_types_int8 1\n"
@@ -555,8 +581,15 @@ void TParseVersions::getPreamble(std::string& preamble)
"#define GL_EXT_shader_atomic_float 1\n"
"#define GL_EXT_shader_atomic_float2 1\n"
"#define GL_EXT_fragment_shader_barycentric 1\n"
"#define GL_EXT_texture_array 1\n"
;
if (spvVersion.spv == 0) {
preamble += "#define GL_ARB_bindless_texture 1\n";
}
if (version >= 150) {
// define GL_core_profile and GL_compatibility_profile
preamble += "#define GL_core_profile 1\n";
@@ -568,10 +601,11 @@ void TParseVersions::getPreamble(std::string& preamble)
preamble += "#define GL_EXT_null_initializer 1\n";
preamble += "#define GL_EXT_subgroup_uniform_control_flow 1\n";
}
#endif // GLSLANG_WEB
if (version >= 130) {
preamble +="#define GL_FRAGMENT_PRECISION_HIGH 1\n";
}
}
#ifndef GLSLANG_WEB
if ((!isEsProfile() && version >= 140) ||
(isEsProfile() && version >= 310)) {
preamble +=
@@ -599,7 +633,6 @@ void TParseVersions::getPreamble(std::string& preamble)
preamble +=
"#define GL_EXT_terminate_invocation 1\n"
;
#endif
// #define VULKAN XXXX
const int numberBufSize = 12;
@@ -611,7 +644,6 @@ void TParseVersions::getPreamble(std::string& preamble)
preamble += "\n";
}
#ifndef GLSLANG_WEB
// #define GL_SPIRV XXXX
if (spvVersion.openGl > 0) {
preamble += "#define GL_SPIRV ";
@@ -619,9 +651,7 @@ void TParseVersions::getPreamble(std::string& preamble)
preamble += numberBuf;
preamble += "\n";
}
#endif
#ifndef GLSLANG_WEB
// GL_EXT_spirv_intrinsics
if (!isEsProfile()) {
switch (language) {
@@ -637,12 +667,11 @@ void TParseVersions::getPreamble(std::string& preamble)
case EShLangClosestHit: preamble += "#define GL_CLOSEST_HIT_SHADER_EXT 1 \n"; break;
case EShLangMiss: preamble += "#define GL_MISS_SHADER_EXT 1 \n"; break;
case EShLangCallable: preamble += "#define GL_CALLABLE_SHADER_EXT 1 \n"; break;
case EShLangTaskNV: preamble += "#define GL_TASK_SHADER_NV 1 \n"; break;
case EShLangMeshNV: preamble += "#define GL_MESH_SHADER_NV 1 \n"; break;
case EShLangTask: preamble += "#define GL_TASK_SHADER_NV 1 \n"; break;
case EShLangMesh: preamble += "#define GL_MESH_SHADER_NV 1 \n"; break;
default: break;
}
}
#endif
}
//
@@ -654,7 +683,6 @@ const char* StageName(EShLanguage stage)
case EShLangVertex: return "vertex";
case EShLangFragment: return "fragment";
case EShLangCompute: return "compute";
#ifndef GLSLANG_WEB
case EShLangTessControl: return "tessellation control";
case EShLangTessEvaluation: return "tessellation evaluation";
case EShLangGeometry: return "geometry";
@@ -664,9 +692,8 @@ const char* StageName(EShLanguage stage)
case EShLangClosestHit: return "closest-hit";
case EShLangMiss: return "miss";
case EShLangCallable: return "callable";
case EShLangMeshNV: return "mesh";
case EShLangTaskNV: return "task";
#endif
case EShLangMesh: return "mesh";
case EShLangTask: return "task";
default: return "unknown stage";
}
}
@@ -691,7 +718,6 @@ void TParseVersions::requireStage(const TSourceLoc& loc, EShLanguage stage, cons
requireStage(loc, static_cast<EShLanguageMask>(1 << stage), featureDesc);
}
#ifndef GLSLANG_WEB
//
// When to use requireProfile():
//
@@ -729,7 +755,6 @@ void TParseVersions::profileRequires(const TSourceLoc& loc, int profileMask, int
{
if (profile & profileMask) {
bool okay = minVersion > 0 && version >= minVersion;
#ifndef GLSLANG_WEB
for (int i = 0; i < numExtensions; ++i) {
switch (getExtensionBehavior(extensions[i])) {
case EBhWarn:
@@ -742,7 +767,6 @@ void TParseVersions::profileRequires(const TSourceLoc& loc, int profileMask, int
default: break; // some compilers want this
}
}
#endif
if (! okay)
error(loc, "not supported for this version or the enabled extensions", featureDesc, "");
}
@@ -1056,10 +1080,22 @@ void TParseVersions::checkExtensionStage(const TSourceLoc& loc, const char * con
{
// GL_NV_mesh_shader extension is only allowed in task/mesh shaders
if (strcmp(extension, "GL_NV_mesh_shader") == 0) {
requireStage(loc, (EShLanguageMask)(EShLangTaskNVMask | EShLangMeshNVMask | EShLangFragmentMask),
requireStage(loc, (EShLanguageMask)(EShLangTaskMask | EShLangMeshMask | EShLangFragmentMask),
"#extension GL_NV_mesh_shader");
profileRequires(loc, ECoreProfile, 450, 0, "#extension GL_NV_mesh_shader");
profileRequires(loc, EEsProfile, 320, 0, "#extension GL_NV_mesh_shader");
profileRequires(loc, ECoreProfile, 450, nullptr, "#extension GL_NV_mesh_shader");
profileRequires(loc, EEsProfile, 320, nullptr, "#extension GL_NV_mesh_shader");
if (extensionTurnedOn(E_GL_EXT_mesh_shader)) {
error(loc, "GL_EXT_mesh_shader is already turned on, and not allowed with", "#extension", extension);
}
}
else if (strcmp(extension, "GL_EXT_mesh_shader") == 0) {
requireStage(loc, (EShLanguageMask)(EShLangTaskMask | EShLangMeshMask | EShLangFragmentMask),
"#extension GL_EXT_mesh_shader");
profileRequires(loc, ECoreProfile, 450, nullptr, "#extension GL_EXT_mesh_shader");
profileRequires(loc, EEsProfile, 320, nullptr, "#extension GL_EXT_mesh_shader");
if (extensionTurnedOn(E_GL_NV_mesh_shader)) {
error(loc, "GL_NV_mesh_shader is already turned on, and not allowed with", "#extension", extension);
}
}
}
@@ -1079,6 +1115,13 @@ void TParseVersions::extensionRequires(const TSourceLoc &loc, const char * const
minSpvVersion = iter->second;
requireSpv(loc, extension, minSpvVersion);
}
if (spvVersion.spv != 0){
for (auto ext : spvUnsupportedExt){
if (strcmp(extension, ext.c_str()) == 0)
error(loc, "not allowed when using generating SPIR-V codes", extension, "");
}
}
}
// Call for any operation needing full GLSL integer data-type support.
@@ -1291,7 +1334,7 @@ void TParseVersions::int64Check(const TSourceLoc& loc, const char* op, bool buil
}
}
void TParseVersions::fcoopmatCheck(const TSourceLoc& loc, const char* op, bool builtIn)
void TParseVersions::fcoopmatCheckNV(const TSourceLoc& loc, const char* op, bool builtIn)
{
if (!builtIn) {
const char* const extensions[] = {E_GL_NV_cooperative_matrix};
@@ -1299,14 +1342,22 @@ void TParseVersions::fcoopmatCheck(const TSourceLoc& loc, const char* op, bool b
}
}
void TParseVersions::intcoopmatCheck(const TSourceLoc& loc, const char* op, bool builtIn)
void TParseVersions::intcoopmatCheckNV(const TSourceLoc& loc, const char* op, bool builtIn)
{
if (!builtIn) {
const char* const extensions[] = {E_GL_NV_integer_cooperative_matrix};
requireExtensions(loc, sizeof(extensions)/sizeof(extensions[0]), extensions, op);
}
}
#endif // GLSLANG_WEB
void TParseVersions::coopmatCheck(const TSourceLoc& loc, const char* op, bool builtIn)
{
if (!builtIn) {
const char* const extensions[] = {E_GL_KHR_cooperative_matrix};
requireExtensions(loc, sizeof(extensions)/sizeof(extensions[0]), extensions, op);
}
}
// Call for any operation removed because SPIR-V is in use.
void TParseVersions::spvRemoved(const TSourceLoc& loc, const char* op)
{
@@ -1324,26 +1375,20 @@ void TParseVersions::vulkanRemoved(const TSourceLoc& loc, const char* op)
// Call for any operation that requires Vulkan.
void TParseVersions::requireVulkan(const TSourceLoc& loc, const char* op)
{
#ifndef GLSLANG_WEB
if (spvVersion.vulkan == 0)
error(loc, "only allowed when using GLSL for Vulkan", op, "");
#endif
}
// Call for any operation that requires SPIR-V.
void TParseVersions::requireSpv(const TSourceLoc& loc, const char* op)
{
#ifndef GLSLANG_WEB
if (spvVersion.spv == 0)
error(loc, "only allowed when generating SPIR-V", op, "");
#endif
}
void TParseVersions::requireSpv(const TSourceLoc& loc, const char *op, unsigned int version)
{
#ifndef GLSLANG_WEB
if (spvVersion.spv < version)
error(loc, "not supported for current targeted SPIR-V version", op, "");
#endif
}
} // end namespace glslang
+32 -5
View File
@@ -120,7 +120,6 @@ const char* const E_GL_EXT_YUV_target = "GL_EXT_YUV_target";
const char* const E_GL_EXT_shader_texture_lod = "GL_EXT_shader_texture_lod";
const char* const E_GL_EXT_shadow_samplers = "GL_EXT_shadow_samplers";
const char* const E_GL_EXT_texture_array = "GL_EXT_texture_array";
const char* const E_GL_ARB_texture_rectangle = "GL_ARB_texture_rectangle";
const char* const E_GL_3DL_array_objects = "GL_3DL_array_objects";
const char* const E_GL_ARB_shading_language_420pack = "GL_ARB_shading_language_420pack";
@@ -164,6 +163,7 @@ const char* const E_GL_ARB_texture_query_lod = "GL_ARB_texture_query_
const char* const E_GL_ARB_vertex_attrib_64bit = "GL_ARB_vertex_attrib_64bit";
const char* const E_GL_ARB_draw_instanced = "GL_ARB_draw_instanced";
const char* const E_GL_ARB_fragment_coord_conventions = "GL_ARB_fragment_coord_conventions";
const char* const E_GL_ARB_bindless_texture = "GL_ARB_bindless_texture";
const char* const E_GL_KHR_shader_subgroup_basic = "GL_KHR_shader_subgroup_basic";
const char* const E_GL_KHR_shader_subgroup_vote = "GL_KHR_shader_subgroup_vote";
@@ -174,6 +174,7 @@ const char* const E_GL_KHR_shader_subgroup_shuffle_relative = "GL_KHR_shader_sub
const char* const E_GL_KHR_shader_subgroup_clustered = "GL_KHR_shader_subgroup_clustered";
const char* const E_GL_KHR_shader_subgroup_quad = "GL_KHR_shader_subgroup_quad";
const char* const E_GL_KHR_memory_scope_semantics = "GL_KHR_memory_scope_semantics";
const char* const E_GL_KHR_cooperative_matrix = "GL_KHR_cooperative_matrix";
const char* const E_GL_EXT_shader_atomic_int64 = "GL_EXT_shader_atomic_int64";
@@ -202,6 +203,7 @@ const char* const E_GL_EXT_debug_printf = "GL_EXT_debug_prin
const char* const E_GL_EXT_ray_tracing = "GL_EXT_ray_tracing";
const char* const E_GL_EXT_ray_query = "GL_EXT_ray_query";
const char* const E_GL_EXT_ray_flags_primitive_culling = "GL_EXT_ray_flags_primitive_culling";
const char* const E_GL_EXT_ray_cull_mask = "GL_EXT_ray_cull_mask";
const char* const E_GL_EXT_blend_func_extended = "GL_EXT_blend_func_extended";
const char* const E_GL_EXT_shader_implicit_conversions = "GL_EXT_shader_implicit_conversions";
const char* const E_GL_EXT_fragment_shading_rate = "GL_EXT_fragment_shading_rate";
@@ -210,12 +212,21 @@ const char* const E_GL_EXT_null_initializer = "GL_EXT_null_initi
const char* const E_GL_EXT_shared_memory_block = "GL_EXT_shared_memory_block";
const char* const E_GL_EXT_subgroup_uniform_control_flow = "GL_EXT_subgroup_uniform_control_flow";
const char* const E_GL_EXT_spirv_intrinsics = "GL_EXT_spirv_intrinsics";
const char* const E_GL_EXT_fragment_shader_barycentric = "GL_EXT_fragment_shader_barycentric";
const char* const E_GL_EXT_mesh_shader = "GL_EXT_mesh_shader";
const char* const E_GL_EXT_opacity_micromap = "GL_EXT_opacity_micromap";
const char* const E_GL_EXT_draw_instanced = "GL_EXT_draw_instanced";
const char* const E_GL_EXT_texture_array = "GL_EXT_texture_array";
// Arrays of extensions for the above viewportEXTs duplications
const char* const post_depth_coverageEXTs[] = { E_GL_ARB_post_depth_coverage, E_GL_EXT_post_depth_coverage };
const int Num_post_depth_coverageEXTs = sizeof(post_depth_coverageEXTs) / sizeof(post_depth_coverageEXTs[0]);
// Array of extensions to cover both extensions providing ray tracing capabilities.
const char* const ray_tracing_EXTs[] = { E_GL_EXT_ray_query, E_GL_EXT_ray_tracing };
const int Num_ray_tracing_EXTs = sizeof(ray_tracing_EXTs) / sizeof(ray_tracing_EXTs[0]);
// OVR extensions
const char* const E_GL_OVR_multiview = "GL_OVR_multiview";
const char* const E_GL_OVR_multiview2 = "GL_OVR_multiview2";
@@ -237,6 +248,7 @@ const char* const E_GL_AMD_gpu_shader_int16 = "GL_AMD_gpu_sh
const char* const E_GL_AMD_shader_image_load_store_lod = "GL_AMD_shader_image_load_store_lod";
const char* const E_GL_AMD_shader_fragment_mask = "GL_AMD_shader_fragment_mask";
const char* const E_GL_AMD_gpu_shader_half_float_fetch = "GL_AMD_gpu_shader_half_float_fetch";
const char* const E_GL_AMD_shader_early_and_late_fragment_tests = "GL_AMD_shader_early_and_late_fragment_tests";
const char* const E_GL_INTEL_shader_integer_functions2 = "GL_INTEL_shader_integer_functions2";
@@ -256,15 +268,23 @@ const char* const E_GL_NV_fragment_shader_barycentric = "GL_NV_fragmen
const char* const E_GL_NV_compute_shader_derivatives = "GL_NV_compute_shader_derivatives";
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";
const char* const E_GL_NV_cooperative_matrix = "GL_NV_cooperative_matrix";
const char* const E_GL_NV_shader_sm_builtins = "GL_NV_shader_sm_builtins";
const char* const E_GL_NV_integer_cooperative_matrix = "GL_NV_integer_cooperative_matrix";
const char* const E_GL_NV_shader_invocation_reorder = "GL_NV_shader_invocation_reorder";
const char* const E_GL_EXT_ray_tracing_position_fetch = "GL_EXT_ray_tracing_position_fetch";
const char* const E_GL_NV_displacement_micromap = "GL_NV_displacement_micromap";
// 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 };
const int Num_viewportEXTs = sizeof(viewportEXTs) / sizeof(viewportEXTs[0]);
const char* const E_GL_NV_cooperative_matrix = "GL_NV_cooperative_matrix";
const char* const E_GL_NV_shader_sm_builtins = "GL_NV_shader_sm_builtins";
const char* const E_GL_NV_integer_cooperative_matrix = "GL_NV_integer_cooperative_matrix";
const char* const E_GL_QCOM_image_processing = "GL_QCOM_image_processing";
// AEP
const char* const E_GL_ANDROID_extension_pack_es31a = "GL_ANDROID_extension_pack_es31a";
@@ -282,7 +302,7 @@ const char* const E_GL_EXT_tessellation_shader = "GL_EXT_tessel
const char* const E_GL_EXT_tessellation_point_size = "GL_EXT_tessellation_point_size";
const char* const E_GL_EXT_texture_buffer = "GL_EXT_texture_buffer";
const char* const E_GL_EXT_texture_cube_map_array = "GL_EXT_texture_cube_map_array";
const char* const E_GL_EXT_shader_integer_mix = "GL_EXT_shader_integer_mix";
const char* const E_GL_EXT_shader_integer_mix = "GL_EXT_shader_integer_mix";
// OES matching AEP
const char* const E_GL_OES_geometry_shader = "GL_OES_geometry_shader";
@@ -314,6 +334,10 @@ const char* const E_GL_EXT_terminate_invocation = "GL_EXT_terminate_invocation";
const char* const E_GL_EXT_shader_atomic_float = "GL_EXT_shader_atomic_float";
const char* const E_GL_EXT_shader_atomic_float2 = "GL_EXT_shader_atomic_float2";
const char* const E_GL_EXT_shader_tile_image = "GL_EXT_shader_tile_image";
const char* const E_GL_EXT_texture_shadow_lod = "GL_EXT_texture_shadow_lod";
// Arrays of extensions for the above AEP duplications
const char* const AEP_geometry_shader[] = { E_GL_EXT_geometry_shader, E_GL_OES_geometry_shader };
@@ -343,6 +367,9 @@ const int Num_AEP_texture_buffer = sizeof(AEP_texture_buffer)/sizeof(AEP_texture
const char* const AEP_texture_cube_map_array[] = { E_GL_EXT_texture_cube_map_array, E_GL_OES_texture_cube_map_array };
const int Num_AEP_texture_cube_map_array = sizeof(AEP_texture_cube_map_array)/sizeof(AEP_texture_cube_map_array[0]);
const char* const AEP_mesh_shader[] = { E_GL_NV_mesh_shader, E_GL_EXT_mesh_shader };
const int Num_AEP_mesh_shader = sizeof(AEP_mesh_shader)/sizeof(AEP_mesh_shader[0]);
} // end namespace glslang
#endif // _VERSIONS_INCLUDED_
@@ -34,8 +34,6 @@
// POSSIBILITY OF SUCH DAMAGE.
//
#ifndef GLSLANG_WEB
#include "attribute.h"
#include "../Include/intermediate.h"
#include "ParseHelper.h"
@@ -125,6 +123,8 @@ TAttributeType TParseContext::attributeFromName(const TString& name) const
return EatPartialCount;
else if (name == "subgroup_uniform_control_flow")
return EatSubgroupUniformControlFlow;
else if (name == "export")
return EatExport;
else
return EatNone;
}
@@ -357,6 +357,7 @@ void TParseContext::handleFunctionAttributes(const TSourceLoc& loc, const TAttri
switch (it->name) {
case EatSubgroupUniformControlFlow:
requireExtensions(loc, 1, &E_GL_EXT_subgroup_uniform_control_flow, "attribute");
intermediate.setSubgroupUniformControlFlow();
break;
default:
@@ -367,5 +368,3 @@ void TParseContext::handleFunctionAttributes(const TSourceLoc& loc, const TAttri
}
} // end namespace glslang
#endif // GLSLANG_WEB
@@ -120,6 +120,7 @@ namespace glslang {
EatNonWritable,
EatNonReadable,
EatSubgroupUniformControlFlow,
EatExport,
};
class TIntermAggregate;
File diff suppressed because it is too large Load Diff
@@ -1,8 +1,8 @@
/* A Bison parser, made by GNU Bison 3.7.4. */
/* A Bison parser, made by GNU Bison 3.8.2. */
/* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2020 Free Software Foundation,
Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation,
Inc.
This program is free software: you can redistribute it and/or modify
@@ -16,7 +16,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
@@ -217,295 +217,305 @@ extern int yydebug;
FCOOPMATNV = 418, /* FCOOPMATNV */
ICOOPMATNV = 419, /* ICOOPMATNV */
UCOOPMATNV = 420, /* UCOOPMATNV */
SAMPLERCUBEARRAY = 421, /* SAMPLERCUBEARRAY */
SAMPLERCUBEARRAYSHADOW = 422, /* SAMPLERCUBEARRAYSHADOW */
ISAMPLERCUBEARRAY = 423, /* ISAMPLERCUBEARRAY */
USAMPLERCUBEARRAY = 424, /* USAMPLERCUBEARRAY */
SAMPLER1D = 425, /* SAMPLER1D */
SAMPLER1DARRAY = 426, /* SAMPLER1DARRAY */
SAMPLER1DARRAYSHADOW = 427, /* SAMPLER1DARRAYSHADOW */
ISAMPLER1D = 428, /* ISAMPLER1D */
SAMPLER1DSHADOW = 429, /* SAMPLER1DSHADOW */
SAMPLER2DRECT = 430, /* SAMPLER2DRECT */
SAMPLER2DRECTSHADOW = 431, /* SAMPLER2DRECTSHADOW */
ISAMPLER2DRECT = 432, /* ISAMPLER2DRECT */
USAMPLER2DRECT = 433, /* USAMPLER2DRECT */
SAMPLERBUFFER = 434, /* SAMPLERBUFFER */
ISAMPLERBUFFER = 435, /* ISAMPLERBUFFER */
USAMPLERBUFFER = 436, /* USAMPLERBUFFER */
SAMPLER2DMS = 437, /* SAMPLER2DMS */
ISAMPLER2DMS = 438, /* ISAMPLER2DMS */
USAMPLER2DMS = 439, /* USAMPLER2DMS */
SAMPLER2DMSARRAY = 440, /* SAMPLER2DMSARRAY */
ISAMPLER2DMSARRAY = 441, /* ISAMPLER2DMSARRAY */
USAMPLER2DMSARRAY = 442, /* USAMPLER2DMSARRAY */
SAMPLEREXTERNALOES = 443, /* SAMPLEREXTERNALOES */
SAMPLEREXTERNAL2DY2YEXT = 444, /* SAMPLEREXTERNAL2DY2YEXT */
ISAMPLER1DARRAY = 445, /* ISAMPLER1DARRAY */
USAMPLER1D = 446, /* USAMPLER1D */
USAMPLER1DARRAY = 447, /* USAMPLER1DARRAY */
F16SAMPLER1D = 448, /* F16SAMPLER1D */
F16SAMPLER2D = 449, /* F16SAMPLER2D */
F16SAMPLER3D = 450, /* F16SAMPLER3D */
F16SAMPLER2DRECT = 451, /* F16SAMPLER2DRECT */
F16SAMPLERCUBE = 452, /* F16SAMPLERCUBE */
F16SAMPLER1DARRAY = 453, /* F16SAMPLER1DARRAY */
F16SAMPLER2DARRAY = 454, /* F16SAMPLER2DARRAY */
F16SAMPLERCUBEARRAY = 455, /* F16SAMPLERCUBEARRAY */
F16SAMPLERBUFFER = 456, /* F16SAMPLERBUFFER */
F16SAMPLER2DMS = 457, /* F16SAMPLER2DMS */
F16SAMPLER2DMSARRAY = 458, /* F16SAMPLER2DMSARRAY */
F16SAMPLER1DSHADOW = 459, /* F16SAMPLER1DSHADOW */
F16SAMPLER2DSHADOW = 460, /* F16SAMPLER2DSHADOW */
F16SAMPLER1DARRAYSHADOW = 461, /* F16SAMPLER1DARRAYSHADOW */
F16SAMPLER2DARRAYSHADOW = 462, /* F16SAMPLER2DARRAYSHADOW */
F16SAMPLER2DRECTSHADOW = 463, /* F16SAMPLER2DRECTSHADOW */
F16SAMPLERCUBESHADOW = 464, /* F16SAMPLERCUBESHADOW */
F16SAMPLERCUBEARRAYSHADOW = 465, /* F16SAMPLERCUBEARRAYSHADOW */
IMAGE1D = 466, /* IMAGE1D */
IIMAGE1D = 467, /* IIMAGE1D */
UIMAGE1D = 468, /* UIMAGE1D */
IMAGE2D = 469, /* IMAGE2D */
IIMAGE2D = 470, /* IIMAGE2D */
UIMAGE2D = 471, /* UIMAGE2D */
IMAGE3D = 472, /* IMAGE3D */
IIMAGE3D = 473, /* IIMAGE3D */
UIMAGE3D = 474, /* UIMAGE3D */
IMAGE2DRECT = 475, /* IMAGE2DRECT */
IIMAGE2DRECT = 476, /* IIMAGE2DRECT */
UIMAGE2DRECT = 477, /* UIMAGE2DRECT */
IMAGECUBE = 478, /* IMAGECUBE */
IIMAGECUBE = 479, /* IIMAGECUBE */
UIMAGECUBE = 480, /* UIMAGECUBE */
IMAGEBUFFER = 481, /* IMAGEBUFFER */
IIMAGEBUFFER = 482, /* IIMAGEBUFFER */
UIMAGEBUFFER = 483, /* UIMAGEBUFFER */
IMAGE1DARRAY = 484, /* IMAGE1DARRAY */
IIMAGE1DARRAY = 485, /* IIMAGE1DARRAY */
UIMAGE1DARRAY = 486, /* UIMAGE1DARRAY */
IMAGE2DARRAY = 487, /* IMAGE2DARRAY */
IIMAGE2DARRAY = 488, /* IIMAGE2DARRAY */
UIMAGE2DARRAY = 489, /* UIMAGE2DARRAY */
IMAGECUBEARRAY = 490, /* IMAGECUBEARRAY */
IIMAGECUBEARRAY = 491, /* IIMAGECUBEARRAY */
UIMAGECUBEARRAY = 492, /* UIMAGECUBEARRAY */
IMAGE2DMS = 493, /* IMAGE2DMS */
IIMAGE2DMS = 494, /* IIMAGE2DMS */
UIMAGE2DMS = 495, /* UIMAGE2DMS */
IMAGE2DMSARRAY = 496, /* IMAGE2DMSARRAY */
IIMAGE2DMSARRAY = 497, /* IIMAGE2DMSARRAY */
UIMAGE2DMSARRAY = 498, /* UIMAGE2DMSARRAY */
F16IMAGE1D = 499, /* F16IMAGE1D */
F16IMAGE2D = 500, /* F16IMAGE2D */
F16IMAGE3D = 501, /* F16IMAGE3D */
F16IMAGE2DRECT = 502, /* F16IMAGE2DRECT */
F16IMAGECUBE = 503, /* F16IMAGECUBE */
F16IMAGE1DARRAY = 504, /* F16IMAGE1DARRAY */
F16IMAGE2DARRAY = 505, /* F16IMAGE2DARRAY */
F16IMAGECUBEARRAY = 506, /* F16IMAGECUBEARRAY */
F16IMAGEBUFFER = 507, /* F16IMAGEBUFFER */
F16IMAGE2DMS = 508, /* F16IMAGE2DMS */
F16IMAGE2DMSARRAY = 509, /* F16IMAGE2DMSARRAY */
I64IMAGE1D = 510, /* I64IMAGE1D */
U64IMAGE1D = 511, /* U64IMAGE1D */
I64IMAGE2D = 512, /* I64IMAGE2D */
U64IMAGE2D = 513, /* U64IMAGE2D */
I64IMAGE3D = 514, /* I64IMAGE3D */
U64IMAGE3D = 515, /* U64IMAGE3D */
I64IMAGE2DRECT = 516, /* I64IMAGE2DRECT */
U64IMAGE2DRECT = 517, /* U64IMAGE2DRECT */
I64IMAGECUBE = 518, /* I64IMAGECUBE */
U64IMAGECUBE = 519, /* U64IMAGECUBE */
I64IMAGEBUFFER = 520, /* I64IMAGEBUFFER */
U64IMAGEBUFFER = 521, /* U64IMAGEBUFFER */
I64IMAGE1DARRAY = 522, /* I64IMAGE1DARRAY */
U64IMAGE1DARRAY = 523, /* U64IMAGE1DARRAY */
I64IMAGE2DARRAY = 524, /* I64IMAGE2DARRAY */
U64IMAGE2DARRAY = 525, /* U64IMAGE2DARRAY */
I64IMAGECUBEARRAY = 526, /* I64IMAGECUBEARRAY */
U64IMAGECUBEARRAY = 527, /* U64IMAGECUBEARRAY */
I64IMAGE2DMS = 528, /* I64IMAGE2DMS */
U64IMAGE2DMS = 529, /* U64IMAGE2DMS */
I64IMAGE2DMSARRAY = 530, /* I64IMAGE2DMSARRAY */
U64IMAGE2DMSARRAY = 531, /* U64IMAGE2DMSARRAY */
TEXTURECUBEARRAY = 532, /* TEXTURECUBEARRAY */
ITEXTURECUBEARRAY = 533, /* ITEXTURECUBEARRAY */
UTEXTURECUBEARRAY = 534, /* UTEXTURECUBEARRAY */
TEXTURE1D = 535, /* TEXTURE1D */
ITEXTURE1D = 536, /* ITEXTURE1D */
UTEXTURE1D = 537, /* UTEXTURE1D */
TEXTURE1DARRAY = 538, /* TEXTURE1DARRAY */
ITEXTURE1DARRAY = 539, /* ITEXTURE1DARRAY */
UTEXTURE1DARRAY = 540, /* UTEXTURE1DARRAY */
TEXTURE2DRECT = 541, /* TEXTURE2DRECT */
ITEXTURE2DRECT = 542, /* ITEXTURE2DRECT */
UTEXTURE2DRECT = 543, /* UTEXTURE2DRECT */
TEXTUREBUFFER = 544, /* TEXTUREBUFFER */
ITEXTUREBUFFER = 545, /* ITEXTUREBUFFER */
UTEXTUREBUFFER = 546, /* UTEXTUREBUFFER */
TEXTURE2DMS = 547, /* TEXTURE2DMS */
ITEXTURE2DMS = 548, /* ITEXTURE2DMS */
UTEXTURE2DMS = 549, /* UTEXTURE2DMS */
TEXTURE2DMSARRAY = 550, /* TEXTURE2DMSARRAY */
ITEXTURE2DMSARRAY = 551, /* ITEXTURE2DMSARRAY */
UTEXTURE2DMSARRAY = 552, /* UTEXTURE2DMSARRAY */
F16TEXTURE1D = 553, /* F16TEXTURE1D */
F16TEXTURE2D = 554, /* F16TEXTURE2D */
F16TEXTURE3D = 555, /* F16TEXTURE3D */
F16TEXTURE2DRECT = 556, /* F16TEXTURE2DRECT */
F16TEXTURECUBE = 557, /* F16TEXTURECUBE */
F16TEXTURE1DARRAY = 558, /* F16TEXTURE1DARRAY */
F16TEXTURE2DARRAY = 559, /* F16TEXTURE2DARRAY */
F16TEXTURECUBEARRAY = 560, /* F16TEXTURECUBEARRAY */
F16TEXTUREBUFFER = 561, /* F16TEXTUREBUFFER */
F16TEXTURE2DMS = 562, /* F16TEXTURE2DMS */
F16TEXTURE2DMSARRAY = 563, /* F16TEXTURE2DMSARRAY */
SUBPASSINPUT = 564, /* SUBPASSINPUT */
SUBPASSINPUTMS = 565, /* SUBPASSINPUTMS */
ISUBPASSINPUT = 566, /* ISUBPASSINPUT */
ISUBPASSINPUTMS = 567, /* ISUBPASSINPUTMS */
USUBPASSINPUT = 568, /* USUBPASSINPUT */
USUBPASSINPUTMS = 569, /* USUBPASSINPUTMS */
F16SUBPASSINPUT = 570, /* F16SUBPASSINPUT */
F16SUBPASSINPUTMS = 571, /* F16SUBPASSINPUTMS */
SPIRV_INSTRUCTION = 572, /* SPIRV_INSTRUCTION */
SPIRV_EXECUTION_MODE = 573, /* SPIRV_EXECUTION_MODE */
SPIRV_EXECUTION_MODE_ID = 574, /* SPIRV_EXECUTION_MODE_ID */
SPIRV_DECORATE = 575, /* SPIRV_DECORATE */
SPIRV_DECORATE_ID = 576, /* SPIRV_DECORATE_ID */
SPIRV_DECORATE_STRING = 577, /* SPIRV_DECORATE_STRING */
SPIRV_TYPE = 578, /* SPIRV_TYPE */
SPIRV_STORAGE_CLASS = 579, /* SPIRV_STORAGE_CLASS */
SPIRV_BY_REFERENCE = 580, /* SPIRV_BY_REFERENCE */
SPIRV_LITERAL = 581, /* SPIRV_LITERAL */
LEFT_OP = 582, /* LEFT_OP */
RIGHT_OP = 583, /* RIGHT_OP */
INC_OP = 584, /* INC_OP */
DEC_OP = 585, /* DEC_OP */
LE_OP = 586, /* LE_OP */
GE_OP = 587, /* GE_OP */
EQ_OP = 588, /* EQ_OP */
NE_OP = 589, /* NE_OP */
AND_OP = 590, /* AND_OP */
OR_OP = 591, /* OR_OP */
XOR_OP = 592, /* XOR_OP */
MUL_ASSIGN = 593, /* MUL_ASSIGN */
DIV_ASSIGN = 594, /* DIV_ASSIGN */
ADD_ASSIGN = 595, /* ADD_ASSIGN */
MOD_ASSIGN = 596, /* MOD_ASSIGN */
LEFT_ASSIGN = 597, /* LEFT_ASSIGN */
RIGHT_ASSIGN = 598, /* RIGHT_ASSIGN */
AND_ASSIGN = 599, /* AND_ASSIGN */
XOR_ASSIGN = 600, /* XOR_ASSIGN */
OR_ASSIGN = 601, /* OR_ASSIGN */
SUB_ASSIGN = 602, /* SUB_ASSIGN */
STRING_LITERAL = 603, /* STRING_LITERAL */
LEFT_PAREN = 604, /* LEFT_PAREN */
RIGHT_PAREN = 605, /* RIGHT_PAREN */
LEFT_BRACKET = 606, /* LEFT_BRACKET */
RIGHT_BRACKET = 607, /* RIGHT_BRACKET */
LEFT_BRACE = 608, /* LEFT_BRACE */
RIGHT_BRACE = 609, /* RIGHT_BRACE */
DOT = 610, /* DOT */
COMMA = 611, /* COMMA */
COLON = 612, /* COLON */
EQUAL = 613, /* EQUAL */
SEMICOLON = 614, /* SEMICOLON */
BANG = 615, /* BANG */
DASH = 616, /* DASH */
TILDE = 617, /* TILDE */
PLUS = 618, /* PLUS */
STAR = 619, /* STAR */
SLASH = 620, /* SLASH */
PERCENT = 621, /* PERCENT */
LEFT_ANGLE = 622, /* LEFT_ANGLE */
RIGHT_ANGLE = 623, /* RIGHT_ANGLE */
VERTICAL_BAR = 624, /* VERTICAL_BAR */
CARET = 625, /* CARET */
AMPERSAND = 626, /* AMPERSAND */
QUESTION = 627, /* QUESTION */
INVARIANT = 628, /* INVARIANT */
HIGH_PRECISION = 629, /* HIGH_PRECISION */
MEDIUM_PRECISION = 630, /* MEDIUM_PRECISION */
LOW_PRECISION = 631, /* LOW_PRECISION */
PRECISION = 632, /* PRECISION */
PACKED = 633, /* PACKED */
RESOURCE = 634, /* RESOURCE */
SUPERP = 635, /* SUPERP */
FLOATCONSTANT = 636, /* FLOATCONSTANT */
INTCONSTANT = 637, /* INTCONSTANT */
UINTCONSTANT = 638, /* UINTCONSTANT */
BOOLCONSTANT = 639, /* BOOLCONSTANT */
IDENTIFIER = 640, /* IDENTIFIER */
TYPE_NAME = 641, /* TYPE_NAME */
CENTROID = 642, /* CENTROID */
IN = 643, /* IN */
OUT = 644, /* OUT */
INOUT = 645, /* INOUT */
STRUCT = 646, /* STRUCT */
VOID = 647, /* VOID */
WHILE = 648, /* WHILE */
BREAK = 649, /* BREAK */
CONTINUE = 650, /* CONTINUE */
DO = 651, /* DO */
ELSE = 652, /* ELSE */
FOR = 653, /* FOR */
IF = 654, /* IF */
DISCARD = 655, /* DISCARD */
RETURN = 656, /* RETURN */
SWITCH = 657, /* SWITCH */
CASE = 658, /* CASE */
DEFAULT = 659, /* DEFAULT */
TERMINATE_INVOCATION = 660, /* TERMINATE_INVOCATION */
TERMINATE_RAY = 661, /* TERMINATE_RAY */
IGNORE_INTERSECTION = 662, /* IGNORE_INTERSECTION */
UNIFORM = 663, /* UNIFORM */
SHARED = 664, /* SHARED */
BUFFER = 665, /* BUFFER */
FLAT = 666, /* FLAT */
SMOOTH = 667, /* SMOOTH */
LAYOUT = 668, /* LAYOUT */
DOUBLECONSTANT = 669, /* DOUBLECONSTANT */
INT16CONSTANT = 670, /* INT16CONSTANT */
UINT16CONSTANT = 671, /* UINT16CONSTANT */
FLOAT16CONSTANT = 672, /* FLOAT16CONSTANT */
INT32CONSTANT = 673, /* INT32CONSTANT */
UINT32CONSTANT = 674, /* UINT32CONSTANT */
INT64CONSTANT = 675, /* INT64CONSTANT */
UINT64CONSTANT = 676, /* UINT64CONSTANT */
SUBROUTINE = 677, /* SUBROUTINE */
DEMOTE = 678, /* DEMOTE */
PAYLOADNV = 679, /* PAYLOADNV */
PAYLOADINNV = 680, /* PAYLOADINNV */
HITATTRNV = 681, /* HITATTRNV */
CALLDATANV = 682, /* CALLDATANV */
CALLDATAINNV = 683, /* CALLDATAINNV */
PAYLOADEXT = 684, /* PAYLOADEXT */
PAYLOADINEXT = 685, /* PAYLOADINEXT */
HITATTREXT = 686, /* HITATTREXT */
CALLDATAEXT = 687, /* CALLDATAEXT */
CALLDATAINEXT = 688, /* CALLDATAINEXT */
PATCH = 689, /* PATCH */
SAMPLE = 690, /* SAMPLE */
NONUNIFORM = 691, /* NONUNIFORM */
COHERENT = 692, /* COHERENT */
VOLATILE = 693, /* VOLATILE */
RESTRICT = 694, /* RESTRICT */
READONLY = 695, /* READONLY */
WRITEONLY = 696, /* WRITEONLY */
DEVICECOHERENT = 697, /* DEVICECOHERENT */
QUEUEFAMILYCOHERENT = 698, /* QUEUEFAMILYCOHERENT */
WORKGROUPCOHERENT = 699, /* WORKGROUPCOHERENT */
SUBGROUPCOHERENT = 700, /* SUBGROUPCOHERENT */
NONPRIVATE = 701, /* NONPRIVATE */
SHADERCALLCOHERENT = 702, /* SHADERCALLCOHERENT */
NOPERSPECTIVE = 703, /* NOPERSPECTIVE */
EXPLICITINTERPAMD = 704, /* EXPLICITINTERPAMD */
PERVERTEXNV = 705, /* PERVERTEXNV */
PERPRIMITIVENV = 706, /* PERPRIMITIVENV */
PERVIEWNV = 707, /* PERVIEWNV */
PERTASKNV = 708, /* PERTASKNV */
PRECISE = 709 /* PRECISE */
COOPMAT = 421, /* COOPMAT */
HITOBJECTNV = 422, /* HITOBJECTNV */
HITOBJECTATTRNV = 423, /* HITOBJECTATTRNV */
SAMPLERCUBEARRAY = 424, /* SAMPLERCUBEARRAY */
SAMPLERCUBEARRAYSHADOW = 425, /* SAMPLERCUBEARRAYSHADOW */
ISAMPLERCUBEARRAY = 426, /* ISAMPLERCUBEARRAY */
USAMPLERCUBEARRAY = 427, /* USAMPLERCUBEARRAY */
SAMPLER1D = 428, /* SAMPLER1D */
SAMPLER1DARRAY = 429, /* SAMPLER1DARRAY */
SAMPLER1DARRAYSHADOW = 430, /* SAMPLER1DARRAYSHADOW */
ISAMPLER1D = 431, /* ISAMPLER1D */
SAMPLER1DSHADOW = 432, /* SAMPLER1DSHADOW */
SAMPLER2DRECT = 433, /* SAMPLER2DRECT */
SAMPLER2DRECTSHADOW = 434, /* SAMPLER2DRECTSHADOW */
ISAMPLER2DRECT = 435, /* ISAMPLER2DRECT */
USAMPLER2DRECT = 436, /* USAMPLER2DRECT */
SAMPLERBUFFER = 437, /* SAMPLERBUFFER */
ISAMPLERBUFFER = 438, /* ISAMPLERBUFFER */
USAMPLERBUFFER = 439, /* USAMPLERBUFFER */
SAMPLER2DMS = 440, /* SAMPLER2DMS */
ISAMPLER2DMS = 441, /* ISAMPLER2DMS */
USAMPLER2DMS = 442, /* USAMPLER2DMS */
SAMPLER2DMSARRAY = 443, /* SAMPLER2DMSARRAY */
ISAMPLER2DMSARRAY = 444, /* ISAMPLER2DMSARRAY */
USAMPLER2DMSARRAY = 445, /* USAMPLER2DMSARRAY */
SAMPLEREXTERNALOES = 446, /* SAMPLEREXTERNALOES */
SAMPLEREXTERNAL2DY2YEXT = 447, /* SAMPLEREXTERNAL2DY2YEXT */
ISAMPLER1DARRAY = 448, /* ISAMPLER1DARRAY */
USAMPLER1D = 449, /* USAMPLER1D */
USAMPLER1DARRAY = 450, /* USAMPLER1DARRAY */
F16SAMPLER1D = 451, /* F16SAMPLER1D */
F16SAMPLER2D = 452, /* F16SAMPLER2D */
F16SAMPLER3D = 453, /* F16SAMPLER3D */
F16SAMPLER2DRECT = 454, /* F16SAMPLER2DRECT */
F16SAMPLERCUBE = 455, /* F16SAMPLERCUBE */
F16SAMPLER1DARRAY = 456, /* F16SAMPLER1DARRAY */
F16SAMPLER2DARRAY = 457, /* F16SAMPLER2DARRAY */
F16SAMPLERCUBEARRAY = 458, /* F16SAMPLERCUBEARRAY */
F16SAMPLERBUFFER = 459, /* F16SAMPLERBUFFER */
F16SAMPLER2DMS = 460, /* F16SAMPLER2DMS */
F16SAMPLER2DMSARRAY = 461, /* F16SAMPLER2DMSARRAY */
F16SAMPLER1DSHADOW = 462, /* F16SAMPLER1DSHADOW */
F16SAMPLER2DSHADOW = 463, /* F16SAMPLER2DSHADOW */
F16SAMPLER1DARRAYSHADOW = 464, /* F16SAMPLER1DARRAYSHADOW */
F16SAMPLER2DARRAYSHADOW = 465, /* F16SAMPLER2DARRAYSHADOW */
F16SAMPLER2DRECTSHADOW = 466, /* F16SAMPLER2DRECTSHADOW */
F16SAMPLERCUBESHADOW = 467, /* F16SAMPLERCUBESHADOW */
F16SAMPLERCUBEARRAYSHADOW = 468, /* F16SAMPLERCUBEARRAYSHADOW */
IMAGE1D = 469, /* IMAGE1D */
IIMAGE1D = 470, /* IIMAGE1D */
UIMAGE1D = 471, /* UIMAGE1D */
IMAGE2D = 472, /* IMAGE2D */
IIMAGE2D = 473, /* IIMAGE2D */
UIMAGE2D = 474, /* UIMAGE2D */
IMAGE3D = 475, /* IMAGE3D */
IIMAGE3D = 476, /* IIMAGE3D */
UIMAGE3D = 477, /* UIMAGE3D */
IMAGE2DRECT = 478, /* IMAGE2DRECT */
IIMAGE2DRECT = 479, /* IIMAGE2DRECT */
UIMAGE2DRECT = 480, /* UIMAGE2DRECT */
IMAGECUBE = 481, /* IMAGECUBE */
IIMAGECUBE = 482, /* IIMAGECUBE */
UIMAGECUBE = 483, /* UIMAGECUBE */
IMAGEBUFFER = 484, /* IMAGEBUFFER */
IIMAGEBUFFER = 485, /* IIMAGEBUFFER */
UIMAGEBUFFER = 486, /* UIMAGEBUFFER */
IMAGE1DARRAY = 487, /* IMAGE1DARRAY */
IIMAGE1DARRAY = 488, /* IIMAGE1DARRAY */
UIMAGE1DARRAY = 489, /* UIMAGE1DARRAY */
IMAGE2DARRAY = 490, /* IMAGE2DARRAY */
IIMAGE2DARRAY = 491, /* IIMAGE2DARRAY */
UIMAGE2DARRAY = 492, /* UIMAGE2DARRAY */
IMAGECUBEARRAY = 493, /* IMAGECUBEARRAY */
IIMAGECUBEARRAY = 494, /* IIMAGECUBEARRAY */
UIMAGECUBEARRAY = 495, /* UIMAGECUBEARRAY */
IMAGE2DMS = 496, /* IMAGE2DMS */
IIMAGE2DMS = 497, /* IIMAGE2DMS */
UIMAGE2DMS = 498, /* UIMAGE2DMS */
IMAGE2DMSARRAY = 499, /* IMAGE2DMSARRAY */
IIMAGE2DMSARRAY = 500, /* IIMAGE2DMSARRAY */
UIMAGE2DMSARRAY = 501, /* UIMAGE2DMSARRAY */
F16IMAGE1D = 502, /* F16IMAGE1D */
F16IMAGE2D = 503, /* F16IMAGE2D */
F16IMAGE3D = 504, /* F16IMAGE3D */
F16IMAGE2DRECT = 505, /* F16IMAGE2DRECT */
F16IMAGECUBE = 506, /* F16IMAGECUBE */
F16IMAGE1DARRAY = 507, /* F16IMAGE1DARRAY */
F16IMAGE2DARRAY = 508, /* F16IMAGE2DARRAY */
F16IMAGECUBEARRAY = 509, /* F16IMAGECUBEARRAY */
F16IMAGEBUFFER = 510, /* F16IMAGEBUFFER */
F16IMAGE2DMS = 511, /* F16IMAGE2DMS */
F16IMAGE2DMSARRAY = 512, /* F16IMAGE2DMSARRAY */
I64IMAGE1D = 513, /* I64IMAGE1D */
U64IMAGE1D = 514, /* U64IMAGE1D */
I64IMAGE2D = 515, /* I64IMAGE2D */
U64IMAGE2D = 516, /* U64IMAGE2D */
I64IMAGE3D = 517, /* I64IMAGE3D */
U64IMAGE3D = 518, /* U64IMAGE3D */
I64IMAGE2DRECT = 519, /* I64IMAGE2DRECT */
U64IMAGE2DRECT = 520, /* U64IMAGE2DRECT */
I64IMAGECUBE = 521, /* I64IMAGECUBE */
U64IMAGECUBE = 522, /* U64IMAGECUBE */
I64IMAGEBUFFER = 523, /* I64IMAGEBUFFER */
U64IMAGEBUFFER = 524, /* U64IMAGEBUFFER */
I64IMAGE1DARRAY = 525, /* I64IMAGE1DARRAY */
U64IMAGE1DARRAY = 526, /* U64IMAGE1DARRAY */
I64IMAGE2DARRAY = 527, /* I64IMAGE2DARRAY */
U64IMAGE2DARRAY = 528, /* U64IMAGE2DARRAY */
I64IMAGECUBEARRAY = 529, /* I64IMAGECUBEARRAY */
U64IMAGECUBEARRAY = 530, /* U64IMAGECUBEARRAY */
I64IMAGE2DMS = 531, /* I64IMAGE2DMS */
U64IMAGE2DMS = 532, /* U64IMAGE2DMS */
I64IMAGE2DMSARRAY = 533, /* I64IMAGE2DMSARRAY */
U64IMAGE2DMSARRAY = 534, /* U64IMAGE2DMSARRAY */
TEXTURECUBEARRAY = 535, /* TEXTURECUBEARRAY */
ITEXTURECUBEARRAY = 536, /* ITEXTURECUBEARRAY */
UTEXTURECUBEARRAY = 537, /* UTEXTURECUBEARRAY */
TEXTURE1D = 538, /* TEXTURE1D */
ITEXTURE1D = 539, /* ITEXTURE1D */
UTEXTURE1D = 540, /* UTEXTURE1D */
TEXTURE1DARRAY = 541, /* TEXTURE1DARRAY */
ITEXTURE1DARRAY = 542, /* ITEXTURE1DARRAY */
UTEXTURE1DARRAY = 543, /* UTEXTURE1DARRAY */
TEXTURE2DRECT = 544, /* TEXTURE2DRECT */
ITEXTURE2DRECT = 545, /* ITEXTURE2DRECT */
UTEXTURE2DRECT = 546, /* UTEXTURE2DRECT */
TEXTUREBUFFER = 547, /* TEXTUREBUFFER */
ITEXTUREBUFFER = 548, /* ITEXTUREBUFFER */
UTEXTUREBUFFER = 549, /* UTEXTUREBUFFER */
TEXTURE2DMS = 550, /* TEXTURE2DMS */
ITEXTURE2DMS = 551, /* ITEXTURE2DMS */
UTEXTURE2DMS = 552, /* UTEXTURE2DMS */
TEXTURE2DMSARRAY = 553, /* TEXTURE2DMSARRAY */
ITEXTURE2DMSARRAY = 554, /* ITEXTURE2DMSARRAY */
UTEXTURE2DMSARRAY = 555, /* UTEXTURE2DMSARRAY */
F16TEXTURE1D = 556, /* F16TEXTURE1D */
F16TEXTURE2D = 557, /* F16TEXTURE2D */
F16TEXTURE3D = 558, /* F16TEXTURE3D */
F16TEXTURE2DRECT = 559, /* F16TEXTURE2DRECT */
F16TEXTURECUBE = 560, /* F16TEXTURECUBE */
F16TEXTURE1DARRAY = 561, /* F16TEXTURE1DARRAY */
F16TEXTURE2DARRAY = 562, /* F16TEXTURE2DARRAY */
F16TEXTURECUBEARRAY = 563, /* F16TEXTURECUBEARRAY */
F16TEXTUREBUFFER = 564, /* F16TEXTUREBUFFER */
F16TEXTURE2DMS = 565, /* F16TEXTURE2DMS */
F16TEXTURE2DMSARRAY = 566, /* F16TEXTURE2DMSARRAY */
SUBPASSINPUT = 567, /* SUBPASSINPUT */
SUBPASSINPUTMS = 568, /* SUBPASSINPUTMS */
ISUBPASSINPUT = 569, /* ISUBPASSINPUT */
ISUBPASSINPUTMS = 570, /* ISUBPASSINPUTMS */
USUBPASSINPUT = 571, /* USUBPASSINPUT */
USUBPASSINPUTMS = 572, /* USUBPASSINPUTMS */
F16SUBPASSINPUT = 573, /* F16SUBPASSINPUT */
F16SUBPASSINPUTMS = 574, /* F16SUBPASSINPUTMS */
SPIRV_INSTRUCTION = 575, /* SPIRV_INSTRUCTION */
SPIRV_EXECUTION_MODE = 576, /* SPIRV_EXECUTION_MODE */
SPIRV_EXECUTION_MODE_ID = 577, /* SPIRV_EXECUTION_MODE_ID */
SPIRV_DECORATE = 578, /* SPIRV_DECORATE */
SPIRV_DECORATE_ID = 579, /* SPIRV_DECORATE_ID */
SPIRV_DECORATE_STRING = 580, /* SPIRV_DECORATE_STRING */
SPIRV_TYPE = 581, /* SPIRV_TYPE */
SPIRV_STORAGE_CLASS = 582, /* SPIRV_STORAGE_CLASS */
SPIRV_BY_REFERENCE = 583, /* SPIRV_BY_REFERENCE */
SPIRV_LITERAL = 584, /* SPIRV_LITERAL */
ATTACHMENTEXT = 585, /* ATTACHMENTEXT */
IATTACHMENTEXT = 586, /* IATTACHMENTEXT */
UATTACHMENTEXT = 587, /* UATTACHMENTEXT */
LEFT_OP = 588, /* LEFT_OP */
RIGHT_OP = 589, /* RIGHT_OP */
INC_OP = 590, /* INC_OP */
DEC_OP = 591, /* DEC_OP */
LE_OP = 592, /* LE_OP */
GE_OP = 593, /* GE_OP */
EQ_OP = 594, /* EQ_OP */
NE_OP = 595, /* NE_OP */
AND_OP = 596, /* AND_OP */
OR_OP = 597, /* OR_OP */
XOR_OP = 598, /* XOR_OP */
MUL_ASSIGN = 599, /* MUL_ASSIGN */
DIV_ASSIGN = 600, /* DIV_ASSIGN */
ADD_ASSIGN = 601, /* ADD_ASSIGN */
MOD_ASSIGN = 602, /* MOD_ASSIGN */
LEFT_ASSIGN = 603, /* LEFT_ASSIGN */
RIGHT_ASSIGN = 604, /* RIGHT_ASSIGN */
AND_ASSIGN = 605, /* AND_ASSIGN */
XOR_ASSIGN = 606, /* XOR_ASSIGN */
OR_ASSIGN = 607, /* OR_ASSIGN */
SUB_ASSIGN = 608, /* SUB_ASSIGN */
STRING_LITERAL = 609, /* STRING_LITERAL */
LEFT_PAREN = 610, /* LEFT_PAREN */
RIGHT_PAREN = 611, /* RIGHT_PAREN */
LEFT_BRACKET = 612, /* LEFT_BRACKET */
RIGHT_BRACKET = 613, /* RIGHT_BRACKET */
LEFT_BRACE = 614, /* LEFT_BRACE */
RIGHT_BRACE = 615, /* RIGHT_BRACE */
DOT = 616, /* DOT */
COMMA = 617, /* COMMA */
COLON = 618, /* COLON */
EQUAL = 619, /* EQUAL */
SEMICOLON = 620, /* SEMICOLON */
BANG = 621, /* BANG */
DASH = 622, /* DASH */
TILDE = 623, /* TILDE */
PLUS = 624, /* PLUS */
STAR = 625, /* STAR */
SLASH = 626, /* SLASH */
PERCENT = 627, /* PERCENT */
LEFT_ANGLE = 628, /* LEFT_ANGLE */
RIGHT_ANGLE = 629, /* RIGHT_ANGLE */
VERTICAL_BAR = 630, /* VERTICAL_BAR */
CARET = 631, /* CARET */
AMPERSAND = 632, /* AMPERSAND */
QUESTION = 633, /* QUESTION */
INVARIANT = 634, /* INVARIANT */
HIGH_PRECISION = 635, /* HIGH_PRECISION */
MEDIUM_PRECISION = 636, /* MEDIUM_PRECISION */
LOW_PRECISION = 637, /* LOW_PRECISION */
PRECISION = 638, /* PRECISION */
PACKED = 639, /* PACKED */
RESOURCE = 640, /* RESOURCE */
SUPERP = 641, /* SUPERP */
FLOATCONSTANT = 642, /* FLOATCONSTANT */
INTCONSTANT = 643, /* INTCONSTANT */
UINTCONSTANT = 644, /* UINTCONSTANT */
BOOLCONSTANT = 645, /* BOOLCONSTANT */
IDENTIFIER = 646, /* IDENTIFIER */
TYPE_NAME = 647, /* TYPE_NAME */
CENTROID = 648, /* CENTROID */
IN = 649, /* IN */
OUT = 650, /* OUT */
INOUT = 651, /* INOUT */
STRUCT = 652, /* STRUCT */
VOID = 653, /* VOID */
WHILE = 654, /* WHILE */
BREAK = 655, /* BREAK */
CONTINUE = 656, /* CONTINUE */
DO = 657, /* DO */
ELSE = 658, /* ELSE */
FOR = 659, /* FOR */
IF = 660, /* IF */
DISCARD = 661, /* DISCARD */
RETURN = 662, /* RETURN */
SWITCH = 663, /* SWITCH */
CASE = 664, /* CASE */
DEFAULT = 665, /* DEFAULT */
TERMINATE_INVOCATION = 666, /* TERMINATE_INVOCATION */
TERMINATE_RAY = 667, /* TERMINATE_RAY */
IGNORE_INTERSECTION = 668, /* IGNORE_INTERSECTION */
UNIFORM = 669, /* UNIFORM */
SHARED = 670, /* SHARED */
BUFFER = 671, /* BUFFER */
TILEIMAGEEXT = 672, /* TILEIMAGEEXT */
FLAT = 673, /* FLAT */
SMOOTH = 674, /* SMOOTH */
LAYOUT = 675, /* LAYOUT */
DOUBLECONSTANT = 676, /* DOUBLECONSTANT */
INT16CONSTANT = 677, /* INT16CONSTANT */
UINT16CONSTANT = 678, /* UINT16CONSTANT */
FLOAT16CONSTANT = 679, /* FLOAT16CONSTANT */
INT32CONSTANT = 680, /* INT32CONSTANT */
UINT32CONSTANT = 681, /* UINT32CONSTANT */
INT64CONSTANT = 682, /* INT64CONSTANT */
UINT64CONSTANT = 683, /* UINT64CONSTANT */
SUBROUTINE = 684, /* SUBROUTINE */
DEMOTE = 685, /* DEMOTE */
PAYLOADNV = 686, /* PAYLOADNV */
PAYLOADINNV = 687, /* PAYLOADINNV */
HITATTRNV = 688, /* HITATTRNV */
CALLDATANV = 689, /* CALLDATANV */
CALLDATAINNV = 690, /* CALLDATAINNV */
PAYLOADEXT = 691, /* PAYLOADEXT */
PAYLOADINEXT = 692, /* PAYLOADINEXT */
HITATTREXT = 693, /* HITATTREXT */
CALLDATAEXT = 694, /* CALLDATAEXT */
CALLDATAINEXT = 695, /* CALLDATAINEXT */
PATCH = 696, /* PATCH */
SAMPLE = 697, /* SAMPLE */
NONUNIFORM = 698, /* NONUNIFORM */
COHERENT = 699, /* COHERENT */
VOLATILE = 700, /* VOLATILE */
RESTRICT = 701, /* RESTRICT */
READONLY = 702, /* READONLY */
WRITEONLY = 703, /* WRITEONLY */
DEVICECOHERENT = 704, /* DEVICECOHERENT */
QUEUEFAMILYCOHERENT = 705, /* QUEUEFAMILYCOHERENT */
WORKGROUPCOHERENT = 706, /* WORKGROUPCOHERENT */
SUBGROUPCOHERENT = 707, /* SUBGROUPCOHERENT */
NONPRIVATE = 708, /* NONPRIVATE */
SHADERCALLCOHERENT = 709, /* SHADERCALLCOHERENT */
NOPERSPECTIVE = 710, /* NOPERSPECTIVE */
EXPLICITINTERPAMD = 711, /* EXPLICITINTERPAMD */
PERVERTEXEXT = 712, /* PERVERTEXEXT */
PERVERTEXNV = 713, /* PERVERTEXNV */
PERPRIMITIVENV = 714, /* PERPRIMITIVENV */
PERVIEWNV = 715, /* PERVIEWNV */
PERTASKNV = 716, /* PERTASKNV */
PERPRIMITIVEEXT = 717, /* PERPRIMITIVEEXT */
TASKPAYLOADWORKGROUPEXT = 718, /* TASKPAYLOADWORKGROUPEXT */
PRECISE = 719 /* PRECISE */
};
typedef enum yytokentype yytoken_kind_t;
#endif
@@ -514,7 +524,7 @@ extern int yydebug;
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
union YYSTYPE
{
#line 97 "MachineIndependent/glslang.y"
#line 72 "MachineIndependent/glslang.y"
struct {
glslang::TSourceLoc loc;
@@ -550,10 +560,10 @@ union YYSTYPE
glslang::TArraySizes* arraySizes;
glslang::TIdentifierList* identifierList;
};
glslang::TArraySizes* typeParameters;
glslang::TTypeParameters* typeParameters;
} interm;
#line 557 "MachineIndependent/glslang_tab.cpp.h"
#line 567 "MachineIndependent/glslang_tab.cpp.h"
};
typedef union YYSTYPE YYSTYPE;
@@ -563,6 +573,8 @@ typedef union YYSTYPE YYSTYPE;
int yyparse (glslang::TParseContext* pParseContext);
#endif /* !YY_YY_MACHINEINDEPENDENT_GLSLANG_TAB_CPP_H_INCLUDED */
@@ -36,8 +36,6 @@
// POSSIBILITY OF SUCH DAMAGE.
//
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
#include "localintermediate.h"
#include "../Include/InfoSink.h"
@@ -663,11 +661,13 @@ bool TOutputTraverser::visitUnary(TVisit /* visit */, TIntermUnary* node)
case EOpSubpassLoad: out.debug << "subpassLoad"; break;
case EOpSubpassLoadMS: out.debug << "subpassLoadMS"; break;
case EOpColorAttachmentReadEXT: out.debug << "colorAttachmentReadEXT"; break;
case EOpConstructReference: out.debug << "Construct reference type"; break;
#ifndef GLSLANG_WEB
case EOpDeclare: out.debug << "Declare"; break;
case EOpSpirvInst: out.debug << "spirv_instruction"; break;
#endif
default: out.debug.message(EPrefixError, "Bad unary op");
}
@@ -692,6 +692,7 @@ bool TOutputTraverser::visitAggregate(TVisit /* visit */, TIntermAggregate* node
switch (node->getOp()) {
case EOpSequence: out.debug << "Sequence\n"; return true;
case EOpScope: out.debug << "Scope\n"; return true;
case EOpLinkerObjects: out.debug << "Linker Objects\n"; return true;
case EOpComma: out.debug << "Comma"; break;
case EOpFunction: out.debug << "Function Definition: " << node->getName(); break;
@@ -804,7 +805,8 @@ bool TOutputTraverser::visitAggregate(TVisit /* visit */, TIntermAggregate* node
case EOpConstructStruct: out.debug << "Construct structure"; break;
case EOpConstructTextureSampler: out.debug << "Construct combined texture-sampler"; break;
case EOpConstructReference: out.debug << "Construct reference"; break;
case EOpConstructCooperativeMatrix: out.debug << "Construct cooperative matrix"; break;
case EOpConstructCooperativeMatrixNV: out.debug << "Construct cooperative matrix NV"; break;
case EOpConstructCooperativeMatrixKHR: out.debug << "Construct cooperative matrix KHR"; break;
case EOpConstructAccStruct: out.debug << "Construct acceleration structure"; break;
case EOpLessThan: out.debug << "Compare Less Than"; break;
@@ -1057,6 +1059,8 @@ bool TOutputTraverser::visitAggregate(TVisit /* visit */, TIntermAggregate* node
case EOpSubpassLoad: out.debug << "subpassLoad"; break;
case EOpSubpassLoadMS: out.debug << "subpassLoadMS"; break;
case EOpColorAttachmentReadEXT: out.debug << "colorAttachmentReadEXT"; break;
case EOpTraceNV: out.debug << "traceNV"; break;
case EOpTraceRayMotionNV: out.debug << "traceRayMotionNV"; break;
case EOpTraceKHR: out.debug << "traceRayKHR"; break;
@@ -1068,6 +1072,8 @@ bool TOutputTraverser::visitAggregate(TVisit /* visit */, TIntermAggregate* node
case EOpExecuteCallableNV: out.debug << "executeCallableNV"; break;
case EOpExecuteCallableKHR: out.debug << "executeCallableKHR"; break;
case EOpWritePackedPrimitiveIndices4x8NV: out.debug << "writePackedPrimitiveIndices4x8NV"; break;
case EOpEmitMeshTasksEXT: out.debug << "EmitMeshTasksEXT"; break;
case EOpSetMeshOutputsEXT: out.debug << "SetMeshOutputsEXT"; break;
case EOpRayQueryInitialize: out.debug << "rayQueryInitializeEXT"; break;
case EOpRayQueryTerminate: out.debug << "rayQueryTerminateEXT"; break;
@@ -1092,22 +1098,60 @@ bool TOutputTraverser::visitAggregate(TVisit /* visit */, TIntermAggregate* node
case EOpRayQueryGetWorldRayOrigin: out.debug << "rayQueryGetWorldRayOriginEXT"; break;
case EOpRayQueryGetIntersectionObjectToWorld: out.debug << "rayQueryGetIntersectionObjectToWorldEXT"; break;
case EOpRayQueryGetIntersectionWorldToObject: out.debug << "rayQueryGetIntersectionWorldToObjectEXT"; break;
case EOpRayQueryGetIntersectionTriangleVertexPositionsEXT: out.debug << "rayQueryGetIntersectionTriangleVertexPositionsEXT"; break;
case EOpCooperativeMatrixLoad: out.debug << "Load cooperative matrix"; break;
case EOpCooperativeMatrixStore: out.debug << "Store cooperative matrix"; break;
case EOpCooperativeMatrixMulAdd: out.debug << "MulAdd cooperative matrices"; break;
case EOpCooperativeMatrixLoad: out.debug << "Load cooperative matrix KHR"; break;
case EOpCooperativeMatrixStore: out.debug << "Store cooperative matrix KHR"; break;
case EOpCooperativeMatrixMulAdd: out.debug << "MulAdd cooperative matrices KHR"; break;
case EOpCooperativeMatrixLoadNV: out.debug << "Load cooperative matrix NV"; break;
case EOpCooperativeMatrixStoreNV: out.debug << "Store cooperative matrix NV"; break;
case EOpCooperativeMatrixMulAddNV: out.debug << "MulAdd cooperative matrices NV"; break;
case EOpIsHelperInvocation: out.debug << "IsHelperInvocation"; break;
case EOpDebugPrintf: out.debug << "Debug printf"; break;
#ifndef GLSLANG_WEB
case EOpHitObjectTraceRayNV: out.debug << "HitObjectTraceRayNV"; break;
case EOpHitObjectTraceRayMotionNV: out.debug << "HitObjectTraceRayMotionNV"; break;
case EOpHitObjectRecordHitNV: out.debug << "HitObjectRecordHitNV"; break;
case EOpHitObjectRecordHitMotionNV: out.debug << "HitObjectRecordHitMotionNV"; break;
case EOpHitObjectRecordHitWithIndexNV: out.debug << "HitObjectRecordHitWithIndexNV"; break;
case EOpHitObjectRecordHitWithIndexMotionNV: out.debug << "HitObjectRecordHitWithIndexMotionNV"; break;
case EOpHitObjectRecordMissNV: out.debug << "HitObjectRecordMissNV"; break;
case EOpHitObjectRecordMissMotionNV: out.debug << "HitObjectRecordMissMotionNV"; break;
case EOpHitObjectRecordEmptyNV: out.debug << "HitObjectRecordEmptyNV"; break;
case EOpHitObjectExecuteShaderNV: out.debug << "HitObjectExecuteShaderNV"; break;
case EOpHitObjectIsEmptyNV: out.debug << "HitObjectIsEmptyNV"; break;
case EOpHitObjectIsMissNV: out.debug << "HitObjectIsMissNV"; break;
case EOpHitObjectIsHitNV: out.debug << "HitObjectIsHitNV"; break;
case EOpHitObjectGetRayTMinNV: out.debug << "HitObjectGetRayTMinNV"; break;
case EOpHitObjectGetRayTMaxNV: out.debug << "HitObjectGetRayTMaxNV"; break;
case EOpHitObjectGetObjectRayOriginNV: out.debug << "HitObjectGetObjectRayOriginNV"; break;
case EOpHitObjectGetObjectRayDirectionNV: out.debug << "HitObjectGetObjectRayDirectionNV"; break;
case EOpHitObjectGetWorldRayOriginNV: out.debug << "HitObjectGetWorldRayOriginNV"; break;
case EOpHitObjectGetWorldRayDirectionNV: out.debug << "HitObjectGetWorldRayDirectionNV"; break;
case EOpHitObjectGetObjectToWorldNV: out.debug << "HitObjectGetObjectToWorldNV"; break;
case EOpHitObjectGetWorldToObjectNV: out.debug << "HitObjectGetWorldToObjectNV"; break;
case EOpHitObjectGetInstanceCustomIndexNV: out.debug<< "HitObjectGetInstanceCustomIndexNV"; break;
case EOpHitObjectGetInstanceIdNV: out.debug << "HitObjectGetInstaneIdNV"; break;
case EOpHitObjectGetGeometryIndexNV: out.debug << "HitObjectGetGeometryIndexNV"; break;
case EOpHitObjectGetPrimitiveIndexNV: out.debug << "HitObjectGetPrimitiveIndexNV"; break;
case EOpHitObjectGetHitKindNV: out.debug << "HitObjectGetHitKindNV"; break;
case EOpHitObjectGetAttributesNV: out.debug << "HitObjectGetAttributesNV"; break;
case EOpHitObjectGetCurrentTimeNV: out.debug << "HitObjectGetCurrentTimeNV"; break;
case EOpHitObjectGetShaderBindingTableRecordIndexNV: out.debug << "HitObjectGetShaderBindingTableRecordIndexNV"; break;
case EOpHitObjectGetShaderRecordBufferHandleNV: out.debug << "HitObjectReadShaderRecordBufferHandleNV"; break;
case EOpReorderThreadNV: out.debug << "ReorderThreadNV"; break;
case EOpFetchMicroTriangleVertexPositionNV: out.debug << "MicroTriangleVertexPositionNV"; break;
case EOpFetchMicroTriangleVertexBarycentricNV: out.debug << "MicroTriangleVertexBarycentricNV"; break;
case EOpSpirvInst: out.debug << "spirv_instruction"; break;
#endif
case EOpStencilAttachmentReadEXT: out.debug << "stencilAttachmentReadEXT"; break;
case EOpDepthAttachmentReadEXT: out.debug << "depthAttachmentReadEXT"; break;
default: out.debug.message(EPrefixError, "Bad aggregation op");
}
if (node->getOp() != EOpSequence && node->getOp() != EOpParameters)
if (node->getOp() != EOpSequence && node->getOp() != EOpScope && node->getOp() != EOpParameters)
out.debug << " (" << node->getCompleteString() << ")";
out.debug << "\n";
@@ -1164,12 +1208,12 @@ bool TOutputTraverser::visitSelection(TVisit /* visit */, TIntermSelection* node
// - shows all digits, no premature rounding
static void OutputDouble(TInfoSink& out, double value, TOutputTraverser::EExtraOutput extra)
{
if (IsInfinity(value)) {
if (std::isinf(value)) {
if (value < 0)
out.debug << "-1.#INF";
else
out.debug << "+1.#INF";
} else if (IsNan(value))
} else if (std::isnan(value))
out.debug << "1.#IND";
else {
const int maxSize = 340;
@@ -1507,6 +1551,12 @@ void TIntermediate::output(TInfoSink& infoSink, bool tree)
infoSink.debug << "using early_fragment_tests\n";
if (postDepthCoverage)
infoSink.debug << "using post_depth_coverage\n";
if (nonCoherentColorAttachmentReadEXT)
infoSink.debug << "using non_coherent_color_attachment_readEXT\n";
if (nonCoherentDepthAttachmentReadEXT)
infoSink.debug << "using non_coherent_depth_attachment_readEXT\n";
if (nonCoherentStencilAttachmentReadEXT)
infoSink.debug << "using non_coherent_stencil_attachment_readEXT\n";
if (depthLayout != EldNone)
infoSink.debug << "using " << TQualifier::getLayoutDepthString(depthLayout) << "\n";
if (blendEquations != 0) {
@@ -1522,12 +1572,12 @@ void TIntermediate::output(TInfoSink& infoSink, bool tree)
infoSink.debug << "interlock ordering = " << TQualifier::getInterlockOrderingString(interlockOrdering) << "\n";
break;
case EShLangMeshNV:
case EShLangMesh:
infoSink.debug << "max_vertices = " << vertices << "\n";
infoSink.debug << "max_primitives = " << primitives << "\n";
infoSink.debug << "output primitive = " << TQualifier::getGeometryString(outputPrimitive) << "\n";
// Fall through
case EShLangTaskNV:
case EShLangTask:
// Fall through
case EShLangCompute:
infoSink.debug << "local_size = (" << localSize[0] << ", " << localSize[1] << ", " << localSize[2] << ")\n";
@@ -1547,7 +1597,7 @@ void TIntermediate::output(TInfoSink& infoSink, bool tree)
break;
}
if (treeRoot == 0 || ! tree)
if (treeRoot == nullptr || ! tree)
return;
TOutputTraverser it(infoSink);
@@ -1557,5 +1607,3 @@ void TIntermediate::output(TInfoSink& infoSink, bool tree)
}
} // end namespace glslang
#endif // !GLSLANG_WEB && !GLSLANG_ANGLE
@@ -33,8 +33,6 @@
// POSSIBILITY OF SUCH DAMAGE.
//
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
#include "../Include/Common.h"
#include "../Include/InfoSink.h"
#include "../Include/Types.h"
@@ -145,6 +143,8 @@ public:
base->getWritableType().getQualifier().layoutComponent = at->second.newComponent;
if (at->second.newIndex != -1)
base->getWritableType().getQualifier().layoutIndex = at->second.newIndex;
if (at->second.upgradedToPushConstant)
base->getWritableType().getQualifier().layoutPushConstant = true;
}
private:
@@ -203,11 +203,7 @@ struct TResolverUniformAdaptor {
inline void operator()(std::pair<const TString, TVarEntryInfo>& entKey) {
TVarEntryInfo& ent = entKey.second;
ent.newLocation = -1;
ent.newComponent = -1;
ent.newBinding = -1;
ent.newSet = -1;
ent.newIndex = -1;
ent.clearNewAssignments();
const bool isValid = resolver.validateBinding(stage, ent);
if (isValid) {
resolver.resolveSet(ent.stage, ent);
@@ -281,11 +277,7 @@ struct TResolverInOutAdaptor {
inline void operator()(std::pair<const TString, TVarEntryInfo>& entKey)
{
TVarEntryInfo& ent = entKey.second;
ent.newLocation = -1;
ent.newComponent = -1;
ent.newBinding = -1;
ent.newSet = -1;
ent.newIndex = -1;
ent.clearNewAssignments();
const bool isValid = resolver.validateInOut(ent.stage, ent);
if (isValid) {
resolver.resolveInOutLocation(stage, ent);
@@ -874,7 +866,7 @@ int TDefaultIoResolverBase::resolveInOutLocation(EShLanguage stage, TVarEntryInf
}
// no locations added if already present, a built-in variable, or a variable with SPIR-V decorate
if (type.getQualifier().hasLocation() || type.isBuiltIn() || type.getQualifier().hasSprivDecorate()) {
if (type.getQualifier().hasLocation() || type.isBuiltIn() || type.getQualifier().hasSpirvDecorate()) {
return ent.newLocation = -1;
}
@@ -961,7 +953,7 @@ int TDefaultGlslIoResolver::resolveInOutLocation(EShLanguage stage, TVarEntryInf
return ent.newLocation = type.getQualifier().layoutLocation;
}
// no locations added if already present, a built-in variable, or a variable with SPIR-V decorate
if (type.isBuiltIn() || type.getQualifier().hasSprivDecorate()) {
if (type.isBuiltIn() || type.getQualifier().hasSpirvDecorate()) {
return ent.newLocation = -1;
}
// no locations on blocks of built-in variables
@@ -1670,31 +1662,42 @@ bool TGlslIoMapper::doMap(TIoMapResolver* resolver, TInfoSink& infoSink) {
if (size <= int(autoPushConstantMaxSize)) {
qualifier.setBlockStorage(EbsPushConstant);
qualifier.layoutPacking = autoPushConstantBlockPacking;
// Push constants don't have set/binding etc. decorations, remove those.
qualifier.layoutSet = TQualifier::layoutSetEnd;
at->second.clearNewAssignments();
upgraded = true;
}
}
}
// If it's been upgraded to push_constant, then remove it from the uniformVector
// If it's been upgraded to push_constant, then set the flag so when its traversed
// in the next for loop, all references to this symbol will get their flag changed.
// so it doesn't get a set/binding assigned to it.
if (upgraded) {
auto at = std::find_if(uniformVector.begin(), uniformVector.end(),
[this](const TVarLivePair& p) { return p.first == autoPushConstantBlockName; });
if (at != uniformVector.end())
uniformVector.erase(at);
std::for_each(uniformVector.begin(), uniformVector.end(),
[this](TVarLivePair& p) {
if (p.first == autoPushConstantBlockName) {
p.second.upgradedToPushConstant = true;
}
});
}
}
for (size_t stage = 0; stage < EShLangCount; stage++) {
if (intermediates[stage] != nullptr) {
// traverse each stage, set new location to each input/output and unifom symbol, set new binding to
// ubo, ssbo and opaque symbols
// ubo, ssbo and opaque symbols. Assign push_constant upgrades as well.
TVarLiveMap** pUniformVarMap = uniformResolve.uniformVarMap;
std::for_each(uniformVector.begin(), uniformVector.end(), [pUniformVarMap, stage](TVarLivePair p) {
auto at = pUniformVarMap[stage]->find(p.second.symbol->getAccessName());
if (at != pUniformVarMap[stage]->end() && at->second.id == p.second.id){
int resolvedBinding = at->second.newBinding;
at->second = p.second;
if (resolvedBinding > 0)
at->second.newBinding = resolvedBinding;
if (p.second.upgradedToPushConstant) {
at->second.upgradedToPushConstant = true;
} else {
int resolvedBinding = at->second.newBinding;
at->second = p.second;
if (resolvedBinding > 0)
at->second.newBinding = resolvedBinding;
}
}
});
TVarSetTraverser iter_iomap(*intermediates[stage], *inVarMaps[stage], *outVarMaps[stage],
@@ -1709,5 +1712,3 @@ bool TGlslIoMapper::doMap(TIoMapResolver* resolver, TInfoSink& infoSink) {
}
} // end namespace glslang
#endif // !GLSLANG_WEB && !GLSLANG_ANGLE
@@ -33,8 +33,6 @@
// POSSIBILITY OF SUCH DAMAGE.
//
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
#ifndef _IOMAPPER_INCLUDED
#define _IOMAPPER_INCLUDED
@@ -55,12 +53,23 @@ struct TVarEntryInfo {
long long id;
TIntermSymbol* symbol;
bool live;
bool upgradedToPushConstant;
int newBinding;
int newSet;
int newLocation;
int newComponent;
int newIndex;
EShLanguage stage;
void clearNewAssignments() {
upgradedToPushConstant = false;
newBinding = -1;
newSet = -1;
newLocation = -1;
newComponent = -1;
newIndex = -1;
}
struct TOrderById {
inline bool operator()(const TVarEntryInfo& l, const TVarEntryInfo& r) { return l.id < r.id; }
};
@@ -348,5 +357,3 @@ private:
} // end namespace glslang
#endif // _IOMAPPER_INCLUDED
#endif // !GLSLANG_WEB && !GLSLANG_ANGLE
@@ -187,14 +187,12 @@ bool TIndexTraverser::visitAggregate(TVisit /* visit */, TIntermAggregate* node)
//
void TParseContext::constantIndexExpressionCheck(TIntermNode* index)
{
#ifndef GLSLANG_WEB
TIndexTraverser it(inductiveLoopIds);
index->traverse(&it);
if (it.bad)
error(it.badLoc, "Non-constant-index-expression", "limitations", "");
#endif
}
} // end namespace glslang
@@ -55,23 +55,25 @@ namespace glslang {
//
// Link-time error emitter.
//
void TIntermediate::error(TInfoSink& infoSink, const char* message)
void TIntermediate::error(TInfoSink& infoSink, const char* message, EShLanguage unitStage)
{
#ifndef GLSLANG_WEB
infoSink.info.prefix(EPrefixError);
infoSink.info << "Linking " << StageName(language) << " stage: " << message << "\n";
#endif
if (unitStage < EShLangCount)
infoSink.info << "Linking " << StageName(getStage()) << " and " << StageName(unitStage) << " stages: " << message << "\n";
else
infoSink.info << "Linking " << StageName(language) << " stage: " << message << "\n";
++numErrors;
}
// Link-time warning.
void TIntermediate::warn(TInfoSink& infoSink, const char* message)
void TIntermediate::warn(TInfoSink& infoSink, const char* message, EShLanguage unitStage)
{
#ifndef GLSLANG_WEB
infoSink.info.prefix(EPrefixWarning);
infoSink.info << "Linking " << StageName(language) << " stage: " << message << "\n";
#endif
if (unitStage < EShLangCount)
infoSink.info << "Linking " << StageName(language) << " and " << StageName(unitStage) << " stages: " << message << "\n";
else
infoSink.info << "Linking " << StageName(language) << " stage: " << message << "\n";
}
// TODO: 4.4 offset/align: "Two blocks linked together in the same program with the same block
@@ -83,11 +85,9 @@ void TIntermediate::warn(TInfoSink& infoSink, const char* message)
//
void TIntermediate::merge(TInfoSink& infoSink, TIntermediate& unit)
{
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
mergeCallGraphs(infoSink, unit);
mergeModes(infoSink, unit);
mergeTrees(infoSink, unit);
#endif
}
//
@@ -114,7 +114,7 @@ void TIntermediate::mergeUniformObjects(TInfoSink& infoSink, TIntermediate& unit
}
//
// do error checking on the shader boundary in / out vars
// do error checking on the shader boundary in / out vars
//
void TIntermediate::checkStageIO(TInfoSink& infoSink, TIntermediate& unit) {
if (unit.treeRoot == nullptr || treeRoot == nullptr)
@@ -155,8 +155,6 @@ void TIntermediate::mergeCallGraphs(TInfoSink& infoSink, TIntermediate& unit)
callGraph.insert(callGraph.end(), unit.callGraph.begin(), unit.callGraph.end());
}
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
#define MERGE_MAX(member) member = std::max(member, unit.member)
#define MERGE_TRUE(member) if (unit.member) member = unit.member;
@@ -206,7 +204,7 @@ void TIntermediate::mergeModes(TInfoSink& infoSink, TIntermediate& unit)
if (vertices == TQualifier::layoutNotSet)
vertices = unit.vertices;
else if (unit.vertices != TQualifier::layoutNotSet && vertices != unit.vertices) {
if (language == EShLangGeometry || language == EShLangMeshNV)
if (language == EShLangGeometry || language == EShLangMesh)
error(infoSink, "Contradictory layout max_vertices values");
else if (language == EShLangTessControl)
error(infoSink, "Contradictory layout vertices values");
@@ -216,7 +214,7 @@ void TIntermediate::mergeModes(TInfoSink& infoSink, TIntermediate& unit)
if (primitives == TQualifier::layoutNotSet)
primitives = unit.primitives;
else if (primitives != unit.primitives) {
if (language == EShLangMeshNV)
if (language == EShLangMesh)
error(infoSink, "Contradictory layout max_primitives values");
else
assert(0);
@@ -265,6 +263,9 @@ void TIntermediate::mergeModes(TInfoSink& infoSink, TIntermediate& unit)
MERGE_TRUE(earlyFragmentTests);
MERGE_TRUE(postDepthCoverage);
MERGE_TRUE(nonCoherentColorAttachmentReadEXT);
MERGE_TRUE(nonCoherentDepthAttachmentReadEXT);
MERGE_TRUE(nonCoherentStencilAttachmentReadEXT);
if (depthLayout == EldNone)
depthLayout = unit.depthLayout;
@@ -313,6 +314,7 @@ void TIntermediate::mergeModes(TInfoSink& infoSink, TIntermediate& unit)
MERGE_TRUE(autoMapLocations);
MERGE_TRUE(invertY);
MERGE_TRUE(dxPositionW);
MERGE_TRUE(debugInfo);
MERGE_TRUE(flattenUniformArrays);
MERGE_TRUE(useUnknownFormat);
MERGE_TRUE(hlslOffsets);
@@ -371,8 +373,6 @@ void TIntermediate::mergeTrees(TInfoSink& infoSink, TIntermediate& unit)
ioAccessed.insert(unit.ioAccessed.begin(), unit.ioAccessed.end());
}
#endif
static const TString& getNameForIdMap(TIntermSymbol* symbol)
{
TShaderInterface si = symbol->getType().getShaderInterface();
@@ -580,9 +580,6 @@ void TIntermediate::mergeGlobalUniformBlocks(TInfoSink& infoSink, TIntermediate&
}
void TIntermediate::mergeBlockDefinitions(TInfoSink& infoSink, TIntermSymbol* block, TIntermSymbol* unitBlock, TIntermediate* unit) {
if (block->getType() == unitBlock->getType()) {
return;
}
if (block->getType().getTypeName() != unitBlock->getType().getTypeName() ||
block->getType().getBasicType() != unitBlock->getType().getBasicType() ||
@@ -629,44 +626,42 @@ void TIntermediate::mergeBlockDefinitions(TInfoSink& infoSink, TIntermSymbol* bl
}
}
TType unitType;
unitType.shallowCopy(unitBlock->getType());
// update symbol node in unit tree,
// and other nodes that may reference it
class TMergeBlockTraverser : public TIntermTraverser {
public:
TMergeBlockTraverser(const glslang::TType &type, const glslang::TType& unitType,
glslang::TIntermediate& unit,
const std::map<unsigned int, unsigned int>& memberIdxUpdates) :
newType(type), unitType(unitType), unit(unit), memberIndexUpdates(memberIdxUpdates)
{ }
virtual ~TMergeBlockTraverser() { }
TMergeBlockTraverser(const TIntermSymbol* newSym)
: newSymbol(newSym), newType(nullptr), unit(nullptr), memberIndexUpdates(nullptr)
{
}
TMergeBlockTraverser(const TIntermSymbol* newSym, const glslang::TType* unitType, glslang::TIntermediate* unit,
const std::map<unsigned int, unsigned int>* memberIdxUpdates)
: TIntermTraverser(false, true), newSymbol(newSym), newType(unitType), unit(unit), memberIndexUpdates(memberIdxUpdates)
{
}
virtual ~TMergeBlockTraverser() {}
const glslang::TType& newType; // type with modifications
const glslang::TType& unitType; // copy of original type
glslang::TIntermediate& unit; // intermediate that is being updated
const std::map<unsigned int, unsigned int>& memberIndexUpdates;
const TIntermSymbol* newSymbol;
const glslang::TType* newType; // shallow copy of the new type
glslang::TIntermediate* unit; // intermediate that is being updated
const std::map<unsigned int, unsigned int>* memberIndexUpdates;
virtual void visitSymbol(TIntermSymbol* symbol)
{
glslang::TType& symType = symbol->getWritableType();
if (symType == unitType) {
// each symbol node has a local copy of the unitType
// if merging involves changing properties that aren't shared objects
// they should be updated in all instances
// e.g. the struct list is a ptr to an object, so it can be updated
// once, outside the traverser
//*symType.getWritableStruct() = *newType.getStruct();
if (newSymbol->getAccessName() == symbol->getAccessName() &&
newSymbol->getQualifier().getBlockStorage() == symbol->getQualifier().getBlockStorage()) {
// Each symbol node may have a local copy of the block structure.
// Update those structures to match the new one post-merge
*(symbol->getWritableType().getWritableStruct()) = *(newSymbol->getType().getStruct());
}
}
virtual bool visitBinary(TVisit, glslang::TIntermBinary* node)
{
if (node->getOp() == EOpIndexDirectStruct && node->getLeft()->getType() == unitType) {
if (!unit || !newType || !memberIndexUpdates || memberIndexUpdates->empty())
return true;
if (node->getOp() == EOpIndexDirectStruct && node->getLeft()->getType() == *newType) {
// this is a dereference to a member of the block since the
// member list changed, need to update this to point to the
// right index
@@ -674,8 +669,8 @@ void TIntermediate::mergeBlockDefinitions(TInfoSink& infoSink, TIntermSymbol* bl
glslang::TIntermConstantUnion* constNode = node->getRight()->getAsConstantUnion();
unsigned int memberIdx = constNode->getConstArray()[0].getUConst();
unsigned int newIdx = memberIndexUpdates.at(memberIdx);
TIntermTyped* newConstNode = unit.addConstantUnion(newIdx, node->getRight()->getLoc());
unsigned int newIdx = memberIndexUpdates->at(memberIdx);
TIntermTyped* newConstNode = unit->addConstantUnion(newIdx, node->getRight()->getLoc());
node->setRight(newConstNode);
delete constNode;
@@ -684,10 +679,20 @@ void TIntermediate::mergeBlockDefinitions(TInfoSink& infoSink, TIntermSymbol* bl
}
return true;
}
} finalLinkTraverser(block->getType(), unitType, *unit, memberIndexUpdates);
};
// update the tree to use the new type
unit->getTreeRoot()->traverse(&finalLinkTraverser);
// 'this' may have symbols that are using the old block structure, so traverse the tree to update those
// in 'visitSymbol'
TMergeBlockTraverser finalLinkTraverser(block);
getTreeRoot()->traverse(&finalLinkTraverser);
// The 'unit' intermediate needs the block structures update, but also structure entry indices
// may have changed from the old block to the new one that it was merged into, so update those
// in 'visitBinary'
TType newType;
newType.shallowCopy(block->getType());
TMergeBlockTraverser unitFinalLinkTraverser(block, &newType, unit, &memberIndexUpdates);
unit->getTreeRoot()->traverse(&unitFinalLinkTraverser);
// update the member list
(*unitMemberList) = (*memberList);
@@ -737,6 +742,21 @@ void TIntermediate::mergeLinkerObjects(TInfoSink& infoSink, TIntermSequence& lin
symbol->getQualifier().layoutLocation = unitSymbol->getQualifier().layoutLocation;
}
// Update implicit array sizes
if (symbol->getWritableType().isImplicitlySizedArray() && unitSymbol->getType().isImplicitlySizedArray()) {
if (unitSymbol->getType().getImplicitArraySize() > symbol->getType().getImplicitArraySize()){
symbol->getWritableType().updateImplicitArraySize(unitSymbol->getType().getImplicitArraySize());
}
}
else if (symbol->getWritableType().isImplicitlySizedArray() && unitSymbol->getType().isSizedArray()) {
if (symbol->getWritableType().getImplicitArraySize() > unitSymbol->getType().getOuterArraySize())
error(infoSink, "Implicit size of unsized array doesn't match same symbol among multiple shaders.");
}
else if (unitSymbol->getType().isImplicitlySizedArray() && symbol->getWritableType().isSizedArray()) {
if (unitSymbol->getType().getImplicitArraySize() > symbol->getWritableType().getOuterArraySize())
error(infoSink, "Implicit size of unsized array doesn't match same symbol among multiple shaders.");
}
// Update implicit array sizes
mergeImplicitArraySizes(symbol->getWritableType(), unitSymbol->getType());
@@ -747,6 +767,19 @@ void TIntermediate::mergeLinkerObjects(TInfoSink& infoSink, TIntermSequence& lin
else if (symbol->getQualifier().isPushConstant() && unitSymbol->getQualifier().isPushConstant() && getStage() == unitStage)
error(infoSink, "Only one push_constant block is allowed per stage");
}
// Check conflicts between preset primitives and sizes of I/O variables among multiple geometry shaders
if (language == EShLangGeometry && unitStage == EShLangGeometry)
{
TIntermSymbol* unitSymbol = unitLinkerObjects[unitLinkObj]->getAsSymbolNode();
if (unitSymbol->isArray() && unitSymbol->getQualifier().storage == EvqVaryingIn && unitSymbol->getQualifier().builtIn == EbvNone)
if ((unitSymbol->getArraySizes()->isImplicitlySized() &&
unitSymbol->getArraySizes()->getImplicitSize() != TQualifier::mapGeometryToSize(getInputPrimitive())) ||
(! unitSymbol->getArraySizes()->isImplicitlySized() &&
unitSymbol->getArraySizes()->getDimSize(0) != TQualifier::mapGeometryToSize(getInputPrimitive())))
error(infoSink, "Not all array sizes match across all geometry shaders in the program");
}
if (merge) {
linkerObjects.push_back(unitLinkerObjects[unitLinkObj]);
@@ -816,9 +849,12 @@ void TIntermediate::mergeImplicitArraySizes(TType& type, const TType& unitType)
//
void TIntermediate::mergeErrorCheck(TInfoSink& infoSink, const TIntermSymbol& symbol, const TIntermSymbol& unitSymbol, EShLanguage unitStage)
{
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
bool crossStage = getStage() != unitStage;
bool writeTypeComparison = false;
bool errorReported = false;
bool printQualifiers = false;
bool printPrecision = false;
bool printType = false;
// Types have to match
{
@@ -847,14 +883,52 @@ void TIntermediate::mergeErrorCheck(TInfoSink& infoSink, const TIntermSymbol& sy
else {
arraysMatch = symbol.getType().sameArrayness(unitSymbol.getType()) ||
(symbol.getType().isArray() && unitSymbol.getType().isArray() &&
(symbol.getType().isUnsizedArray() || unitSymbol.getType().isUnsizedArray()));
(symbol.getType().isImplicitlySizedArray() || unitSymbol.getType().isImplicitlySizedArray() ||
symbol.getType().isUnsizedArray() || unitSymbol.getType().isUnsizedArray()));
}
if (!symbol.getType().sameElementType(unitSymbol.getType()) ||
!symbol.getType().sameTypeParameters(unitSymbol.getType()) ||
!arraysMatch ) {
int lpidx = -1;
int rpidx = -1;
if (!symbol.getType().sameElementType(unitSymbol.getType(), &lpidx, &rpidx)) {
if (lpidx >= 0 && rpidx >= 0) {
error(infoSink, "Member names and types must match:", unitStage);
infoSink.info << " Block: " << symbol.getType().getTypeName() << "\n";
infoSink.info << " " << StageName(getStage()) << " stage: \""
<< (*symbol.getType().getStruct())[lpidx].type->getCompleteString(true, false, false, true,
(*symbol.getType().getStruct())[lpidx].type->getFieldName()) << "\"\n";
infoSink.info << " " << StageName(unitStage) << " stage: \""
<< (*unitSymbol.getType().getStruct())[rpidx].type->getCompleteString(true, false, false, true,
(*unitSymbol.getType().getStruct())[rpidx].type->getFieldName()) << "\"\n";
errorReported = true;
} else if (lpidx >= 0 && rpidx == -1) {
TString errmsg = StageName(getStage());
errmsg.append(" block member has no corresponding member in ").append(StageName(unitStage)).append(" block:");
error(infoSink, errmsg.c_str(), unitStage);
infoSink.info << " " << StageName(getStage()) << " stage: Block: " << symbol.getType().getTypeName() << ", Member: "
<< (*symbol.getType().getStruct())[lpidx].type->getFieldName() << "\n";
infoSink.info << " " << StageName(unitStage) << " stage: Block: " << unitSymbol.getType().getTypeName() << ", Member: n/a \n";
errorReported = true;
} else if (lpidx == -1 && rpidx >= 0) {
TString errmsg = StageName(unitStage);
errmsg.append(" block member has no corresponding member in ").append(StageName(getStage())).append(" block:");
error(infoSink, errmsg.c_str(), unitStage);
infoSink.info << " " << StageName(unitStage) << " stage: Block: " << unitSymbol.getType().getTypeName() << ", Member: "
<< (*unitSymbol.getType().getStruct())[rpidx].type->getFieldName() << "\n";
infoSink.info << " " << StageName(getStage()) << " stage: Block: " << symbol.getType().getTypeName() << ", Member: n/a \n";
errorReported = true;
} else {
error(infoSink, "Types must match:", unitStage);
writeTypeComparison = true;
printType = true;
}
} else if (!arraysMatch) {
error(infoSink, "Array sizes must be compatible:", unitStage);
writeTypeComparison = true;
error(infoSink, "Types must match:");
printType = true;
} else if (!symbol.getType().sameTypeParameters(unitSymbol.getType())) {
error(infoSink, "Type parameters must match:", unitStage);
writeTypeComparison = true;
printType = true;
}
}
@@ -875,13 +949,35 @@ void TIntermediate::mergeErrorCheck(TInfoSink& infoSink, const TIntermSymbol& sy
}
const TQualifier& qualifier = (*symbol.getType().getStruct())[li].type->getQualifier();
const TQualifier & unitQualifier = (*unitSymbol.getType().getStruct())[ri].type->getQualifier();
if (qualifier.layoutMatrix != unitQualifier.layoutMatrix ||
qualifier.layoutOffset != unitQualifier.layoutOffset ||
qualifier.layoutAlign != unitQualifier.layoutAlign ||
qualifier.layoutLocation != unitQualifier.layoutLocation ||
qualifier.layoutComponent != unitQualifier.layoutComponent) {
error(infoSink, "Interface block member layout qualifiers must match:");
writeTypeComparison = true;
bool layoutQualifierError = false;
if (qualifier.layoutMatrix != unitQualifier.layoutMatrix) {
error(infoSink, "Interface block member layout matrix qualifier must match:", unitStage);
layoutQualifierError = true;
}
if (qualifier.layoutOffset != unitQualifier.layoutOffset) {
error(infoSink, "Interface block member layout offset qualifier must match:", unitStage);
layoutQualifierError = true;
}
if (qualifier.layoutAlign != unitQualifier.layoutAlign) {
error(infoSink, "Interface block member layout align qualifier must match:", unitStage);
layoutQualifierError = true;
}
if (qualifier.layoutLocation != unitQualifier.layoutLocation) {
error(infoSink, "Interface block member layout location qualifier must match:", unitStage);
layoutQualifierError = true;
}
if (qualifier.layoutComponent != unitQualifier.layoutComponent) {
error(infoSink, "Interface block member layout component qualifier must match:", unitStage);
layoutQualifierError = true;
}
if (layoutQualifierError) {
infoSink.info << " " << StageName(getStage()) << " stage: Block: " << symbol.getType().getTypeName() << ", Member: "
<< (*symbol.getType().getStruct())[li].type->getFieldName() << " \""
<< (*symbol.getType().getStruct())[li].type->getCompleteString(true, true, false, false) << "\"\n";
infoSink.info << " " << StageName(unitStage) << " stage: Block: " << unitSymbol.getType().getTypeName() << ", Member: "
<< (*unitSymbol.getType().getStruct())[ri].type->getFieldName() << " \""
<< (*unitSymbol.getType().getStruct())[ri].type->getCompleteString(true, true, false, false) << "\"\n";
errorReported = true;
}
++li;
++ri;
@@ -895,8 +991,9 @@ void TIntermediate::mergeErrorCheck(TInfoSink& infoSink, const TIntermSymbol& sy
// Qualifiers have to (almost) match
// Storage...
if (!isInOut && symbol.getQualifier().storage != unitSymbol.getQualifier().storage) {
error(infoSink, "Storage qualifiers must match:");
error(infoSink, "Storage qualifiers must match:", unitStage);
writeTypeComparison = true;
printQualifiers = true;
}
// Uniform and buffer blocks must either both have an instance name, or
@@ -904,37 +1001,40 @@ void TIntermediate::mergeErrorCheck(TInfoSink& infoSink, const TIntermSymbol& sy
if (symbol.getQualifier().isUniformOrBuffer() &&
(IsAnonymous(symbol.getName()) != IsAnonymous(unitSymbol.getName()))) {
error(infoSink, "Matched Uniform or Storage blocks must all be anonymous,"
" or all be named:");
" or all be named:", unitStage);
writeTypeComparison = true;
}
if (symbol.getQualifier().storage == unitSymbol.getQualifier().storage &&
(IsAnonymous(symbol.getName()) != IsAnonymous(unitSymbol.getName()) ||
(!IsAnonymous(symbol.getName()) && symbol.getName() != unitSymbol.getName()))) {
warn(infoSink, "Matched shader interfaces are using different instance names.");
warn(infoSink, "Matched shader interfaces are using different instance names.", unitStage);
writeTypeComparison = true;
}
// Precision...
if (!isInOut && symbol.getQualifier().precision != unitSymbol.getQualifier().precision) {
error(infoSink, "Precision qualifiers must match:");
error(infoSink, "Precision qualifiers must match:", unitStage);
writeTypeComparison = true;
printPrecision = true;
}
// Invariance...
if (! crossStage && symbol.getQualifier().invariant != unitSymbol.getQualifier().invariant) {
error(infoSink, "Presence of invariant qualifier must match:");
error(infoSink, "Presence of invariant qualifier must match:", unitStage);
writeTypeComparison = true;
printQualifiers = true;
}
// Precise...
if (! crossStage && symbol.getQualifier().isNoContraction() != unitSymbol.getQualifier().isNoContraction()) {
error(infoSink, "Presence of precise qualifier must match:");
error(infoSink, "Presence of precise qualifier must match:", unitStage);
writeTypeComparison = true;
printPrecision = true;
}
// Auxiliary and interpolation...
// "interpolation qualification (e.g., flat) and auxiliary qualification (e.g. centroid) may differ.
// "interpolation qualification (e.g., flat) and auxiliary qualification (e.g. centroid) may differ.
// These mismatches are allowed between any pair of stages ...
// those provided in the fragment shader supersede those provided in previous stages."
if (!crossStage &&
@@ -944,59 +1044,138 @@ void TIntermediate::mergeErrorCheck(TInfoSink& infoSink, const TIntermSymbol& sy
symbol.getQualifier().isSample()!= unitSymbol.getQualifier().isSample() ||
symbol.getQualifier().isPatch() != unitSymbol.getQualifier().isPatch() ||
symbol.getQualifier().isNonPerspective() != unitSymbol.getQualifier().isNonPerspective())) {
error(infoSink, "Interpolation and auxiliary storage qualifiers must match:");
error(infoSink, "Interpolation and auxiliary storage qualifiers must match:", unitStage);
writeTypeComparison = true;
printQualifiers = true;
}
// Memory...
if (symbol.getQualifier().coherent != unitSymbol.getQualifier().coherent ||
symbol.getQualifier().devicecoherent != unitSymbol.getQualifier().devicecoherent ||
symbol.getQualifier().queuefamilycoherent != unitSymbol.getQualifier().queuefamilycoherent ||
symbol.getQualifier().workgroupcoherent != unitSymbol.getQualifier().workgroupcoherent ||
symbol.getQualifier().subgroupcoherent != unitSymbol.getQualifier().subgroupcoherent ||
symbol.getQualifier().shadercallcoherent!= unitSymbol.getQualifier().shadercallcoherent ||
symbol.getQualifier().nonprivate != unitSymbol.getQualifier().nonprivate ||
symbol.getQualifier().volatil != unitSymbol.getQualifier().volatil ||
symbol.getQualifier().restrict != unitSymbol.getQualifier().restrict ||
symbol.getQualifier().readonly != unitSymbol.getQualifier().readonly ||
symbol.getQualifier().writeonly != unitSymbol.getQualifier().writeonly) {
error(infoSink, "Memory qualifiers must match:");
writeTypeComparison = true;
bool memoryQualifierError = false;
if (symbol.getQualifier().coherent != unitSymbol.getQualifier().coherent) {
error(infoSink, "Memory coherent qualifier must match:", unitStage);
memoryQualifierError = true;
}
if (symbol.getQualifier().devicecoherent != unitSymbol.getQualifier().devicecoherent) {
error(infoSink, "Memory devicecoherent qualifier must match:", unitStage);
memoryQualifierError = true;
}
if (symbol.getQualifier().queuefamilycoherent != unitSymbol.getQualifier().queuefamilycoherent) {
error(infoSink, "Memory queuefamilycoherent qualifier must match:", unitStage);
memoryQualifierError = true;
}
if (symbol.getQualifier().workgroupcoherent != unitSymbol.getQualifier().workgroupcoherent) {
error(infoSink, "Memory workgroupcoherent qualifier must match:", unitStage);
memoryQualifierError = true;
}
if (symbol.getQualifier().subgroupcoherent != unitSymbol.getQualifier().subgroupcoherent) {
error(infoSink, "Memory subgroupcoherent qualifier must match:", unitStage);
memoryQualifierError = true;
}
if (symbol.getQualifier().shadercallcoherent != unitSymbol.getQualifier().shadercallcoherent) {
error(infoSink, "Memory shadercallcoherent qualifier must match:", unitStage);
memoryQualifierError = true;
}
if (symbol.getQualifier().nonprivate != unitSymbol.getQualifier().nonprivate) {
error(infoSink, "Memory nonprivate qualifier must match:", unitStage);
memoryQualifierError = true;
}
if (symbol.getQualifier().volatil != unitSymbol.getQualifier().volatil) {
error(infoSink, "Memory volatil qualifier must match:", unitStage);
memoryQualifierError = true;
}
if (symbol.getQualifier().restrict != unitSymbol.getQualifier().restrict) {
error(infoSink, "Memory restrict qualifier must match:", unitStage);
memoryQualifierError = true;
}
if (symbol.getQualifier().readonly != unitSymbol.getQualifier().readonly) {
error(infoSink, "Memory readonly qualifier must match:", unitStage);
memoryQualifierError = true;
}
if (symbol.getQualifier().writeonly != unitSymbol.getQualifier().writeonly) {
error(infoSink, "Memory writeonly qualifier must match:", unitStage);
memoryQualifierError = true;
}
if (memoryQualifierError) {
writeTypeComparison = true;
printQualifiers = true;
}
// Layouts...
// TODO: 4.4 enhanced layouts: Generalize to include offset/align: current spec
// requires separate user-supplied offset from actual computed offset, but
// current implementation only has one offset.
if (symbol.getQualifier().layoutMatrix != unitSymbol.getQualifier().layoutMatrix ||
symbol.getQualifier().layoutPacking != unitSymbol.getQualifier().layoutPacking ||
(symbol.getQualifier().hasLocation() && unitSymbol.getQualifier().hasLocation() && symbol.getQualifier().layoutLocation != unitSymbol.getQualifier().layoutLocation) ||
symbol.getQualifier().layoutComponent != unitSymbol.getQualifier().layoutComponent ||
symbol.getQualifier().layoutIndex != unitSymbol.getQualifier().layoutIndex ||
(symbol.getQualifier().hasBinding() && unitSymbol.getQualifier().hasBinding() && symbol.getQualifier().layoutBinding != unitSymbol.getQualifier().layoutBinding) ||
(symbol.getQualifier().hasBinding() && (symbol.getQualifier().layoutOffset != unitSymbol.getQualifier().layoutOffset))) {
error(infoSink, "Layout qualification must match:");
bool layoutQualifierError = false;
if (symbol.getQualifier().layoutMatrix != unitSymbol.getQualifier().layoutMatrix) {
error(infoSink, "Layout matrix qualifier must match:", unitStage);
layoutQualifierError = true;
}
if (symbol.getQualifier().layoutPacking != unitSymbol.getQualifier().layoutPacking) {
error(infoSink, "Layout packing qualifier must match:", unitStage);
layoutQualifierError = true;
}
if (symbol.getQualifier().hasLocation() && unitSymbol.getQualifier().hasLocation() && symbol.getQualifier().layoutLocation != unitSymbol.getQualifier().layoutLocation) {
error(infoSink, "Layout location qualifier must match:", unitStage);
layoutQualifierError = true;
}
if (symbol.getQualifier().layoutComponent != unitSymbol.getQualifier().layoutComponent) {
error(infoSink, "Layout component qualifier must match:", unitStage);
layoutQualifierError = true;
}
if (symbol.getQualifier().layoutIndex != unitSymbol.getQualifier().layoutIndex) {
error(infoSink, "Layout index qualifier must match:", unitStage);
layoutQualifierError = true;
}
if (symbol.getQualifier().hasBinding() && unitSymbol.getQualifier().hasBinding() && symbol.getQualifier().layoutBinding != unitSymbol.getQualifier().layoutBinding) {
error(infoSink, "Layout binding qualifier must match:", unitStage);
layoutQualifierError = true;
}
if (symbol.getQualifier().hasBinding() && (symbol.getQualifier().layoutOffset != unitSymbol.getQualifier().layoutOffset)) {
error(infoSink, "Layout offset qualifier must match:", unitStage);
layoutQualifierError = true;
}
if (layoutQualifierError) {
writeTypeComparison = true;
printQualifiers = true;
}
// Initializers have to match, if both are present, and if we don't already know the types don't match
if (! writeTypeComparison) {
if (! writeTypeComparison && ! errorReported) {
if (! symbol.getConstArray().empty() && ! unitSymbol.getConstArray().empty()) {
if (symbol.getConstArray() != unitSymbol.getConstArray()) {
error(infoSink, "Initializers must match:");
error(infoSink, "Initializers must match:", unitStage);
infoSink.info << " " << symbol.getName() << "\n";
}
}
}
if (writeTypeComparison) {
infoSink.info << " " << symbol.getName() << ": \"" << symbol.getType().getCompleteString() << "\" versus ";
if (symbol.getName() != unitSymbol.getName())
infoSink.info << unitSymbol.getName() << ": ";
infoSink.info << "\"" << unitSymbol.getType().getCompleteString() << "\"\n";
if (symbol.getType().getBasicType() == EbtBlock && unitSymbol.getType().getBasicType() == EbtBlock &&
symbol.getType().getStruct() && unitSymbol.getType().getStruct()) {
if (printType) {
infoSink.info << " " << StageName(getStage()) << " stage: \"" << symbol.getType().getCompleteString(true, printQualifiers, printPrecision,
printType, symbol.getName(), symbol.getType().getTypeName()) << "\"\n";
infoSink.info << " " << StageName(unitStage) << " stage: \"" << unitSymbol.getType().getCompleteString(true, printQualifiers, printPrecision,
printType, unitSymbol.getName(), unitSymbol.getType().getTypeName()) << "\"\n";
} else {
infoSink.info << " " << StageName(getStage()) << " stage: Block: " << symbol.getType().getTypeName() << " Instance: " << symbol.getName()
<< ": \"" << symbol.getType().getCompleteString(true, printQualifiers, printPrecision, printType) << "\"\n";
infoSink.info << " " << StageName(unitStage) << " stage: Block: " << unitSymbol.getType().getTypeName() << " Instance: " << unitSymbol.getName()
<< ": \"" << unitSymbol.getType().getCompleteString(true, printQualifiers, printPrecision, printType) << "\"\n";
}
} else {
if (printType) {
infoSink.info << " " << StageName(getStage()) << " stage: \""
<< symbol.getType().getCompleteString(true, printQualifiers, printPrecision, printType, symbol.getName()) << "\"\n";
infoSink.info << " " << StageName(unitStage) << " stage: \""
<< unitSymbol.getType().getCompleteString(true, printQualifiers, printPrecision, printType, unitSymbol.getName()) << "\"\n";
} else {
infoSink.info << " " << StageName(getStage()) << " stage: " << symbol.getName() << " \""
<< symbol.getType().getCompleteString(true, printQualifiers, printPrecision, printType) << "\"\n";
infoSink.info << " " << StageName(unitStage) << " stage: " << unitSymbol.getName() << " \""
<< unitSymbol.getType().getCompleteString(true, printQualifiers, printPrecision, printType) << "\"\n";
}
}
}
#endif
}
void TIntermediate::sharedBlockCheck(TInfoSink& infoSink)
@@ -1043,7 +1222,6 @@ void TIntermediate::finalCheck(TInfoSink& infoSink, bool keepUncalled)
// overlap/alias/missing I/O, etc.
inOutLocationCheck(infoSink);
#ifndef GLSLANG_WEB
if (getNumPushConstants() > 1)
error(infoSink, "Only one push_constant block is allowed per stage");
@@ -1136,8 +1314,8 @@ void TIntermediate::finalCheck(TInfoSink& infoSink, bool keepUncalled)
error(infoSink, "At least one shader must specify a layout(max_vertices = value)");
break;
case EShLangFragment:
// for GL_ARB_post_depth_coverage, EarlyFragmentTest is set automatically in
// ParseHelper.cpp. So if we reach here, this must be GL_EXT_post_depth_coverage
// for GL_ARB_post_depth_coverage, EarlyFragmentTest is set automatically in
// ParseHelper.cpp. So if we reach here, this must be GL_EXT_post_depth_coverage
// requiring explicit early_fragment_tests
if (getPostDepthCoverage() && !getEarlyFragmentTests())
error(infoSink, "post_depth_coverage requires early_fragment_tests");
@@ -1154,7 +1332,7 @@ void TIntermediate::finalCheck(TInfoSink& infoSink, bool keepUncalled)
if (numShaderRecordBlocks > 1)
error(infoSink, "Only one shaderRecordNV buffer block is allowed per stage");
break;
case EShLangMeshNV:
case EShLangMesh:
// NV_mesh_shader doesn't allow use of both single-view and per-view builtins.
if (inIoAccessed("gl_Position") && inIoAccessed("gl_PositionPerViewNV"))
error(infoSink, "Can only use one of gl_Position or gl_PositionPerViewNV");
@@ -1173,9 +1351,11 @@ void TIntermediate::finalCheck(TInfoSink& infoSink, bool keepUncalled)
if (primitives == TQualifier::layoutNotSet)
error(infoSink, "At least one shader must specify a layout(max_primitives = value)");
// fall through
case EShLangTaskNV:
case EShLangTask:
if (numTaskNVBlocks > 1)
error(infoSink, "Only one taskNV interface block is allowed per shader");
if (numTaskEXTPayloads > 1)
error(infoSink, "Only single variable of type taskPayloadSharedEXT is allowed per shader");
sharedBlockCheck(infoSink);
break;
default:
@@ -1199,7 +1379,6 @@ void TIntermediate::finalCheck(TInfoSink& infoSink, bool keepUncalled)
} finalLinkTraverser;
treeRoot->traverse(&finalLinkTraverser);
#endif
}
//
@@ -1222,7 +1401,7 @@ void TIntermediate::checkCallGraphCycles(TInfoSink& infoSink)
TCall* newRoot;
do {
// See if we have unvisited parts of the graph.
newRoot = 0;
newRoot = nullptr;
for (TGraph::iterator call = callGraph.begin(); call != callGraph.end(); ++call) {
if (! call->visited) {
newRoot = &(*call);
@@ -1356,7 +1535,10 @@ void TIntermediate::checkCallGraphBodies(TInfoSink& infoSink, bool keepUncalled)
if (! keepUncalled) {
for (int f = 0; f < (int)functionSequence.size(); ++f) {
if (! reachable[f])
{
resetTopLevelUncalledStatus(functionSequence[f]->getAsAggregate()->getName());
functionSequence[f] = nullptr;
}
}
functionSequence.erase(std::remove(functionSequence.begin(), functionSequence.end(), nullptr), functionSequence.end());
}
@@ -1424,7 +1606,7 @@ bool TIntermediate::userOutputUsed() const
return found;
}
// Accumulate locations used for inputs, outputs, and uniforms, payload and callable data
// Accumulate locations used for inputs, outputs, and uniforms, payload, callable data, and tileImageEXT
// and check for collisions as the accumulation is done.
//
// Returns < 0 if no collision, >= 0 if collision and the value returned is a colliding value.
@@ -1437,7 +1619,6 @@ int TIntermediate::addUsedLocation(const TQualifier& qualifier, const TType& typ
typeCollision = false;
int set;
int setRT;
if (qualifier.isPipeInput())
set = 0;
else if (qualifier.isPipeOutput())
@@ -1446,10 +1627,14 @@ int TIntermediate::addUsedLocation(const TQualifier& qualifier, const TType& typ
set = 2;
else if (qualifier.storage == EvqBuffer)
set = 3;
else if (qualifier.storage == EvqTileImageEXT)
set = 4;
else if (qualifier.isAnyPayload())
setRT = 0;
set = 0;
else if (qualifier.isAnyCallable())
setRT = 1;
set = 1;
else if (qualifier.isHitObjectAttrNV())
set = 2;
else
return -1;
@@ -1488,13 +1673,14 @@ int TIntermediate::addUsedLocation(const TQualifier& qualifier, const TType& typ
// For raytracing IO (payloads and callabledata) each declaration occupies a single
// slot irrespective of type.
int collision = -1; // no collision
#ifndef GLSLANG_WEB
if (qualifier.isAnyPayload() || qualifier.isAnyCallable()) {
if (qualifier.isAnyPayload() || qualifier.isAnyCallable() || qualifier.isHitObjectAttrNV()) {
TRange range(qualifier.layoutLocation, qualifier.layoutLocation);
collision = checkLocationRT(setRT, qualifier.layoutLocation);
collision = checkLocationRT(set, qualifier.layoutLocation);
if (collision < 0)
usedIoRT[setRT].push_back(range);
} else if (size == 2 && type.getBasicType() == EbtDouble && type.getVectorSize() == 3 &&
usedIoRT[set].push_back(range);
return collision;
}
if (size == 2 && type.getBasicType() == EbtDouble && type.getVectorSize() == 3 &&
(qualifier.isPipeInput() || qualifier.isPipeOutput())) {
// Dealing with dvec3 in/out split across two locations.
// Need two io-ranges.
@@ -1520,32 +1706,34 @@ int TIntermediate::addUsedLocation(const TQualifier& qualifier, const TType& typ
if (collision < 0)
usedIo[set].push_back(range2);
}
} else
#endif
{
// Not a dvec3 in/out split across two locations, generic path.
// Need a single IO-range block.
TRange locationRange(qualifier.layoutLocation, qualifier.layoutLocation + size - 1);
TRange componentRange(0, 3);
if (qualifier.hasComponent() || type.getVectorSize() > 0) {
int consumedComponents = type.getVectorSize() * (type.getBasicType() == EbtDouble ? 2 : 1);
if (qualifier.hasComponent())
componentRange.start = qualifier.layoutComponent;
componentRange.last = componentRange.start + consumedComponents - 1;
}
// combine location and component ranges
TIoRange range(locationRange, componentRange, type.getBasicType(), qualifier.hasIndex() ? qualifier.getIndex() : 0);
// check for collisions, except for vertex inputs on desktop targeting OpenGL
if (! (!isEsProfile() && language == EShLangVertex && qualifier.isPipeInput()) || spvVersion.vulkan > 0)
collision = checkLocationRange(set, range, type, typeCollision);
if (collision < 0)
usedIo[set].push_back(range);
return collision;
}
// Not a dvec3 in/out split across two locations, generic path.
// Need a single IO-range block.
TRange locationRange(qualifier.layoutLocation, qualifier.layoutLocation + size - 1);
TRange componentRange(0, 3);
if (qualifier.hasComponent() || type.getVectorSize() > 0) {
int consumedComponents = type.getVectorSize() * (type.getBasicType() == EbtDouble ? 2 : 1);
if (qualifier.hasComponent())
componentRange.start = qualifier.layoutComponent;
componentRange.last = componentRange.start + consumedComponents - 1;
}
// combine location and component ranges
TBasicType basicTy = type.getBasicType();
if (basicTy == EbtSampler && type.getSampler().isAttachmentEXT())
basicTy = type.getSampler().type;
TIoRange range(locationRange, componentRange, basicTy, qualifier.hasIndex() ? qualifier.getIndex() : 0);
// check for collisions, except for vertex inputs on desktop targeting OpenGL
if (! (!isEsProfile() && language == EShLangVertex && qualifier.isPipeInput()) || spvVersion.vulkan > 0)
collision = checkLocationRange(set, range, type, typeCollision);
if (collision < 0)
usedIo[set].push_back(range);
return collision;
}
@@ -1567,6 +1755,19 @@ int TIntermediate::checkLocationRange(int set, const TIoRange& range, const TTyp
}
}
// check typeCollision between tileImageEXT and out
if (set == 4 || set == 1) {
// if the set is "tileImageEXT", check against "out" and vice versa
int againstSet = (set == 4) ? 1 : 4;
for (size_t r = 0; r < usedIo[againstSet].size(); ++r) {
if (range.location.overlap(usedIo[againstSet][r].location) && type.getBasicType() != usedIo[againstSet][r].basicType) {
// aliased-type mismatch
typeCollision = true;
return std::max(range.location.start, usedIo[againstSet][r].location.start);
}
}
}
return -1; // no collision
}
@@ -1630,10 +1831,8 @@ int TIntermediate::computeTypeLocationSize(const TType& type, EShLanguage stage)
if (type.isSizedArray() && !type.getQualifier().isPerView())
return type.getOuterArraySize() * computeTypeLocationSize(elementType, stage);
else {
#ifndef GLSLANG_WEB
// unset perViewNV attributes for arrayed per-view outputs: "perviewNV vec4 v[MAX_VIEWS][3];"
elementType.getQualifier().perViewNV = false;
#endif
return computeTypeLocationSize(elementType, stage);
}
}
@@ -1709,8 +1908,6 @@ int TIntermediate::computeTypeUniformLocationSize(const TType& type)
return 1;
}
#ifndef GLSLANG_WEB
// Accumulate xfb buffer ranges and check for collisions as the accumulation is done.
//
// Returns < 0 if no collision, >= 0 if collision and the value returned is a colliding value.
@@ -1802,7 +1999,7 @@ unsigned int TIntermediate::computeTypeXfbSize(const TType& type, bool& contains
return size;
}
int numComponents;
int numComponents {0};
if (type.isScalar())
numComponents = 1;
else if (type.isVector())
@@ -1828,8 +2025,6 @@ unsigned int TIntermediate::computeTypeXfbSize(const TType& type, bool& contains
}
}
#endif
const int baseAlignmentVec4Std140 = 16;
// Return the size and alignment of a component of the given type.
@@ -1837,10 +2032,6 @@ const int baseAlignmentVec4Std140 = 16;
// Return value is the alignment..
int TIntermediate::getBaseAlignmentScalar(const TType& type, int& size)
{
#ifdef GLSLANG_WEB
size = 4; return 4;
#endif
switch (type.getBasicType()) {
case EbtInt64:
case EbtUint64:
@@ -1851,6 +2042,15 @@ int TIntermediate::getBaseAlignmentScalar(const TType& type, int& size)
case EbtInt16:
case EbtUint16: size = 2; return 2;
case EbtReference: size = 8; return 8;
case EbtSampler:
{
if (type.isBindlessImage() || type.isBindlessTexture()) {
size = 8; return 8;
}
else {
size = 4; return 4;
}
}
default: size = 4; return 4;
}
}
@@ -2068,7 +2268,7 @@ int TIntermediate::getScalarAlignment(const TType& type, int& size, int& stride,
if (type.isVector()) {
int scalarAlign = getBaseAlignmentScalar(type, size);
size *= type.getVectorSize();
return scalarAlign;
}
@@ -2089,7 +2289,7 @@ int TIntermediate::getScalarAlignment(const TType& type, int& size, int& stride,
assert(0); // all cases should be covered above
size = 1;
return 1;
return 1;
}
int TIntermediate::getMemberAlignment(const TType& type, int& size, int& stride, TLayoutPacking layoutPacking, bool rowMajor)
@@ -2171,7 +2371,6 @@ int TIntermediate::computeBufferReferenceTypeSize(const TType& type)
return size;
}
#ifndef GLSLANG_WEB
bool TIntermediate::isIoResizeArray(const TType& type, EShLanguage language) {
return type.isArray() &&
((language == EShLangGeometry && type.getQualifier().storage == EvqVaryingIn) ||
@@ -2179,10 +2378,9 @@ bool TIntermediate::isIoResizeArray(const TType& type, EShLanguage language) {
! type.getQualifier().patch) ||
(language == EShLangTessEvaluation && type.getQualifier().storage == EvqVaryingIn) ||
(language == EShLangFragment && type.getQualifier().storage == EvqVaryingIn &&
type.getQualifier().pervertexNV) ||
(language == EShLangMeshNV && type.getQualifier().storage == EvqVaryingOut &&
(type.getQualifier().pervertexNV || type.getQualifier().pervertexEXT)) ||
(language == EShLangMesh && type.getQualifier().storage == EvqVaryingOut &&
!type.getQualifier().perTaskNV));
}
#endif // not GLSLANG_WEB
} // end namespace glslang
@@ -43,11 +43,12 @@
#include "../Public/ShaderLang.h"
#include "Versions.h"
#include <algorithm>
#include <array>
#include <functional>
#include <set>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <array>
class TInfoSink;
@@ -147,7 +148,6 @@ struct TOffsetRange {
TRange offset;
};
#ifndef GLSLANG_WEB
// Things that need to be tracked per xfb buffer.
struct TXfbBuffer {
TXfbBuffer() : stride(TQualifier::layoutXfbStrideEnd), implicitStride(0), contains64BitType(false),
@@ -159,7 +159,6 @@ struct TXfbBuffer {
bool contains32BitType;
bool contains16BitType;
};
#endif
// Track a set of strings describing how the module was processed.
// This includes command line options, transforms, etc., ideally inclusive enough
@@ -225,6 +224,16 @@ enum ComputeDerivativeMode {
LayoutDerivativeGroupLinear, // derivative_group_linearNV
};
//
// Status type on AST level. Some uncalled status or functions would be reset in call graph.
// Currently we will keep status set by explicitly declared layout or variable decl.
//
enum AstRefType {
AstRefTypeVar, // Status set by variable decl
AstRefTypeFunc, // Status set by function decl
AstRefTypeLayout, // Status set by layout decl
};
class TIdMaps {
public:
TMap<TString, long long>& operator[](long long i) { return maps[i]; }
@@ -283,34 +292,38 @@ class TIntermediate {
public:
explicit TIntermediate(EShLanguage l, int v = 0, EProfile p = ENoProfile) :
language(l),
#ifndef GLSLANG_ANGLE
profile(p), version(v),
#endif
treeRoot(0),
treeRoot(nullptr),
resources(TBuiltInResource{}),
numEntryPoints(0), numErrors(0), numPushConstants(0), recursive(false),
invertY(false),
dxPositionW(false),
enhancedMsgs(false),
debugInfo(false),
useStorageBuffer(false),
invariantAll(false),
nanMinMaxClamp(false),
depthReplacing(false),
stencilReplacing(false),
uniqueId(0),
globalUniformBlockName(""),
atomicCounterBlockName(""),
globalUniformBlockSet(TQualifier::layoutSetEnd),
globalUniformBlockBinding(TQualifier::layoutBindingEnd),
atomicCounterBlockSet(TQualifier::layoutSetEnd)
#ifndef GLSLANG_WEB
,
atomicCounterBlockSet(TQualifier::layoutSetEnd),
implicitThisName("@this"), implicitCounterName("@count"),
source(EShSourceNone),
useVulkanMemoryModel(false),
invocations(TQualifier::layoutNotSet), vertices(TQualifier::layoutNotSet),
inputPrimitive(ElgNone), outputPrimitive(ElgNone),
pixelCenterInteger(false), originUpperLeft(false),
pixelCenterInteger(false), originUpperLeft(false),texCoordBuiltinRedeclared(false),
vertexSpacing(EvsNone), vertexOrder(EvoNone), interlockOrdering(EioNone), pointMode(false), earlyFragmentTests(false),
postDepthCoverage(false), depthLayout(EldNone),
postDepthCoverage(false), earlyAndLateFragmentTestsAMD(false),
nonCoherentColorAttachmentReadEXT(false),
nonCoherentDepthAttachmentReadEXT(false),
nonCoherentStencilAttachmentReadEXT(false),
depthLayout(EldNone),
stencilLayout(ElsNone),
hlslFunctionality1(false),
blendEquations(0), xfbMode(false), multiStream(false),
layoutOverrideCoverage(false),
@@ -320,6 +333,7 @@ public:
primitives(TQualifier::layoutNotSet),
numTaskNVBlocks(0),
layoutPrimitiveCulling(false),
numTaskEXTPayloads(0),
autoMapBindings(false),
autoMapLocations(false),
flattenUniformArrays(false),
@@ -335,7 +349,6 @@ public:
spirvRequirement(nullptr),
spirvExecutionMode(nullptr),
uniformLocationBase(0)
#endif
{
localSize[0] = 1;
localSize[1] = 1;
@@ -346,23 +359,17 @@ public:
localSizeSpecId[0] = TQualifier::layoutNotSet;
localSizeSpecId[1] = TQualifier::layoutNotSet;
localSizeSpecId[2] = TQualifier::layoutNotSet;
#ifndef GLSLANG_WEB
xfbBuffers.resize(TQualifier::layoutXfbBufferEnd);
shiftBinding.fill(0);
#endif
}
void setVersion(int v)
{
#ifndef GLSLANG_ANGLE
version = v;
#endif
}
void setProfile(EProfile p)
{
#ifndef GLSLANG_ANGLE
profile = p;
#endif
}
int getVersion() const { return version; }
@@ -419,6 +426,9 @@ public:
case EShTargetVulkan_1_2:
processes.addProcess("target-env vulkan1.2");
break;
case EShTargetVulkan_1_3:
processes.addProcess("target-env vulkan1.3");
break;
default:
processes.addProcess("target-env vulkanUnknown");
break;
@@ -456,6 +466,12 @@ public:
const std::string& getEntryPointName() const { return entryPointName; }
const std::string& getEntryPointMangledName() const { return entryPointMangledName; }
void setDebugInfo(bool debuginfo)
{
debugInfo = debuginfo;
}
bool getDebugInfo() const { return debugInfo; }
void setInvertY(bool invert)
{
invertY = invert;
@@ -466,12 +482,18 @@ public:
void setDxPositionW(bool dxPosW)
{
dxPositionW = dxPosW;
if (dxPositionW)
processes.addProcess("dx-position-w");
dxPositionW = dxPosW;
if (dxPositionW)
processes.addProcess("dx-position-w");
}
bool getDxPositionW() const { return dxPositionW; }
void setEnhancedMsgs()
{
enhancedMsgs = true;
}
bool getEnhancedMsgs() const { return enhancedMsgs && getSource() == EShSourceGlsl; }
#ifdef ENABLE_HLSL
void setSource(EShSource s) { source = s; }
EShSource getSource() const { return source; }
@@ -506,6 +528,8 @@ public:
TOperator mapTypeToConstructorOp(const TType&) const;
TIntermAggregate* growAggregate(TIntermNode* left, TIntermNode* right);
TIntermAggregate* growAggregate(TIntermNode* left, TIntermNode* right, const TSourceLoc&);
TIntermAggregate* mergeAggregate(TIntermNode* left, TIntermNode* right);
TIntermAggregate* mergeAggregate(TIntermNode* left, TIntermNode* right, const TSourceLoc&);
TIntermAggregate* makeAggregate(TIntermNode* node);
TIntermAggregate* makeAggregate(TIntermNode* node, const TSourceLoc&);
TIntermAggregate* makeAggregate(const TSourceLoc&);
@@ -551,7 +575,8 @@ public:
TIntermTyped* foldSwizzle(TIntermTyped* node, TSwizzleSelectors<TVectorSelector>& fields, const TSourceLoc&);
// Tree ops
static const TIntermTyped* findLValueBase(const TIntermTyped*, bool swizzleOkay , bool BufferReferenceOk = false);
static const TIntermTyped* traverseLValueBase(const TIntermTyped*, bool swizzleOkay, bool bufferReferenceOk = false,
std::function<bool(const TIntermNode&)> proc = {});
// Linkage related
void addSymbolLinkageNodes(TIntermAggregate*& linkage, EShLanguage, TSymbolTable&);
@@ -577,6 +602,8 @@ public:
bool isInvariantAll() const { return invariantAll; }
void setDepthReplacing() { depthReplacing = true; }
bool isDepthReplacing() const { return depthReplacing; }
void setStencilReplacing() { stencilReplacing = true; }
bool isStencilReplacing() const { return stencilReplacing; }
bool setLocalSize(int dim, int size)
{
if (localSizeNotDefault[dim])
@@ -606,34 +633,6 @@ public:
localSizeSpecId[1] != TQualifier::layoutNotSet ||
localSizeSpecId[2] != TQualifier::layoutNotSet;
}
#ifdef GLSLANG_WEB
void output(TInfoSink&, bool tree) { }
bool isEsProfile() const { return false; }
bool getXfbMode() const { return false; }
bool isMultiStream() const { return false; }
TLayoutGeometry getOutputPrimitive() const { return ElgNone; }
bool getPostDepthCoverage() const { return false; }
bool getEarlyFragmentTests() const { return false; }
TLayoutDepth getDepth() const { return EldNone; }
bool getPixelCenterInteger() const { return false; }
void setOriginUpperLeft() { }
bool getOriginUpperLeft() const { return true; }
TInterlockOrdering getInterlockOrdering() const { return EioNone; }
bool getAutoMapBindings() const { return false; }
bool getAutoMapLocations() const { return false; }
int getNumPushConstants() const { return 0; }
void addShaderRecordCount() { }
void addTaskNVCount() { }
void setUseVulkanMemoryModel() { }
bool usingVulkanMemoryModel() const { return false; }
bool usingPhysicalStorageBuffer() const { return false; }
bool usingVariablePointers() const { return false; }
unsigned getXfbStride(int buffer) const { return 0; }
bool hasLayoutDerivativeModeNone() const { return false; }
ComputeDerivativeMode getLayoutDerivativeModeNone() const { return LayoutDerivativeNone; }
#else
void output(TInfoSink&, bool tree);
bool isEsProfile() const { return profile == EEsProfile; }
@@ -728,6 +727,65 @@ public:
useVariablePointers = true;
processes.addProcess("use-variable-pointers");
}
// Set the global flag for bindless texture
void setBindlessTextureMode(const TString& currentCaller, AstRefType type)
{
// When type is not func, currentCaller should be "" (empty string)
bindlessTextureModeCaller[currentCaller] = type;
}
// Get the global flag for bindless texture
bool getBindlessTextureMode() const
{
return (bindlessTextureModeCaller.size() > 0);
}
// Set the global flag for bindless image
void setBindlessImageMode(const TString& currentCaller, AstRefType type)
{
// When type is not func, currentCaller should be "" (empty string)
bindlessImageModeCaller[currentCaller] = type;
}
// Get the global flag for bindless image
bool getBindlessImageMode() const
{
return (bindlessImageModeCaller.size() > 0);
}
// Get the global flag for bindless texture
bool resetTopLevelUncalledStatus(const TString& deadCaller)
{
// For reflection collection purpose, currently uniform layout setting and some
// flags introduced by variables (IO, global, etc,.) won't be reset here.
// Remove each global status (AST top level) introduced by uncalled functions.
// If a status is set by several functions, keep those which in call graph.
bool result = false;
// For two types of bindless mode flag, we would only reset which is set by an uncalled function.
// If one status flag's key in caller vec is empty, it should be come from a non-function setting.
if (!bindlessTextureModeCaller.empty()) {
auto caller = bindlessTextureModeCaller.find(deadCaller);
if (caller != bindlessTextureModeCaller.end() && bindlessTextureModeCaller[deadCaller] == AstRefTypeFunc) {
bindlessTextureModeCaller.erase(caller);
result = true;
}
}
if (!bindlessImageModeCaller.empty()) {
auto caller = bindlessImageModeCaller.find(deadCaller);
if (caller != bindlessImageModeCaller.end() && bindlessImageModeCaller[deadCaller] == AstRefTypeFunc) {
bindlessImageModeCaller.erase(caller);
result = true;
}
}
return result;
}
bool getBindlessMode() const
{
return getBindlessTextureMode() || getBindlessImageMode();
}
bool usingVariablePointers() const { return useVariablePointers; }
#ifdef ENABLE_HLSL
@@ -743,6 +801,7 @@ public:
int getNumPushConstants() const { return numPushConstants; }
void addShaderRecordCount() { ++numShaderRecordBlocks; }
void addTaskNVCount() { ++numTaskNVBlocks; }
void addTaskPayloadEXTCount() { ++numTaskEXTPayloads; }
bool setInvocations(int i)
{
@@ -808,10 +867,18 @@ public:
return true;
}
TLayoutGeometry getOutputPrimitive() const { return outputPrimitive; }
void setNonCoherentColorAttachmentReadEXT() { nonCoherentColorAttachmentReadEXT = true; }
bool getNonCoherentColorAttachmentReadEXT() const { return nonCoherentColorAttachmentReadEXT; }
void setNonCoherentDepthAttachmentReadEXT() { nonCoherentDepthAttachmentReadEXT = true; }
bool getNonCoherentDepthAttachmentReadEXT() const { return nonCoherentDepthAttachmentReadEXT; }
void setNonCoherentStencilAttachmentReadEXT() { nonCoherentStencilAttachmentReadEXT = true; }
bool getNonCoherentStencilAttachmentReadEXT() const { return nonCoherentStencilAttachmentReadEXT; }
void setPostDepthCoverage() { postDepthCoverage = true; }
bool getPostDepthCoverage() const { return postDepthCoverage; }
void setEarlyFragmentTests() { earlyFragmentTests = true; }
void setEarlyAndLateFragmentTestsAMD() { earlyAndLateFragmentTestsAMD = true; }
bool getEarlyFragmentTests() const { return earlyFragmentTests; }
bool getEarlyAndLateFragmentTestsAMD() const { return earlyAndLateFragmentTestsAMD; }
bool setDepth(TLayoutDepth d)
{
if (depthLayout != EldNone)
@@ -819,11 +886,21 @@ public:
depthLayout = d;
return true;
}
bool setStencil(TLayoutStencil s)
{
if (stencilLayout != ElsNone)
return stencilLayout == s;
stencilLayout = s;
return true;
}
TLayoutDepth getDepth() const { return depthLayout; }
TLayoutStencil getStencil() const { return stencilLayout; }
void setOriginUpperLeft() { originUpperLeft = true; }
bool getOriginUpperLeft() const { return originUpperLeft; }
void setPixelCenterInteger() { pixelCenterInteger = true; }
bool getPixelCenterInteger() const { return pixelCenterInteger; }
void setTexCoordRedeclared() { texCoordBuiltinRedeclared = true; }
bool getTexCoordRedeclared() const { return texCoordBuiltinRedeclared; }
void addBlendEquation(TBlendEquationShift b) { blendEquations |= (1 << b); }
unsigned int getBlendEquations() const { return blendEquations; }
bool setXfbBufferStride(int buffer, unsigned stride)
@@ -894,7 +971,6 @@ public:
void insertSpirvExecutionModeId(int executionMode, const TIntermAggregate* args);
bool hasSpirvExecutionMode() const { return spirvExecutionMode != nullptr; }
const TSpirvExecutionMode& getSpirvExecutionMode() const { return *spirvExecutionMode; }
#endif // GLSLANG_WEB
void addBlockStorageOverride(const char* nameStr, TBlockStorageClass backing)
{
@@ -1001,12 +1077,6 @@ public:
void setUniqueId(unsigned long long id) { uniqueId = id; }
// Certain explicit conversions are allowed conditionally
#ifdef GLSLANG_WEB
bool getArithemeticInt8Enabled() const { return false; }
bool getArithemeticInt16Enabled() const { return false; }
bool getArithemeticFloat16Enabled() const { return false; }
void updateNumericFeature(TNumericFeatures::feature f, bool on) { }
#else
bool getArithemeticInt8Enabled() const {
return numericFeatures.contains(TNumericFeatures::shader_explicit_arithmetic_types) ||
numericFeatures.contains(TNumericFeatures::shader_explicit_arithmetic_types_int8);
@@ -1024,12 +1094,11 @@ public:
}
void updateNumericFeature(TNumericFeatures::feature f, bool on)
{ on ? numericFeatures.insert(f) : numericFeatures.erase(f); }
#endif
protected:
TIntermSymbol* addSymbol(long long Id, const TString&, const TType&, const TConstUnionArray&, TIntermTyped* subtree, const TSourceLoc&);
void error(TInfoSink& infoSink, const char*);
void warn(TInfoSink& infoSink, const char*);
void error(TInfoSink& infoSink, const char*, EShLanguage unitStage = EShLangCount);
void warn(TInfoSink& infoSink, const char*, EShLanguage unitStage = EShLangCount);
void mergeCallGraphs(TInfoSink&, TIntermediate&);
void mergeModes(TInfoSink&, TIntermediate&);
void mergeTrees(TInfoSink&, TIntermediate&);
@@ -1066,13 +1135,8 @@ protected:
typedef std::list<TCall> TGraph;
TGraph callGraph;
#ifdef GLSLANG_ANGLE
const EProfile profile = ECoreProfile;
const int version = 450;
#else
EProfile profile; // source profile
int version; // source version
#endif
SpvVersion spvVersion;
TIntermNode* treeRoot;
std::set<std::string> requestedExtensions; // cumulation of all enabled or required extensions; not connected to what subset of the shader used them
@@ -1083,10 +1147,13 @@ protected:
bool recursive;
bool invertY;
bool dxPositionW;
bool enhancedMsgs;
bool debugInfo;
bool useStorageBuffer;
bool invariantAll;
bool nanMinMaxClamp; // true if desiring min/max/clamp to favor non-NaN over NaN
bool depthReplacing;
bool stencilReplacing;
int localSize[3];
bool localSizeNotDefault[3];
int localSizeSpecId[3];
@@ -1098,7 +1165,6 @@ protected:
unsigned int globalUniformBlockBinding;
unsigned int atomicCounterBlockSet;
#ifndef GLSLANG_WEB
public:
const char* const implicitThisName;
const char* const implicitCounterName;
@@ -1111,13 +1177,19 @@ protected:
TLayoutGeometry outputPrimitive;
bool pixelCenterInteger;
bool originUpperLeft;
bool texCoordBuiltinRedeclared;
TVertexSpacing vertexSpacing;
TVertexOrder vertexOrder;
TInterlockOrdering interlockOrdering;
bool pointMode;
bool earlyFragmentTests;
bool postDepthCoverage;
bool earlyAndLateFragmentTestsAMD;
bool nonCoherentColorAttachmentReadEXT;
bool nonCoherentDepthAttachmentReadEXT;
bool nonCoherentStencilAttachmentReadEXT;
TLayoutDepth depthLayout;
TLayoutStencil stencilLayout;
bool hlslFunctionality1;
int blendEquations; // an 'or'ing of masks of shifts of TBlendEquationShift
bool xfbMode;
@@ -1130,6 +1202,7 @@ protected:
int primitives;
int numTaskNVBlocks;
bool layoutPrimitiveCulling;
int numTaskEXTPayloads;
// Base shift values
std::array<unsigned int, EResCount> shiftBinding;
@@ -1157,20 +1230,22 @@ protected:
TSpirvRequirement* spirvRequirement;
TSpirvExecutionMode* spirvExecutionMode;
std::map<TString, AstRefType> bindlessTextureModeCaller;
std::map<TString, AstRefType> bindlessImageModeCaller;
std::unordered_map<std::string, int> uniformLocationOverrides;
int uniformLocationBase;
TNumericFeatures numericFeatures;
#endif
std::unordered_map<std::string, TBlockStorageClass> blockBackingOverrides;
std::unordered_set<int> usedConstantId; // specialization constant ids used
std::vector<TOffsetRange> usedAtomics; // sets of bindings used by atomic counters
std::vector<TIoRange> usedIo[4]; // sets of used locations, one for each of in, out, uniform, and buffers
std::vector<TRange> usedIoRT[2]; // sets of used location, one for rayPayload/rayPayloadIN and other
// for callableData/callableDataIn
std::vector<TRange> usedIoRT[4]; // sets of used location, one for rayPayload/rayPayloadIN,
// one for callableData/callableDataIn, one for hitObjectAttributeNV and
// one for shaderrecordhitobjectNV
// set of names of statically read/written I/O that might need extra checking
std::set<TString> ioAccessed;
// source code of shader, useful as part of debug information
std::string sourceFile;
std::string sourceText;
@@ -198,7 +198,7 @@ void TConstTraverser::visitConstantUnion(TIntermConstantUnion* node)
bool TIntermediate::parseConstTree(TIntermNode* root, TConstUnionArray unionArray, TOperator constructorType, const TType& t, bool singleConstantParam)
{
if (root == 0)
if (root == nullptr)
return false;
TConstTraverser it(unionArray, singleConstantParam, constructorType, t);
@@ -58,72 +58,18 @@ public:
const SpvVersion& spvVersion, EShLanguage language, TInfoSink& infoSink,
bool forwardCompatible, EShMessages messages)
:
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
forwardCompatible(forwardCompatible),
profile(profile),
#endif
infoSink(infoSink), version(version),
language(language),
spvVersion(spvVersion),
intermediate(interm), messages(messages), numErrors(0), currentScanner(0) { }
intermediate(interm), messages(messages), numErrors(0), currentScanner(nullptr) { }
virtual ~TParseVersions() { }
void requireStage(const TSourceLoc&, EShLanguageMask, const char* featureDesc);
void requireStage(const TSourceLoc&, EShLanguage, const char* featureDesc);
#ifdef GLSLANG_WEB
const EProfile profile = EEsProfile;
bool isEsProfile() const { return true; }
void requireProfile(const TSourceLoc& loc, int profileMask, const char* featureDesc)
{
if (! (EEsProfile & profileMask))
error(loc, "not supported with this profile:", featureDesc, ProfileName(profile));
}
void profileRequires(const TSourceLoc& loc, int profileMask, int minVersion, int numExtensions,
const char* const extensions[], const char* featureDesc)
{
if ((EEsProfile & profileMask) && (minVersion == 0 || version < minVersion))
error(loc, "not supported for this version or the enabled extensions", featureDesc, "");
}
void profileRequires(const TSourceLoc& loc, int profileMask, int minVersion, const char* extension,
const char* featureDesc)
{
profileRequires(loc, profileMask, minVersion, extension ? 1 : 0, &extension, featureDesc);
}
void initializeExtensionBehavior() { }
void checkDeprecated(const TSourceLoc&, int queryProfiles, int depVersion, const char* featureDesc) { }
void requireNotRemoved(const TSourceLoc&, int queryProfiles, int removedVersion, const char* featureDesc) { }
void requireExtensions(const TSourceLoc&, int numExtensions, const char* const extensions[],
const char* featureDesc) { }
void ppRequireExtensions(const TSourceLoc&, int numExtensions, const char* const extensions[],
const char* featureDesc) { }
TExtensionBehavior getExtensionBehavior(const char*) { return EBhMissing; }
bool extensionTurnedOn(const char* const extension) { return false; }
bool extensionsTurnedOn(int numExtensions, const char* const extensions[]) { return false; }
void updateExtensionBehavior(int line, const char* const extension, const char* behavior) { }
void updateExtensionBehavior(const char* const extension, TExtensionBehavior) { }
void checkExtensionStage(const TSourceLoc&, const char* const extension) { }
void extensionRequires(const TSourceLoc&, const char* const extension, const char* behavior) { }
void fullIntegerCheck(const TSourceLoc&, const char* op) { }
void doubleCheck(const TSourceLoc&, const char* op) { }
bool float16Arithmetic() { return false; }
void requireFloat16Arithmetic(const TSourceLoc& loc, const char* op, const char* featureDesc) { }
bool int16Arithmetic() { return false; }
void requireInt16Arithmetic(const TSourceLoc& loc, const char* op, const char* featureDesc) { }
bool int8Arithmetic() { return false; }
void requireInt8Arithmetic(const TSourceLoc& loc, const char* op, const char* featureDesc) { }
void int64Check(const TSourceLoc&, const char* op, bool builtIn = false) { }
void explicitFloat32Check(const TSourceLoc&, const char* op, bool builtIn = false) { }
void explicitFloat64Check(const TSourceLoc&, const char* op, bool builtIn = false) { }
bool relaxedErrors() const { return false; }
bool suppressWarnings() const { return true; }
bool isForwardCompatible() const { return false; }
#else
#ifdef GLSLANG_ANGLE
const bool forwardCompatible = true;
const EProfile profile = ECoreProfile;
#else
bool forwardCompatible; // true if errors are to be given for use of deprecated features
EProfile profile; // the declared profile in the shader (core by default)
#endif
bool isEsProfile() const { return profile == EEsProfile; }
void requireProfile(const TSourceLoc& loc, int profileMask, const char* featureDesc);
void profileRequires(const TSourceLoc& loc, int profileMask, int minVersion, int numExtensions,
@@ -167,29 +113,19 @@ public:
virtual void explicitInt32Check(const TSourceLoc&, const char* op, bool builtIn = false);
virtual void explicitFloat32Check(const TSourceLoc&, const char* op, bool builtIn = false);
virtual void explicitFloat64Check(const TSourceLoc&, const char* op, bool builtIn = false);
virtual void fcoopmatCheck(const TSourceLoc&, const char* op, bool builtIn = false);
virtual void intcoopmatCheck(const TSourceLoc&, const char *op, bool builtIn = false);
virtual void fcoopmatCheckNV(const TSourceLoc&, const char* op, bool builtIn = false);
virtual void intcoopmatCheckNV(const TSourceLoc&, const char *op, bool builtIn = false);
virtual void coopmatCheck(const TSourceLoc&, const char* op, bool builtIn = false);
bool relaxedErrors() const { return (messages & EShMsgRelaxedErrors) != 0; }
bool suppressWarnings() const { return (messages & EShMsgSuppressWarnings) != 0; }
bool isForwardCompatible() const { return forwardCompatible; }
#endif // GLSLANG_WEB
virtual void spvRemoved(const TSourceLoc&, const char* op);
virtual void vulkanRemoved(const TSourceLoc&, const char* op);
virtual void requireVulkan(const TSourceLoc&, const char* op);
virtual void requireSpv(const TSourceLoc&, const char* op);
virtual void requireSpv(const TSourceLoc&, const char *op, unsigned int version);
#if defined(GLSLANG_WEB) && !defined(GLSLANG_WEB_DEVEL)
void C_DECL error(const TSourceLoc&, const char* szReason, const char* szToken,
const char* szExtraInfoFormat, ...) { addError(); }
void C_DECL warn(const TSourceLoc&, const char* szReason, const char* szToken,
const char* szExtraInfoFormat, ...) { }
void C_DECL ppError(const TSourceLoc&, const char* szReason, const char* szToken,
const char* szExtraInfoFormat, ...) { addError(); }
void C_DECL ppWarn(const TSourceLoc&, const char* szReason, const char* szToken,
const char* szExtraInfoFormat, ...) { }
#else
virtual void C_DECL error(const TSourceLoc&, const char* szReason, const char* szToken,
const char* szExtraInfoFormat, ...) = 0;
virtual void C_DECL warn(const TSourceLoc&, const char* szReason, const char* szToken,
@@ -198,7 +134,6 @@ public:
const char* szExtraInfoFormat, ...) = 0;
virtual void C_DECL ppWarn(const TSourceLoc&, const char* szReason, const char* szToken,
const char* szExtraInfoFormat, ...) = 0;
#endif
void addError() { ++numErrors; }
int getNumErrors() const { return numErrors; }
@@ -231,6 +166,7 @@ public:
protected:
TMap<TString, TExtensionBehavior> extensionBehavior; // for each extension string, what its current behavior is
TMap<TString, unsigned int> extensionMinSpv; // for each extension string, store minimum spirv required
TVector<TString> spvUnsupportedExt; // for extensions reserved for spv usage.
EShMessages messages; // errors/warnings/rule-sets
int numErrors; // number of compile-time errors encountered
TInputScanner* currentScanner;
@@ -378,8 +378,6 @@ namespace {
int op_cmpl(int a) { return ~a; }
int op_not(int a) { return !a; }
};
struct TBinop {
int token, precedence, (*op)(int, int);
} binop[] = {
@@ -412,6 +410,8 @@ struct TUnop {
{ '!', op_not },
};
} // anonymous namespace
#define NUM_ELEMENTS(A) (sizeof(A) / sizeof(A[0]))
int TPpContext::eval(int token, int precedence, bool shortCircuit, int& res, bool& err, TPpToken* ppToken)
@@ -736,7 +736,6 @@ int TPpContext::CPPline(TPpToken* ppToken)
parseContext.setCurrentLine(lineRes);
if (token != '\n') {
#ifndef GLSLANG_WEB
if (token == PpAtomConstString) {
parseContext.ppRequireExtensions(directiveLoc, 1, &E_GL_GOOGLE_cpp_style_line_directive, "filename-based #line");
// We need to save a copy of the string instead of pointing
@@ -746,9 +745,7 @@ int TPpContext::CPPline(TPpToken* ppToken)
parseContext.setCurrentSourceName(sourceName);
hasFile = true;
token = scanToken(ppToken);
} else
#endif
{
} else {
token = eval(token, MIN_PRECEDENCE, false, fileRes, fileErr, ppToken);
if (! fileErr) {
parseContext.setCurrentString(fileRes);
@@ -974,7 +971,6 @@ int TPpContext::readCPPline(TPpToken* ppToken)
case PpAtomLine:
token = CPPline(ppToken);
break;
#ifndef GLSLANG_WEB
case PpAtomInclude:
if(!parseContext.isReadingHLSL()) {
parseContext.ppRequireExtensions(ppToken->loc, 1, &E_GL_GOOGLE_include_directive, "#include");
@@ -984,7 +980,6 @@ int TPpContext::readCPPline(TPpToken* ppToken)
case PpAtomPragma:
token = CPPpragma(ppToken);
break;
#endif
case PpAtomUndef:
token = CPPundef(ppToken);
break;
@@ -1126,9 +1121,6 @@ int TPpContext::tMacroInput::scan(TPpToken* ppToken)
pasting = true;
}
// HLSL does expand macros before concatenation
if (pasting && pp->parseContext.isReadingHLSL())
pasting = false;
// TODO: preprocessor: properly handle whitespace (or lack of it) between tokens when expanding
if (token == PpAtomIdentifier) {
@@ -1138,9 +1130,12 @@ int TPpContext::tMacroInput::scan(TPpToken* ppToken)
break;
if (i >= 0) {
TokenStream* arg = expandedArgs[i];
if (arg == nullptr || pasting)
bool expanded = !!arg && !pasting;
// HLSL does expand macros before concatenation
if (arg == nullptr || (pasting && !pp->parseContext.isReadingHLSL()) ) {
arg = args[i];
pp->pushTokenStreamInput(*arg, prepaste);
}
pp->pushTokenStreamInput(*arg, prepaste, expanded);
return pp->scanToken(ppToken);
}
@@ -1183,6 +1178,9 @@ MacroExpandResult TPpContext::MacroExpand(TPpToken* ppToken, bool expandUndef, b
{
ppToken->space = false;
int macroAtom = atomStrings.getAtom(ppToken->name);
if (ppToken->fullyExpanded)
return MacroExpandNotStarted;
switch (macroAtom) {
case PpAtomLineMacro:
// Arguments which are macro have been replaced in the first stage.
@@ -1214,8 +1212,10 @@ MacroExpandResult TPpContext::MacroExpand(TPpToken* ppToken, bool expandUndef, b
MacroSymbol* macro = macroAtom == 0 ? nullptr : lookupMacroDef(macroAtom);
// no recursive expansions
if (macro != nullptr && macro->busy)
if (macro != nullptr && macro->busy) {
ppToken->fullyExpanded = true;
return MacroExpandNotStarted;
}
// not expanding undefined macros
if ((macro == nullptr || macro->undef) && ! expandUndef)
@@ -85,7 +85,7 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
namespace glslang {
TPpContext::TPpContext(TParseContextBase& pc, const std::string& rootFileName, TShader::Includer& inclr) :
preamble(0), strings(0), previous_token('\n'), parseContext(pc), includer(inclr), inComment(false),
preamble(nullptr), strings(nullptr), previous_token('\n'), parseContext(pc), includer(inclr), inComment(false),
rootFileName(rootFileName),
currentSourceFile(rootFileName),
disableEscapeSequences(false)
@@ -86,11 +86,6 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "../ParseHelper.h"
#include "PpTokens.h"
/* windows only pragma */
#ifdef _MSC_VER
#pragma warning(disable : 4127)
#endif
namespace glslang {
class TPpToken {
@@ -102,6 +97,7 @@ public:
i64val = 0;
loc.init();
name[0] = 0;
fullyExpanded = false;
}
// Used for comparing macro definitions, so checks what is relevant for that.
@@ -117,6 +113,8 @@ public:
// True if a space (for white space or a removed comment) should also be
// recognized, in front of the token returned:
bool space;
bool fullyExpanded;
// Numeric value of the token:
union {
int ival;
@@ -217,6 +215,7 @@ public:
virtual bool peekContinuedPasting(int) { return false; } // true when non-spaced tokens can paste
virtual bool endOfReplacementList() { return false; } // true when at the end of a macro replacement list (RHS of #define)
virtual bool isMacroInput() { return false; }
virtual bool isStringInput() { return false; }
// Will be called when we start reading tokens from this instance
virtual void notifyActivated() {}
@@ -357,7 +356,8 @@ protected:
// Scanner data:
int previous_token;
TParseContextBase& parseContext;
std::vector<int> lastLineTokens;
std::vector<TSourceLoc> lastLineTokenLocs;
// Get the next token from *stack* of input sources, popping input sources
// that are out of tokens, down until an input source is found that has a token.
// Return EndOfInput when there are no more tokens to be found by doing this.
@@ -371,7 +371,31 @@ protected:
break;
popInput();
}
if (!inputStack.empty() && inputStack.back()->isStringInput()) {
if (token == '\n') {
bool seenNumSign = false;
for (int i = 0; i < (int)lastLineTokens.size() - 1;) {
int curPos = i;
int curToken = lastLineTokens[i++];
if (curToken == '#' && lastLineTokens[i] == '#') {
curToken = PpAtomPaste;
i++;
}
if (curToken == '#') {
if (seenNumSign) {
parseContext.ppError(lastLineTokenLocs[curPos], "(#) can be preceded in its line only by spaces or horizontal tabs", "#", "");
} else {
seenNumSign = true;
}
}
}
lastLineTokens.clear();
lastLineTokenLocs.clear();
} else {
lastLineTokens.push_back(token);
lastLineTokenLocs.push_back(ppToken->loc);
}
}
return token;
}
int getChar() { return inputStack.back()->getch(); }
@@ -475,16 +499,27 @@ protected:
//
// From PpTokens.cpp
//
void pushTokenStreamInput(TokenStream&, bool pasting = false);
void pushTokenStreamInput(TokenStream&, bool pasting = false, bool expanded = false);
void UngetToken(int token, TPpToken*);
class tTokenInput : public tInput {
public:
tTokenInput(TPpContext* pp, TokenStream* t, bool prepasting) :
tTokenInput(TPpContext* pp, TokenStream* t, bool prepasting, bool expanded) :
tInput(pp),
tokens(t),
lastTokenPastes(prepasting) { }
virtual int scan(TPpToken *ppToken) override { return tokens->getToken(pp->parseContext, ppToken); }
lastTokenPastes(prepasting),
preExpanded(expanded) { }
virtual int scan(TPpToken *ppToken) override {
int token = tokens->getToken(pp->parseContext, ppToken);
ppToken->fullyExpanded = preExpanded;
if (tokens->atEnd() && token == PpAtomIdentifier) {
int macroAtom = pp->atomStrings.getAtom(ppToken->name);
MacroSymbol* macro = macroAtom == 0 ? nullptr : pp->lookupMacroDef(macroAtom);
if (macro && macro->functionLike)
ppToken->fullyExpanded = false;
}
return token;
}
virtual int getch() override { assert(0); return EndOfInput; }
virtual void ungetch() override { assert(0); }
virtual bool peekPasting() override { return tokens->peekTokenizedPasting(lastTokenPastes); }
@@ -492,6 +527,7 @@ protected:
protected:
TokenStream* tokens;
bool lastTokenPastes; // true if the last token in the input is to be pasted, rather than consumed as a token
bool preExpanded;
};
class tUngotTokenInput : public tInput {
@@ -512,7 +548,7 @@ protected:
public:
tStringInput(TPpContext* pp, TInputScanner& i) : tInput(pp), input(&i) { }
virtual int scan(TPpToken*) override;
bool isStringInput() override { return true; }
// Scanner used to get source stream characters.
// - Escaped newlines are handled here, invisibly to the caller.
// - All forms of newline are handled, and turned into just a '\n'.
@@ -3,6 +3,7 @@
// Copyright (C) 2013 LunarG, Inc.
// Copyright (C) 2017 ARM Limited.
// Copyright (C) 2015-2018 Google, Inc.
// Copyright (c) 2023, Mobica Limited
//
// All rights reserved.
//
@@ -259,7 +260,6 @@ int TPpContext::lFloatConst(int len, int ch, TPpToken* ppToken)
// Suffix:
bool isDouble = false;
bool isFloat16 = false;
#ifndef GLSLANG_WEB
if (ch == 'l' || ch == 'L') {
if (ifdepth == 0 && parseContext.intermediate.getSource() == EShSourceGlsl)
parseContext.doubleCheck(ppToken->loc, "double floating-point suffix");
@@ -299,14 +299,11 @@ int TPpContext::lFloatConst(int len, int ch, TPpToken* ppToken)
isFloat16 = true;
}
} else
#endif
if (ch == 'f' || ch == 'F') {
#ifndef GLSLANG_WEB
if (ifdepth == 0)
parseContext.profileRequires(ppToken->loc, EEsProfile, 300, nullptr, "floating-point suffix");
if (ifdepth == 0 && !parseContext.relaxedErrors())
parseContext.profileRequires(ppToken->loc, ~EEsProfile, 120, nullptr, "floating-point suffix");
#endif
if (ifdepth == 0 && !hasDecimalOrExponent)
parseContext.ppError(ppToken->loc, "float literal needs a decimal point or exponent", "", "");
saveName(ch);
@@ -480,9 +477,7 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken)
E_GL_EXT_shader_explicit_arithmetic_types_int16 };
static const int Num_Int16_Extensions = sizeof(Int16_Extensions) / sizeof(Int16_Extensions[0]);
ppToken->ival = 0;
ppToken->i64val = 0;
ppToken->space = false;
ppToken->clear();
ch = getch();
for (;;) {
while (ch == ' ' || ch == '\t') {
@@ -551,7 +546,7 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken)
ival = 0;
do {
if (len < MaxTokenLength && ival <= 0x0fffffffffffffffull) {
if (len < MaxTokenLength && ival <= 0x7fffffffffffffffull) {
ppToken->name[len++] = (char)ch;
if (ch >= '0' && ch <= '9') {
ii = ch - '0';
@@ -584,7 +579,6 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken)
ppToken->name[len++] = (char)ch;
isUnsigned = true;
#ifndef GLSLANG_WEB
int nextCh = getch();
if (nextCh == 'l' || nextCh == 'L') {
if (len < MaxTokenLength)
@@ -610,7 +604,6 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken)
if (len < MaxTokenLength)
ppToken->name[len++] = (char)ch;
isInt16 = true;
#endif
} else
ungetch();
ppToken->name[len] = '\0';
@@ -641,6 +634,108 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken)
ppToken->ival = (int)ival;
return isUnsigned ? PpAtomConstUint : PpAtomConstInt;
}
} else if ((ch == 'b' || ch == 'B') && pp->parseContext.intermediate.getSource() == EShSourceHlsl) {
// must be binary
bool isUnsigned = false;
bool isInt64 = false;
bool isInt16 = false;
ppToken->name[len++] = (char)ch;
ch = getch();
// Check value
if ((ch == '0' || ch == '1'))
{
ival = 0;
do {
if (len < MaxTokenLength && ival <= 0x7fffffffffffffffull) {
ppToken->name[len++] = (char)ch;
if (ch == '0' || ch == '1') {
ii = ch - '0';
} else {
pp->parseContext.ppError(ppToken->loc, "bad digit in binary literal", "", "");
}
ival = (ival << 1) | ii;
}
else
{
if (! AlreadyComplained) {
if(len < MaxTokenLength)
pp->parseContext.ppError(ppToken->loc, "binary literal too big", "", "");
else
pp->parseContext.ppError(ppToken->loc, "binary literal too long", "", "");
AlreadyComplained = 1;
}
ival = 0xffffffffffffffffull;
}
ch = getch();
} while (ch == '0' || ch == '1');
}
else
{
pp->parseContext.ppError(ppToken->loc, "bad digit in binary literal", "", "");
}
// check type
if (ch == 'u' || ch == 'U') {
if (len < MaxTokenLength)
ppToken->name[len++] = (char)ch;
isUnsigned = true;
int nextCh = getch();
if (nextCh == 'l' || nextCh == 'L') {
if (len < MaxTokenLength)
ppToken->name[len++] = (char)nextCh;
isInt64 = true;
} else
ungetch();
nextCh = getch();
if ((nextCh == 's' || nextCh == 'S') &&
pp->parseContext.intermediate.getSource() == EShSourceGlsl) {
if (len < MaxTokenLength)
ppToken->name[len++] = (char)nextCh;
isInt16 = true;
} else
ungetch();
} else if (ch == 'l' || ch == 'L') {
if (len < MaxTokenLength)
ppToken->name[len++] = (char)ch;
isInt64 = true;
} else if ((ch == 's' || ch == 'S') &&
pp->parseContext.intermediate.getSource() == EShSourceGlsl) {
if (len < MaxTokenLength)
ppToken->name[len++] = (char)ch;
isInt16 = true;
} else {
ungetch();
}
ppToken->name[len] = '\0';
// Assign value
if (isInt64 && pp->parseContext.intermediate.getSource() == EShSourceGlsl) {
if (pp->ifdepth == 0) {
pp->parseContext.requireProfile(ppToken->loc, ~EEsProfile,
"64-bit binary literal");
pp->parseContext.profileRequires(ppToken->loc, ~EEsProfile, 0,
Num_Int64_Extensions, Int64_Extensions, "64-bit binary literal");
}
ppToken->i64val = ival;
return isUnsigned ? PpAtomConstUint64 : PpAtomConstInt64;
} else if (isInt16) {
if (pp->ifdepth == 0) {
if (pp->parseContext.intermediate.getSource() == EShSourceGlsl) {
pp->parseContext.requireProfile(ppToken->loc, ~EEsProfile,
"16-bit binary literal");
pp->parseContext.profileRequires(ppToken->loc, ~EEsProfile, 0,
Num_Int16_Extensions, Int16_Extensions, "16-bit binary literal");
}
}
ppToken->ival = (int)ival;
return isUnsigned ? PpAtomConstUint16 : PpAtomConstInt16;
} else {
ppToken->ival = (int)ival;
return isUnsigned ? PpAtomConstUint : PpAtomConstInt;
}
} else {
// could be octal integer or floating point, speculative pursue octal until it must be floating point
@@ -692,7 +787,6 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken)
ppToken->name[len++] = (char)ch;
isUnsigned = true;
#ifndef GLSLANG_WEB
int nextCh = getch();
if (nextCh == 'l' || nextCh == 'L') {
if (len < MaxTokenLength)
@@ -718,7 +812,6 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken)
if (len < MaxTokenLength)
ppToken->name[len++] = (char)ch;
isInt16 = true;
#endif
} else
ungetch();
ppToken->name[len] = '\0';
@@ -781,7 +874,6 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken)
ppToken->name[len++] = (char)ch;
isUnsigned = true;
#ifndef GLSLANG_WEB
int nextCh = getch();
if (nextCh == 'l' || nextCh == 'L') {
if (len < MaxTokenLength)
@@ -807,7 +899,6 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken)
if (len < MaxTokenLength)
ppToken->name[len++] = (char)ch;
isInt16 = true;
#endif
} else
ungetch();
@@ -85,9 +85,6 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#endif
#if (defined(_MSC_VER) && _MSC_VER < 1900 /*vs2015*/)
#define snprintf sprintf_s
#endif
#include <cassert>
#include <cstdlib>
@@ -116,17 +113,15 @@ int TPpContext::TokenStream::getToken(TParseContextBase& parseContext, TPpToken
int atom = stream[currentPos++].get(*ppToken);
ppToken->loc = parseContext.getCurrentLoc();
#ifndef GLSLANG_WEB
// Check for ##, unless the current # is the last character
if (atom == '#') {
if (peekToken('#')) {
parseContext.requireProfile(ppToken->loc, ~EEsProfile, "token pasting (##)");
parseContext.profileRequires(ppToken->loc, ~EEsProfile, 130, 0, "token pasting (##)");
parseContext.profileRequires(ppToken->loc, ~EEsProfile, 130, nullptr, "token pasting (##)");
currentPos++;
atom = PpAtomPaste;
}
}
#endif
return atom;
}
@@ -195,9 +190,9 @@ bool TPpContext::TokenStream::peekUntokenizedPasting()
return pasting;
}
void TPpContext::pushTokenStreamInput(TokenStream& ts, bool prepasting)
void TPpContext::pushTokenStreamInput(TokenStream& ts, bool prepasting, bool expanded)
{
pushInput(new tTokenInput(this, &ts, prepasting));
pushInput(new tTokenInput(this, &ts, prepasting, expanded));
ts.reset();
}
@@ -37,8 +37,6 @@
// propagate the 'noContraction' qualifier.
//
#ifndef GLSLANG_WEB
#include "propagateNoContraction.h"
#include <cstdlib>
@@ -423,7 +421,7 @@ getSymbolToDefinitionMappingAndPreciseSymbolIDs(const glslang::TIntermediate& in
ReturnBranchNodeSet());
TIntermNode* root = intermediate.getTreeRoot();
if (root == 0)
if (root == nullptr)
return result_tuple;
NodeMapping& symbol_definition_mapping = std::get<0>(result_tuple);
@@ -865,6 +863,4 @@ void PropagateNoContraction(const glslang::TIntermediate& intermediate)
precise_object_accesschains.erase(precise_object_accesschain);
}
}
};
#endif // GLSLANG_WEB
}
@@ -33,8 +33,6 @@
// POSSIBILITY OF SUCH DAMAGE.
//
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
#include "../Include/Common.h"
#include "reflection.h"
#include "LiveTraverser.h"
@@ -251,7 +249,7 @@ public:
void blowUpActiveAggregate(const TType& baseType, const TString& baseName, const TList<TIntermBinary*>& derefs,
TList<TIntermBinary*>::const_iterator deref, int offset, int blockIndex, int arraySize,
int topLevelArraySize, int topLevelArrayStride, TStorageQualifier baseStorage, bool active,
const TConstUnionArray* constArray = nullptr)
const TConstUnionArray* constArray = nullptr)
{
// when strictArraySuffix is enabled, we closely follow the rules from ARB_program_interface_query.
// Broadly:
@@ -266,18 +264,18 @@ public:
// process the part of the dereference chain that was explicit in the shader
TString name = baseName;
const TType* terminalType = &baseType;
const TConstUnionArray* terminalConstArray = constArray;
const TConstUnionArray* terminalConstArray = constArray;
for (; deref != derefs.end(); ++deref) {
TIntermBinary* visitNode = *deref;
terminalType = &visitNode->getType();
if (visitNode->getAsSymbolNode())
terminalConstArray = &visitNode->getAsSymbolNode()->getConstArray();
else if (visitNode->getAsConstantUnion())
terminalConstArray = &visitNode->getAsConstantUnion()->getConstArray();
else if (visitNode->getLeft() != nullptr && visitNode->getLeft()->getAsSymbolNode())
terminalConstArray = &visitNode->getLeft()->getAsSymbolNode()->getConstArray();
else
terminalConstArray = nullptr;
if (visitNode->getAsSymbolNode())
terminalConstArray = &visitNode->getAsSymbolNode()->getConstArray();
else if (visitNode->getAsConstantUnion())
terminalConstArray = &visitNode->getAsConstantUnion()->getConstArray();
else if (visitNode->getLeft() != nullptr && visitNode->getLeft()->getAsSymbolNode())
terminalConstArray = &visitNode->getLeft()->getAsSymbolNode()->getConstArray();
else
terminalConstArray = nullptr;
int index;
switch (visitNode->getOp()) {
case EOpIndexIndirect: {
@@ -692,7 +690,7 @@ public:
}
// For a binary operation indexing into an aggregate, chase down the base of the aggregate.
// Return 0 if the topology does not fit this situation.
// Return nullptr if the topology does not fit this situation.
TIntermSymbol* findBase(const TIntermBinary* node)
{
TIntermSymbol *base = node->getLeft()->getAsSymbolNode();
@@ -1280,5 +1278,3 @@ void TReflection::dump()
}
} // end namespace glslang
#endif // !GLSLANG_WEB && !GLSLANG_ANGLE
@@ -33,8 +33,6 @@
// POSSIBILITY OF SUCH DAMAGE.
//
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
#ifndef _REFLECTION_INCLUDED
#define _REFLECTION_INCLUDED
@@ -219,5 +217,3 @@ protected:
} // end namespace glslang
#endif // _REFLECTION_INCLUDED
#endif // !GLSLANG_WEB && !GLSLANG_ANGLE
@@ -0,0 +1,92 @@
#pragma once
//
// Copyright (C) 2023 LunarG, Inc.
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// Partial implementation of std::span for C++11
// Replace with std::span if repo standard is bumped to C++20
//
// This code was copied from https://github.com/KhronosGroup/Vulkan-ValidationLayers/blob/main/layers/containers/custom_containers.h
template <typename T>
class span {
public:
using pointer = T *;
using const_pointer = T const *;
using iterator = pointer;
using const_iterator = const_pointer;
span() = default;
span(pointer start, size_t n) : data_(start), count_(n) {}
template <typename Iterator>
span(Iterator start, Iterator end) : data_(&(*start)), count_(end - start) {}
template <typename Container>
span(Container &c) : data_(c.data()), count_(c.size()) {}
iterator begin() { return data_; }
const_iterator begin() const { return data_; }
iterator end() { return data_ + count_; }
const_iterator end() const { return data_ + count_; }
T &operator[](int i) { return data_[i]; }
const T &operator[](int i) const { return data_[i]; }
T &front() { return *data_; }
const T &front() const { return *data_; }
T &back() { return *(data_ + (count_ - 1)); }
const T &back() const { return *(data_ + (count_ - 1)); }
size_t size() const { return count_; }
bool empty() const { return count_ == 0; }
pointer data() { return data_; }
const_pointer data() const { return data_; }
private:
pointer data_ = {};
size_t count_ = 0;
};
//
// Allow type inference that using the constructor doesn't allow in C++11
template <typename T>
span<T> make_span(T *begin, size_t count) {
return span<T>(begin, count);
}
template <typename T>
span<T> make_span(T *begin, T *end) {
return make_span<T>(begin, end);
}
@@ -36,15 +36,8 @@
// This file contains the Linux-specific functions
//
#include "../osinclude.h"
#include "../../../OGLCompilersDLL/InitializeDll.h"
#include <pthread.h>
#include <semaphore.h>
#include <assert.h>
#include <errno.h>
#include <stdint.h>
#include <cstdio>
#include <sys/time.h>
#if !defined(__Fuchsia__)
#include <sys/resource.h>
@@ -52,150 +45,6 @@
namespace glslang {
//
// Thread cleanup
//
//
// Wrapper for Linux call to DetachThread. This is required as pthread_cleanup_push() expects
// the cleanup routine to return void.
//
static void DetachThreadLinux(void *)
{
DetachThread();
}
//
// Registers cleanup handler, sets cancel type and state, and executes the thread specific
// cleanup handler. This function will be called in the Standalone.cpp for regression
// testing. When OpenGL applications are run with the driver code, Linux OS does the
// thread cleanup.
//
void OS_CleanupThreadData(void)
{
#if defined(__ANDROID__) || defined(__Fuchsia__)
DetachThreadLinux(NULL);
#else
int old_cancel_state, old_cancel_type;
void *cleanupArg = NULL;
//
// Set thread cancel state and push cleanup handler.
//
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &old_cancel_state);
pthread_cleanup_push(DetachThreadLinux, (void *) cleanupArg);
//
// Put the thread in deferred cancellation mode.
//
pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &old_cancel_type);
//
// Pop cleanup handler and execute it prior to unregistering the cleanup handler.
//
pthread_cleanup_pop(1);
//
// Restore the thread's previous cancellation mode.
//
pthread_setcanceltype(old_cancel_state, NULL);
#endif
}
//
// Thread Local Storage Operations
//
inline OS_TLSIndex PthreadKeyToTLSIndex(pthread_key_t key)
{
return (OS_TLSIndex)((uintptr_t)key + 1);
}
inline pthread_key_t TLSIndexToPthreadKey(OS_TLSIndex nIndex)
{
return (pthread_key_t)((uintptr_t)nIndex - 1);
}
OS_TLSIndex OS_AllocTLSIndex()
{
pthread_key_t pPoolIndex;
//
// Create global pool key.
//
if ((pthread_key_create(&pPoolIndex, NULL)) != 0) {
assert(0 && "OS_AllocTLSIndex(): Unable to allocate Thread Local Storage");
return OS_INVALID_TLS_INDEX;
}
else
return PthreadKeyToTLSIndex(pPoolIndex);
}
bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue)
{
if (nIndex == OS_INVALID_TLS_INDEX) {
assert(0 && "OS_SetTLSValue(): Invalid TLS Index");
return false;
}
if (pthread_setspecific(TLSIndexToPthreadKey(nIndex), lpvValue) == 0)
return true;
else
return false;
}
void* OS_GetTLSValue(OS_TLSIndex nIndex)
{
//
// This function should return 0 if nIndex is invalid.
//
assert(nIndex != OS_INVALID_TLS_INDEX);
return pthread_getspecific(TLSIndexToPthreadKey(nIndex));
}
bool OS_FreeTLSIndex(OS_TLSIndex nIndex)
{
if (nIndex == OS_INVALID_TLS_INDEX) {
assert(0 && "OS_SetTLSValue(): Invalid TLS Index");
return false;
}
//
// Delete the global pool key.
//
if (pthread_key_delete(TLSIndexToPthreadKey(nIndex)) == 0)
return true;
else
return false;
}
namespace {
pthread_mutex_t gMutex;
}
static void InitMutex(void)
{
pthread_mutexattr_t mutexattr;
pthread_mutexattr_init(&mutexattr);
pthread_mutexattr_settype(&mutexattr, PTHREAD_MUTEX_RECURSIVE);
pthread_mutex_init(&gMutex, &mutexattr);
}
void InitGlobalLock()
{
static pthread_once_t once = PTHREAD_ONCE_INIT;
pthread_once(&once, InitMutex);
}
void GetGlobalLock()
{
pthread_mutex_lock(&gMutex);
}
void ReleaseGlobalLock()
{
pthread_mutex_unlock(&gMutex);
}
// #define DUMP_COUNTERS
void OS_DumpMemoryCounters()
@@ -141,6 +141,15 @@ const TBuiltInResource DefaultTBuiltInResource = {
/* .maxTaskWorkGroupSizeY_NV = */ 1,
/* .maxTaskWorkGroupSizeZ_NV = */ 1,
/* .maxMeshViewCountNV = */ 4,
/* .maxMeshOutputVerticesEXT = */ 256,
/* .maxMeshOutputPrimitivesEXT = */ 512,
/* .maxMeshWorkGroupSizeX_EXT = */ 32,
/* .maxMeshWorkGroupSizeY_EXT = */ 1,
/* .maxMeshWorkGroupSizeZ_EXT = */ 1,
/* .maxTaskWorkGroupSizeX_EXT = */ 32,
/* .maxTaskWorkGroupSizeY_EXT = */ 1,
/* .maxTaskWorkGroupSizeZ_EXT = */ 1,
/* .maxMeshViewCountEXT = */ 4,
/* .maxDualSourceDrawBuffersEXT = */ 1,
/* .limits = */ {
@@ -25,7 +25,7 @@ Module['compileGLSLZeroCopy'] = function(glsl, shader_stage, gen_debug, spirv_ve
var p_output = Module['_malloc'](4);
var p_output_len = Module['_malloc'](4);
var id = ccall('convert_glsl_to_spirv',
var id = Module['ccall']('convert_glsl_to_spirv',
'number',
['string', 'number', 'boolean', 'number', 'number', 'number'],
[glsl, shader_stage_int, gen_debug, spirv_version_int, p_output, p_output_len]);
@@ -37,11 +37,9 @@
#define STRICT
#define VC_EXTRALEAN 1
#include <windows.h>
#include <cassert>
#include <process.h>
#include <psapi.h>
#include <cstdio>
#include <cstdint>
//
// This file contains the Window-OS-specific functions
@@ -53,84 +51,6 @@
namespace glslang {
inline OS_TLSIndex ToGenericTLSIndex (DWORD handle)
{
return (OS_TLSIndex)((uintptr_t)handle + 1);
}
inline DWORD ToNativeTLSIndex (OS_TLSIndex nIndex)
{
return (DWORD)((uintptr_t)nIndex - 1);
}
//
// Thread Local Storage Operations
//
OS_TLSIndex OS_AllocTLSIndex()
{
DWORD dwIndex = TlsAlloc();
if (dwIndex == TLS_OUT_OF_INDEXES) {
assert(0 && "OS_AllocTLSIndex(): Unable to allocate Thread Local Storage");
return OS_INVALID_TLS_INDEX;
}
return ToGenericTLSIndex(dwIndex);
}
bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue)
{
if (nIndex == OS_INVALID_TLS_INDEX) {
assert(0 && "OS_SetTLSValue(): Invalid TLS Index");
return false;
}
if (TlsSetValue(ToNativeTLSIndex(nIndex), lpvValue))
return true;
else
return false;
}
void* OS_GetTLSValue(OS_TLSIndex nIndex)
{
assert(nIndex != OS_INVALID_TLS_INDEX);
return TlsGetValue(ToNativeTLSIndex(nIndex));
}
bool OS_FreeTLSIndex(OS_TLSIndex nIndex)
{
if (nIndex == OS_INVALID_TLS_INDEX) {
assert(0 && "OS_SetTLSValue(): Invalid TLS Index");
return false;
}
if (TlsFree(ToNativeTLSIndex(nIndex)))
return true;
else
return false;
}
HANDLE GlobalLock;
void InitGlobalLock()
{
GlobalLock = CreateMutex(0, false, 0);
}
void GetGlobalLock()
{
WaitForSingleObject(GlobalLock, INFINITE);
}
void ReleaseGlobalLock()
{
ReleaseMutex(GlobalLock);
}
unsigned int __stdcall EnterGenericThread (void* entry)
{
return ((TThreadEntrypoint)entry)(0);
}
//#define DUMP_COUNTERS
void OS_DumpMemoryCounters()
@@ -37,25 +37,6 @@
namespace glslang {
//
// Thread Local Storage Operations
//
typedef void* OS_TLSIndex;
#define OS_INVALID_TLS_INDEX ((void*)0)
OS_TLSIndex OS_AllocTLSIndex();
bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue);
bool OS_FreeTLSIndex(OS_TLSIndex nIndex);
void* OS_GetTLSValue(OS_TLSIndex nIndex);
void InitGlobalLock();
void GetGlobalLock();
void ReleaseGlobalLock();
typedef unsigned int (*TThreadEntrypoint)(void*);
void OS_CleanupThreadData(void);
void OS_DumpMemoryCounters();
} // end namespace glslang
@@ -1,5 +1,6 @@
//
// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
// Copyright (C) 2016 Google, Inc.
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@@ -14,7 +15,7 @@
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
// Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
@@ -30,45 +31,27 @@
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
#include "glslang/OGLCompilersDLL/InitializeDll.h"
#ifndef _STAND_ALONE_RESOURCE_LIMITS_INCLUDED_
#define _STAND_ALONE_RESOURCE_LIMITS_INCLUDED_
#define STRICT
#define VC_EXTRALEAN 1
#include <windows.h>
#include <assert.h>
#include <string>
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
#include "../Include/ResourceLimits.h"
if (! glslang::InitProcess())
return FALSE;
break;
case DLL_THREAD_ATTACH:
// Return pointer to user-writable Resource to pass through API in
// future-proof way.
extern TBuiltInResource* GetResources();
if (! glslang::InitThread())
return FALSE;
break;
// These are the default resources for TBuiltInResources, used for both
// - parsing this string for the case where the user didn't supply one,
// - dumping out a template for user construction of a config file.
extern const TBuiltInResource* GetDefaultResources();
case DLL_THREAD_DETACH:
// Returns the DefaultTBuiltInResource as a human-readable string.
std::string GetDefaultTBuiltInResourceString();
if (! glslang::DetachThread())
return FALSE;
break;
// Decodes the resource limits from |config| to |resources|.
void DecodeResourceLimits(TBuiltInResource* resources, char* config);
case DLL_PROCESS_DETACH:
glslang::DetachProcess();
break;
default:
assert(0 && "DllMain(): Reason for calling DLL Main is unknown");
return FALSE;
}
return TRUE;
}
#endif // _STAND_ALONE_RESOURCE_LIMITS_INCLUDED_
@@ -108,8 +108,10 @@ typedef enum {
EShLangMissNV = EShLangMiss,
EShLangCallable,
EShLangCallableNV = EShLangCallable,
EShLangTaskNV,
EShLangMeshNV,
EShLangTask,
EShLangTaskNV = EShLangTask,
EShLangMesh,
EShLangMeshNV = EShLangMesh,
LAST_ELEMENT_MARKER(EShLangCount),
} EShLanguage; // would be better as stage, but this is ancient now
@@ -132,8 +134,10 @@ typedef enum : unsigned {
EShLangMissNVMask = EShLangMissMask,
EShLangCallableMask = (1 << EShLangCallable),
EShLangCallableNVMask = EShLangCallableMask,
EShLangTaskNVMask = (1 << EShLangTaskNV),
EShLangMeshNVMask = (1 << EShLangMeshNV),
EShLangTaskMask = (1 << EShLangTask),
EShLangTaskNVMask = EShLangTaskMask,
EShLangMeshMask = (1 << EShLangMesh),
EShLangMeshNVMask = EShLangMeshMask,
LAST_ELEMENT_MARKER(EShLanguageMaskCount),
} EShLanguageMask;
@@ -151,8 +155,8 @@ typedef enum {
typedef enum {
EShClientNone, // use when there is no client, e.g. for validation
EShClientVulkan,
EShClientOpenGL,
EShClientVulkan, // as GLSL dialect, specifies KHR_vulkan_glsl extension
EShClientOpenGL, // as GLSL dialect, specifies ARB_gl_spirv extension
LAST_ELEMENT_MARKER(EShClientCount),
} EShClient;
@@ -164,12 +168,12 @@ typedef enum {
} EShTargetLanguage;
typedef enum {
EShTargetUniversal = 0, // Universal
EShTargetVulkan_1_0 = (1 << 22), // Vulkan 1.0
EShTargetVulkan_1_1 = (1 << 22) | (1 << 12), // Vulkan 1.1
EShTargetVulkan_1_2 = (1 << 22) | (2 << 12), // Vulkan 1.2
EShTargetVulkan_1_3 = (1 << 22) | (3 << 12), // Vulkan 1.3
EShTargetOpenGL_450 = 450, // OpenGL
LAST_ELEMENT_MARKER(EShTargetClientVersionCount = 4),
LAST_ELEMENT_MARKER(EShTargetClientVersionCount = 5),
} EShTargetClientVersion;
typedef EShTargetClientVersion EshTargetClientVersion;
@@ -265,6 +269,7 @@ enum EShMessages : unsigned {
EShMsgHlslLegalization = (1 << 12), // enable HLSL Legalization messages
EShMsgHlslDX9Compatible = (1 << 13), // enable HLSL DX9 compatible mode (for samplers and semantics)
EShMsgBuiltinSymbolTable = (1 << 14), // print the builtin symbol table
EShMsgEnhanced = (1 << 15), // enhanced message readability
LAST_ELEMENT_MARKER(EShMsgCount),
};
@@ -301,7 +306,7 @@ typedef struct {
//
// ShHandle held by but opaque to the driver. It is allocated,
// managed, and de-allocated by the compiler/linker. It's contents
// managed, and de-allocated by the compiler/linker. Its contents
// are defined by and used by the compiler and linker. For example,
// symbol table information and object code passed from the compiler
// to the linker can be stored where ShHandle points.
@@ -314,8 +319,8 @@ typedef void* ShHandle;
// Driver calls these to create and destroy compiler/linker
// objects.
//
GLSLANG_EXPORT ShHandle ShConstructCompiler(const EShLanguage, int debugOptions); // one per shader
GLSLANG_EXPORT ShHandle ShConstructLinker(const EShExecutable, int debugOptions); // one per shader pair
GLSLANG_EXPORT ShHandle ShConstructCompiler(const EShLanguage, int /*debugOptions unused*/); // one per shader
GLSLANG_EXPORT ShHandle ShConstructLinker(const EShExecutable, int /*debugOptions unused*/); // one per shader pair
GLSLANG_EXPORT ShHandle ShConstructUniformMap(); // one per uniform namespace (currently entire program object)
GLSLANG_EXPORT void ShDestruct(ShHandle);
@@ -326,18 +331,13 @@ GLSLANG_EXPORT void ShDestruct(ShHandle);
// The info-log should be written by ShCompile into
// ShHandle, so it can answer future queries.
//
GLSLANG_EXPORT int ShCompile(
const ShHandle,
const char* const shaderStrings[],
const int numStrings,
const int* lengths,
const EShOptimizationLevel,
const TBuiltInResource *resources,
int debugOptions,
int defaultVersion = 110, // use 100 for ES environment, overridden by #version in shader
bool forwardCompatible = false, // give errors for use of deprecated features
EShMessages messages = EShMsgDefault // warnings and errors
);
GLSLANG_EXPORT int ShCompile(const ShHandle, const char* const shaderStrings[], const int numStrings,
const int* lengths, const EShOptimizationLevel, const TBuiltInResource* resources,
int, // debugOptions unused
int defaultVersion = 110, // use 100 for ES environment, overridden by #version in shader
bool forwardCompatible = false, // give errors for use of deprecated features
EShMessages messages = EShMsgDefault // warnings and errors
);
GLSLANG_EXPORT int ShLinkExt(
const ShHandle, // linker object
@@ -471,6 +471,8 @@ public:
GLSLANG_EXPORT void setSourceEntryPoint(const char* sourceEntryPointName);
GLSLANG_EXPORT void addProcesses(const std::vector<std::string>&);
GLSLANG_EXPORT void setUniqueId(unsigned long long id);
GLSLANG_EXPORT void setOverrideVersion(int version);
GLSLANG_EXPORT void setDebugInfo(bool debugInfo);
// IO resolver binding data: see comments in ShaderLang.cpp
GLSLANG_EXPORT void setShiftBinding(TResourceType res, unsigned int base);
@@ -489,6 +491,7 @@ public:
GLSLANG_EXPORT void setUniformLocationBase(int base);
GLSLANG_EXPORT void setInvertY(bool invert);
GLSLANG_EXPORT void setDxPositionW(bool dxPosW);
GLSLANG_EXPORT void setEnhancedMsgs();
#ifdef ENABLE_HLSL
GLSLANG_EXPORT void setHlslIoMapping(bool hlslIoMap);
GLSLANG_EXPORT void setFlattenUniformArrays(bool flatten);
@@ -516,11 +519,14 @@ public:
// use EShClientNone and version of 0, e.g. for validation mode.
// Note 'version' does not describe the target environment,
// just the version of the source dialect to compile under.
// For example, to choose the Vulkan dialect of GLSL defined by
// version 100 of the KHR_vulkan_glsl extension: lang = EShSourceGlsl,
// dialect = EShClientVulkan, and version = 100.
//
// See the definitions of TEnvironment, EShSource, EShLanguage,
// and EShClient for choices and more detail.
//
// setEnvClient: The client that will be hosting the execution, and it's version.
// setEnvClient: The client that will be hosting the execution, and its version.
// Note 'version' is not the version of the languages involved, but
// the version of the client environment.
// Use EShClientNone and version of 0 if there is no client, e.g.
@@ -563,6 +569,9 @@ public:
void setEnvInputVulkanRulesRelaxed() { environment.input.vulkanRulesRelaxed = true; }
bool getEnvInputVulkanRulesRelaxed() const { return environment.input.vulkanRulesRelaxed; }
void setCompileOnly() { compileOnly = true; }
bool getCompileOnly() const { return compileOnly; }
// Interface to #include handlers.
//
// To support #include, a client of Glslang does the following:
@@ -707,16 +716,20 @@ protected:
// a function in the source string can be renamed FROM this TO the name given in setEntryPoint.
std::string sourceEntryPointName;
// overrides #version in shader source or default version if #version isn't present
int overrideVersion;
TEnvironment environment;
// Indicates this shader is meant to be used without linking
bool compileOnly = false;
friend class TProgram;
private:
TShader& operator=(TShader&);
};
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
//
// A reflection database and its interface, consistent with the OpenGL API reflection queries.
//
@@ -727,7 +740,7 @@ public:
GLSLANG_EXPORT TObjectReflection(const std::string& pName, const TType& pType, int pOffset, int pGLDefineType, int pSize, int pIndex, const TConstUnionArray* pConstArray = nullptr);
const TType* getType() const { return type; }
const TConstUnionArray* getConstArray() const { return constArray; }
const TConstUnionArray* getConstArray() const { return constArray; }
GLSLANG_EXPORT int getBinding() const;
GLSLANG_EXPORT void dump() const;
static TObjectReflection badReflection() { return TObjectReflection(); }
@@ -752,7 +765,7 @@ protected:
}
const TType* type;
const TConstUnionArray* constArray;
const TConstUnionArray* constArray;
};
class TReflection;
@@ -835,8 +848,6 @@ public:
virtual void addStage(EShLanguage stage, TIntermediate& stageIntermediate) = 0;
};
#endif // !GLSLANG_WEB && !GLSLANG_ANGLE
// Make one TProgram per set of shaders that will get linked together. Add all
// the shaders that are to be linked together. After calling shader.parse()
// for all shaders, call link().
@@ -856,8 +867,6 @@ public:
TIntermediate* getIntermediate(EShLanguage stage) const { return intermediate[stage]; }
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
// Reflection Interface
// call first, to do liveness analysis, index mapping, etc.; returns false on failure
@@ -950,7 +959,6 @@ public:
// If resolver is not provided it uses the previous approach
// and respects auto assignment and offsets.
GLSLANG_EXPORT bool mapIO(TIoMapResolver* pResolver = nullptr, TIoMapper* pIoMapper = nullptr);
#endif // !GLSLANG_WEB && !GLSLANG_ANGLE
protected:
GLSLANG_EXPORT bool linkStage(EShLanguage, EShMessages);
@@ -961,9 +969,7 @@ protected:
TIntermediate* intermediate[EShLangCount];
bool newedIntermediate[EShLangCount]; // track which intermediate were "new" versus reusing a singleton unit in a stage
TInfoSink* infoSink;
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
TReflection* reflection;
#endif
bool linked;
private:
@@ -0,0 +1,542 @@
//
// Copyright (C) 2016 Google, Inc.
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <cctype>
#include "../../glslang/Public/ResourceLimits.h"
TBuiltInResource Resources;
const TBuiltInResource DefaultTBuiltInResource = {
/* .MaxLights = */ 32,
/* .MaxClipPlanes = */ 6,
/* .MaxTextureUnits = */ 32,
/* .MaxTextureCoords = */ 32,
/* .MaxVertexAttribs = */ 64,
/* .MaxVertexUniformComponents = */ 4096,
/* .MaxVaryingFloats = */ 64,
/* .MaxVertexTextureImageUnits = */ 32,
/* .MaxCombinedTextureImageUnits = */ 80,
/* .MaxTextureImageUnits = */ 32,
/* .MaxFragmentUniformComponents = */ 4096,
/* .MaxDrawBuffers = */ 32,
/* .MaxVertexUniformVectors = */ 128,
/* .MaxVaryingVectors = */ 8,
/* .MaxFragmentUniformVectors = */ 16,
/* .MaxVertexOutputVectors = */ 16,
/* .MaxFragmentInputVectors = */ 15,
/* .MinProgramTexelOffset = */ -8,
/* .MaxProgramTexelOffset = */ 7,
/* .MaxClipDistances = */ 8,
/* .MaxComputeWorkGroupCountX = */ 65535,
/* .MaxComputeWorkGroupCountY = */ 65535,
/* .MaxComputeWorkGroupCountZ = */ 65535,
/* .MaxComputeWorkGroupSizeX = */ 1024,
/* .MaxComputeWorkGroupSizeY = */ 1024,
/* .MaxComputeWorkGroupSizeZ = */ 64,
/* .MaxComputeUniformComponents = */ 1024,
/* .MaxComputeTextureImageUnits = */ 16,
/* .MaxComputeImageUniforms = */ 8,
/* .MaxComputeAtomicCounters = */ 8,
/* .MaxComputeAtomicCounterBuffers = */ 1,
/* .MaxVaryingComponents = */ 60,
/* .MaxVertexOutputComponents = */ 64,
/* .MaxGeometryInputComponents = */ 64,
/* .MaxGeometryOutputComponents = */ 128,
/* .MaxFragmentInputComponents = */ 128,
/* .MaxImageUnits = */ 8,
/* .MaxCombinedImageUnitsAndFragmentOutputs = */ 8,
/* .MaxCombinedShaderOutputResources = */ 8,
/* .MaxImageSamples = */ 0,
/* .MaxVertexImageUniforms = */ 0,
/* .MaxTessControlImageUniforms = */ 0,
/* .MaxTessEvaluationImageUniforms = */ 0,
/* .MaxGeometryImageUniforms = */ 0,
/* .MaxFragmentImageUniforms = */ 8,
/* .MaxCombinedImageUniforms = */ 8,
/* .MaxGeometryTextureImageUnits = */ 16,
/* .MaxGeometryOutputVertices = */ 256,
/* .MaxGeometryTotalOutputComponents = */ 1024,
/* .MaxGeometryUniformComponents = */ 1024,
/* .MaxGeometryVaryingComponents = */ 64,
/* .MaxTessControlInputComponents = */ 128,
/* .MaxTessControlOutputComponents = */ 128,
/* .MaxTessControlTextureImageUnits = */ 16,
/* .MaxTessControlUniformComponents = */ 1024,
/* .MaxTessControlTotalOutputComponents = */ 4096,
/* .MaxTessEvaluationInputComponents = */ 128,
/* .MaxTessEvaluationOutputComponents = */ 128,
/* .MaxTessEvaluationTextureImageUnits = */ 16,
/* .MaxTessEvaluationUniformComponents = */ 1024,
/* .MaxTessPatchComponents = */ 120,
/* .MaxPatchVertices = */ 32,
/* .MaxTessGenLevel = */ 64,
/* .MaxViewports = */ 16,
/* .MaxVertexAtomicCounters = */ 0,
/* .MaxTessControlAtomicCounters = */ 0,
/* .MaxTessEvaluationAtomicCounters = */ 0,
/* .MaxGeometryAtomicCounters = */ 0,
/* .MaxFragmentAtomicCounters = */ 8,
/* .MaxCombinedAtomicCounters = */ 8,
/* .MaxAtomicCounterBindings = */ 1,
/* .MaxVertexAtomicCounterBuffers = */ 0,
/* .MaxTessControlAtomicCounterBuffers = */ 0,
/* .MaxTessEvaluationAtomicCounterBuffers = */ 0,
/* .MaxGeometryAtomicCounterBuffers = */ 0,
/* .MaxFragmentAtomicCounterBuffers = */ 1,
/* .MaxCombinedAtomicCounterBuffers = */ 1,
/* .MaxAtomicCounterBufferSize = */ 16384,
/* .MaxTransformFeedbackBuffers = */ 4,
/* .MaxTransformFeedbackInterleavedComponents = */ 64,
/* .MaxCullDistances = */ 8,
/* .MaxCombinedClipAndCullDistances = */ 8,
/* .MaxSamples = */ 4,
/* .maxMeshOutputVerticesNV = */ 256,
/* .maxMeshOutputPrimitivesNV = */ 512,
/* .maxMeshWorkGroupSizeX_NV = */ 32,
/* .maxMeshWorkGroupSizeY_NV = */ 1,
/* .maxMeshWorkGroupSizeZ_NV = */ 1,
/* .maxTaskWorkGroupSizeX_NV = */ 32,
/* .maxTaskWorkGroupSizeY_NV = */ 1,
/* .maxTaskWorkGroupSizeZ_NV = */ 1,
/* .maxMeshViewCountNV = */ 4,
/* .maxMeshOutputVerticesEXT = */ 256,
/* .maxMeshOutputPrimitivesEXT = */ 256,
/* .maxMeshWorkGroupSizeX_EXT = */ 128,
/* .maxMeshWorkGroupSizeY_EXT = */ 128,
/* .maxMeshWorkGroupSizeZ_EXT = */ 128,
/* .maxTaskWorkGroupSizeX_EXT = */ 128,
/* .maxTaskWorkGroupSizeY_EXT = */ 128,
/* .maxTaskWorkGroupSizeZ_EXT = */ 128,
/* .maxMeshViewCountEXT = */ 4,
/* .maxDualSourceDrawBuffersEXT = */ 1,
/* .limits = */ {
/* .nonInductiveForLoops = */ 1,
/* .whileLoops = */ 1,
/* .doWhileLoops = */ 1,
/* .generalUniformIndexing = */ 1,
/* .generalAttributeMatrixVectorIndexing = */ 1,
/* .generalVaryingIndexing = */ 1,
/* .generalSamplerIndexing = */ 1,
/* .generalVariableIndexing = */ 1,
/* .generalConstantMatrixVectorIndexing = */ 1,
}};
std::string GetDefaultTBuiltInResourceString()
{
std::ostringstream ostream;
ostream << "MaxLights " << DefaultTBuiltInResource.maxLights << "\n"
<< "MaxClipPlanes " << DefaultTBuiltInResource.maxClipPlanes << "\n"
<< "MaxTextureUnits " << DefaultTBuiltInResource.maxTextureUnits << "\n"
<< "MaxTextureCoords " << DefaultTBuiltInResource.maxTextureCoords << "\n"
<< "MaxVertexAttribs " << DefaultTBuiltInResource.maxVertexAttribs << "\n"
<< "MaxVertexUniformComponents " << DefaultTBuiltInResource.maxVertexUniformComponents << "\n"
<< "MaxVaryingFloats " << DefaultTBuiltInResource.maxVaryingFloats << "\n"
<< "MaxVertexTextureImageUnits " << DefaultTBuiltInResource.maxVertexTextureImageUnits << "\n"
<< "MaxCombinedTextureImageUnits " << DefaultTBuiltInResource.maxCombinedTextureImageUnits << "\n"
<< "MaxTextureImageUnits " << DefaultTBuiltInResource.maxTextureImageUnits << "\n"
<< "MaxFragmentUniformComponents " << DefaultTBuiltInResource.maxFragmentUniformComponents << "\n"
<< "MaxDrawBuffers " << DefaultTBuiltInResource.maxDrawBuffers << "\n"
<< "MaxVertexUniformVectors " << DefaultTBuiltInResource.maxVertexUniformVectors << "\n"
<< "MaxVaryingVectors " << DefaultTBuiltInResource.maxVaryingVectors << "\n"
<< "MaxFragmentUniformVectors " << DefaultTBuiltInResource.maxFragmentUniformVectors << "\n"
<< "MaxVertexOutputVectors " << DefaultTBuiltInResource.maxVertexOutputVectors << "\n"
<< "MaxFragmentInputVectors " << DefaultTBuiltInResource.maxFragmentInputVectors << "\n"
<< "MinProgramTexelOffset " << DefaultTBuiltInResource.minProgramTexelOffset << "\n"
<< "MaxProgramTexelOffset " << DefaultTBuiltInResource.maxProgramTexelOffset << "\n"
<< "MaxClipDistances " << DefaultTBuiltInResource.maxClipDistances << "\n"
<< "MaxComputeWorkGroupCountX " << DefaultTBuiltInResource.maxComputeWorkGroupCountX << "\n"
<< "MaxComputeWorkGroupCountY " << DefaultTBuiltInResource.maxComputeWorkGroupCountY << "\n"
<< "MaxComputeWorkGroupCountZ " << DefaultTBuiltInResource.maxComputeWorkGroupCountZ << "\n"
<< "MaxComputeWorkGroupSizeX " << DefaultTBuiltInResource.maxComputeWorkGroupSizeX << "\n"
<< "MaxComputeWorkGroupSizeY " << DefaultTBuiltInResource.maxComputeWorkGroupSizeY << "\n"
<< "MaxComputeWorkGroupSizeZ " << DefaultTBuiltInResource.maxComputeWorkGroupSizeZ << "\n"
<< "MaxComputeUniformComponents " << DefaultTBuiltInResource.maxComputeUniformComponents << "\n"
<< "MaxComputeTextureImageUnits " << DefaultTBuiltInResource.maxComputeTextureImageUnits << "\n"
<< "MaxComputeImageUniforms " << DefaultTBuiltInResource.maxComputeImageUniforms << "\n"
<< "MaxComputeAtomicCounters " << DefaultTBuiltInResource.maxComputeAtomicCounters << "\n"
<< "MaxComputeAtomicCounterBuffers " << DefaultTBuiltInResource.maxComputeAtomicCounterBuffers << "\n"
<< "MaxVaryingComponents " << DefaultTBuiltInResource.maxVaryingComponents << "\n"
<< "MaxVertexOutputComponents " << DefaultTBuiltInResource.maxVertexOutputComponents << "\n"
<< "MaxGeometryInputComponents " << DefaultTBuiltInResource.maxGeometryInputComponents << "\n"
<< "MaxGeometryOutputComponents " << DefaultTBuiltInResource.maxGeometryOutputComponents << "\n"
<< "MaxFragmentInputComponents " << DefaultTBuiltInResource.maxFragmentInputComponents << "\n"
<< "MaxImageUnits " << DefaultTBuiltInResource.maxImageUnits << "\n"
<< "MaxCombinedImageUnitsAndFragmentOutputs " << DefaultTBuiltInResource.maxCombinedImageUnitsAndFragmentOutputs << "\n"
<< "MaxCombinedShaderOutputResources " << DefaultTBuiltInResource.maxCombinedShaderOutputResources << "\n"
<< "MaxImageSamples " << DefaultTBuiltInResource.maxImageSamples << "\n"
<< "MaxVertexImageUniforms " << DefaultTBuiltInResource.maxVertexImageUniforms << "\n"
<< "MaxTessControlImageUniforms " << DefaultTBuiltInResource.maxTessControlImageUniforms << "\n"
<< "MaxTessEvaluationImageUniforms " << DefaultTBuiltInResource.maxTessEvaluationImageUniforms << "\n"
<< "MaxGeometryImageUniforms " << DefaultTBuiltInResource.maxGeometryImageUniforms << "\n"
<< "MaxFragmentImageUniforms " << DefaultTBuiltInResource.maxFragmentImageUniforms << "\n"
<< "MaxCombinedImageUniforms " << DefaultTBuiltInResource.maxCombinedImageUniforms << "\n"
<< "MaxGeometryTextureImageUnits " << DefaultTBuiltInResource.maxGeometryTextureImageUnits << "\n"
<< "MaxGeometryOutputVertices " << DefaultTBuiltInResource.maxGeometryOutputVertices << "\n"
<< "MaxGeometryTotalOutputComponents " << DefaultTBuiltInResource.maxGeometryTotalOutputComponents << "\n"
<< "MaxGeometryUniformComponents " << DefaultTBuiltInResource.maxGeometryUniformComponents << "\n"
<< "MaxGeometryVaryingComponents " << DefaultTBuiltInResource.maxGeometryVaryingComponents << "\n"
<< "MaxTessControlInputComponents " << DefaultTBuiltInResource.maxTessControlInputComponents << "\n"
<< "MaxTessControlOutputComponents " << DefaultTBuiltInResource.maxTessControlOutputComponents << "\n"
<< "MaxTessControlTextureImageUnits " << DefaultTBuiltInResource.maxTessControlTextureImageUnits << "\n"
<< "MaxTessControlUniformComponents " << DefaultTBuiltInResource.maxTessControlUniformComponents << "\n"
<< "MaxTessControlTotalOutputComponents " << DefaultTBuiltInResource.maxTessControlTotalOutputComponents << "\n"
<< "MaxTessEvaluationInputComponents " << DefaultTBuiltInResource.maxTessEvaluationInputComponents << "\n"
<< "MaxTessEvaluationOutputComponents " << DefaultTBuiltInResource.maxTessEvaluationOutputComponents << "\n"
<< "MaxTessEvaluationTextureImageUnits " << DefaultTBuiltInResource.maxTessEvaluationTextureImageUnits << "\n"
<< "MaxTessEvaluationUniformComponents " << DefaultTBuiltInResource.maxTessEvaluationUniformComponents << "\n"
<< "MaxTessPatchComponents " << DefaultTBuiltInResource.maxTessPatchComponents << "\n"
<< "MaxPatchVertices " << DefaultTBuiltInResource.maxPatchVertices << "\n"
<< "MaxTessGenLevel " << DefaultTBuiltInResource.maxTessGenLevel << "\n"
<< "MaxViewports " << DefaultTBuiltInResource.maxViewports << "\n"
<< "MaxVertexAtomicCounters " << DefaultTBuiltInResource.maxVertexAtomicCounters << "\n"
<< "MaxTessControlAtomicCounters " << DefaultTBuiltInResource.maxTessControlAtomicCounters << "\n"
<< "MaxTessEvaluationAtomicCounters " << DefaultTBuiltInResource.maxTessEvaluationAtomicCounters << "\n"
<< "MaxGeometryAtomicCounters " << DefaultTBuiltInResource.maxGeometryAtomicCounters << "\n"
<< "MaxFragmentAtomicCounters " << DefaultTBuiltInResource.maxFragmentAtomicCounters << "\n"
<< "MaxCombinedAtomicCounters " << DefaultTBuiltInResource.maxCombinedAtomicCounters << "\n"
<< "MaxAtomicCounterBindings " << DefaultTBuiltInResource.maxAtomicCounterBindings << "\n"
<< "MaxVertexAtomicCounterBuffers " << DefaultTBuiltInResource.maxVertexAtomicCounterBuffers << "\n"
<< "MaxTessControlAtomicCounterBuffers " << DefaultTBuiltInResource.maxTessControlAtomicCounterBuffers << "\n"
<< "MaxTessEvaluationAtomicCounterBuffers " << DefaultTBuiltInResource.maxTessEvaluationAtomicCounterBuffers << "\n"
<< "MaxGeometryAtomicCounterBuffers " << DefaultTBuiltInResource.maxGeometryAtomicCounterBuffers << "\n"
<< "MaxFragmentAtomicCounterBuffers " << DefaultTBuiltInResource.maxFragmentAtomicCounterBuffers << "\n"
<< "MaxCombinedAtomicCounterBuffers " << DefaultTBuiltInResource.maxCombinedAtomicCounterBuffers << "\n"
<< "MaxAtomicCounterBufferSize " << DefaultTBuiltInResource.maxAtomicCounterBufferSize << "\n"
<< "MaxTransformFeedbackBuffers " << DefaultTBuiltInResource.maxTransformFeedbackBuffers << "\n"
<< "MaxTransformFeedbackInterleavedComponents " << DefaultTBuiltInResource.maxTransformFeedbackInterleavedComponents << "\n"
<< "MaxCullDistances " << DefaultTBuiltInResource.maxCullDistances << "\n"
<< "MaxCombinedClipAndCullDistances " << DefaultTBuiltInResource.maxCombinedClipAndCullDistances << "\n"
<< "MaxSamples " << DefaultTBuiltInResource.maxSamples << "\n"
<< "MaxMeshOutputVerticesNV " << DefaultTBuiltInResource.maxMeshOutputVerticesNV << "\n"
<< "MaxMeshOutputPrimitivesNV " << DefaultTBuiltInResource.maxMeshOutputPrimitivesNV << "\n"
<< "MaxMeshWorkGroupSizeX_NV " << DefaultTBuiltInResource.maxMeshWorkGroupSizeX_NV << "\n"
<< "MaxMeshWorkGroupSizeY_NV " << DefaultTBuiltInResource.maxMeshWorkGroupSizeY_NV << "\n"
<< "MaxMeshWorkGroupSizeZ_NV " << DefaultTBuiltInResource.maxMeshWorkGroupSizeZ_NV << "\n"
<< "MaxTaskWorkGroupSizeX_NV " << DefaultTBuiltInResource.maxTaskWorkGroupSizeX_NV << "\n"
<< "MaxTaskWorkGroupSizeY_NV " << DefaultTBuiltInResource.maxTaskWorkGroupSizeY_NV << "\n"
<< "MaxTaskWorkGroupSizeZ_NV " << DefaultTBuiltInResource.maxTaskWorkGroupSizeZ_NV << "\n"
<< "MaxMeshViewCountNV " << DefaultTBuiltInResource.maxMeshViewCountNV << "\n"
<< "MaxMeshOutputVerticesEXT " << DefaultTBuiltInResource.maxMeshOutputVerticesEXT << "\n"
<< "MaxMeshOutputPrimitivesEXT " << DefaultTBuiltInResource.maxMeshOutputPrimitivesEXT << "\n"
<< "MaxMeshWorkGroupSizeX_EXT " << DefaultTBuiltInResource.maxMeshWorkGroupSizeX_EXT << "\n"
<< "MaxMeshWorkGroupSizeY_EXT " << DefaultTBuiltInResource.maxMeshWorkGroupSizeY_EXT << "\n"
<< "MaxMeshWorkGroupSizeZ_EXT " << DefaultTBuiltInResource.maxMeshWorkGroupSizeZ_EXT << "\n"
<< "MaxTaskWorkGroupSizeX_EXT " << DefaultTBuiltInResource.maxTaskWorkGroupSizeX_EXT << "\n"
<< "MaxTaskWorkGroupSizeY_EXT " << DefaultTBuiltInResource.maxTaskWorkGroupSizeY_EXT << "\n"
<< "MaxTaskWorkGroupSizeZ_EXT " << DefaultTBuiltInResource.maxTaskWorkGroupSizeZ_EXT << "\n"
<< "MaxMeshViewCountEXT " << DefaultTBuiltInResource.maxMeshViewCountEXT << "\n"
<< "MaxDualSourceDrawBuffersEXT " << DefaultTBuiltInResource.maxDualSourceDrawBuffersEXT << "\n"
<< "nonInductiveForLoops " << DefaultTBuiltInResource.limits.nonInductiveForLoops << "\n"
<< "whileLoops " << DefaultTBuiltInResource.limits.whileLoops << "\n"
<< "doWhileLoops " << DefaultTBuiltInResource.limits.doWhileLoops << "\n"
<< "generalUniformIndexing " << DefaultTBuiltInResource.limits.generalUniformIndexing << "\n"
<< "generalAttributeMatrixVectorIndexing " << DefaultTBuiltInResource.limits.generalAttributeMatrixVectorIndexing << "\n"
<< "generalVaryingIndexing " << DefaultTBuiltInResource.limits.generalVaryingIndexing << "\n"
<< "generalSamplerIndexing " << DefaultTBuiltInResource.limits.generalSamplerIndexing << "\n"
<< "generalVariableIndexing " << DefaultTBuiltInResource.limits.generalVariableIndexing << "\n"
<< "generalConstantMatrixVectorIndexing " << DefaultTBuiltInResource.limits.generalConstantMatrixVectorIndexing << "\n"
;
return ostream.str();
}
void DecodeResourceLimits(TBuiltInResource* resources, char* config)
{
static const char* delims = " \t\n\r";
size_t pos = 0;
std::string configStr(config);
while ((pos = configStr.find_first_not_of(delims, pos)) != std::string::npos) {
const size_t token_s = pos;
const size_t token_e = configStr.find_first_of(delims, token_s);
const size_t value_s = configStr.find_first_not_of(delims, token_e);
const size_t value_e = configStr.find_first_of(delims, value_s);
pos = value_e;
// Faster to use compare(), but prefering readability.
const std::string tokenStr = configStr.substr(token_s, token_e-token_s);
const std::string valueStr = configStr.substr(value_s, value_e-value_s);
if (value_s == std::string::npos || ! (valueStr[0] == '-' || isdigit(valueStr[0]))) {
printf("Error: '%s' bad .conf file. Each name must be followed by one number.\n",
valueStr.c_str());
return;
}
const int value = std::atoi(valueStr.c_str());
if (tokenStr == "MaxLights")
resources->maxLights = value;
else if (tokenStr == "MaxClipPlanes")
resources->maxClipPlanes = value;
else if (tokenStr == "MaxTextureUnits")
resources->maxTextureUnits = value;
else if (tokenStr == "MaxTextureCoords")
resources->maxTextureCoords = value;
else if (tokenStr == "MaxVertexAttribs")
resources->maxVertexAttribs = value;
else if (tokenStr == "MaxVertexUniformComponents")
resources->maxVertexUniformComponents = value;
else if (tokenStr == "MaxVaryingFloats")
resources->maxVaryingFloats = value;
else if (tokenStr == "MaxVertexTextureImageUnits")
resources->maxVertexTextureImageUnits = value;
else if (tokenStr == "MaxCombinedTextureImageUnits")
resources->maxCombinedTextureImageUnits = value;
else if (tokenStr == "MaxTextureImageUnits")
resources->maxTextureImageUnits = value;
else if (tokenStr == "MaxFragmentUniformComponents")
resources->maxFragmentUniformComponents = value;
else if (tokenStr == "MaxDrawBuffers")
resources->maxDrawBuffers = value;
else if (tokenStr == "MaxVertexUniformVectors")
resources->maxVertexUniformVectors = value;
else if (tokenStr == "MaxVaryingVectors")
resources->maxVaryingVectors = value;
else if (tokenStr == "MaxFragmentUniformVectors")
resources->maxFragmentUniformVectors = value;
else if (tokenStr == "MaxVertexOutputVectors")
resources->maxVertexOutputVectors = value;
else if (tokenStr == "MaxFragmentInputVectors")
resources->maxFragmentInputVectors = value;
else if (tokenStr == "MinProgramTexelOffset")
resources->minProgramTexelOffset = value;
else if (tokenStr == "MaxProgramTexelOffset")
resources->maxProgramTexelOffset = value;
else if (tokenStr == "MaxClipDistances")
resources->maxClipDistances = value;
else if (tokenStr == "MaxComputeWorkGroupCountX")
resources->maxComputeWorkGroupCountX = value;
else if (tokenStr == "MaxComputeWorkGroupCountY")
resources->maxComputeWorkGroupCountY = value;
else if (tokenStr == "MaxComputeWorkGroupCountZ")
resources->maxComputeWorkGroupCountZ = value;
else if (tokenStr == "MaxComputeWorkGroupSizeX")
resources->maxComputeWorkGroupSizeX = value;
else if (tokenStr == "MaxComputeWorkGroupSizeY")
resources->maxComputeWorkGroupSizeY = value;
else if (tokenStr == "MaxComputeWorkGroupSizeZ")
resources->maxComputeWorkGroupSizeZ = value;
else if (tokenStr == "MaxComputeUniformComponents")
resources->maxComputeUniformComponents = value;
else if (tokenStr == "MaxComputeTextureImageUnits")
resources->maxComputeTextureImageUnits = value;
else if (tokenStr == "MaxComputeImageUniforms")
resources->maxComputeImageUniforms = value;
else if (tokenStr == "MaxComputeAtomicCounters")
resources->maxComputeAtomicCounters = value;
else if (tokenStr == "MaxComputeAtomicCounterBuffers")
resources->maxComputeAtomicCounterBuffers = value;
else if (tokenStr == "MaxVaryingComponents")
resources->maxVaryingComponents = value;
else if (tokenStr == "MaxVertexOutputComponents")
resources->maxVertexOutputComponents = value;
else if (tokenStr == "MaxGeometryInputComponents")
resources->maxGeometryInputComponents = value;
else if (tokenStr == "MaxGeometryOutputComponents")
resources->maxGeometryOutputComponents = value;
else if (tokenStr == "MaxFragmentInputComponents")
resources->maxFragmentInputComponents = value;
else if (tokenStr == "MaxImageUnits")
resources->maxImageUnits = value;
else if (tokenStr == "MaxCombinedImageUnitsAndFragmentOutputs")
resources->maxCombinedImageUnitsAndFragmentOutputs = value;
else if (tokenStr == "MaxCombinedShaderOutputResources")
resources->maxCombinedShaderOutputResources = value;
else if (tokenStr == "MaxImageSamples")
resources->maxImageSamples = value;
else if (tokenStr == "MaxVertexImageUniforms")
resources->maxVertexImageUniforms = value;
else if (tokenStr == "MaxTessControlImageUniforms")
resources->maxTessControlImageUniforms = value;
else if (tokenStr == "MaxTessEvaluationImageUniforms")
resources->maxTessEvaluationImageUniforms = value;
else if (tokenStr == "MaxGeometryImageUniforms")
resources->maxGeometryImageUniforms = value;
else if (tokenStr == "MaxFragmentImageUniforms")
resources->maxFragmentImageUniforms = value;
else if (tokenStr == "MaxCombinedImageUniforms")
resources->maxCombinedImageUniforms = value;
else if (tokenStr == "MaxGeometryTextureImageUnits")
resources->maxGeometryTextureImageUnits = value;
else if (tokenStr == "MaxGeometryOutputVertices")
resources->maxGeometryOutputVertices = value;
else if (tokenStr == "MaxGeometryTotalOutputComponents")
resources->maxGeometryTotalOutputComponents = value;
else if (tokenStr == "MaxGeometryUniformComponents")
resources->maxGeometryUniformComponents = value;
else if (tokenStr == "MaxGeometryVaryingComponents")
resources->maxGeometryVaryingComponents = value;
else if (tokenStr == "MaxTessControlInputComponents")
resources->maxTessControlInputComponents = value;
else if (tokenStr == "MaxTessControlOutputComponents")
resources->maxTessControlOutputComponents = value;
else if (tokenStr == "MaxTessControlTextureImageUnits")
resources->maxTessControlTextureImageUnits = value;
else if (tokenStr == "MaxTessControlUniformComponents")
resources->maxTessControlUniformComponents = value;
else if (tokenStr == "MaxTessControlTotalOutputComponents")
resources->maxTessControlTotalOutputComponents = value;
else if (tokenStr == "MaxTessEvaluationInputComponents")
resources->maxTessEvaluationInputComponents = value;
else if (tokenStr == "MaxTessEvaluationOutputComponents")
resources->maxTessEvaluationOutputComponents = value;
else if (tokenStr == "MaxTessEvaluationTextureImageUnits")
resources->maxTessEvaluationTextureImageUnits = value;
else if (tokenStr == "MaxTessEvaluationUniformComponents")
resources->maxTessEvaluationUniformComponents = value;
else if (tokenStr == "MaxTessPatchComponents")
resources->maxTessPatchComponents = value;
else if (tokenStr == "MaxPatchVertices")
resources->maxPatchVertices = value;
else if (tokenStr == "MaxTessGenLevel")
resources->maxTessGenLevel = value;
else if (tokenStr == "MaxViewports")
resources->maxViewports = value;
else if (tokenStr == "MaxVertexAtomicCounters")
resources->maxVertexAtomicCounters = value;
else if (tokenStr == "MaxTessControlAtomicCounters")
resources->maxTessControlAtomicCounters = value;
else if (tokenStr == "MaxTessEvaluationAtomicCounters")
resources->maxTessEvaluationAtomicCounters = value;
else if (tokenStr == "MaxGeometryAtomicCounters")
resources->maxGeometryAtomicCounters = value;
else if (tokenStr == "MaxFragmentAtomicCounters")
resources->maxFragmentAtomicCounters = value;
else if (tokenStr == "MaxCombinedAtomicCounters")
resources->maxCombinedAtomicCounters = value;
else if (tokenStr == "MaxAtomicCounterBindings")
resources->maxAtomicCounterBindings = value;
else if (tokenStr == "MaxVertexAtomicCounterBuffers")
resources->maxVertexAtomicCounterBuffers = value;
else if (tokenStr == "MaxTessControlAtomicCounterBuffers")
resources->maxTessControlAtomicCounterBuffers = value;
else if (tokenStr == "MaxTessEvaluationAtomicCounterBuffers")
resources->maxTessEvaluationAtomicCounterBuffers = value;
else if (tokenStr == "MaxGeometryAtomicCounterBuffers")
resources->maxGeometryAtomicCounterBuffers = value;
else if (tokenStr == "MaxFragmentAtomicCounterBuffers")
resources->maxFragmentAtomicCounterBuffers = value;
else if (tokenStr == "MaxCombinedAtomicCounterBuffers")
resources->maxCombinedAtomicCounterBuffers = value;
else if (tokenStr == "MaxAtomicCounterBufferSize")
resources->maxAtomicCounterBufferSize = value;
else if (tokenStr == "MaxTransformFeedbackBuffers")
resources->maxTransformFeedbackBuffers = value;
else if (tokenStr == "MaxTransformFeedbackInterleavedComponents")
resources->maxTransformFeedbackInterleavedComponents = value;
else if (tokenStr == "MaxCullDistances")
resources->maxCullDistances = value;
else if (tokenStr == "MaxCombinedClipAndCullDistances")
resources->maxCombinedClipAndCullDistances = value;
else if (tokenStr == "MaxSamples")
resources->maxSamples = value;
else if (tokenStr == "MaxMeshOutputVerticesNV")
resources->maxMeshOutputVerticesNV = value;
else if (tokenStr == "MaxMeshOutputPrimitivesNV")
resources->maxMeshOutputPrimitivesNV = value;
else if (tokenStr == "MaxMeshWorkGroupSizeX_NV")
resources->maxMeshWorkGroupSizeX_NV = value;
else if (tokenStr == "MaxMeshWorkGroupSizeY_NV")
resources->maxMeshWorkGroupSizeY_NV = value;
else if (tokenStr == "MaxMeshWorkGroupSizeZ_NV")
resources->maxMeshWorkGroupSizeZ_NV = value;
else if (tokenStr == "MaxTaskWorkGroupSizeX_NV")
resources->maxTaskWorkGroupSizeX_NV = value;
else if (tokenStr == "MaxTaskWorkGroupSizeY_NV")
resources->maxTaskWorkGroupSizeY_NV = value;
else if (tokenStr == "MaxTaskWorkGroupSizeZ_NV")
resources->maxTaskWorkGroupSizeZ_NV = value;
else if (tokenStr == "MaxMeshViewCountNV")
resources->maxMeshViewCountNV = value;
else if (tokenStr == "MaxMeshOutputVerticesEXT")
resources->maxMeshOutputVerticesEXT = value;
else if (tokenStr == "MaxMeshOutputPrimitivesEXT")
resources->maxMeshOutputPrimitivesEXT = value;
else if (tokenStr == "MaxMeshWorkGroupSizeX_EXT")
resources->maxMeshWorkGroupSizeX_EXT = value;
else if (tokenStr == "MaxMeshWorkGroupSizeY_EXT")
resources->maxMeshWorkGroupSizeY_EXT = value;
else if (tokenStr == "MaxMeshWorkGroupSizeZ_EXT")
resources->maxMeshWorkGroupSizeZ_EXT = value;
else if (tokenStr == "MaxTaskWorkGroupSizeX_EXT")
resources->maxTaskWorkGroupSizeX_EXT = value;
else if (tokenStr == "MaxTaskWorkGroupSizeY_EXT")
resources->maxTaskWorkGroupSizeY_EXT = value;
else if (tokenStr == "MaxTaskWorkGroupSizeZ_EXT")
resources->maxTaskWorkGroupSizeZ_EXT = value;
else if (tokenStr == "MaxMeshViewCountEXT")
resources->maxMeshViewCountEXT = value;
else if (tokenStr == "MaxDualSourceDrawBuffersEXT")
resources->maxDualSourceDrawBuffersEXT = value;
else if (tokenStr == "nonInductiveForLoops")
resources->limits.nonInductiveForLoops = (value != 0);
else if (tokenStr == "whileLoops")
resources->limits.whileLoops = (value != 0);
else if (tokenStr == "doWhileLoops")
resources->limits.doWhileLoops = (value != 0);
else if (tokenStr == "generalUniformIndexing")
resources->limits.generalUniformIndexing = (value != 0);
else if (tokenStr == "generalAttributeMatrixVectorIndexing")
resources->limits.generalAttributeMatrixVectorIndexing = (value != 0);
else if (tokenStr == "generalVaryingIndexing")
resources->limits.generalVaryingIndexing = (value != 0);
else if (tokenStr == "generalSamplerIndexing")
resources->limits.generalSamplerIndexing = (value != 0);
else if (tokenStr == "generalVariableIndexing")
resources->limits.generalVariableIndexing = (value != 0);
else if (tokenStr == "generalConstantMatrixVectorIndexing")
resources->limits.generalConstantMatrixVectorIndexing = (value != 0);
else
printf("Warning: unrecognized limit (%s) in configuration file.\n", tokenStr.c_str());
}
}
TBuiltInResource* GetResources()
{
return &Resources;
}
const TBuiltInResource* GetDefaultResources()
{
return &DefaultTBuiltInResource;
}
+13 -13
View File
@@ -34,29 +34,29 @@
#ifndef GLSLANG_BUILD_INFO
#define GLSLANG_BUILD_INFO
#define GLSLANG_VERSION_MAJOR 11
#define GLSLANG_VERSION_MAJOR 14
#define GLSLANG_VERSION_MINOR 0
#define GLSLANG_VERSION_PATCH 0
#define GLSLANG_VERSION_FLAVOR ""
#define GLSLANG_VERSION_GREATER_THAN(major, minor, patch) \
(((major) > GLSLANG_VERSION_MAJOR) || ((major) == GLSLANG_VERSION_MAJOR && \
(((minor) > GLSLANG_VERSION_MINOR) || ((minor) == GLSLANG_VERSION_MINOR && \
((patch) > GLSLANG_VERSION_PATCH)))))
((GLSLANG_VERSION_MAJOR) > (major) || ((major) == GLSLANG_VERSION_MAJOR && \
((GLSLANG_VERSION_MINOR) > (minor) || ((minor) == GLSLANG_VERSION_MINOR && \
(GLSLANG_VERSION_PATCH) > (patch)))))
#define GLSLANG_VERSION_GREATER_OR_EQUAL_TO(major, minor, patch) \
(((major) > GLSLANG_VERSION_MAJOR) || ((major) == GLSLANG_VERSION_MAJOR && \
(((minor) > GLSLANG_VERSION_MINOR) || ((minor) == GLSLANG_VERSION_MINOR && \
((patch) >= GLSLANG_VERSION_PATCH)))))
((GLSLANG_VERSION_MAJOR) > (major) || ((major) == GLSLANG_VERSION_MAJOR && \
((GLSLANG_VERSION_MINOR) > (minor) || ((minor) == GLSLANG_VERSION_MINOR && \
(GLSLANG_VERSION_PATCH >= (patch))))))
#define GLSLANG_VERSION_LESS_THAN(major, minor, patch) \
(((major) < GLSLANG_VERSION_MAJOR) || ((major) == GLSLANG_VERSION_MAJOR && \
(((minor) < GLSLANG_VERSION_MINOR) || ((minor) == GLSLANG_VERSION_MINOR && \
((patch) < GLSLANG_VERSION_PATCH)))))
((GLSLANG_VERSION_MAJOR) < (major) || ((major) == GLSLANG_VERSION_MAJOR && \
((GLSLANG_VERSION_MINOR) < (minor) || ((minor) == GLSLANG_VERSION_MINOR && \
(GLSLANG_VERSION_PATCH) < (patch)))))
#define GLSLANG_VERSION_LESS_OR_EQUAL_TO(major, minor, patch) \
(((major) < GLSLANG_VERSION_MAJOR) || ((major) == GLSLANG_VERSION_MAJOR && \
(((minor) < GLSLANG_VERSION_MINOR) || ((minor) == GLSLANG_VERSION_MINOR && \
((patch) <= GLSLANG_VERSION_PATCH)))))
((GLSLANG_VERSION_MAJOR) < (major) || ((major) == GLSLANG_VERSION_MAJOR && \
((GLSLANG_VERSION_MINOR) < (minor) || ((minor) == GLSLANG_VERSION_MINOR && \
(GLSLANG_VERSION_PATCH <= (patch))))))
#endif // GLSLANG_BUILD_INFO
+2 -109
View File
@@ -23,114 +23,7 @@
#include "Graphics.h"
#include "libraries/glslang/glslang/Public/ShaderLang.h"
// TODO: Use love.graphics to determine actual limits?
static const TBuiltInResource defaultTBuiltInResource = {
/* .MaxLights = */ 32,
/* .MaxClipPlanes = */ 6,
/* .MaxTextureUnits = */ 32,
/* .MaxTextureCoords = */ 32,
/* .MaxVertexAttribs = */ 64,
/* .MaxVertexUniformComponents = */ 16384,
/* .MaxVaryingFloats = */ 128,
/* .MaxVertexTextureImageUnits = */ 32,
/* .MaxCombinedTextureImageUnits = */ 80,
/* .MaxTextureImageUnits = */ 32,
/* .MaxFragmentUniformComponents = */ 16384,
/* .MaxDrawBuffers = */ 8,
/* .MaxVertexUniformVectors = */ 4096,
/* .MaxVaryingVectors = */ 32,
/* .MaxFragmentUniformVectors = */ 4096,
/* .MaxVertexOutputVectors = */ 32,
/* .MaxFragmentInputVectors = */ 31,
/* .MinProgramTexelOffset = */ -8,
/* .MaxProgramTexelOffset = */ 7,
/* .MaxClipDistances = */ 8,
/* .MaxComputeWorkGroupCountX = */ 65535,
/* .MaxComputeWorkGroupCountY = */ 65535,
/* .MaxComputeWorkGroupCountZ = */ 65535,
/* .MaxComputeWorkGroupSizeX = */ 1024,
/* .MaxComputeWorkGroupSizeY = */ 1024,
/* .MaxComputeWorkGroupSizeZ = */ 64,
/* .MaxComputeUniformComponents = */ 1024,
/* .MaxComputeTextureImageUnits = */ 32,
/* .MaxComputeImageUniforms = */ 16,
/* .MaxComputeAtomicCounters = */ 4096,
/* .MaxComputeAtomicCounterBuffers = */ 8,
/* .MaxVaryingComponents = */ 128,
/* .MaxVertexOutputComponents = */ 128,
/* .MaxGeometryInputComponents = */ 128,
/* .MaxGeometryOutputComponents = */ 128,
/* .MaxFragmentInputComponents = */ 128,
/* .MaxImageUnits = */ 192,
/* .MaxCombinedImageUnitsAndFragmentOutputs = */ 144,
/* .MaxCombinedShaderOutputResources = */ 144,
/* .MaxImageSamples = */ 32,
/* .MaxVertexImageUniforms = */ 16,
/* .MaxTessControlImageUniforms = */ 16,
/* .MaxTessEvaluationImageUniforms = */ 16,
/* .MaxGeometryImageUniforms = */ 16,
/* .MaxFragmentImageUniforms = */ 16,
/* .MaxCombinedImageUniforms = */ 80,
/* .MaxGeometryTextureImageUnits = */ 16,
/* .MaxGeometryOutputVertices = */ 256,
/* .MaxGeometryTotalOutputComponents = */ 1024,
/* .MaxGeometryUniformComponents = */ 1024,
/* .MaxGeometryVaryingComponents = */ 64,
/* .MaxTessControlInputComponents = */ 128,
/* .MaxTessControlOutputComponents = */ 128,
/* .MaxTessControlTextureImageUnits = */ 16,
/* .MaxTessControlUniformComponents = */ 1024,
/* .MaxTessControlTotalOutputComponents = */ 4096,
/* .MaxTessEvaluationInputComponents = */ 128,
/* .MaxTessEvaluationOutputComponents = */ 128,
/* .MaxTessEvaluationTextureImageUnits = */ 16,
/* .MaxTessEvaluationUniformComponents = */ 1024,
/* .MaxTessPatchComponents = */ 120,
/* .MaxPatchVertices = */ 32,
/* .MaxTessGenLevel = */ 64,
/* .MaxViewports = */ 16,
/* .MaxVertexAtomicCounters = */ 4096,
/* .MaxTessControlAtomicCounters = */ 4096,
/* .MaxTessEvaluationAtomicCounters = */ 4096,
/* .MaxGeometryAtomicCounters = */ 4096,
/* .MaxFragmentAtomicCounters = */ 4096,
/* .MaxCombinedAtomicCounters = */ 4096,
/* .MaxAtomicCounterBindings = */ 8,
/* .MaxVertexAtomicCounterBuffers = */ 8,
/* .MaxTessControlAtomicCounterBuffers = */ 8,
/* .MaxTessEvaluationAtomicCounterBuffers = */ 8,
/* .MaxGeometryAtomicCounterBuffers = */ 8,
/* .MaxFragmentAtomicCounterBuffers = */ 8,
/* .MaxCombinedAtomicCounterBuffers = */ 8,
/* .MaxAtomicCounterBufferSize = */ 16384,
/* .MaxTransformFeedbackBuffers = */ 4,
/* .MaxTransformFeedbackInterleavedComponents = */ 64,
/* .MaxCullDistances = */ 8,
/* .MaxCombinedClipAndCullDistances = */ 8,
/* .MaxSamples = */ 32,
/* .maxMeshOutputVerticesNV = */ 256,
/* .maxMeshOutputPrimitivesNV = */ 512,
/* .maxMeshWorkGroupSizeX_NV = */ 32,
/* .maxMeshWorkGroupSizeY_NV = */ 1,
/* .maxMeshWorkGroupSizeZ_NV = */ 1,
/* .maxTaskWorkGroupSizeX_NV = */ 32,
/* .maxTaskWorkGroupSizeY_NV = */ 1,
/* .maxTaskWorkGroupSizeZ_NV = */ 1,
/* .maxMeshViewCountNV = */ 4,
/* .maxDualSourceDrawBuffersEXT = */ 1,
/* .limits = */ {
/* .nonInductiveForLoops = */ 1,
/* .whileLoops = */ 1,
/* .doWhileLoops = */ 1,
/* .generalUniformIndexing = */ 1,
/* .generalAttributeMatrixVectorIndexing = */ 1,
/* .generalVaryingIndexing = */ 1,
/* .generalSamplerIndexing = */ 1,
/* .generalVariableIndexing = */ 1,
/* .generalConstantMatrixVectorIndexing = */ 1,
}
};
#include "libraries/glslang/glslang/Public/ResourceLimits.h"
namespace love
{
@@ -169,7 +62,7 @@ ShaderStage::ShaderStage(Graphics *gfx, ShaderStageType stage, const std::string
bool forwardcompat = supportsGLSL3 && !forcedefault;
if (!glslangShader->parse(&defaultTBuiltInResource, defaultversion, defaultprofile, forcedefault, forwardcompat, EShMsgSuppressWarnings))
if (!glslangShader->parse(GetDefaultResources(), defaultversion, defaultprofile, forcedefault, forwardcompat, EShMsgSuppressWarnings))
{
const char *stagename = "unknown";
getConstant(stage, stagename);
+2 -109
View File
@@ -24,6 +24,7 @@
// glslang
#include "libraries/glslang/glslang/Public/ShaderLang.h"
#include "libraries/glslang/glslang/Public/ResourceLimits.h"
#include "libraries/glslang/SPIRV/GlslangToSpv.h"
#include "libraries/spirv_cross/spirv_msl.hpp"
#include "libraries/spirv_cross/spirv_reflect.hpp"
@@ -39,114 +40,6 @@ namespace metal
static_assert(MAX_COLOR_RENDER_TARGETS <= 8, "Metal pipeline cache key only stores 8 render target pixel formats.");
// TODO: Use love.graphics to determine actual limits?
static const TBuiltInResource defaultTBuiltInResource = {
/* .MaxLights = */ 32,
/* .MaxClipPlanes = */ 6,
/* .MaxTextureUnits = */ 32,
/* .MaxTextureCoords = */ 32,
/* .MaxVertexAttribs = */ 64,
/* .MaxVertexUniformComponents = */ 16384,
/* .MaxVaryingFloats = */ 128,
/* .MaxVertexTextureImageUnits = */ 32,
/* .MaxCombinedTextureImageUnits = */ 80,
/* .MaxTextureImageUnits = */ 32,
/* .MaxFragmentUniformComponents = */ 16384,
/* .MaxDrawBuffers = */ 8,
/* .MaxVertexUniformVectors = */ 4096,
/* .MaxVaryingVectors = */ 32,
/* .MaxFragmentUniformVectors = */ 4096,
/* .MaxVertexOutputVectors = */ 32,
/* .MaxFragmentInputVectors = */ 31,
/* .MinProgramTexelOffset = */ -8,
/* .MaxProgramTexelOffset = */ 7,
/* .MaxClipDistances = */ 8,
/* .MaxComputeWorkGroupCountX = */ 65535,
/* .MaxComputeWorkGroupCountY = */ 65535,
/* .MaxComputeWorkGroupCountZ = */ 65535,
/* .MaxComputeWorkGroupSizeX = */ 1024,
/* .MaxComputeWorkGroupSizeY = */ 1024,
/* .MaxComputeWorkGroupSizeZ = */ 64,
/* .MaxComputeUniformComponents = */ 1024,
/* .MaxComputeTextureImageUnits = */ 32,
/* .MaxComputeImageUniforms = */ 16,
/* .MaxComputeAtomicCounters = */ 4096,
/* .MaxComputeAtomicCounterBuffers = */ 8,
/* .MaxVaryingComponents = */ 128,
/* .MaxVertexOutputComponents = */ 128,
/* .MaxGeometryInputComponents = */ 128,
/* .MaxGeometryOutputComponents = */ 128,
/* .MaxFragmentInputComponents = */ 128,
/* .MaxImageUnits = */ 192,
/* .MaxCombinedImageUnitsAndFragmentOutputs = */ 144,
/* .MaxCombinedShaderOutputResources = */ 144,
/* .MaxImageSamples = */ 32,
/* .MaxVertexImageUniforms = */ 16,
/* .MaxTessControlImageUniforms = */ 16,
/* .MaxTessEvaluationImageUniforms = */ 16,
/* .MaxGeometryImageUniforms = */ 16,
/* .MaxFragmentImageUniforms = */ 16,
/* .MaxCombinedImageUniforms = */ 80,
/* .MaxGeometryTextureImageUnits = */ 16,
/* .MaxGeometryOutputVertices = */ 256,
/* .MaxGeometryTotalOutputComponents = */ 1024,
/* .MaxGeometryUniformComponents = */ 1024,
/* .MaxGeometryVaryingComponents = */ 64,
/* .MaxTessControlInputComponents = */ 128,
/* .MaxTessControlOutputComponents = */ 128,
/* .MaxTessControlTextureImageUnits = */ 16,
/* .MaxTessControlUniformComponents = */ 1024,
/* .MaxTessControlTotalOutputComponents = */ 4096,
/* .MaxTessEvaluationInputComponents = */ 128,
/* .MaxTessEvaluationOutputComponents = */ 128,
/* .MaxTessEvaluationTextureImageUnits = */ 16,
/* .MaxTessEvaluationUniformComponents = */ 1024,
/* .MaxTessPatchComponents = */ 120,
/* .MaxPatchVertices = */ 32,
/* .MaxTessGenLevel = */ 64,
/* .MaxViewports = */ 16,
/* .MaxVertexAtomicCounters = */ 4096,
/* .MaxTessControlAtomicCounters = */ 4096,
/* .MaxTessEvaluationAtomicCounters = */ 4096,
/* .MaxGeometryAtomicCounters = */ 4096,
/* .MaxFragmentAtomicCounters = */ 4096,
/* .MaxCombinedAtomicCounters = */ 4096,
/* .MaxAtomicCounterBindings = */ 8,
/* .MaxVertexAtomicCounterBuffers = */ 8,
/* .MaxTessControlAtomicCounterBuffers = */ 8,
/* .MaxTessEvaluationAtomicCounterBuffers = */ 8,
/* .MaxGeometryAtomicCounterBuffers = */ 8,
/* .MaxFragmentAtomicCounterBuffers = */ 8,
/* .MaxCombinedAtomicCounterBuffers = */ 8,
/* .MaxAtomicCounterBufferSize = */ 16384,
/* .MaxTransformFeedbackBuffers = */ 4,
/* .MaxTransformFeedbackInterleavedComponents = */ 64,
/* .MaxCullDistances = */ 8,
/* .MaxCombinedClipAndCullDistances = */ 8,
/* .MaxSamples = */ 32,
/* .maxMeshOutputVerticesNV = */ 256,
/* .maxMeshOutputPrimitivesNV = */ 512,
/* .maxMeshWorkGroupSizeX_NV = */ 32,
/* .maxMeshWorkGroupSizeY_NV = */ 1,
/* .maxMeshWorkGroupSizeZ_NV = */ 1,
/* .maxTaskWorkGroupSizeX_NV = */ 32,
/* .maxTaskWorkGroupSizeY_NV = */ 1,
/* .maxTaskWorkGroupSizeZ_NV = */ 1,
/* .maxMeshViewCountNV = */ 4,
/* .maxDualSourceDrawBuffersEXT = */ 1,
/* .limits = */ {
/* .nonInductiveForLoops = */ 1,
/* .whileLoops = */ 1,
/* .doWhileLoops = */ 1,
/* .generalUniformIndexing = */ 1,
/* .generalAttributeMatrixVectorIndexing = */ 1,
/* .generalVaryingIndexing = */ 1,
/* .generalSamplerIndexing = */ 1,
/* .generalVariableIndexing = */ 1,
/* .generalConstantMatrixVectorIndexing = */ 1,
}
};
static MTLVertexFormat getMTLVertexFormat(DataFormat format)
{
switch (format)
@@ -314,7 +207,7 @@ Shader::Shader(id<MTLDevice> device, StrongRef<love::graphics::ShaderStage> stag
forcedefault = true;
#endif
if (!tshader->parse(&defaultTBuiltInResource, defaultversion, defaultprofile, forcedefault, forwardcompat, EShMsgSuppressWarnings))
if (!tshader->parse(GetDefaultResources(), defaultversion, defaultprofile, forcedefault, forwardcompat, EShMsgSuppressWarnings))
{
const char *stagename = "unknown";
ShaderStage::getConstant(stage, stagename);
+2 -108
View File
@@ -23,6 +23,7 @@
#include "Graphics.h"
#include "libraries/glslang/glslang/Public/ShaderLang.h"
#include "libraries/glslang/glslang/Public/ResourceLimits.h"
#include "libraries/glslang/SPIRV/GlslangToSpv.h"
@@ -33,113 +34,6 @@ namespace graphics
namespace vulkan
{
static const TBuiltInResource defaultTBuiltInResource = {
/* .MaxLights = */ 32,
/* .MaxClipPlanes = */ 6,
/* .MaxTextureUnits = */ 32,
/* .MaxTextureCoords = */ 32,
/* .MaxVertexAttribs = */ 64,
/* .MaxVertexUniformComponents = */ 16384,
/* .MaxVaryingFloats = */ 128,
/* .MaxVertexTextureImageUnits = */ 32,
/* .MaxCombinedTextureImageUnits = */ 80,
/* .MaxTextureImageUnits = */ 32,
/* .MaxFragmentUniformComponents = */ 16384,
/* .MaxDrawBuffers = */ 8,
/* .MaxVertexUniformVectors = */ 4096,
/* .MaxVaryingVectors = */ 32,
/* .MaxFragmentUniformVectors = */ 4096,
/* .MaxVertexOutputVectors = */ 32,
/* .MaxFragmentInputVectors = */ 31,
/* .MinProgramTexelOffset = */ -8,
/* .MaxProgramTexelOffset = */ 7,
/* .MaxClipDistances = */ 8,
/* .MaxComputeWorkGroupCountX = */ 65535,
/* .MaxComputeWorkGroupCountY = */ 65535,
/* .MaxComputeWorkGroupCountZ = */ 65535,
/* .MaxComputeWorkGroupSizeX = */ 1024,
/* .MaxComputeWorkGroupSizeY = */ 1024,
/* .MaxComputeWorkGroupSizeZ = */ 64,
/* .MaxComputeUniformComponents = */ 1024,
/* .MaxComputeTextureImageUnits = */ 32,
/* .MaxComputeImageUniforms = */ 16,
/* .MaxComputeAtomicCounters = */ 4096,
/* .MaxComputeAtomicCounterBuffers = */ 8,
/* .MaxVaryingComponents = */ 128,
/* .MaxVertexOutputComponents = */ 128,
/* .MaxGeometryInputComponents = */ 128,
/* .MaxGeometryOutputComponents = */ 128,
/* .MaxFragmentInputComponents = */ 128,
/* .MaxImageUnits = */ 192,
/* .MaxCombinedImageUnitsAndFragmentOutputs = */ 144,
/* .MaxCombinedShaderOutputResources = */ 144,
/* .MaxImageSamples = */ 32,
/* .MaxVertexImageUniforms = */ 16,
/* .MaxTessControlImageUniforms = */ 16,
/* .MaxTessEvaluationImageUniforms = */ 16,
/* .MaxGeometryImageUniforms = */ 16,
/* .MaxFragmentImageUniforms = */ 16,
/* .MaxCombinedImageUniforms = */ 80,
/* .MaxGeometryTextureImageUnits = */ 16,
/* .MaxGeometryOutputVertices = */ 256,
/* .MaxGeometryTotalOutputComponents = */ 1024,
/* .MaxGeometryUniformComponents = */ 1024,
/* .MaxGeometryVaryingComponents = */ 64,
/* .MaxTessControlInputComponents = */ 128,
/* .MaxTessControlOutputComponents = */ 128,
/* .MaxTessControlTextureImageUnits = */ 16,
/* .MaxTessControlUniformComponents = */ 1024,
/* .MaxTessControlTotalOutputComponents = */ 4096,
/* .MaxTessEvaluationInputComponents = */ 128,
/* .MaxTessEvaluationOutputComponents = */ 128,
/* .MaxTessEvaluationTextureImageUnits = */ 16,
/* .MaxTessEvaluationUniformComponents = */ 1024,
/* .MaxTessPatchComponents = */ 120,
/* .MaxPatchVertices = */ 32,
/* .MaxTessGenLevel = */ 64,
/* .MaxViewports = */ 16,
/* .MaxVertexAtomicCounters = */ 4096,
/* .MaxTessControlAtomicCounters = */ 4096,
/* .MaxTessEvaluationAtomicCounters = */ 4096,
/* .MaxGeometryAtomicCounters = */ 4096,
/* .MaxFragmentAtomicCounters = */ 4096,
/* .MaxCombinedAtomicCounters = */ 4096,
/* .MaxAtomicCounterBindings = */ 8,
/* .MaxVertexAtomicCounterBuffers = */ 8,
/* .MaxTessControlAtomicCounterBuffers = */ 8,
/* .MaxTessEvaluationAtomicCounterBuffers = */ 8,
/* .MaxGeometryAtomicCounterBuffers = */ 8,
/* .MaxFragmentAtomicCounterBuffers = */ 8,
/* .MaxCombinedAtomicCounterBuffers = */ 8,
/* .MaxAtomicCounterBufferSize = */ 16384,
/* .MaxTransformFeedbackBuffers = */ 4,
/* .MaxTransformFeedbackInterleavedComponents = */ 64,
/* .MaxCullDistances = */ 8,
/* .MaxCombinedClipAndCullDistances = */ 8,
/* .MaxSamples = */ 32,
/* .maxMeshOutputVerticesNV = */ 256,
/* .maxMeshOutputPrimitivesNV = */ 512,
/* .maxMeshWorkGroupSizeX_NV = */ 32,
/* .maxMeshWorkGroupSizeY_NV = */ 1,
/* .maxMeshWorkGroupSizeZ_NV = */ 1,
/* .maxTaskWorkGroupSizeX_NV = */ 32,
/* .maxTaskWorkGroupSizeY_NV = */ 1,
/* .maxTaskWorkGroupSizeZ_NV = */ 1,
/* .maxMeshViewCountNV = */ 4,
/* .maxDualSourceDrawBuffersEXT = */ 1,
/* .limits = */ {
/* .nonInductiveForLoops = */ 1,
/* .whileLoops = */ 1,
/* .doWhileLoops = */ 1,
/* .generalUniformIndexing = */ 1,
/* .generalAttributeMatrixVectorIndexing = */ 1,
/* .generalVaryingIndexing = */ 1,
/* .generalSamplerIndexing = */ 1,
/* .generalVariableIndexing = */ 1,
/* .generalConstantMatrixVectorIndexing = */ 1,
}
};
static const uint32_t STREAMBUFFER_DEFAULT_SIZE = 16;
static const uint32_t DESCRIPTOR_POOL_SIZE = 1000;
@@ -726,7 +620,7 @@ void Shader::compileShaders()
bool forceDefault = false;
bool forwardCompat = true;
if (!tshader->parse(&defaultTBuiltInResource, defaultVersion, defaultProfile, forceDefault, forwardCompat, EShMsgSuppressWarnings))
if (!tshader->parse(GetDefaultResources(), defaultVersion, defaultProfile, forceDefault, forwardCompat, EShMsgSuppressWarnings))
{
const char *stageName = "unknown";
ShaderStage::getConstant(stage, stageName);