@@ -326,10 +326,10 @@ struct partition_info
326
326
uint8_t partition_texel_count[BLOCK_MAX_PARTITIONS];
327
327
328
328
/* * @brief The partition of each texel in the block. */
329
- uint8_t partition_of_texel[BLOCK_MAX_TEXELS];
329
+ ASTCENC_ALIGNAS uint8_t partition_of_texel[BLOCK_MAX_TEXELS];
330
330
331
331
/* * @brief The list of texels in each partition. */
332
- uint8_t texels_of_partition[BLOCK_MAX_PARTITIONS][BLOCK_MAX_TEXELS];
332
+ ASTCENC_ALIGNAS uint8_t texels_of_partition[BLOCK_MAX_PARTITIONS][BLOCK_MAX_TEXELS];
333
333
};
334
334
335
335
/* *
@@ -367,19 +367,19 @@ struct decimation_info
367
367
* @brief The number of weights that contribute to each texel.
368
368
* Value is between 1 and 4.
369
369
*/
370
- uint8_t texel_weight_count[BLOCK_MAX_TEXELS];
370
+ ASTCENC_ALIGNAS uint8_t texel_weight_count[BLOCK_MAX_TEXELS];
371
371
372
372
/* *
373
373
* @brief The weight index of the N weights that are interpolated for each texel.
374
374
* Stored transposed to improve vectorization.
375
375
*/
376
- uint8_t texel_weights_tr[4 ][BLOCK_MAX_TEXELS];
376
+ ASTCENC_ALIGNAS uint8_t texel_weights_tr[4 ][BLOCK_MAX_TEXELS];
377
377
378
378
/* *
379
379
* @brief The bilinear contribution of the N weights that are interpolated for each texel.
380
380
* Value is between 0 and 16, stored transposed to improve vectorization.
381
381
*/
382
- uint8_t texel_weight_contribs_int_tr[4 ][BLOCK_MAX_TEXELS];
382
+ ASTCENC_ALIGNAS uint8_t texel_weight_contribs_int_tr[4 ][BLOCK_MAX_TEXELS];
383
383
384
384
/* *
385
385
* @brief The bilinear contribution of the N weights that are interpolated for each texel.
@@ -388,13 +388,13 @@ struct decimation_info
388
388
ASTCENC_ALIGNAS float texel_weight_contribs_float_tr[4 ][BLOCK_MAX_TEXELS];
389
389
390
390
/* * @brief The number of texels that each stored weight contributes to. */
391
- uint8_t weight_texel_count[BLOCK_MAX_WEIGHTS];
391
+ ASTCENC_ALIGNAS uint8_t weight_texel_count[BLOCK_MAX_WEIGHTS];
392
392
393
393
/* *
394
394
* @brief The list of texels that use a specific weight index.
395
395
* Stored transposed to improve vectorization.
396
396
*/
397
- uint8_t weight_texels_tr[BLOCK_MAX_TEXELS][BLOCK_MAX_WEIGHTS];
397
+ ASTCENC_ALIGNAS uint8_t weight_texels_tr[BLOCK_MAX_TEXELS][BLOCK_MAX_WEIGHTS];
398
398
399
399
/* *
400
400
* @brief The bilinear contribution to the N texels that use each weight.
@@ -732,24 +732,28 @@ struct block_size_descriptor
732
732
*
733
733
* The @c data_[rgba] fields store the image data in an encoded SoA float form designed for easy
734
734
* vectorization. Input data is converted to float and stored as values between 0 and 65535. LDR
735
- * data is stored as direct UNORM data, HDR data is stored as LNS data.
735
+ * data is stored as direct UNORM data, HDR data is stored as LNS data. They are allocated SIMD
736
+ * elements over-size to allow vectorized stores of unaligned and partial SIMD lanes (e.g. in a
737
+ * 6x6x6 block the final row write will read elements 210-217 (vec8) or 214-217 (vec4), which is
738
+ * two elements above the last real data element). The overspill values are never written to memory,
739
+ * and would be benign, but the padding avoids hitting undefined behavior.
736
740
*
737
741
* The @c rgb_lns and @c alpha_lns fields that assigned a per-texel use of HDR are only used during
738
742
* decompression. The current compressor will always use HDR endpoint formats when in HDR mode.
739
743
*/
740
744
struct image_block
741
745
{
742
746
/* * @brief The input (compress) or output (decompress) data for the red color component. */
743
- ASTCENC_ALIGNAS float data_r[BLOCK_MAX_TEXELS];
747
+ ASTCENC_ALIGNAS float data_r[BLOCK_MAX_TEXELS + ASTCENC_SIMD_WIDTH - 1 ];
744
748
745
749
/* * @brief The input (compress) or output (decompress) data for the green color component. */
746
- ASTCENC_ALIGNAS float data_g[BLOCK_MAX_TEXELS];
750
+ ASTCENC_ALIGNAS float data_g[BLOCK_MAX_TEXELS + ASTCENC_SIMD_WIDTH - 1 ];
747
751
748
752
/* * @brief The input (compress) or output (decompress) data for the blue color component. */
749
- ASTCENC_ALIGNAS float data_b[BLOCK_MAX_TEXELS];
753
+ ASTCENC_ALIGNAS float data_b[BLOCK_MAX_TEXELS + ASTCENC_SIMD_WIDTH - 1 ];
750
754
751
755
/* * @brief The input (compress) or output (decompress) data for the alpha color component. */
752
- ASTCENC_ALIGNAS float data_a[BLOCK_MAX_TEXELS];
756
+ ASTCENC_ALIGNAS float data_a[BLOCK_MAX_TEXELS + ASTCENC_SIMD_WIDTH - 1 ];
753
757
754
758
/* * @brief The number of texels in the block. */
755
759
uint8_t texel_count;
@@ -957,7 +961,7 @@ struct ASTCENC_ALIGNAS compression_working_buffers
957
961
*
958
962
* For two planes, second plane starts at @c WEIGHTS_PLANE2_OFFSET offsets.
959
963
*/
960
- uint8_t dec_weights_uquant[WEIGHTS_MAX_BLOCK_MODES * BLOCK_MAX_WEIGHTS];
964
+ ASTCENC_ALIGNAS uint8_t dec_weights_uquant[WEIGHTS_MAX_BLOCK_MODES * BLOCK_MAX_WEIGHTS];
961
965
962
966
/* * @brief Error of the best encoding combination for each block mode. */
963
967
ASTCENC_ALIGNAS float errors_of_best_combination[WEIGHTS_MAX_BLOCK_MODES];
@@ -1111,7 +1115,7 @@ struct symbolic_compressed_block
1111
1115
*
1112
1116
* If dual plane, the second plane starts at @c weights[WEIGHTS_PLANE2_OFFSET].
1113
1117
*/
1114
- uint8_t weights[BLOCK_MAX_WEIGHTS];
1118
+ ASTCENC_ALIGNAS uint8_t weights[BLOCK_MAX_WEIGHTS];
1115
1119
1116
1120
/* *
1117
1121
* @brief Get the weight quantization used by this block mode.
0 commit comments