Skip to content
Snippets Groups Projects
Verified Commit fee7397f authored by Anna Wilcox's avatar Anna Wilcox :fox:
Browse files

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.
parent 72699bd7
No related branches found
No related tags found
1 merge request!778Improve Wayland situation somewhat
......@@ -10,7 +10,9 @@ license="BSD-3-Clause AND MIT AND BSD-2-Clause AND GPL-3.0+ WITH Bison-2.2-excep
depends="spirv-tools"
makedepends="cmake python3 spirv-tools-dev"
subpackages="$pkgname-dev"
source="glslang-$pkgver.tar.gz::https://github.com/KhronosGroup/glslang/archive/$pkgver.tar.gz"
source="glslang-$pkgver.tar.gz::https://github.com/KhronosGroup/glslang/archive/$pkgver.tar.gz
remap-endian.patch
"
build() {
if [ "$CBUILD" != "$CHOST" ]; then
......@@ -37,4 +39,5 @@ package() {
make DESTDIR="$pkgdir" install
}
sha512sums="ce6d09cc4d98b01d162ec5a196eec017c4a5f25eaf98c6612695d911f8d136c2f7193ff8f2c07931b2e94182d2c654833adc3b645f0c225e1d07c4e6e7abfd76 glslang-14.3.0.tar.gz"
sha512sums="ce6d09cc4d98b01d162ec5a196eec017c4a5f25eaf98c6612695d911f8d136c2f7193ff8f2c07931b2e94182d2c654833adc3b645f0c225e1d07c4e6e7abfd76 glslang-14.3.0.tar.gz
4745982dac709fc106f50e4f51800cefef07f11f609dfdaa234c3d61fab5f7bd2350720a294a686e88eb92916d1ccdfa203993419d697eb780ee741395bde8c2 remap-endian.patch"
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);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment