Skip to content

Commit 8ea0299

Browse files
committed
Shrink types and reorder the BSD
1 parent b555fed commit 8ea0299

4 files changed

Lines changed: 15 additions & 21 deletions

File tree

Source/astcenc_block_sizes.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,6 @@ static void assign_kmeans_texels(
720720
bsd.kmeans_texels[i] = i;
721721
}
722722

723-
bsd.kmeans_texel_count = bsd.texel_count;
724723
return;
725724
}
726725

@@ -747,8 +746,6 @@ static void assign_kmeans_texels(
747746
seen[texel] = true;
748747
}
749748
}
750-
751-
bsd.kmeans_texel_count = BLOCK_MAX_KMEANS_TEXELS;
752749
}
753750

754751
/**

Source/astcenc_find_best_partitioning.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ static void compute_kmeans_partition_ordering(
453453

454454
// Construct the block bitmaps of texel assignments to each partition
455455
uint64_t bitmaps[BLOCK_MAX_PARTITIONS] { 0 };
456-
unsigned int texels_to_process = bsd.kmeans_texel_count;
456+
unsigned int texels_to_process = astc::min(bsd.texel_count, BLOCK_MAX_KMEANS_TEXELS);
457457
promise(texels_to_process > 0);
458458
for (unsigned int i = 0; i < texels_to_process; i++)
459459
{

Source/astcenc_internal.h

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ static constexpr unsigned int BLOCK_MAX_PARTITIONINGS { 1024 };
7979
static constexpr unsigned int BLOCK_MAX_TEXELS { 216 };
8080

8181
/** @brief The maximum number of weights used during partition selection for texel clustering. */
82-
static constexpr unsigned int BLOCK_MAX_KMEANS_TEXELS { 64 };
82+
static constexpr uint8_t BLOCK_MAX_KMEANS_TEXELS { 64 };
8383

8484
/** @brief The maximum number of weights a block can support. */
8585
static constexpr unsigned int BLOCK_MAX_WEIGHTS { 64 };
@@ -514,8 +514,8 @@ struct decimation_info
514514
*/
515515
struct block_mode
516516
{
517-
int16_t mode_index;
518-
int8_t decimation_mode;
517+
uint16_t mode_index;
518+
uint8_t decimation_mode;
519519
uint8_t quant_mode;
520520
uint8_t is_dual_plane : 1;
521521
uint8_t percentile_hit : 1;
@@ -560,44 +560,41 @@ struct decimation_mode
560560
struct block_size_descriptor
561561
{
562562
/** @brief The block X dimension, in texels. */
563-
unsigned int xdim;
563+
uint8_t xdim;
564564

565565
/** @brief The block Y dimension, in texels. */
566-
unsigned int ydim;
566+
uint8_t ydim;
567567

568568
/** @brief The block Z dimension, in texels. */
569-
unsigned int zdim;
569+
uint8_t zdim;
570570

571571
/** @brief The block total texel count. */
572-
unsigned int texel_count;
572+
uint8_t texel_count;
573573

574574
/** @brief The number of stored decimation modes. */
575575
unsigned int decimation_mode_count;
576576

577+
/** @brief The number of stored block modes. */
578+
unsigned int block_mode_count;
579+
577580
/** @brief The active decimation modes, stored in low indices. */
578581
decimation_mode decimation_modes[WEIGHTS_MAX_DECIMATION_MODES];
579582

580583
/** @brief The active decimation tables, stored in low indices. */
581584
const decimation_info *decimation_tables[WEIGHTS_MAX_DECIMATION_MODES];
582585

583-
/** @brief The number of stored block modes. */
584-
unsigned int block_mode_count;
585-
586586
/** @brief The packed block mode array index, or @c BLOCK_BAD_BLOCK_MODE if not active. */
587587
uint16_t block_mode_packed_index[WEIGHTS_MAX_BLOCK_MODES];
588588

589589
/** @brief The active block modes, stored in low indices. */
590590
block_mode block_modes[WEIGHTS_MAX_BLOCK_MODES];
591591

592-
/** @brief The texel count for k-means partition selection. */
593-
unsigned int kmeans_texel_count;
594-
595-
/** @brief The active texels for k-means partition selection. */
596-
unsigned int kmeans_texels[BLOCK_MAX_KMEANS_TEXELS];
597-
598592
/** @brief The partion tables for all of the possible partitions. */
599593
partition_info partitions[(3 * BLOCK_MAX_PARTITIONINGS) + 1];
600594

595+
/** @brief The active texels for k-means partition selection. */
596+
uint8_t kmeans_texels[BLOCK_MAX_KMEANS_TEXELS];
597+
601598
/**
602599
* @brief Get the block mode structure for index @c block_mode.
603600
*

Source/astcenc_partition_tables.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ static void generate_one_partition_info_entry(
348348
pi.coverage_bitmaps[i] = 0ULL;
349349
}
350350

351-
unsigned int texels_to_process = bsd.kmeans_texel_count;
351+
unsigned int texels_to_process = astc::min(bsd.texel_count, BLOCK_MAX_KMEANS_TEXELS);
352352
for (unsigned int i = 0; i < texels_to_process; i++)
353353
{
354354
unsigned int idx = bsd.kmeans_texels[i];

0 commit comments

Comments
 (0)