summaryrefslogtreecommitdiff
path: root/user/glslang/remap-endian.patch
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2024-11-22 15:39:08 -0600
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2024-11-29 04:55:33 -0600
commitfee7397fd3f6ca6cdd9936bc54ac394d5393a921 (patch)
treed3f353dd3ea68fed5f4a5826b746f2d4d20ed137 /user/glslang/remap-endian.patch
parent72699bd7edad7dd007ebfa74a19881537f0e9cc0 (diff)
downloadpackages-fee7397fd3f6ca6cdd9936bc54ac394d5393a921.tar.gz
packages-fee7397fd3f6ca6cdd9936bc54ac394d5393a921.tar.bz2
packages-fee7397fd3f6ca6cdd9936bc54ac394d5393a921.tar.xz
packages-fee7397fd3f6ca6cdd9936bc54ac394d5393a921.zip
user/glslang: spirv-remap: Cross-endian support
Reported upstream at https://github.com/KhronosGroup/glslang/issues/3799; I'm not happy with the patch, and I feel like it can be better, but it works and it unblocks Vulkan for beta6.
Diffstat (limited to 'user/glslang/remap-endian.patch')
-rw-r--r--user/glslang/remap-endian.patch46
1 files changed, 46 insertions, 0 deletions
diff --git a/user/glslang/remap-endian.patch b/user/glslang/remap-endian.patch
new file mode 100644
index 000000000..4c1fc78ff
--- /dev/null
+++ b/user/glslang/remap-endian.patch
@@ -0,0 +1,46 @@
+Issue: https://github.com/KhronosGroup/glslang/issues/3799
+
+--- glslang-14.3.0/StandAlone/spirv-remap.cpp.old 2024-06-25 17:42:43.000000000 -0500
++++ glslang-14.3.0/StandAlone/spirv-remap.cpp 2024-11-22 15:27:02.655869572 -0600
+@@ -38,6 +38,7 @@
+ #include <cstring>
+ #include <stdexcept>
+ #include <filesystem>
++#include <byteswap.h>
+
+ //
+ // Include remapper
+@@ -48,6 +49,8 @@
+
+ typedef unsigned int SpvWord;
+
++ static const SpvWord MagicNumber = 0x07230203;
++
+ // Poor man's basename: given a complete path, return file portion.
+ // E.g:
+ // Linux: /foo/bar/test -> test
+@@ -82,6 +85,7 @@
+ void read(std::vector<SpvWord>& spv, const std::string& inFilename, int verbosity)
+ {
+ std::ifstream fp;
++ bool isNativeEndian = true;
+
+ if (verbosity > 0)
+ logHandler(std::string(" reading: ") + inFilename);
+@@ -97,11 +101,16 @@
+ spv.reserve(size_t(fp.tellg()) / sizeof(SpvWord));
+ fp.seekg(0, fp.beg);
+
++ char begin = fp.peek();
++ char native_begin = reinterpret_cast<const char*>(&MagicNumber)[0];
++ if (begin != native_begin) isNativeEndian = false;
++
+ while (!fp.eof()) {
+ SpvWord inWord;
+ fp.read((char *)&inWord, sizeof(inWord));
+
+ if (!fp.eof()) {
++ if (!isNativeEndian) inWord = __bswap_32(inWord);
+ spv.push_back(inWord);
+ if (fp.fail())
+ errHandler(std::string("error reading file: ") + inFilename);