Skip to content

Commit db34073

Browse files
committed
Merge pull request #111445 from akien-mga/basisu-git-2025-10-09
basis_universal: Sync with latest Git to solve more warnings
2 parents 09ea0cf + 845f9f7 commit db34073

23 files changed

+297
-405
lines changed

COPYRIGHT.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ License: Apache-2.0
214214

215215
Files: thirdparty/basis_universal/*
216216
Comment: Basis Universal
217-
Copyright: 2019-2024, Binomial LLC.
217+
Copyright: 2019-2025, Binomial LLC.
218218
License: Apache-2.0
219219

220220
Files: thirdparty/brotli/*

thirdparty/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Files extracted from upstream source:
7474
## basis_universal
7575

7676
- Upstream: https://github.com/BinomialLLC/basis_universal
77-
- Version: 1.60 (323239a6a5ffa57d6570cfc403be99156e33a8b0, 2025)
77+
- Version: git (b1110111d4a93c7dd7de93ce3d9ed8fcdfd114f2, 2025)
7878
- License: Apache 2.0
7979

8080
Files extracted from upstream source:
@@ -88,9 +88,9 @@ Patches:
8888
- `0001-external-zstd-pr344.patch` (GH-73441)
8989
- `0002-external-tinyexr.patch` (GH-97582)
9090
- `0003-remove-tinydds-qoi.patch` (GH-97582)
91-
- `0004-ambiguous-calls.patch` (GH-103968)
92-
- `0005-msvc-include-ctype.patch` (GH-106155)
93-
- `0006-clang-warning-exclude.patch` (GH-111346)
91+
- `0004-clang-warning-exclude.patch` (GH-111346)
92+
- `0005-unused-typedef.patch` (GH-111445)
93+
9494

9595
## brotli
9696

thirdparty/basis_universal/LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright [yyyy] [name of copyright owner]
189+
Copyright 2019-2025 Binomial LLC
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

thirdparty/basis_universal/encoder/3rdparty/android_astc_decomp.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,7 @@ void decodeISETritBlock (ISEDecodedResult* dst, int numValues, BitAccessStream&
837837
deUint32 T7 = data.getNext(1);
838838

839839
#ifndef __EMSCRIPTEN__
840-
#if defined(__GNUC__) && !defined(__clang__)
840+
#ifdef __GNUC__
841841
#pragma GCC diagnostic push
842842
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough="
843843
#endif
@@ -854,7 +854,7 @@ void decodeISETritBlock (ISEDecodedResult* dst, int numValues, BitAccessStream&
854854
DE_ASSERT(false);
855855
}
856856
#ifndef __EMSCRIPTEN__
857-
#if defined(__GNUC__) && !defined(__clang__)
857+
#ifdef __GNUC__
858858
#pragma GCC diagnostic pop
859859
#endif
860860
#endif
@@ -903,7 +903,7 @@ void decodeISEQuintBlock (ISEDecodedResult* dst, int numValues, BitAccessStream&
903903
deUint32 Q56 = data.getNext(2);
904904

905905
#ifndef __EMSCRIPTEN__
906-
#if defined(__GNUC__) && !defined(__clang__)
906+
#ifdef __GNUC__
907907
#pragma GCC diagnostic push
908908
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough="
909909
#endif
@@ -918,7 +918,7 @@ void decodeISEQuintBlock (ISEDecodedResult* dst, int numValues, BitAccessStream&
918918
DE_ASSERT(false);
919919
}
920920
#ifndef __EMSCRIPTEN__
921-
#if defined(__GNUC__) && !defined(__clang__)
921+
#ifdef __GNUC__
922922
#pragma GCC diagnostic pop
923923
#endif
924924
#endif

thirdparty/basis_universal/encoder/basisu_astc_hdr_6x6_enc.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2376,7 +2376,7 @@ static void filter_block(uint32_t grid_x, uint32_t grid_y, const vec3F* pSrc_blo
23762376
// filter columns
23772377
if (grid_y == 6)
23782378
{
2379-
memcpy(pDst_block, temp_block, sizeof(vec3F) * 6 * 6);
2379+
memcpy((void *)pDst_block, temp_block, sizeof(vec3F) * 6 * 6);
23802380
}
23812381
else
23822382
{
@@ -3360,6 +3360,7 @@ static bool pack_bc6h_image(const imagef &src_img, vector2D<basist::bc6h_block>
33603360

33613361
interval_timer tm;
33623362
double total_enc_time = 0.0f;
3363+
BASISU_NOTE_UNUSED(total_enc_time);
33633364

33643365
const uint32_t num_blocks_x = src_img.get_block_width(4);
33653366
const uint32_t num_blocks_y = src_img.get_block_height(4);
@@ -4422,7 +4423,18 @@ static bool compress_strip_task(
44224423
float min_corr = BIG_FLOAT_VAL, max_corr = -BIG_FLOAT_VAL;
44234424
for (uint32_t i = 0; i < 3; i++)
44244425
{
4425-
if (half_comp_stats[i].m_range > 0.0f)
4426+
#if 0
4427+
// 9/5/2025, wrong metric, we're iterating channels pairs here, not individual channels.
4428+
// On 3 active channel blocks this causes no difference.
4429+
if (half_comp_stats[i].m_range > 0.0f)
4430+
#else
4431+
static const uint8_t s_chan_pairs[3][2] = { {0, 1}, {0, 2}, {1, 2} };
4432+
4433+
const uint32_t chanA = s_chan_pairs[i][0];
4434+
const uint32_t chanB = s_chan_pairs[i][1];
4435+
4436+
if ((half_comp_stats[chanA].m_range > 0.0f) && (half_comp_stats[chanB].m_range > 0.0f))
4437+
#endif
44264438
{
44274439
const float c = fabsf((float)half_cross_chan_stats[i].m_pearson);
44284440
min_corr = minimum(min_corr, c);
@@ -4437,7 +4449,7 @@ static bool compress_strip_task(
44374449
// TODO: Transform grayscale axis by covar matrix, compute variance vs. total variance
44384450
const float MODE7_MIN_CHAN_CORR = .5f;
44394451
const float MODE7_PCA_ANGLE_THRESH = .9f;
4440-
use_single_subset_mode7 = is_grayscale || is_solid_block || (min_corr >= MODE7_MIN_CHAN_CORR);
4452+
use_single_subset_mode7 = is_grayscale || is_solid_block || ((total_used_block_chans == 1) || (min_corr >= MODE7_MIN_CHAN_CORR));
44414453

44424454
if (use_single_subset_mode7)
44434455
{

thirdparty/basis_universal/encoder/basisu_astc_hdr_6x6_enc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace astc_6x6_hdr
1616
{
1717
// 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.
1818
// 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.
19-
// 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).
19+
// 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).
2020
// 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).
2121
// 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).
2222
// 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.

thirdparty/basis_universal/encoder/basisu_comp.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3448,15 +3448,15 @@ namespace basisu
34483448
}
34493449
default:
34503450
assert(0);
3451-
fmt_debug_printf("HERE 1\n");
3451+
//fmt_debug_printf("HERE 1\n");
34523452
return false;
34533453
}
34543454

34553455
if (can_use_zstd)
34563456
{
34573457
if ((m_params.m_ktx2_uastc_supercompression != basist::KTX2_SS_NONE) && (m_params.m_ktx2_uastc_supercompression != basist::KTX2_SS_ZSTANDARD))
34583458
{
3459-
fmt_debug_printf("HERE 2\n");
3459+
//fmt_debug_printf("HERE 2\n");
34603460
return false;
34613461
}
34623462
}
@@ -3492,7 +3492,7 @@ namespace basisu
34923492
}
34933493

34943494
basist::ktx2_header header;
3495-
memset(&header, 0, sizeof(header));
3495+
memset((void *)&header, 0, sizeof(header));
34963496

34973497
memcpy(header.m_identifier, basist::g_ktx2_file_identifier, sizeof(basist::g_ktx2_file_identifier));
34983498
header.m_pixel_width = base_width;
@@ -3544,7 +3544,7 @@ namespace basisu
35443544
}
35453545
default:
35463546
assert(0);
3547-
fmt_debug_printf("HERE 3\n");
3547+
//fmt_debug_printf("HERE 3\n");
35483548
return false;
35493549
}
35503550
}
@@ -3584,7 +3584,7 @@ namespace basisu
35843584

35853585
if (ZSTD_isError(result))
35863586
{
3587-
fmt_debug_printf("HERE 5\n");
3587+
//fmt_debug_printf("HERE 5\n");
35883588
return false;
35893589
}
35903590

@@ -3593,7 +3593,7 @@ namespace basisu
35933593
#else
35943594
// Can't get here
35953595
assert(0);
3596-
fmt_debug_printf("HERE 6\n");
3596+
//fmt_debug_printf("HERE 6\n");
35973597
return false;
35983598
#endif
35993599
}
@@ -3618,7 +3618,7 @@ namespace basisu
36183618
etc1s_global_data_header.m_tables_byte_length = backend_output.m_slice_image_tables.size();
36193619

36203620
basisu::vector<basist::ktx2_etc1s_image_desc> etc1s_image_descs(total_levels * total_layers * total_faces);
3621-
memset(etc1s_image_descs.data(), 0, etc1s_image_descs.size_in_bytes());
3621+
memset((void *)etc1s_image_descs.data(), 0, etc1s_image_descs.size_in_bytes());
36223622

36233623
for (uint32_t slice_index = 0; slice_index < m_slice_descs.size(); slice_index++)
36243624
{
@@ -3662,7 +3662,7 @@ namespace basisu
36623662
else if (m_fmt_mode == basist::basis_tex_format::cASTC_HDR_6x6_INTERMEDIATE)
36633663
{
36643664
basisu::vector<basist::ktx2_astc_hdr_6x6_intermediate_image_desc> image_descs(total_levels * total_layers * total_faces);
3665-
memset(image_descs.data(), 0, image_descs.size_in_bytes());
3665+
memset((void *)image_descs.data(), 0, image_descs.size_in_bytes());
36663666

36673667
for (uint32_t slice_index = 0; slice_index < m_slice_descs.size(); slice_index++)
36683668
{
@@ -3717,7 +3717,7 @@ namespace basisu
37173717
uint8_vec dfd;
37183718
if (!get_dfd(dfd, header))
37193719
{
3720-
fmt_debug_printf("HERE 7\n");
3720+
//fmt_debug_printf("HERE 7\n");
37213721
return false;
37223722
}
37233723

@@ -3729,20 +3729,20 @@ namespace basisu
37293729
{
37303730
if (key_values[i].m_key.size() < 2)
37313731
{
3732-
fmt_debug_printf("HERE 8\n");
3732+
//fmt_debug_printf("HERE 8\n");
37333733
return false;
37343734
}
37353735

37363736
if (key_values[i].m_key.back() != 0)
37373737
{
3738-
fmt_debug_printf("HERE 9\n");
3738+
//fmt_debug_printf("HERE 9\n");
37393739
return false;
37403740
}
37413741

37423742
const uint64_t total_len = (uint64_t)key_values[i].m_key.size() + (uint64_t)key_values[i].m_value.size();
37433743
if (total_len >= UINT32_MAX)
37443744
{
3745-
fmt_debug_printf("HERE 10\n");
3745+
//fmt_debug_printf("HERE 10\n");
37463746
return false;
37473747
}
37483748

@@ -3777,7 +3777,7 @@ namespace basisu
37773777
assert(!pass);
37783778
if (pass)
37793779
{
3780-
fmt_debug_printf("HERE 11\n");
3780+
//fmt_debug_printf("HERE 11\n");
37813781
return false;
37823782
}
37833783

@@ -3805,7 +3805,7 @@ namespace basisu
38053805
}
38063806

38073807
basisu::vector<basist::ktx2_level_index> level_index_array(total_levels);
3808-
memset(level_index_array.data(), 0, level_index_array.size_in_bytes());
3808+
memset((void *)level_index_array.data(), 0, level_index_array.size_in_bytes());
38093809

38103810
m_output_ktx2_file.clear();
38113811
m_output_ktx2_file.reserve(m_output_basis_file.size());

thirdparty/basis_universal/encoder/basisu_enc.cpp

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ namespace basisu
651651
}
652652

653653
img.resize(width, height);
654-
memcpy(img.get_ptr(), pMem, width * height * sizeof(float) * 4);
654+
memcpy((void *)img.get_ptr(), pMem, width * height * sizeof(float) * 4);
655655

656656
break;
657657
}
@@ -2236,7 +2236,10 @@ namespace basisu
22362236
debug_printf("job_pool::~job_pool\n");
22372237

22382238
// Notify all workers that they need to die right now.
2239-
m_kill_flag.store(true);
2239+
{
2240+
std::lock_guard<std::mutex> lk(m_mutex);
2241+
m_kill_flag.store(true);
2242+
}
22402243

22412244
m_has_work.notify_all();
22422245

@@ -2326,17 +2329,27 @@ namespace basisu
23262329

23272330
m_num_active_workers.fetch_add(1);
23282331

2329-
while (true)
2332+
while (!m_kill_flag)
23302333
{
23312334
std::unique_lock<std::mutex> lock(m_mutex);
23322335

23332336
// Wait for any jobs to be issued.
2337+
#if 0
23342338
m_has_work.wait(lock, [this] { return m_kill_flag || m_queue.size(); } );
2339+
#else
2340+
// For more safety vs. buggy RTL's. Worse case we stall for a second vs. locking up forever if something goes wrong.
2341+
m_has_work.wait_for(lock, std::chrono::milliseconds(1000), [this] {
2342+
return m_kill_flag || !m_queue.empty();
2343+
});
2344+
#endif
23352345

23362346
// Check to see if we're supposed to exit.
23372347
if (m_kill_flag)
23382348
break;
23392349

2350+
if (m_queue.empty())
2351+
continue;
2352+
23402353
// Get the job and execute it.
23412354
std::function<void()> job(m_queue.back());
23422355
m_queue.pop_back();
@@ -3449,7 +3462,7 @@ namespace basisu
34493462
}
34503463
else
34513464
{
3452-
memcpy(img.get_ptr(), out_rgba, sizeof(float) * 4 * img.get_total_pixels());
3465+
memcpy((void *)img.get_ptr(), out_rgba, static_cast<size_t>(sizeof(float) * 4 * img.get_total_pixels()));
34533466
}
34543467

34553468
free(out_rgba);
@@ -3471,7 +3484,7 @@ namespace basisu
34713484
}
34723485

34733486
img.resize(width, height);
3474-
memcpy(img.get_ptr(), out_rgba, width * height * sizeof(float) * 4);
3487+
memcpy((void *)img.get_ptr(), out_rgba, width * height * sizeof(float) * 4);
34753488
free(out_rgba);
34763489

34773490
return true;

thirdparty/basis_universal/encoder/basisu_enc.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <functional>
2323
#include <thread>
2424
#include <unordered_map>
25+
#include <map>
2526
#include <ostream>
2627

2728
#if !defined(_WIN32) || defined(__MINGW32__)
@@ -2163,17 +2164,24 @@ namespace basisu
21632164
uint32_t max_threads, job_pool *pJob_pool,
21642165
bool even_odd_input_pairs_equal)
21652166
{
2167+
// rg 6/24/2025 - Cross platform determinism
2168+
#if 0
21662169
typedef bit_hasher<typename Quantizer::training_vec_type> training_vec_bit_hasher;
2167-
21682170
typedef std::unordered_map < typename Quantizer::training_vec_type, weighted_block_group,
21692171
training_vec_bit_hasher> group_hash;
2172+
#else
2173+
typedef std::map< typename Quantizer::training_vec_type, weighted_block_group > group_hash;
2174+
#endif
21702175

21712176
//interval_timer tm;
21722177
//tm.start();
21732178

21742179
group_hash unique_vecs;
21752180

2181+
// rg 6/24/2025 - Cross platform determinism
2182+
#if 0
21762183
unique_vecs.reserve(20000);
2184+
#endif
21772185

21782186
weighted_block_group g;
21792187

thirdparty/basis_universal/encoder/basisu_opencl.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131
#include <CL/cl.h>
3232
#endif
3333

34-
#define BASISU_OPENCL_ASSERT_ON_ANY_ERRORS (1)
34+
#ifndef BASISU_OPENCL_ASSERT_ON_ANY_ERRORS
35+
#define BASISU_OPENCL_ASSERT_ON_ANY_ERRORS (0)
36+
#endif
3537

3638
namespace basisu
3739
{

0 commit comments

Comments
 (0)