From 319de233dcad574eee1ab7573f96c2d8b0f9174d Mon Sep 17 00:00:00 2001 From: John Kessenich Date: Wed, 4 Dec 2013 04:43:40 +0000 Subject: [PATCH] Add a versioning system and tie it to the -v command-line option. System is described in glslang/Include/revision.template. git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@24314 e7fa87d3-cd2b-0410-9028-fcbf551c1848 --- StandAlone/StandAlone.cpp | 45 ++++++++++++++++++++----------- glslang.vcxproj | 6 +++++ glslang/Include/revision.h | 13 +++++++++ glslang/Include/revision.template | 13 +++++++++ glslang/MachineIndependent/ShaderLang.cpp | 6 +++-- 5 files changed, 65 insertions(+), 18 deletions(-) create mode 100644 glslang/Include/revision.h create mode 100644 glslang/Include/revision.template diff --git a/StandAlone/StandAlone.cpp b/StandAlone/StandAlone.cpp index 8e240c6..ba910f8 100644 --- a/StandAlone/StandAlone.cpp +++ b/StandAlone/StandAlone.cpp @@ -63,6 +63,7 @@ enum TOptions { EOptionDumpConfig = 0x080, EOptionDumpReflection = 0x100, EOptionSuppressWarnings = 0x200, + EOptionDumpVersions = 0x400, }; // @@ -486,6 +487,9 @@ bool ProcessArguments(int argc, char* argv[]) Options |= EOptionMultiThreaded; #endif break; + case 'v': + Options |= EOptionDumpVersions; + break; case 'w': Options |= EOptionSuppressWarnings; break; @@ -552,9 +556,6 @@ void CompileAndLinkShaders() // keep track of what to free std::list shaders; - //printf("%s\n", glslang::GetEsslVersionString()); - //printf("%s\n", glslang::GetGlslVersionString()); - EShMessages messages = EShMsgDefault; SetMessageOptions(messages); @@ -632,6 +633,13 @@ int C_DECL main(int argc, char* argv[]) return ESuccess; } + if (Options & EOptionDumpVersions) { + printf("ESSL Version: %s\n", glslang::GetEsslVersionString()); + printf("GLSL Version: %s\n", glslang::GetGlslVersionString()); + if (Worklist.empty()) + return ESuccess; + } + if (Worklist.empty()) { usage(); return EFailUsage; @@ -783,27 +791,32 @@ void CompileFile(const char *fileName, ShHandle compiler) // void usage() { - printf("Usage: glslangValidator [ options ] filename\n" - "Where: filename is a name ending in\n" - " .conf provides an optional config file that replaces the default configuration\n" + printf("Usage: glslangValidator [option]... [file]...\n" + "\n" + "Where: each 'file' ends in\n" + " .conf to provide an optional config file that replaces the default configuration\n" " (see -c option below for generating a template)\n" " .vert for a vertex shader\n" " .tesc for a tessellation control shader\n" " .tese for a tessellation evaluation shader\n" " .geom for a geometry shader\n" " .frag for a fragment shader\n" - " .comp for a compute shader\n\n" + " .comp for a compute shader\n" + "\n" "Compilation warnings and errors will be printed to stdout.\n" + "\n" "To get other information, use one of the following options:\n" - "-c: configuration dump; use to create default configuration file (redirect to a .conf file)\n" - "-i: intermediate tree (glslang AST) is printed out\n" - "-l: link validation of all input files\n" - "-m: memory leak mode\n" - "-q: dump reflection query database\n" - "-r: relaxed semantic error-checking mode\n" - "-s: silent mode\n" - "-t: multi-threaded mode\n" - "-w: suppress warnings (except as required by #extension : warn)\n" + "(Each option must be specified separately, but can go anywhere in the command line.)\n" + " -c configuration dump; use to create default configuration file (redirect to a .conf file)\n" + " -i intermediate tree (glslang AST) is printed out\n" + " -l link validation of all input files\n" + " -m memory leak mode\n" + " -q dump reflection query database\n" + " -r relaxed semantic error-checking mode\n" + " -s silent mode\n" + " -t multi-threaded mode\n" + " -v print version strings\n" + " -w suppress warnings (except as required by #extension : warn)\n" ); } diff --git a/glslang.vcxproj b/glslang.vcxproj index 7685882..dc7b773 100644 --- a/glslang.vcxproj +++ b/glslang.vcxproj @@ -94,6 +94,9 @@ xcopy /y $(IntDir)$(TargetName)$(TargetExt) Test _DEBUG;%(PreprocessorDefinitions) 0x0809 + + SubWCRev . glslang/Include/revision.template glslang/Include/revision.h -q + @@ -147,6 +150,9 @@ xcopy /y $(IntDir)$(TargetName)$(TargetExt) Test NDEBUG;%(PreprocessorDefinitions) 0x0809 + + SubWCRev . glslang/Include/revision.template glslang/Include/revision.h -q + diff --git a/glslang/Include/revision.h b/glslang/Include/revision.h new file mode 100644 index 0000000..e18be76 --- /dev/null +++ b/glslang/Include/revision.h @@ -0,0 +1,13 @@ +// The file revision.h should be updated to the latest version, somehow, on +// check-in, if glslang has changed. +// +// revision.template is the source for revision.h when using SubWCRev as the +// method of updating revision.h. You don't have to do it this way, the +// requirement is only that revision.h gets updated. +// +// revision.h is under source control so that not all consumers of glslang +// source have to figure out how to create revision.h just to get a build +// going. However, if it is not updated, it can be a version behind. + +#define GLSLANG_REVISION "24303" +#define GLSLANG_DATE "2013/12/03 14:05:07" diff --git a/glslang/Include/revision.template b/glslang/Include/revision.template new file mode 100644 index 0000000..1dc3392 --- /dev/null +++ b/glslang/Include/revision.template @@ -0,0 +1,13 @@ +// The file revision.h should be updated to the latest version, somehow, on +// check-in, if glslang has changed. +// +// revision.template is the source for revision.h when using SubWCRev as the +// method of updating revision.h. You don't have to do it this way, the +// requirement is only that revision.h gets updated. +// +// revision.h is under source control so that not all consumers of glslang +// source have to figure out how to create revision.h just to get a build +// going. However, if it is not updated, it can be a version behind. + +#define GLSLANG_REVISION "$WCREV$" +#define GLSLANG_DATE "$WCDATE$" diff --git a/glslang/MachineIndependent/ShaderLang.cpp b/glslang/MachineIndependent/ShaderLang.cpp index 8fcf581..730ffe9 100644 --- a/glslang/MachineIndependent/ShaderLang.cpp +++ b/glslang/MachineIndependent/ShaderLang.cpp @@ -912,14 +912,16 @@ int ShGetUniformLocation(const ShHandle handle, const char* name) namespace glslang { +#include "../Include/revision.h" + const char* GetEsslVersionString() { - return "OpenGL ES GLSL 3.00 glslang"; + return "OpenGL ES GLSL 3.00 glslang LunarG Khronos." GLSLANG_REVISION " " GLSLANG_DATE; } const char* GetGlslVersionString() { - return "4.20 glslang"; + return "4.20 glslang LunarG Khronos." GLSLANG_REVISION " " GLSLANG_DATE; } bool InitializeProcess() -- 2.7.4