-
Notifications
You must be signed in to change notification settings - Fork 818
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPIR-V] Incorrect encoding for string literals on big-endian machines #202
Comments
Agreed glslang is creating octets in address order instead of significant-byte order, and hence glslang only generates correct SPIR-V when executing on a little-endian system. |
so this is why the tests fail on s390x/sparc/power/hppa? |
If we have a real big-endian system to test glslang on, I can fix this. |
should've failed on m68k too, but didn't: |
This issue has surfaced in QtShaderTools on s390x and ppc64, where the implementations in glslang and SPIRV-cross conflict: glslang encodes strings incorrectly while spirv-cross attempts to decode them correctly, resulting in reordered characters (https://bugreports.qt.io/browse/QTBUG-93101). Both the SPIR-V generation and disassembly use incorrect encoding/decoding, so calling |
I have a fix mostly working for the encoding and for the "disassembly" and printing of strings. I still need to change how the disassembly code collects id descriptions (decorations), as in
|
Per SPIR-V spec, a string literal's UTF-8 octets are encoded packed into words with little-endian convention. Explicitly perform that encoding instead of assuming that the host system is little-endian. Fixes KhronosGroup#202
Per SPIR-V spec, a string literal's UTF-8 octets are encoded packed into words with little-endian convention. Explicitly perform that encoding instead of assuming that the host system is little-endian. Note that this change requires corresponding fixes in SPIRV-Tools. Fixes KhronosGroup#202
…d_allocation_section Add xml section for memory operand bit allocation tracking
The SPIR-V spec says, in the definition of "literal string," "the UTF-8 octets (8-bit bytes) are packed four per word, following the little-endian convention (i.e., the first octet is in the lowest-order 8 bits of the word)." But when emitting literal strings here, we just reinterpret an integer as a character array, which won't work on big-endian systems, since we'll end up packing them according to the big-endian convention instead.
The text was updated successfully, but these errors were encountered: