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/core/slang-semantic-version.cpp | 50 ++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 source/core/slang-semantic-version.cpp (limited to 'source/core/slang-semantic-version.cpp') diff --git a/source/core/slang-semantic-version.cpp b/source/core/slang-semantic-version.cpp new file mode 100644 index 000000000..93536e007 --- /dev/null +++ b/source/core/slang-semantic-version.cpp @@ -0,0 +1,50 @@ +// slang-semantic-version.cpp +#include "slang-semantic-version.h" + +#include "../../slang-com-helper.h" + +#include "../core/slang-string-util.h" + +namespace Slang { + +SlangResult SemanticVersion::parse(const UnownedStringSlice& value, SemanticVersion& outVersion) +{ + outVersion.reset(); + + UnownedStringSlice slices[3]; + Index splitCount; + SLANG_RETURN_ON_FAIL(StringUtil::split(value, '.', 3, slices, splitCount)); + if (splitCount <= 0) + { + return SLANG_FAIL; + } + + Int ints[3] = { 0, 0, 0 }; + for (Index i = 0; i < splitCount; i++) + { + SLANG_RETURN_ON_FAIL(StringUtil::parseInt(slices[i], ints[i])); + + const Int max = (i == 0) ? 0x7fffffff : 0xffff; + if (ints[i] < 0 || ints[i] > max) + { + return SLANG_FAIL; + } + } + + outVersion.m_major = uint32_t(ints[0]); + outVersion.m_minor = uint16_t(ints[1]); + outVersion.m_patch = uint16_t(ints[2]); + + return SLANG_OK; +} + +void SemanticVersion::append(StringBuilder& buf) const +{ + buf << Int32(m_major) << "." << Int32(m_minor); + if (m_patch != 0) + { + buf << "." << Int32(m_patch); + } +} + +} // namespace Slang -- cgit v1.2.3