Skip to content

Commit

Permalink
Versioning: Address #1255: Move to semantic versioning.
Browse files Browse the repository at this point in the history
Still missing is automation and final decisions on mechanisms in general.
  • Loading branch information
johnkslang committed Mar 6, 2018
1 parent 41e24fd commit c6c80a6
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 19 deletions.
4 changes: 3 additions & 1 deletion SPIRV/GlslangToSpv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6159,7 +6159,9 @@ void OutputSpvHex(const std::vector<unsigned int>& 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;
Expand Down
30 changes: 23 additions & 7 deletions StandAlone/StandAlone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ enum TOptions {
EOptionOptimizeDisable = (1 << 28),
EOptionOptimizeSize = (1 << 29),
EOptionInvertY = (1 << 30),
EOptionDumpBareVersion = (1 << 31),
};

//
Expand Down Expand Up @@ -449,6 +450,9 @@ void ProcessArguments(std::vector<std::unique_ptr<glslang::TWorkItem>>& 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;
Expand Down Expand Up @@ -520,9 +524,8 @@ void ProcessArguments(std::vector<std::unique_ptr<glslang::TWorkItem>>& workItem
variableName = argv[1];
bumpArg();
break;
} else if (lowerword == "invert-y" || // synonyms
lowerword == "iy") {
Options |= EOptionInvertY;
} else if (lowerword == "version") {
Options |= EOptionDumpVersions;
} else {
usage();
}
Expand Down Expand Up @@ -586,7 +589,11 @@ void ProcessArguments(std::vector<std::unique_ptr<glslang::TWorkItem>>& 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.
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -1313,12 +1326,15 @@ void usage()
" 'location' (fragile, not cross stage)\n"
" --aml synonym for --auto-map-locations\n"
" --client {vulkan<ver>|opengl<ver>} 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"
Expand Down Expand Up @@ -1365,8 +1381,8 @@ void usage()
" --variable-name <name> Creates a C header file that contains a\n"
" uint32_t array named <name>\n"
" initialized with the shader binary code.\n"
" --version synonym for -v\n"
" --vn <name> synonym for --variable-name <name>\n"
" --invert-y | --iy invert position.Y output in vertex shader\n"
);

exit(EFailUsage);
Expand Down
5 changes: 1 addition & 4 deletions glslang/Include/revision.h
Original file line number Diff line number Diff line change
@@ -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
7 changes: 5 additions & 2 deletions glslang/MachineIndependent/ShaderLang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
5 changes: 5 additions & 0 deletions glslang/Public/ShaderLang.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
//
Expand Down
6 changes: 1 addition & 5 deletions make-revision
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit c6c80a6

Please sign in to comment.