Merge pull request #111445 from akien-mga/basisu-git-2025-10-09

basis_universal: Sync with latest Git to solve more warnings
This commit is contained in:
Thaddeus Crews 2025-10-09 11:46:54 -05:00
commit db3407370c
No known key found for this signature in database
GPG key ID: 8C6E5FEB5FC03CCC
23 changed files with 297 additions and 405 deletions

View file

@ -214,7 +214,7 @@ License: Apache-2.0
Files: thirdparty/basis_universal/*
Comment: Basis Universal
Copyright: 2019-2024, Binomial LLC.
Copyright: 2019-2025, Binomial LLC.
License: Apache-2.0
Files: thirdparty/brotli/*

View file

@ -74,7 +74,7 @@ Files extracted from upstream source:
## basis_universal
- Upstream: https://github.com/BinomialLLC/basis_universal
- Version: 1.60 (323239a6a5ffa57d6570cfc403be99156e33a8b0, 2025)
- Version: git (b1110111d4a93c7dd7de93ce3d9ed8fcdfd114f2, 2025)
- License: Apache 2.0
Files extracted from upstream source:
@ -88,9 +88,9 @@ Patches:
- `0001-external-zstd-pr344.patch` (GH-73441)
- `0002-external-tinyexr.patch` (GH-97582)
- `0003-remove-tinydds-qoi.patch` (GH-97582)
- `0004-ambiguous-calls.patch` (GH-103968)
- `0005-msvc-include-ctype.patch` (GH-106155)
- `0006-clang-warning-exclude.patch` (GH-111346)
- `0004-clang-warning-exclude.patch` (GH-111346)
- `0005-unused-typedef.patch` (GH-111445)
## brotli

View file

@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Copyright 2019-2025 Binomial LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View file

@ -837,7 +837,7 @@ void decodeISETritBlock (ISEDecodedResult* dst, int numValues, BitAccessStream&
deUint32 T7 = data.getNext(1);
#ifndef __EMSCRIPTEN__
#if defined(__GNUC__) && !defined(__clang__)
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough="
#endif
@ -854,7 +854,7 @@ void decodeISETritBlock (ISEDecodedResult* dst, int numValues, BitAccessStream&
DE_ASSERT(false);
}
#ifndef __EMSCRIPTEN__
#if defined(__GNUC__) && !defined(__clang__)
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
#endif
@ -903,7 +903,7 @@ void decodeISEQuintBlock (ISEDecodedResult* dst, int numValues, BitAccessStream&
deUint32 Q56 = data.getNext(2);
#ifndef __EMSCRIPTEN__
#if defined(__GNUC__) && !defined(__clang__)
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough="
#endif
@ -918,7 +918,7 @@ void decodeISEQuintBlock (ISEDecodedResult* dst, int numValues, BitAccessStream&
DE_ASSERT(false);
}
#ifndef __EMSCRIPTEN__
#if defined(__GNUC__) && !defined(__clang__)
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
#endif

View file

@ -2376,7 +2376,7 @@ static void filter_block(uint32_t grid_x, uint32_t grid_y, const vec3F* pSrc_blo
// filter columns
if (grid_y == 6)
{
memcpy(pDst_block, temp_block, sizeof(vec3F) * 6 * 6);
memcpy((void *)pDst_block, temp_block, sizeof(vec3F) * 6 * 6);
}
else
{
@ -3360,6 +3360,7 @@ static bool pack_bc6h_image(const imagef &src_img, vector2D<basist::bc6h_block>
interval_timer tm;
double total_enc_time = 0.0f;
BASISU_NOTE_UNUSED(total_enc_time);
const uint32_t num_blocks_x = src_img.get_block_width(4);
const uint32_t num_blocks_y = src_img.get_block_height(4);
@ -4422,7 +4423,18 @@ static bool compress_strip_task(
float min_corr = BIG_FLOAT_VAL, max_corr = -BIG_FLOAT_VAL;
for (uint32_t i = 0; i < 3; i++)
{
if (half_comp_stats[i].m_range > 0.0f)
#if 0
// 9/5/2025, wrong metric, we're iterating channels pairs here, not individual channels.
// On 3 active channel blocks this causes no difference.
if (half_comp_stats[i].m_range > 0.0f)
#else
static const uint8_t s_chan_pairs[3][2] = { {0, 1}, {0, 2}, {1, 2} };
const uint32_t chanA = s_chan_pairs[i][0];
const uint32_t chanB = s_chan_pairs[i][1];
if ((half_comp_stats[chanA].m_range > 0.0f) && (half_comp_stats[chanB].m_range > 0.0f))
#endif
{
const float c = fabsf((float)half_cross_chan_stats[i].m_pearson);
min_corr = minimum(min_corr, c);
@ -4437,7 +4449,7 @@ static bool compress_strip_task(
// TODO: Transform grayscale axis by covar matrix, compute variance vs. total variance
const float MODE7_MIN_CHAN_CORR = .5f;
const float MODE7_PCA_ANGLE_THRESH = .9f;
use_single_subset_mode7 = is_grayscale || is_solid_block || (min_corr >= MODE7_MIN_CHAN_CORR);
use_single_subset_mode7 = is_grayscale || is_solid_block || ((total_used_block_chans == 1) || (min_corr >= MODE7_MIN_CHAN_CORR));
if (use_single_subset_mode7)
{

View file

@ -16,7 +16,7 @@ namespace astc_6x6_hdr
{
// Important: The Delta ITP colorspace error metric we use internally makes several assumptions about the nature of the HDR RGB inputs supplied to the encoder.
// This encoder computes colorspace error in the ICtCp (or more accurately the delta ITP, where CT is scaled by .5 vs. ICtCp to become T) colorspace, so getting this correct is important.
// By default the encoder assumes the input is in absolute luminance (in nits or candela per square meter, cd/m²), specified as positive-only linear light RGB, using the REC 709 colorspace gamut (but NOT the sRGB transfer function, i.e. linear light).
// By default the encoder assumes the input is in absolute luminance (in nits or candela per square meter, cd/m^2), specified as positive-only linear light RGB, using the REC 709 colorspace gamut (but NOT the sRGB transfer function, i.e. linear light).
// If the m_rec2020_bt2100_color_gamut flag is true, the input colorspace is treated as REC 2020/BT.2100 (which is wider than 709).
// For SDR/LDR->HDR upconversion, the REC 709 sRGB input should be converted to linear light (sRGB->linear) and the resulting normalized linear RGB values scaled by either 80 or 100 nits (the luminance of a typical SDR monitor).
// SDR upconversion to normalized [0,1] (i.e. non-absolute) luminances may work but is not supported because ITP errors will not be predicted correctly.

View file

@ -3448,7 +3448,7 @@ namespace basisu
}
default:
assert(0);
fmt_debug_printf("HERE 1\n");
//fmt_debug_printf("HERE 1\n");
return false;
}
@ -3456,7 +3456,7 @@ namespace basisu
{
if ((m_params.m_ktx2_uastc_supercompression != basist::KTX2_SS_NONE) && (m_params.m_ktx2_uastc_supercompression != basist::KTX2_SS_ZSTANDARD))
{
fmt_debug_printf("HERE 2\n");
//fmt_debug_printf("HERE 2\n");
return false;
}
}
@ -3492,7 +3492,7 @@ namespace basisu
}
basist::ktx2_header header;
memset(&header, 0, sizeof(header));
memset((void *)&header, 0, sizeof(header));
memcpy(header.m_identifier, basist::g_ktx2_file_identifier, sizeof(basist::g_ktx2_file_identifier));
header.m_pixel_width = base_width;
@ -3544,7 +3544,7 @@ namespace basisu
}
default:
assert(0);
fmt_debug_printf("HERE 3\n");
//fmt_debug_printf("HERE 3\n");
return false;
}
}
@ -3584,7 +3584,7 @@ namespace basisu
if (ZSTD_isError(result))
{
fmt_debug_printf("HERE 5\n");
//fmt_debug_printf("HERE 5\n");
return false;
}
@ -3593,7 +3593,7 @@ namespace basisu
#else
// Can't get here
assert(0);
fmt_debug_printf("HERE 6\n");
//fmt_debug_printf("HERE 6\n");
return false;
#endif
}
@ -3618,7 +3618,7 @@ namespace basisu
etc1s_global_data_header.m_tables_byte_length = backend_output.m_slice_image_tables.size();
basisu::vector<basist::ktx2_etc1s_image_desc> etc1s_image_descs(total_levels * total_layers * total_faces);
memset(etc1s_image_descs.data(), 0, etc1s_image_descs.size_in_bytes());
memset((void *)etc1s_image_descs.data(), 0, etc1s_image_descs.size_in_bytes());
for (uint32_t slice_index = 0; slice_index < m_slice_descs.size(); slice_index++)
{
@ -3662,7 +3662,7 @@ namespace basisu
else if (m_fmt_mode == basist::basis_tex_format::cASTC_HDR_6x6_INTERMEDIATE)
{
basisu::vector<basist::ktx2_astc_hdr_6x6_intermediate_image_desc> image_descs(total_levels * total_layers * total_faces);
memset(image_descs.data(), 0, image_descs.size_in_bytes());
memset((void *)image_descs.data(), 0, image_descs.size_in_bytes());
for (uint32_t slice_index = 0; slice_index < m_slice_descs.size(); slice_index++)
{
@ -3717,7 +3717,7 @@ namespace basisu
uint8_vec dfd;
if (!get_dfd(dfd, header))
{
fmt_debug_printf("HERE 7\n");
//fmt_debug_printf("HERE 7\n");
return false;
}
@ -3729,20 +3729,20 @@ namespace basisu
{
if (key_values[i].m_key.size() < 2)
{
fmt_debug_printf("HERE 8\n");
//fmt_debug_printf("HERE 8\n");
return false;
}
if (key_values[i].m_key.back() != 0)
{
fmt_debug_printf("HERE 9\n");
//fmt_debug_printf("HERE 9\n");
return false;
}
const uint64_t total_len = (uint64_t)key_values[i].m_key.size() + (uint64_t)key_values[i].m_value.size();
if (total_len >= UINT32_MAX)
{
fmt_debug_printf("HERE 10\n");
//fmt_debug_printf("HERE 10\n");
return false;
}
@ -3777,7 +3777,7 @@ namespace basisu
assert(!pass);
if (pass)
{
fmt_debug_printf("HERE 11\n");
//fmt_debug_printf("HERE 11\n");
return false;
}
@ -3805,7 +3805,7 @@ namespace basisu
}
basisu::vector<basist::ktx2_level_index> level_index_array(total_levels);
memset(level_index_array.data(), 0, level_index_array.size_in_bytes());
memset((void *)level_index_array.data(), 0, level_index_array.size_in_bytes());
m_output_ktx2_file.clear();
m_output_ktx2_file.reserve(m_output_basis_file.size());

View file

@ -651,7 +651,7 @@ namespace basisu
}
img.resize(width, height);
memcpy(img.get_ptr(), pMem, width * height * sizeof(float) * 4);
memcpy((void *)img.get_ptr(), pMem, width * height * sizeof(float) * 4);
break;
}
@ -2236,7 +2236,10 @@ namespace basisu
debug_printf("job_pool::~job_pool\n");
// Notify all workers that they need to die right now.
m_kill_flag.store(true);
{
std::lock_guard<std::mutex> lk(m_mutex);
m_kill_flag.store(true);
}
m_has_work.notify_all();
@ -2326,17 +2329,27 @@ namespace basisu
m_num_active_workers.fetch_add(1);
while (true)
while (!m_kill_flag)
{
std::unique_lock<std::mutex> lock(m_mutex);
// Wait for any jobs to be issued.
#if 0
m_has_work.wait(lock, [this] { return m_kill_flag || m_queue.size(); } );
#else
// For more safety vs. buggy RTL's. Worse case we stall for a second vs. locking up forever if something goes wrong.
m_has_work.wait_for(lock, std::chrono::milliseconds(1000), [this] {
return m_kill_flag || !m_queue.empty();
});
#endif
// Check to see if we're supposed to exit.
if (m_kill_flag)
break;
if (m_queue.empty())
continue;
// Get the job and execute it.
std::function<void()> job(m_queue.back());
m_queue.pop_back();
@ -3449,7 +3462,7 @@ namespace basisu
}
else
{
memcpy(img.get_ptr(), out_rgba, sizeof(float) * 4 * img.get_total_pixels());
memcpy((void *)img.get_ptr(), out_rgba, static_cast<size_t>(sizeof(float) * 4 * img.get_total_pixels()));
}
free(out_rgba);
@ -3471,7 +3484,7 @@ namespace basisu
}
img.resize(width, height);
memcpy(img.get_ptr(), out_rgba, width * height * sizeof(float) * 4);
memcpy((void *)img.get_ptr(), out_rgba, width * height * sizeof(float) * 4);
free(out_rgba);
return true;

View file

@ -22,6 +22,7 @@
#include <functional>
#include <thread>
#include <unordered_map>
#include <map>
#include <ostream>
#if !defined(_WIN32) || defined(__MINGW32__)
@ -2163,17 +2164,24 @@ namespace basisu
uint32_t max_threads, job_pool *pJob_pool,
bool even_odd_input_pairs_equal)
{
// rg 6/24/2025 - Cross platform determinism
#if 0
typedef bit_hasher<typename Quantizer::training_vec_type> training_vec_bit_hasher;
typedef std::unordered_map < typename Quantizer::training_vec_type, weighted_block_group,
training_vec_bit_hasher> group_hash;
#else
typedef std::map< typename Quantizer::training_vec_type, weighted_block_group > group_hash;
#endif
//interval_timer tm;
//tm.start();
group_hash unique_vecs;
// rg 6/24/2025 - Cross platform determinism
#if 0
unique_vecs.reserve(20000);
#endif
weighted_block_group g;

View file

@ -31,7 +31,9 @@
#include <CL/cl.h>
#endif
#define BASISU_OPENCL_ASSERT_ON_ANY_ERRORS (1)
#ifndef BASISU_OPENCL_ASSERT_ON_ANY_ERRORS
#define BASISU_OPENCL_ASSERT_ON_ANY_ERRORS (0)
#endif
namespace basisu
{

View file

@ -231,18 +231,7 @@ namespace basisu
inline void set_to_black()
{
#ifndef __EMSCRIPTEN__
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif
#endif
memset(m_blocks.get_ptr(), 0, m_blocks.size_in_bytes());
#ifndef __EMSCRIPTEN__
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif
#endif
memset((void *)m_blocks.get_ptr(), 0, m_blocks.size_in_bytes());
}
inline bool get_block_uses_transparent_modulation(uint32_t bx, uint32_t by) const

View file

@ -3146,7 +3146,7 @@ namespace jpgd {
for (int y = 0; y < image_height; y++)
{
const uint8* pScan_line;
const uint8* pScan_line = nullptr;
uint scan_line_len;
if (decoder.decode((const void**)&pScan_line, &scan_line_len) != JPGD_SUCCESS)
{

View file

@ -1,5 +1,5 @@
diff --git a/thirdparty/basis_universal/encoder/basisu_enc.cpp b/thirdparty/basis_universal/encoder/basisu_enc.cpp
index 1cc982b134..ab9a458744 100644
index 2c314740cd..cee9c77ca0 100644
--- a/thirdparty/basis_universal/encoder/basisu_enc.cpp
+++ b/thirdparty/basis_universal/encoder/basisu_enc.cpp
@@ -29,7 +29,7 @@
@ -11,7 +11,7 @@ index 1cc982b134..ab9a458744 100644
#ifndef MINIZ_HEADER_FILE_ONLY
#define MINIZ_HEADER_FILE_ONLY
@@ -3420,7 +3420,8 @@ namespace basisu
@@ -3433,7 +3433,8 @@ namespace basisu
float* out_rgba = nullptr;
const char* err = nullptr;

View file

@ -1,5 +1,5 @@
diff --git a/thirdparty/basis_universal/encoder/basisu_enc.cpp b/thirdparty/basis_universal/encoder/basisu_enc.cpp
index 4d885cba16..6c2cf0260e 100644
index cee9c77ca0..e9c8a01388 100644
--- a/thirdparty/basis_universal/encoder/basisu_enc.cpp
+++ b/thirdparty/basis_universal/encoder/basisu_enc.cpp
@@ -39,9 +39,6 @@
@ -31,7 +31,7 @@ index 4d885cba16..6c2cf0260e 100644
bool load_png(const uint8_t *pBuf, size_t buf_size, image &img, const char *pFilename)
diff --git a/thirdparty/basis_universal/encoder/basisu_gpu_texture.cpp b/thirdparty/basis_universal/encoder/basisu_gpu_texture.cpp
index 339218fcf2..028ac3f314 100644
index 3fa65b43c6..028ac3f314 100644
--- a/thirdparty/basis_universal/encoder/basisu_gpu_texture.cpp
+++ b/thirdparty/basis_universal/encoder/basisu_gpu_texture.cpp
@@ -19,9 +19,6 @@
@ -398,7 +398,7 @@ index 339218fcf2..028ac3f314 100644
- goto failure;
- }
-
- memcpy(hdr_mips[level].get_ptr(), pImage, image_size);
- memcpy((void *)hdr_mips[level].get_ptr(), pImage, image_size);
- }
- else if (fmt == cRGBA_HALF)
- {

View file

@ -1,22 +0,0 @@
diff --git a/thirdparty/basis_universal/transcoder/basisu_containers.h b/thirdparty/basis_universal/transcoder/basisu_containers.h
index 03fae33974..7fff4c243e 100644
--- a/thirdparty/basis_universal/transcoder/basisu_containers.h
+++ b/thirdparty/basis_universal/transcoder/basisu_containers.h
@@ -3349,7 +3349,7 @@ namespace basisu
inline size_t hash_key(const Key& k) const
{
- assert((safe_shift_left(1ULL, (SIZE_T_BITS - m_hash_shift))) == m_values.size());
+ assert((safe_shift_left(static_cast<uint64_t>(1), (SIZE_T_BITS - m_hash_shift))) == m_values.size());
// Fibonacci hashing
if (SIZE_T_BITS == 32)
@@ -3433,7 +3433,7 @@ namespace basisu
return false;
new_map.m_hash_shift = SIZE_T_BITS - helpers::floor_log2i((uint64_t)new_hash_size);
- assert(new_hash_size == safe_shift_left(1ULL, SIZE_T_BITS - new_map.m_hash_shift));
+ assert(new_hash_size == safe_shift_left(static_cast<uint64_t>(1), SIZE_T_BITS - new_map.m_hash_shift));
new_map.m_grow_threshold = std::numeric_limits<size_t>::max();

View file

@ -0,0 +1,142 @@
diff --git a/thirdparty/basis_universal/encoder/basisu_pvrtc1_4.h b/thirdparty/basis_universal/encoder/basisu_pvrtc1_4.h
index a9fe6b27aa..4b8ffb0817 100644
--- a/thirdparty/basis_universal/encoder/basisu_pvrtc1_4.h
+++ b/thirdparty/basis_universal/encoder/basisu_pvrtc1_4.h
@@ -231,18 +231,7 @@ namespace basisu
inline void set_to_black()
{
-#ifndef __EMSCRIPTEN__
-#ifdef __GNUC__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wclass-memaccess"
-#endif
-#endif
- memset(m_blocks.get_ptr(), 0, m_blocks.size_in_bytes());
-#ifndef __EMSCRIPTEN__
-#ifdef __GNUC__
-#pragma GCC diagnostic pop
-#endif
-#endif
+ memset((void *)m_blocks.get_ptr(), 0, m_blocks.size_in_bytes());
}
inline bool get_block_uses_transparent_modulation(uint32_t bx, uint32_t by) const
diff --git a/thirdparty/basis_universal/transcoder/basisu.h b/thirdparty/basis_universal/transcoder/basisu.h
index e1f7161141..31b20d2734 100644
--- a/thirdparty/basis_universal/transcoder/basisu.h
+++ b/thirdparty/basis_universal/transcoder/basisu.h
@@ -107,21 +107,8 @@ namespace basisu
debug_puts(res.c_str());
}
-#ifndef __EMSCRIPTEN__
-#ifdef __GNUC__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wclass-memaccess"
-#endif
-#endif
-
template <typename T> inline void clear_obj(T& obj) { memset((void *)&obj, 0, sizeof(obj)); }
-#ifndef __EMSCRIPTEN__
-#ifdef __GNUC__
-#pragma GCC diagnostic pop
-#endif
-#endif
-
constexpr double cPiD = 3.14159265358979323846264338327950288;
constexpr float REALLY_SMALL_FLOAT_VAL = .000000125f;
constexpr float SMALL_FLOAT_VAL = .0000125f;
diff --git a/thirdparty/basis_universal/transcoder/basisu_containers.h b/thirdparty/basis_universal/transcoder/basisu_containers.h
index 82b78cba62..9ea5917dfb 100644
--- a/thirdparty/basis_universal/transcoder/basisu_containers.h
+++ b/thirdparty/basis_universal/transcoder/basisu_containers.h
@@ -1503,22 +1503,10 @@ namespace basisu
if (BASISU_IS_BITWISE_COPYABLE(T))
{
-
-#ifndef __EMSCRIPTEN__
-#ifdef __GNUC__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wclass-memaccess"
-#endif
-#endif
if ((m_p) && (other.m_p))
{
- memcpy(m_p, other.m_p, m_size * sizeof(T));
+ memcpy((void *)m_p, other.m_p, m_size * sizeof(T));
}
-#ifndef __EMSCRIPTEN__
-#ifdef __GNUC__
-#pragma GCC diagnostic pop
-#endif
-#endif
}
else
{
@@ -1649,19 +1637,8 @@ namespace basisu
if (BASISU_IS_BITWISE_COPYABLE(T))
{
-#ifndef __EMSCRIPTEN__
-#ifdef __GNUC__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wclass-memaccess"
-#endif
-#endif
if ((m_p) && (other.m_p))
memcpy((void *)m_p, other.m_p, other.m_size * sizeof(T));
-#ifndef __EMSCRIPTEN__
-#ifdef __GNUC__
-#pragma GCC diagnostic pop
-#endif
-#endif
}
else
{
@@ -2233,21 +2210,7 @@ namespace basisu
}
// Copy "down" the objects to preserve, filling in the empty slots.
-
-#ifndef __EMSCRIPTEN__
-#ifdef __GNUC__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wclass-memaccess"
-#endif
-#endif
-
memmove((void *)pDst, pSrc, num_to_move * sizeof(T));
-
-#ifndef __EMSCRIPTEN__
-#ifdef __GNUC__
-#pragma GCC diagnostic pop
-#endif
-#endif
}
else
{
@@ -2492,18 +2455,13 @@ namespace basisu
{
if ((sizeof(T) == 1) && (scalar_type<T>::cFlag))
{
-#ifndef __EMSCRIPTEN__
-#ifdef __GNUC__
+#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wclass-memaccess"
-#endif
+#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif
memset(m_p, *reinterpret_cast<const uint8_t*>(&o), m_size);
-
-#ifndef __EMSCRIPTEN__
-#ifdef __GNUC__
+#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
-#endif
#endif
}
else

View file

@ -0,0 +1,16 @@
diff --git a/thirdparty/basis_universal/encoder/basisu_enc.h b/thirdparty/basis_universal/encoder/basisu_enc.h
index a565803e04..5256d34ad3 100644
--- a/thirdparty/basis_universal/encoder/basisu_enc.h
+++ b/thirdparty/basis_universal/encoder/basisu_enc.h
@@ -2164,10 +2164,9 @@ namespace basisu
uint32_t max_threads, job_pool *pJob_pool,
bool even_odd_input_pairs_equal)
{
- typedef bit_hasher<typename Quantizer::training_vec_type> training_vec_bit_hasher;
-
// rg 6/24/2025 - Cross platform determinism
#if 0
+ typedef bit_hasher<typename Quantizer::training_vec_type> training_vec_bit_hasher;
typedef std::unordered_map < typename Quantizer::training_vec_type, weighted_block_group,
training_vec_bit_hasher> group_hash;
#else

View file

@ -1,165 +0,0 @@
.../encoder/3rdparty/android_astc_decomp.cpp | 8 ++++----
thirdparty/basis_universal/encoder/basisu_pvrtc1_4.h | 4 ++--
thirdparty/basis_universal/transcoder/basisu.h | 4 ++--
.../basis_universal/transcoder/basisu_containers.h | 16 ++++++++--------
4 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/thirdparty/basis_universal/encoder/3rdparty/android_astc_decomp.cpp b/thirdparty/basis_universal/encoder/3rdparty/android_astc_decomp.cpp
index a667d0d637..742427c838 100644
--- a/thirdparty/basis_universal/encoder/3rdparty/android_astc_decomp.cpp
+++ b/thirdparty/basis_universal/encoder/3rdparty/android_astc_decomp.cpp
@@ -837,7 +837,7 @@ void decodeISETritBlock (ISEDecodedResult* dst, int numValues, BitAccessStream&
deUint32 T7 = data.getNext(1);
#ifndef __EMSCRIPTEN__
-#ifdef __GNUC__
+#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough="
#endif
@@ -854,7 +854,7 @@ void decodeISETritBlock (ISEDecodedResult* dst, int numValues, BitAccessStream&
DE_ASSERT(false);
}
#ifndef __EMSCRIPTEN__
-#ifdef __GNUC__
+#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif
#endif
@@ -903,7 +903,7 @@ void decodeISEQuintBlock (ISEDecodedResult* dst, int numValues, BitAccessStream&
deUint32 Q56 = data.getNext(2);
#ifndef __EMSCRIPTEN__
-#ifdef __GNUC__
+#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough="
#endif
@@ -918,7 +918,7 @@ void decodeISEQuintBlock (ISEDecodedResult* dst, int numValues, BitAccessStream&
DE_ASSERT(false);
}
#ifndef __EMSCRIPTEN__
-#ifdef __GNUC__
+#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif
#endif
diff --git a/thirdparty/basis_universal/encoder/basisu_pvrtc1_4.h b/thirdparty/basis_universal/encoder/basisu_pvrtc1_4.h
index a9fe6b27aa..356aaba97a 100644
--- a/thirdparty/basis_universal/encoder/basisu_pvrtc1_4.h
+++ b/thirdparty/basis_universal/encoder/basisu_pvrtc1_4.h
@@ -232,14 +232,14 @@ namespace basisu
inline void set_to_black()
{
#ifndef __EMSCRIPTEN__
-#ifdef __GNUC__
+#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif
#endif
memset(m_blocks.get_ptr(), 0, m_blocks.size_in_bytes());
#ifndef __EMSCRIPTEN__
-#ifdef __GNUC__
+#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif
#endif
diff --git a/thirdparty/basis_universal/transcoder/basisu.h b/thirdparty/basis_universal/transcoder/basisu.h
index 44fb9a3007..1dbf14ace3 100644
--- a/thirdparty/basis_universal/transcoder/basisu.h
+++ b/thirdparty/basis_universal/transcoder/basisu.h
@@ -108,7 +108,7 @@ namespace basisu
}
#ifndef __EMSCRIPTEN__
-#ifdef __GNUC__
+#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif
@@ -117,7 +117,7 @@ namespace basisu
template <typename T> inline void clear_obj(T& obj) { memset(&obj, 0, sizeof(obj)); }
#ifndef __EMSCRIPTEN__
-#ifdef __GNUC__
+#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif
#endif
diff --git a/thirdparty/basis_universal/transcoder/basisu_containers.h b/thirdparty/basis_universal/transcoder/basisu_containers.h
index 7fff4c243e..d30736842a 100644
--- a/thirdparty/basis_universal/transcoder/basisu_containers.h
+++ b/thirdparty/basis_universal/transcoder/basisu_containers.h
@@ -1505,7 +1505,7 @@ namespace basisu
{
#ifndef __EMSCRIPTEN__
-#ifdef __GNUC__
+#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif
@@ -1515,7 +1515,7 @@ namespace basisu
memcpy(m_p, other.m_p, m_size * sizeof(T));
}
#ifndef __EMSCRIPTEN__
-#ifdef __GNUC__
+#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif
#endif
@@ -1650,7 +1650,7 @@ namespace basisu
if (BASISU_IS_BITWISE_COPYABLE(T))
{
#ifndef __EMSCRIPTEN__
-#ifdef __GNUC__
+#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif
@@ -1658,7 +1658,7 @@ namespace basisu
if ((m_p) && (other.m_p))
memcpy(m_p, other.m_p, other.m_size * sizeof(T));
#ifndef __EMSCRIPTEN__
-#ifdef __GNUC__
+#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif
#endif
@@ -2235,7 +2235,7 @@ namespace basisu
// Copy "down" the objects to preserve, filling in the empty slots.
#ifndef __EMSCRIPTEN__
-#ifdef __GNUC__
+#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif
@@ -2244,7 +2244,7 @@ namespace basisu
memmove(pDst, pSrc, num_to_move * sizeof(T));
#ifndef __EMSCRIPTEN__
-#ifdef __GNUC__
+#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif
#endif
@@ -2493,7 +2493,7 @@ namespace basisu
if ((sizeof(T) == 1) && (scalar_type<T>::cFlag))
{
#ifndef __EMSCRIPTEN__
-#ifdef __GNUC__
+#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif
@@ -2501,7 +2501,7 @@ namespace basisu
memset(m_p, *reinterpret_cast<const uint8_t*>(&o), m_size);
#ifndef __EMSCRIPTEN__
-#ifdef __GNUC__
+#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif
#endif

View file

@ -107,20 +107,7 @@ namespace basisu
debug_puts(res.c_str());
}
#ifndef __EMSCRIPTEN__
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif
#endif
template <typename T> inline void clear_obj(T& obj) { memset(&obj, 0, sizeof(obj)); }
#ifndef __EMSCRIPTEN__
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif
#endif
template <typename T> inline void clear_obj(T& obj) { memset((void *)&obj, 0, sizeof(obj)); }
constexpr double cPiD = 3.14159265358979323846264338327950288;
constexpr float REALLY_SMALL_FLOAT_VAL = .000000125f;
@ -348,6 +335,7 @@ namespace basisu
inline packed_uint& operator= (uint64_t v)
{
// TODO: Add assert on truncation?
for (uint32_t i = 0; i < NumBytes; i++)
m_bytes[i] = static_cast<uint8_t>(v >> (i * 8));
return *this;
@ -358,69 +346,10 @@ namespace basisu
memcpy(m_bytes, rhs.m_bytes, sizeof(m_bytes));
return *this;
}
#if 0
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warray-bounds"
#endif
inline operator uint32_t() const
{
switch (NumBytes)
{
case 1:
{
return m_bytes[0];
}
case 2:
{
return (m_bytes[1] << 8U) | m_bytes[0];
}
case 3:
{
return (m_bytes[2] << 16U) | (m_bytes[1] << 8U) | m_bytes[0];
}
case 4:
{
return read_le_dword(m_bytes);
}
case 5:
{
uint32_t l = read_le_dword(m_bytes);
uint32_t h = m_bytes[4];
return static_cast<uint64_t>(l) | (static_cast<uint64_t>(h) << 32U);
}
case 6:
{
uint32_t l = read_le_dword(m_bytes);
uint32_t h = (m_bytes[5] << 8U) | m_bytes[4];
return static_cast<uint64_t>(l) | (static_cast<uint64_t>(h) << 32U);
}
case 7:
{
uint32_t l = read_le_dword(m_bytes);
uint32_t h = (m_bytes[6] << 16U) | (m_bytes[5] << 8U) | m_bytes[4];
return static_cast<uint64_t>(l) | (static_cast<uint64_t>(h) << 32U);
}
case 8:
{
uint32_t l = read_le_dword(m_bytes);
uint32_t h = read_le_dword(m_bytes + 4);
return static_cast<uint64_t>(l) | (static_cast<uint64_t>(h) << 32U);
}
default:
{
assert(0);
return 0;
}
}
}
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
#else
inline operator uint32_t() const
inline uint64_t get_uint64() const
{
// Some compilers may warn about this code. It clearly cannot access beyond the end of the m_bytes struct here.
if constexpr (NumBytes == 1)
{
return m_bytes[0];
@ -467,8 +396,18 @@ namespace basisu
return 0;
}
}
#endif
inline uint32_t get_uint32() const
{
static_assert(NumBytes <= sizeof(uint32_t), "packed_uint too large to use get_uint32");
return static_cast<uint32_t>(get_uint64());
}
inline operator uint32_t() const
{
static_assert(NumBytes <= sizeof(uint32_t), "packed_uint too large to use operator uint32_t");
return static_cast<uint32_t>(get_uint64());
}
};
enum eZero { cZero };

View file

@ -1,6 +1,5 @@
// basisu_astc_helpers.h
// Be sure to define ASTC_HELPERS_IMPLEMENTATION somewhere to get the implementation, otherwise you only get the header.
#pragma once
#ifndef BASISU_ASTC_HELPERS_HEADER
#define BASISU_ASTC_HELPERS_HEADER

View file

@ -1503,22 +1503,10 @@ namespace basisu
if (BASISU_IS_BITWISE_COPYABLE(T))
{
#ifndef __EMSCRIPTEN__
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif
#endif
if ((m_p) && (other.m_p))
{
memcpy(m_p, other.m_p, m_size * sizeof(T));
memcpy((void *)m_p, other.m_p, m_size * sizeof(T));
}
#ifndef __EMSCRIPTEN__
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif
#endif
}
else
{
@ -1649,19 +1637,8 @@ namespace basisu
if (BASISU_IS_BITWISE_COPYABLE(T))
{
#ifndef __EMSCRIPTEN__
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif
#endif
if ((m_p) && (other.m_p))
memcpy(m_p, other.m_p, other.m_size * sizeof(T));
#ifndef __EMSCRIPTEN__
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif
#endif
memcpy((void *)m_p, other.m_p, other.m_size * sizeof(T));
}
else
{
@ -2233,21 +2210,7 @@ namespace basisu
}
// Copy "down" the objects to preserve, filling in the empty slots.
#ifndef __EMSCRIPTEN__
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif
#endif
memmove(pDst, pSrc, num_to_move * sizeof(T));
#ifndef __EMSCRIPTEN__
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif
#endif
memmove((void *)pDst, pSrc, num_to_move * sizeof(T));
}
else
{
@ -2492,18 +2455,13 @@ namespace basisu
{
if ((sizeof(T) == 1) && (scalar_type<T>::cFlag))
{
#ifndef __EMSCRIPTEN__
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif
memset(m_p, *reinterpret_cast<const uint8_t*>(&o), m_size);
#ifndef __EMSCRIPTEN__
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif
#endif
}
else

View file

@ -16,11 +16,11 @@
#include "basisu_transcoder.h"
#include "basisu_containers_impl.h"
#include "basisu_astc_hdr_core.h"
#define BASISU_ASTC_HELPERS_IMPLEMENTATION
#include "basisu_astc_helpers.h"
#include "basisu_astc_hdr_core.h"
#include <limits.h>
#if defined(_MSC_VER)
@ -4622,6 +4622,7 @@ namespace basist
const int CHROMA_THRESH = 10;
uint32_t total_filtered_blocks = 0;
BASISU_NOTE_UNUSED(total_filtered_blocks);
for (int by = 0; by < (int)num_blocks_y; by++)
{
@ -9446,7 +9447,7 @@ namespace basist
void* pOutput_blocks, uint32_t output_blocks_buf_size_in_blocks_or_pixels,
const uint8_t* pCompressed_data, uint32_t compressed_data_length,
uint32_t num_blocks_x, uint32_t num_blocks_y, uint32_t orig_width, uint32_t orig_height, uint32_t level_index,
uint32_t rgb_offset, uint32_t rgb_length, uint32_t alpha_offset, uint32_t alpha_length,
uint64_t rgb_offset, uint32_t rgb_length, uint64_t alpha_offset, uint32_t alpha_length,
uint32_t decode_flags,
bool basis_file_has_alpha_slices,
bool is_video,
@ -10311,7 +10312,7 @@ namespace basist
void* pOutput_blocks, uint32_t output_blocks_buf_size_in_blocks_or_pixels,
const uint8_t* pCompressed_data, uint32_t compressed_data_length,
uint32_t num_blocks_x, uint32_t num_blocks_y, uint32_t orig_width, uint32_t orig_height, uint32_t level_index,
uint32_t slice_offset, uint32_t slice_length,
uint64_t slice_offset, uint32_t slice_length,
uint32_t decode_flags,
bool has_alpha,
bool is_video,
@ -10802,7 +10803,7 @@ namespace basist
void* pOutput_blocks, uint32_t output_blocks_buf_size_in_blocks_or_pixels,
const uint8_t* pCompressed_data, uint32_t compressed_data_length,
uint32_t num_blocks_x, uint32_t num_blocks_y, uint32_t orig_width, uint32_t orig_height, uint32_t level_index,
uint32_t slice_offset, uint32_t slice_length,
uint64_t slice_offset, uint32_t slice_length,
uint32_t decode_flags,
bool has_alpha,
bool is_video,
@ -11238,7 +11239,7 @@ namespace basist
void* pOutput_blocks, uint32_t output_blocks_buf_size_in_blocks_or_pixels,
const uint8_t* pCompressed_data, uint32_t compressed_data_length,
uint32_t num_blocks_x, uint32_t num_blocks_y, uint32_t orig_width, uint32_t orig_height, uint32_t level_index,
uint32_t slice_offset, uint32_t slice_length,
uint64_t slice_offset, uint32_t slice_length,
uint32_t decode_flags,
bool has_alpha,
bool is_video,
@ -11685,7 +11686,7 @@ namespace basist
void* pOutput_blocks, uint32_t output_blocks_buf_size_in_blocks_or_pixels,
const uint8_t* pCompressed_data, uint32_t compressed_data_length,
uint32_t num_blocks_x, uint32_t num_blocks_y, uint32_t orig_width, uint32_t orig_height, uint32_t level_index,
uint32_t slice_offset, uint32_t slice_length,
uint64_t slice_offset, uint32_t slice_length,
uint32_t decode_flags,
bool has_alpha,
bool is_video,
@ -18847,11 +18848,11 @@ namespace basist
m_pData = nullptr;
m_data_size = 0;
memset(&m_header, 0, sizeof(m_header));
memset((void *)&m_header, 0, sizeof(m_header));
m_levels.clear();
m_dfd.clear();
m_key_values.clear();
memset(&m_etc1s_header, 0, sizeof(m_etc1s_header));
memset((void *)&m_etc1s_header, 0, sizeof(m_etc1s_header));
m_etc1s_image_descs.clear();
m_astc_6x6_intermediate_image_descs.clear();
@ -18900,7 +18901,7 @@ namespace basist
m_pData = static_cast<const uint8_t *>(pData);
m_data_size = data_size;
memcpy(&m_header, pData, sizeof(m_header));
memcpy((void *)&m_header, pData, sizeof(m_header));
// Check for supported VK formats. We may also need to parse the DFD.
if ((m_header.m_vk_format != KTX2_VK_FORMAT_UNDEFINED) &&
@ -18973,13 +18974,13 @@ namespace basist
}
#endif
if (m_header.m_sgd_byte_offset < sizeof(ktx2_header))
if (m_header.m_sgd_byte_offset.get_uint64() < sizeof(ktx2_header))
{
BASISU_DEVEL_ERROR("ktx2_transcoder::init: Supercompression global data offset is too low\n");
return false;
}
if (m_header.m_sgd_byte_offset + m_header.m_sgd_byte_length > m_data_size)
if (m_header.m_sgd_byte_offset.get_uint64() + m_header.m_sgd_byte_length.get_uint64() > m_data_size)
{
BASISU_DEVEL_ERROR("ktx2_transcoder::init: Supercompression global data offset and/or length is too high\n");
return false;
@ -19000,23 +19001,23 @@ namespace basist
return false;
}
memcpy(&m_levels[0], m_pData + sizeof(ktx2_header), level_index_size_in_bytes);
memcpy((void *)&m_levels[0], m_pData + sizeof(ktx2_header), level_index_size_in_bytes);
// Sanity check the level offsets and byte sizes
for (uint32_t i = 0; i < m_levels.size(); i++)
{
if (m_levels[i].m_byte_offset < sizeof(ktx2_header))
if (m_levels[i].m_byte_offset.get_uint64() < sizeof(ktx2_header))
{
BASISU_DEVEL_ERROR("ktx2_transcoder::init: Invalid level offset (too low)\n");
return false;
}
if (!m_levels[i].m_byte_length)
if (!m_levels[i].m_byte_length.get_uint64())
{
BASISU_DEVEL_ERROR("ktx2_transcoder::init: Invalid level byte length\n");
}
if ((m_levels[i].m_byte_offset + m_levels[i].m_byte_length) > m_data_size)
if ((m_levels[i].m_byte_offset.get_uint64() + m_levels[i].m_byte_length.get_uint64()) > m_data_size)
{
BASISU_DEVEL_ERROR("ktx2_transcoder::init: Invalid level offset and/or length\n");
return false;
@ -19024,7 +19025,7 @@ namespace basist
const uint64_t MAX_SANE_LEVEL_UNCOMP_SIZE = 2048ULL * 1024ULL * 1024ULL;
if (m_levels[i].m_uncompressed_byte_length >= MAX_SANE_LEVEL_UNCOMP_SIZE)
if (m_levels[i].m_uncompressed_byte_length.get_uint64() >= MAX_SANE_LEVEL_UNCOMP_SIZE)
{
BASISU_DEVEL_ERROR("ktx2_transcoder::init: Invalid level offset (too large)\n");
return false;
@ -19032,7 +19033,7 @@ namespace basist
if (m_header.m_supercompression_scheme == KTX2_SS_BASISLZ)
{
if (m_levels[i].m_uncompressed_byte_length)
if (m_levels[i].m_uncompressed_byte_length.get_uint64())
{
BASISU_DEVEL_ERROR("ktx2_transcoder::init: Invalid uncompressed length (0)\n");
return false;
@ -19040,7 +19041,7 @@ namespace basist
}
else if (m_header.m_supercompression_scheme >= KTX2_SS_ZSTANDARD)
{
if (!m_levels[i].m_uncompressed_byte_length)
if (!m_levels[i].m_uncompressed_byte_length.get_uint64())
{
BASISU_DEVEL_ERROR("ktx2_transcoder::init: Invalid uncompressed length (1)\n");
return false;
@ -19435,8 +19436,8 @@ namespace basist
return false;
}
const uint8_t* pComp_level_data = m_pData + m_levels[level_index].m_byte_offset;
uint64_t comp_level_data_size = m_levels[level_index].m_byte_length;
const uint8_t* pComp_level_data = m_pData + m_levels[level_index].m_byte_offset.get_uint64();
uint64_t comp_level_data_size = m_levels[level_index].m_byte_length.get_uint64();
const uint8_t* pUncomp_level_data = pComp_level_data;
uint64_t uncomp_level_data_size = comp_level_data_size;
@ -19498,8 +19499,8 @@ namespace basist
pOutput_blocks, output_blocks_buf_size_in_blocks_or_pixels, m_pData, m_data_size,
num_blocks4_x, num_blocks4_y, level_width, level_height,
level_index,
m_levels[level_index].m_byte_offset + image_desc.m_rgb_slice_byte_offset, image_desc.m_rgb_slice_byte_length,
image_desc.m_alpha_slice_byte_length ? (m_levels[level_index].m_byte_offset + image_desc.m_alpha_slice_byte_offset) : 0, image_desc.m_alpha_slice_byte_length,
m_levels[level_index].m_byte_offset.get_uint64() + image_desc.m_rgb_slice_byte_offset, image_desc.m_rgb_slice_byte_length,
image_desc.m_alpha_slice_byte_length ? (m_levels[level_index].m_byte_offset.get_uint64() + image_desc.m_alpha_slice_byte_offset) : 0, image_desc.m_alpha_slice_byte_length,
decode_flags, m_has_alpha,
m_is_video, output_row_pitch_in_blocks_or_pixels, &pState->m_transcoder_state, output_rows_in_pixels))
{
@ -19536,7 +19537,7 @@ namespace basist
if (!m_astc_hdr_6x6_intermediate_transcoder.transcode_image(fmt,
pOutput_blocks, output_blocks_buf_size_in_blocks_or_pixels,
m_pData, m_data_size, num_blocks6_x, num_blocks6_y, level_width, level_height, level_index,
m_levels[level_index].m_byte_offset + image_desc.m_rgb_slice_byte_offset, image_desc.m_rgb_slice_byte_length,
m_levels[level_index].m_byte_offset.get_uint64() + image_desc.m_rgb_slice_byte_offset, image_desc.m_rgb_slice_byte_length,
decode_flags, m_has_alpha, m_is_video, output_row_pitch_in_blocks_or_pixels, nullptr, output_rows_in_pixels, channel0, channel1))
{
BASISU_DEVEL_ERROR("ktx2_transcoder::transcode_image_2D: ASTC 6x6 HDR transcode_image() failed, this is either a bug or the file is corrupted/invalid\n");
@ -19549,7 +19550,7 @@ namespace basist
const uint32_t num_blocks6_y = (level_height + 5) / 6;
// Compute length and offset to uncompressed 2D UASTC texture data, given the face/layer indices.
assert(uncomp_level_data_size == m_levels[level_index].m_uncompressed_byte_length);
assert(uncomp_level_data_size == m_levels[level_index].m_uncompressed_byte_length.get_uint64());
const uint32_t total_2D_image_size = num_blocks6_x * num_blocks6_y * sizeof(astc_helpers::astc_block);
const uint32_t uncomp_ofs = (layer_index * m_header.m_face_count + face_index) * total_2D_image_size;
@ -19581,7 +19582,7 @@ namespace basist
(m_format == basist::basis_tex_format::cUASTC_HDR_4x4))
{
// Compute length and offset to uncompressed 2D UASTC texture data, given the face/layer indices.
assert(uncomp_level_data_size == m_levels[level_index].m_uncompressed_byte_length);
assert(uncomp_level_data_size == m_levels[level_index].m_uncompressed_byte_length.get_uint64());
const uint32_t total_2D_image_size = num_blocks4_x * num_blocks4_y * KTX2_UASTC_BLOCK_SIZE;
const uint32_t uncomp_ofs = (layer_index * m_header.m_face_count + face_index) * total_2D_image_size;
@ -19637,10 +19638,10 @@ namespace basist
bool ktx2_transcoder::decompress_level_data(uint32_t level_index, basisu::uint8_vec& uncomp_data)
{
const uint8_t* pComp_data = m_levels[level_index].m_byte_offset + m_pData;
const uint64_t comp_size = m_levels[level_index].m_byte_length;
const uint8_t* pComp_data = m_levels[level_index].m_byte_offset.get_uint64() + m_pData;
const uint64_t comp_size = m_levels[level_index].m_byte_length.get_uint64();
const uint64_t uncomp_size = m_levels[level_index].m_uncompressed_byte_length;
const uint64_t uncomp_size = m_levels[level_index].m_uncompressed_byte_length.get_uint64();
if (((size_t)comp_size) != comp_size)
{
@ -19687,9 +19688,9 @@ namespace basist
const uint32_t image_count = basisu::maximum<uint32_t>(m_header.m_layer_count, 1) * m_header.m_face_count * m_header.m_level_count;
assert(image_count);
const uint8_t* pSrc = m_pData + m_header.m_sgd_byte_offset;
const uint8_t* pSrc = m_pData + m_header.m_sgd_byte_offset.get_uint64();
if (m_header.m_sgd_byte_length != image_count * sizeof(ktx2_astc_hdr_6x6_intermediate_image_desc))
if (m_header.m_sgd_byte_length.get_uint64() != image_count * sizeof(ktx2_astc_hdr_6x6_intermediate_image_desc))
{
BASISU_DEVEL_ERROR("ktx2_transcoder::decompress_astc_6x6_hdr_intermediate_global_data: Invalid global data length\n");
return false;
@ -19697,7 +19698,7 @@ namespace basist
m_astc_6x6_intermediate_image_descs.resize(image_count);
memcpy(m_astc_6x6_intermediate_image_descs.data(), pSrc, sizeof(ktx2_astc_hdr_6x6_intermediate_image_desc) * image_count);
memcpy((void *)m_astc_6x6_intermediate_image_descs.data(), pSrc, sizeof(ktx2_astc_hdr_6x6_intermediate_image_desc) * image_count);
// Sanity check the image descs
for (uint32_t i = 0; i < image_count; i++)
@ -19724,9 +19725,9 @@ namespace basist
const uint32_t image_count = basisu::maximum<uint32_t>(m_header.m_layer_count, 1) * m_header.m_face_count * m_header.m_level_count;
assert(image_count);
const uint8_t* pSrc = m_pData + m_header.m_sgd_byte_offset;
const uint8_t* pSrc = m_pData + m_header.m_sgd_byte_offset.get_uint64();
memcpy(&m_etc1s_header, pSrc, sizeof(ktx2_etc1s_global_data_header));
memcpy((void *)&m_etc1s_header, pSrc, sizeof(ktx2_etc1s_global_data_header));
pSrc += sizeof(ktx2_etc1s_global_data_header);
if ((!m_etc1s_header.m_endpoints_byte_length) || (!m_etc1s_header.m_selectors_byte_length) || (!m_etc1s_header.m_tables_byte_length))
@ -19747,7 +19748,7 @@ namespace basist
m_etc1s_header.m_endpoints_byte_length +
m_etc1s_header.m_selectors_byte_length +
m_etc1s_header.m_tables_byte_length +
m_etc1s_header.m_extended_byte_length) > m_header.m_sgd_byte_length)
m_etc1s_header.m_extended_byte_length) > m_header.m_sgd_byte_length.get_uint64())
{
BASISU_DEVEL_ERROR("ktx2_transcoder::decompress_etc1s_global_data: SGD byte length is too small, file is invalid or corrupted\n");
return false;
@ -19759,7 +19760,7 @@ namespace basist
return false;
}
memcpy(m_etc1s_image_descs.data(), pSrc, sizeof(ktx2_etc1s_image_desc) * image_count);
memcpy((void *)m_etc1s_image_descs.data(), pSrc, sizeof(ktx2_etc1s_image_desc) * image_count);
pSrc += sizeof(ktx2_etc1s_image_desc) * image_count;
// Sanity check the ETC1S image descs

View file

@ -254,7 +254,7 @@ namespace basist
void* pOutput_blocks, uint32_t output_blocks_buf_size_in_blocks_or_pixels,
const uint8_t* pCompressed_data, uint32_t compressed_data_length,
uint32_t num_blocks_x, uint32_t num_blocks_y, uint32_t orig_width, uint32_t orig_height, uint32_t level_index,
uint32_t rgb_offset, uint32_t rgb_length, uint32_t alpha_offset, uint32_t alpha_length,
uint64_t rgb_offset, uint32_t rgb_length, uint64_t alpha_offset, uint32_t alpha_length,
uint32_t decode_flags = 0,
bool basis_file_has_alpha_slices = false,
bool is_video = false,
@ -342,7 +342,7 @@ namespace basist
void* pOutput_blocks, uint32_t output_blocks_buf_size_in_blocks_or_pixels,
const uint8_t* pCompressed_data, uint32_t compressed_data_length,
uint32_t num_blocks_x, uint32_t num_blocks_y, uint32_t orig_width, uint32_t orig_height, uint32_t level_index,
uint32_t slice_offset, uint32_t slice_length,
uint64_t slice_offset, uint32_t slice_length,
uint32_t decode_flags = 0,
bool has_alpha = false,
bool is_video = false,
@ -379,7 +379,7 @@ namespace basist
void* pOutput_blocks, uint32_t output_blocks_buf_size_in_blocks_or_pixels,
const uint8_t* pCompressed_data, uint32_t compressed_data_length,
uint32_t num_blocks_x, uint32_t num_blocks_y, uint32_t orig_width, uint32_t orig_height, uint32_t level_index,
uint32_t slice_offset, uint32_t slice_length,
uint64_t slice_offset, uint32_t slice_length,
uint32_t decode_flags = 0,
bool has_alpha = false,
bool is_video = false,
@ -416,7 +416,7 @@ namespace basist
void* pOutput_blocks, uint32_t output_blocks_buf_size_in_blocks_or_pixels,
const uint8_t* pCompressed_data, uint32_t compressed_data_length,
uint32_t num_blocks_x, uint32_t num_blocks_y, uint32_t orig_width, uint32_t orig_height, uint32_t level_index,
uint32_t slice_offset, uint32_t slice_length,
uint64_t slice_offset, uint32_t slice_length,
uint32_t decode_flags = 0,
bool has_alpha = false,
bool is_video = false,
@ -453,7 +453,7 @@ namespace basist
void* pOutput_blocks, uint32_t output_blocks_buf_size_in_blocks_or_pixels,
const uint8_t* pCompressed_data, uint32_t compressed_data_length,
uint32_t num_blocks_x, uint32_t num_blocks_y, uint32_t orig_width, uint32_t orig_height, uint32_t level_index,
uint32_t slice_offset, uint32_t slice_length,
uint64_t slice_offset, uint32_t slice_length,
uint32_t decode_flags = 0,
bool has_alpha = false,
bool is_video = false,