11// SPDX-License-Identifier: Apache-2.0
22// ----------------------------------------------------------------------------
3- // Copyright 2011-2025 Arm Limited
3+ // Copyright 2011-2026 Arm Limited
44//
55// Licensed under the Apache License, Version 2.0 (the "License"); you may not
66// use this file except in compliance with the License. You may obtain a copy
@@ -260,7 +260,9 @@ static void init_decimation_info_2d(
260260 unsigned int texels_per_block = x_texels * y_texels;
261261 unsigned int weights_per_block = x_weights * y_weights;
262262
263+ #if !defined(ASTCENC_DECOMPRESS_ONLY)
263264 uint8_t max_texel_count_of_weight = 0 ;
265+ #endif
264266
265267 promise (weights_per_block > 0 );
266268 promise (texels_per_block > 0 );
@@ -316,7 +318,9 @@ static void init_decimation_info_2d(
316318 wb.texels_of_weight [qweight[i]][wb.texel_count_of_weight [qweight[i]]] = static_cast <uint8_t >(texel);
317319 wb.texel_weights_of_weight [qweight[i]][wb.texel_count_of_weight [qweight[i]]] = static_cast <uint8_t >(weight[i]);
318320 wb.texel_count_of_weight [qweight[i]]++;
321+ #if !defined(ASTCENC_DECOMPRESS_ONLY)
319322 max_texel_count_of_weight = astc::max (max_texel_count_of_weight, wb.texel_count_of_weight [qweight[i]]);
323+ #endif
320324 }
321325 }
322326 }
@@ -331,21 +335,26 @@ static void init_decimation_info_2d(
331335 for (unsigned int j = 0 ; j < wb.weight_count_of_texel [i]; j++)
332336 {
333337 di.texel_weight_contribs_int_tr [j][i] = wb.weights_of_texel [i][j];
338+ #if !defined(ASTCENC_DECOMPRESS_ONLY)
334339 di.texel_weight_contribs_float_tr [j][i] = static_cast <float >(wb.weights_of_texel [i][j]) * (1 .0f / WEIGHTS_TEXEL_SUM);
340+ #endif
335341 di.texel_weights_tr [j][i] = wb.grid_weights_of_texel [i][j];
336342 }
337343
338344 // Init all 4 entries so we can rely on zeros for vectorization
339345 for (unsigned int j = wb.weight_count_of_texel [i]; j < 4 ; j++)
340346 {
341347 di.texel_weight_contribs_int_tr [j][i] = 0 ;
348+ #if !defined(ASTCENC_DECOMPRESS_ONLY)
342349 di.texel_weight_contribs_float_tr [j][i] = 0 .0f ;
350+ #endif
343351 di.texel_weights_tr [j][i] = 0 ;
344352 }
345353 }
346354
347355 di.max_texel_weight_count = max_texel_weight_count;
348356
357+ #if !defined(ASTCENC_DECOMPRESS_ONLY)
349358 for (unsigned int i = 0 ; i < weights_per_block; i++)
350359 {
351360 unsigned int texel_count_wt = wb.texel_count_of_weight [i];
@@ -382,6 +391,7 @@ static void init_decimation_info_2d(
382391 di.weights_texel_contribs_tr [j][i] = 0 .0f ;
383392 }
384393 }
394+ #endif
385395
386396 // Initialize array tail so we can over-fetch with SIMD later to avoid loop tails
387397 size_t texels_per_block_simd = round_up_to_simd_multiple_vla (texels_per_block);
@@ -391,12 +401,15 @@ static void init_decimation_info_2d(
391401
392402 for (size_t j = 0 ; j < 4 ; j++)
393403 {
404+ #if !defined(ASTCENC_DECOMPRESS_ONLY)
394405 di.texel_weight_contribs_float_tr [j][i] = 0 ;
406+ #endif
395407 di.texel_weights_tr [j][i] = 0 ;
396408 di.texel_weight_contribs_int_tr [j][i] = 0 ;
397409 }
398410 }
399411
412+ #if !defined(ASTCENC_DECOMPRESS_ONLY)
400413 // Initialize array tail so we can over-fetch with SIMD later to avoid loop tails
401414 // Match last texel in active lane in SIMD group, for better gathers
402415 unsigned int last_texel_count_wt = wb.texel_count_of_weight [weights_per_block - 1 ];
@@ -413,6 +426,7 @@ static void init_decimation_info_2d(
413426 di.weights_texel_contribs_tr [j][i] = 0 .0f ;
414427 }
415428 }
429+ #endif
416430
417431 di.texel_count = static_cast <uint8_t >(texels_per_block);
418432 di.weight_count = static_cast <uint8_t >(weights_per_block);
@@ -446,7 +460,9 @@ static void init_decimation_info_3d(
446460 unsigned int texels_per_block = x_texels * y_texels * z_texels;
447461 unsigned int weights_per_block = x_weights * y_weights * z_weights;
448462
463+ #if !defined(ASTCENC_DECOMPRESS_ONLY)
449464 uint8_t max_texel_count_of_weight = 0 ;
465+ #endif
450466
451467 promise (weights_per_block > 0 );
452468 promise (texels_per_block > 0 );
@@ -571,7 +587,9 @@ static void init_decimation_info_3d(
571587 wb.texels_of_weight [qweight[i]][wb.texel_count_of_weight [qweight[i]]] = static_cast <uint8_t >(texel);
572588 wb.texel_weights_of_weight [qweight[i]][wb.texel_count_of_weight [qweight[i]]] = static_cast <uint8_t >(weight[i]);
573589 wb.texel_count_of_weight [qweight[i]]++;
590+ #if !defined(ASTCENC_DECOMPRESS_ONLY)
574591 max_texel_count_of_weight = astc::max (max_texel_count_of_weight, wb.texel_count_of_weight [qweight[i]]);
592+ #endif
575593 }
576594 }
577595 }
@@ -588,20 +606,25 @@ static void init_decimation_info_3d(
588606 for (unsigned int j = 0 ; j < 4 ; j++)
589607 {
590608 di.texel_weight_contribs_int_tr [j][i] = 0 ;
609+ #if !defined(ASTCENC_DECOMPRESS_ONLY)
591610 di.texel_weight_contribs_float_tr [j][i] = 0 .0f ;
611+ #endif
592612 di.texel_weights_tr [j][i] = 0 ;
593613 }
594614
595615 for (unsigned int j = 0 ; j < wb.weight_count_of_texel [i]; j++)
596616 {
597617 di.texel_weight_contribs_int_tr [j][i] = wb.weights_of_texel [i][j];
618+ #if !defined(ASTCENC_DECOMPRESS_ONLY)
598619 di.texel_weight_contribs_float_tr [j][i] = static_cast <float >(wb.weights_of_texel [i][j]) * (1 .0f / WEIGHTS_TEXEL_SUM);
620+ #endif
599621 di.texel_weights_tr [j][i] = wb.grid_weights_of_texel [i][j];
600622 }
601623 }
602624
603625 di.max_texel_weight_count = max_texel_weight_count;
604626
627+ #if !defined(ASTCENC_DECOMPRESS_ONLY)
605628 for (unsigned int i = 0 ; i < weights_per_block; i++)
606629 {
607630 unsigned int texel_count_wt = wb.texel_count_of_weight [i];
@@ -638,6 +661,7 @@ static void init_decimation_info_3d(
638661 di.weights_texel_contribs_tr [j][i] = 0 .0f ;
639662 }
640663 }
664+ #endif
641665
642666 // Initialize array tail so we can over-fetch with SIMD later to avoid loop tails
643667 size_t texels_per_block_simd = round_up_to_simd_multiple_vla (texels_per_block);
@@ -647,12 +671,15 @@ static void init_decimation_info_3d(
647671
648672 for (size_t j = 0 ; j < 4 ; j++)
649673 {
674+ #if !defined(ASTCENC_DECOMPRESS_ONLY)
650675 di.texel_weight_contribs_float_tr [j][i] = 0 ;
676+ #endif
651677 di.texel_weights_tr [j][i] = 0 ;
652678 di.texel_weight_contribs_int_tr [j][i] = 0 ;
653679 }
654680 }
655681
682+ #if !defined(ASTCENC_DECOMPRESS_ONLY)
656683 // Initialize array tail so we can over-fetch with SIMD later to avoid loop tails
657684 // Match last texel in active lane in SIMD group, for better gathers
658685 int last_texel_count_wt = wb.texel_count_of_weight [weights_per_block - 1 ];
@@ -669,6 +696,7 @@ static void init_decimation_info_3d(
669696 di.weights_texel_contribs_tr [j][i] = 0 .0f ;
670697 }
671698 }
699+ #endif
672700
673701 di.texel_count = static_cast <uint8_t >(texels_per_block);
674702 di.weight_count = static_cast <uint8_t >(weights_per_block);
0 commit comments