diff options
Diffstat (limited to 'thirdparty/glslang/SPIRV/spvIR.h')
-rw-r--r-- | thirdparty/glslang/SPIRV/spvIR.h | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/thirdparty/glslang/SPIRV/spvIR.h b/thirdparty/glslang/SPIRV/spvIR.h index 5249a5ba73..486e80d000 100644 --- a/thirdparty/glslang/SPIRV/spvIR.h +++ b/thirdparty/glslang/SPIRV/spvIR.h @@ -111,23 +111,27 @@ public: void addStringOperand(const char* str) { - unsigned int word = 0; - unsigned int shiftAmount = 0; + unsigned int word; + char* wordString = (char*)&word; + char* wordPtr = wordString; + int charCount = 0; char c; - do { c = *(str++); - word |= ((unsigned int)c) << shiftAmount; - shiftAmount += 8; - if (shiftAmount == 32) { + *(wordPtr++) = c; + ++charCount; + if (charCount == 4) { addImmediateOperand(word); - word = 0; - shiftAmount = 0; + wordPtr = wordString; + charCount = 0; } } while (c != 0); // deal with partial last word - if (shiftAmount > 0) { + if (charCount > 0) { + // pad with 0s + for (; charCount < 4; ++charCount) + *(wordPtr++) = 0; addImmediateOperand(word); } } |