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-string-util.cpp | 41 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'source/core/slang-string-util.cpp') diff --git a/source/core/slang-string-util.cpp b/source/core/slang-string-util.cpp index 32f017f46..f961e6060 100644 --- a/source/core/slang-string-util.cpp +++ b/source/core/slang-string-util.cpp @@ -30,6 +30,47 @@ namespace Slang { } } +/* static */Index StringUtil::split(const UnownedStringSlice& in, char splitChar, Index maxSlices, UnownedStringSlice* outSlices) +{ + Index index = 0; + + const char* start = in.begin(); + const char* end = in.end(); + + while (start < end && index < maxSlices) + { + // Move cur so it's either at the end or at next split character + const char* cur = start; + while (cur < end && *cur != splitChar) + { + cur++; + } + + // Add to output + outSlices[index++] = UnownedStringSlice(start, cur); + + // Skip the split character, if at end we are okay anyway + start = cur + 1; + } + + return index; +} + +/* static */SlangResult StringUtil::split(const UnownedStringSlice& in, char splitChar, Index maxSlices, UnownedStringSlice* outSlices, Index& outSlicesCount) +{ + const Index sliceCount = split(in, splitChar, maxSlices, outSlices); + if (sliceCount == maxSlices && sliceCount > 0) + { + // To succeed must have parsed all of the input + if (in.end() != outSlices[sliceCount - 1].end()) + { + return SLANG_FAIL; + } + } + outSlicesCount = sliceCount; + return SLANG_OK; +} + /* static */void StringUtil::join(const List& values, char separator, StringBuilder& out) { join(values, UnownedStringSlice(&separator, 1), out); -- cgit v1.2.3