Skip to content

Commit bb89ab4

Browse files
committed
Fix MSVC compiler warnings
1 parent 421af16 commit bb89ab4

7 files changed

+49
-12
lines changed

Source/astcenc_averages_and_directions.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ static void compute_partition_averages_rgb(
6868
{
6969
vint texel_partition(pi.partition_of_texel + i);
7070

71-
vmask lane_mask = lane_id < vint(texel_count);
71+
vmask lane_mask = lane_id < vint_from_size(texel_count);
7272
lane_id += vint(ASTCENC_SIMD_WIDTH);
7373

7474
vmask p0_mask = lane_mask & (texel_partition == vint(0));
@@ -104,7 +104,7 @@ static void compute_partition_averages_rgb(
104104
{
105105
vint texel_partition(pi.partition_of_texel + i);
106106

107-
vmask lane_mask = lane_id < vint(texel_count);
107+
vmask lane_mask = lane_id < vint_from_size(texel_count);
108108
lane_id += vint(ASTCENC_SIMD_WIDTH);
109109

110110
vmask p0_mask = lane_mask & (texel_partition == vint(0));
@@ -149,7 +149,7 @@ static void compute_partition_averages_rgb(
149149
{
150150
vint texel_partition(pi.partition_of_texel + i);
151151

152-
vmask lane_mask = lane_id < vint(texel_count);
152+
vmask lane_mask = lane_id < vint_from_size(texel_count);
153153
lane_id += vint(ASTCENC_SIMD_WIDTH);
154154

155155
vmask p0_mask = lane_mask & (texel_partition == vint(0));
@@ -239,7 +239,7 @@ static void compute_partition_averages_rgba(
239239
{
240240
vint texel_partition(pi.partition_of_texel + i);
241241

242-
vmask lane_mask = lane_id < vint(texel_count);
242+
vmask lane_mask = lane_id < vint_from_size(texel_count);
243243
lane_id += vint(ASTCENC_SIMD_WIDTH);
244244

245245
vmask p0_mask = lane_mask & (texel_partition == vint(0));
@@ -279,7 +279,7 @@ static void compute_partition_averages_rgba(
279279
{
280280
vint texel_partition(pi.partition_of_texel + i);
281281

282-
vmask lane_mask = lane_id < vint(texel_count);
282+
vmask lane_mask = lane_id < vint_from_size(texel_count);
283283
lane_id += vint(ASTCENC_SIMD_WIDTH);
284284

285285
vmask p0_mask = lane_mask & (texel_partition == vint(0));
@@ -330,7 +330,7 @@ static void compute_partition_averages_rgba(
330330
{
331331
vint texel_partition(pi.partition_of_texel + i);
332332

333-
vmask lane_mask = lane_id < vint(texel_count);
333+
vmask lane_mask = lane_id < vint_from_size(texel_count);
334334
lane_id += vint(ASTCENC_SIMD_WIDTH);
335335

336336
vmask p0_mask = lane_mask & (texel_partition == vint(0));
@@ -777,7 +777,7 @@ void compute_error_squared_rgba(
777777
vint lane_ids = vint::lane_id();
778778
for (size_t i = 0; i < texel_count; i += ASTCENC_SIMD_WIDTH)
779779
{
780-
vmask mask = lane_ids < vint(texel_count);
780+
vmask mask = lane_ids < vint_from_size(texel_count);
781781
const uint8_t* texel_idxs = texel_indexes + i;
782782

783783
vfloat data_r = gatherf_byte_inds<vfloat>(blk.data_r, texel_idxs);
@@ -891,7 +891,7 @@ void compute_error_squared_rgb(
891891
vint lane_ids = vint::lane_id();
892892
for (size_t i = 0; i < texel_count; i += ASTCENC_SIMD_WIDTH)
893893
{
894-
vmask mask = lane_ids < vint(texel_count);
894+
vmask mask = lane_ids < vint_from_size(texel_count);
895895
const uint8_t* texel_idxs = texel_indexes + i;
896896

897897
vfloat data_r = gatherf_byte_inds<vfloat>(blk.data_r, texel_idxs);

Source/astcenc_pick_best_endpoint_format.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: Apache-2.0
22
// ----------------------------------------------------------------------------
3-
// Copyright 2011-2024 Arm Limited
3+
// Copyright 2011-2025 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
@@ -1292,9 +1292,12 @@ unsigned int compute_ideal_endpoint_formats(
12921292
vint vbest_error_index(-1);
12931293
vfloat vbest_ep_error(ERROR_CALC_DEFAULT);
12941294

1295-
start_block_mode = round_down_to_simd_multiple_vla(start_block_mode);
1296-
vint lane_ids = vint::lane_id() + vint(start_block_mode);
1297-
for (unsigned int j = start_block_mode; j < end_block_mode; j += ASTCENC_SIMD_WIDTH)
1295+
// TODO: This should use size_t for the inputs of start/end_block_mode
1296+
// to avoid some of this type conversion, but that propagates and will
1297+
// need a bigger PR to fix
1298+
size_t start_mode = round_down_to_simd_multiple_vla(start_block_mode);
1299+
vint lane_ids = vint::lane_id() + vint_from_size(start_mode);
1300+
for (size_t j = start_mode; j < end_block_mode; j += ASTCENC_SIMD_WIDTH)
12981301
{
12991302
vfloat err = vfloat(errors_of_best_combination + j);
13001303
vmask mask = err < vbest_ep_error;

Source/astcenc_vecmathlib.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ template<typename T> T gatherf_byte_inds(const float* base, const uint8_t* indic
104104

105105
constexpr auto loada = vfloat8::loada;
106106
constexpr auto load1 = vfloat8::load1;
107+
constexpr auto vint_from_size = vint8_from_size;
107108

108109
#elif ASTCENC_SSE >= 20
109110
// If we have SSE expose 4-wide VLA, and 4-wide fixed width.
@@ -123,6 +124,7 @@ template<typename T> T gatherf_byte_inds(const float* base, const uint8_t* indic
123124

124125
constexpr auto loada = vfloat4::loada;
125126
constexpr auto load1 = vfloat4::load1;
127+
constexpr auto vint_from_size = vint4_from_size;
126128

127129
#elif ASTCENC_SVE == 8
128130
// Check the compiler is configured with fixed-length 256-bit SVE.
@@ -154,6 +156,7 @@ template<typename T> T gatherf_byte_inds(const float* base, const uint8_t* indic
154156

155157
constexpr auto loada = vfloat8::loada;
156158
constexpr auto load1 = vfloat8::load1;
159+
constexpr auto vint_from_size = vint8_from_size;
157160

158161
#elif ASTCENC_NEON > 0
159162
// If we have NEON expose 4-wide VLA.
@@ -173,6 +176,7 @@ template<typename T> T gatherf_byte_inds(const float* base, const uint8_t* indic
173176

174177
constexpr auto loada = vfloat4::loada;
175178
constexpr auto load1 = vfloat4::load1;
179+
constexpr auto vint_from_size = vint4_from_size;
176180

177181
#else
178182
// If we have nothing expose 4-wide VLA, and 4-wide fixed width.
@@ -209,6 +213,7 @@ template<typename T> T gatherf_byte_inds(const float* base, const uint8_t* indic
209213

210214
constexpr auto loada = vfloat4::loada;
211215
constexpr auto load1 = vfloat4::load1;
216+
constexpr auto vint_from_size = vint4_from_size;
212217
#endif
213218

214219
/**

Source/astcenc_vecmathlib_avx2_8.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,15 @@ ASTCENC_SIMD_INLINE int hmax_s(vint8 a)
497497
return _mm256_cvtsi256_si32(hmax(a).m);
498498
}
499499

500+
/**
501+
* @brief Generate a vint8 from a size_t.
502+
*/
503+
ASTCENC_SIMD_INLINE vint8 vint8_from_size(size_t a)
504+
{
505+
assert(a <= std::numeric_limits<int>::max());
506+
return vint8(static_cast<int>(a));
507+
}
508+
500509
/**
501510
* @brief Store a vector to a 16B aligned memory address.
502511
*/

Source/astcenc_vecmathlib_common_4.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#endif
3232

3333
#include <cstdio>
34+
#include <limits>
3435

3536
// ============================================================================
3637
// vint4 operators and functions
@@ -117,6 +118,15 @@ ASTCENC_SIMD_INLINE int hmin_s(vint4 a)
117118
return hmin(a).lane<0>();
118119
}
119120

121+
/**
122+
* @brief Generate a vint4 from a size_t.
123+
*/
124+
ASTCENC_SIMD_INLINE vint4 vint4_from_size(size_t a)
125+
{
126+
assert(a <= std::numeric_limits<int>::max());
127+
return vint4(static_cast<int>(a));
128+
}
129+
120130
/**
121131
* @brief Return the horizontal maximum of a vector.
122132
*/

Source/astcenc_vecmathlib_sve_8.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,15 @@ ASTCENC_SIMD_INLINE int hmax_s(vint8 a)
485485
return svmaxv_s32(svptrue_b32(), a.m);
486486
}
487487

488+
/**
489+
* @brief Generate a vint8 from a size_t.
490+
*/
491+
ASTCENC_SIMD_INLINE vint8 vint8_from_size(size_t a)
492+
{
493+
assert(a <= std::numeric_limits<int>::max());
494+
return vint8(static_cast<int>(a));
495+
}
496+
488497
/**
489498
* @brief Store a vector to a 16B aligned memory address.
490499
*/

Source/cmake_core.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ macro(astcenc_set_properties ASTCENC_TARGET_NAME ASTCENC_VENEER_TYPE)
164164

165165
# MSVC compiler defines
166166
$<${is_msvc_fe}:/EHsc>
167+
$<${is_msvc_fe}:/WX>
167168
$<${is_msvccl}:/wd4324>
168169

169170
# G++ and Clang++ compiler defines

0 commit comments

Comments
 (0)