Commit 3121585a by Alexis Hetu Committed by Alexis Hétu

ASTC Decoder: Trim unused struct members

A few struct members were only ever written to and never read, which means these were encoder only struct members. Since we only need the ASTC decoder, these encoder only struct members were removed. The gains in memory allocation sizes are substantial: block_size_descriptor Initial size: 3469056 B (~3.3 MB) After this cl: 693168 B (~677 kB) decimation_table Initial size: 364896 B (~356 kB) After this cl: 1948 B (~1.9 kB) Change-Id: Id86c993331d2602a1106f6aaa729d1047e2ebc27 Tests: dEQP-VK.*astc* Bug: b/150130101 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/46128 Presubmit-Ready: Alexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Kokoro-Result: kokoro <noreply+kokoro@google.com> Tested-by: 's avatarAlexis Hétu <sugoi@google.com>
parent 5d4c9817
...@@ -56,7 +56,6 @@ swiftshader_source_set("Device") { ...@@ -56,7 +56,6 @@ swiftshader_source_set("Device") {
"../../third_party/astc-encoder/Source/astc_mathlib.cpp", "../../third_party/astc-encoder/Source/astc_mathlib.cpp",
"../../third_party/astc-encoder/Source/astc_mathlib_softfloat.cpp", "../../third_party/astc-encoder/Source/astc_mathlib_softfloat.cpp",
"../../third_party/astc-encoder/Source/astc_partition_tables.cpp", "../../third_party/astc-encoder/Source/astc_partition_tables.cpp",
"../../third_party/astc-encoder/Source/astc_percentile_tables.cpp",
"../../third_party/astc-encoder/Source/astc_quantization.cpp", "../../third_party/astc-encoder/Source/astc_quantization.cpp",
"../../third_party/astc-encoder/Source/astc_symbolic_physical.cpp", "../../third_party/astc-encoder/Source/astc_symbolic_physical.cpp",
"../../third_party/astc-encoder/Source/astc_weight_quant_xfer_tables.cpp", "../../third_party/astc-encoder/Source/astc_weight_quant_xfer_tables.cpp",
......
...@@ -28,7 +28,6 @@ set(ASTC_ENCODER_SRC_FILES ...@@ -28,7 +28,6 @@ set(ASTC_ENCODER_SRC_FILES
Source/astc_mathlib.h Source/astc_mathlib.h
Source/astc_mathlib_softfloat.cpp Source/astc_mathlib_softfloat.cpp
Source/astc_partition_tables.cpp Source/astc_partition_tables.cpp
Source/astc_percentile_tables.cpp
Source/astc_quantization.cpp Source/astc_quantization.cpp
Source/astc_symbolic_physical.cpp Source/astc_symbolic_physical.cpp
Source/astc_weight_quant_xfer_tables.cpp Source/astc_weight_quant_xfer_tables.cpp
......
...@@ -64,10 +64,7 @@ enum astc_decode_mode ...@@ -64,10 +64,7 @@ enum astc_decode_mode
struct partition_info struct partition_info
{ {
int partition_count; int partition_count;
uint8_t texels_per_partition[4];
uint8_t partition_of_texel[MAX_TEXELS_PER_BLOCK]; uint8_t partition_of_texel[MAX_TEXELS_PER_BLOCK];
uint8_t texels_of_partition[4][MAX_TEXELS_PER_BLOCK];
uint64_t coverage_bitmaps[4];
}; };
/* /*
...@@ -80,22 +77,10 @@ struct partition_info ...@@ -80,22 +77,10 @@ struct partition_info
*/ */
struct decimation_table struct decimation_table
{ {
int num_texels;
int num_weights; int num_weights;
uint8_t texel_num_weights[MAX_TEXELS_PER_BLOCK]; // number of indices that go into the calculation for a texel uint8_t texel_num_weights[MAX_TEXELS_PER_BLOCK]; // number of indices that go into the calculation for a texel
uint8_t texel_weights_int[MAX_TEXELS_PER_BLOCK][4]; // the weight to assign to each weight uint8_t texel_weights_int[MAX_TEXELS_PER_BLOCK][4]; // the weight to assign to each weight
float texel_weights_float[MAX_TEXELS_PER_BLOCK][4]; // the weight to assign to each weight
uint8_t texel_weights[MAX_TEXELS_PER_BLOCK][4]; // the weights that go into a texel calculation uint8_t texel_weights[MAX_TEXELS_PER_BLOCK][4]; // the weights that go into a texel calculation
uint8_t weight_num_texels[MAX_WEIGHTS_PER_BLOCK]; // the number of texels that a given weight contributes to
uint8_t weight_texel[MAX_WEIGHTS_PER_BLOCK][MAX_TEXELS_PER_BLOCK]; // the texels that the weight contributes to
uint8_t weights_int[MAX_WEIGHTS_PER_BLOCK][MAX_TEXELS_PER_BLOCK]; // the weights that the weight contributes to a texel.
float weights_flt[MAX_WEIGHTS_PER_BLOCK][MAX_TEXELS_PER_BLOCK]; // the weights that the weight contributes to a texel.
// folded data structures:
// * texel_weights_texel[i][j] = texel_weights[weight_texel[i][j]];
// * texel_weights_float_texel[i][j] = texel_weights_float[weight_texel[i][j]
uint8_t texel_weights_texel[MAX_WEIGHTS_PER_BLOCK][MAX_TEXELS_PER_BLOCK][4];
float texel_weights_float_texel[MAX_WEIGHTS_PER_BLOCK][MAX_TEXELS_PER_BLOCK][4];
}; };
/* /*
...@@ -106,9 +91,7 @@ struct block_mode ...@@ -106,9 +91,7 @@ struct block_mode
int8_t decimation_mode; int8_t decimation_mode;
int8_t quantization_mode; int8_t quantization_mode;
int8_t is_dual_plane; int8_t is_dual_plane;
int8_t permit_encode;
int8_t permit_decode; int8_t permit_decode;
float percentile;
}; };
struct block_size_descriptor struct block_size_descriptor
...@@ -119,20 +102,9 @@ struct block_size_descriptor ...@@ -119,20 +102,9 @@ struct block_size_descriptor
int texel_count; int texel_count;
int decimation_mode_count; int decimation_mode_count;
int decimation_mode_samples[MAX_DECIMATION_MODES];
int decimation_mode_maxprec_1plane[MAX_DECIMATION_MODES];
int decimation_mode_maxprec_2planes[MAX_DECIMATION_MODES];
float decimation_mode_percentile[MAX_DECIMATION_MODES];
int permit_encode[MAX_DECIMATION_MODES];
const decimation_table *decimation_tables[MAX_DECIMATION_MODES]; const decimation_table *decimation_tables[MAX_DECIMATION_MODES];
block_mode block_modes[MAX_WEIGHT_MODES]; block_mode block_modes[MAX_WEIGHT_MODES];
// for the k-means bed bitmap partitioning algorithm, we don't
// want to consider more than 64 texels; this array specifies
// which 64 texels (if that many) to consider.
int texelcount_for_bitmap_partitioning;
int texels_for_bitmap_partitioning[64];
// All the partitioning information for this block size // All the partitioning information for this block size
partition_info partitions[(3*PARTITION_COUNT)+1]; partition_info partitions[(3*PARTITION_COUNT)+1];
}; };
...@@ -217,25 +189,8 @@ enum quantization_method ...@@ -217,25 +189,8 @@ enum quantization_method
*/ */
struct quantization_and_transfer_table struct quantization_and_transfer_table
{ {
/** The quantization level used */
quantization_method method;
/** The unscrambled unquantized value. */
// TODO: Converted to floats to support AVX gathers
float unquantized_value_unsc[33];
/** The scrambling order: value[map[i]] == value_unsc[i] */
// TODO: Converted to u32 to support AVX gathers
int32_t scramble_map[32];
/** The scrambled unquantized values. */ /** The scrambled unquantized values. */
uint8_t unquantized_value[32]; uint8_t unquantized_value[32];
/**
* An encoded table of previous-and-next weight values, indexed by the
* current unquantized value.
* * bits 7:0 = previous-index, unquantized
* * bits 15:8 = next-index, unquantized
* * bits 23:16 = previous-index, quantized
* * bits 31:24 = next-index, quantized
*/
uint32_t prev_next_values[65];
}; };
extern const quantization_and_transfer_table quant_and_xfer_tables[12]; extern const quantization_and_transfer_table quant_and_xfer_tables[12];
...@@ -327,23 +282,6 @@ static inline const partition_info *get_partition_table( ...@@ -327,23 +282,6 @@ static inline const partition_info *get_partition_table(
return bsd->partitions + index; return bsd->partitions + index;
} }
/**
* @brief Get the percentile table for 2D block modes.
*
* This is an empirically determined prioritization of which block modes to
* use in the search in terms of their centile (lower centiles = more useful).
*
* Returns a dynamically allocated array; caller must free with delete[].
*
* @param xdim The block x size.
* @param ydim The block y size.
*
* @return The unpacked table.
*/
const float *get_2d_percentile_table(
int xdim,
int ydim);
// *********************************************************** // ***********************************************************
// functions and data pertaining to quantization and encoding // functions and data pertaining to quantization and encoding
// ********************************************************** // **********************************************************
......
...@@ -249,12 +249,9 @@ static void generate_one_partition_table( ...@@ -249,12 +249,9 @@ static void generate_one_partition_table(
for (i = 0; i < texels_per_block; i++) for (i = 0; i < texels_per_block; i++)
{ {
int partition = pt->partition_of_texel[i]; int partition = pt->partition_of_texel[i];
pt->texels_of_partition[partition][counts[partition]++] = i; counts[partition]++;
} }
for (i = 0; i < 4; i++)
pt->texels_per_partition[i] = counts[i];
if (counts[0] == 0) if (counts[0] == 0)
pt->partition_count = 0; pt->partition_count = 0;
else if (counts[1] == 0) else if (counts[1] == 0)
...@@ -265,16 +262,6 @@ static void generate_one_partition_table( ...@@ -265,16 +262,6 @@ static void generate_one_partition_table(
pt->partition_count = 3; pt->partition_count = 3;
else else
pt->partition_count = 4; pt->partition_count = 4;
for (i = 0; i < 4; i++)
pt->coverage_bitmaps[i] = 0ULL;
int texels_to_process = bsd->texelcount_for_bitmap_partitioning;
for (i = 0; i < texels_to_process; i++)
{
int idx = bsd->texels_for_bitmap_partitioning[i];
pt->coverage_bitmaps[pt->partition_of_texel[idx]] |= 1ULL << i;
}
} }
/* Public function, see header file for detailed documentation */ /* Public function, see header file for detailed documentation */
......
...@@ -26,142 +26,53 @@ ...@@ -26,142 +26,53 @@
const quantization_and_transfer_table quant_and_xfer_tables[12] = { const quantization_and_transfer_table quant_and_xfer_tables[12] = {
// quantization method 0, range 0..1 // quantization method 0, range 0..1
{ {
QUANT_2,
{0, 64, 255},
{0, 1},
{0, 64}, {0, 64},
{0x01004000,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,
_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,
0x01004000}
}, },
// quantization method 1, range 0..2 // quantization method 1, range 0..2
{ {
QUANT_3,
{0, 32, 64, 255},
{0, 1, 2},
{0, 32, 64}, {0, 32, 64},
{0x01002000,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,
_,_,0x02004000,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,
_,_,_,_,0x02014020}
}, },
// quantization method 2, range 0..3 // quantization method 2, range 0..3
{ {
QUANT_4,
{0, 21, 43, 64, 255},
{0, 1, 2, 3},
{0, 21, 43, 64}, {0, 21, 43, 64},
{0x01001500,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,0x02002b00,_,_,_,_,
_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,0x03014015,_,_,_,_,_,_,_,_,_,_,_,_,
_,_,_,_,_,_,_,_,0x0302402b}
}, },
// quantization method 3, range 0..4 // quantization method 3, range 0..4
{ {
QUANT_5,
{0, 16, 32, 48, 64, 255},
{0, 1, 2, 3, 4},
{0, 16, 32, 48, 64}, {0, 16, 32, 48, 64},
{0x01001000,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,0x02002000,_,_,_,_,_,_,_,_,_,
_,_,_,_,_,_,0x03013010,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,0x04024020,_,_,_,
_,_,_,_,_,_,_,_,_,_,_,_,0x04034030}
}, },
// quantization method 4, range 0..5 // quantization method 4, range 0..5
{ {
QUANT_6,
{0, 12, 25, 39, 52, 64, 255},
{0, 2, 4, 5, 3, 1},
{0, 64, 12, 52, 25, 39}, {0, 64, 12, 52, 25, 39},
{0x02000c00,_,_,_,_,_,_,_,_,_,_,_,0x04001900,_,_,_,_,_,_,_,_,_,_,_,_,
0x0502270c,_,_,_,_,_,_,_,_,_,_,_,_,_,0x03043419,_,_,_,_,_,_,_,_,_,_,
_,_,0x01054027,_,_,_,_,_,_,_,_,_,_,_,0x01034034}
}, },
// quantization method 5, range 0..7 // quantization method 5, range 0..7
{ {
QUANT_8,
{0, 9, 18, 27, 37, 46, 55, 64, 255},
{0, 1, 2, 3, 4, 5, 6, 7},
{0, 9, 18, 27, 37, 46, 55, 64}, {0, 9, 18, 27, 37, 46, 55, 64},
{0x01000900,_,_,_,_,_,_,_,_,0x02001200,_,_,_,_,_,_,_,_,0x03011b09,_,_,
_,_,_,_,_,_,0x04022512,_,_,_,_,_,_,_,_,_,0x05032e1b,_,_,_,_,_,_,_,_,
0x06043725,_,_,_,_,_,_,_,_,0x0705402e,_,_,_,_,_,_,_,_,0x07064037}
}, },
// quantization method 6, range 0..9 // quantization method 6, range 0..9
{ {
QUANT_10,
{0, 7, 14, 21, 28, 36, 43, 50, 57, 64, 255},
{0, 2, 4, 6, 8, 9, 7, 5, 3, 1},
{0, 64, 7, 57, 14, 50, 21, 43, 28, 36}, {0, 64, 7, 57, 14, 50, 21, 43, 28, 36},
{0x02000700,_,_,_,_,_,_,0x04000e00,_,_,_,_,_,_,0x06021507,_,_,_,_,_,_,
0x08041c0e,_,_,_,_,_,_,0x09062415,_,_,_,_,_,_,_,0x07082b1c,_,_,_,_,_,
_,0x05093224,_,_,_,_,_,_,0x0307392b,_,_,_,_,_,_,0x01054032,_,_,_,_,_,
_,0x01034039}
}, },
// quantization method 7, range 0..11 // quantization method 7, range 0..11
{ {
QUANT_12,
{0, 5, 11, 17, 23, 28, 36, 41, 47, 53, 59, 64, 255},
{0, 4, 8, 2, 6, 10, 11, 7, 3, 9, 5, 1},
{0, 64, 17, 47, 5, 59, 23, 41, 11, 53, 28, 36}, {0, 64, 17, 47, 5, 59, 23, 41, 11, 53, 28, 36},
{0x04000500,_,_,_,_,0x08000b00,_,_,_,_,_,0x02041105,_,_,_,_,_,
0x0608170b,_,_,_,_,_,0x0a021c11,_,_,_,_,0x0b062417,_,_,_,_,_,_,_,
0x070a291c,_,_,_,_,0x030b2f24,_,_,_,_,_,0x09073529,_,_,_,_,_,
0x05033b2f,_,_,_,_,_,0x01094035,_,_,_,_,0x0105403b}
}, },
// quantization method 8, range 0..15 // quantization method 8, range 0..15
{ {
QUANT_16,
{0, 4, 8, 12, 17, 21, 25, 29, 35, 39, 43, 47, 52, 56, 60, 64, 255},
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
{0, 4, 8, 12, 17, 21, 25, 29, 35, 39, 43, 47, 52, 56, 60, 64}, {0, 4, 8, 12, 17, 21, 25, 29, 35, 39, 43, 47, 52, 56, 60, 64},
{0x01000400,_,_,_,0x02000800,_,_,_,0x03010c04,_,_,_,0x04021108,_,_,_,_,
0x0503150c,_,_,_,0x06041911,_,_,_,0x07051d15,_,_,_,0x08062319,_,_,_,_,
_,0x0907271d,_,_,_,0x0a082b23,_,_,_,0x0b092f27,_,_,_,0x0c0a342b,_,_,_,
_,0x0d0b382f,_,_,_,0x0e0c3c34,_,_,_,0x0f0d4038,_,_,_,0x0f0e403c}
}, },
// quantization method 9, range 0..19 // quantization method 9, range 0..19
{ {
QUANT_20,
{0, 3, 6, 9, 13, 16, 19, 23, 26, 29, 35, 38, 41, 45, 48, 51, 55, 58,
61, 64, 255},
{0, 4, 8, 12, 16, 2, 6, 10, 14, 18, 19, 15, 11, 7, 3, 17, 13, 9, 5, 1},
{0, 64, 16, 48, 3, 61, 19, 45, 6, 58, 23, 41, 9, 55, 26, 38, 13, 51, {0, 64, 16, 48, 3, 61, 19, 45, 6, 58, 23, 41, 9, 55, 26, 38, 13, 51,
29, 35}, 29, 35},
{0x04000300,_,_,0x08000600,_,_,0x0c040903,_,_,0x10080d06,_,_,_,
0x020c1009,_,_,0x0610130d,_,_,0x0a021710,_,_,_,0x0e061a13,_,_,
0x120a1d17,_,_,0x130e231a,_,_,_,_,_,0x0f12261d,_,_,0x0b132923,_,_,
0x070f2d26,_,_,_,0x030b3029,_,_,0x1107332d,_,_,0x0d033730,_,_,_,
0x09113a33,_,_,0x050d3d37,_,_,0x0109403a,_,_,0x0105403d}
}, },
// quantization method 10, range 0..23 // quantization method 10, range 0..23
{ {
QUANT_24,
{0, 2, 5, 8, 11, 13, 16, 19, 22, 24, 27, 30, 34, 37, 40, 42, 45, 48,
51, 53, 56, 59, 62, 64, 255},
{0, 8, 16, 2, 10, 18, 4, 12, 20, 6, 14, 22, 23, 15, 7, 21, 13, 5, 19,
11, 3, 17, 9, 1},
{0, 64, 8, 56, 16, 48, 24, 40, 2, 62, 11, 53, 19, 45, 27, 37, 5, 59, {0, 64, 8, 56, 16, 48, 24, 40, 2, 62, 11, 53, 19, 45, 27, 37, 5, 59,
13, 51, 22, 42, 30, 34}, 13, 51, 22, 42, 30, 34},
{0x08000200,_,0x10000500,_,_,0x02080802,_,_,0x0a100b05,_,_,0x12020d08,
_,0x040a100b,_,_,0x0c12130d,_,_,0x14041610,_,_,0x060c1813,_,
0x0e141b16,_,_,0x16061e18,_,_,0x170e221b,_,_,_,0x0f16251e,_,_,
0x07172822,_,_,0x150f2a25,_,0x0d072d28,_,_,0x0515302a,_,_,0x130d332d,
_,_,0x0b053530,_,0x03133833,_,_,0x110b3b35,_,_,0x09033e38,_,_,
0x0111403b,_,0x0109403e}
}, },
// quantization method 11, range 0..31 // quantization method 11, range 0..31
{ {
QUANT_32,
{0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 34, 36, 38,
40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 255},
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31},
{0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 34, 36, 38, {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 34, 36, 38,
40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64}, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64},
{0x01000200,_,0x02000400,_,0x03010602,_,0x04020804,_,0x05030a06,_,
0x06040c08,_,0x07050e0a,_,0x0806100c,_,0x0907120e,_,0x0a081410,_,
0x0b091612,_,0x0c0a1814,_,0x0d0b1a16,_,0x0e0c1c18,_,0x0f0d1e1a,_,
0x100e221c,_,_,_,0x110f241e,_,0x12102622,_,0x13112824,_,0x14122a26,_,
0x15132c28,_,0x16142e2a,_,0x1715302c,_,0x1816322e,_,0x19173430,_,
0x1a183632,_,0x1b193834,_,0x1c1a3a36,_,0x1d1b3c38,_,0x1e1c3e3a,_,
0x1f1d403c,_,0x1f1e403e}
} }
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment