Skip to content

Switch to size_t part 2 #557

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions Source/astcenc_block_sizes.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: Apache-2.0
// ----------------------------------------------------------------------------
// Copyright 2011-2023 Arm Limited
// Copyright 2011-2025 Arm Limited
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy
Expand Down Expand Up @@ -384,12 +384,12 @@ static void init_decimation_info_2d(
}

// Initialize array tail so we can over-fetch with SIMD later to avoid loop tails
unsigned int texels_per_block_simd = round_up_to_simd_multiple_vla(texels_per_block);
for (unsigned int i = texels_per_block; i < texels_per_block_simd; i++)
size_t texels_per_block_simd = round_up_to_simd_multiple_vla(texels_per_block);
for (size_t i = texels_per_block; i < texels_per_block_simd; i++)
{
di.texel_weight_count[i] = 0;

for (unsigned int j = 0; j < 4; j++)
for (size_t j = 0; j < 4; j++)
{
di.texel_weight_contribs_float_tr[j][i] = 0;
di.texel_weights_tr[j][i] = 0;
Expand All @@ -402,12 +402,12 @@ static void init_decimation_info_2d(
unsigned int last_texel_count_wt = wb.texel_count_of_weight[weights_per_block - 1];
uint8_t last_texel = di.weight_texels_tr[last_texel_count_wt - 1][weights_per_block - 1];

unsigned int weights_per_block_simd = round_up_to_simd_multiple_vla(weights_per_block);
for (unsigned int i = weights_per_block; i < weights_per_block_simd; i++)
size_t weights_per_block_simd = round_up_to_simd_multiple_vla(weights_per_block);
for (size_t i = weights_per_block; i < weights_per_block_simd; i++)
{
di.weight_texel_count[i] = 0;

for (unsigned int j = 0; j < max_texel_count_of_weight; j++)
for (size_t j = 0; j < max_texel_count_of_weight; j++)
{
di.weight_texels_tr[j][i] = last_texel;
di.weights_texel_contribs_tr[j][i] = 0.0f;
Expand Down Expand Up @@ -640,12 +640,12 @@ static void init_decimation_info_3d(
}

// Initialize array tail so we can over-fetch with SIMD later to avoid loop tails
unsigned int texels_per_block_simd = round_up_to_simd_multiple_vla(texels_per_block);
for (unsigned int i = texels_per_block; i < texels_per_block_simd; i++)
size_t texels_per_block_simd = round_up_to_simd_multiple_vla(texels_per_block);
for (size_t i = texels_per_block; i < texels_per_block_simd; i++)
{
di.texel_weight_count[i] = 0;

for (unsigned int j = 0; j < 4; j++)
for (size_t j = 0; j < 4; j++)
{
di.texel_weight_contribs_float_tr[j][i] = 0;
di.texel_weights_tr[j][i] = 0;
Expand All @@ -658,12 +658,12 @@ static void init_decimation_info_3d(
int last_texel_count_wt = wb.texel_count_of_weight[weights_per_block - 1];
uint8_t last_texel = di.weight_texels_tr[last_texel_count_wt - 1][weights_per_block - 1];

unsigned int weights_per_block_simd = round_up_to_simd_multiple_vla(weights_per_block);
for (unsigned int i = weights_per_block; i < weights_per_block_simd; i++)
size_t weights_per_block_simd = round_up_to_simd_multiple_vla(weights_per_block);
for (size_t i = weights_per_block; i < weights_per_block_simd; i++)
{
di.weight_texel_count[i] = 0;

for (int j = 0; j < max_texel_count_of_weight; j++)
for (size_t j = 0; j < max_texel_count_of_weight; j++)
{
di.weight_texels_tr[j][i] = last_texel;
di.weights_texel_contribs_tr[j][i] = 0.0f;
Expand Down
16 changes: 8 additions & 8 deletions Source/astcenc_ideal_endpoints_and_weights.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ static void compute_ideal_colors_and_weights_1_comp(
}

// Zero initialize any SIMD over-fetch
unsigned int texel_count_simd = round_up_to_simd_multiple_vla(texel_count);
for (unsigned int i = texel_count; i < texel_count_simd; i++)
size_t texel_count_simd = round_up_to_simd_multiple_vla(texel_count);
for (size_t i = texel_count; i < texel_count_simd; i++)
{
ei.weights[i] = 0.0f;
ei.weight_error_scale[i] = 0.0f;
Expand Down Expand Up @@ -333,8 +333,8 @@ static void compute_ideal_colors_and_weights_2_comp(
}

// Zero initialize any SIMD over-fetch
unsigned int texel_count_simd = round_up_to_simd_multiple_vla(texel_count);
for (unsigned int i = texel_count; i < texel_count_simd; i++)
size_t texel_count_simd = round_up_to_simd_multiple_vla(texel_count);
for (size_t i = texel_count; i < texel_count_simd; i++)
{
ei.weights[i] = 0.0f;
ei.weight_error_scale[i] = 0.0f;
Expand Down Expand Up @@ -500,8 +500,8 @@ static void compute_ideal_colors_and_weights_3_comp(
}

// Zero initialize any SIMD over-fetch
unsigned int texel_count_simd = round_up_to_simd_multiple_vla(texel_count);
for (unsigned int i = texel_count; i < texel_count_simd; i++)
size_t texel_count_simd = round_up_to_simd_multiple_vla(texel_count);
for (size_t i = texel_count; i < texel_count_simd; i++)
{
ei.weights[i] = 0.0f;
ei.weight_error_scale[i] = 0.0f;
Expand Down Expand Up @@ -598,8 +598,8 @@ static void compute_ideal_colors_and_weights_4_comp(
}

// Zero initialize any SIMD over-fetch
unsigned int texel_count_simd = round_up_to_simd_multiple_vla(texel_count);
for (unsigned int i = texel_count; i < texel_count_simd; i++)
size_t texel_count_simd = round_up_to_simd_multiple_vla(texel_count);
for (size_t i = texel_count; i < texel_count_simd; i++)
{
ei.weights[i] = 0.0f;
ei.weight_error_scale[i] = 0.0f;
Expand Down
6 changes: 3 additions & 3 deletions Source/astcenc_partition_tables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,9 @@ static bool generate_one_partition_info_entry(
// Fill loop tail so we can overfetch later
for (unsigned int i = 0; i < partition_count; i++)
{
int ptex_count = counts[i];
int ptex_count_simd = round_up_to_simd_multiple_vla(ptex_count);
for (int j = ptex_count; j < ptex_count_simd; j++)
size_t ptex_count = counts[i];
size_t ptex_count_simd = round_up_to_simd_multiple_vla(ptex_count);
for (size_t j = ptex_count; j < ptex_count_simd; j++)
{
pi.texels_of_partition[i][j] = pi.texels_of_partition[i][ptex_count - 1];
}
Expand Down
4 changes: 2 additions & 2 deletions Source/astcenc_pick_best_endpoint_format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1135,13 +1135,13 @@ unsigned int compute_ideal_endpoint_formats(
vfloat clear_error(ERROR_CALC_DEFAULT);
vint clear_quant(0);

unsigned int packed_start_block_mode = round_down_to_simd_multiple_vla(start_block_mode);
size_t packed_start_block_mode = round_down_to_simd_multiple_vla(start_block_mode);
storea(clear_error, errors_of_best_combination + packed_start_block_mode);
store_nbytes(clear_quant, best_quant_levels + packed_start_block_mode);
store_nbytes(clear_quant, best_quant_levels_mod + packed_start_block_mode);

// Ensure that last iteration overstep contains data that will never be picked
unsigned int packed_end_block_mode = round_down_to_simd_multiple_vla(end_block_mode - 1);
size_t packed_end_block_mode = round_down_to_simd_multiple_vla(end_block_mode - 1);
storea(clear_error, errors_of_best_combination + packed_end_block_mode);
store_nbytes(clear_quant, best_quant_levels + packed_end_block_mode);
store_nbytes(clear_quant, best_quant_levels_mod + packed_end_block_mode);
Expand Down
34 changes: 5 additions & 29 deletions Source/astcenc_vecmathlib.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: Apache-2.0
// ----------------------------------------------------------------------------
// Copyright 2019-2024 Arm Limited
// Copyright 2019-2025 Arm Limited
// Copyright 2008 Jose Fonseca
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
Expand Down Expand Up @@ -211,30 +211,6 @@ template<typename T> T gatherf_byte_inds(const float* base, const uint8_t* indic
constexpr auto load1 = vfloat4::load1;
#endif

/**
* @brief Round a count down to the largest multiple of 8.
*
* @param count The unrounded value.
*
* @return The rounded value.
*/
ASTCENC_SIMD_INLINE unsigned int round_down_to_simd_multiple_8(unsigned int count)
{
return count & static_cast<unsigned int>(~(8 - 1));
}

/**
* @brief Round a count down to the largest multiple of 4.
*
* @param count The unrounded value.
*
* @return The rounded value.
*/
ASTCENC_SIMD_INLINE unsigned int round_down_to_simd_multiple_4(unsigned int count)
{
return count & static_cast<unsigned int>(~(4 - 1));
}

/**
* @brief Round a count down to the largest multiple of the SIMD width.
*
Expand All @@ -244,9 +220,9 @@ ASTCENC_SIMD_INLINE unsigned int round_down_to_simd_multiple_4(unsigned int coun
*
* @return The rounded value.
*/
ASTCENC_SIMD_INLINE unsigned int round_down_to_simd_multiple_vla(unsigned int count)
ASTCENC_SIMD_INLINE size_t round_down_to_simd_multiple_vla(size_t count)
{
return count & static_cast<unsigned int>(~(ASTCENC_SIMD_WIDTH - 1));
return count & static_cast<size_t>(~(ASTCENC_SIMD_WIDTH - 1));
}

/**
Expand All @@ -258,9 +234,9 @@ ASTCENC_SIMD_INLINE unsigned int round_down_to_simd_multiple_vla(unsigned int co
*
* @return The rounded value.
*/
ASTCENC_SIMD_INLINE unsigned int round_up_to_simd_multiple_vla(unsigned int count)
ASTCENC_SIMD_INLINE size_t round_up_to_simd_multiple_vla(size_t count)
{
unsigned int multiples = (count + ASTCENC_SIMD_WIDTH - 1) / ASTCENC_SIMD_WIDTH;
size_t multiples = (count + ASTCENC_SIMD_WIDTH - 1) / ASTCENC_SIMD_WIDTH;
return multiples * ASTCENC_SIMD_WIDTH;
}

Expand Down