diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp index adf2d3d014..21cd869fac 100755 --- a/SPIRV/GlslangToSpv.cpp +++ b/SPIRV/GlslangToSpv.cpp @@ -6159,7 +6159,9 @@ void OutputSpvHex(const std::vector& spirv, const char* baseName, out.open(baseName, std::ios::binary | std::ios::out); if (out.fail()) printf("ERROR: Failed to open file: %s\n", baseName); - out << "\t// " GLSLANG_REVISION " " GLSLANG_DATE << std::endl; + out << "\t// " << + glslang::GetSpirvGeneratorVersion() << "." << GLSLANG_MINOR_VERSION << "." << GLSLANG_PATCH_LEVEL << + std::endl; if (varName != nullptr) { out << "\t #pragma once" << std::endl; out << "const uint32_t " << varName << "[] = {" << std::endl; diff --git a/StandAlone/StandAlone.cpp b/StandAlone/StandAlone.cpp index 89a16aa450..8452a68d84 100644 --- a/StandAlone/StandAlone.cpp +++ b/StandAlone/StandAlone.cpp @@ -99,6 +99,7 @@ enum TOptions { EOptionOptimizeDisable = (1 << 28), EOptionOptimizeSize = (1 << 29), EOptionInvertY = (1 << 30), + EOptionDumpBareVersion = (1 << 31), }; // @@ -449,6 +450,9 @@ void ProcessArguments(std::vector>& workItem lowerword == "hlsl-iomapper" || lowerword == "hlsl-iomapping") { Options |= EOptionHlslIoMapping; + } else if (lowerword == "invert-y" || // synonyms + lowerword == "iy") { + Options |= EOptionInvertY; } else if (lowerword == "keep-uncalled" || // synonyms lowerword == "ku") { Options |= EOptionKeepUncalled; @@ -520,9 +524,8 @@ void ProcessArguments(std::vector>& workItem variableName = argv[1]; bumpArg(); break; - } else if (lowerword == "invert-y" || // synonyms - lowerword == "iy") { - Options |= EOptionInvertY; + } else if (lowerword == "version") { + Options |= EOptionDumpVersions; } else { usage(); } @@ -586,7 +589,11 @@ void ProcessArguments(std::vector>& workItem Options |= EOptionDumpConfig; break; case 'd': - Options |= EOptionDefaultDesktop; + if (strncmp(&argv[0][1], "dumpversion", strlen(&argv[0][1]) + 1) == 0 || + strncmp(&argv[0][1], "dumpfullversion", strlen(&argv[0][1]) + 1) == 0) + Options |= EOptionDumpBareVersion; + else + Options |= EOptionDefaultDesktop; break; case 'e': // HLSL todo: entry point handle needs much more sophistication. @@ -1046,8 +1053,14 @@ int singleMain() return ESuccess; } - if (Options & EOptionDumpVersions) { - printf("Glslang Version: %s %s\n", GLSLANG_REVISION, GLSLANG_DATE); + if (Options & EOptionDumpBareVersion) { + printf("%d.%d.%d\n", + glslang::GetSpirvGeneratorVersion(), GLSLANG_MINOR_VERSION, GLSLANG_PATCH_LEVEL); + if (workList.empty()) + return ESuccess; + } else if (Options & EOptionDumpVersions) { + printf("Glslang Version: %d.%d.%d\n", + glslang::GetSpirvGeneratorVersion(), GLSLANG_MINOR_VERSION, GLSLANG_PATCH_LEVEL); printf("ESSL Version: %s\n", glslang::GetEsslVersionString()); printf("GLSL Version: %s\n", glslang::GetGlslVersionString()); std::string spirvVersion; @@ -1313,12 +1326,15 @@ void usage() " 'location' (fragile, not cross stage)\n" " --aml synonym for --auto-map-locations\n" " --client {vulkan|opengl} see -V and -G\n" + " -dumpfullversion print bare major.minor.patchlevel\n" + " -dumpversion same as -dumpfullversion\n" " --flatten-uniform-arrays flatten uniform texture/sampler arrays to\n" " scalars\n" " --fua synonym for --flatten-uniform-arrays\n" " --hlsl-offsets Allow block offsets to follow HLSL rules\n" " Works independently of source language\n" " --hlsl-iomap Perform IO mapping in HLSL register space\n" + " --invert-y | --iy invert position.Y output in vertex shader\n" " --keep-uncalled don't eliminate uncalled functions\n" " --ku synonym for --keep-uncalled\n" " --no-storage-format use Unknown image format\n" @@ -1365,8 +1381,8 @@ void usage() " --variable-name Creates a C header file that contains a\n" " uint32_t array named \n" " initialized with the shader binary code.\n" + " --version synonym for -v\n" " --vn synonym for --variable-name \n" - " --invert-y | --iy invert position.Y output in vertex shader\n" ); exit(EFailUsage); diff --git a/glslang/Include/revision.h b/glslang/Include/revision.h index 218f8b67f5..5e94323ec4 100644 --- a/glslang/Include/revision.h +++ b/glslang/Include/revision.h @@ -1,6 +1,3 @@ // This header is generated by the make-revision script. -// For the version, it uses the latest git tag followed by the number of commits. -// For the date, it uses the current date (when then script is run). -#define GLSLANG_REVISION "Overload400-PrecQual.2000" -#define GLSLANG_DATE "12-Apr-2017" +#define GLSLANG_PATCH_LEVEL 2583 diff --git a/glslang/MachineIndependent/ShaderLang.cpp b/glslang/MachineIndependent/ShaderLang.cpp index 91137607fc..0bf428e140 100644 --- a/glslang/MachineIndependent/ShaderLang.cpp +++ b/glslang/MachineIndependent/ShaderLang.cpp @@ -1577,14 +1577,17 @@ namespace glslang { #include "../Include/revision.h" +#define QUOTE(s) #s +#define STR(n) QUOTE(n) + const char* GetEsslVersionString() { - return "OpenGL ES GLSL 3.20 glslang Khronos." GLSLANG_REVISION " " GLSLANG_DATE; + return "OpenGL ES GLSL 3.20 glslang Khronos. " STR(GLSLANG_MINOR_VERSION) "." STR(GLSLANG_PATCH_LEVEL); } const char* GetGlslVersionString() { - return "4.60 glslang Khronos." GLSLANG_REVISION " " GLSLANG_DATE; + return "4.60 glslang Khronos. " STR(GLSLANG_MINOR_VERSION) "." STR(GLSLANG_PATCH_LEVEL); } int GetKhronosToolId() diff --git a/glslang/Public/ShaderLang.h b/glslang/Public/ShaderLang.h index 484906e97f..fe8a3f2814 100644 --- a/glslang/Public/ShaderLang.h +++ b/glslang/Public/ShaderLang.h @@ -67,6 +67,11 @@ extern "C" { #endif +// This should always increase, as some paths to do not consume +// a more major number. +// It should increment by one when new functionality is added. +#define GLSLANG_MINOR_VERSION 0 + // // Call before doing any other compiler/linker operations. // diff --git a/make-revision b/make-revision index 492e437562..a89ff08772 100755 --- a/make-revision +++ b/make-revision @@ -1,10 +1,6 @@ #!/bin/sh ( echo "// This header is generated by the make-revision script." -echo "// For the version, it uses the latest git tag followed by the number of commits." -echo "// For the date, it uses the current date (when then script is run)." - echo -echo \#define GLSLANG_REVISION \"`git describe --tags --abbrev=0`.`git log --oneline | wc -l`\" -echo \#define GLSLANG_DATE \"`date +%d-%b-%Y`\" +echo \#define GLSLANG_PATCH_LEVEL `git log --oneline | wc -l` ) > glslang/Include/revision.h