Merge remote-tracking branch 'GitHub/master'
diff --git a/.appveyor.yml b/.appveyor.yml
index d5c7225..33a6837 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -7,7 +7,7 @@
os: Visual Studio 2013
platform:
- - Any CPU
+ - x64
configuration:
- Debug
@@ -39,3 +39,45 @@
test_script:
- ctest -C %CONFIGURATION% --output-on-failure
- cd ../Test && bash runtests
+ - cd ../build
+
+after_test:
+ # For debug build, the generated dll has a postfix "d" in its name.
+ - ps: >-
+ If ($env:configuration -Match "Debug") {
+ $env:SUFFIX="d"
+ } Else {
+ $env:SUFFIX=""
+ }
+ - cd install
+ # Zip all glslang artifacts for uploading and deploying
+ - 7z a glslang-master-windows-"%PLATFORM%"-"%CONFIGURATION%".zip
+ bin\glslangValidator.exe
+ include\glslang\*
+ include\SPIRV\*
+ lib\glslang%SUFFIX%.lib
+ lib\HLSL%SUFFIX%.lib
+ lib\OGLCompiler%SUFFIX%.lib
+ lib\OSDependent%SUFFIX%.lib
+ lib\SPIRV%SUFFIX%.lib
+ lib\SPVRemapper%SUFFIX%.lib
+ lib\SPIRV-Tools%SUFFIX%.lib
+ lib\SPIRV-Tools-opt%SUFFIX%.lib
+
+artifacts:
+ - path: build\install\*.zip
+ name: artifacts-zip
+
+deploy:
+ - provider: GitHub
+ auth_token:
+ secure: YglcSYdl0TylEa59H4K6lylBEDr586NAt2EMgZquSo+iuPrwgZQuJLPCoihSm9y6
+ release: master-tot
+ description: "Continuous build of the latest master branch by Appveyor and Travis CI"
+ artifact: artifacts-zip
+ draft: false
+ prerelease: false
+ force_update: true
+ on:
+ branch: master
+ APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp
index aa29267..d20de0e 100644
--- a/SPIRV/GlslangToSpv.cpp
+++ b/SPIRV/GlslangToSpv.cpp
@@ -79,11 +79,6 @@
namespace {
-// For low-order part of the generator's magic number. Bump up
-// when there is a change in the style (e.g., if SSA form changes,
-// or a different instruction sequence to do something gets used).
-const int GeneratorVersion = 2;
-
namespace {
class SpecConstantOpModeGuard {
public:
@@ -928,7 +923,7 @@
options(options),
shaderEntry(nullptr), currentFunction(nullptr),
sequenceDepth(0), logger(buildLogger),
- builder((glslang::GetKhronosToolId() << 16) | GeneratorVersion, logger),
+ builder((glslang::GetKhronosToolId() << 16) | glslang::GetSpirvGeneratorVersion(), logger),
inEntryPoint(false), entryPointTerminated(false), linkageOnly(false),
glslangIntermediate(glslangIntermediate)
{
@@ -6433,6 +6428,14 @@
version = buf;
}
+// For low-order part of the generator's magic number. Bump up
+// when there is a change in the style (e.g., if SSA form changes,
+// or a different instruction sequence to do something gets used).
+int GetSpirvGeneratorVersion()
+{
+ return 2;
+}
+
// Write SPIR-V out to a binary file
void OutputSpvBin(const std::vector<unsigned int>& spirv, const char* baseName)
{
diff --git a/SPIRV/GlslangToSpv.h b/SPIRV/GlslangToSpv.h
index 0398501..3a43713 100644
--- a/SPIRV/GlslangToSpv.h
+++ b/SPIRV/GlslangToSpv.h
@@ -56,6 +56,7 @@
};
void GetSpirvVersion(std::string&);
+int GetSpirvGeneratorVersion();
void GlslangToSpv(const glslang::TIntermediate& intermediate, std::vector<unsigned int>& spirv,
SpvOptions* options = nullptr);
void GlslangToSpv(const glslang::TIntermediate& intermediate, std::vector<unsigned int>& spirv,
diff --git a/SPIRV/SPVRemapper.cpp b/SPIRV/SPVRemapper.cpp
index 412f649..5e59861 100755
--- a/SPIRV/SPVRemapper.cpp
+++ b/SPIRV/SPVRemapper.cpp
@@ -1392,7 +1392,7 @@
int strippedPos = 0;
for (unsigned word = 0; word < unsigned(spv.size()); ++word) {
- if (strip_it != stripRange.end() && word >= strip_it->second)
+ while (strip_it != stripRange.end() && word >= strip_it->second)
++strip_it;
if (strip_it == stripRange.end() || word < strip_it->first || word >= strip_it->second)
diff --git a/StandAlone/StandAlone.cpp b/StandAlone/StandAlone.cpp
index 977ee62..003c03b 100644
--- a/StandAlone/StandAlone.cpp
+++ b/StandAlone/StandAlone.cpp
@@ -261,14 +261,14 @@
//
void Error(const char* message)
{
- printf("%s: Error %s (use -h for usage)\n", ExecutableName, message);
+ fprintf(stderr, "%s: Error %s (use -h for usage)\n", ExecutableName, message);
exit(EFailUsage);
}
//
// Process an optional binding base of one the forms:
// --argname [stage] base // base for stage (if given) or all stages (if not)
-// --argname [stage] [set base]... // set/base pairs: set the base for given binding set.
+// --argname [stage] [base set]... // set/base pairs: set the base for given binding set.
// Where stage is one of the forms accepted by FindLanguage, and base is an integer
//
@@ -293,8 +293,8 @@
if ((argc - arg) > 2 && isdigit(argv[arg+0][0]) && isdigit(argv[arg+1][0])) {
// Parse a per-set binding base
while ((argc - arg) > 2 && isdigit(argv[arg+0][0]) && isdigit(argv[arg+1][0])) {
- const int setNum = atoi(argv[arg++]);
const int baseNum = atoi(argv[arg++]);
+ const int setNum = atoi(argv[arg++]);
perSetBase[setNum] = baseNum;
}
} else {
@@ -825,7 +825,7 @@
// TODO: use a range based for loop here, when available in all environments.
for (auto i = baseBindingForSet[res][compUnit.stage].begin();
i != baseBindingForSet[res][compUnit.stage].end(); ++i)
- shader->setShiftBindingForSet(res, i->first, i->second);
+ shader->setShiftBindingForSet(res, i->second, i->first);
}
shader->setFlattenUniformArrays((Options & EOptionFlattenUniformArrays) != 0);
@@ -1053,6 +1053,7 @@
printf("SPIR-V Version %s\n", spirvVersion.c_str());
printf("GLSL.std.450 Version %d, Revision %d\n", GLSLstd450Version, GLSLstd450Revision);
printf("Khronos Tool ID %d\n", glslang::GetKhronosToolId());
+ printf("SPIR-V Generator Version %d\n", glslang::GetSpirvGeneratorVersion());
printf("GL_KHR_vulkan_glsl version %d\n", 100);
printf("ARB_GL_gl_spirv version %d\n", 100);
if (workList.empty())
@@ -1093,7 +1094,7 @@
threads[t] = std::thread(CompileShaders, std::ref(workList));
if (threads[t].get_id() == std::thread::id())
{
- printf("Failed to create thread\n");
+ fprintf(stderr, "Failed to create thread\n");
return EFailThreadCreate;
}
}
@@ -1305,24 +1306,24 @@
" Set descriptor set for all resources\n"
" --rsb [stage] type set binding synonym for --resource-set-binding\n"
" --shift-image-binding [stage] num base binding number for images (uav)\n"
- " --shift-image-binding [stage] [set num]... per-descriptor-set shift values\n"
+ " --shift-image-binding [stage] [num set]... per-descriptor-set shift values\n"
" --sib [stage] num synonym for --shift-image-binding\n"
" --shift-sampler-binding [stage] num base binding number for samplers\n"
- " --shift-sampler-binding [stage] [set num]... per-descriptor-set shift values\n"
+ " --shift-sampler-binding [stage] [num set]... per-descriptor-set shift values\n"
" --ssb [stage] num synonym for --shift-sampler-binding\n"
" --shift-ssbo-binding [stage] num base binding number for SSBOs\n"
- " --shift-ssbo-binding [stage] [set num]... per-descriptor-set shift values\n"
+ " --shift-ssbo-binding [stage] [num set]... per-descriptor-set shift values\n"
" --sbb [stage] num synonym for --shift-ssbo-binding\n"
" --shift-texture-binding [stage] num base binding number for textures\n"
- " --shift-texture-binding [stage] [set num]... per-descriptor-set shift values\n"
+ " --shift-texture-binding [stage] [num set]... per-descriptor-set shift values\n"
" --stb [stage] num synonym for --shift-texture-binding\n"
" --shift-uav-binding [stage] num base binding number for UAVs\n"
- " --shift-uav-binding [stage] [set num]... per-descriptor-set shift values\n"
+ " --shift-uav-binding [stage] [num set]... per-descriptor-set shift values\n"
" --suavb [stage] num synonym for --shift-uav-binding\n"
" --shift-UBO-binding [stage] num base binding number for UBOs\n"
- " --shift-UBO-binding [stage] [set num]... per-descriptor-set shift values\n"
+ " --shift-UBO-binding [stage] [num set]... per-descriptor-set shift values\n"
" --shift-cbuffer-binding [stage] num synonym for --shift-UBO-binding\n"
- " --shift-cbuffer-binding [stage] [set num]... per-descriptor-set shift values\n"
+ " --shift-cbuffer-binding [stage] [num set]... per-descriptor-set shift values\n"
" --sub [stage] num synonym for --shift-UBO-binding\n"
" --source-entrypoint <name> the given shader source function is\n"
" renamed to be the <name> given in -e\n"
diff --git a/Test/baseResults/310AofA.vert.out b/Test/baseResults/310AofA.vert.out
index 882c58a..70b5968 100644
--- a/Test/baseResults/310AofA.vert.out
+++ b/Test/baseResults/310AofA.vert.out
@@ -320,7 +320,7 @@
0:? Linker Objects
0:? 'name' (layout( column_major shared) buffer 3-element array of block{layout( column_major shared) buffer implicitly-sized array of highp float u, layout( column_major shared) buffer implicitly-sized array of highp 4-component vector of float v})
0:? 'uname' (layout( column_major shared) uniform 3-element array of block{layout( column_major shared) uniform highp float u, layout( column_major shared) uniform implicitly-sized array of highp 4-component vector of float v})
-0:? 'name2' (layout( column_major shared) buffer 3-element array of block{layout( column_major shared) buffer highp float u, layout( column_major shared) buffer implicitly-sized array of implicitly-sized array of highp 4-component vector of float v})
+0:? 'name2' (layout( column_major shared) buffer 3-element array of block{layout( column_major shared) buffer highp float u, layout( column_major shared) buffer implicitly-sized array of 1-element array of highp 4-component vector of float v})
0:? 'name3' (layout( column_major shared) buffer 3-element array of block{layout( column_major shared) buffer highp float u, layout( column_major shared) buffer implicitly-sized array of 7-element array of highp 4-component vector of float v})
0:? 'many' ( global 1-element array of 2-element array of 3-element array of 4-element array of 5-element array of 6-element array of highp float)
0:? 'gu' ( global implicitly-sized array of 7-element array of highp float)
@@ -361,7 +361,7 @@
0:? Linker Objects
0:? 'name' (layout( column_major shared) buffer 3-element array of block{layout( column_major shared) buffer implicitly-sized array of highp float u, layout( column_major shared) buffer implicitly-sized array of highp 4-component vector of float v})
0:? 'uname' (layout( column_major shared) uniform 3-element array of block{layout( column_major shared) uniform highp float u, layout( column_major shared) uniform 1-element array of highp 4-component vector of float v})
-0:? 'name2' (layout( column_major shared) buffer 3-element array of block{layout( column_major shared) buffer highp float u, layout( column_major shared) buffer implicitly-sized array of implicitly-sized array of highp 4-component vector of float v})
+0:? 'name2' (layout( column_major shared) buffer 3-element array of block{layout( column_major shared) buffer highp float u, layout( column_major shared) buffer implicitly-sized array of 1-element array of highp 4-component vector of float v})
0:? 'name3' (layout( column_major shared) buffer 3-element array of block{layout( column_major shared) buffer highp float u, layout( column_major shared) buffer implicitly-sized array of 7-element array of highp 4-component vector of float v})
0:? 'many' ( global 1-element array of 2-element array of 3-element array of 4-element array of 5-element array of 6-element array of highp float)
0:? 'gu' ( global 1-element array of 7-element array of highp float)
diff --git a/Test/baseResults/430AofA.frag.out b/Test/baseResults/430AofA.frag.out
index 788a8d1..22dc4d3 100644
--- a/Test/baseResults/430AofA.frag.out
+++ b/Test/baseResults/430AofA.frag.out
@@ -405,7 +405,7 @@
0:? Linker Objects
0:? 'many' ( global 1-element array of 2-element array of 3-element array of 4-element array of 5-element array of 6-element array of float)
0:? 'gu' ( global implicitly-sized array of 7-element array of float)
-0:? 'gimp' ( global implicitly-sized array of implicitly-sized array of float)
+0:? 'gimp' ( global implicitly-sized array of 1-element array of float)
0:? 'g4' ( global 4-element array of 7-element array of float)
0:? 'g5' ( global 5-element array of 7-element array of float)
@@ -768,7 +768,7 @@
0:? Linker Objects
0:? 'many' ( global 1-element array of 2-element array of 3-element array of 4-element array of 5-element array of 6-element array of float)
0:? 'gu' ( global 1-element array of 7-element array of float)
-0:? 'gimp' ( global 1-element array of implicitly-sized array of float)
+0:? 'gimp' ( global 1-element array of 1-element array of float)
0:? 'g4' ( global 4-element array of 7-element array of float)
0:? 'g5' ( global 5-element array of 7-element array of float)
diff --git a/Test/baseResults/cppBad.vert.out b/Test/baseResults/cppBad.vert.out
index 205c29b..1a2286a 100755
--- a/Test/baseResults/cppBad.vert.out
+++ b/Test/baseResults/cppBad.vert.out
@@ -2,10 +2,9 @@
ERROR: 0:2: 'preprocessor evaluation' : bad expression
ERROR: 0:2: '#if' : unexpected tokens following directive
ERROR: 0:5: 'string' : End of line in string
-ERROR: 0:5: 'macro expansion' : expected '(' following n
ERROR: 0:5: '""' : string literals not supported
ERROR: 0:5: '' : syntax error, unexpected INT, expecting COMMA or SEMICOLON
-ERROR: 6 compilation errors. No code generated.
+ERROR: 5 compilation errors. No code generated.
Shader version: 100
diff --git a/Test/baseResults/cppPassMacroName.frag.out b/Test/baseResults/cppPassMacroName.frag.out
new file mode 100755
index 0000000..d8459b3
--- /dev/null
+++ b/Test/baseResults/cppPassMacroName.frag.out
@@ -0,0 +1,67 @@
+cppPassMacroName.frag
+Shader version: 100
+0:? Sequence
+0:5 Function Definition: main( ( global void)
+0:5 Function Parameters:
+0:7 Sequence
+0:7 Sequence
+0:7 move second child to first child ( temp mediump int)
+0:7 'f1' ( temp mediump int)
+0:7 Constant:
+0:7 4 (const int)
+0:8 Sequence
+0:8 move second child to first child ( temp mediump int)
+0:8 'f2' ( temp mediump int)
+0:8 'f1' ( temp mediump int)
+0:9 Sequence
+0:9 move second child to first child ( temp mediump int)
+0:9 'f3' ( temp mediump int)
+0:9 Constant:
+0:9 9 (const int)
+0:10 Sequence
+0:10 move second child to first child ( temp mediump int)
+0:10 'f4' ( temp mediump int)
+0:10 Constant:
+0:10 1 (const int)
+0:11 Sequence
+0:11 move second child to first child ( temp mediump int)
+0:11 'f5' ( temp mediump int)
+0:11 Constant:
+0:11 5 (const int)
+0:? Linker Objects
+
+
+Linked fragment stage:
+
+
+Shader version: 100
+0:? Sequence
+0:5 Function Definition: main( ( global void)
+0:5 Function Parameters:
+0:7 Sequence
+0:7 Sequence
+0:7 move second child to first child ( temp mediump int)
+0:7 'f1' ( temp mediump int)
+0:7 Constant:
+0:7 4 (const int)
+0:8 Sequence
+0:8 move second child to first child ( temp mediump int)
+0:8 'f2' ( temp mediump int)
+0:8 'f1' ( temp mediump int)
+0:9 Sequence
+0:9 move second child to first child ( temp mediump int)
+0:9 'f3' ( temp mediump int)
+0:9 Constant:
+0:9 9 (const int)
+0:10 Sequence
+0:10 move second child to first child ( temp mediump int)
+0:10 'f4' ( temp mediump int)
+0:10 Constant:
+0:10 1 (const int)
+0:11 Sequence
+0:11 move second child to first child ( temp mediump int)
+0:11 'f5' ( temp mediump int)
+0:11 Constant:
+0:11 5 (const int)
+0:? Linker Objects
+
diff --git a/Test/baseResults/cppSimple.vert.out b/Test/baseResults/cppSimple.vert.out
index 1b6e6b5..edb0c33 100644
--- a/Test/baseResults/cppSimple.vert.out
+++ b/Test/baseResults/cppSimple.vert.out
@@ -75,10 +75,8 @@
ERROR: 12:20055: '#error' : good evaluation 2
ERROR: 12:9000: 'preprocessor evaluation' : expected ')'
ERROR: 12:9002: '#if' : unexpected tokens following directive
-ERROR: 12:9014: 'macro expansion' : expected '(' following FOOOM
ERROR: 12:9014: 'FOOOM' : undeclared identifier
ERROR: 12:9014: '=' : cannot convert from ' temp float' to ' global int'
-ERROR: 12:9015: 'macro expansion' : expected '(' following FOOOM
ERROR: 12:9016: 'preprocessor evaluation' : can't evaluate expression
ERROR: 12:9016: 'preprocessor evaluation' : bad expression
ERROR: 12:9500: 'preprocessor evaluation' : bad expression
@@ -93,7 +91,7 @@
ERROR: 12:9602: 'defined' : cannot use in preprocessor expression when expanded from macros
ERROR: 12:9603: '#error' : DEF_DEFINED then
ERROR: 12:10002: '' : missing #endif
-ERROR: 90 compilation errors. No code generated.
+ERROR: 88 compilation errors. No code generated.
Shader version: 400
diff --git a/Test/baseResults/glspv.frag.out b/Test/baseResults/glspv.frag.out
index 5622d01..4939807 100755
--- a/Test/baseResults/glspv.frag.out
+++ b/Test/baseResults/glspv.frag.out
@@ -1,9 +1,13 @@
glspv.frag
ERROR: 0:4: '#error' : GL_SPIRV is set ( correct , not an error )
ERROR: 0:6: '#error' : GL_SPIR is 100
-ERROR: 0:19: 'input_attachment_index' : only allowed when using GLSL for Vulkan
-ERROR: 0:19: '' : syntax error, unexpected IDENTIFIER, expecting LEFT_BRACE or COMMA or SEMICOLON
-ERROR: 4 compilation errors. No code generated.
+ERROR: 0:21: 'noise1' : no matching overloaded function found
+ERROR: 0:22: 'noise2' : no matching overloaded function found
+ERROR: 0:23: 'noise3' : no matching overloaded function found
+ERROR: 0:24: 'noise4' : no matching overloaded function found
+ERROR: 0:27: 'input_attachment_index' : only allowed when using GLSL for Vulkan
+ERROR: 0:27: '' : syntax error, unexpected IDENTIFIER, expecting LEFT_BRACE or COMMA or SEMICOLON
+ERROR: 8 compilation errors. No code generated.
SPIR-V is not generated for failed compile or link
diff --git a/Test/baseResults/implicitInnerAtomicUint.frag.out b/Test/baseResults/implicitInnerAtomicUint.frag.out
new file mode 100755
index 0000000..ed9771e
--- /dev/null
+++ b/Test/baseResults/implicitInnerAtomicUint.frag.out
@@ -0,0 +1,20 @@
+implicitInnerAtomicUint.frag
+ERROR: 0:2: '[]' : only outermost dimension of an array of arrays can be implicitly sized
+ERROR: 1 compilation errors. No code generated.
+
+
+Shader version: 460
+ERROR: node is still EOpNull!
+0:? Linker Objects
+0:? 'c' (layout( binding=0 offset=0) uniform 1-element array of 1-element array of atomic_uint)
+
+
+Linked fragment stage:
+
+ERROR: Linking fragment stage: Missing entry point: Each stage requires one entry point
+
+Shader version: 460
+ERROR: node is still EOpNull!
+0:? Linker Objects
+0:? 'c' (layout( binding=0 offset=0) uniform 1-element array of 1-element array of atomic_uint)
+
diff --git a/Test/baseResults/spv.specConstant.vert.out b/Test/baseResults/spv.specConstant.vert.out
index 2d57625..b633c7b 100644
--- a/Test/baseResults/spv.specConstant.vert.out
+++ b/Test/baseResults/spv.specConstant.vert.out
@@ -11,7 +11,7 @@
Source GLSL 400
Name 4 "main"
Name 9 "arraySize"
- Name 14 "foo(vf4[s2164];"
+ Name 14 "foo(vf4[s2148];"
Name 13 "p"
Name 17 "builtin_spec_constant("
Name 20 "color"
@@ -102,10 +102,10 @@
Store 20(color) 46
48: 10 Load 22(ucol)
Store 47(param) 48
- 49: 2 FunctionCall 14(foo(vf4[s2164];) 47(param)
+ 49: 2 FunctionCall 14(foo(vf4[s2148];) 47(param)
Return
FunctionEnd
-14(foo(vf4[s2164];): 2 Function None 12
+14(foo(vf4[s2148];): 2 Function None 12
13(p): 11(ptr) FunctionParameter
15: Label
54: 24(ptr) AccessChain 53(dupUcol) 23
diff --git a/Test/baseResults/vulkan.frag.out b/Test/baseResults/vulkan.frag.out
index c8e1ed6..0440cf4 100644
--- a/Test/baseResults/vulkan.frag.out
+++ b/Test/baseResults/vulkan.frag.out
@@ -39,7 +39,11 @@
ERROR: 0:94: ':' : wrong operand types: no operation ':' exists that takes a left-hand operand of type ' temp sampler2D' and a right operand of type ' temp sampler2D' (or there is no acceptable conversion)
ERROR: 0:94: 'call argument' : sampler constructor must appear at point of use
ERROR: 0:96: 'gl_NumSamples' : undeclared identifier
-ERROR: 38 compilation errors. No code generated.
+ERROR: 0:101: 'noise1' : no matching overloaded function found
+ERROR: 0:102: 'noise2' : no matching overloaded function found
+ERROR: 0:103: 'noise3' : no matching overloaded function found
+ERROR: 0:104: 'noise4' : no matching overloaded function found
+ERROR: 42 compilation errors. No code generated.
ERROR: Linking fragment stage: Only one push_constant block is allowed per stage
diff --git a/Test/cppPassMacroName.frag b/Test/cppPassMacroName.frag
new file mode 100644
index 0000000..f42d9de
--- /dev/null
+++ b/Test/cppPassMacroName.frag
@@ -0,0 +1,12 @@
+#define f1(i) ((i)*(i))
+#define I2(f, n) f(n) + f(n+1)
+#define I3(f, n) I2(f, n) + f(n+2)
+
+void main()
+{
+ int f1 = 4;
+ int f2 = f1;
+ int f3 = f1(3);
+ int f4 = I2(f1, 0);
+ int f5 = I3(f1, 0);
+}
diff --git a/Test/glspv.frag b/Test/glspv.frag
index 008d191..86c9f6a 100644
--- a/Test/glspv.frag
+++ b/Test/glspv.frag
@@ -16,4 +16,12 @@
uniform sampler2D s1;
layout(location = 3) uniform sampler2D s2;
+void noise()
+{
+ noise1(vec4(1));
+ noise2(4.0);
+ noise3(vec2(3));
+ noise4(1);
+}
+
layout(input_attachment_index = 1) uniform subpassInput sub; // ERROR, no inputs
diff --git a/Test/implicitInnerAtomicUint.frag b/Test/implicitInnerAtomicUint.frag
new file mode 100644
index 0000000..bb76516
--- /dev/null
+++ b/Test/implicitInnerAtomicUint.frag
@@ -0,0 +1,2 @@
+#version 460
+layout(binding = 0) uniform atomic_uint c[1][];
\ No newline at end of file
diff --git a/Test/runtests b/Test/runtests
index c31a022..7d269e4 100755
--- a/Test/runtests
+++ b/Test/runtests
@@ -108,7 +108,7 @@
# Testing per-descriptor-set IO map shift
#
echo 'Testing per-descriptor-set IO map shift'
-$EXE -e main --hlsl-iomap --ssb 1 10 2 15 --stb 20 --stb 2 25 --suavb 30 --suavb 2 40 --sub 6 50 -i -q -D -V hlsl.shift.per-set.frag > $TARGETDIR/hlsl.shift.per-set.frag.out || HASERROR=1
+$EXE -e main --hlsl-iomap --ssb 10 1 15 2 --stb 20 --stb 25 2 --suavb 30 --suavb 40 2 --sub 50 6 -i -q -D -V hlsl.shift.per-set.frag > $TARGETDIR/hlsl.shift.per-set.frag.out || HASERROR=1
diff -b $BASEDIR/hlsl.shift.per-set.frag.out $TARGETDIR/hlsl.shift.per-set.frag.out || HASERROR=1
#
diff --git a/Test/validate-shaders.sh b/Test/validate-shaders.sh
new file mode 100755
index 0000000..9211106
--- /dev/null
+++ b/Test/validate-shaders.sh
@@ -0,0 +1,269 @@
+#!/bin/bash
+
+# This script validates shaders (if successfully compiled) using spirv-val.
+# It is not meant to preclude the possible addition of the validator to
+# glslang.
+
+declare -r EXE='../build/install/bin/glslangValidator'
+
+# search common locations for spirv-tools: keep first one
+for toolsdir in '../External/spirv-tools/build/tools' '../../SPIRV-Tools/build/tools' '/usr/local/bin'; do
+ [[ -z "$VAL" && -x "${toolsdir}/spirv-val" ]] && declare -r VAL="${toolsdir}/spirv-val"
+ [[ -z "$DIS" && -x "${toolsdir}/spirv-dis" ]] && declare -r DIS="${toolsdir}/spirv-dis"
+done
+
+declare -r gtests='../gtests/Hlsl.FromFile.cpp ../gtests/Spv.FromFile.cpp'
+
+declare -r targetenv='vulkan1.0'
+
+function fatal() { echo "ERROR: $@"; exit 5; }
+
+function usage
+{
+ echo
+ echo "Usage: $(basename $0) [options...] shaders..."
+ echo
+ echo " Validates shaders (if successfully compiled) through spirv-val."
+ echo
+ echo "General options:"
+ echo " --help prints this text"
+ echo " --no-color disables output colorization"
+ echo " --dump-asm dumps all successfully compiled shader assemblies"
+ echo " --dump-val dumps all validation results"
+ echo " --dump-comp dumps all compilation logs"
+ echo "Spam reduction options:"
+ echo " --no-summary disables result summaries"
+ echo " --skip-ok do not print successful validations"
+ echo " --skip-comperr do not print compilation errors"
+ echo " --skip-valerr do not print validation errors"
+ echo " --quiet synonym for --skip-ok --skip-comperr --skip-valerr --no-summary"
+ echo " --terse print terse single line progress summary"
+ echo "Disassembly options:"
+ echo " --raw-id uses raw ids for disassembly"
+ echo
+ echo "Usage examples. Note most non-hlsl tests fail to compile for expected reasons."
+ echo " Exercise all hlsl.* files:"
+ echo " $(basename $0) hlsl.*"
+ echo " Exercise all hlsl.* files, tersely:"
+ echo " $(basename $0) --terse hlsl.*"
+ echo " Print validator output for myfile.frag:"
+ echo " $(basename $0) --quiet --dump-val myfile.frag"
+ echo " Exercise hlsl.* files, only printing validation errors:"
+ echo " $(basename $0) --skip-ok --skip-comperr hlsl.*"
+
+ exit 5
+}
+
+function status()
+{
+ printf "%-40s: %b\n" "$1" "$2"
+}
+
+# make sure we can find glslang
+[[ -x "$EXE" ]] || fatal "Unable to locate $(basename "$EXE") executable"
+[[ -x "$VAL" ]] || fatal "Unable to locate spirv-val executable"
+[[ -x "$DIS" ]] || fatal "Unable to locate spirv-dis executable"
+
+for gtest in $gtests; do
+ [[ -r "$gtest" ]] || fatal "Unable to locate source file: $(basename $gtest)"
+done
+
+# temp files
+declare -r spvfile='out.spv' \
+ complog='comp.out' \
+ vallog='val.out' \
+ dislog='dis.out' \
+
+# options
+declare opt_vallog=false \
+ opt_complog=false \
+ opt_dislog=false \
+ opt_summary=true \
+ opt_stat_comperr=true \
+ opt_stat_ok=true \
+ opt_stat_valerr=true \
+ opt_color=true \
+ opt_raw_id=false \
+ opt_quiet=false \
+ opt_terse=false
+
+# clean up on exit
+trap "rm -f ${spvfile} ${complog} ${vallog} ${dislog}" EXIT
+
+# Language guesser: there is no fixed mapping from filenames to language,
+# so this examines the file and return one of:
+# hlsl
+# glsl
+# bin
+# unknown
+# This is easier WRT future expansion than a big explicit list.
+function FindLanguage()
+{
+ local test="$1"
+
+ # If it starts with hlsl, assume it's hlsl.
+ if [[ "$test" == *hlsl.* ]]; then
+ echo hlsl
+ return
+ fi
+
+ if [[ "$test" == *.spv ]]; then
+ echo bin
+ return;
+ fi
+
+ # If it doesn't start with spv., assume it's GLSL.
+ if [[ ! "$test" == spv.* && ! "$test" == remap.* ]]; then
+ echo glsl
+ return
+ fi
+
+ # Otherwise, attempt to guess from shader contents, since there's no
+ # fixed mapping of filenames to languages.
+ local contents="$(cat "$test")"
+
+ if [[ "$contents" == *#version* ]]; then
+ echo glsl
+ return
+ fi
+
+ if [[ "$contents" == *SamplerState* ||
+ "$contents" == *cbuffer* ||
+ "$contents" == *SV_* ]]; then
+ echo hlsl
+ return
+ fi
+
+ echo unknown
+}
+
+# Attempt to discover entry point
+function FindEntryPoint()
+{
+ local test="$1"
+
+ # if it's not hlsl, always use main
+ if [[ "$language" != 'hlsl' ]]; then
+ echo 'main'
+ return
+ fi
+
+ # Try to find it in test sources
+ awk -F '[ (){",]+' -e "\$2 == \"${test}\" { print \$3; found=1; } END { if (found==0) print \"main\"; } " $gtests
+}
+
+# command line options
+while [ $# -gt 0 ]
+do
+ case "$1" in
+ # -c) glslang="$2"; shift 2;;
+ --help|-?) usage;;
+ --no-color) opt_color=false; shift;;
+ --no-summary) opt_summary=false; shift;;
+ --skip-ok) opt_stat_ok=false; shift;;
+ --skip-comperr) opt_stat_comperr=false; shift;;
+ --skip-valerr) opt_stat_valerr=false; shift;;
+ --dump-asm) opt_dislog=true; shift;;
+ --dump-val) opt_vallog=true; shift;;
+ --dump-comp) opt_complog=true; shift;;
+ --raw-id) opt_raw_id=true; shift;;
+ --quiet) opt_quiet=true; shift;;
+ --terse) opt_quiet=true
+ opt_terse=true
+ shift;;
+ --*) fatal "Unknown command line option: $1";;
+ *) break;;
+ esac
+done
+
+# this is what quiet means
+if $opt_quiet; then
+ opt_stat_ok=false
+ opt_stat_comperr=false
+ opt_stat_valerr=false
+ $opt_terse || opt_summary=false
+fi
+
+if $opt_color; then
+ declare -r white="\e[1;37m" cyan="\e[1;36m" red="\e[0;31m" no_color="\e[0m"
+else
+ declare -r white="" cyan="" red="" no_color=""
+fi
+
+# stats
+declare -i count_ok=0 count_err=0 count_nocomp=0 count_total=0
+
+declare -r dashsep='------------------------------------------------------------------------'
+
+testfiles=(${@})
+# if no shaders given, look for everything in current directory
+[[ ${#testfiles[*]} == 0 ]] && testfiles=(*.frag *.vert *.tesc *.tese *.geom *.comp)
+
+$opt_summary && printf "\nValidating: ${#testfiles[*]} shaders\n\n"
+
+# Loop through the shaders we were given, compiling them if we can.
+for test in ${testfiles[*]}
+do
+ if [[ ! -r "$test" ]]; then
+ $opt_quiet || status "$test" "${red}FILE NOT FOUND${no_color}"
+ continue
+ fi
+
+ ((++count_total))
+
+ $opt_terse && printf "\r[%-3d/%-3d : ${white}comperr=%-3d ${red}valerr=%-3d ${cyan}ok=%-3d${no_color}]" \
+ ${count_total} ${#testfiles[*]} ${count_nocomp} ${count_err} ${count_ok}
+
+ language="$(FindLanguage $test)"
+ entry="$(FindEntryPoint $test)"
+ langops=''
+
+ case "$language" in
+ hlsl) langops='-D --hlsl-iomap --hlsl-offsets';;
+ glsl) ;;
+ bin) continue;; # skip binaries
+ *) $opt_quiet || status "$test" "${red}UNKNOWN LANGUAGE${no_color}"; continue;;
+ esac
+
+ # compile the test file
+ if compout=$("$EXE" -e "$entry" $langops -V -o "$spvfile" "$test" 2>&1)
+ then
+ # successful compilation: validate
+ if valout=$("$VAL" --target-env ${targetenv} "$spvfile" 2>&1)
+ then
+ # validated OK
+ $opt_stat_ok && status "$test" "${cyan}OK${no_color}"
+ ((++count_ok))
+ else
+ # validation failure
+ $opt_stat_valerr && status "$test" "${red}VAL ERROR${no_color}"
+ printf "%s\n%s:\n%s\n" "$dashsep" "$test" "$valout" >> "$vallog"
+ ((++count_err))
+ fi
+
+ if $opt_dislog; then
+ printf "%s\n%s:\n" "$dashsep" "$test" >> "$dislog"
+ $opt_raw_id && id_opt=--raw-id
+ "$DIS" ${id_opt} "$spvfile" >> "$dislog"
+ fi
+ else
+ # compile failure
+ $opt_stat_comperr && status "$test" "${white}COMP ERROR${no_color}"
+ printf "%s\n%s\n" "$dashsep" "$compout" >> "$complog"
+ ((++count_nocomp))
+ fi
+done
+
+$opt_terse && echo
+
+# summarize
+$opt_summary && printf "\nSummary: ${white}${count_nocomp} compile errors${no_color}, ${red}${count_err} validation errors${no_color}, ${cyan}${count_ok} successes${no_color}\n"
+
+# dump logs
+$opt_vallog && [[ -r $vallog ]] && cat "$vallog"
+$opt_complog && [[ -r $complog ]] && cat "$complog"
+$opt_dislog && [[ -r $dislog ]] && cat "$dislog"
+
+# exit code
+[[ ${count_err} -gt 0 ]] && exit 1
+exit 0
diff --git a/Test/vulkan.frag b/Test/vulkan.frag
index 1447ec1..14c0c30 100644
--- a/Test/vulkan.frag
+++ b/Test/vulkan.frag
@@ -95,3 +95,11 @@
gl_NumSamples; // ERROR, not for Vulkan
}
+
+void noise()
+{
+ noise1(dv4);
+ noise2(4.0);
+ noise3(vec2(3));
+ noise4(dv4);
+}
diff --git a/Test/vulkan.vert b/Test/vulkan.vert
index a6dc8ad..e670e95 100644
--- a/Test/vulkan.vert
+++ b/Test/vulkan.vert
@@ -58,3 +58,6 @@
out ban2 {
float f;
} bai2[arraySize][2];
+
+layout(binding = 3000) uniform sampler2D s3000;
+layout(binding = 3001) uniform b3001 { int a; };
diff --git a/glslang/Include/arrays.h b/glslang/Include/arrays.h
index bc21c6c..1660a99 100644
--- a/glslang/Include/arrays.h
+++ b/glslang/Include/arrays.h
@@ -264,6 +264,15 @@
return false;
}
+ bool clearInnerImplicit()
+ {
+ for (int d = 1; d < sizes.size(); ++d) {
+ if (sizes.getDimSize(d) == (unsigned)UnsizedArraySize)
+ setDimSize(d, 1);
+ }
+
+ return false;
+ }
bool isInnerSpecialization() const
{
for (int d = 1; d < sizes.size(); ++d) {
diff --git a/glslang/MachineIndependent/Initialize.cpp b/glslang/MachineIndependent/Initialize.cpp
index 0143b4d..b8011b8 100644
--- a/glslang/MachineIndependent/Initialize.cpp
+++ b/glslang/MachineIndependent/Initialize.cpp
@@ -1388,7 +1388,7 @@
//
// Noise functions.
//
- if (profile != EEsProfile) {
+ if (spvVersion.spv == 0 && profile != EEsProfile) {
commonBuiltins.append(
"float noise1(float x);"
"float noise1(vec2 x);"
diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp
index 7bf036d..fe49ff0 100644
--- a/glslang/MachineIndependent/ParseHelper.cpp
+++ b/glslang/MachineIndependent/ParseHelper.cpp
@@ -3000,7 +3000,7 @@
}
}
-void TParseContext::arraySizesCheck(const TSourceLoc& loc, const TQualifier& qualifier, const TArraySizes* arraySizes, bool initializer, bool lastMember)
+void TParseContext::arraySizesCheck(const TSourceLoc& loc, const TQualifier& qualifier, TArraySizes* arraySizes, bool initializer, bool lastMember)
{
assert(arraySizes);
@@ -3013,8 +3013,10 @@
return;
// No environment allows any non-outer-dimension to be implicitly sized
- if (arraySizes->isInnerImplicit())
+ if (arraySizes->isInnerImplicit()) {
error(loc, "only outermost dimension of an array of arrays can be implicitly sized", "[]", "");
+ arraySizes->clearInnerImplicit();
+ }
if (arraySizes->isInnerSpecialization())
error(loc, "only outermost dimension of an array of arrays can be a specialization constant", "[]", "");
@@ -4610,7 +4612,7 @@
} else
lastBinding += type.getCumulativeArraySize();
}
- if (lastBinding >= resources.maxCombinedTextureImageUnits)
+ if (spvVersion.vulkan == 0 && lastBinding >= resources.maxCombinedTextureImageUnits)
error(loc, "sampler binding not less than gl_MaxCombinedTextureImageUnits", "binding", type.isArray() ? "(using array)" : "");
}
if (type.getBasicType() == EbtAtomicUint) {
diff --git a/glslang/MachineIndependent/ParseHelper.h b/glslang/MachineIndependent/ParseHelper.h
index 3908a66..c484cc0 100644
--- a/glslang/MachineIndependent/ParseHelper.h
+++ b/glslang/MachineIndependent/ParseHelper.h
@@ -338,7 +338,7 @@
bool arrayError(const TSourceLoc&, const TType&);
void arraySizeRequiredCheck(const TSourceLoc&, const TArraySizes&);
void structArrayCheck(const TSourceLoc&, const TType& structure);
- void arraySizesCheck(const TSourceLoc&, const TQualifier&, const TArraySizes*, bool initializer, bool lastMember);
+ void arraySizesCheck(const TSourceLoc&, const TQualifier&, TArraySizes*, bool initializer, bool lastMember);
void arrayOfArrayVersionCheck(const TSourceLoc&);
void arrayDimCheck(const TSourceLoc&, const TArraySizes* sizes1, const TArraySizes* sizes2);
void arrayDimCheck(const TSourceLoc&, const TType*, const TArraySizes*);
diff --git a/glslang/MachineIndependent/ShaderLang.cpp b/glslang/MachineIndependent/ShaderLang.cpp
index 05d2212..c8e954c 100644
--- a/glslang/MachineIndependent/ShaderLang.cpp
+++ b/glslang/MachineIndependent/ShaderLang.cpp
@@ -1572,12 +1572,12 @@
const char* GetEsslVersionString()
{
- return "OpenGL ES GLSL 3.00 glslang LunarG Khronos." GLSLANG_REVISION " " GLSLANG_DATE;
+ return "OpenGL ES GLSL 3.20 glslang Khronos." GLSLANG_REVISION " " GLSLANG_DATE;
}
const char* GetGlslVersionString()
{
- return "4.20 glslang LunarG Khronos." GLSLANG_REVISION " " GLSLANG_DATE;
+ return "4.60 glslang Khronos." GLSLANG_REVISION " " GLSLANG_DATE;
}
int GetKhronosToolId()
@@ -1667,8 +1667,8 @@
}
// Set binding base for given resource type for a given binding set.
-void TShader::setShiftBindingForSet(TResourceType res, unsigned int set, unsigned int base) {
- intermediate->setShiftBindingForSet(res, set, base);
+void TShader::setShiftBindingForSet(TResourceType res, unsigned int base, unsigned int set) {
+ intermediate->setShiftBindingForSet(res, base, set);
}
// Set binding base for sampler types
diff --git a/glslang/MachineIndependent/localintermediate.h b/glslang/MachineIndependent/localintermediate.h
index 60deb1c..1dc2953 100644
--- a/glslang/MachineIndependent/localintermediate.h
+++ b/glslang/MachineIndependent/localintermediate.h
@@ -272,7 +272,7 @@
unsigned int getShiftBinding(TResourceType res) const { return shiftBinding[res]; }
- void setShiftBindingForSet(TResourceType res, unsigned int set, unsigned int shift)
+ void setShiftBindingForSet(TResourceType res, unsigned int shift, unsigned int set)
{
if (shift == 0) // ignore if there's no shift: it's a no-op.
return;
@@ -282,8 +282,8 @@
const char* name = getResourceName(res);
if (name != nullptr) {
processes.addProcess(name);
- processes.addArgument(set);
processes.addArgument(shift);
+ processes.addArgument(set);
}
}
diff --git a/glslang/MachineIndependent/preprocessor/Pp.cpp b/glslang/MachineIndependent/preprocessor/Pp.cpp
index df7ec88..8048fa5 100644
--- a/glslang/MachineIndependent/preprocessor/Pp.cpp
+++ b/glslang/MachineIndependent/preprocessor/Pp.cpp
@@ -1153,7 +1153,6 @@
}
MacroSymbol* macro = macroAtom == 0 ? nullptr : lookupMacroDef(macroAtom);
- int token;
int depth = 0;
// no recursive expansions
@@ -1175,13 +1174,12 @@
TSourceLoc loc = ppToken->loc; // in case we go to the next line before discovering the error
in->mac = macro;
if (macro->args.size() > 0 || macro->emptyArgs) {
- token = scanToken(ppToken);
+ int token = scanToken(ppToken);
if (newLineOkay) {
while (token == '\n')
token = scanToken(ppToken);
}
if (token != '(') {
- parseContext.ppError(loc, "expected '(' following", "macro expansion", atomStrings.getString(macroAtom));
UngetToken(token, ppToken);
delete in;
return 0;
diff --git a/glslang/Public/ShaderLang.h b/glslang/Public/ShaderLang.h
index f0990ad..6fadfbf 100644
--- a/glslang/Public/ShaderLang.h
+++ b/glslang/Public/ShaderLang.h
@@ -368,7 +368,7 @@
void setShiftUavBinding(unsigned int base); // DEPRECATED: use setShiftBinding
void setShiftCbufferBinding(unsigned int base); // synonym for setShiftUboBinding
void setShiftSsboBinding(unsigned int base); // DEPRECATED: use setShiftBinding
- void setShiftBindingForSet(TResourceType res, unsigned int set, unsigned int base);
+ void setShiftBindingForSet(TResourceType res, unsigned int base, unsigned int set);
void setResourceSetBinding(const std::vector<std::string>& base);
void setAutoMapBindings(bool map);
void setAutoMapLocations(bool map);
diff --git a/gtests/AST.FromFile.cpp b/gtests/AST.FromFile.cpp
index 63ffd1d..9c96edb 100644
--- a/gtests/AST.FromFile.cpp
+++ b/gtests/AST.FromFile.cpp
@@ -84,6 +84,7 @@
"cppBad2.vert",
"cppComplexExpr.vert",
"cppDeepNest.frag",
+ "cppPassMacroName.frag",
"badChars.frag",
"pointCoord.frag",
"array.frag",
@@ -160,7 +161,7 @@
"460.vert",
"dce.frag",
"atomic_uint.frag",
-// "implicitInnerAtomicUint.frag",
+ "implicitInnerAtomicUint.frag",
"aggOps.frag",
"always-discard.frag",
"always-discard2.frag",