From 269a1bd4eb5ff8473b629a39089e97e6f8d89d1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Sat, 21 Apr 2018 07:53:47 -0700 Subject: [PATCH] Updated glslang. --- 3rdparty/glslang/SPIRV/GlslangToSpv.cpp | 5 ++ 3rdparty/glslang/StandAlone/StandAlone.cpp | 60 +++++++++++-------- 3rdparty/glslang/Test/310.tese | 2 +- 3rdparty/glslang/Test/320.tese | 2 +- 3rdparty/glslang/Test/400.tese | 2 +- .../glslang/Test/baseResults/150.tesc.out | 3 +- .../glslang/Test/baseResults/310.tese.out | 3 +- .../glslang/Test/baseResults/320.tese.out | 3 +- .../glslang/Test/baseResults/400.tese.out | 3 +- 3rdparty/glslang/Test/runtests | 8 ++- 3rdparty/glslang/glslang/Include/revision.h | 2 +- .../MachineIndependent/ParseHelper.cpp | 24 +++++--- 12 files changed, 72 insertions(+), 45 deletions(-) diff --git a/3rdparty/glslang/SPIRV/GlslangToSpv.cpp b/3rdparty/glslang/SPIRV/GlslangToSpv.cpp index ec8cd6aaa..bfa5bf796 100755 --- a/3rdparty/glslang/SPIRV/GlslangToSpv.cpp +++ b/3rdparty/glslang/SPIRV/GlslangToSpv.cpp @@ -6126,6 +6126,11 @@ spv::Id TGlslangToSpvTraverser::createMiscOperation(glslang::TOperator op, spv:: assert(builder.isPointerType(typeId1)); typeId1 = builder.getContainedTypeId(typeId1); int width = builder.getScalarTypeWidth(typeId1); +#ifdef AMD_EXTENSIONS + if (width == 16) + // Using 16-bit exp operand, enable extension SPV_AMD_gpu_shader_int16 + builder.addExtension(spv::E_SPV_AMD_gpu_shader_int16); +#endif if (builder.getNumComponents(operands[0]) == 1) frexpIntType = builder.makeIntegerType(width, true); else diff --git a/3rdparty/glslang/StandAlone/StandAlone.cpp b/3rdparty/glslang/StandAlone/StandAlone.cpp index 044662fe0..6736dbcbf 100644 --- a/3rdparty/glslang/StandAlone/StandAlone.cpp +++ b/3rdparty/glslang/StandAlone/StandAlone.cpp @@ -1196,38 +1196,48 @@ int C_DECL main(int argc, char* argv[]) // .frag = fragment // .comp = compute // -EShLanguage FindLanguage(const std::string& name, bool parseSuffix) +// Additionally, the file names may end in ..glsl and ..hlsl +// where is one of the stages listed above. +// +EShLanguage FindLanguage(const std::string& name, bool parseStageName) { - size_t ext = 0; - std::string suffix; - + std::string stageName; if (shaderStageName) - suffix = shaderStageName; - else { - // Search for a suffix on a filename: e.g, "myfile.frag". If given - // the suffix directly, we skip looking for the '.' - if (parseSuffix) { - ext = name.rfind('.'); - if (ext == std::string::npos) { - usage(); - return EShLangVertex; - } - ++ext; + stageName = shaderStageName; + else if (parseStageName) { + // Note: "first" extension means "first from the end", i.e. + // if the file is named foo.vert.glsl, then "glsl" is first, + // "vert" is second. + size_t firstExtStart = name.find_last_of("."); + bool hasFirstExt = firstExtStart != std::string::npos; + size_t secondExtStart = hasFirstExt ? name.find_last_of(".", firstExtStart - 1) : std::string::npos; + bool hasSecondExt = secondExtStart != std::string::npos; + std::string firstExt = name.substr(firstExtStart + 1, std::string::npos); + bool usesUnifiedExt = hasFirstExt && (firstExt == "glsl" || firstExt == "hlsl"); + if (usesUnifiedExt && firstExt == "hlsl") + Options |= EOptionReadHlsl; + if (hasFirstExt && !usesUnifiedExt) + stageName = firstExt; + else if (usesUnifiedExt && hasSecondExt) + stageName = name.substr(secondExtStart + 1, firstExtStart - secondExtStart - 1); + else { + usage(); + return EShLangVertex; } - suffix = name.substr(ext, std::string::npos); - } + } else + stageName = name; - if (suffix == "vert") + if (stageName == "vert") return EShLangVertex; - else if (suffix == "tesc") + else if (stageName == "tesc") return EShLangTessControl; - else if (suffix == "tese") + else if (stageName == "tese") return EShLangTessEvaluation; - else if (suffix == "geom") + else if (stageName == "geom") return EShLangGeometry; - else if (suffix == "frag") + else if (stageName == "frag") return EShLangFragment; - else if (suffix == "comp") + else if (stageName == "comp") return EShLangCompute; usage(); @@ -1298,10 +1308,12 @@ void usage() " .geom for a geometry shader\n" " .frag for a fragment shader\n" " .comp for a compute shader\n" + " .glsl for .vert.glsl, .tesc.glsl, ..., .comp.glsl compound suffixes\n" + " .hlsl for .vert.hlsl, .tesc.hlsl, ..., .comp.hlsl compound suffixes\n" "\n" "Options:\n" " -C cascading errors; risk crash from accumulation of error recoveries\n" - " -D input is HLSL\n" + " -D input is HLSL (default when any suffix is .hlsl)\n" " -D\n" " -D define a pre-processor macro\n" " -E print pre-processed GLSL; cannot be used with -l;\n" diff --git a/3rdparty/glslang/Test/310.tese b/3rdparty/glslang/Test/310.tese index 63b1daa69..bbeaa87fc 100644 --- a/3rdparty/glslang/Test/310.tese +++ b/3rdparty/glslang/Test/310.tese @@ -55,7 +55,7 @@ patch sample in vec3 badp4; // ERROR #extension GL_ARB_separate_shader_objects : enable -in gl_PerVertex // ERROR, no size +in gl_PerVertex { vec4 gl_Position; } gl_in[]; diff --git a/3rdparty/glslang/Test/320.tese b/3rdparty/glslang/Test/320.tese index b1507d9f9..cce2637cb 100644 --- a/3rdparty/glslang/Test/320.tese +++ b/3rdparty/glslang/Test/320.tese @@ -51,7 +51,7 @@ patch sample in vec3 badp4; // ERROR #extension GL_ARB_separate_shader_objects : enable -in gl_PerVertex // ERROR, no size +in gl_PerVertex { vec4 gl_Position; } gl_in[]; diff --git a/3rdparty/glslang/Test/400.tese b/3rdparty/glslang/Test/400.tese index aea454651..c110a1c4d 100644 --- a/3rdparty/glslang/Test/400.tese +++ b/3rdparty/glslang/Test/400.tese @@ -51,7 +51,7 @@ patch sample in vec3 badp4; // ERROR #extension GL_ARB_separate_shader_objects : enable -in gl_PerVertex // ERROR, no size +in gl_PerVertex { float gl_ClipDistance[1]; } gl_in[]; diff --git a/3rdparty/glslang/Test/baseResults/150.tesc.out b/3rdparty/glslang/Test/baseResults/150.tesc.out index d237ee4de..89220264f 100644 --- a/3rdparty/glslang/Test/baseResults/150.tesc.out +++ b/3rdparty/glslang/Test/baseResults/150.tesc.out @@ -453,7 +453,6 @@ ERROR: 0:47: 'patch' : cannot use interpolation qualifiers with patch ERROR: 0:48: 'patch' : cannot use interpolation qualifiers with patch ERROR: 0:49: 'patch' : cannot use interpolation qualifiers with patch ERROR: 0:50: '' : can only have one auxiliary qualifier (centroid, patch, and sample) -ERROR: 0:54: 'gl_PerVertex' : block already declared with size, can't redeclare as unsized ERROR: 0:59: 'gl_PerVertex' : can only redeclare a built-in block once, and before any use ERROR: 0:64: 'quads' : cannot apply to 'out' ERROR: 0:64: 'cw' : can only apply to 'in' @@ -473,7 +472,7 @@ ERROR: 0:99: 'location' : overlapping use of location 24 ERROR: 0:101: 'gl_TessLevelOuter' : identifiers starting with "gl_" are reserved ERROR: 0:109: 'gl_DeviceIndex' : required extension not requested: GL_EXT_device_group ERROR: 0:110: 'gl_ViewIndex' : required extension not requested: GL_EXT_multiview -ERROR: 32 compilation errors. No code generated. +ERROR: 31 compilation errors. No code generated. Shader version: 400 diff --git a/3rdparty/glslang/Test/baseResults/310.tese.out b/3rdparty/glslang/Test/baseResults/310.tese.out index 7d91e937d..9c7c679da 100644 --- a/3rdparty/glslang/Test/baseResults/310.tese.out +++ b/3rdparty/glslang/Test/baseResults/310.tese.out @@ -25,7 +25,6 @@ ERROR: 0:53: 'noperspective' : not supported for this version or the enabled ext ERROR: 0:53: 'patch' : cannot use interpolation qualifiers with patch ERROR: 0:54: 'sample' : Reserved word. ERROR: 0:54: '' : can only have one auxiliary qualifier (centroid, patch, and sample) -ERROR: 0:58: 'gl_PerVertex' : block already declared with size, can't redeclare as unsized ERROR: 0:63: 'gl_PerVertex' : can only redeclare a built-in block once, and before any use ERROR: 0:68: 'quads' : cannot apply to 'out' ERROR: 0:68: 'cw' : can only apply to 'in' @@ -47,7 +46,7 @@ ERROR: 0:113: 'sample' : Reserved word. ERROR: 0:119: 'gl_PointSize' : no such field in structure ERROR: 0:119: '=' : cannot convert from ' temp block{ in highp 4-component vector of float Position gl_Position}' to ' temp highp float' ERROR: 0:127: 'gl_BoundingBoxOES' : undeclared identifier -ERROR: 44 compilation errors. No code generated. +ERROR: 43 compilation errors. No code generated. Shader version: 310 diff --git a/3rdparty/glslang/Test/baseResults/320.tese.out b/3rdparty/glslang/Test/baseResults/320.tese.out index 456bd88bc..93165ae10 100755 --- a/3rdparty/glslang/Test/baseResults/320.tese.out +++ b/3rdparty/glslang/Test/baseResults/320.tese.out @@ -24,7 +24,6 @@ ERROR: 0:49: 'noperspective' : Reserved word. ERROR: 0:49: 'noperspective' : not supported for this version or the enabled extensions ERROR: 0:49: 'patch' : cannot use interpolation qualifiers with patch ERROR: 0:50: '' : can only have one auxiliary qualifier (centroid, patch, and sample) -ERROR: 0:54: 'gl_PerVertex' : block already declared with size, can't redeclare as unsized ERROR: 0:59: 'gl_PerVertex' : can only redeclare a built-in block once, and before any use ERROR: 0:64: 'quads' : cannot apply to 'out' ERROR: 0:64: 'cw' : can only apply to 'in' @@ -43,7 +42,7 @@ ERROR: 0:96: 'location' : overlapping use of location 24 ERROR: 0:99: 'location' : overlapping use of location 24 ERROR: 0:101: 'gl_TessLevelOuter' : identifiers starting with "gl_" are reserved ERROR: 0:113: 'gl_BoundingBoxOES' : undeclared identifier -ERROR: 40 compilation errors. No code generated. +ERROR: 39 compilation errors. No code generated. Shader version: 320 diff --git a/3rdparty/glslang/Test/baseResults/400.tese.out b/3rdparty/glslang/Test/baseResults/400.tese.out index 28c4468d9..9580e857c 100644 --- a/3rdparty/glslang/Test/baseResults/400.tese.out +++ b/3rdparty/glslang/Test/baseResults/400.tese.out @@ -11,7 +11,6 @@ ERROR: 0:47: 'patch' : cannot use interpolation qualifiers with patch ERROR: 0:48: 'patch' : cannot use interpolation qualifiers with patch ERROR: 0:49: 'patch' : cannot use interpolation qualifiers with patch ERROR: 0:50: '' : can only have one auxiliary qualifier (centroid, patch, and sample) -ERROR: 0:54: 'gl_PerVertex' : block already declared with size, can't redeclare as unsized ERROR: 0:59: 'gl_PerVertex' : can only redeclare a built-in block once, and before any use ERROR: 0:64: 'quads' : cannot apply to 'out' ERROR: 0:64: 'cw' : can only apply to 'in' @@ -31,7 +30,7 @@ ERROR: 0:99: 'location' : overlapping use of location 24 ERROR: 0:101: 'gl_TessLevelOuter' : identifiers starting with "gl_" are reserved ERROR: 0:109: 'gl_DeviceIndex' : required extension not requested: GL_EXT_device_group ERROR: 0:110: 'gl_ViewIndex' : required extension not requested: GL_EXT_multiview -ERROR: 32 compilation errors. No code generated. +ERROR: 31 compilation errors. No code generated. Shader version: 400 diff --git a/3rdparty/glslang/Test/runtests b/3rdparty/glslang/Test/runtests index 6ebb6ee6b..51e15c0ff 100755 --- a/3rdparty/glslang/Test/runtests +++ b/3rdparty/glslang/Test/runtests @@ -74,11 +74,15 @@ else fi # -# Testing -S +# Testing -S and compound suffixes # -echo Running explicit stage test +echo Running explicit stage test and compound suffix tests $EXE -i -S vert nosuffix > $TARGETDIR/nosuffix.out diff -b $BASEDIR/nosuffix.out $TARGETDIR/nosuffix.out || HASERROR=1 +$EXE -i compoundsuffix.vert.glsl > $TARGETDIR/compoundsuffix.vert.glsl +diff -b $BASEDIR/compoundsuffix.vert.glsl $TARGETDIR/compoundsuffix.vert.glsl || HASERROR=1 +$EXE -e main -H compoundsuffix.frag.hlsl > $TARGETDIR/compoundsuffix.frag.hlsl +diff -b $BASEDIR/compoundsuffix.frag.hlsl $TARGETDIR/compoundsuffix.frag.hlsl || HASERROR=1 # # Testing --hlsl-offsets diff --git a/3rdparty/glslang/glslang/Include/revision.h b/3rdparty/glslang/glslang/Include/revision.h index ea5e30cb8..2626c5df7 100644 --- a/3rdparty/glslang/glslang/Include/revision.h +++ b/3rdparty/glslang/glslang/Include/revision.h @@ -1,3 +1,3 @@ // This header is generated by the make-revision script. -#define GLSLANG_PATCH_LEVEL 2691 +#define GLSLANG_PATCH_LEVEL 2712 diff --git a/3rdparty/glslang/glslang/MachineIndependent/ParseHelper.cpp b/3rdparty/glslang/glslang/MachineIndependent/ParseHelper.cpp index 45c050d45..bb088e5d4 100644 --- a/3rdparty/glslang/glslang/MachineIndependent/ParseHelper.cpp +++ b/3rdparty/glslang/glslang/MachineIndependent/ParseHelper.cpp @@ -3508,7 +3508,8 @@ TSymbol* TParseContext::redeclareBuiltinVariable(const TSourceLoc& loc, const TS // Either redeclare the requested block, or give an error message why it can't be done. // // TODO: functionality: explicitly sizing members of redeclared blocks is not giving them an explicit size -void TParseContext::redeclareBuiltinBlock(const TSourceLoc& loc, TTypeList& newTypeList, const TString& blockName, const TString* instanceName, TArraySizes* arraySizes) +void TParseContext::redeclareBuiltinBlock(const TSourceLoc& loc, TTypeList& newTypeList, const TString& blockName, + const TString* instanceName, TArraySizes* arraySizes) { const char* feature = "built-in block redeclaration"; profileRequires(loc, EEsProfile, 320, Num_AEP_shader_io_blocks, AEP_shader_io_blocks, feature); @@ -3662,15 +3663,24 @@ void TParseContext::redeclareBuiltinBlock(const TSourceLoc& loc, TTypeList& newT if (numOriginalMembersFound < newTypeList.size()) error(loc, "block redeclaration has extra members", blockName.c_str(), ""); - if (type.isArray() != (arraySizes != nullptr)) + if (type.isArray() != (arraySizes != nullptr) || + (type.isArray() && arraySizes != nullptr && type.getArraySizes()->getNumDims() != arraySizes->getNumDims())) error(loc, "cannot change arrayness of redeclared block", blockName.c_str(), ""); else if (type.isArray()) { - if (type.isSizedArray() && !arraySizes->isSized()) - error(loc, "block already declared with size, can't redeclare as unsized", blockName.c_str(), ""); - else if (type.isSizedArray() && *type.getArraySizes() != *arraySizes) - error(loc, "cannot change array size of redeclared block", blockName.c_str(), ""); - else if (!type.isSizedArray() && arraySizes->isSized()) + // At this point, we know both are arrays and both have the same number of dimensions. + + // It is okay for a built-in block redeclaration to be unsized, and keep the size of the + // original block declaration. + if (!arraySizes->isSized() && type.isSizedArray()) + arraySizes->changeOuterSize(type.getOuterArraySize()); + + // And, okay to be giving a size to the array, by the redeclaration + if (!type.isSizedArray() && arraySizes->isSized()) type.changeOuterArraySize(arraySizes->getOuterSize()); + + // Now, they must match in all dimensions. + if (type.isSizedArray() && *type.getArraySizes() != *arraySizes) + error(loc, "cannot change array size of redeclared block", blockName.c_str(), ""); } symbolTable.insert(*block);