Remove unused and broken big endian support code.

This commit is contained in:
Pāvels Nadtočajevs
2026-04-13 12:41:46 +03:00
parent 1aabcb9e9b
commit cdd274199e
10 changed files with 2 additions and 265 deletions
-36
View File
@@ -313,15 +313,9 @@ uint16_t FileAccess::get_16() const {
uint16_t data = 0;
get_buffer(reinterpret_cast<uint8_t *>(&data), sizeof(uint16_t));
#ifdef BIG_ENDIAN_ENABLED
if (!big_endian) {
data = BSWAP16(data);
}
#else
if (big_endian) {
data = BSWAP16(data);
}
#endif
return data;
}
@@ -330,15 +324,9 @@ uint32_t FileAccess::get_32() const {
uint32_t data = 0;
get_buffer(reinterpret_cast<uint8_t *>(&data), sizeof(uint32_t));
#ifdef BIG_ENDIAN_ENABLED
if (!big_endian) {
data = BSWAP32(data);
}
#else
if (big_endian) {
data = BSWAP32(data);
}
#endif
return data;
}
@@ -347,15 +335,9 @@ uint64_t FileAccess::get_64() const {
uint64_t data = 0;
get_buffer(reinterpret_cast<uint8_t *>(&data), sizeof(uint64_t));
#ifdef BIG_ENDIAN_ENABLED
if (!big_endian) {
data = BSWAP64(data);
}
#else
if (big_endian) {
data = BSWAP64(data);
}
#endif
return data;
}
@@ -605,43 +587,25 @@ bool FileAccess::store_8(uint8_t p_dest) {
}
bool FileAccess::store_16(uint16_t p_dest) {
#ifdef BIG_ENDIAN_ENABLED
if (!big_endian) {
p_dest = BSWAP16(p_dest);
}
#else
if (big_endian) {
p_dest = BSWAP16(p_dest);
}
#endif
return store_buffer(reinterpret_cast<uint8_t *>(&p_dest), sizeof(uint16_t));
}
bool FileAccess::store_32(uint32_t p_dest) {
#ifdef BIG_ENDIAN_ENABLED
if (!big_endian) {
p_dest = BSWAP32(p_dest);
}
#else
if (big_endian) {
p_dest = BSWAP32(p_dest);
}
#endif
return store_buffer(reinterpret_cast<uint8_t *>(&p_dest), sizeof(uint32_t));
}
bool FileAccess::store_64(uint64_t p_dest) {
#ifdef BIG_ENDIAN_ENABLED
if (!big_endian) {
p_dest = BSWAP64(p_dest);
}
#else
if (big_endian) {
p_dest = BSWAP64(p_dest);
}
#endif
return store_buffer(reinterpret_cast<uint8_t *>(&p_dest), sizeof(uint64_t));
}
-4
View File
@@ -88,11 +88,7 @@ public:
typedef void (*FileCloseFailNotify)(const String &);
typedef Ref<FileAccess> (*CreateFunc)();
#ifdef BIG_ENDIAN_ENABLED
bool big_endian = true;
#else
bool big_endian = false;
#endif
bool real_is_double = false;
virtual BitField<UnixPermissionFlags> _get_unix_permissions(const String &p_file) = 0;
-65
View File
@@ -115,14 +115,6 @@ static Error read_reals(real_t *dst, Ref<FileAccess> &f, size_t count) {
if constexpr (sizeof(real_t) == 8) {
// Ideal case with double-precision
f->get_buffer((uint8_t *)dst, count * sizeof(double));
#ifdef BIG_ENDIAN_ENABLED
{
uint64_t *dst = (uint64_t *)dst;
for (size_t i = 0; i < count; i++) {
dst[i] = BSWAP64(dst[i]);
}
}
#endif
} else if constexpr (sizeof(real_t) == 4) {
// May be slower, but this is for compatibility. Eventually the data should be converted.
for (size_t i = 0; i < count; ++i) {
@@ -135,14 +127,6 @@ static Error read_reals(real_t *dst, Ref<FileAccess> &f, size_t count) {
if constexpr (sizeof(real_t) == 4) {
// Ideal case with float-precision
f->get_buffer((uint8_t *)dst, count * sizeof(float));
#ifdef BIG_ENDIAN_ENABLED
{
uint32_t *dst = (uint32_t *)dst;
for (size_t i = 0; i < count; i++) {
dst[i] = BSWAP32(dst[i]);
}
}
#endif
} else if constexpr (sizeof(real_t) == 8) {
for (size_t i = 0; i < count; ++i) {
dst[i] = f->get_float();
@@ -526,15 +510,6 @@ Error ResourceLoaderBinary::parse_variant(Variant &r_v) {
array.resize(len);
int32_t *w = array.ptrw();
f->get_buffer((uint8_t *)w, len * sizeof(int32_t));
#ifdef BIG_ENDIAN_ENABLED
{
uint32_t *ptr = (uint32_t *)w.ptr();
for (int i = 0; i < len; i++) {
ptr[i] = BSWAP32(ptr[i]);
}
}
#endif
r_v = array;
} break;
@@ -545,15 +520,6 @@ Error ResourceLoaderBinary::parse_variant(Variant &r_v) {
array.resize(len);
int64_t *w = array.ptrw();
f->get_buffer((uint8_t *)w, len * sizeof(int64_t));
#ifdef BIG_ENDIAN_ENABLED
{
uint64_t *ptr = (uint64_t *)w.ptr();
for (int i = 0; i < len; i++) {
ptr[i] = BSWAP64(ptr[i]);
}
}
#endif
r_v = array;
} break;
@@ -564,15 +530,6 @@ Error ResourceLoaderBinary::parse_variant(Variant &r_v) {
array.resize(len);
float *w = array.ptrw();
f->get_buffer((uint8_t *)w, len * sizeof(float));
#ifdef BIG_ENDIAN_ENABLED
{
uint32_t *ptr = (uint32_t *)w.ptr();
for (int i = 0; i < len; i++) {
ptr[i] = BSWAP32(ptr[i]);
}
}
#endif
r_v = array;
} break;
@@ -583,15 +540,6 @@ Error ResourceLoaderBinary::parse_variant(Variant &r_v) {
array.resize(len);
double *w = array.ptrw();
f->get_buffer((uint8_t *)w, len * sizeof(double));
#ifdef BIG_ENDIAN_ENABLED
{
uint64_t *ptr = (uint64_t *)w.ptr();
for (int i = 0; i < len; i++) {
ptr[i] = BSWAP64(ptr[i]);
}
}
#endif
r_v = array;
} break;
@@ -642,15 +590,6 @@ Error ResourceLoaderBinary::parse_variant(Variant &r_v) {
// Colors always use `float` even with double-precision support enabled
static_assert(sizeof(Color) == 4 * sizeof(float));
f->get_buffer((uint8_t *)w, len * sizeof(float) * 4);
#ifdef BIG_ENDIAN_ENABLED
{
uint32_t *ptr = (uint32_t *)w.ptr();
for (int i = 0; i < len * 4; i++) {
ptr[i] = BSWAP32(ptr[i]);
}
}
#endif
r_v = array;
} break;
@@ -1014,11 +953,7 @@ void ResourceLoaderBinary::open(Ref<FileAccess> p_f, bool p_no_resources, bool p
ver_format = f->get_32();
print_bl("big endian: " + itos(big_endian));
#ifdef BIG_ENDIAN_ENABLED
print_bl("endian swap: " + itos(!big_endian));
#else
print_bl("endian swap: " + itos(big_endian));
#endif
print_bl("real64: " + itos(use_real64));
print_bl("major: " + itos(ver_major));
print_bl("minor: " + itos(ver_minor));
-113
View File
@@ -126,90 +126,54 @@ void StreamPeer::put_8(int8_t p_val) {
}
void StreamPeer::put_u16(uint16_t p_val) {
#ifdef BIG_ENDIAN_ENABLED
if (!big_endian) {
p_val = BSWAP16(p_val);
}
#else
if (big_endian) {
p_val = BSWAP16(p_val);
}
#endif
uint8_t buf[2];
encode_uint16(p_val, buf);
put_data(buf, 2);
}
void StreamPeer::put_16(int16_t p_val) {
#ifdef BIG_ENDIAN_ENABLED
if (!big_endian) {
p_val = BSWAP16(p_val);
}
#else
if (big_endian) {
p_val = BSWAP16(p_val);
}
#endif
uint8_t buf[2];
encode_uint16(p_val, buf);
put_data(buf, 2);
}
void StreamPeer::put_u32(uint32_t p_val) {
#ifdef BIG_ENDIAN_ENABLED
if (!big_endian) {
p_val = BSWAP32(p_val);
}
#else
if (big_endian) {
p_val = BSWAP32(p_val);
}
#endif
uint8_t buf[4];
encode_uint32(p_val, buf);
put_data(buf, 4);
}
void StreamPeer::put_32(int32_t p_val) {
#ifdef BIG_ENDIAN_ENABLED
if (!big_endian) {
p_val = BSWAP32(p_val);
}
#else
if (big_endian) {
p_val = BSWAP32(p_val);
}
#endif
uint8_t buf[4];
encode_uint32(p_val, buf);
put_data(buf, 4);
}
void StreamPeer::put_u64(uint64_t p_val) {
#ifdef BIG_ENDIAN_ENABLED
if (!big_endian) {
p_val = BSWAP64(p_val);
}
#else
if (big_endian) {
p_val = BSWAP64(p_val);
}
#endif
uint8_t buf[8];
encode_uint64(p_val, buf);
put_data(buf, 8);
}
void StreamPeer::put_64(int64_t p_val) {
#ifdef BIG_ENDIAN_ENABLED
if (!big_endian) {
p_val = BSWAP64(p_val);
}
#else
if (big_endian) {
p_val = BSWAP64(p_val);
}
#endif
uint8_t buf[8];
encode_uint64(p_val, buf);
put_data(buf, 8);
@@ -220,15 +184,9 @@ void StreamPeer::put_half(float p_val) {
encode_half(p_val, buf);
uint16_t *p16 = (uint16_t *)buf;
#ifdef BIG_ENDIAN_ENABLED
if (!big_endian) {
*p16 = BSWAP16(*p16);
}
#else
if (big_endian) {
*p16 = BSWAP16(*p16);
}
#endif
put_data(buf, 2);
}
@@ -237,17 +195,10 @@ void StreamPeer::put_float(float p_val) {
uint8_t buf[4];
encode_float(p_val, buf);
#ifdef BIG_ENDIAN_ENABLED
if (!big_endian) {
uint32_t *p32 = (uint32_t *)buf;
*p32 = BSWAP32(*p32);
}
#else
if (big_endian) {
uint32_t *p32 = (uint32_t *)buf;
*p32 = BSWAP32(*p32);
}
#endif
put_data(buf, 4);
}
@@ -256,17 +207,10 @@ void StreamPeer::put_double(double p_val) {
uint8_t buf[8];
encode_double(p_val, buf);
#ifdef BIG_ENDIAN_ENABLED
if (!big_endian) {
uint64_t *p64 = (uint64_t *)buf;
*p64 = BSWAP64(*p64);
}
#else
if (big_endian) {
uint64_t *p64 = (uint64_t *)buf;
*p64 = BSWAP64(*p64);
}
#endif
put_data(buf, 8);
}
@@ -310,15 +254,9 @@ uint16_t StreamPeer::get_u16() {
get_data(buf, 2);
uint16_t r = decode_uint16(buf);
#ifdef BIG_ENDIAN_ENABLED
if (!big_endian) {
r = BSWAP16(r);
}
#else
if (big_endian) {
r = BSWAP16(r);
}
#endif
return r;
}
@@ -328,15 +266,9 @@ int16_t StreamPeer::get_16() {
get_data(buf, 2);
uint16_t r = decode_uint16(buf);
#ifdef BIG_ENDIAN_ENABLED
if (!big_endian) {
r = BSWAP16(r);
}
#else
if (big_endian) {
r = BSWAP16(r);
}
#endif
return int16_t(r);
}
@@ -346,15 +278,9 @@ uint32_t StreamPeer::get_u32() {
get_data(buf, 4);
uint32_t r = decode_uint32(buf);
#ifdef BIG_ENDIAN_ENABLED
if (!big_endian) {
r = BSWAP32(r);
}
#else
if (big_endian) {
r = BSWAP32(r);
}
#endif
return r;
}
@@ -364,15 +290,9 @@ int32_t StreamPeer::get_32() {
get_data(buf, 4);
uint32_t r = decode_uint32(buf);
#ifdef BIG_ENDIAN_ENABLED
if (!big_endian) {
r = BSWAP32(r);
}
#else
if (big_endian) {
r = BSWAP32(r);
}
#endif
return int32_t(r);
}
@@ -382,15 +302,9 @@ uint64_t StreamPeer::get_u64() {
get_data(buf, 8);
uint64_t r = decode_uint64(buf);
#ifdef BIG_ENDIAN_ENABLED
if (!big_endian) {
r = BSWAP64(r);
}
#else
if (big_endian) {
r = BSWAP64(r);
}
#endif
return r;
}
@@ -400,15 +314,9 @@ int64_t StreamPeer::get_64() {
get_data(buf, 8);
uint64_t r = decode_uint64(buf);
#ifdef BIG_ENDIAN_ENABLED
if (!big_endian) {
r = BSWAP64(r);
}
#else
if (big_endian) {
r = BSWAP64(r);
}
#endif
return int64_t(r);
}
@@ -417,17 +325,10 @@ float StreamPeer::get_half() {
uint8_t buf[2];
get_data(buf, 2);
#ifdef BIG_ENDIAN_ENABLED
if (!big_endian) {
uint16_t *p16 = (uint16_t *)buf;
*p16 = BSWAP16(*p16);
}
#else
if (big_endian) {
uint16_t *p16 = (uint16_t *)buf;
*p16 = BSWAP16(*p16);
}
#endif
return decode_half(buf);
}
@@ -436,17 +337,10 @@ float StreamPeer::get_float() {
uint8_t buf[4];
get_data(buf, 4);
#ifdef BIG_ENDIAN_ENABLED
if (!big_endian) {
uint32_t *p32 = (uint32_t *)buf;
*p32 = BSWAP32(*p32);
}
#else
if (big_endian) {
uint32_t *p32 = (uint32_t *)buf;
*p32 = BSWAP32(*p32);
}
#endif
return decode_float(buf);
}
@@ -455,17 +349,10 @@ double StreamPeer::get_double() {
uint8_t buf[8];
get_data(buf, 8);
#ifdef BIG_ENDIAN_ENABLED
if (!big_endian) {
uint64_t *p64 = (uint64_t *)buf;
*p64 = BSWAP64(*p64);
}
#else
if (big_endian) {
uint64_t *p64 = (uint64_t *)buf;
*p64 = BSWAP64(*p64);
}
#endif
return decode_double(buf);
}
-4
View File
@@ -48,11 +48,7 @@ protected:
Array _get_data(int p_bytes);
Array _get_partial_data(int p_bytes);
#ifdef BIG_ENDIAN_ENABLED
bool big_endian = true;
#else
bool big_endian = false;
#endif
public:
virtual Error put_data(const uint8_t *p_data, int p_bytes) = 0; ///< put a whole chunk of data, blocking until it sent
-4
View File
@@ -2022,11 +2022,7 @@ Error String::append_utf16(const char16_t *p_utf16, int p_len, bool p_default_li
int cstr_size = 0;
int str_size = 0;
#ifdef BIG_ENDIAN_ENABLED
bool byteswap = p_default_little_endian;
#else
bool byteswap = !p_default_little_endian;
#endif
/* HANDLE BOM (Byte Order Mark) */
if (p_len < 0 || p_len >= 1) {
bool has_bom = false;
-14
View File
@@ -861,11 +861,7 @@ Error LightmapperRD::_store_pfm(RenderingDevice *p_rd, RID p_atlas_tex, int p_in
ERR_FAIL_COND_V_MSG(err, err, vformat("Can't save PFN at path: '%s'.", p_name));
file->store_line("PF");
file->store_line(vformat("%d %d", img->get_width(), img->get_height()));
#ifdef BIG_ENDIAN_ENABLED
file->store_line("1.0");
#else
file->store_line("-1.0");
#endif
file->store_buffer(data_float);
file->close();
@@ -887,15 +883,6 @@ Ref<Image> LightmapperRD::_read_pfm(const String &p_name, bool p_shadowmask) {
Vector<uint8_t> new_data = file->get_buffer(file->get_length() - file->get_position());
file->close();
#ifdef BIG_ENDIAN_ENABLED
if (unlikely(endian < 0.0)) {
uint32_t count = new_data.size() / 4;
uint16_t *dst = (uint16_t *)new_data.ptrw();
for (uint32_t j = 0; j < count; j++) {
dst[j * 4] = BSWAP32(dst[j * 4]);
}
}
#else
if (unlikely(endian > 0.0)) {
uint32_t count = new_data.size() / 4;
uint16_t *dst = (uint16_t *)new_data.ptrw();
@@ -903,7 +890,6 @@ Ref<Image> LightmapperRD::_read_pfm(const String &p_name, bool p_shadowmask) {
dst[j * 4] = BSWAP32(dst[j * 4]);
}
}
#endif
Ref<Image> img = Image::create_from_data(new_width, new_height, false, Image::FORMAT_RGBF, new_data);
img->convert(p_shadowmask ? Image::FORMAT_RGBA8 : Image::FORMAT_RGBAH);
return img;
+1 -4
View File
@@ -134,11 +134,8 @@ void AudioDriverOpenSL::start() {
pcm.bitsPerSample = SL_PCMSAMPLEFORMAT_FIXED_16;
pcm.containerSize = SL_PCMSAMPLEFORMAT_FIXED_16;
pcm.channelMask = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT;
#ifdef BIG_ENDIAN_ENABLED
pcm.endianness = SL_BYTEORDER_BIGENDIAN;
#else
pcm.endianness = SL_BYTEORDER_LITTLEENDIAN;
#endif
audioSource.pFormat = (void *)&pcm;
audioSource.pLocator = (void *)&loc_bufq;
+1 -12
View File
@@ -92,18 +92,7 @@ void TileMap::_set_tile_map_data_using_compatibility_format(int p_layer, TileMap
local[j] = ptr[j];
}
#ifdef BIG_ENDIAN_ENABLED
SWAP(local[0], local[3]);
SWAP(local[1], local[2]);
SWAP(local[4], local[7]);
SWAP(local[5], local[6]);
//TODO: ask someone to check this...
if (FORMAT >= FORMAT_2) {
SWAP(local[8], local[11]);
SWAP(local[9], local[10]);
}
#endif // BIG_ENDIAN_ENABLED
// Extracts position in TileMap.
// Extracts position in TileMap.
int16_t x = decode_uint16(&local[0]);
int16_t y = decode_uint16(&local[2]);
-9
View File
@@ -61,15 +61,6 @@ void TileMapPattern::_set_tile_data(const Vector<int> &p_data) {
local[j] = ptr[j];
}
#ifdef BIG_ENDIAN_ENABLED
SWAP(local[0], local[3]);
SWAP(local[1], local[2]);
SWAP(local[4], local[7]);
SWAP(local[5], local[6]);
SWAP(local[8], local[11]);
SWAP(local[9], local[10]);
#endif
int16_t x = decode_uint16(&local[0]);
int16_t y = decode_uint16(&local[2]);
uint16_t source_id = decode_uint16(&local[4]);