ref:caceca37d1f02eda6a8849a8c31ce33f184ff3ea

Add endianness guard to memcpy upload path

The RGBA memcpy only works on little-endian (where NativeImage's ABGR int stores as RGBA bytes). Falls back to per-pixel path on big-endian. Both aarch64 and x86_64 are little-endian so this is defensive only. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
SHA: caceca37d1f02eda6a8849a8c31ce33f184ff3ea
Author: Cole Christensen <cole.christensen@macmillan.com>
Date: 2026-03-20 17:56
Parents: e85f7bd
1 files changed +4 -2
Type
common/src/main/java/io/fangorn/alacrittymc/client/renderer/TerminalTexture.java +4 −2
@@ -44,8 +44,10 @@
int size = w * h * 4;
pixelData.rewind();
if (nativePixelPtr != 0 && pixelData.isDirect()) {
// Fast path: bulk memcpy (RGBA bytes → NativeImage native memory)
if (nativePixelPtr != 0 && pixelData.isDirect() && java.nio.ByteOrder.nativeOrder() == java.nio.ByteOrder.LITTLE_ENDIAN) {
// Fast path: bulk memcpy. Works because Rust outputs RGBA bytes and
// NativeImage stores ABGR ints in little-endian (= RGBA bytes in memory).
// Both aarch64 and x86_64 are little-endian so this covers all targets.
long srcAddr = MemoryUtil.memAddress(pixelData);
MemoryUtil.memCopy(srcAddr, nativePixelPtr, size);
} else {