diff --git a/3rdparty/glslang/SPIRV/GlslangToSpv.cpp b/3rdparty/glslang/SPIRV/GlslangToSpv.cpp old mode 100644 new mode 100755 index 587460e7a..10ad425ca --- a/3rdparty/glslang/SPIRV/GlslangToSpv.cpp +++ b/3rdparty/glslang/SPIRV/GlslangToSpv.cpp @@ -2729,10 +2729,6 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty spvType = builder.makeFloatType(64); break; case glslang::EbtFloat16: -#if AMD_EXTENSIONS - if (builder.getSpvVersion() < glslang::EShTargetSpv_1_3) - builder.addExtension(spv::E_SPV_AMD_gpu_shader_half_float); -#endif spvType = builder.makeFloatType(16); break; case glslang::EbtBool: @@ -2750,17 +2746,9 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty spvType = builder.makeUintType(8); break; case glslang::EbtInt16: -#ifdef AMD_EXTENSIONS - if (builder.getSpvVersion() < glslang::EShTargetSpv_1_3) - builder.addExtension(spv::E_SPV_AMD_gpu_shader_int16); -#endif spvType = builder.makeIntType(16); break; case glslang::EbtUint16: -#ifdef AMD_EXTENSIONS - if (builder.getSpvVersion() < glslang::EShTargetSpv_1_3) - builder.addExtension(spv::E_SPV_AMD_gpu_shader_int16); -#endif spvType = builder.makeUintType(16); break; case glslang::EbtInt: diff --git a/3rdparty/glslang/SPIRV/SpvPostProcess.cpp b/3rdparty/glslang/SPIRV/SpvPostProcess.cpp old mode 100644 new mode 100755 index d9abd91e6..27f145d03 --- a/3rdparty/glslang/SPIRV/SpvPostProcess.cpp +++ b/3rdparty/glslang/SPIRV/SpvPostProcess.cpp @@ -120,6 +120,25 @@ void Builder::postProcessType(const Instruction& inst, Id typeId) case OpSConvert: case OpUConvert: break; + case OpExtInst: + switch (inst.getImmediateOperand(1)) { +#if AMD_EXTENSIONS + case GLSLstd450Frexp: + case GLSLstd450FrexpStruct: + if (getSpvVersion() < glslang::EShTargetSpv_1_3 && containsType(typeId, OpTypeInt, 16)) + addExtension(spv::E_SPV_AMD_gpu_shader_int16); + break; + case GLSLstd450InterpolateAtCentroid: + case GLSLstd450InterpolateAtSample: + case GLSLstd450InterpolateAtOffset: + if (getSpvVersion() < glslang::EShTargetSpv_1_3 && containsType(typeId, OpTypeFloat, 16)) + addExtension(spv::E_SPV_AMD_gpu_shader_half_float); + break; +#endif + default: + break; + } + break; default: if (basicTypeOp == OpTypeFloat && width == 16) addCapability(CapabilityFloat16); diff --git a/3rdparty/glslang/SPIRV/bitutils.h b/3rdparty/glslang/SPIRV/bitutils.h index 31288ab69..22e44cec2 100644 --- a/3rdparty/glslang/SPIRV/bitutils.h +++ b/3rdparty/glslang/SPIRV/bitutils.h @@ -26,7 +26,7 @@ Dest BitwiseCast(Src source) { Dest dest; static_assert(sizeof(source) == sizeof(dest), "BitwiseCast: Source and destination must have the same size"); - std::memcpy(&dest, &source, sizeof(dest)); + std::memcpy(static_cast(&dest), &source, sizeof(dest)); return dest; } diff --git a/3rdparty/glslang/Test/baseResults/hlsl.pp.expand.frag.out b/3rdparty/glslang/Test/baseResults/hlsl.pp.expand.frag.out index 71978916d..adfe02c12 100644 --- a/3rdparty/glslang/Test/baseResults/hlsl.pp.expand.frag.out +++ b/3rdparty/glslang/Test/baseResults/hlsl.pp.expand.frag.out @@ -14,5 +14,6 @@ struct A void main() { + "a string" } diff --git a/3rdparty/glslang/Test/baseResults/spv.16bitstorage-int.frag.out b/3rdparty/glslang/Test/baseResults/spv.16bitstorage-int.frag.out index dd7d1b1c9..1b2a16ba1 100644 --- a/3rdparty/glslang/Test/baseResults/spv.16bitstorage-int.frag.out +++ b/3rdparty/glslang/Test/baseResults/spv.16bitstorage-int.frag.out @@ -6,7 +6,6 @@ spv.16bitstorage-int.frag Capability Shader Capability StorageUniformBufferBlock16 Capability StorageUniform16 - Extension "SPV_AMD_gpu_shader_int16" Extension "SPV_KHR_16bit_storage" 1: ExtInstImport "GLSL.std.450" MemoryModel Logical GLSL450 diff --git a/3rdparty/glslang/Test/baseResults/spv.16bitstorage-uint.frag.out b/3rdparty/glslang/Test/baseResults/spv.16bitstorage-uint.frag.out index 3a13826f8..f935f2662 100644 --- a/3rdparty/glslang/Test/baseResults/spv.16bitstorage-uint.frag.out +++ b/3rdparty/glslang/Test/baseResults/spv.16bitstorage-uint.frag.out @@ -6,7 +6,6 @@ spv.16bitstorage-uint.frag Capability Shader Capability StorageUniformBufferBlock16 Capability StorageUniform16 - Extension "SPV_AMD_gpu_shader_int16" Extension "SPV_KHR_16bit_storage" 1: ExtInstImport "GLSL.std.450" MemoryModel Logical GLSL450 diff --git a/3rdparty/glslang/Test/baseResults/spv.16bitstorage.frag.out b/3rdparty/glslang/Test/baseResults/spv.16bitstorage.frag.out index cf536e8be..d2a83ba97 100644 --- a/3rdparty/glslang/Test/baseResults/spv.16bitstorage.frag.out +++ b/3rdparty/glslang/Test/baseResults/spv.16bitstorage.frag.out @@ -6,7 +6,6 @@ spv.16bitstorage.frag Capability Shader Capability StorageUniformBufferBlock16 Capability StorageUniform16 - Extension "SPV_AMD_gpu_shader_half_float" Extension "SPV_KHR_16bit_storage" 1: ExtInstImport "GLSL.std.450" MemoryModel Logical GLSL450 diff --git a/3rdparty/glslang/Test/baseResults/spv.float16Fetch.frag.out b/3rdparty/glslang/Test/baseResults/spv.float16Fetch.frag.out index 857ca6fac..7632737ac 100644 --- a/3rdparty/glslang/Test/baseResults/spv.float16Fetch.frag.out +++ b/3rdparty/glslang/Test/baseResults/spv.float16Fetch.frag.out @@ -27,7 +27,6 @@ error: Capability Float16 is not allowed by Vulkan 1.0 specification (or require Capability StorageInputOutput16 Capability Float16ImageAMD Capability ImageGatherBiasLodAMD - Extension "SPV_AMD_gpu_shader_half_float" Extension "SPV_AMD_gpu_shader_half_float_fetch" Extension "SPV_AMD_texture_gather_bias_lod" Extension "SPV_KHR_16bit_storage" diff --git a/3rdparty/glslang/Test/baseResults/spv.int16.amd.frag.out b/3rdparty/glslang/Test/baseResults/spv.int16.amd.frag.out index ab0861479..526373bcb 100644 --- a/3rdparty/glslang/Test/baseResults/spv.int16.amd.frag.out +++ b/3rdparty/glslang/Test/baseResults/spv.int16.amd.frag.out @@ -14,7 +14,6 @@ error: Capability Float16 is not allowed by Vulkan 1.0 specification (or require Capability Int16 Capability StorageUniform16 Capability StorageInputOutput16 - Extension "SPV_AMD_gpu_shader_half_float" Extension "SPV_AMD_gpu_shader_int16" Extension "SPV_KHR_16bit_storage" 1: ExtInstImport "GLSL.std.450" diff --git a/3rdparty/glslang/Test/baseResults/spv.int16.frag.out b/3rdparty/glslang/Test/baseResults/spv.int16.frag.out index 11818b75e..3ba5c0715 100644 --- a/3rdparty/glslang/Test/baseResults/spv.int16.frag.out +++ b/3rdparty/glslang/Test/baseResults/spv.int16.frag.out @@ -14,8 +14,6 @@ error: Capability Float16 is not allowed by Vulkan 1.0 specification (or require Capability Int16 Capability Int8 Capability StorageUniform16 - Extension "SPV_AMD_gpu_shader_half_float" - Extension "SPV_AMD_gpu_shader_int16" Extension "SPV_KHR_16bit_storage" 1: ExtInstImport "GLSL.std.450" MemoryModel Logical GLSL450 diff --git a/3rdparty/glslang/Test/baseResults/spv.shaderBallotAMD.comp.out b/3rdparty/glslang/Test/baseResults/spv.shaderBallotAMD.comp.out index a28791e66..5219a3a42 100644 --- a/3rdparty/glslang/Test/baseResults/spv.shaderBallotAMD.comp.out +++ b/3rdparty/glslang/Test/baseResults/spv.shaderBallotAMD.comp.out @@ -14,8 +14,6 @@ error: Capability Float16 is not allowed by Vulkan 1.0 specification (or require Capability Groups Capability Int16 Capability StorageUniformBufferBlock16 - Extension "SPV_AMD_gpu_shader_half_float" - Extension "SPV_AMD_gpu_shader_int16" Extension "SPV_AMD_shader_ballot" Extension "SPV_KHR_16bit_storage" 1: ExtInstImport "GLSL.std.450" diff --git a/3rdparty/glslang/Test/hlsl.pp.expand.frag b/3rdparty/glslang/Test/hlsl.pp.expand.frag old mode 100644 new mode 100755 index 765d17e44..d5318a027 --- a/3rdparty/glslang/Test/hlsl.pp.expand.frag +++ b/3rdparty/glslang/Test/hlsl.pp.expand.frag @@ -14,4 +14,5 @@ struct A void main() { + "a string" } diff --git a/3rdparty/glslang/glslang/Include/revision.h b/3rdparty/glslang/glslang/Include/revision.h index a7f2856b2..f57fb1ce5 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 2880 +#define GLSLANG_PATCH_LEVEL 2888 diff --git a/3rdparty/glslang/glslang/MachineIndependent/Initialize.cpp b/3rdparty/glslang/glslang/MachineIndependent/Initialize.cpp index b8005095f..eb690bc54 100644 --- a/3rdparty/glslang/glslang/MachineIndependent/Initialize.cpp +++ b/3rdparty/glslang/glslang/MachineIndependent/Initialize.cpp @@ -982,7 +982,6 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV "\n"); } -#ifdef NV_EXTENSIONS if (profile != EEsProfile && version >= 440) { commonBuiltins.append( "uint64_t atomicMin(coherent volatile inout uint64_t, uint64_t);" @@ -1032,7 +1031,6 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV "void atomicStore(coherent volatile out int64_t, int64_t, int, int, int);" "\n"); } -#endif if ((profile == EEsProfile && version >= 310) || (profile != EEsProfile && version >= 450)) { diff --git a/3rdparty/glslang/glslang/MachineIndependent/ParseHelper.cpp b/3rdparty/glslang/glslang/MachineIndependent/ParseHelper.cpp index 1d7413d35..ee7488bf5 100644 --- a/3rdparty/glslang/glslang/MachineIndependent/ParseHelper.cpp +++ b/3rdparty/glslang/glslang/MachineIndependent/ParseHelper.cpp @@ -1858,11 +1858,15 @@ void TParseContext::builtInOpCheck(const TSourceLoc& loc, const TFunction& fnCan if (argp->size() > 3) { requireExtensions(loc, 1, &E_GL_KHR_memory_scope_semantics, fnCandidate.getName().c_str()); memorySemanticsCheck(loc, fnCandidate, callNode); - } + } else if (arg0->getType().getBasicType() == EbtInt64 || arg0->getType().getBasicType() == EbtUint64) { #ifdef NV_EXTENSIONS - else if (arg0->getType().getBasicType() == EbtInt64 || arg0->getType().getBasicType() == EbtUint64) - requireExtensions(loc, 1, &E_GL_NV_shader_atomic_int64, fnCandidate.getName().c_str()); + const char* const extensions[2] = { E_GL_NV_shader_atomic_int64, + E_GL_EXT_shader_atomic_int64 }; + requireExtensions(loc, 2, extensions, fnCandidate.getName().c_str()); +#else + requireExtensions(loc, 1, &E_GL_EXT_shader_atomic_int64, fnCandidate.getName().c_str()); #endif + } break; } diff --git a/3rdparty/glslang/glslang/MachineIndependent/ShaderLang.cpp b/3rdparty/glslang/glslang/MachineIndependent/ShaderLang.cpp old mode 100644 new mode 100755 index dd3e159a2..c99f95811 --- a/3rdparty/glslang/glslang/MachineIndependent/ShaderLang.cpp +++ b/3rdparty/glslang/glslang/MachineIndependent/ShaderLang.cpp @@ -67,6 +67,11 @@ #include "iomapper.h" #include "Initialize.h" +// TODO: this really shouldn't be here, it is only because of the trial addition +// of printing pre-processed tokens, which requires knowing the string literal +// token to print ", but none of that seems appropriate for this file. +#include "preprocessor/PpTokens.h" + namespace { // anonymous namespace for file-local functions and symbols // Total number of successful initializers of glslang: a refcount @@ -965,6 +970,8 @@ private: // DoPreprocessing is a valid ProcessingContext template argument, // which only performs the preprocessing step of compilation. // It places the result in the "string" argument to its constructor. +// +// This is not an officially supported or fully working path. struct DoPreprocessing { explicit DoPreprocessing(std::string* string): outputString(string) {} bool operator()(TParseContextBase& parseContext, TPpContext& ppContext, @@ -1072,7 +1079,11 @@ struct DoPreprocessing { outputBuffer += ' '; } lastToken = token; + if (token == PpAtomConstString) + outputBuffer += "\""; outputBuffer += ppToken.name; + if (token == PpAtomConstString) + outputBuffer += "\""; } while (true); outputBuffer += '\n'; *outputString = std::move(outputBuffer); @@ -1122,6 +1133,9 @@ struct DoFullParse{ // Return: True if there were no issues found in preprocessing, // False if during preprocessing any unknown version, pragmas or // extensions were found. +// +// NOTE: Doing just preprocessing to obtain a correct preprocessed shader string +// is not an officially supported or fully working path. bool PreprocessDeferred( TCompiler* compiler, const char* const shaderStrings[], @@ -1726,6 +1740,9 @@ bool TShader::parse(const TBuiltInResource* builtInResources, int defaultVersion // Fill in a string with the result of preprocessing ShaderStrings // Returns true if all extensions, pragmas and version strings were valid. +// +// NOTE: Doing just preprocessing to obtain a correct preprocessed shader string +// is not an officially supported or fully working path. bool TShader::preprocess(const TBuiltInResource* builtInResources, int defaultVersion, EProfile defaultProfile, bool forceDefaultVersionAndProfile, diff --git a/3rdparty/glslang/glslang/MachineIndependent/Versions.cpp b/3rdparty/glslang/glslang/MachineIndependent/Versions.cpp index bd7b7de6e..e757c2911 100644 --- a/3rdparty/glslang/glslang/MachineIndependent/Versions.cpp +++ b/3rdparty/glslang/glslang/MachineIndependent/Versions.cpp @@ -196,6 +196,8 @@ void TParseVersions::initializeExtensionBehavior() extensionBehavior[E_GL_KHR_shader_subgroup_quad] = EBhDisable; extensionBehavior[E_GL_KHR_memory_scope_semantics] = EBhDisable; + extensionBehavior[E_GL_EXT_shader_atomic_int64] = EBhDisable; + extensionBehavior[E_GL_EXT_shader_non_constant_global_initializers] = EBhDisable; extensionBehavior[E_GL_EXT_shader_image_load_formatted] = EBhDisable; extensionBehavior[E_GL_EXT_post_depth_coverage] = EBhDisable; @@ -381,6 +383,8 @@ void TParseVersions::getPreamble(std::string& preamble) "#define GL_KHR_shader_subgroup_clustered 1\n" "#define GL_KHR_shader_subgroup_quad 1\n" + "#define E_GL_EXT_shader_atomic_int64 1\n" + #ifdef AMD_EXTENSIONS "#define GL_AMD_shader_ballot 1\n" "#define GL_AMD_shader_trinary_minmax 1\n" diff --git a/3rdparty/glslang/glslang/MachineIndependent/Versions.h b/3rdparty/glslang/glslang/MachineIndependent/Versions.h index f544324e1..7628163ae 100644 --- a/3rdparty/glslang/glslang/MachineIndependent/Versions.h +++ b/3rdparty/glslang/glslang/MachineIndependent/Versions.h @@ -150,6 +150,8 @@ const char* const E_GL_KHR_shader_subgroup_clustered = "GL_KHR_shader_sub const char* const E_GL_KHR_shader_subgroup_quad = "GL_KHR_shader_subgroup_quad"; const char* const E_GL_KHR_memory_scope_semantics = "GL_KHR_memory_scope_semantics"; +const char* const E_GL_EXT_shader_atomic_int64 = "GL_EXT_shader_atomic_int64"; + const char* const E_GL_EXT_shader_non_constant_global_initializers = "GL_EXT_shader_non_constant_global_initializers"; const char* const E_GL_EXT_shader_image_load_formatted = "GL_EXT_shader_image_load_formatted"; diff --git a/3rdparty/glslang/glslang/Public/ShaderLang.h b/3rdparty/glslang/glslang/Public/ShaderLang.h old mode 100644 new mode 100755 index 3c833f836..7fc2ca346 --- a/3rdparty/glslang/glslang/Public/ShaderLang.h +++ b/3rdparty/glslang/glslang/Public/ShaderLang.h @@ -532,6 +532,8 @@ public: return parse(builtInResources, defaultVersion, ENoProfile, false, forwardCompatible, messages, includer); } + // NOTE: Doing just preprocessing to obtain a correct preprocessed shader string + // is not an officially supported or fully working path. bool preprocess(const TBuiltInResource* builtInResources, int defaultVersion, EProfile defaultProfile, bool forceDefaultVersionAndProfile, bool forwardCompatible, EShMessages message, std::string* outputString,