From 6684d32db1f5693bcfb4971558cb30e855cd3bad Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Thu, 5 Mar 2020 10:59:54 -0500 Subject: Feature/glslang spirv version (#1256) * WIP add support for __spirv_version . * Added IRRequireSPIRVVersionDecoration * SPIR-V version passed to glslang. Enable VK wave tests. Split ExtensionTracker out, so can be cast and used externally to emit. Added SourceResult. * Fix warning on Clang. * Missing hlsl.meta.h * Refactor communication/parsing of __spirv_version with glslang. * Fix some debug typos. Be more precise in handling of substring handling. * Make glslang forwards and backwards binary compatible. * Small comment improvements. * Added slang-spirv-target-info.h/cpp * Fix for major/minor on gcc. * Another fix for gcc/clang. * VS projects include slang-spirv-target-info.h/cpp * Removed SPIRVTargetInfo Added SemanticVersion. Don't bother with passing a target to glslang. Should be separate from 'version'. * Renamed slang-emit-glsl-extension-tracker.cpp/.h -> slang-glsl-extension-tracker.cpp/.h Fixed some VS project issues. * Fix a comment. * Added slang-semantic-version.cpp/.h * Added slang-glsl-extension-tracker.cpp/.h * Added split that can check for input has all been parsed. * Fix problem on x86 win build. --- source/slang/slang-glsl-extension-tracker.cpp | 64 +++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 source/slang/slang-glsl-extension-tracker.cpp (limited to 'source/slang/slang-glsl-extension-tracker.cpp') diff --git a/source/slang/slang-glsl-extension-tracker.cpp b/source/slang/slang-glsl-extension-tracker.cpp new file mode 100644 index 000000000..30acd8936 --- /dev/null +++ b/source/slang/slang-glsl-extension-tracker.cpp @@ -0,0 +1,64 @@ +// slang-glsl-extension-tracker.cpp +#include "slang-glsl-extension-tracker.h" + +namespace Slang { + +void GLSLExtensionTracker::appendExtensionRequireLines(StringBuilder& ioBuilder) const +{ + for (const auto& extension : m_extensionPool.getSlices()) + { + ioBuilder.append("#extension "); + ioBuilder.append(extension); + ioBuilder.append(" : require\n"); + } +} + +void GLSLExtensionTracker::requireSPIRVVersion(const SemanticVersion& version) +{ + if (version > m_spirvVersion) + { + m_spirvVersion = version; + } +} + +void GLSLExtensionTracker::requireVersion(ProfileVersion version) +{ + // Check if this profile is newer + if ((UInt)version > (UInt)m_profileVersion) + { + m_profileVersion = version; + } +} + +void GLSLExtensionTracker::requireBaseTypeExtension(BaseType baseType) +{ + uint32_t bit = 1 << int(baseType); + if (m_hasBaseTypeFlags & bit) + { + return; + } + + switch (baseType) + { + case BaseType::Half: + { + // https://github.com/KhronosGroup/GLSL/blob/master/extensions/ext/GL_EXT_shader_16bit_storage.txt + requireExtension(UnownedStringSlice::fromLiteral("GL_EXT_shader_16bit_storage")); + + // https://github.com/KhronosGroup/GLSL/blob/master/extensions/ext/GL_EXT_shader_explicit_arithmetic_types.txt + requireExtension(UnownedStringSlice::fromLiteral("GL_EXT_shader_explicit_arithmetic_types")); + break; + } + case BaseType::UInt64: + case BaseType::Int64: + { + requireExtension(UnownedStringSlice::fromLiteral("GL_EXT_shader_explicit_arithmetic_types_int64")); + m_hasBaseTypeFlags |= _getFlag(BaseType::UInt64) | _getFlag(BaseType::Int64); + break; + } + } + + m_hasBaseTypeFlags |= bit; +} + +} // namespace Slang -- cgit v1.2.3