author
int64
658
755k
date
stringlengths
19
19
timezone
int64
-46,800
43.2k
hash
stringlengths
40
40
message
stringlengths
5
490
mods
list
language
stringclasses
20 values
license
stringclasses
3 values
repo
stringlengths
5
68
original_message
stringlengths
12
491
61,745
17.02.2021 08:45:26
0
5093cb983e995d7ad8fd9db9fdd9adedec03ada5
Use selects in compute_avgs_and_dirs
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_averages_and_directions.cpp", "new_path": "Source/astcenc_averages_and_directions.cpp", "diff": "@@ -83,25 +83,19 @@ void compute_averages_and_directions_rgba(\nvfloat4 texel_datum = blk->texel(iwt);\ntexel_datum = (texel_datum - average) * weight;\n- if (texel_datum.lane<0>() > 0.0f)\n- {\n- sum_xp = sum_xp + texel_datum;\n- }\n+ vfloat4 zero = vfloat4::zero();\n- if (texel_datum.lane<1>() > 0.0f)\n- {\n- sum_yp = sum_yp + texel_datum;\n- }\n+ vmask4 tdm0 = vfloat4(texel_datum.lane<0>()) > zero;\n+ sum_xp = sum_xp + select(zero, texel_datum, tdm0);\n- if (texel_datum.lane<2>() > 0.0f)\n- {\n- sum_zp = sum_zp + texel_datum;\n- }\n+ vmask4 tdm1 = vfloat4(texel_datum.lane<1>()) > zero;\n+ sum_yp = sum_yp + select(zero, texel_datum, tdm1);\n- if (texel_datum.lane<3>() > 0.0f)\n- {\n- sum_wp = sum_wp + texel_datum;\n- }\n+ vmask4 tdm2 = vfloat4(texel_datum.lane<2>()) > zero;\n+ sum_zp = sum_zp + select(zero, texel_datum, tdm2);\n+\n+ vmask4 tdm3 = vfloat4(texel_datum.lane<3>()) > zero;\n+ sum_wp = sum_wp + select(zero, texel_datum, tdm3);\n}\nfloat prod_xp = dot_s(sum_xp, sum_xp);\n@@ -143,9 +137,9 @@ void compute_averages_and_directions_3_components(\nvfloat4* directions\n) {\nconst float *texel_weights;\n- const float* data_vr;\n- const float* data_vg;\n- const float* data_vb;\n+ const float* data_vr = blk->data_r;\n+ const float* data_vg = blk->data_g;\n+ const float* data_vb = blk->data_b;\nif (omitted_component == 0)\n{\n@@ -157,24 +151,18 @@ void compute_averages_and_directions_3_components(\nelse if (omitted_component == 1)\n{\ntexel_weights = ewb->texel_weight_rba;\n- data_vr = blk->data_r;\ndata_vg = blk->data_b;\ndata_vb = blk->data_a;\n}\nelse if (omitted_component == 2)\n{\ntexel_weights = ewb->texel_weight_rga;\n- data_vr = blk->data_r;\n- data_vg = blk->data_g;\ndata_vb = blk->data_a;\n}\nelse\n{\nassert(omitted_component == 3);\ntexel_weights = ewb->texel_weight_rgb;\n- data_vr = blk->data_r;\n- data_vg = blk->data_g;\n- data_vb = blk->data_b;\n}\nint partition_count = pt->partition_count;\n@@ -222,20 +210,16 @@ void compute_averages_and_directions_3_components(\n0.0f);\ntexel_datum = (texel_datum - average) * weight;\n- if (texel_datum.lane<0>() > 0.0f)\n- {\n- sum_xp = sum_xp + texel_datum;\n- }\n+ vfloat4 zero = vfloat4::zero();\n- if (texel_datum.lane<1>() > 0.0f)\n- {\n- sum_yp = sum_yp + texel_datum;\n- }\n+ vmask4 tdm0 = vfloat4(texel_datum.lane<0>()) > zero;\n+ sum_xp = sum_xp + select(zero, texel_datum, tdm0);\n- if (texel_datum.lane<2>() > 0.0f)\n- {\n- sum_zp = sum_zp + texel_datum;\n- }\n+ vmask4 tdm1 = vfloat4(texel_datum.lane<1>()) > zero;\n+ sum_yp = sum_yp + select(zero, texel_datum, tdm1);\n+\n+ vmask4 tdm2 = vfloat4(texel_datum.lane<2>()) > zero;\n+ sum_zp = sum_zp + select(zero, texel_datum, tdm2);\n}\nfloat prod_xp = dot3_s(sum_xp, sum_xp);\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -572,7 +572,9 @@ void imageblock_initialize_orig_from_work(\nstruct error_weight_block\n{\nvfloat4 error_weights[MAX_TEXELS_PER_BLOCK];\n+\nfloat texel_weight[MAX_TEXELS_PER_BLOCK];\n+\nfloat texel_weight_gba[MAX_TEXELS_PER_BLOCK];\nfloat texel_weight_rba[MAX_TEXELS_PER_BLOCK];\nfloat texel_weight_rga[MAX_TEXELS_PER_BLOCK];\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Use selects in compute_avgs_and_dirs
61,745
17.02.2021 09:01:23
0
68c63b4fe6ff78daf79ddcbec4d5af6f617bb113
Use swizzle in hdr endpoint encoding
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_color_quantize.cpp", "new_path": "Source/astcenc_color_quantize.cpp", "diff": "@@ -886,10 +886,10 @@ static void quantize_hdr_rgbo3(\nswitch (majcomp)\n{\ncase 1:\n- color = vfloat4(color.lane<1>(), color.lane<0>(), color.lane<2>(), color.lane<3>());\n+ color = color.swz<1, 0, 2, 3>();\nbreak;\ncase 2:\n- color = vfloat4(color.lane<2>(), color.lane<1>(), color.lane<0>(), color.lane<3>());\n+ color = color.swz<2, 1, 0, 3>();\nbreak;\ndefault:\nbreak;\n@@ -1208,12 +1208,12 @@ static void quantize_hdr_rgb3(\nswitch (majcomp)\n{\ncase 1: // red-green swap\n- color0 = vfloat4(color0.lane<1>(), color0.lane<0>(), color0.lane<2>(), color0.lane<3>());\n- color1 = vfloat4(color1.lane<1>(), color1.lane<0>(), color1.lane<2>(), color1.lane<3>());\n+ color0 = color0.swz<1, 0, 2, 3>();\n+ color1 = color1.swz<1, 0, 2, 3>();\nbreak;\ncase 2: // red-blue swap\n- color0 = vfloat4(color0.lane<2>(), color0.lane<1>(), color0.lane<0>(), color0.lane<3>());\n- color1 = vfloat4(color1.lane<2>(), color1.lane<1>(), color1.lane<0>(), color1.lane<3>());\n+ color0 = color0.swz<2, 1, 0, 3>();\n+ color1 = color1.swz<2, 1, 0, 3>();\nbreak;\ndefault:\nbreak;\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Use swizzle in hdr endpoint encoding
61,745
17.02.2021 09:06:34
0
7aaa54c095c251baf0cc8976094104b4f1a1e1f4
Branch cleanup in hdr_rgb_unpack3
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_color_unquantize.cpp", "new_path": "Source/astcenc_color_unquantize.cpp", "diff": "@@ -511,23 +511,28 @@ static void hdr_rgb_unpack3(\nc |= bit2 << 7;\nif (ohmod & 0x5B)\n+ {\nb0 |= bit0 << 6;\n- if (ohmod & 0x5B)\nb1 |= bit1 << 6;\n+ }\nif (ohmod & 0x12)\n+ {\nb0 |= bit2 << 7;\n- if (ohmod & 0x12)\nb1 |= bit3 << 7;\n+ }\nif (ohmod & 0xAF)\n+ {\nd0 |= bit4 << 5;\n- if (ohmod & 0xAF)\nd1 |= bit5 << 5;\n+ }\n+\nif (ohmod & 0x5)\n+ {\nd0 |= bit2 << 6;\n- if (ohmod & 0x5)\nd1 |= bit3 << 6;\n+ }\n// sign-extend 'd0' and 'd1'\n// note: this code assumes that signed right-shift actually sign-fills, not zero-fills.\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Branch cleanup in hdr_rgb_unpack3
61,745
17.02.2021 20:39:37
0
48d58ffa4525d1e08db556a7d67985c93b1af300
Simplify in compute_endpoints_and_ideal_weights
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "diff": "@@ -226,23 +226,20 @@ static void compute_endpoints_and_ideal_weights_2_components(\nfor (int i = 0; i < partition_count; i++)\n{\n- float2 egv = directions[i];\n- if (egv.r + egv.g < 0.0f)\n+ float2 dir = directions[i];\n+ if (dir.r + dir.g < 0.0f)\n{\n- directions[i] = float2(0.0f) - egv;\n- }\n+ dir = float2(0.0f) - dir;\n}\n- for (int i = 0; i < partition_count; i++)\n- {\nlines[i].a = averages[i];\n- if (dot(directions[i], directions[i]) == 0.0f)\n+ if (dot(dir, dir) == 0.0f)\n{\nlines[i].b = normalize(float2(1.0f));\n}\nelse\n{\n- lines[i].b = normalize(directions[i]);\n+ lines[i].b = normalize(dir);\n}\n}\n@@ -421,23 +418,20 @@ static void compute_endpoints_and_ideal_weights_3_components(\nfor (int i = 0; i < partition_count; i++)\n{\n- vfloat4 direc = directions[i];\n- if (hadd_rgb_s(direc) < 0.0f)\n+ vfloat4 dir = directions[i];\n+ if (hadd_rgb_s(dir) < 0.0f)\n{\n- directions[i] = vfloat4(0.0f) - direc;\n- }\n+ dir = vfloat4(0.0f) - dir;\n}\n- for (int i = 0; i < partition_count; i++)\n- {\nlines[i].a = averages[i];\n- if (dot3_s(directions[i], directions[i]) == 0.0f)\n+ if (dot3_s(dir, dir) == 0.0f)\n{\nlines[i].b = normalize(vfloat4(1.0f, 1.0f, 1.0f, 0.0f));\n}\nelse\n{\n- lines[i].b = normalize(directions[i]);\n+ lines[i].b = normalize(dir);\n}\n}\n@@ -564,20 +558,20 @@ static void compute_endpoints_and_ideal_weights_rgba(\n// this will make the first endpoint the darkest one.\nfor (int i = 0; i < partition_count; i++)\n{\n- vfloat4 direc = directions_rgba[i];\n- if (hadd_rgb_s(direc) < 0.0f)\n+ vfloat4 dir = directions_rgba[i];\n+ if (hadd_rgb_s(dir) < 0.0f)\n{\n- directions_rgba[i] = vfloat4::zero() - direc;\n+ dir = vfloat4::zero() - dir;\n}\nlines[i].a = averages[i];\n- if (dot_s(directions_rgba[i], directions_rgba[i]) == 0.0f)\n+ if (dot_s(dir, dir) == 0.0f)\n{\nlines[i].b = normalize(vfloat4(1.0f));\n}\nelse\n{\n- lines[i].b = normalize(directions_rgba[i]);\n+ lines[i].b = normalize(dir);\n}\n}\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Simplify in compute_endpoints_and_ideal_weights
61,745
18.02.2021 08:29:09
0
874bbcc3d51bdc8d9bf678dad89ca6cdc10a0f0c
Tune -thorough: more refinement fewer parts/bmodes
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_entry.cpp", "new_path": "Source/astcenc_entry.cpp", "diff": "@@ -120,7 +120,7 @@ static const std::array<astcenc_preset_config, 5> preset_configs {{\n25, 75, 2, 2, 95, 70, 1.75f, 1.75f, 1.2f, 0.75f\n}, {\nASTCENC_PRE_THOROUGH,\n- 100, 95, 4, 3, 105, 77, 10.0f, 10.0f, 2.5f, 0.95f\n+ 75, 92, 4, 4, 105, 77, 10.0f, 10.0f, 2.5f, 0.95f\n}, {\nASTCENC_PRE_EXHAUSTIVE,\n1024, 100, 4, 4, 200, 200, 10.0f, 10.0f, 10.0f, 0.99f\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Tune -thorough: more refinement fewer parts/bmodes
61,745
18.02.2021 18:01:15
0
e383de7072a421636cf887fbb1163f7daa7ed0b5
Update help text with new tunings
[ { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel_help.cpp", "new_path": "Source/astcenccli_toplevel_help.cpp", "diff": "@@ -299,7 +299,7 @@ ADVANCED COMPRESSION\n-fastest : 2\n-fast : 4\n-medium : 25\n- -thorough : 100\n+ -thorough : 75\n-exhaustive : 1024\n-blockmodelimit <number>\n@@ -310,7 +310,7 @@ ADVANCED COMPRESSION\n-fastest : 25\n-fast : 50\n-medium : 75\n- -thorough : 95\n+ -thorough : 92\n-exhaustive : 100\n-refinementlimit <value>\n@@ -329,7 +329,7 @@ ADVANCED COMPRESSION\n-fastest : 1\n-fast : 2\n-medium : 2\n- -thorough : 3\n+ -thorough : 4\n-exhaustive : 4\n-dblimit <number>\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Update help text with new tunings
61,745
18.02.2021 18:59:31
0
4d523eedadd2dcd902a6e4b727c6ff395e898c68
Add partition count as a tuning parameter
[ { "change_type": "MODIFY", "old_path": "Source/astcenc.h", "new_path": "Source/astcenc.h", "diff": "@@ -418,11 +418,18 @@ struct astcenc_config {\nfloat b_deblock_weight;\n/**\n- * @brief The maximum number of partitions searched (-partitionlimit).\n+ * @brief The maximum number of partitions searched (-partitioncountlimit).\n+ *\n+ * Valid values are between 1 and 4.\n+ */\n+ unsigned int tune_partition_count_limit;\n+\n+ /**\n+ * @brief The maximum number of partitions searched (-partitionindexlimit).\n*\n* Valid values are between 1 and 1024.\n*/\n- unsigned int tune_partition_limit;\n+ unsigned int tune_partition_index_limit;\n/**\n* @brief The maximum centile for block modes searched (-blockmodelimit).\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -1286,6 +1286,14 @@ void compress_block(\nbool block_is_la = imageblock_is_lumalp(blk);\nfloat block_is_la_scale = block_is_la ? 1.0f / 1.05f : 1.0f;\n+ // Default max partition, but +1 if only have 1 or 2 active components\n+ int max_partitions = ctx.config.tune_partition_count_limit;\n+ if (block_is_l || block_is_la)\n+ {\n+ max_partitions = astc::min(max_partitions + 1, 4);\n+ }\n+\n+\n#if defined(ASTCENC_DIAGNOSTICS)\n// Do this early in diagnostic builds so we can dump uniform metrics\n// for every block. Do it later in release builds to avoid redundant work!\n@@ -1440,13 +1448,13 @@ void compress_block(\n}\n// find best blocks for 2, 3 and 4 partitions\n- for (int partition_count = 2; partition_count <= 4; partition_count++)\n+ for (int partition_count = 2; partition_count <= max_partitions; partition_count++)\n{\nint partition_indices_1plane[2];\nint partition_index_2planes;\nfind_best_partitionings(bsd, blk, ewb, partition_count,\n- ctx.config.tune_partition_limit,\n+ ctx.config.tune_partition_index_limit,\n&(partition_indices_1plane[0]),\n&(partition_indices_1plane[1]),\n&partition_index_2planes);\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_entry.cpp", "new_path": "Source/astcenc_entry.cpp", "diff": "@@ -93,7 +93,8 @@ static astcenc_error validate_cpu_isa()\n*/\nstruct astcenc_preset_config {\nfloat quality;\n- unsigned int tune_partition_limit;\n+ unsigned int tune_partition_count_limit;\n+ unsigned int tune_partition_index_limit;\nunsigned int tune_block_mode_limit;\nunsigned int tune_refinement_limit;\nunsigned int tune_candidate_limit;\n@@ -111,19 +112,19 @@ struct astcenc_preset_config {\nstatic const std::array<astcenc_preset_config, 5> preset_configs {{\n{\nASTCENC_PRE_FASTEST,\n- 2, 25, 1, 1, 75, 53, 1.0f, 1.0f, 1.0f, 0.5f\n+ 2, 2, 25, 1, 1, 75, 53, 1.0f, 1.0f, 1.0f, 0.5f\n}, {\nASTCENC_PRE_FAST,\n- 4, 50, 1, 2, 85, 63, 2.5f, 2.5f, 1.0f, 0.5f\n+ 3, 4, 50, 1, 2, 85, 63, 2.5f, 2.5f, 1.0f, 0.5f\n}, {\nASTCENC_PRE_MEDIUM,\n- 25, 75, 2, 2, 95, 70, 1.75f, 1.75f, 1.2f, 0.75f\n+ 3, 26, 76, 2, 2, 95, 70, 1.75f, 1.75f, 1.2f, 0.75f\n}, {\nASTCENC_PRE_THOROUGH,\n- 75, 92, 4, 4, 105, 77, 10.0f, 10.0f, 2.5f, 0.95f\n+ 3, 75, 92, 4, 4, 105, 77, 10.0f, 10.0f, 2.5f, 0.95f\n}, {\nASTCENC_PRE_EXHAUSTIVE,\n- 1024, 100, 4, 4, 200, 200, 10.0f, 10.0f, 10.0f, 0.99f\n+ 4, 1024, 100, 4, 4, 200, 200, 10.0f, 10.0f, 10.0f, 0.99f\n}\n}};\n@@ -306,7 +307,8 @@ static astcenc_error validate_config(\nconfig.b_deblock_weight = astc::max(config.b_deblock_weight, 0.0f);\n- config.tune_partition_limit = astc::clamp(config.tune_partition_limit, 1u, (unsigned int)PARTITION_COUNT);\n+ config.tune_partition_count_limit = astc::clamp(config.tune_partition_count_limit, 1u, 4u);\n+ config.tune_partition_index_limit = astc::clamp(config.tune_partition_index_limit, 1u, (unsigned int)PARTITION_COUNT);\nconfig.tune_block_mode_limit = astc::clamp(config.tune_block_mode_limit, 1u, 100u);\nconfig.tune_refinement_limit = astc::max(config.tune_refinement_limit, 1u);\nconfig.tune_candidate_limit = astc::clamp(config.tune_candidate_limit, 1u, TUNE_MAX_TRIAL_CANDIDATES);\n@@ -391,7 +393,8 @@ astcenc_error astcenc_config_init(\n// Start and end node are the same - so just transfer the values.\nif (start == end)\n{\n- config.tune_partition_limit = preset_configs[start].tune_partition_limit;\n+ config.tune_partition_count_limit = preset_configs[start].tune_partition_count_limit;\n+ config.tune_partition_index_limit = preset_configs[start].tune_partition_index_limit;\nconfig.tune_block_mode_limit = preset_configs[start].tune_block_mode_limit;\nconfig.tune_refinement_limit = preset_configs[start].tune_refinement_limit;\nconfig.tune_candidate_limit = astc::min(preset_configs[start].tune_candidate_limit,\n@@ -424,7 +427,8 @@ astcenc_error astcenc_config_init(\n#define LERPI(param) astc::flt2int_rtn((node_a.param * wt_node_a) + (node_b.param * wt_node_b))\n#define LERPUI(param) (unsigned int)astc::flt2int_rtn((node_a.param * wt_node_a) + (node_b.param * wt_node_b))\n- config.tune_partition_limit = LERPI(tune_partition_limit);\n+ config.tune_partition_count_limit = LERPI(tune_partition_count_limit);\n+ config.tune_partition_index_limit = LERPI(tune_partition_index_limit);\nconfig.tune_block_mode_limit = LERPI(tune_block_mode_limit);\nconfig.tune_refinement_limit = LERPI(tune_refinement_limit);\nconfig.tune_candidate_limit = astc::min(LERPUI(tune_candidate_limit),\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel.cpp", "new_path": "Source/astcenccli_toplevel.cpp", "diff": "@@ -790,16 +790,27 @@ static int edit_astcenc_config(\nconfig.tune_block_mode_limit = atoi(argv[argidx - 1]);\n}\n- else if (!strcmp(argv[argidx], \"-partitionlimit\"))\n+ else if (!strcmp(argv[argidx], \"-partitioncountlimit\"))\n{\nargidx += 2;\nif (argidx > argc)\n{\n- printf(\"ERROR: -partitionlimit switch with no argument\\n\");\n+ printf(\"ERROR: -partitioncountlimit switch with no argument\\n\");\nreturn 1;\n}\n- config.tune_partition_limit = atoi(argv[argidx - 1]);\n+ config.tune_partition_count_limit = atoi(argv[argidx - 1]);\n+ }\n+ else if (!strcmp(argv[argidx], \"-partitionindexlimit\"))\n+ {\n+ argidx += 2;\n+ if (argidx > argc)\n+ {\n+ printf(\"ERROR: -partitionindexlimit switch with no argument\\n\");\n+ return 1;\n+ }\n+\n+ config.tune_partition_index_limit = atoi(argv[argidx - 1]);\n}\nelse if (!strcmp(argv[argidx], \"-dblimit\"))\n{\n@@ -1022,7 +1033,8 @@ static int edit_astcenc_config(\nprintf(\" B channel weight: %g\\n\",(double)config.cw_b_weight);\nprintf(\" A channel weight: %g\\n\",(double)config.cw_a_weight);\nprintf(\" Deblock artifact setting: %g\\n\", (double)config.b_deblock_weight);\n- printf(\" Block partition cutoff: %u partitions\\n\", config.tune_partition_limit);\n+ printf(\" Partition cutoff: %u partitions\\n\", config.tune_partition_count_limit);\n+ printf(\" Partition index cutoff: %u partition ids\\n\", config.tune_partition_index_limit);\nprintf(\" PSNR cutoff: %g dB\\n\", (double)config.tune_db_limit);\nprintf(\" 1->2 partition cutoff: %g\\n\", (double)config.tune_partition_early_out_limit);\nprintf(\" 2 plane correlation cutoff: %g\\n\", (double)config.tune_two_plane_early_out_limit);\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel_help.cpp", "new_path": "Source/astcenccli_toplevel_help.cpp", "diff": "@@ -291,14 +291,26 @@ ADVANCED COMPRESSION\nThese options provide low-level control of the codec heuristics that\ndrive the performance-quality trade off.\n- -partitionlimit <number>\n- Test only <number> block partitions. Higher numbers give\n- better quality, however large values give diminishing returns\n- especially for smaller block sizes. Preset defaults are:\n+ -partitioncountlimit <number>\n+ Test only up to and including <number> partitions for each block.\n+ Higher numbers give better quality, as more complex blocks can be\n+ encoded, however they are expensive to search. Preset defaults are:\n+\n+ -fastest : 2\n+ -fast : 3\n+ -medium : 3\n+ -thorough : 3\n+ -exhaustive : 4\n+\n+ -partitionindexlimit <number>\n+ Test only <number> block partition indices for each partition count.\n+ Higher numbers give better quality, however large values give\n+ diminishing returns especially for smaller block sizes. Preset\n+ defaults are:\n-fastest : 2\n-fast : 4\n- -medium : 25\n+ -medium : 26\n-thorough : 75\n-exhaustive : 1024\n@@ -309,7 +321,7 @@ ADVANCED COMPRESSION\n-fastest : 25\n-fast : 50\n- -medium : 75\n+ -medium : 76\n-thorough : 92\n-exhaustive : 100\n" }, { "change_type": "MODIFY", "old_path": "Test/astc_test_functional.py", "new_path": "Test/astc_test_functional.py", "diff": "#!/usr/bin/env python3\n# SPDX-License-Identifier: Apache-2.0\n# -----------------------------------------------------------------------------\n-# Copyright 2020 Arm Limited\n+# Copyright 2020-2021 Arm Limited\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n# use this file except in compliance with the License. You may obtain a copy\n@@ -1042,9 +1042,9 @@ class CLIPTest(CLITestBase):\nchRMSE = self.get_channel_rmse(inputFile, decompFile)\nself.assertLess(chRMSE[chIdx], baseRMSE[chIdx])\n- def test_partition_limit(self):\n+ def test_partition_count_limit(self):\n\"\"\"\n- Test partition limit.\n+ Test partition count limit.\n\"\"\"\ninputFile = \"./Test/Images/Small/LDR-RGBA/ldr-rgba-00.png\"\ndecompFile = self.get_tmp_image_path(\"LDR\", \"decomp\")\n@@ -1057,7 +1057,29 @@ class CLIPTest(CLITestBase):\nself.exec(command)\nrefRMSE = sum(self.get_channel_rmse(inputFile, decompFile))\n- command += [\"-partitionlimit\", \"1\"]\n+ command += [\"-partitioncountlimit\", \"1\"]\n+ self.exec(command)\n+ testRMSE = sum(self.get_channel_rmse(inputFile, decompFile))\n+\n+ # RMSE should get worse (higher) if we reduce search space\n+ self.assertGreater(testRMSE, refRMSE)\n+\n+ def test_partition_index_limit(self):\n+ \"\"\"\n+ Test partition index limit.\n+ \"\"\"\n+ inputFile = \"./Test/Images/Small/LDR-RGBA/ldr-rgba-00.png\"\n+ decompFile = self.get_tmp_image_path(\"LDR\", \"decomp\")\n+\n+ # Compute the basic image without any channel weights\n+ command = [\n+ self.binary, \"-tl\",\n+ inputFile, decompFile, \"4x4\", \"-medium\"]\n+\n+ self.exec(command)\n+ refRMSE = sum(self.get_channel_rmse(inputFile, decompFile))\n+\n+ command += [\"-partitionindexlimit\", \"1\"]\nself.exec(command)\ntestRMSE = sum(self.get_channel_rmse(inputFile, decompFile))\n@@ -1870,7 +1892,7 @@ class CLINTest(CLITestBase):\ndef test_cl_partitionlimit_missing_args(self):\n\"\"\"\n- Test -cl with -partitionlimit and missing arguments.\n+ Test -cl with -partitionindexlimit and missing arguments.\n\"\"\"\n# Build a valid command\ncommand = [\n@@ -1878,7 +1900,7 @@ class CLINTest(CLITestBase):\nself.get_ref_image_path(\"LDR\", \"input\", \"A\"),\nself.get_tmp_image_path(\"LDR\", \"comp\"),\n\"4x4\", \"-fast\",\n- \"-partitionlimit\", \"3\"]\n+ \"-partitionindexlimit\", \"3\"]\n# Run the command, incrementally omitting arguments\nself.exec_with_omit(command, 7)\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add partition count as a tuning parameter
61,745
19.02.2021 13:53:23
0
d5178ded4dc328581c4ed156711b01fe207843e3
Cleanup from main branch rename
[ { "change_type": "MODIFY", "old_path": ".gitignore", "new_path": ".gitignore", "diff": "@@ -32,5 +32,5 @@ TestOutput\n/*.png\n/*.exr\n/*.astc\n-astc_reference-master*\n+astc_reference-main*\nDocs/Profiling.md\n" }, { "change_type": "MODIFY", "old_path": "README.md", "new_path": "README.md", "diff": "@@ -89,7 +89,7 @@ is not universally available, but each step gains ~15% more performance.\n## Repository branches\n-The `master` branch is an active development branch for the compressor. It aims\n+The `main` branch is an active development branch for the compressor. It aims\nto be a stable branch, but as it is used for development expect it to change.\nThe `1.x` branch is a maintenance branch for the 1.x release series. It is\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -128,7 +128,7 @@ static const unsigned int TUNE_MAX_TRIAL_CANDIDATES { 4 };\n* * A condition variable so threads can wait for processing completion.\n*\n* The init stage will be executed by the first thread to arrive in the\n- * critical section, there is no master thread in the thread pool.\n+ * critical section, there is no main thread in the thread pool.\n*\n* The processing stage uses dynamic dispatch to assign task tickets to threads\n* on an on-demand basis. Threads may each therefore executed different numbers\n" }, { "change_type": "MODIFY", "old_path": "Test/astc_test_image.py", "new_path": "Test/astc_test_image.py", "diff": "@@ -294,33 +294,33 @@ def get_encoder_params(encoderName, referenceName, imageSet):\nname = \"reference-2.3-neon\"\noutDir = \"Test/Images/%s\" % imageSet\nrefName = None\n- # Latest master\n- elif encoderName == \"ref-master-neon\":\n+ # Latest main\n+ elif encoderName == \"ref-main-neon\":\n# Warning: this option rebuilds a new reference test result for the\n- # master branch using the user's locally build encoder.\n+ # main branch using the user's locally build encoder.\nencoder = te.Encoder2x(\"neon\")\n- name = \"reference-master-neon\"\n+ name = \"reference-main-neon\"\noutDir = \"Test/Images/%s\" % imageSet\nrefName = None\n- elif encoderName == \"ref-master-sse2\":\n+ elif encoderName == \"ref-main-sse2\":\n# Warning: this option rebuilds a new reference test result for the\n- # master branch using the user's locally build encoder.\n+ # main branch using the user's locally build encoder.\nencoder = te.Encoder2x(\"sse2\")\n- name = \"reference-master-sse2\"\n+ name = \"reference-main-sse2\"\noutDir = \"Test/Images/%s\" % imageSet\nrefName = None\n- elif encoderName == \"ref-master-sse4.1\":\n+ elif encoderName == \"ref-main-sse4.1\":\n# Warning: this option rebuilds a new reference test result for the\n- # master branch using the user's locally build encoder.\n+ # main branch using the user's locally build encoder.\nencoder = te.Encoder2x(\"sse4.1\")\n- name = \"reference-master-sse4.1\"\n+ name = \"reference-main-sse4.1\"\noutDir = \"Test/Images/%s\" % imageSet\nrefName = None\n- elif encoderName == \"ref-master-avx2\":\n+ elif encoderName == \"ref-main-avx2\":\n# Warning: this option rebuilds a new reference test result for the\n- # master branch using the user's locally build encoder.\n+ # main branch using the user's locally build encoder.\nencoder = te.Encoder2x(\"avx2\")\n- name = \"reference-master-avx2\"\n+ name = \"reference-main-avx2\"\noutDir = \"Test/Images/%s\" % imageSet\nrefName = None\nelse:\n@@ -345,7 +345,7 @@ def parse_command_line():\nrefcoders = [\"ref-1.7\",\n\"ref-2.2-neon\", \"ref-2.2-sse2\", \"ref-2.2-sse4.1\", \"ref-2.2-avx2\",\n\"ref-2.3-neon\", \"ref-2.3-sse2\", \"ref-2.3-sse4.1\", \"ref-2.3-avx2\",\n- \"ref-master-neon\", \"ref-master-sse2\", \"ref-master-sse4.1\", \"ref-master-avx2\"]\n+ \"ref-main-neon\", \"ref-main-sse2\", \"ref-main-sse4.1\", \"ref-main-avx2\"]\n# All test encoders\ntestcoders = [\"none\", \"neon\", \"sse2\", \"sse4.1\", \"avx2\"]\n" }, { "change_type": "MODIFY", "old_path": "Test/astc_update_ref.sh", "new_path": "Test/astc_update_ref.sh", "diff": "#!/bin/bash\nif [ -z \"$1\" ]; then\n- echo \"ERROR: Missing root; e.g. for ref-master-avx2 set 'master'\"\n+ echo \"ERROR: Missing root; e.g. for ref-main-avx2 set 'main'\"\nexit 1\nfi\necho \"Generating new ref-$1 results\"\n-if [ \"$1\" = \"master\" ]; then\n+if [ \"$1\" = \"main\" ]; then\necho \"Using binary from ./astcenc/${1}/\"\nelse\necho \"Using binary from ./Binaries/${1}/\"\n" }, { "change_type": "MODIFY", "old_path": "Test/testlib/encoder.py", "new_path": "Test/testlib/encoder.py", "diff": "# SPDX-License-Identifier: Apache-2.0\n# -----------------------------------------------------------------------------\n-# Copyright 2019-2020 Arm Limited\n+# Copyright 2019-2021 Arm Limited\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n# use this file except in compliance with the License. You may obtain a copy\n@@ -228,10 +228,10 @@ class EncoderBase():\nclass Encoder2x(EncoderBase):\n\"\"\"\n- This class wraps the latest `astcenc` 2.x series binaries from the master\n+ This class wraps the latest `astcenc` 2.x series binaries from main branch.\nbranch.\n\"\"\"\n- VERSION = \"master\"\n+ VERSION = \"main\"\nSWITCHES = {\n\"ldr\": \"-tl\",\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Cleanup from main branch rename
61,745
19.02.2021 14:38:52
0
37925b970aa5b9df74d1df6ad4ad82a1c517fcfc
Split help string.
[ { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel_help.cpp", "new_path": "Source/astcenccli_toplevel_help.cpp", "diff": "@@ -195,7 +195,10 @@ COMPRESSION\nRun a preprocess over the image that scales RGB components\nin the image by the alpha value. Preprocessing applies before any\ncodec encoding swizzle, so color data must be in the RGB\n- channels in the source image.\n+ channels in the source image.)\"\n+// This split in the literals is needed for Visual Studio; the compiler\n+// will concatenate these two strings together ...\n+R\"(\nCOMPRESSION TIPS & TRICKS\nASTC is a block-based format that can be prone to block artifacts.\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Split help string.
61,745
19.02.2021 14:39:21
0
f29a54443d5d321d1f9129eca1ee0895ec039e3c
Add workaround for MSVC bug with _mm_cvtps_ph
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_sse_4.h", "new_path": "Source/astcenc_vecmathlib_sse_4.h", "diff": "@@ -1076,7 +1076,13 @@ ASTCENC_SIMD_INLINE vfloat4 int_to_float(vint4 a)\nASTCENC_SIMD_INLINE vint4 float_to_float16(vfloat4 a)\n{\n#if ASTCENC_F16C >= 1\n+ // Workaround for MSVC bug not accepting _MM_FROUND_NO_EXC;\n+ // https://developercommunity2.visualstudio.com/t/-mm-cvtps-ph-doesnt-accept-mm-fround-no-exc/1343857\n+ #if !defined(__clang__) && defined(_MSC_VER)\n+ __m128i packedf16 = _mm_cvtps_ph(a.m, 0);\n+ #else\n__m128i packedf16 = _mm_cvtps_ph(a.m, _MM_FROUND_NO_EXC);\n+ #endif\n__m128i f16 = _mm_cvtepu16_epi32(packedf16);\nreturn vint4(f16);\n#else\n@@ -1094,7 +1100,13 @@ ASTCENC_SIMD_INLINE vint4 float_to_float16(vfloat4 a)\nstatic inline uint16_t float_to_float16(float a)\n{\n#if ASTCENC_F16C >= 1\n+ // Workaround for MSVC bug not accepting _MM_FROUND_NO_EXC;\n+ // https://developercommunity2.visualstudio.com/t/-mm-cvtps-ph-doesnt-accept-mm-fround-no-exc/1343857\n+ #if !defined(__clang__) && defined(_MSC_VER)\n+ __m128i f16 = _mm_cvtps_ph(_mm_set1_ps(a), 0);\n+ #else\n__m128i f16 = _mm_cvtps_ph(_mm_set1_ps(a), _MM_FROUND_NO_EXC);\n+ #endif\nreturn (uint16_t)_mm_cvtsi128_si32(f16);\n#else\nreturn float_to_sf16(a);\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add workaround for MSVC bug with _mm_cvtps_ph
61,745
19.02.2021 01:03:15
0
cf3de1d8ad2cb41c189bc4f16359fcaebdf8f01e
Improve minify test script
[ { "change_type": "MODIFY", "old_path": "Test/astc_minify_test.sh", "new_path": "Test/astc_minify_test.sh", "diff": "#!/bin/bash\n-./astcenc/astcenc-avx2-good -tl in.png out-good.png 6x6 -medium\n+BLOCK_SIZE=6x6\n+QUALITY=-thorough\n-./astcenc/astcenc-avx2 -tl in.png out-bad.png 6x6 -medium\n+./astcenc/astcenc-avx2-good -tl in.png out-good.png ${BLOCK_SIZE} ${QUALITY} -silent\n-./astcenc/astc_test_autoextract 6x6 in.png out-good.png out-bad.png in-min.png\n+./astcenc/astcenc-avx2 -tl in.png out-bad.png ${BLOCK_SIZE} ${QUALITY} -silent\n+\n+compare out-good.png out-bad.png out-vs-out-diff.png\n+compare in.png out-bad.png out-vs-in-diff.png\n+\n+./astcenc/astc_test_autoextract ${BLOCK_SIZE} in.png out-good.png out-bad.png in-min.png\n+\n+./astcenc/astcenc-avx2-good -tl in-min.png out-min-good.png ${BLOCK_SIZE} ${QUALITY} -silent\n+\n+./astcenc/astcenc-avx2 -tl in-min.png out-min-bad.png ${BLOCK_SIZE} ${QUALITY} -silent\n+\n+compare out-min-good.png out-min-bad.png out-min-diff.png\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Improve minify test script
61,745
19.02.2021 08:23:21
0
0e6c184ad4797f78df766982c154cbae2230330b
Standardize on pt for partition table variables
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -220,14 +220,14 @@ static float compress_symbolic_block_fixed_partition_1_plane(\n0, 115 - 4, 111 - 4 - PARTITION_BITS, 108 - 4 - PARTITION_BITS, 105 - 4 - PARTITION_BITS\n};\n- const partition_info *pi = get_partition_table(bsd, partition_count);\n- pi += partition_index;\n+ const partition_info *pt = get_partition_table(bsd, partition_count);\n+ pt += partition_index;\n// first, compute ideal weights and endpoint colors, under the assumption that\n// there is no quantization or decimation going on.\nendpoints_and_weights *ei = &tmpbuf->ei1;\nendpoints_and_weights *eix = tmpbuf->eix1;\n- compute_endpoints_and_ideal_weights_1_plane(bsd, pi, blk, ewb, ei);\n+ compute_endpoints_and_ideal_weights_1_plane(bsd, pt, blk, ewb, ei);\n// next, compute ideal weights and endpoint colors for every decimation.\nconst decimation_table *const *ixtab2 = bsd->decimation_tables;\n@@ -347,7 +347,7 @@ static float compress_symbolic_block_fixed_partition_1_plane(\nint color_quant_level_mod[TUNE_MAX_TRIAL_CANDIDATES];\ndetermine_optimal_set_of_endpoint_formats_to_use(\n- bsd, pi, blk, ewb, &(ei->ep), -1, qwt_bitcounts, qwt_errors,\n+ bsd, pt, blk, ewb, &(ei->ep), -1, qwt_bitcounts, qwt_errors,\ntune_candidate_limit, partition_format_specifiers, quantized_weight,\ncolor_quant_level, color_quant_level_mod);\n@@ -394,7 +394,7 @@ static float compress_symbolic_block_fixed_partition_1_plane(\n{\nrecompute_ideal_colors_1plane(\nweight_quant_mode, &(eix[decimation_mode].ep),\n- rgbs_colors, rgbo_colors, u8_weight_src, pi, it, blk, ewb);\n+ rgbs_colors, rgbo_colors, u8_weight_src, pt, it, blk, ewb);\n// quantize the chosen color\n@@ -571,15 +571,15 @@ static float compress_symbolic_block_fixed_partition_2_planes(\n0, 113 - 4, 109 - 4 - PARTITION_BITS, 106 - 4 - PARTITION_BITS, 103 - 4 - PARTITION_BITS\n};\n- const partition_info *pi = get_partition_table(bsd, partition_count);\n- pi += partition_index;\n+ const partition_info *pt = get_partition_table(bsd, partition_count);\n+ pt += partition_index;\n// first, compute ideal weights and endpoint colors\nendpoints_and_weights *ei1 = &tmpbuf->ei1;\nendpoints_and_weights *ei2 = &tmpbuf->ei2;\nendpoints_and_weights *eix1 = tmpbuf->eix1;\nendpoints_and_weights *eix2 = tmpbuf->eix2;\n- compute_endpoints_and_ideal_weights_2_planes(bsd, pi, blk, ewb, separate_component, ei1, ei2);\n+ compute_endpoints_and_ideal_weights_2_planes(bsd, pt, blk, ewb, separate_component, ei1, ei2);\n// next, compute ideal weights and endpoint colors for every decimation.\nconst decimation_table *const *ixtab2 = bsd->decimation_tables;\n@@ -741,7 +741,7 @@ static float compress_symbolic_block_fixed_partition_2_planes(\nmerge_endpoints(&(ei1->ep), &(ei2->ep), separate_component, &epm);\ndetermine_optimal_set_of_endpoint_formats_to_use(\n- bsd, pi, blk, ewb, &epm, separate_component, qwt_bitcounts, qwt_errors,\n+ bsd, pt, blk, ewb, &epm, separate_component, qwt_bitcounts, qwt_errors,\ntune_candidate_limit, partition_format_specifiers, quantized_weight,\ncolor_quant_level, color_quant_level_mod);\n@@ -793,7 +793,7 @@ static float compress_symbolic_block_fixed_partition_2_planes(\n{\nrecompute_ideal_colors_2planes(\nweight_quant_mode, &epm, rgbs_colors, rgbo_colors,\n- u8_weight1_src, u8_weight2_src, separate_component, pi, it, blk, ewb);\n+ u8_weight1_src, u8_weight2_src, separate_component, pt, it, blk, ewb);\n// store the colors for the block\nfor (int j = 0; j < partition_count; j++)\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_encoding_choice_error.cpp", "new_path": "Source/astcenc_encoding_choice_error.cpp", "diff": "@@ -151,12 +151,12 @@ static void compute_error_squared_rgb_single_partition(\nvoid compute_encoding_choice_errors(\nconst block_size_descriptor* bsd,\nconst imageblock* pb,\n- const partition_info* pi,\n+ const partition_info* pt,\nconst error_weight_block* ewb,\nint separate_component, // component that is separated out in 2-plane mode, -1 in 1-plane mode\nencoding_choice_errors* eci)\n{\n- int partition_count = pi->partition_count;\n+ int partition_count = pt->partition_count;\nint texels_per_block = bsd->texel_count;\npromise(partition_count > 0);\n@@ -167,20 +167,20 @@ void compute_encoding_choice_errors(\nvfloat4 error_weightings[4];\nvfloat4 color_scalefactors[4];\n- compute_partition_error_color_weightings(bsd, ewb, pi, error_weightings, color_scalefactors);\n- compute_avgs_and_dirs_3_comp(pi, pb, ewb, color_scalefactors, 3, averages, directions_rgb);\n+ compute_partition_error_color_weightings(bsd, ewb, pt, error_weightings, color_scalefactors);\n+ compute_avgs_and_dirs_3_comp(pt, pb, ewb, color_scalefactors, 3, averages, directions_rgb);\nendpoints ep;\nif (separate_component == -1)\n{\nendpoints_and_weights ei;\n- compute_endpoints_and_ideal_weights_1_plane(bsd, pi, pb, ewb, &ei);\n+ compute_endpoints_and_ideal_weights_1_plane(bsd, pt, pb, ewb, &ei);\nep = ei.ep;\n}\nelse\n{\nendpoints_and_weights ei1, ei2;\n- compute_endpoints_and_ideal_weights_2_planes(bsd, pi, pb, ewb, separate_component, &ei1, &ei2);\n+ compute_endpoints_and_ideal_weights_2_planes(bsd, pt, pb, ewb, separate_component, &ei1, &ei2);\nmerge_endpoints(&(ei1.ep), &(ei2.ep), separate_component, &ep);\n}\n@@ -249,7 +249,7 @@ void compute_encoding_choice_errors(\nproc_luminance_lines.bis = normalize(csf) * icsf;\ncompute_error_squared_rgb_single_partition(\n- i, bsd, pi, pb, ewb,\n+ i, bsd, pt, pb, ewb,\n&proc_uncorr_rgb_lines, &uncorr_rgb_error,\n&proc_samechroma_rgb_lines, &samechroma_rgb_error,\n&proc_rgb_luma_lines, &rgb_luma_error,\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_find_best_partitioning.cpp", "new_path": "Source/astcenc_find_best_partitioning.cpp", "diff": "@@ -94,12 +94,12 @@ static void compute_partition_error_color_weightings_and_range(\nvoid compute_partition_error_color_weightings(\nconst block_size_descriptor* bsd,\nconst error_weight_block* ewb,\n- const partition_info* pi,\n+ const partition_info* pt,\nvfloat4 error_weightings[4],\nvfloat4 color_scalefactors[4]\n) {\nint texels_per_block = bsd->texel_count;\n- int pcnt = pi->partition_count;\n+ int pcnt = pt->partition_count;\nfor (int i = 0; i < pcnt; i++)\n{\n@@ -108,13 +108,13 @@ void compute_partition_error_color_weightings(\nfor (int i = 0; i < texels_per_block; i++)\n{\n- int part = pi->partition_of_texel[i];\n+ int part = pt->partition_of_texel[i];\nerror_weightings[part] = error_weightings[part] + ewb->error_weights[i];\n}\nfor (int i = 0; i < pcnt; i++)\n{\n- error_weightings[i] = error_weightings[i] * (1.0f / pi->texels_per_partition[i]);\n+ error_weightings[i] = error_weightings[i] * (1.0f / pt->texels_per_partition[i]);\ncolor_scalefactors[i] = sqrt(error_weightings[i]);\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "diff": "@@ -1103,7 +1103,7 @@ void recompute_ideal_colors_2planes(\nconst uint8_t* weight_set8, // the current set of weight values\nconst uint8_t* plane2_weight_set8, // nullptr if plane 2 is not actually used.\nint plane2_color_component, // color component for 2nd plane of weights; -1 if the 2nd plane of weights is not present\n- const partition_info* pi,\n+ const partition_info* pt,\nconst decimation_table* it,\nconst imageblock* pb, // picture-block containing the actual data.\nconst error_weight_block* ewb\n@@ -1126,15 +1126,15 @@ void recompute_ideal_colors_2planes(\n}\n}\n- int partition_count = pi->partition_count;\n+ int partition_count = pt->partition_count;\nfor (int i = 0; i < partition_count; i++)\n{\nvfloat4 rgba_sum(1e-17f);\nvfloat4 rgba_weight_sum(1e-17f);\n- int texelcount = pi->texels_per_partition[i];\n- const uint8_t *texel_indexes = pi->texels_of_partition[i];\n+ int texelcount = pt->texels_per_partition[i];\n+ const uint8_t *texel_indexes = pt->texels_of_partition[i];\nfor (int j = 0; j < texelcount; j++)\n{\nint tix = texel_indexes[j];\n@@ -1435,13 +1435,13 @@ void recompute_ideal_colors_1plane(\nvfloat4* rgbs_vectors, // used to return RGBS-vectors for endpoint mode #6\nvfloat4* rgbo_vectors, // used to return RGBO-vectors for endpoint mode #7\nconst uint8_t* weight_set8, // the current set of weight values\n- const partition_info* pi,\n+ const partition_info* pt,\nconst decimation_table* it,\nconst imageblock* pb, // picture-block containing the actual data.\nconst error_weight_block* ewb\n) {\nint weight_count = it->weight_count;\n- int partition_count = pi->partition_count;\n+ int partition_count = pt->partition_count;\npromise(weight_count > 0);\npromise(partition_count > 0);\n@@ -1459,8 +1459,8 @@ void recompute_ideal_colors_1plane(\nvfloat4 rgba_sum(1e-17f);\nvfloat4 rgba_weight_sum(1e-17f);\n- int texelcount = pi->texels_per_partition[i];\n- const uint8_t *texel_indexes = pi->texels_of_partition[i];\n+ int texelcount = pt->texels_per_partition[i];\n+ const uint8_t *texel_indexes = pt->texels_of_partition[i];\npromise(texelcount > 0);\nfor (int j = 0; j < texelcount; j++)\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -879,7 +879,7 @@ void compute_error_squared_rgb(\nvoid compute_partition_error_color_weightings(\nconst block_size_descriptor* bsd,\nconst error_weight_block * ewb,\n- const partition_info* pi,\n+ const partition_info* pt,\nvfloat4 error_weightings[4],\nvfloat4 color_scalefactors[4]);\n@@ -1168,7 +1168,7 @@ struct compress_symbolic_block_buffers\nvoid compute_encoding_choice_errors(\nconst block_size_descriptor* bsd,\nconst imageblock* pb,\n- const partition_info* pi,\n+ const partition_info* pt,\nconst error_weight_block* ewb,\nint separate_component, // component that is separated out in 2-plane mode, -1 in 1-plane mode\nencoding_choice_errors* eci);\n@@ -1196,7 +1196,7 @@ void recompute_ideal_colors_1plane(\nvfloat4* rgbs_vectors, // used to return RGBS-vectors for endpoint mode #6 (LDR RGB base + scale)\nvfloat4* rgbo_vectors, // used to return RGBS-vectors for endpoint mode #7 (HDR RGB base + scale)\nconst uint8_t* weight_set8, // the current set of weight values\n- const partition_info* pi,\n+ const partition_info* pt,\nconst decimation_table* it,\nconst imageblock* pb, // picture-block containing the actual data.\nconst error_weight_block* ewb);\n@@ -1209,7 +1209,7 @@ void recompute_ideal_colors_2planes(\nconst uint8_t* weight_set8, // the current set of weight values\nconst uint8_t* plane2_weight_set8, // nullptr if plane 2 is not actually used.\nint plane2_color_component, // color component for 2nd plane of weights; -1 if the 2nd plane of weights is not present\n- const partition_info* pi,\n+ const partition_info* pt,\nconst decimation_table* it,\nconst imageblock* pb, // picture-block containing the actual data.\nconst error_weight_block* ewb);\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_kmeans_partitioning.cpp", "new_path": "Source/astcenc_kmeans_partitioning.cpp", "diff": "@@ -325,7 +325,7 @@ static void count_partition_mismatch_bits(\nconst uint64_t bitmaps[4],\nint bitcounts[PARTITION_COUNT]\n) {\n- const partition_info *pi = get_partition_table(bsd, partition_count);\n+ const partition_info *pt = get_partition_table(bsd, partition_count);\nif (partition_count == 2)\n{\n@@ -333,15 +333,15 @@ static void count_partition_mismatch_bits(\nuint64_t bm1 = bitmaps[1];\nfor (int i = 0; i < PARTITION_COUNT; i++)\n{\n- if (pi->partition_count == 2)\n+ if (pt->partition_count == 2)\n{\n- bitcounts[i] = partition_mismatch2(bm0, bm1, pi->coverage_bitmaps[0], pi->coverage_bitmaps[1]);\n+ bitcounts[i] = partition_mismatch2(bm0, bm1, pt->coverage_bitmaps[0], pt->coverage_bitmaps[1]);\n}\nelse\n{\nbitcounts[i] = 255;\n}\n- pi++;\n+ pt++;\n}\n}\nelse if (partition_count == 3)\n@@ -351,15 +351,15 @@ static void count_partition_mismatch_bits(\nuint64_t bm2 = bitmaps[2];\nfor (int i = 0; i < PARTITION_COUNT; i++)\n{\n- if (pi->partition_count == 3)\n+ if (pt->partition_count == 3)\n{\n- bitcounts[i] = partition_mismatch3(bm0, bm1, bm2, pi->coverage_bitmaps[0], pi->coverage_bitmaps[1], pi->coverage_bitmaps[2]);\n+ bitcounts[i] = partition_mismatch3(bm0, bm1, bm2, pt->coverage_bitmaps[0], pt->coverage_bitmaps[1], pt->coverage_bitmaps[2]);\n}\nelse\n{\nbitcounts[i] = 255;\n}\n- pi++;\n+ pt++;\n}\n}\nelse if (partition_count == 4)\n@@ -370,15 +370,15 @@ static void count_partition_mismatch_bits(\nuint64_t bm3 = bitmaps[3];\nfor (int i = 0; i < PARTITION_COUNT; i++)\n{\n- if (pi->partition_count == 4)\n+ if (pt->partition_count == 4)\n{\n- bitcounts[i] = partition_mismatch4(bm0, bm1, bm2, bm3, pi->coverage_bitmaps[0], pi->coverage_bitmaps[1], pi->coverage_bitmaps[2], pi->coverage_bitmaps[3]);\n+ bitcounts[i] = partition_mismatch4(bm0, bm1, bm2, bm3, pt->coverage_bitmaps[0], pt->coverage_bitmaps[1], pt->coverage_bitmaps[2], pt->coverage_bitmaps[3]);\n}\nelse\n{\nbitcounts[i] = 255;\n}\n- pi++;\n+ pt++;\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_partition_tables.cpp", "new_path": "Source/astcenc_partition_tables.cpp", "diff": "@@ -75,14 +75,14 @@ static int compare_canonicalized_partition_tables(\nconsider and thus improves encode performance. */\nstatic void partition_table_zap_equal_elements(\nint texel_count,\n- partition_info* pi\n+ partition_info* pt\n) {\nint partition_tables_zapped = 0;\nuint64_t *canonicalizeds = new uint64_t[PARTITION_COUNT * 7];\nfor (int i = 0; i < PARTITION_COUNT; i++)\n{\n- gen_canonicalized_partition_table(texel_count, pi[i].partition_of_texel, canonicalizeds + i * 7);\n+ gen_canonicalized_partition_table(texel_count, pt[i].partition_of_texel, canonicalizeds + i * 7);\n}\nfor (int i = 0; i < PARTITION_COUNT; i++)\n@@ -91,7 +91,7 @@ static void partition_table_zap_equal_elements(\n{\nif (compare_canonicalized_partition_tables(canonicalizeds + 7 * i, canonicalizeds + 7 * j))\n{\n- pi[i].partition_count = 0;\n+ pt[i].partition_count = 0;\npartition_tables_zapped++;\nbreak;\n}\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_pick_best_endpoint_format.cpp", "new_path": "Source/astcenc_pick_best_endpoint_format.cpp", "diff": "@@ -36,7 +36,7 @@ static void compute_color_error_for_every_integer_count_and_quant_level(\nint encode_hdr_rgb, // 1 = perform HDR encoding, 0 = perform LDR encoding.\nint encode_hdr_alpha,\nint partition_index,\n- const partition_info* pi,\n+ const partition_info* pt,\nconst encoding_choice_errors* eci, // pointer to the structure for the CURRENT partition.\nconst endpoints* ep,\nvfloat4 error_weightings[4],\n@@ -44,7 +44,7 @@ static void compute_color_error_for_every_integer_count_and_quant_level(\nfloat best_error[21][4],\nint format_of_choice[21][4]\n) {\n- int partition_size = pi->texels_per_partition[partition_index];\n+ int partition_size = pt->texels_per_partition[partition_index];\nstatic const float baseline_quant_error[21] = {\n(65536.0f * 65536.0f / 18.0f), // 2 values, 1 step\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Standardize on pt for partition table variables
61,745
19.02.2021 08:24:21
0
7ae38a14cd5fd0192334d9398c4b49d2be8df95a
Standardize on blk for image block variables
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_decompress_symbolic.cpp", "new_path": "Source/astcenc_decompress_symbolic.cpp", "diff": "@@ -285,7 +285,7 @@ float compute_symbolic_block_difference(\nastcenc_profile decode_mode,\nconst block_size_descriptor* bsd,\nconst symbolic_compressed_block* scb,\n- const imageblock* pb,\n+ const imageblock* blk,\nconst error_weight_block *ewb\n) {\n// if we detected an error-block, blow up immediately.\n@@ -394,7 +394,7 @@ float compute_symbolic_block_difference(\nplane2_weights[i],\nplane2_mask);\n- vfloat4 oldColor = pb->texel(i);\n+ vfloat4 oldColor = blk->texel(i);\nvfloat4 error = oldColor - color;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_encoding_choice_error.cpp", "new_path": "Source/astcenc_encoding_choice_error.cpp", "diff": "@@ -150,7 +150,7 @@ static void compute_error_squared_rgb_single_partition(\n*/\nvoid compute_encoding_choice_errors(\nconst block_size_descriptor* bsd,\n- const imageblock* pb,\n+ const imageblock* blk,\nconst partition_info* pt,\nconst error_weight_block* ewb,\nint separate_component, // component that is separated out in 2-plane mode, -1 in 1-plane mode\n@@ -168,19 +168,19 @@ void compute_encoding_choice_errors(\nvfloat4 color_scalefactors[4];\ncompute_partition_error_color_weightings(bsd, ewb, pt, error_weightings, color_scalefactors);\n- compute_avgs_and_dirs_3_comp(pt, pb, ewb, color_scalefactors, 3, averages, directions_rgb);\n+ compute_avgs_and_dirs_3_comp(pt, blk, ewb, color_scalefactors, 3, averages, directions_rgb);\nendpoints ep;\nif (separate_component == -1)\n{\nendpoints_and_weights ei;\n- compute_endpoints_and_ideal_weights_1_plane(bsd, pt, pb, ewb, &ei);\n+ compute_endpoints_and_ideal_weights_1_plane(bsd, pt, blk, ewb, &ei);\nep = ei.ep;\n}\nelse\n{\nendpoints_and_weights ei1, ei2;\n- compute_endpoints_and_ideal_weights_2_planes(bsd, pt, pb, ewb, separate_component, &ei1, &ei2);\n+ compute_endpoints_and_ideal_weights_2_planes(bsd, pt, blk, ewb, separate_component, &ei1, &ei2);\nmerge_endpoints(&(ei1.ep), &(ei2.ep), separate_component, &ep);\n}\n@@ -249,7 +249,7 @@ void compute_encoding_choice_errors(\nproc_luminance_lines.bis = normalize(csf) * icsf;\ncompute_error_squared_rgb_single_partition(\n- i, bsd, pt, pb, ewb,\n+ i, bsd, pt, blk, ewb,\n&proc_uncorr_rgb_lines, &uncorr_rgb_error,\n&proc_samechroma_rgb_lines, &samechroma_rgb_error,\n&proc_rgb_luma_lines, &rgb_luma_error,\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_entry.cpp", "new_path": "Source/astcenc_entry.cpp", "diff": "@@ -693,7 +693,7 @@ static void compress_image(\nint block_z = bsd->zdim;\nastcenc_profile decode_mode = ctx.config.profile;\n- imageblock pb;\n+ imageblock blk;\nint dim_x = image.dim_x;\nint dim_y = image.dim_y;\nint dim_z = image.dim_z;\n@@ -770,22 +770,22 @@ static void compress_image(\n// Fetch the full block for compression\nif (use_full_block)\n{\n- fetch_imageblock(decode_mode, image, &pb, bsd, x * block_x, y * block_y, z * block_z, swizzle);\n+ fetch_imageblock(decode_mode, image, &blk, bsd, x * block_x, y * block_y, z * block_z, swizzle);\n}\n// Apply alpha scale RDO - substitute constant color block\nelse\n{\n- pb.origin_texel = vfloat4::zero();\n- pb.data_min = vfloat4::zero();\n- pb.data_max = pb.data_min;\n- pb.grayscale = false;\n+ blk.origin_texel = vfloat4::zero();\n+ blk.data_min = vfloat4::zero();\n+ blk.data_max = blk.data_min;\n+ blk.grayscale = false;\n}\nint offset = ((z * yblocks + y) * xblocks + x) * 16;\nuint8_t *bp = buffer + offset;\nphysical_compressed_block* pcb = reinterpret_cast<physical_compressed_block*>(bp);\nsymbolic_compressed_block scb;\n- compress_block(ctx, image, &pb, scb, *pcb, temp_buffers);\n+ compress_block(ctx, image, &blk, scb, *pcb, temp_buffers);\n}\nctx.manage_compress.complete_task_assignment(count);\n@@ -943,7 +943,7 @@ astcenc_error astcenc_decompress_image(\nreturn ASTCENC_ERR_OUT_OF_MEM;\n}\n- imageblock pb;\n+ imageblock blk;\nfor (unsigned int z = 0; z < zblocks; z++)\n{\n@@ -960,9 +960,9 @@ astcenc_error astcenc_decompress_image(\ndecompress_symbolic_block(context->config.profile, context->bsd,\nx * block_x, y * block_y, z * block_z,\n- &scb, &pb);\n+ &scb, &blk);\n- write_imageblock(image_out, &pb, context->bsd,\n+ write_imageblock(image_out, &blk, context->bsd,\nx * block_x, y * block_y, z * block_z, swizzle);\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "diff": "@@ -1105,7 +1105,7 @@ void recompute_ideal_colors_2planes(\nint plane2_color_component, // color component for 2nd plane of weights; -1 if the 2nd plane of weights is not present\nconst partition_info* pt,\nconst decimation_table* it,\n- const imageblock* pb, // picture-block containing the actual data.\n+ const imageblock* blk, // picture-block containing the actual data.\nconst error_weight_block* ewb\n) {\nconst quantization_and_transfer_table *qat = &(quant_and_xfer_tables[weight_quant_mode]);\n@@ -1139,7 +1139,7 @@ void recompute_ideal_colors_2planes(\n{\nint tix = texel_indexes[j];\n- vfloat4 rgba = pb->texel(tix);\n+ vfloat4 rgba = blk->texel(tix);\nvfloat4 error_weight(ewb->texel_weight_r[tix], ewb->texel_weight_g[tix], ewb->texel_weight_b[tix], ewb->texel_weight_a[tix]);\nrgba_sum = rgba_sum + (rgba * error_weight);\n@@ -1179,7 +1179,7 @@ void recompute_ideal_colors_2planes(\n{\nint tix = texel_indexes[j];\n- vfloat4 rgba = pb->texel(tix);\n+ vfloat4 rgba = blk->texel(tix);\nvfloat4 color_weight(ewb->texel_weight_r[tix], ewb->texel_weight_g[tix], ewb->texel_weight_b[tix], ewb->texel_weight_a[tix]);\nvfloat4 color_weight3 = color_weight.swz<0, 1, 2>();\n@@ -1437,7 +1437,7 @@ void recompute_ideal_colors_1plane(\nconst uint8_t* weight_set8, // the current set of weight values\nconst partition_info* pt,\nconst decimation_table* it,\n- const imageblock* pb, // picture-block containing the actual data.\n+ const imageblock* blk, // picture-block containing the actual data.\nconst error_weight_block* ewb\n) {\nint weight_count = it->weight_count;\n@@ -1467,7 +1467,7 @@ void recompute_ideal_colors_1plane(\n{\nint tix = texel_indexes[j];\n- vfloat4 rgba = pb->texel(tix);\n+ vfloat4 rgba = blk->texel(tix);\nvfloat4 error_weight(ewb->texel_weight_r[tix], ewb->texel_weight_g[tix], ewb->texel_weight_b[tix], ewb->texel_weight_a[tix]);\nrgba_sum = rgba_sum + (rgba * error_weight);\n@@ -1501,7 +1501,7 @@ void recompute_ideal_colors_1plane(\n{\nint tix = texel_indexes[j];\n- vfloat4 rgba = pb->texel(tix);\n+ vfloat4 rgba = blk->texel(tix);\nvfloat4 color_weight(ewb->texel_weight_r[tix], ewb->texel_weight_g[tix], ewb->texel_weight_b[tix], ewb->texel_weight_a[tix]);\nvfloat4 color_weight3 = color_weight.swz<0, 1, 2>();\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_image.cpp", "new_path": "Source/astcenc_image.cpp", "diff": "@@ -122,7 +122,7 @@ uint16_t unorm16_to_sf16(uint16_t p)\n}\nvoid imageblock_initialize_deriv(\n- const imageblock* pb,\n+ const imageblock* blk,\nint pixelcount,\nvfloat4* dptr\n) {\n@@ -134,13 +134,13 @@ void imageblock_initialize_deriv(\nvfloat4 derv_lns = vfloat4::zero();\n// TODO: Pack these into bits and avoid the disjoint fetch\n- int rgb_lns = pb->rgb_lns[i];\n- int a_lns = pb->alpha_lns[i];\n+ int rgb_lns = blk->rgb_lns[i];\n+ int a_lns = blk->alpha_lns[i];\n// Compute derivatives if we have any use of LNS\nif (rgb_lns || a_lns)\n{\n- vfloat4 data = pb->texel(i);\n+ vfloat4 data = blk->texel(i);\nvint4 datai(\nlns_to_sf16((uint16_t)data.lane<0>()),\n@@ -185,10 +185,10 @@ void imageblock_initialize_deriv(\n// helper function to initialize the work-data from the orig-data\nstatic void imageblock_initialize_work_from_orig(\n- imageblock* pb,\n+ imageblock* blk,\nint pixelcount\n) {\n- pb->origin_texel = pb->texel(0);\n+ blk->origin_texel = blk->texel(0);\nvfloat4 data_min(1e38f);\nvfloat4 data_max(-1e38f);\n@@ -196,9 +196,9 @@ static void imageblock_initialize_work_from_orig(\nfor (int i = 0; i < pixelcount; i++)\n{\n- vfloat4 data = pb->texel(i);\n+ vfloat4 data = blk->texel(i);\n- if (pb->rgb_lns[i])\n+ if (blk->rgb_lns[i])\n{\ndata.set_lane<0>(float_to_lns(data.lane<0>()));\ndata.set_lane<1>(float_to_lns(data.lane<1>()));\n@@ -211,7 +211,7 @@ static void imageblock_initialize_work_from_orig(\ndata.set_lane<2>(data.lane<2>() * 65535.0f);\n}\n- if (pb->alpha_lns[i])\n+ if (blk->alpha_lns[i])\n{\ndata.set_lane<3>(float_to_lns(data.lane<3>()));\n}\n@@ -229,21 +229,21 @@ static void imageblock_initialize_work_from_orig(\n}\n// Store block data\n- pb->data_r[i] = data.lane<0>();\n- pb->data_g[i] = data.lane<1>();\n- pb->data_b[i] = data.lane<2>();\n- pb->data_a[i] = data.lane<3>();\n+ blk->data_r[i] = data.lane<0>();\n+ blk->data_g[i] = data.lane<1>();\n+ blk->data_b[i] = data.lane<2>();\n+ blk->data_a[i] = data.lane<3>();\n}\n// Store block metadata\n- pb->data_min = data_min;\n- pb->data_max = data_max;\n- pb->grayscale = grayscale;\n+ blk->data_min = data_min;\n+ blk->data_max = data_max;\n+ blk->grayscale = grayscale;\n}\n// helper function to initialize the orig-data from the work-data\nvoid imageblock_initialize_orig_from_work(\n- imageblock* pb,\n+ imageblock* blk,\nint pixelcount\n) {\nvfloat4 data_min(1e38f);\n@@ -252,14 +252,14 @@ void imageblock_initialize_orig_from_work(\nfor (int i = 0; i < pixelcount; i++)\n{\n- vfloat4 data = pb->texel(i);\n+ vfloat4 data = blk->texel(i);\nvint4 color_lns = vint4::zero();\nvint4 color_unorm = vint4::zero();\n// TODO: Pack these into bits and avoid the disjoint fetch\n- int rgb_lns = pb->rgb_lns[i];\n- int a_lns = pb->alpha_lns[i];\n+ int rgb_lns = blk->rgb_lns[i];\n+ int a_lns = blk->alpha_lns[i];\n// TODO: Do a vector version of lns_to_sf16\n// ... or do we even need the f16 intermediate?\n@@ -301,23 +301,23 @@ void imageblock_initialize_orig_from_work(\n}\n// Store block data\n- pb->data_r[i] = data.lane<0>();\n- pb->data_g[i] = data.lane<1>();\n- pb->data_b[i] = data.lane<2>();\n- pb->data_a[i] = data.lane<3>();\n+ blk->data_r[i] = data.lane<0>();\n+ blk->data_g[i] = data.lane<1>();\n+ blk->data_b[i] = data.lane<2>();\n+ blk->data_a[i] = data.lane<3>();\n}\n// Store block metadata\n- pb->data_min = data_min;\n- pb->data_max = data_max;\n- pb->grayscale = grayscale;\n+ blk->data_min = data_min;\n+ blk->data_max = data_max;\n+ blk->grayscale = grayscale;\n}\n// fetch an imageblock from the input file.\nvoid fetch_imageblock(\nastcenc_profile decode_mode,\nconst astcenc_image& img,\n- imageblock* pb, // picture-block to initialize with image data\n+ imageblock* blk, // picture-block to initialize with image data\nconst block_size_descriptor* bsd,\n// position in texture.\nint xpos,\n@@ -329,9 +329,9 @@ void fetch_imageblock(\nint ysize = img.dim_y;\nint zsize = img.dim_z;\n- pb->xpos = xpos;\n- pb->ypos = ypos;\n- pb->zpos = zpos;\n+ blk->xpos = xpos;\n+ blk->ypos = ypos;\n+ blk->zpos = zpos;\n// True if any non-identity swizzle\nbool needs_swz = (swz.r != ASTCENC_SWZ_R) || (swz.g != ASTCENC_SWZ_G) ||\n@@ -375,10 +375,10 @@ void fetch_imageblock(\na = data[swz.a];\n}\n- pb->data_r[idx] = static_cast<float>(r) / 255.0f;\n- pb->data_g[idx] = static_cast<float>(g) / 255.0f;\n- pb->data_b[idx] = static_cast<float>(b) / 255.0f;\n- pb->data_a[idx] = static_cast<float>(a) / 255.0f;\n+ blk->data_r[idx] = static_cast<float>(r) / 255.0f;\n+ blk->data_g[idx] = static_cast<float>(g) / 255.0f;\n+ blk->data_b[idx] = static_cast<float>(b) / 255.0f;\n+ blk->data_a[idx] = static_cast<float>(a) / 255.0f;\nidx++;\n}\n}\n@@ -422,10 +422,10 @@ void fetch_imageblock(\n}\nvfloat4 dataf = max(float16_to_float(vint4(r, g, b, a)), 1e-8);\n- pb->data_r[idx] = dataf.lane<0>();\n- pb->data_g[idx] = dataf.lane<1>();\n- pb->data_b[idx] = dataf.lane<2>();\n- pb->data_a[idx] = dataf.lane<3>();\n+ blk->data_r[idx] = dataf.lane<0>();\n+ blk->data_g[idx] = dataf.lane<1>();\n+ blk->data_b[idx] = dataf.lane<2>();\n+ blk->data_a[idx] = dataf.lane<3>();\nidx++;\n}\n}\n@@ -470,10 +470,10 @@ void fetch_imageblock(\na = data[swz.a];\n}\n- pb->data_r[idx] = astc::max(r, 1e-8f);\n- pb->data_g[idx] = astc::max(g, 1e-8f);\n- pb->data_b[idx] = astc::max(b, 1e-8f);\n- pb->data_a[idx] = astc::max(a, 1e-8f);\n+ blk->data_r[idx] = astc::max(r, 1e-8f);\n+ blk->data_g[idx] = astc::max(g, 1e-8f);\n+ blk->data_b[idx] = astc::max(b, 1e-8f);\n+ blk->data_a[idx] = astc::max(a, 1e-8f);\nidx++;\n}\n}\n@@ -486,17 +486,17 @@ void fetch_imageblock(\n// impose the choice on every pixel when encoding.\nfor (int i = 0; i < bsd->texel_count; i++)\n{\n- pb->rgb_lns[i] = rgb_lns;\n- pb->alpha_lns[i] = alpha_lns;\n- pb->nan_texel[i] = 0;\n+ blk->rgb_lns[i] = rgb_lns;\n+ blk->alpha_lns[i] = alpha_lns;\n+ blk->nan_texel[i] = 0;\n}\n- imageblock_initialize_work_from_orig(pb, bsd->texel_count);\n+ imageblock_initialize_work_from_orig(blk, bsd->texel_count);\n}\nvoid write_imageblock(\nastcenc_image& img,\n- const imageblock* pb, // picture-block to initialize with image data. We assume that orig_data is valid.\n+ const imageblock* blk, // picture-block to initialize with image data. We assume that orig_data is valid.\nconst block_size_descriptor* bsd,\n// position to write the block to\nint xpos,\n@@ -504,7 +504,7 @@ void write_imageblock(\nint zpos,\nastcenc_swizzle swz\n) {\n- const uint8_t *nptr = pb->nan_texel;\n+ const uint8_t *nptr = blk->nan_texel;\nint xsize = img.dim_x;\nint ysize = img.dim_y;\nint zsize = img.dim_z;\n@@ -551,10 +551,10 @@ void write_imageblock(\n}\nelse if (needs_swz)\n{\n- data[ASTCENC_SWZ_R] = pb->data_r[idx];\n- data[ASTCENC_SWZ_G] = pb->data_g[idx];\n- data[ASTCENC_SWZ_B] = pb->data_b[idx];\n- data[ASTCENC_SWZ_A] = pb->data_a[idx];\n+ data[ASTCENC_SWZ_R] = blk->data_r[idx];\n+ data[ASTCENC_SWZ_G] = blk->data_g[idx];\n+ data[ASTCENC_SWZ_B] = blk->data_b[idx];\n+ data[ASTCENC_SWZ_A] = blk->data_a[idx];\nif (needs_z)\n{\n@@ -575,10 +575,10 @@ void write_imageblock(\n}\nelse\n{\n- ri = astc::flt2int_rtn(astc::min(pb->data_r[idx], 1.0f) * 255.0f);\n- gi = astc::flt2int_rtn(astc::min(pb->data_g[idx], 1.0f) * 255.0f);\n- bi = astc::flt2int_rtn(astc::min(pb->data_b[idx], 1.0f) * 255.0f);\n- ai = astc::flt2int_rtn(astc::min(pb->data_a[idx], 1.0f) * 255.0f);\n+ ri = astc::flt2int_rtn(astc::min(blk->data_r[idx], 1.0f) * 255.0f);\n+ gi = astc::flt2int_rtn(astc::min(blk->data_g[idx], 1.0f) * 255.0f);\n+ bi = astc::flt2int_rtn(astc::min(blk->data_b[idx], 1.0f) * 255.0f);\n+ ai = astc::flt2int_rtn(astc::min(blk->data_a[idx], 1.0f) * 255.0f);\n}\ndata8[(4 * xsize * yi) + (4 * xi )] = ri;\n@@ -617,10 +617,10 @@ void write_imageblock(\n}\nelse if (needs_swz)\n{\n- data[ASTCENC_SWZ_R] = pb->data_r[idx];\n- data[ASTCENC_SWZ_G] = pb->data_g[idx];\n- data[ASTCENC_SWZ_B] = pb->data_b[idx];\n- data[ASTCENC_SWZ_A] = pb->data_a[idx];\n+ data[ASTCENC_SWZ_R] = blk->data_r[idx];\n+ data[ASTCENC_SWZ_G] = blk->data_g[idx];\n+ data[ASTCENC_SWZ_B] = blk->data_b[idx];\n+ data[ASTCENC_SWZ_A] = blk->data_a[idx];\nif (needs_z)\n{\n@@ -639,7 +639,7 @@ void write_imageblock(\n}\nelse\n{\n- vfloat4 colorf = pb->texel(idx);\n+ vfloat4 colorf = blk->texel(idx);\ncolor = float_to_float16(colorf);\n}\n@@ -684,10 +684,10 @@ void write_imageblock(\n}\nelse if (needs_swz)\n{\n- data[ASTCENC_SWZ_R] = pb->data_r[idx];\n- data[ASTCENC_SWZ_G] = pb->data_g[idx];\n- data[ASTCENC_SWZ_B] = pb->data_b[idx];\n- data[ASTCENC_SWZ_A] = pb->data_a[idx];\n+ data[ASTCENC_SWZ_R] = blk->data_r[idx];\n+ data[ASTCENC_SWZ_G] = blk->data_g[idx];\n+ data[ASTCENC_SWZ_B] = blk->data_b[idx];\n+ data[ASTCENC_SWZ_A] = blk->data_a[idx];\nif (needs_z)\n{\n@@ -708,10 +708,10 @@ void write_imageblock(\n}\nelse\n{\n- rf = pb->data_r[idx];\n- gf = pb->data_g[idx];\n- bf = pb->data_b[idx];\n- af = pb->data_a[idx];\n+ rf = blk->data_r[idx];\n+ gf = blk->data_g[idx];\n+ bf = blk->data_b[idx];\n+ af = blk->data_a[idx];\n}\ndata32[(4 * xsize * yi) + (4 * xi )] = rf;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -525,27 +525,27 @@ struct imageblock\n};\n-static inline int imageblock_uses_alpha(const imageblock * pb)\n+static inline int imageblock_uses_alpha(const imageblock * blk)\n{\n- return pb->data_min.lane<3>() != pb->data_max.lane<3>();\n+ return blk->data_min.lane<3>() != blk->data_max.lane<3>();\n}\n-static inline int imageblock_is_lum(const imageblock * pb)\n+static inline int imageblock_is_lum(const imageblock * blk)\n{\n- bool alpha1 = (pb->data_min.lane<3>() == 65535.0f) &&\n- (pb->data_max.lane<3>() == 65535.0f);\n- return pb->grayscale && alpha1;\n+ bool alpha1 = (blk->data_min.lane<3>() == 65535.0f) &&\n+ (blk->data_max.lane<3>() == 65535.0f);\n+ return blk->grayscale && alpha1;\n}\n-static inline int imageblock_is_lumalp(const imageblock * pb)\n+static inline int imageblock_is_lumalp(const imageblock * blk)\n{\n- bool alpha1 = (pb->data_min.lane<3>() == 65535.0f) &&\n- (pb->data_max.lane<3>() == 65535.0f);\n- return pb->grayscale && !alpha1;\n+ bool alpha1 = (blk->data_min.lane<3>() == 65535.0f) &&\n+ (blk->data_max.lane<3>() == 65535.0f);\n+ return blk->grayscale && !alpha1;\n}\nvoid imageblock_initialize_orig_from_work(\n- imageblock * pb,\n+ imageblock * blk,\nint pixelcount);\n/*\n@@ -1003,7 +1003,7 @@ void compute_averages_and_variances(\nvoid fetch_imageblock(\nastcenc_profile decode_mode,\nconst astcenc_image& img,\n- imageblock* pb, // picture-block to initialize with image data\n+ imageblock* blk, // picture-block to initialize with image data\nconst block_size_descriptor* bsd,\n// position in picture to fetch block from\nint xpos,\n@@ -1015,7 +1015,7 @@ void fetch_imageblock(\n// the data written are taken from orig_data.\nvoid write_imageblock(\nastcenc_image& img,\n- const imageblock* pb, // picture-block to initialize with image data\n+ const imageblock* blk, // picture-block to initialize with image data\nconst block_size_descriptor* bsd,\n// position in picture to write block to.\nint xpos,\n@@ -1027,7 +1027,7 @@ float compute_symbolic_block_difference(\nastcenc_profile decode_mode,\nconst block_size_descriptor* bsd,\nconst symbolic_compressed_block* scb,\n- const imageblock* pb,\n+ const imageblock* blk,\nconst error_weight_block *ewb) ;\n// ***********************************************************\n@@ -1167,7 +1167,7 @@ struct compress_symbolic_block_buffers\nvoid compute_encoding_choice_errors(\nconst block_size_descriptor* bsd,\n- const imageblock* pb,\n+ const imageblock* blk,\nconst partition_info* pt,\nconst error_weight_block* ewb,\nint separate_component, // component that is separated out in 2-plane mode, -1 in 1-plane mode\n@@ -1198,7 +1198,7 @@ void recompute_ideal_colors_1plane(\nconst uint8_t* weight_set8, // the current set of weight values\nconst partition_info* pt,\nconst decimation_table* it,\n- const imageblock* pb, // picture-block containing the actual data.\n+ const imageblock* blk, // picture-block containing the actual data.\nconst error_weight_block* ewb);\nvoid recompute_ideal_colors_2planes(\n@@ -1211,7 +1211,7 @@ void recompute_ideal_colors_2planes(\nint plane2_color_component, // color component for 2nd plane of weights; -1 if the 2nd plane of weights is not present\nconst partition_info* pt,\nconst decimation_table* it,\n- const imageblock* pb, // picture-block containing the actual data.\n+ const imageblock* blk, // picture-block containing the actual data.\nconst error_weight_block* ewb);\nvoid expand_deblock_weights(\n@@ -1221,7 +1221,7 @@ void expand_deblock_weights(\nvoid prepare_angular_tables();\nvoid imageblock_initialize_deriv(\n- const imageblock* pb,\n+ const imageblock* blk,\nint pixelcount,\nvfloat4* dptr);\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Standardize on blk for image block variables
61,745
19.02.2021 09:04:36
0
0ea58b1671ea68ff7f023302eb832a7f3b1e8db0
Make is_lum and is_lumalp HDR safe
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_encoding_choice_error.cpp", "new_path": "Source/astcenc_encoding_choice_error.cpp", "diff": "@@ -98,7 +98,7 @@ static void compute_error_squared_rgb_single_partition(\nvfloat4 ews = ewb->error_weights[i];\n// Compute the error that arises from just ditching alpha\n- float default_alpha = blk->alpha_lns[i] ? (float)0x7800 : (float)0xFFFF;\n+ float default_alpha = imageblock_default_alpha(blk);\nfloat omalpha = point.lane<3>() - default_alpha;\na_drop_errorsum += omalpha * omalpha * ews.lane<3>();\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -524,6 +524,11 @@ struct imageblock\n}\n};\n+static inline float imageblock_default_alpha(const imageblock * blk)\n+{\n+ return blk->alpha_lns[0] ? (float)0x7800 : (float)0xFFFF;\n+}\n+\nstatic inline int imageblock_uses_alpha(const imageblock * blk)\n{\n@@ -532,15 +537,17 @@ static inline int imageblock_uses_alpha(const imageblock * blk)\nstatic inline int imageblock_is_lum(const imageblock * blk)\n{\n- bool alpha1 = (blk->data_min.lane<3>() == 65535.0f) &&\n- (blk->data_max.lane<3>() == 65535.0f);\n+ float default_alpha = imageblock_default_alpha(blk);\n+ bool alpha1 = (blk->data_min.lane<3>() == default_alpha) &&\n+ (blk->data_max.lane<3>() == default_alpha);\nreturn blk->grayscale && alpha1;\n}\nstatic inline int imageblock_is_lumalp(const imageblock * blk)\n{\n- bool alpha1 = (blk->data_min.lane<3>() == 65535.0f) &&\n- (blk->data_max.lane<3>() == 65535.0f);\n+ float default_alpha = imageblock_default_alpha(blk);\n+ bool alpha1 = (blk->data_min.lane<3>() == default_alpha) &&\n+ (blk->data_max.lane<3>() == default_alpha);\nreturn blk->grayscale && !alpha1;\n}\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Make is_lum and is_lumalp HDR safe
61,745
20.02.2021 15:59:23
0
4d1f520fc9b32b8dda0f077dd7b82583a2e3cbb4
Vectorize stdev/variance conversion
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -1044,11 +1044,7 @@ static float prepare_error_weight_block(\nvariance.set_lane<1>(fvar * mixing + variance.lane<1>() * (1.0f - mixing));\nvariance.set_lane<2>(fvar * mixing + variance.lane<2>() * (1.0f - mixing));\n- // TODO: Vectorize this ...\n- vfloat4 stdev = vfloat4(astc::sqrt(astc::max(variance.lane<0>(), 0.0f)),\n- astc::sqrt(astc::max(variance.lane<1>(), 0.0f)),\n- astc::sqrt(astc::max(variance.lane<2>(), 0.0f)),\n- astc::sqrt(astc::max(variance.lane<3>(), 0.0f)));\n+ vfloat4 stdev = sqrt(max(variance, 0.0f));\nvfloat4 scalea(ctx.config.v_rgb_mean, ctx.config.v_rgb_mean, ctx.config.v_rgb_mean, ctx.config.v_a_mean);\navg = avg * scalea;\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Vectorize stdev/variance conversion
61,745
20.02.2021 16:17:22
0
2b3881776ad0df82a36f6a7c99ceb86588248c7b
Make vec4 normalize ISA agnostic, add _safe ver
[ { "change_type": "MODIFY", "old_path": "Source/UnitTest/test_simd.cpp", "new_path": "Source/UnitTest/test_simd.cpp", "diff": "@@ -981,6 +981,26 @@ TEST(vfloat4, normalize)\nEXPECT_NEAR(r.lane<3>(), 4.0f / astc::sqrt(30.0f), 0.0005f);\n}\n+/** @brief Test vfloat4 normalize_safe. */\n+TEST(vfloat4, normalize_safe)\n+{\n+ vfloat4 s(-1.0f, -1.0f, -1.0f, -1.0f);\n+\n+ vfloat4 a1(1.0f, 2.0f, 3.0f, 4.0f);\n+ vfloat4 r1 = normalize_safe(a1, s);\n+ EXPECT_NEAR(r1.lane<0>(), 1.0f / astc::sqrt(30.0f), 0.0005f);\n+ EXPECT_NEAR(r1.lane<1>(), 2.0f / astc::sqrt(30.0f), 0.0005f);\n+ EXPECT_NEAR(r1.lane<2>(), 3.0f / astc::sqrt(30.0f), 0.0005f);\n+ EXPECT_NEAR(r1.lane<3>(), 4.0f / astc::sqrt(30.0f), 0.0005f);\n+\n+ vfloat4 a2(0.0f, 0.0f, 0.0f, 0.0f);\n+ vfloat4 r2 = normalize_safe(a2, s);\n+ EXPECT_EQ(r2.lane<0>(), -1.0f);\n+ EXPECT_EQ(r2.lane<1>(), -1.0f);\n+ EXPECT_EQ(r2.lane<2>(), -1.0f);\n+ EXPECT_EQ(r2.lane<3>(), -1.0f);\n+}\n+\n/** @brief Test vfloat4 float_to_int. */\nTEST(vfloat4, float_to_int)\n{\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib.h", "new_path": "Source/astcenc_vecmathlib.h", "diff": "@@ -186,4 +186,43 @@ ASTCENC_SIMD_INLINE vfloat atan2(vfloat y, vfloat x)\nreturn change_sign(select(z, vfloat(astc::PI) - z, xmask), y);\n}\n+/*\n+ * @brief Factory that returns a unit length 4 component vfloat4.\n+ */\n+static ASTCENC_SIMD_INLINE vfloat4 unit4()\n+{\n+ return vfloat4(0.5f);\n+}\n+\n+/**\n+ * @brief Factory that returns a unit length 3 component vfloat4.\n+ */\n+static ASTCENC_SIMD_INLINE vfloat4 unit3()\n+{\n+ return vfloat4(0.57735f, 0.57735f, 0.57735f, 0.0f);\n+}\n+\n+/**\n+ * @brief Normalize a non-zero length vector to unit length.\n+ */\n+static ASTCENC_SIMD_INLINE vfloat4 normalize(vfloat4 a)\n+{\n+ vfloat4 length = dot(a, a);\n+ return a / sqrt(length);\n+}\n+\n+/**\n+ * @brief Normalize a vector, returning @c safe if len is zero.\n+ */\n+static ASTCENC_SIMD_INLINE vfloat4 normalize_safe(vfloat4 a, vfloat4 safe)\n+{\n+ vfloat4 length = dot(a, a);\n+ if (length.lane<0>() != 0.0f)\n+ {\n+ return a / sqrt(length);\n+ }\n+\n+ return safe;\n+}\n+\n#endif // #ifndef ASTC_VECMATHLIB_H_INCLUDED\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_neon_4.h", "new_path": "Source/astcenc_vecmathlib_neon_4.h", "diff": "@@ -966,16 +966,6 @@ ASTCENC_SIMD_INLINE float dot3_s(vfloat4 a, vfloat4 b)\nreturn dot3(a, b).lane<0>();\n}\n-/**\n- * @brief Normalize a vector to unit length.\n- */\n-ASTCENC_SIMD_INLINE vfloat4 normalize(vfloat4 a)\n-{\n- vfloat4 length = dot(a, a);\n- vfloat4 divisor = sqrt(length);\n- return a / divisor;\n-}\n-\n/**\n* @brief Return a integer value for a float vector, using truncation.\n*/\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_none_4.h", "new_path": "Source/astcenc_vecmathlib_none_4.h", "diff": "@@ -1076,16 +1076,6 @@ ASTCENC_SIMD_INLINE vfloat4 dot3(vfloat4 a, vfloat4 b)\nreturn vfloat4(d3, d3, d3, 0.0f);\n}\n-/**\n- * @brief Normalize a vector to unit length.\n- */\n-ASTCENC_SIMD_INLINE vfloat4 normalize(vfloat4 a)\n-{\n- vfloat4 length = dot(a, a);\n- vfloat4 divisor = sqrt(length);\n- return a / divisor;\n-}\n-\n/**\n* @brief Return a integer value for a float vector, using truncation.\n*/\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_sse_4.h", "new_path": "Source/astcenc_vecmathlib_sse_4.h", "diff": "@@ -1036,15 +1036,6 @@ ASTCENC_SIMD_INLINE vfloat4 recip(vfloat4 b)\nreturn 1.0f / b;\n}\n-/**\n- * @brief Normalize a vector to unit length.\n- */\n-ASTCENC_SIMD_INLINE vfloat4 normalize(vfloat4 a)\n-{\n- vfloat4 length = dot(a, a);\n- return a / sqrt(length);\n-}\n-\n/**\n* @brief Return a integer value for a float vector, using truncation.\n*/\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Make vec4 normalize ISA agnostic, add _safe ver
61,745
20.02.2021 17:23:58
0
0e2e155d78883a69cf7aff87a214230beaedf6bb
Style cleanup find_best_partitionings
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_find_best_partitioning.cpp", "new_path": "Source/astcenc_find_best_partitioning.cpp", "diff": "@@ -58,8 +58,8 @@ static void compute_partition_error_color_weightings_and_range(\nconst error_weight_block* ewb,\nconst partition_info* pt,\nvfloat4 error_weightings[4],\n- vfloat4 color_scalefactors[4],\n- vfloat4 rgba_range[4]\n+ vfloat4 color_scale_factors[4],\n+ vfloat4 ranges_rgba[4]\n) {\nint partition_count = pt->partition_count;\n@@ -85,8 +85,8 @@ static void compute_partition_error_color_weightings_and_range(\nerror_weight = error_weight / pt->texels_per_partition[i];\nerror_weightings[i] = error_weight;\n- color_scalefactors[i] = sqrt(error_weight);\n- rgba_range[i] = max(rgba_max - rgba_min, 1e-10f);\n+ color_scale_factors[i] = sqrt(error_weight);\n+ ranges_rgba[i] = max(rgba_max - rgba_min, 1e-10f);\n}\n}\n@@ -96,7 +96,7 @@ void compute_partition_error_color_weightings(\nconst error_weight_block* ewb,\nconst partition_info* pt,\nvfloat4 error_weightings[4],\n- vfloat4 color_scalefactors[4]\n+ vfloat4 color_scale_factors[4]\n) {\nint texels_per_block = bsd->texel_count;\nint pcnt = pt->partition_count;\n@@ -115,7 +115,7 @@ void compute_partition_error_color_weightings(\nfor (int i = 0; i < pcnt; i++)\n{\nerror_weightings[i] = error_weightings[i] * (1.0f / pt->texels_per_partition[i]);\n- color_scalefactors[i] = sqrt(error_weightings[i]);\n+ color_scale_factors[i] = sqrt(error_weightings[i]);\n}\n}\n@@ -126,15 +126,15 @@ void find_best_partitionings(\nconst error_weight_block* ewb,\nint partition_count,\nint partition_search_limit,\n- int* best_partition_uncorrelated,\n- int* best_partition_samechroma,\n+ int* best_partition_uncor,\n+ int* best_partition_samec,\nint* best_partition_dualplane\n) {\n// constant used to estimate quantization error for a given partitioning;\n// the optimal value for this constant depends on bitrate.\n// These constants have been determined empirically.\nint texels_per_block = bsd->texel_count;\n- float weight_imprecision_estim = 100.0f;\n+ float weight_imprecision_estim = 0.055f;\nif (texels_per_block <= 20)\n{\nweight_imprecision_estim = 0.03f;\n@@ -147,34 +147,30 @@ void find_best_partitionings(\n{\nweight_imprecision_estim = 0.05f;\n}\n- else\n- {\n- weight_imprecision_estim = 0.055f;\n- }\n+\n+ weight_imprecision_estim = weight_imprecision_estim * weight_imprecision_estim;\nint partition_sequence[PARTITION_COUNT];\nkmeans_compute_partition_ordering(bsd, partition_count, blk, partition_sequence);\n- float weight_imprecision_estim_squared = weight_imprecision_estim * weight_imprecision_estim;\n-\nint uses_alpha = imageblock_uses_alpha(blk);\nconst partition_info* ptab = get_partition_table(bsd, partition_count);\n// Partitioning errors assuming uncorrelated-chrominance endpoints\n- float uncorr_best_error { ERROR_CALC_DEFAULT };\n- int uncorr_best_partition { 0 };\n+ float uncor_best_error { ERROR_CALC_DEFAULT };\n+ int uncor_best_partition { 0 };\n// Partitioning errors assuming same-chrominance endpoints\n// Store two so we can always return one different to uncorr\n- float samechroma_best_errors[2] { ERROR_CALC_DEFAULT, ERROR_CALC_DEFAULT };\n- int samechroma_best_partitions[2] { 0, 0 };\n+ float samec_best_errors[2] { ERROR_CALC_DEFAULT, ERROR_CALC_DEFAULT };\n+ int samec_best_partitions[2] { 0, 0 };\n// Partitioning errors assuming that one color component is uncorrelated\n- float separate_best_error { ERROR_CALC_DEFAULT };\n- int separate_best_partition { 0 };\n- int separate_best_component { 0 };\n+ float sep_best_error { ERROR_CALC_DEFAULT };\n+ int sep_best_partition { 0 };\n+ int sep_best_component { 0 };\nif (uses_alpha)\n{\n@@ -183,6 +179,7 @@ void find_best_partitionings(\n{\nint partition = partition_sequence[i];\n+ // TODO: Can we avoid returning these completely?\nint bk_partition_count = ptab[partition].partition_count;\nif (bk_partition_count < partition_count)\n{\n@@ -192,151 +189,147 @@ void find_best_partitionings(\n// compute the weighting to give to each color channel\n// in each partition.\nvfloat4 error_weightings[4];\n- vfloat4 color_scalefactors[4];\n- vfloat4 inverse_color_scalefactors[4];\n- vfloat4 rgba_range[4];\n- compute_partition_error_color_weightings_and_range(blk, ewb, ptab + partition, error_weightings, color_scalefactors, rgba_range);\n+ vfloat4 color_scale_factors[4];\n+ vfloat4 icolor_scale_factors[4];\n+ vfloat4 ranges_rgba[4];\n+\n+ compute_partition_error_color_weightings_and_range(\n+ blk, ewb, ptab + partition, error_weightings,\n+ color_scale_factors, ranges_rgba);\nfor (int j = 0; j < partition_count; j++)\n{\n- inverse_color_scalefactors[j] = 1.0f / max(color_scalefactors[j], 1e-7f);\n+ icolor_scale_factors[j] = 1.0f / max(color_scale_factors[j], 1e-7f);\n}\n- vfloat4 averages[4];\n- vfloat4 directions_rgba[4];\n+ vfloat4 avgs_rgba[4];\n+ vfloat4 dirs_rgba[4];\ncompute_avgs_and_dirs_4_comp(ptab + partition, blk, ewb,\n- color_scalefactors, averages,\n- directions_rgba);\n-\n- line4 uncorr_lines[4];\n- line4 samechroma_lines[4];\n- line3 separate_red_lines[4];\n- line3 separate_green_lines[4];\n- line3 separate_blue_lines[4];\n- line3 separate_alpha_lines[4];\n-\n- processed_line4 proc_uncorr_lines[4];\n- processed_line4 proc_samechroma_lines[4];\n- processed_line3 proc_separate_red_lines[4];\n- processed_line3 proc_separate_green_lines[4];\n- processed_line3 proc_separate_blue_lines[4];\n- processed_line3 proc_separate_alpha_lines[4];\n-\n- float uncorr_linelengths[4];\n- float samechroma_linelengths[4];\n+ color_scale_factors, avgs_rgba,\n+ dirs_rgba);\n+\n+ line4 uncor_lines[4];\n+ line4 samec_lines[4];\n+ line3 sep_r_lines[4];\n+ line3 sep_g_lines[4];\n+ line3 sep_b_lines[4];\n+ line3 sep_a_lines[4];\n+\n+ processed_line4 uncor_plines[4];\n+ processed_line4 samec_plines[4];\n+ processed_line3 sep_r_plines[4];\n+ processed_line3 sep_g_plines[4];\n+ processed_line3 sep_b_plines[4];\n+ processed_line3 sep_a_plines[4];\n+\n+ float uncor_line_lens[4];\n+ float samec_line_lens[4];\nfor (int j = 0; j < partition_count; j++)\n{\n- uncorr_lines[j].a = averages[j];\n- if (dot_s(directions_rgba[j], directions_rgba[j]) == 0.0f)\n+ uncor_lines[j].a = avgs_rgba[j];\n+ if (dot_s(dirs_rgba[j], dirs_rgba[j]) == 0.0f)\n{\n- uncorr_lines[j].b = normalize(vfloat4(1.0f));\n+ uncor_lines[j].b = normalize(vfloat4(1.0f));\n}\nelse\n{\n- uncorr_lines[j].b = normalize(directions_rgba[j]);\n+ uncor_lines[j].b = normalize(dirs_rgba[j]);\n}\n- proc_uncorr_lines[j].amod = (uncorr_lines[j].a - uncorr_lines[j].b * dot(uncorr_lines[j].a, uncorr_lines[j].b)) * inverse_color_scalefactors[j];\n- proc_uncorr_lines[j].bs = uncorr_lines[j].b * color_scalefactors[j];\n- proc_uncorr_lines[j].bis = uncorr_lines[j].b * inverse_color_scalefactors[j];\n+ uncor_plines[j].amod = (uncor_lines[j].a - uncor_lines[j].b * dot(uncor_lines[j].a, uncor_lines[j].b)) * icolor_scale_factors[j];\n+ uncor_plines[j].bs = uncor_lines[j].b * color_scale_factors[j];\n+ uncor_plines[j].bis = uncor_lines[j].b * icolor_scale_factors[j];\n- samechroma_lines[j].a = vfloat4::zero();\n- if (dot_s(averages[j], averages[j]) == 0.0f)\n+ samec_lines[j].a = vfloat4::zero();\n+ if (dot_s(avgs_rgba[j], avgs_rgba[j]) == 0.0f)\n{\n- samechroma_lines[j].b = normalize(vfloat4(1.0f));\n+ samec_lines[j].b = normalize(vfloat4(1.0f));\n}\nelse\n{\n- samechroma_lines[j].b = normalize(averages[j]);\n+ samec_lines[j].b = normalize(avgs_rgba[j]);\n}\n- proc_samechroma_lines[j].amod = (samechroma_lines[j].a - samechroma_lines[j].b * dot(samechroma_lines[j].a, samechroma_lines[j].b)) * inverse_color_scalefactors[j];\n- proc_samechroma_lines[j].bs = samechroma_lines[j].b * color_scalefactors[j];\n- proc_samechroma_lines[j].bis = samechroma_lines[j].b * inverse_color_scalefactors[j];\n+ samec_plines[j].amod = (samec_lines[j].a - samec_lines[j].b * dot(samec_lines[j].a, samec_lines[j].b)) * icolor_scale_factors[j];\n+ samec_plines[j].bs = samec_lines[j].b * color_scale_factors[j];\n+ samec_plines[j].bis = samec_lines[j].b * icolor_scale_factors[j];\n- // TODO: Future: implement swizzle 3 as a vfloat 4\n- separate_red_lines[j].a = averages[j].swz<1, 2, 3, 0>();\n- separate_red_lines[j].a.set_lane<3>(0.0f);\n- vfloat4 dirs_gba = directions_rgba[j].swz<1, 2, 3, 0>();\n+ sep_r_lines[j].a = avgs_rgba[j].swz<1, 2, 3>();\n+ vfloat4 dirs_gba = dirs_rgba[j].swz<1, 2, 3, 0>();\nif (dot3_s(dirs_gba, dirs_gba) == 0.0f)\n{\n- separate_red_lines[j].b = normalize(vfloat4(1.0f, 1.0f, 1.0f, 0.0f));\n+ sep_r_lines[j].b = normalize(vfloat4(1.0f, 1.0f, 1.0f, 0.0f));\n}\nelse\n{\n- separate_red_lines[j].b = normalize(dirs_gba);\n+ sep_r_lines[j].b = normalize(dirs_gba);\n}\n- separate_green_lines[j].a = averages[j].swz<0, 2, 3, 1>();\n- separate_red_lines[j].a.set_lane<3>(0.0f);\n- vfloat4 dirs_rba = directions_rgba[j].swz<0, 2, 3, 1>();\n+ sep_g_lines[j].a = avgs_rgba[j].swz<0, 2, 3>();\n+ vfloat4 dirs_rba = dirs_rgba[j].swz<0, 2, 3, 1>();\nif (dot3_s(dirs_rba, dirs_rba) == 0.0f)\n{\n- separate_green_lines[j].b = normalize(vfloat4(1.0f, 1.0f, 1.0f, 0.0f));\n+ sep_g_lines[j].b = normalize(vfloat4(1.0f, 1.0f, 1.0f, 0.0f));\n}\nelse\n{\n- separate_green_lines[j].b = normalize(dirs_rba);\n+ sep_g_lines[j].b = normalize(dirs_rba);\n}\n- separate_blue_lines[j].a = averages[j].swz<0, 1, 3, 2>();\n- separate_blue_lines[j].a.set_lane<3>(0.0f);\n- vfloat4 dirs_rga = directions_rgba[j].swz<0, 1, 3, 2>();\n+ sep_b_lines[j].a = avgs_rgba[j].swz<0, 1, 3>();\n+ vfloat4 dirs_rga = dirs_rgba[j].swz<0, 1, 3, 2>();\nif (dot3_s(dirs_rga, dirs_rga) == 0.0f)\n{\n- separate_blue_lines[j].b = normalize(vfloat4(1.0f, 1.0f, 1.0f, 0.0f));\n+ sep_b_lines[j].b = normalize(vfloat4(1.0f, 1.0f, 1.0f, 0.0f));\n}\nelse\n{\n- separate_blue_lines[j].b = normalize(dirs_rga);\n+ sep_b_lines[j].b = normalize(dirs_rga);\n}\n- separate_alpha_lines[j].a = averages[j].swz<0, 1, 2, 3>();\n- separate_alpha_lines[j].a.set_lane<3>(0.0f);\n-\n- vfloat4 dirs_rgb = directions_rgba[j].swz<0, 1, 2, 3>();\n+ sep_a_lines[j].a = avgs_rgba[j].swz<0, 1, 2>();\n+ vfloat4 dirs_rgb = dirs_rgba[j].swz<0, 1, 2, 3>();\nif (dot3_s(dirs_rgb, dirs_rgb) == 0.0f)\n{\n- separate_alpha_lines[j].b = normalize(vfloat4(1.0f, 1.0f, 1.0f, 0.0f));\n+ sep_a_lines[j].b = normalize(vfloat4(1.0f, 1.0f, 1.0f, 0.0f));\n}\nelse\n{\n- separate_alpha_lines[j].b = normalize(dirs_rgb);\n+ sep_a_lines[j].b = normalize(dirs_rgb);\n}\n- proc_separate_red_lines[j].amod = (separate_red_lines[j].a - separate_red_lines[j].b * dot3_s(separate_red_lines[j].a, separate_red_lines[j].b)) * inverse_color_scalefactors[j].swz<1, 2, 3, 0>();\n- proc_separate_red_lines[j].bs = (separate_red_lines[j].b * color_scalefactors[j].swz<1, 2, 3, 0>());\n- proc_separate_red_lines[j].bis = (separate_red_lines[j].b * inverse_color_scalefactors[j].swz<1, 2, 3, 0>());\n+ sep_r_plines[j].amod = (sep_r_lines[j].a - sep_r_lines[j].b * dot3(sep_r_lines[j].a, sep_r_lines[j].b)) * icolor_scale_factors[j].swz<1, 2, 3, 0>();\n+ sep_r_plines[j].bs = (sep_r_lines[j].b * color_scale_factors[j].swz<1, 2, 3, 0>());\n+ sep_r_plines[j].bis = (sep_r_lines[j].b * icolor_scale_factors[j].swz<1, 2, 3, 0>());\n- proc_separate_green_lines[j].amod =\n- (separate_green_lines[j].a - separate_green_lines[j].b * dot3_s(separate_green_lines[j].a, separate_green_lines[j].b)) * inverse_color_scalefactors[j].swz<0, 2, 3, 1>();\n- proc_separate_green_lines[j].bs = (separate_green_lines[j].b * color_scalefactors[j].swz<0, 2, 3, 1>());\n- proc_separate_green_lines[j].bis = (separate_green_lines[j].b * inverse_color_scalefactors[j].swz<0, 2, 3, 1>());\n+ sep_g_plines[j].amod = (sep_g_lines[j].a - sep_g_lines[j].b * dot3(sep_g_lines[j].a, sep_g_lines[j].b)) * icolor_scale_factors[j].swz<0, 2, 3, 1>();\n+ sep_g_plines[j].bs = (sep_g_lines[j].b * color_scale_factors[j].swz<0, 2, 3, 1>());\n+ sep_g_plines[j].bis = (sep_g_lines[j].b * icolor_scale_factors[j].swz<0, 2, 3, 1>());\n- proc_separate_blue_lines[j].amod = (separate_blue_lines[j].a - separate_blue_lines[j].b * dot3_s(separate_blue_lines[j].a, separate_blue_lines[j].b)) * inverse_color_scalefactors[j].swz<0, 1, 3, 2>();\n- proc_separate_blue_lines[j].bs = (separate_blue_lines[j].b * color_scalefactors[j].swz<0, 1, 3, 2>());\n- proc_separate_blue_lines[j].bis = (separate_blue_lines[j].b * inverse_color_scalefactors[j].swz<0, 1, 3, 2>());\n+ sep_b_plines[j].amod = (sep_b_lines[j].a - sep_b_lines[j].b * dot3(sep_b_lines[j].a, sep_b_lines[j].b)) * icolor_scale_factors[j].swz<0, 1, 3, 2>();\n+ sep_b_plines[j].bs = (sep_b_lines[j].b * color_scale_factors[j].swz<0, 1, 3, 2>());\n+ sep_b_plines[j].bis = (sep_b_lines[j].b * icolor_scale_factors[j].swz<0, 1, 3, 2>());\n- proc_separate_alpha_lines[j].amod =\n- (separate_alpha_lines[j].a - separate_alpha_lines[j].b * dot3_s(separate_alpha_lines[j].a, separate_alpha_lines[j].b)) * inverse_color_scalefactors[j].swz<0, 1, 2, 3>();\n- proc_separate_alpha_lines[j].bs = (separate_alpha_lines[j].b * color_scalefactors[j].swz<0, 1, 2, 3>());\n- proc_separate_alpha_lines[j].bis = (separate_alpha_lines[j].b * inverse_color_scalefactors[j].swz<0, 1, 2, 3>());\n+ sep_a_plines[j].amod = (sep_a_lines[j].a - sep_a_lines[j].b * dot3(sep_a_lines[j].a, sep_a_lines[j].b)) * icolor_scale_factors[j].swz<0, 1, 2, 3>();\n+ sep_a_plines[j].bs = (sep_a_lines[j].b * color_scale_factors[j].swz<0, 1, 2, 3>());\n+ sep_a_plines[j].bis = (sep_a_lines[j].b * icolor_scale_factors[j].swz<0, 1, 2, 3>());\n}\n- float uncorr_error = 0.0f;\n- float samechroma_error = 0.0f;\n- vfloat4 separate_error = vfloat4::zero();\n+ float uncor_error = 0.0f;\n+ float samec_error = 0.0f;\n+ // TODO: Try this as a scalar\n+ vfloat4 sep_error = vfloat4::zero();\ncompute_error_squared_rgba(ptab + partition,\nblk,\newb,\n- proc_uncorr_lines,\n- proc_samechroma_lines,\n- uncorr_linelengths,\n- samechroma_linelengths,\n- &uncorr_error,\n- &samechroma_error);\n+ uncor_plines,\n+ samec_plines,\n+ uncor_line_lens,\n+ samec_line_lens,\n+ &uncor_error,\n+ &samec_error);\n/*\nCompute an estimate of error introduced by weight quantization imprecision.\n@@ -354,80 +347,80 @@ void find_best_partitionings(\n{\nfloat tpp = (float)(ptab[partition].texels_per_partition[j]);\n- vfloat4 ics = inverse_color_scalefactors[j];\n- vfloat4 error_weights = error_weightings[j] * (tpp * weight_imprecision_estim_squared);\n+ vfloat4 ics = icolor_scale_factors[j];\n+ vfloat4 error_weights = error_weightings[j] * (tpp * weight_imprecision_estim);\n- vfloat4 uncorr_vector = uncorr_lines[j].b * uncorr_linelengths[j] * ics;\n- vfloat4 samechroma_vector = samechroma_lines[j].b * samechroma_linelengths[j] * ics;\n- vfloat4 separate_red_vector = separate_red_lines[j].b * ics.swz<1, 2, 3, 0>();\n- vfloat4 separate_green_vector = separate_green_lines[j].b * ics.swz<0, 2, 3, 1>();\n- vfloat4 separate_blue_vector = separate_blue_lines[j].b * ics.swz<0, 1, 3, 2>();\n- vfloat4 separate_alpha_vector = separate_alpha_lines[j].b * ics.swz<0, 1, 2, 3>();\n+ vfloat4 uncor_vector = uncor_lines[j].b * uncor_line_lens[j] * ics;\n+ vfloat4 samec_vector = samec_lines[j].b * samec_line_lens[j] * ics;\n+ vfloat4 sep_r_vector = sep_r_lines[j].b * ics.swz<1, 2, 3, 0>();\n+ vfloat4 sep_g_vector = sep_g_lines[j].b * ics.swz<0, 2, 3, 1>();\n+ vfloat4 sep_b_vector = sep_b_lines[j].b * ics.swz<0, 1, 3, 2>();\n+ vfloat4 sep_a_vector = sep_a_lines[j].b * ics.swz<0, 1, 2, 3>();\n- uncorr_vector = uncorr_vector * uncorr_vector;\n- samechroma_vector = samechroma_vector * samechroma_vector;\n- separate_red_vector = separate_red_vector * separate_red_vector;\n- separate_green_vector = separate_green_vector * separate_green_vector;\n- separate_blue_vector = separate_blue_vector * separate_blue_vector;\n- separate_alpha_vector = separate_alpha_vector * separate_alpha_vector;\n+ uncor_vector = uncor_vector * uncor_vector;\n+ samec_vector = samec_vector * samec_vector;\n+ sep_r_vector = sep_r_vector * sep_r_vector;\n+ sep_g_vector = sep_g_vector * sep_g_vector;\n+ sep_b_vector = sep_b_vector * sep_b_vector;\n+ sep_a_vector = sep_a_vector * sep_a_vector;\n- uncorr_error += dot_s(uncorr_vector, error_weights);\n- samechroma_error += dot_s(samechroma_vector, error_weights);\n+ uncor_error += dot_s(uncor_vector, error_weights);\n+ samec_error += dot_s(samec_vector, error_weights);\n- vfloat4 sep_err_inc(dot3_s(separate_red_vector, error_weights.swz<1, 2, 3, 0>()),\n- dot3_s(separate_green_vector, error_weights.swz<0, 2, 3, 1>()),\n- dot3_s(separate_blue_vector, error_weights.swz<0, 1, 3, 2>()),\n- dot3_s(separate_alpha_vector, error_weights.swz<0, 1, 2, 3>()));\n+ vfloat4 sep_err_inc(dot3_s(sep_r_vector, error_weights.swz<1, 2, 3, 0>()),\n+ dot3_s(sep_g_vector, error_weights.swz<0, 2, 3, 1>()),\n+ dot3_s(sep_b_vector, error_weights.swz<0, 1, 3, 2>()),\n+ dot3_s(sep_a_vector, error_weights.swz<0, 1, 2, 3>()));\n- separate_error = separate_error + sep_err_inc + (rgba_range[j] * rgba_range[j] * error_weights);\n+ sep_error = sep_error + sep_err_inc + (ranges_rgba[j] * ranges_rgba[j] * error_weights);\n}\n- if (uncorr_error < uncorr_best_error)\n+ if (uncor_error < uncor_best_error)\n{\n- uncorr_best_error = uncorr_error;\n- uncorr_best_partition = partition;\n+ uncor_best_error = uncor_error;\n+ uncor_best_partition = partition;\n}\n- if (samechroma_error < samechroma_best_errors[0])\n+ if (samec_error < samec_best_errors[0])\n{\n- samechroma_best_errors[1] = samechroma_best_errors[0];\n- samechroma_best_partitions[1] = samechroma_best_partitions[0];\n+ samec_best_errors[1] = samec_best_errors[0];\n+ samec_best_partitions[1] = samec_best_partitions[0];\n- samechroma_best_errors[0] = samechroma_error;\n- samechroma_best_partitions[0] = partition;\n+ samec_best_errors[0] = samec_error;\n+ samec_best_partitions[0] = partition;\n}\n- else if (samechroma_error < samechroma_best_errors[1])\n+ else if (samec_error < samec_best_errors[1])\n{\n- samechroma_best_errors[1] = samechroma_error;\n- samechroma_best_partitions[1] = partition;\n+ samec_best_errors[1] = samec_error;\n+ samec_best_partitions[1] = partition;\n}\n- if (separate_error.lane<0>() < separate_best_error)\n+ if (sep_error.lane<0>() < sep_best_error)\n{\n- separate_best_error = separate_error.lane<0>();\n- separate_best_partition = partition;\n- separate_best_component = 0;\n+ sep_best_error = sep_error.lane<0>();\n+ sep_best_partition = partition;\n+ sep_best_component = 0;\n}\n- if (separate_error.lane<1>() < separate_best_error)\n+ if (sep_error.lane<1>() < sep_best_error)\n{\n- separate_best_error = separate_error.lane<1>();\n- separate_best_partition = partition;\n- separate_best_component = 1;\n+ sep_best_error = sep_error.lane<1>();\n+ sep_best_partition = partition;\n+ sep_best_component = 1;\n}\n- if (separate_error.lane<2>() < separate_best_error)\n+ if (sep_error.lane<2>() < sep_best_error)\n{\n- separate_best_error = separate_error.lane<2>();\n- separate_best_partition = partition;\n- separate_best_component = 2;\n+ sep_best_error = sep_error.lane<2>();\n+ sep_best_partition = partition;\n+ sep_best_component = 2;\n}\n- if (separate_error.lane<3>() < separate_best_error)\n+ if (sep_error.lane<3>() < sep_best_error)\n{\n- separate_best_error = separate_error.lane<3>();\n- separate_best_partition = partition;\n- separate_best_component = 3;\n+ sep_best_error = sep_error.lane<3>();\n+ sep_best_partition = partition;\n+ sep_best_component = 3;\n}\n}\n}\n@@ -446,127 +439,128 @@ void find_best_partitionings(\n// compute the weighting to give to each color channel\n// in each partition.\nvfloat4 error_weightings[4];\n- vfloat4 color_scalefactors[4];\n- vfloat4 inverse_color_scalefactors[4];\n- vfloat4 rgba_range[4];\n- compute_partition_error_color_weightings_and_range(blk, ewb, ptab + partition, error_weightings, color_scalefactors, rgba_range);\n+ vfloat4 color_scale_factors[4];\n+ vfloat4 icolor_scale_factors[4];\n+ vfloat4 ranges_rgba[4];\n+ compute_partition_error_color_weightings_and_range(\n+ blk, ewb, ptab + partition, error_weightings,\n+ color_scale_factors, ranges_rgba);\nfor (int j = 0; j < partition_count; j++)\n{\n- inverse_color_scalefactors[j] = 1.0f / max(color_scalefactors[j], 1e-7f);\n+ icolor_scale_factors[j] = 1.0f / max(color_scale_factors[j], 1e-7f);\n}\n- vfloat4 averages[4];\n- vfloat4 directions_rgb[4];\n+ vfloat4 avgs_rgba[4];\n+ vfloat4 dirs_rgb[4];\n- compute_avgs_and_dirs_3_comp(ptab + partition, blk, ewb, color_scalefactors, 3, averages, directions_rgb);\n+ compute_avgs_and_dirs_3_comp(ptab + partition, blk, ewb, color_scale_factors, 3, avgs_rgba, dirs_rgb);\n- line3 uncorr_lines[4];\n- line3 samechroma_lines[4];\n- line2 separate_red_lines[4];\n- line2 separate_green_lines[4];\n- line2 separate_blue_lines[4];\n+ line3 uncor_lines[4];\n+ line3 samec_lines[4];\n+ line2 sep_r_lines[4];\n+ line2 sep_g_lines[4];\n+ line2 sep_b_lines[4];\n- processed_line3 proc_uncorr_lines[4];\n- processed_line3 proc_samechroma_lines[4];\n+ processed_line3 uncor_plines[4];\n+ processed_line3 samec_plines[4];\n- processed_line2 proc_separate_red_lines[4];\n- processed_line2 proc_separate_green_lines[4];\n- processed_line2 proc_separate_blue_lines[4];\n+ processed_line2 sep_r_plines[4];\n+ processed_line2 sep_g_plines[4];\n+ processed_line2 sep_b_plines[4];\n- float uncorr_linelengths[4];\n- float samechroma_linelengths[4];\n+ float uncor_line_lens[4];\n+ float samec_line_lens[4];\nfor (int j = 0; j < partition_count; j++)\n{\n- uncorr_lines[j].a = averages[j];\n- if (dot3_s(directions_rgb[j], directions_rgb[j]) == 0.0f)\n+ uncor_lines[j].a = avgs_rgba[j];\n+ if (dot3_s(dirs_rgb[j], dirs_rgb[j]) == 0.0f)\n{\n- uncorr_lines[j].b = normalize(vfloat4(1.0f, 1.0f, 1.0f, 0.0f));\n+ uncor_lines[j].b = normalize(vfloat4(1.0f, 1.0f, 1.0f, 0.0f));\n}\nelse\n{\n- uncorr_lines[j].b = normalize(directions_rgb[j]);\n+ uncor_lines[j].b = normalize(dirs_rgb[j]);\n}\n- samechroma_lines[j].a = vfloat4::zero();\n- if (dot3_s(averages[j], averages[j]) == 0.0f)\n+ samec_lines[j].a = vfloat4::zero();\n+ if (dot3_s(avgs_rgba[j], avgs_rgba[j]) == 0.0f)\n{\n- samechroma_lines[j].b = normalize(vfloat4(1.0f, 1.0f, 1.0f, 0.0f));\n+ samec_lines[j].b = normalize(vfloat4(1.0f, 1.0f, 1.0f, 0.0f));\n}\nelse\n{\n- samechroma_lines[j].b = normalize(averages[j]);\n+ samec_lines[j].b = normalize(avgs_rgba[j]);\n}\n- // TODO: dot3, not 3_s?\n- proc_uncorr_lines[j].amod = (uncorr_lines[j].a - uncorr_lines[j].b * dot3_s(uncorr_lines[j].a, uncorr_lines[j].b)) * inverse_color_scalefactors[j].swz<0, 1, 2, 3>();\n- proc_uncorr_lines[j].bs = (uncorr_lines[j].b * color_scalefactors[j].swz<0, 1, 2, 3>());\n- proc_uncorr_lines[j].bis = (uncorr_lines[j].b * inverse_color_scalefactors[j].swz<0, 1, 2, 3>());\n+ uncor_plines[j].amod = (uncor_lines[j].a - uncor_lines[j].b * dot3(uncor_lines[j].a, uncor_lines[j].b)) * icolor_scale_factors[j].swz<0, 1, 2, 3>();\n+ uncor_plines[j].bs = (uncor_lines[j].b * color_scale_factors[j].swz<0, 1, 2, 3>());\n+ uncor_plines[j].bis = (uncor_lines[j].b * icolor_scale_factors[j].swz<0, 1, 2, 3>());\n- proc_samechroma_lines[j].amod = (samechroma_lines[j].a - samechroma_lines[j].b * dot(samechroma_lines[j].a, samechroma_lines[j].b)) * inverse_color_scalefactors[j].swz<0, 1, 2, 3>();\n- proc_samechroma_lines[j].bs = (samechroma_lines[j].b * color_scalefactors[j].swz<0, 1, 2, 3>());\n- proc_samechroma_lines[j].bis = (samechroma_lines[j].b * inverse_color_scalefactors[j].swz<0, 1, 2, 3>());\n+ samec_plines[j].amod = (samec_lines[j].a - samec_lines[j].b * dot(samec_lines[j].a, samec_lines[j].b)) * icolor_scale_factors[j].swz<0, 1, 2, 3>();\n+ samec_plines[j].bs = (samec_lines[j].b * color_scale_factors[j].swz<0, 1, 2, 3>());\n+ samec_plines[j].bis = (samec_lines[j].b * icolor_scale_factors[j].swz<0, 1, 2, 3>());\n- separate_red_lines[j].a = averages[j].swz<1, 2>();\n- float2 dirs_gb = directions_rgb[j].swz<1, 2>();\n+ sep_r_lines[j].a = avgs_rgba[j].swz<1, 2>();\n+ float2 dirs_gb = dirs_rgb[j].swz<1, 2>();\nif (dot(dirs_gb, dirs_gb) == 0.0f)\n{\n- separate_red_lines[j].b = normalize(float2(1.0f));\n+ sep_r_lines[j].b = normalize(float2(1.0f));\n}\nelse\n{\n- separate_red_lines[j].b = normalize(dirs_gb);\n+ sep_r_lines[j].b = normalize(dirs_gb);\n}\n- separate_green_lines[j].a = averages[j].swz<0, 2>();\n- float2 dirs_rb = directions_rgb[j].swz<0, 2>();\n+ sep_g_lines[j].a = avgs_rgba[j].swz<0, 2>();\n+ float2 dirs_rb = dirs_rgb[j].swz<0, 2>();\nif (dot(dirs_rb, dirs_rb) == 0.0f)\n{\n- separate_green_lines[j].b = normalize(float2(1.0f));\n+ sep_g_lines[j].b = normalize(float2(1.0f));\n}\nelse\n{\n- separate_green_lines[j].b = normalize(dirs_rb);\n+ sep_g_lines[j].b = normalize(dirs_rb);\n}\n- separate_blue_lines[j].a = averages[j].swz<0, 1>();\n- float2 dirs_rg = directions_rgb[j].swz<0, 1>();\n+ sep_b_lines[j].a = avgs_rgba[j].swz<0, 1>();\n+ float2 dirs_rg = dirs_rgb[j].swz<0, 1>();\nif (dot(dirs_rg, dirs_rg) == 0.0f)\n{\n- separate_blue_lines[j].b = normalize(float2(1.0f));\n+ sep_b_lines[j].b = normalize(float2(1.0f));\n}\nelse\n{\n- separate_blue_lines[j].b = normalize(dirs_rg);\n+ sep_b_lines[j].b = normalize(dirs_rg);\n}\n- proc_separate_red_lines[j].amod = (separate_red_lines[j].a - separate_red_lines[j].b * dot(separate_red_lines[j].a, separate_red_lines[j].b)) * inverse_color_scalefactors[j].swz<1, 2>();\n- proc_separate_red_lines[j].bs = (separate_red_lines[j].b * color_scalefactors[j].swz<1, 2>());\n- proc_separate_red_lines[j].bis = (separate_red_lines[j].b * inverse_color_scalefactors[j].swz<1, 2>());\n+ sep_r_plines[j].amod = (sep_r_lines[j].a - sep_r_lines[j].b * dot(sep_r_lines[j].a, sep_r_lines[j].b)) * icolor_scale_factors[j].swz<1, 2>();\n+ sep_r_plines[j].bs = (sep_r_lines[j].b * color_scale_factors[j].swz<1, 2>());\n+ sep_r_plines[j].bis = (sep_r_lines[j].b * icolor_scale_factors[j].swz<1, 2>());\n- proc_separate_green_lines[j].amod = (separate_green_lines[j].a - separate_green_lines[j].b * dot(separate_green_lines[j].a, separate_green_lines[j].b)) * inverse_color_scalefactors[j].swz<0, 2>();\n- proc_separate_green_lines[j].bs = (separate_green_lines[j].b * color_scalefactors[j].swz<0, 2>());\n- proc_separate_green_lines[j].bis = (separate_green_lines[j].b * inverse_color_scalefactors[j].swz<0, 2>());\n+ sep_g_plines[j].amod = (sep_g_lines[j].a - sep_g_lines[j].b * dot(sep_g_lines[j].a, sep_g_lines[j].b)) * icolor_scale_factors[j].swz<0, 2>();\n+ sep_g_plines[j].bs = (sep_g_lines[j].b * color_scale_factors[j].swz<0, 2>());\n+ sep_g_plines[j].bis = (sep_g_lines[j].b * icolor_scale_factors[j].swz<0, 2>());\n- proc_separate_blue_lines[j].amod = (separate_blue_lines[j].a - separate_blue_lines[j].b * dot(separate_blue_lines[j].a, separate_blue_lines[j].b)) * inverse_color_scalefactors[j].swz<0, 1>();\n- proc_separate_blue_lines[j].bs = (separate_blue_lines[j].b * color_scalefactors[j].swz<0, 1>());\n- proc_separate_blue_lines[j].bis = (separate_blue_lines[j].b * inverse_color_scalefactors[j].swz<0, 1>());\n+ sep_b_plines[j].amod = (sep_b_lines[j].a - sep_b_lines[j].b * dot(sep_b_lines[j].a, sep_b_lines[j].b)) * icolor_scale_factors[j].swz<0, 1>();\n+ sep_b_plines[j].bs = (sep_b_lines[j].b * color_scale_factors[j].swz<0, 1>());\n+ sep_b_plines[j].bis = (sep_b_lines[j].b * icolor_scale_factors[j].swz<0, 1>());\n}\n- float uncorr_error = 0.0f;\n- float samechroma_error = 0.0f;\n- vfloat4 separate_error = vfloat4(0.0f);\n+ float uncor_error = 0.0f;\n+ float samec_error = 0.0f;\n+ vfloat4 sep_error = vfloat4(0.0f);\ncompute_error_squared_rgb(ptab + partition,\nblk,\newb,\n- proc_uncorr_lines,\n- proc_samechroma_lines,\n- uncorr_linelengths,\n- samechroma_linelengths,\n- &uncorr_error,\n- &samechroma_error);\n+ uncor_plines,\n+ samec_plines,\n+ uncor_line_lens,\n+ samec_line_lens,\n+ &uncor_error,\n+ &samec_error);\n/*\ncompute an estimate of error introduced by weight imprecision.\n@@ -584,85 +578,86 @@ void find_best_partitionings(\n{\nfloat tpp = (float)(ptab[partition].texels_per_partition[j]);\n- vfloat4 ics = inverse_color_scalefactors[j];\n+ vfloat4 ics = icolor_scale_factors[j];\nics.set_lane<3>(0.0f);\n- vfloat4 error_weights = error_weightings[j] * (tpp * weight_imprecision_estim_squared);\n+\n+ vfloat4 error_weights = error_weightings[j] * (tpp * weight_imprecision_estim);\nerror_weights.set_lane<3>(0.0f);\n- vfloat4 uncorr_vector = (uncorr_lines[j].b * uncorr_linelengths[j]) * ics;\n- vfloat4 samechroma_vector = (samechroma_lines[j].b * samechroma_linelengths[j]) * ics;\n+ vfloat4 uncor_vector = (uncor_lines[j].b * uncor_line_lens[j]) * ics;\n+ vfloat4 samec_vector = (samec_lines[j].b * samec_line_lens[j]) * ics;\n- float2 separate_red_vector = separate_red_lines[j].b * ics.swz<1, 2>();\n- float2 separate_green_vector = separate_green_lines[j].b * ics.swz<0, 2>();\n- float2 separate_blue_vector = separate_blue_lines[j].b * ics.swz<0, 1>();\n+ float2 sep_r_vector = sep_r_lines[j].b * ics.swz<1, 2>();\n+ float2 sep_g_vector = sep_g_lines[j].b * ics.swz<0, 2>();\n+ float2 sep_b_vector = sep_b_lines[j].b * ics.swz<0, 1>();\n- uncorr_vector = uncorr_vector * uncorr_vector;\n- samechroma_vector = samechroma_vector * samechroma_vector;\n- separate_red_vector = separate_red_vector * separate_red_vector;\n- separate_green_vector = separate_green_vector * separate_green_vector;\n- separate_blue_vector = separate_blue_vector * separate_blue_vector;\n+ uncor_vector = uncor_vector * uncor_vector;\n+ samec_vector = samec_vector * samec_vector;\n+ sep_r_vector = sep_r_vector * sep_r_vector;\n+ sep_g_vector = sep_g_vector * sep_g_vector;\n+ sep_b_vector = sep_b_vector * sep_b_vector;\n- uncorr_error += dot3_s(uncorr_vector, error_weights);\n- samechroma_error += dot3_s(samechroma_vector, error_weights);\n- separate_error.set_lane<0>(separate_error.lane<0>() + dot(separate_red_vector, error_weights.swz<1, 2>()));\n- separate_error.set_lane<1>(separate_error.lane<1>() + dot(separate_green_vector, error_weights.swz<0, 2>()));\n- separate_error.set_lane<2>(separate_error.lane<2>() + dot(separate_blue_vector, error_weights.swz<0, 1>()));\n+ uncor_error += dot3_s(uncor_vector, error_weights);\n+ samec_error += dot3_s(samec_vector, error_weights);\n+ sep_error.set_lane<0>(sep_error.lane<0>() + dot(sep_r_vector, error_weights.swz<1, 2>()));\n+ sep_error.set_lane<1>(sep_error.lane<1>() + dot(sep_g_vector, error_weights.swz<0, 2>()));\n+ sep_error.set_lane<2>(sep_error.lane<2>() + dot(sep_b_vector, error_weights.swz<0, 1>()));\n- separate_error.set_lane<0>(separate_error.lane<0>() + rgba_range[j].lane<0>() * rgba_range[j].lane<0>() * error_weights.lane<0>());\n- separate_error.set_lane<1>(separate_error.lane<1>() + rgba_range[j].lane<1>() * rgba_range[j].lane<1>() * error_weights.lane<1>());\n- separate_error.set_lane<2>(separate_error.lane<2>() + rgba_range[j].lane<2>() * rgba_range[j].lane<2>() * error_weights.lane<2>());\n+ sep_error.set_lane<0>(sep_error.lane<0>() + ranges_rgba[j].lane<0>() * ranges_rgba[j].lane<0>() * error_weights.lane<0>());\n+ sep_error.set_lane<1>(sep_error.lane<1>() + ranges_rgba[j].lane<1>() * ranges_rgba[j].lane<1>() * error_weights.lane<1>());\n+ sep_error.set_lane<2>(sep_error.lane<2>() + ranges_rgba[j].lane<2>() * ranges_rgba[j].lane<2>() * error_weights.lane<2>());\n}\n- if (uncorr_error < uncorr_best_error)\n+ if (uncor_error < uncor_best_error)\n{\n- uncorr_best_error = uncorr_error;\n- uncorr_best_partition = partition;\n+ uncor_best_error = uncor_error;\n+ uncor_best_partition = partition;\n}\n- if (samechroma_error < samechroma_best_errors[0])\n+ if (samec_error < samec_best_errors[0])\n{\n- samechroma_best_errors[1] = samechroma_best_errors[0];\n- samechroma_best_partitions[1] = samechroma_best_partitions[0];\n+ samec_best_errors[1] = samec_best_errors[0];\n+ samec_best_partitions[1] = samec_best_partitions[0];\n- samechroma_best_errors[0] = samechroma_error;\n- samechroma_best_partitions[0] = partition;\n+ samec_best_errors[0] = samec_error;\n+ samec_best_partitions[0] = partition;\n}\n- else if (samechroma_error < samechroma_best_errors[1])\n+ else if (samec_error < samec_best_errors[1])\n{\n- samechroma_best_errors[1] = samechroma_error;\n- samechroma_best_partitions[1] = partition;\n+ samec_best_errors[1] = samec_error;\n+ samec_best_partitions[1] = partition;\n}\n- if (separate_error.lane<0>() < separate_best_error)\n+ if (sep_error.lane<0>() < sep_best_error)\n{\n- separate_best_error = separate_error.lane<0>();\n- separate_best_partition = partition;\n- separate_best_component = 0;\n+ sep_best_error = sep_error.lane<0>();\n+ sep_best_partition = partition;\n+ sep_best_component = 0;\n}\n- if (separate_error.lane<1>() < separate_best_error)\n+ if (sep_error.lane<1>() < sep_best_error)\n{\n- separate_best_error = separate_error.lane<1>();\n- separate_best_partition = partition;\n- separate_best_component = 1;\n+ sep_best_error = sep_error.lane<1>();\n+ sep_best_partition = partition;\n+ sep_best_component = 1;\n}\n- if (separate_error.lane<2>() < separate_best_error)\n+ if (sep_error.lane<2>() < sep_best_error)\n{\n- separate_best_error = separate_error.lane<2>();\n- separate_best_partition = partition;\n- separate_best_component = 2;\n+ sep_best_error = sep_error.lane<2>();\n+ sep_best_partition = partition;\n+ sep_best_component = 2;\n}\n}\n}\n- *best_partition_uncorrelated = uncorr_best_partition;\n+ *best_partition_uncor = uncor_best_partition;\n- int index { samechroma_best_partitions[0] != uncorr_best_partition ? 0 : 1 };\n- *best_partition_samechroma = samechroma_best_partitions[index];\n+ int index = samec_best_partitions[0] != uncor_best_partition ? 0 : 1;\n+ *best_partition_samec = samec_best_partitions[index];\n- *best_partition_dualplane = (separate_best_component << PARTITION_BITS) |\n- (separate_best_partition);\n+ *best_partition_dualplane = (sep_best_component << PARTITION_BITS) |\n+ (sep_best_partition);\n}\n#endif\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Style cleanup find_best_partitionings
61,745
20.02.2021 18:27:38
0
dd77b435ef696bf8ed36c54ffc7e675826fff74d
Use texel_count convention for partition_info
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_averages_and_directions.cpp", "new_path": "Source/astcenc_averages_and_directions.cpp", "diff": "@@ -55,7 +55,7 @@ void compute_avgs_and_dirs_4_comp(\nvfloat4 base_sum = vfloat4::zero();\nfloat partition_weight = 0.0f;\n- int texel_count = pt->texels_per_partition[partition];\n+ int texel_count = pt->partition_texel_count[partition];\npromise(texel_count > 0);\nfor (int i = 0; i < texel_count; i++)\n@@ -175,7 +175,7 @@ void compute_avgs_and_dirs_3_comp(\nvfloat4 base_sum = vfloat4::zero();\nfloat partition_weight = 0.0f;\n- int texel_count = pt->texels_per_partition[partition];\n+ int texel_count = pt->partition_texel_count[partition];\npromise(texel_count > 0);\nfor (int i = 0; i < texel_count; i++)\n@@ -293,7 +293,7 @@ void compute_avgs_and_dirs_2_comp(\nfloat2 base_sum = float2(0.0f);\nfloat partition_weight = 0.0f;\n- int texel_count = pt->texels_per_partition[partition];\n+ int texel_count = pt->partition_texel_count[partition];\npromise(texel_count > 0);\nfor (int i = 0; i < texel_count; i++)\n@@ -381,7 +381,7 @@ void compute_error_squared_rgba(\n// TODO: split up this loop due to too many temporaries; in particular,\n// the six line functions will consume 18 vector registers\n- int texel_count = pt->texels_per_partition[partition];\n+ int texel_count = pt->partition_texel_count[partition];\npromise(texel_count > 0);\nint i = 0;\n@@ -577,7 +577,7 @@ void compute_error_squared_rgb(\n// TODO: split up this loop due to too many temporaries; in\n// particular, the six line functions will consume 18 vector registers\n- int texel_count = pt->texels_per_partition[partition];\n+ int texel_count = pt->partition_texel_count[partition];\npromise(texel_count > 0);\nint i = 0;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_find_best_partitioning.cpp", "new_path": "Source/astcenc_find_best_partitioning.cpp", "diff": "@@ -69,7 +69,7 @@ static void compute_partition_error_color_weightings_and_range(\nvfloat4 rgba_min(1e38f);\nvfloat4 rgba_max(-1e38f);\n- int texel_count = pt->texels_per_partition[i];\n+ int texel_count = pt->partition_texel_count[i];\nfor (int j = 0; j < texel_count; j++)\n{\nint tidx = pt->texels_of_partition[i][j];\n@@ -83,7 +83,7 @@ static void compute_partition_error_color_weightings_and_range(\n}\n}\n- error_weight = error_weight / pt->texels_per_partition[i];\n+ error_weight = error_weight / pt->partition_texel_count[i];\nerror_weightings[i] = error_weight;\ncolor_scale_factors[i] = sqrt(error_weight);\nranges_rgba[i] = max(rgba_max - rgba_min, 1e-10f);\n@@ -114,7 +114,7 @@ void compute_partition_error_color_weightings(\nfor (int i = 0; i < pcnt; i++)\n{\n- error_weightings[i] = error_weightings[i] * (1.0f / pt->texels_per_partition[i]);\n+ error_weightings[i] = error_weightings[i] * (1.0f / pt->partition_texel_count[i]);\ncolor_scale_factors[i] = sqrt(error_weightings[i]);\n}\n}\n@@ -345,7 +345,7 @@ void find_best_partitionings(\nfor (int j = 0; j < partition_count; j++)\n{\n- float tpp = (float)(ptab[partition].texels_per_partition[j]);\n+ float tpp = (float)(ptab[partition].partition_texel_count[j]);\nvfloat4 ics = icolor_scale_factors[j];\nvfloat4 error_weights = error_weightings[j] * (tpp * weight_imprecision_estim);\n@@ -576,7 +576,7 @@ void find_best_partitionings(\nfor (int j = 0; j < partition_count; j++)\n{\n- float tpp = (float)(ptab[partition].texels_per_partition[j]);\n+ float tpp = (float)(ptab[partition].partition_texel_count[j]);\nvfloat4 ics = icolor_scale_factors[j];\nics.set_lane<3>(0.0f);\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "diff": "@@ -1133,7 +1133,7 @@ void recompute_ideal_colors_2planes(\nvfloat4 rgba_sum(1e-17f);\nvfloat4 rgba_weight_sum(1e-17f);\n- int texelcount = pt->texels_per_partition[i];\n+ int texelcount = pt->partition_texel_count[i];\nconst uint8_t *texel_indexes = pt->texels_of_partition[i];\nfor (int j = 0; j < texelcount; j++)\n{\n@@ -1459,7 +1459,7 @@ void recompute_ideal_colors_1plane(\nvfloat4 rgba_sum(1e-17f);\nvfloat4 rgba_weight_sum(1e-17f);\n- int texelcount = pt->texels_per_partition[i];\n+ int texelcount = pt->partition_texel_count[i];\nconst uint8_t *texel_indexes = pt->texels_of_partition[i];\npromise(texelcount > 0);\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -348,7 +348,7 @@ public:\nstruct partition_info\n{\nint partition_count;\n- uint8_t texels_per_partition[4];\n+ uint8_t partition_texel_count[4];\nuint8_t partition_of_texel[MAX_TEXELS_PER_BLOCK];\nuint8_t texels_of_partition[4][MAX_TEXELS_PER_BLOCK];\nuint64_t coverage_bitmaps[4];\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_kmeans_partitioning.cpp", "new_path": "Source/astcenc_kmeans_partitioning.cpp", "diff": "@@ -133,12 +133,12 @@ static void kmeans_assign(\n) {\nfloat distances[MAX_TEXELS_PER_BLOCK];\n- int texels_per_partition[4];\n+ int partition_texel_count[4];\n- texels_per_partition[0] = texels_per_block;\n+ partition_texel_count[0] = texels_per_block;\nfor (int i = 1; i < partition_count; i++)\n{\n- texels_per_partition[i] = 0;\n+ partition_texel_count[i] = 0;\n}\nfor (int i = 0; i < texels_per_block; i++)\n@@ -162,8 +162,8 @@ static void kmeans_assign(\nif (distance < distances[i])\n{\ndistances[i] = distance;\n- texels_per_partition[partition_of_texel[i]]--;\n- texels_per_partition[j]++;\n+ partition_texel_count[partition_of_texel[i]]--;\n+ partition_texel_count[j]++;\npartition_of_texel[i] = j;\n}\n}\n@@ -180,10 +180,10 @@ static void kmeans_assign(\nproblem_case = 0;\nfor (int i = 0; i < partition_count; i++)\n{\n- if (texels_per_partition[i] == 0)\n+ if (partition_texel_count[i] == 0)\n{\n- texels_per_partition[partition_of_texel[i]]--;\n- texels_per_partition[i]++;\n+ partition_texel_count[partition_of_texel[i]]--;\n+ partition_texel_count[i]++;\npartition_of_texel[i] = i;\nproblem_case = 1;\n}\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_partition_tables.cpp", "new_path": "Source/astcenc_partition_tables.cpp", "diff": "@@ -275,7 +275,7 @@ static void generate_one_partition_table(\nfor (int i = 0; i < 4; i++)\n{\n- pt->texels_per_partition[i] = counts[i];\n+ pt->partition_texel_count[i] = counts[i];\n}\nif (counts[0] == 0)\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_pick_best_endpoint_format.cpp", "new_path": "Source/astcenc_pick_best_endpoint_format.cpp", "diff": "@@ -44,7 +44,7 @@ static void compute_color_error_for_every_integer_count_and_quant_level(\nfloat best_error[21][4],\nint format_of_choice[21][4]\n) {\n- int partition_size = pt->texels_per_partition[partition_index];\n+ int partition_size = pt->partition_texel_count[partition_index];\nstatic const float baseline_quant_error[21] = {\n(65536.0f * 65536.0f / 18.0f), // 2 values, 1 step\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Use texel_count convention for partition_info
61,745
20.02.2021 19:55:28
0
bb8439910ef870c3ac3f383d105a02ed59c2a825
Skip dual plane partition metrics if not needed
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -1282,6 +1282,8 @@ void compress_block(\nbool block_is_la = imageblock_is_lumalp(blk);\nfloat block_is_la_scale = block_is_la ? 1.0f / 1.05f : 1.0f;\n+ bool block_skip_two_plane = false;\n+\n// Default max partition, but +1 if only have 1 or 2 active components\nint max_partitions = ctx.config.tune_partition_count_limit;\nif (block_is_l || block_is_la)\n@@ -1397,6 +1399,7 @@ void compress_block(\n#if !defined(ASTCENC_DIAGNOSTICS)\nlowest_correl = prepare_block_statistics(bsd->texel_count, blk, ewb);\n+ block_skip_two_plane = lowest_correl > ctx.config.tune_two_plane_early_out_limit;\n#endif\n// next, test the four possible 1-partition, 2-planes modes\n@@ -1407,7 +1410,7 @@ void compress_block(\ntrace_add_data(\"plane_count\", 2);\ntrace_add_data(\"plane_channel\", i);\n- if (lowest_correl > ctx.config.tune_two_plane_early_out_limit)\n+ if (block_skip_two_plane)\n{\ntrace_add_data(\"skip\", \"tune_two_plane_early_out_limit\");\ncontinue;\n@@ -1453,7 +1456,7 @@ void compress_block(\nctx.config.tune_partition_index_limit,\n&(partition_indices_1plane[0]),\n&(partition_indices_1plane[1]),\n- &partition_index_2planes);\n+ block_skip_two_plane ? nullptr : &partition_index_2planes);\nfor (int i = 0; i < 2; i++)\n{\n@@ -1501,7 +1504,7 @@ void compress_block(\n}\n// * Blocks with higher component correlation than the tuning cutoff\n- if (lowest_correl > ctx.config.tune_two_plane_early_out_limit)\n+ if (block_skip_two_plane)\n{\ntrace_add_data(\"skip\", \"tune_two_plane_early_out_limit\");\ncontinue;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_find_best_partitioning.cpp", "new_path": "Source/astcenc_find_best_partitioning.cpp", "diff": "@@ -172,6 +172,8 @@ void find_best_partitionings(\nint sep_best_partition { 0 };\nint sep_best_component { 0 };\n+ bool skip_two_plane = best_partition_dualplane == nullptr;\n+\nif (uses_alpha)\n{\n@@ -256,6 +258,8 @@ void find_best_partitionings(\nsamec_plines[j].bs = samec_lines[j].b * color_scale_factors[j];\nsamec_plines[j].bis = samec_lines[j].b * icolor_scale_factors[j];\n+ if (!skip_two_plane)\n+ {\nsep_r_lines[j].a = avgs_rgba[j].swz<1, 2, 3>();\nvfloat4 dirs_gba = dirs_rgba[j].swz<1, 2, 3, 0>();\nif (dot3_s(dirs_gba, dirs_gba) == 0.0f)\n@@ -316,6 +320,7 @@ void find_best_partitionings(\nsep_a_plines[j].bs = (sep_a_lines[j].b * color_scale_factors[j].swz<0, 1, 2, 3>());\nsep_a_plines[j].bis = (sep_a_lines[j].b * icolor_scale_factors[j].swz<0, 1, 2, 3>());\n}\n+ }\nfloat uncor_error = 0.0f;\nfloat samec_error = 0.0f;\n@@ -352,21 +357,25 @@ void find_best_partitionings(\nvfloat4 uncor_vector = uncor_lines[j].b * uncor_line_lens[j] * ics;\nvfloat4 samec_vector = samec_lines[j].b * samec_line_lens[j] * ics;\n+\n+ uncor_vector = uncor_vector * uncor_vector;\n+ samec_vector = samec_vector * samec_vector;\n+\n+ uncor_error += dot_s(uncor_vector, error_weights);\n+ samec_error += dot_s(samec_vector, error_weights);\n+\n+ if (!skip_two_plane)\n+ {\nvfloat4 sep_r_vector = sep_r_lines[j].b * ics.swz<1, 2, 3, 0>();\nvfloat4 sep_g_vector = sep_g_lines[j].b * ics.swz<0, 2, 3, 1>();\nvfloat4 sep_b_vector = sep_b_lines[j].b * ics.swz<0, 1, 3, 2>();\nvfloat4 sep_a_vector = sep_a_lines[j].b * ics.swz<0, 1, 2, 3>();\n- uncor_vector = uncor_vector * uncor_vector;\n- samec_vector = samec_vector * samec_vector;\nsep_r_vector = sep_r_vector * sep_r_vector;\nsep_g_vector = sep_g_vector * sep_g_vector;\nsep_b_vector = sep_b_vector * sep_b_vector;\nsep_a_vector = sep_a_vector * sep_a_vector;\n- uncor_error += dot_s(uncor_vector, error_weights);\n- samec_error += dot_s(samec_vector, error_weights);\n-\nvfloat4 sep_err_inc(dot3_s(sep_r_vector, error_weights.swz<1, 2, 3, 0>()),\ndot3_s(sep_g_vector, error_weights.swz<0, 2, 3, 1>()),\ndot3_s(sep_b_vector, error_weights.swz<0, 1, 3, 2>()),\n@@ -374,6 +383,7 @@ void find_best_partitionings(\nsep_error = sep_error + sep_err_inc + (ranges_rgba[j] * ranges_rgba[j] * error_weights);\n}\n+ }\nif (uncor_error < uncor_best_error)\n{\n@@ -395,6 +405,8 @@ void find_best_partitionings(\nsamec_best_partitions[1] = partition;\n}\n+ if (!skip_two_plane)\n+ {\nif (sep_error.lane<0>() < sep_best_error)\n{\nsep_best_error = sep_error.lane<0>();\n@@ -424,6 +436,7 @@ void find_best_partitionings(\n}\n}\n}\n+ }\nelse\n{\nfor (int i = 0; i < partition_search_limit; i++)\n@@ -502,6 +515,8 @@ void find_best_partitionings(\nsamec_plines[j].bs = (samec_lines[j].b * color_scale_factors[j].swz<0, 1, 2, 3>());\nsamec_plines[j].bis = (samec_lines[j].b * icolor_scale_factors[j].swz<0, 1, 2, 3>());\n+ if (!skip_two_plane)\n+ {\nsep_r_lines[j].a = avgs_rgba[j].swz<1, 2>();\nfloat2 dirs_gb = dirs_rgb[j].swz<1, 2>();\nif (dot(dirs_gb, dirs_gb) == 0.0f)\n@@ -547,6 +562,7 @@ void find_best_partitionings(\nsep_b_plines[j].bs = (sep_b_lines[j].b * color_scale_factors[j].swz<0, 1>());\nsep_b_plines[j].bis = (sep_b_lines[j].b * icolor_scale_factors[j].swz<0, 1>());\n}\n+ }\nfloat uncor_error = 0.0f;\nfloat samec_error = 0.0f;\n@@ -587,18 +603,22 @@ void find_best_partitionings(\nvfloat4 uncor_vector = (uncor_lines[j].b * uncor_line_lens[j]) * ics;\nvfloat4 samec_vector = (samec_lines[j].b * samec_line_lens[j]) * ics;\n+ uncor_vector = uncor_vector * uncor_vector;\n+ samec_vector = samec_vector * samec_vector;\n+\n+ uncor_error += dot3_s(uncor_vector, error_weights);\n+ samec_error += dot3_s(samec_vector, error_weights);\n+\n+ if (!skip_two_plane)\n+ {\nfloat2 sep_r_vector = sep_r_lines[j].b * ics.swz<1, 2>();\nfloat2 sep_g_vector = sep_g_lines[j].b * ics.swz<0, 2>();\nfloat2 sep_b_vector = sep_b_lines[j].b * ics.swz<0, 1>();\n- uncor_vector = uncor_vector * uncor_vector;\n- samec_vector = samec_vector * samec_vector;\nsep_r_vector = sep_r_vector * sep_r_vector;\nsep_g_vector = sep_g_vector * sep_g_vector;\nsep_b_vector = sep_b_vector * sep_b_vector;\n- uncor_error += dot3_s(uncor_vector, error_weights);\n- samec_error += dot3_s(samec_vector, error_weights);\nsep_error.set_lane<0>(sep_error.lane<0>() + dot(sep_r_vector, error_weights.swz<1, 2>()));\nsep_error.set_lane<1>(sep_error.lane<1>() + dot(sep_g_vector, error_weights.swz<0, 2>()));\nsep_error.set_lane<2>(sep_error.lane<2>() + dot(sep_b_vector, error_weights.swz<0, 1>()));\n@@ -607,6 +627,7 @@ void find_best_partitionings(\nsep_error.set_lane<1>(sep_error.lane<1>() + ranges_rgba[j].lane<1>() * ranges_rgba[j].lane<1>() * error_weights.lane<1>());\nsep_error.set_lane<2>(sep_error.lane<2>() + ranges_rgba[j].lane<2>() * ranges_rgba[j].lane<2>() * error_weights.lane<2>());\n}\n+ }\nif (uncor_error < uncor_best_error)\n{\n@@ -628,6 +649,8 @@ void find_best_partitionings(\nsamec_best_partitions[1] = partition;\n}\n+ if (!skip_two_plane)\n+ {\nif (sep_error.lane<0>() < sep_best_error)\n{\nsep_best_error = sep_error.lane<0>();\n@@ -650,14 +673,18 @@ void find_best_partitionings(\n}\n}\n}\n+ }\n*best_partition_uncor = uncor_best_partition;\nint index = samec_best_partitions[0] != uncor_best_partition ? 0 : 1;\n*best_partition_samec = samec_best_partitions[index];\n+ if (best_partition_dualplane)\n+ {\n*best_partition_dualplane = (sep_best_component << PARTITION_BITS) |\n(sep_best_partition);\n}\n+}\n#endif\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Skip dual plane partition metrics if not needed
61,745
20.02.2021 22:02:10
0
9990b6bab4749404ecdd6f4f8c84a720182a82d1
Use helper functions for safe normalization
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_encoding_choice_error.cpp", "new_path": "Source/astcenc_encoding_choice_error.cpp", "diff": "@@ -187,14 +187,14 @@ void compute_encoding_choice_errors(\npartition_metrics& pm = pms[i];\n// TODO: Can we skip rgb_luma_lines for LDR images?\n- line3 uncorr_rgb_lines;\n- line3 samechroma_rgb_lines; // for LDR-RGB-scale\n+ line3 uncor_rgb_lines;\n+ line3 samec_rgb_lines; // for LDR-RGB-scale\nline3 rgb_luma_lines; // for HDR-RGB-scale\n- processed_line3 proc_uncorr_rgb_lines;\n- processed_line3 proc_samechroma_rgb_lines; // for LDR-RGB-scale\n- processed_line3 proc_rgb_luma_lines; // for HDR-RGB-scale\n- processed_line3 proc_luminance_lines;\n+ processed_line3 uncor_rgb_plines;\n+ processed_line3 samec_rgb_plines; // for LDR-RGB-scale\n+ processed_line3 rgb_luma_plines; // for HDR-RGB-scale\n+ processed_line3 luminance_plines;\nfloat uncorr_rgb_error;\nfloat samechroma_rgb_error;\n@@ -204,56 +204,43 @@ void compute_encoding_choice_errors(\nvfloat4 csf = pm.color_scale;\ncsf.set_lane<3>(0.0f);\n+ vfloat4 csfn = normalize(csf);\nvfloat4 icsf = pm.icolor_scale;\nicsf.set_lane<3>(0.0f);\n- uncorr_rgb_lines.a = pm.avg;\n- if (dot3_s(pm.dir, pm.dir) == 0.0f)\n- {\n- uncorr_rgb_lines.b = normalize(csf);\n- }\n- else\n- {\n- uncorr_rgb_lines.b = normalize(pm.dir);\n- }\n+ uncor_rgb_lines.a = pm.avg;\n+ uncor_rgb_lines.b = normalize_safe(pm.dir.swz<0, 1, 2>(), csfn);\n- samechroma_rgb_lines.a = vfloat4::zero();\n- if (dot3_s(pm.avg, pm.avg) < 1e-20f)\n- {\n- samechroma_rgb_lines.b = normalize(csf);\n- }\n- else\n- {\n- samechroma_rgb_lines.b = normalize(pm.avg);\n- }\n+ samec_rgb_lines.a = vfloat4::zero();\n+ samec_rgb_lines.b = normalize_safe(pm.avg.swz<0, 1, 2>(), csfn);\nrgb_luma_lines.a = pm.avg;\n- rgb_luma_lines.b = normalize(csf);\n+ rgb_luma_lines.b = csfn;\n- proc_uncorr_rgb_lines.amod = (uncorr_rgb_lines.a - uncorr_rgb_lines.b * dot3_s(uncorr_rgb_lines.a, uncorr_rgb_lines.b)) * icsf;\n- proc_uncorr_rgb_lines.bs = uncorr_rgb_lines.b * csf;\n- proc_uncorr_rgb_lines.bis = uncorr_rgb_lines.b * icsf;\n+ uncor_rgb_plines.amod = (uncor_rgb_lines.a - uncor_rgb_lines.b * dot3(uncor_rgb_lines.a, uncor_rgb_lines.b)) * icsf;\n+ uncor_rgb_plines.bs = uncor_rgb_lines.b * csf;\n+ uncor_rgb_plines.bis = uncor_rgb_lines.b * icsf;\n- proc_samechroma_rgb_lines.amod = (samechroma_rgb_lines.a - samechroma_rgb_lines.b * dot3_s(samechroma_rgb_lines.a, samechroma_rgb_lines.b)) * icsf;\n- proc_samechroma_rgb_lines.bs = samechroma_rgb_lines.b * csf;\n- proc_samechroma_rgb_lines.bis = samechroma_rgb_lines.b * icsf;\n+ samec_rgb_plines.amod = (samec_rgb_lines.a - samec_rgb_lines.b * dot3(samec_rgb_lines.a, samec_rgb_lines.b)) * icsf;\n+ samec_rgb_plines.bs = samec_rgb_lines.b * csf;\n+ samec_rgb_plines.bis = samec_rgb_lines.b * icsf;\n- proc_rgb_luma_lines.amod = (rgb_luma_lines.a - rgb_luma_lines.b * dot3_s(rgb_luma_lines.a, rgb_luma_lines.b)) * icsf;\n- proc_rgb_luma_lines.bs = rgb_luma_lines.b * csf;\n- proc_rgb_luma_lines.bis = rgb_luma_lines.b * icsf;\n+ rgb_luma_plines.amod = (rgb_luma_lines.a - rgb_luma_lines.b * dot3(rgb_luma_lines.a, rgb_luma_lines.b)) * icsf;\n+ rgb_luma_plines.bs = rgb_luma_lines.b * csf;\n+ rgb_luma_plines.bis = rgb_luma_lines.b * icsf;\n// Luminance always goes though zero, so this is simpler than the others\n- proc_luminance_lines.amod = vfloat4::zero();\n- proc_luminance_lines.bs = normalize(csf) * csf;\n- proc_luminance_lines.bis = normalize(csf) * icsf;\n+ luminance_plines.amod = vfloat4::zero();\n+ luminance_plines.bs = csfn * csf;\n+ luminance_plines.bis = csfn * icsf;\ncompute_error_squared_rgb_single_partition(\ni, bsd, pt, blk, ewb,\n- &proc_uncorr_rgb_lines, &uncorr_rgb_error,\n- &proc_samechroma_rgb_lines, &samechroma_rgb_error,\n- &proc_rgb_luma_lines, &rgb_luma_error,\n- &proc_luminance_lines, &luminance_rgb_error,\n+ &uncor_rgb_plines, &uncorr_rgb_error,\n+ &samec_rgb_plines, &samechroma_rgb_error,\n+ &rgb_luma_plines, &rgb_luma_error,\n+ &luminance_plines, &luminance_rgb_error,\n&alpha_drop_error);\n// Determine if we can offset encode RGB lanes\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_find_best_partitioning.cpp", "new_path": "Source/astcenc_find_best_partitioning.cpp", "diff": "@@ -216,28 +216,14 @@ void find_best_partitionings(\npartition_metrics& pm = pms[j];\nuncor_lines[j].a = pm.avg;\n- if (dot_s(pm.dir, pm.dir) == 0.0f)\n- {\n- uncor_lines[j].b = normalize(vfloat4(1.0f));\n- }\n- else\n- {\n- uncor_lines[j].b = normalize(pm.dir);\n- }\n+ uncor_lines[j].b = normalize_safe(pm.dir, unit4());\nuncor_plines[j].amod = (uncor_lines[j].a - uncor_lines[j].b * dot(uncor_lines[j].a, uncor_lines[j].b)) * pm.icolor_scale;\nuncor_plines[j].bs = uncor_lines[j].b * pm.color_scale;\nuncor_plines[j].bis = uncor_lines[j].b * pm.icolor_scale;\nsamec_lines[j].a = vfloat4::zero();\n- if (dot_s(pm.avg, pm.avg) == 0.0f)\n- {\n- samec_lines[j].b = normalize(vfloat4(1.0f));\n- }\n- else\n- {\n- samec_lines[j].b = normalize(pm.avg);\n- }\n+ samec_lines[j].b = normalize_safe(pm.avg, unit4());\nsamec_plines[j].amod = (samec_lines[j].a - samec_lines[j].b * dot(samec_lines[j].a, samec_lines[j].b)) * pm.icolor_scale;\nsamec_plines[j].bs = samec_lines[j].b * pm.color_scale;\n@@ -246,48 +232,20 @@ void find_best_partitionings(\nif (!skip_two_plane)\n{\nsep_r_lines[j].a = pm.avg.swz<1, 2, 3>();\n- vfloat4 dirs_gba = pm.dir.swz<1, 2, 3, 0>();\n- if (dot3_s(dirs_gba, dirs_gba) == 0.0f)\n- {\n- sep_r_lines[j].b = normalize(vfloat4(1.0f, 1.0f, 1.0f, 0.0f));\n- }\n- else\n- {\n- sep_r_lines[j].b = normalize(dirs_gba);\n- }\n+ vfloat4 dirs_gba = pm.dir.swz<1, 2, 3>();\n+ sep_r_lines[j].b = normalize_safe(dirs_gba, unit3());\nsep_g_lines[j].a = pm.avg.swz<0, 2, 3>();\n- vfloat4 dirs_rba = pm.dir.swz<0, 2, 3, 1>();\n- if (dot3_s(dirs_rba, dirs_rba) == 0.0f)\n- {\n- sep_g_lines[j].b = normalize(vfloat4(1.0f, 1.0f, 1.0f, 0.0f));\n- }\n- else\n- {\n- sep_g_lines[j].b = normalize(dirs_rba);\n- }\n+ vfloat4 dirs_rba = pm.dir.swz<0, 2, 3>();\n+ sep_g_lines[j].b = normalize_safe(dirs_rba, unit3());\nsep_b_lines[j].a = pm.avg.swz<0, 1, 3>();\n- vfloat4 dirs_rga = pm.dir.swz<0, 1, 3, 2>();\n- if (dot3_s(dirs_rga, dirs_rga) == 0.0f)\n- {\n- sep_b_lines[j].b = normalize(vfloat4(1.0f, 1.0f, 1.0f, 0.0f));\n- }\n- else\n- {\n- sep_b_lines[j].b = normalize(dirs_rga);\n- }\n+ vfloat4 dirs_rga = pm.dir.swz<0, 1, 3>();\n+ sep_b_lines[j].b = normalize_safe(dirs_rga, unit3());\nsep_a_lines[j].a = pm.avg.swz<0, 1, 2>();\n- vfloat4 dirs_rgb = pm.dir.swz<0, 1, 2, 3>();\n- if (dot3_s(dirs_rgb, dirs_rgb) == 0.0f)\n- {\n- sep_a_lines[j].b = normalize(vfloat4(1.0f, 1.0f, 1.0f, 0.0f));\n- }\n- else\n- {\n- sep_a_lines[j].b = normalize(dirs_rgb);\n- }\n+ vfloat4 dirs_rgb = pm.dir.swz<0, 1, 2>();\n+ sep_a_lines[j].b = normalize_safe(dirs_rgb, unit3());\nsep_r_plines[j].amod = (sep_r_lines[j].a - sep_r_lines[j].b * dot3(sep_r_lines[j].a, sep_r_lines[j].b)) * pm.icolor_scale.swz<1, 2, 3, 0>();\nsep_r_plines[j].bs = (sep_r_lines[j].b * pm.color_scale.swz<1, 2, 3, 0>());\n@@ -458,24 +416,10 @@ void find_best_partitionings(\npartition_lines3& pl = plines[j];\npl.uncor_line.a = pm.avg;\n- if (dot3_s(pm.dir, pm.dir) == 0.0f)\n- {\n- pl.uncor_line.b = normalize(vfloat4(1.0f, 1.0f, 1.0f, 0.0f));\n- }\n- else\n- {\n- pl.uncor_line.b = normalize(pm.dir);\n- }\n+ pl.uncor_line.b = normalize_safe(pm.dir.swz<0, 1, 2>(), unit3());\npl.samec_line.a = vfloat4::zero();\n- if (dot3_s(pm.avg, pm.avg) == 0.0f)\n- {\n- pl.samec_line.b = normalize(vfloat4(1.0f, 1.0f, 1.0f, 0.0f));\n- }\n- else\n- {\n- pl.samec_line.b = normalize(pm.avg);\n- }\n+ pl.samec_line.b = normalize_safe(pm.avg.swz<0, 1, 2>(), unit3());\npl.uncor_pline.amod = (pl.uncor_line.a - pl.uncor_line.b * dot3(pl.uncor_line.a, pl.uncor_line.b)) * pm.icolor_scale.swz<0, 1, 2, 3>();\npl.uncor_pline.bs = (pl.uncor_line.b * pm.color_scale.swz<0, 1, 2, 3>());\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Use helper functions for safe normalization
61,745
20.02.2021 23:07:46
0
8b8ee4f32d5dd44e5cca88665dfe541e1c09e45d
Exploit same chroma line.amod always being zero
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_averages_and_directions.cpp", "new_path": "Source/astcenc_averages_and_directions.cpp", "diff": "@@ -408,10 +408,7 @@ void compute_error_squared_rgba(\nvfloat l_samec_bs2(l_samec.bs.lane<2>());\nvfloat l_samec_bs3(l_samec.bs.lane<3>());\n- vfloat l_samec_amod0(l_samec.amod.lane<0>());\n- vfloat l_samec_amod1(l_samec.amod.lane<1>());\n- vfloat l_samec_amod2(l_samec.amod.lane<2>());\n- vfloat l_samec_amod3(l_samec.amod.lane<3>());\n+ assert(all(l_samec.amod == vfloat4(0.0f)));\nvfloat l_samec_bis0(l_samec.bis.lane<0>());\nvfloat l_samec_bis1(l_samec.bis.lane<1>());\n@@ -475,14 +472,10 @@ void compute_error_squared_rgba(\nsamec_hiparamv = max(samec_param, samec_hiparamv);\n- vfloat samec_dist0 = (l_samec_amod0 - data_r)\n- + (samec_param * l_samec_bis0);\n- vfloat samec_dist1 = (l_samec_amod1 - data_g)\n- + (samec_param * l_samec_bis1);\n- vfloat samec_dist2 = (l_samec_amod2 - data_b)\n- + (samec_param * l_samec_bis2);\n- vfloat samec_dist3 = (l_samec_amod3 - data_a)\n- + (samec_param * l_samec_bis3);\n+ vfloat samec_dist0 = samec_param * l_samec_bis0 - data_r;\n+ vfloat samec_dist1 = samec_param * l_samec_bis1 - data_g;\n+ vfloat samec_dist2 = samec_param * l_samec_bis2 - data_b;\n+ vfloat samec_dist3 = samec_param * l_samec_bis3 - data_a;\nvfloat samec_error = (ew_r * samec_dist0 * samec_dist0)\n+ (ew_g * samec_dist1 * samec_dist1)\n@@ -521,8 +514,7 @@ void compute_error_squared_rgba(\n+ (uncor_param * l_uncor.bis);\nuncor_errorsum += dot_s(ews, uncor_dist * uncor_dist);\n- vfloat4 samec_dist = (l_samec.amod - dat)\n- + (samec_param * l_samec.bis);\n+ vfloat4 samec_dist = samec_param * l_samec.bis - dat;\nsamec_errorsum += dot_s(ews, samec_dist * samec_dist);\n}\n@@ -595,9 +587,7 @@ void compute_error_squared_rgb(\nvfloat l_samec_bs1(l_samec.bs.lane<1>());\nvfloat l_samec_bs2(l_samec.bs.lane<2>());\n- vfloat l_samec_amod0(l_samec.amod.lane<0>());\n- vfloat l_samec_amod1(l_samec.amod.lane<1>());\n- vfloat l_samec_amod2(l_samec.amod.lane<2>());\n+ assert(all(l_samec.amod == vfloat4(0.0f)));\nvfloat l_samec_bis0(l_samec.bis.lane<0>());\nvfloat l_samec_bis1(l_samec.bis.lane<1>());\n@@ -653,12 +643,9 @@ void compute_error_squared_rgb(\nsamec_hiparamv = max(samec_param, samec_hiparamv);\n- vfloat samec_dist0 = (l_samec_amod0 - data_r)\n- + (samec_param * l_samec_bis0);\n- vfloat samec_dist1 = (l_samec_amod1 - data_g)\n- + (samec_param * l_samec_bis1);\n- vfloat samec_dist2 = (l_samec_amod2 - data_b)\n- + (samec_param * l_samec_bis2);\n+ vfloat samec_dist0 = samec_param * l_samec_bis0 - data_r;\n+ vfloat samec_dist1 = samec_param * l_samec_bis1 - data_g;\n+ vfloat samec_dist2 = samec_param * l_samec_bis2 - data_b;\nvfloat samec_err = (ew_r * samec_dist0 * samec_dist0)\n+ (ew_g * samec_dist1 * samec_dist1)\n@@ -696,8 +683,7 @@ void compute_error_squared_rgb(\n+ (uncor_param * l_uncor.bis);\nuncor_errorsum += dot3_s(ews, uncor_dist * uncor_dist);\n- vfloat4 samec_dist = (l_samec.amod - dat)\n- + (samec_param * l_samec.bis);\n+ vfloat4 samec_dist = samec_param * l_samec.bis - dat;\nsamec_errorsum += dot3_s(ews, samec_dist * samec_dist);\n}\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_encoding_choice_error.cpp", "new_path": "Source/astcenc_encoding_choice_error.cpp", "diff": "@@ -111,7 +111,8 @@ static void compute_error_squared_rgb_single_partition(\n{\nfloat param = dot3_s(point, samec_pline->bs);\n- vfloat4 rp1 = samec_pline->amod + param * samec_pline->bis;\n+ // No samec amod - we know it's always zero\n+ vfloat4 rp1 = /* samec_pline->amod + */ param * samec_pline->bis;\nvfloat4 dist = rp1 - point;\nsamec_errorsum += dot3_s(ews, dist * dist);\n}\n@@ -222,7 +223,8 @@ void compute_encoding_choice_errors(\nuncor_rgb_plines.bs = uncor_rgb_lines.b * csf;\nuncor_rgb_plines.bis = uncor_rgb_lines.b * icsf;\n- samec_rgb_plines.amod = (samec_rgb_lines.a - samec_rgb_lines.b * dot3(samec_rgb_lines.a, samec_rgb_lines.b)) * icsf;\n+ // Same chroma always goes though zero, so this is simpler than the others\n+ samec_rgb_plines.amod = vfloat4::zero();\nsamec_rgb_plines.bs = samec_rgb_lines.b * csf;\nsamec_rgb_plines.bis = samec_rgb_lines.b * icsf;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_find_best_partitioning.cpp", "new_path": "Source/astcenc_find_best_partitioning.cpp", "diff": "@@ -225,7 +225,7 @@ void find_best_partitionings(\nsamec_lines[j].a = vfloat4::zero();\nsamec_lines[j].b = normalize_safe(pm.avg, unit4());\n- samec_plines[j].amod = (samec_lines[j].a - samec_lines[j].b * dot(samec_lines[j].a, samec_lines[j].b)) * pm.icolor_scale;\n+ samec_plines[j].amod = vfloat4::zero();\nsamec_plines[j].bs = samec_lines[j].b * pm.color_scale;\nsamec_plines[j].bis = samec_lines[j].b * pm.icolor_scale;\n@@ -425,7 +425,7 @@ void find_best_partitionings(\npl.uncor_pline.bs = (pl.uncor_line.b * pm.color_scale.swz<0, 1, 2, 3>());\npl.uncor_pline.bis = (pl.uncor_line.b * pm.icolor_scale.swz<0, 1, 2, 3>());\n- pl.samec_pline.amod = (pl.samec_line.a - pl.samec_line.b * dot(pl.samec_line.a, pl.samec_line.b)) * pm.icolor_scale.swz<0, 1, 2, 3>();\n+ pl.samec_pline.amod = vfloat4::zero();\npl.samec_pline.bs = (pl.samec_line.b * pm.color_scale.swz<0, 1, 2, 3>());\npl.samec_pline.bis = (pl.samec_line.b * pm.icolor_scale.swz<0, 1, 2, 3>());\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Exploit same chroma line.amod always being zero
61,745
20.02.2021 23:38:04
0
4ba784b4955d04041a1764908312da5c1fddc9bf
Whitespace and comment cleanup
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_weight_align.cpp", "new_path": "Source/astcenc_weight_align.cpp", "diff": "@@ -121,7 +121,8 @@ static void compute_angular_offsets(\nvfloat sample_weightv(sample_weight);\npromise(max_angular_steps > 0);\n- for (int j = 0; j < max_angular_steps; j += ASTCENC_SIMD_WIDTH) // arrays are multiple of SIMD width (ANGULAR_STEPS), safe to overshoot max\n+ // Arrays are multiple of SIMD width (ANGULAR_STEPS), safe to overshoot max\n+ for (int j = 0; j < max_angular_steps; j += ASTCENC_SIMD_WIDTH)\n{\nvfloat cp = loada(&cosptr[j]);\nvfloat sp = loada(&sinptr[j]);\n@@ -135,7 +136,8 @@ static void compute_angular_offsets(\n// post-process the angle-sums\nvfloat mult = vfloat(1.0f / (2.0f * astc::PI));\nvfloat rcp_stepsize = vfloat::lane_id() + vfloat(1.0f);\n- for (int i = 0; i < max_angular_steps; i += ASTCENC_SIMD_WIDTH) // arrays are multiple of SIMD width (ANGULAR_STEPS), safe to overshoot max\n+ // Arrays are multiple of SIMD width (ANGULAR_STEPS), safe to overshoot max\n+ for (int i = 0; i < max_angular_steps; i += ASTCENC_SIMD_WIDTH)\n{\nvfloat ssize = 1.0f / rcp_stepsize;\nrcp_stepsize = rcp_stepsize + vfloat(ASTCENC_SIMD_WIDTH);\n@@ -301,7 +303,6 @@ static void compute_angular_endpoints_for_quant_levels(\nbest_scale[idx_span - 2] = i;\ncut_low_weight[idx_span - 2] = 1;\n}\n-\n}\n// if we got a better error-value for a low sample count than for a high one,\n@@ -324,11 +325,15 @@ static void compute_angular_endpoints_for_quant_levels(\n// Did we find anything?\n// TODO: Can we do better than bsi = 0 here. We should at least\n// propagate an error (and move the printf into the CLI).\n+#if defined(NDEBUG)\nif (bsi < 0)\n{\nprintf(\"WARNING: Unable to find encoding within specified error limit\\n\");\nbsi = 0;\n}\n+else\n+ bsi = astc::max(0, bsi);\n+#endif\nfloat stepsize = 1.0f / (1.0f + (float)bsi);\nint lwi = lowest_weight[bsi] + cut_low_weight[q];\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Whitespace and comment cleanup
61,745
20.02.2021 23:58:40
0
3cf41968040fe0ae4d62e5d04b604afdf01512ba
Remove collection of old TODO comments
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_averages_and_directions.cpp", "new_path": "Source/astcenc_averages_and_directions.cpp", "diff": "@@ -362,8 +362,6 @@ void compute_error_squared_rgba(\nfor (int partition = 0; partition < partition_count; partition++)\n{\n- // TODO: sort partitions by number of texels. For warp-architectures,\n- // this can reduce the running time by about 25-50%.\nconst uint8_t *weights = pt->texels_of_partition[partition];\nfloat uncor_loparam = 1e10f;\n@@ -375,8 +373,6 @@ void compute_error_squared_rgba(\nprocessed_line4 l_uncor = uncor_plines[partition];\nprocessed_line4 l_samec = samec_plines[partition];\n- // TODO: split up this loop due to too many temporaries; in particular,\n- // the six line functions will consume 18 vector registers\nint texel_count = pt->partition_texel_count[partition];\npromise(texel_count > 0);\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_color_quantize.cpp", "new_path": "Source/astcenc_color_quantize.cpp", "diff": "@@ -44,7 +44,7 @@ static inline int cqt_lookup(\n}\nstatic void quantize_rgb(\n- vfloat4 color0, // LDR: 0=lowest, 255=highest\n+ vfloat4 color0,\nvfloat4 color1,\nint output[6],\nint quant_level\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_find_best_partitioning.cpp", "new_path": "Source/astcenc_find_best_partitioning.cpp", "diff": "@@ -267,8 +267,8 @@ void find_best_partitionings(\nfloat uncor_error = 0.0f;\nfloat samec_error = 0.0f;\n- // TODO: Try this as a scalar\nvfloat4 sep_error = vfloat4::zero();\n+\ncompute_error_squared_rgba(ptab + partition,\nblk,\newb,\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "diff": "@@ -270,7 +270,7 @@ static void compute_endpoints_and_ideal_weights_2_comp(\nif (length < 0.0f) // case for when none of the texels had any weight\n{\nlowparam[i] = 0.0f;\n- highparam[i] = 1e-7f; // TODO: Why is this 1e-7; similar code above is zero\n+ highparam[i] = 1e-7f;\n}\n// it is possible for a uniform-color partition to produce length=0; this\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_mathlib.h", "new_path": "Source/astcenc_mathlib.h", "diff": "@@ -147,9 +147,8 @@ static inline float fabs(float v)\n*\n* @return Zero is not a NaN, non-zero otherwise.\n*/\n-static inline int isnan(float v)\n+static inline bool isnan(float v)\n{\n- // TODO: Make this a boolean.\nreturn v != v;\n}\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_avx2_8.h", "new_path": "Source/astcenc_vecmathlib_avx2_8.h", "diff": "@@ -92,8 +92,6 @@ struct vfloat8\n/**\n* @brief Get the scalar value of a single lane.\n- *\n- * TODO: Can we do better for lane0, which is the common case for VLA?\n*/\ntemplate <int l> ASTCENC_SIMD_INLINE float lane() const\n{\n@@ -210,8 +208,6 @@ struct vint8\n/**\n* @brief Get the scalar from a single lane.\n- *\n- * TODO: Can we do better for lane0, which is the common case for VLA?\n*/\ntemplate <int l> ASTCENC_SIMD_INLINE int lane() const\n{\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_neon_4.h", "new_path": "Source/astcenc_vecmathlib_neon_4.h", "diff": "@@ -95,8 +95,6 @@ struct vfloat4\n/**\n* @brief Get the scalar value of a single lane.\n- *\n- * TODO: Can we do better for lane0, which is the common case for VLA?\n*/\ntemplate <int l> ASTCENC_SIMD_INLINE float lane() const\n{\n@@ -812,9 +810,6 @@ ASTCENC_SIMD_INLINE vfloat4 abs(vfloat4 a)\n/**\n* @brief Return a float rounded to the nearest integer value.\n- *\n- * TODO: Can we do a better fallback here, if we exploit the fact that we\n- * can assume that values are positive?\n*/\nASTCENC_SIMD_INLINE vfloat4 round(vfloat4 a)\n{\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_sse_4.h", "new_path": "Source/astcenc_vecmathlib_sse_4.h", "diff": "@@ -851,9 +851,6 @@ ASTCENC_SIMD_INLINE vfloat4 abs(vfloat4 a)\n/**\n* @brief Return a float rounded to the nearest integer value.\n- *\n- * TODO: Can we do a better fallback here, if we exploit the fact that we\n- * can assume that values are positive?\n*/\nASTCENC_SIMD_INLINE vfloat4 round(vfloat4 a)\n{\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Remove collection of old TODO comments
61,745
21.02.2021 00:14:35
0
b5792b7b6b2bf948b0c6da6121afa2af8333c555
Break out of find_best_partitions for degenerate cases
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_find_best_partitioning.cpp", "new_path": "Source/astcenc_find_best_partitioning.cpp", "diff": "@@ -180,11 +180,10 @@ void find_best_partitionings(\n{\nint partition = partition_sequence[i];\n- // TODO: Can we avoid returning these completely?\nint bk_partition_count = ptab[partition].partition_count;\nif (bk_partition_count < partition_count)\n{\n- continue;\n+ break;\n}\n// Compute weighting to give to each channel in each partition\n@@ -390,7 +389,7 @@ void find_best_partitionings(\nint bk_partition_count = ptab[partition].partition_count;\nif (bk_partition_count < partition_count)\n{\n- continue;\n+ break;\n}\n// Compute weighting to give to each channel in each partition\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Break out of find_best_partitions for degenerate cases
61,745
21.02.2021 00:40:49
0
d4b3681c2d1383092397d788f7cd778354c943db
Avoid needless memcpy of large struct
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -247,9 +247,8 @@ static float compress_symbolic_block_fixed_partition_1_plane(\ncontinue;\n}\n- eix[i] = *ei;\n-\ncompute_ideal_weights_for_decimation_table(\n+ *ei,\neix[i],\n*(ixtab2[i]),\ndecimated_quantized_weights + i * MAX_WEIGHTS_PER_BLOCK,\n@@ -598,16 +597,15 @@ static float compress_symbolic_block_fixed_partition_2_planes(\ncontinue;\n}\n- eix1[i] = *ei1;\n- eix2[i] = *ei2;\n-\ncompute_ideal_weights_for_decimation_table(\n+ *ei1,\neix1[i],\n*(ixtab2[i]),\ndecimated_quantized_weights + (2 * i) * MAX_WEIGHTS_PER_BLOCK,\ndecimated_weights + (2 * i) * MAX_WEIGHTS_PER_BLOCK);\ncompute_ideal_weights_for_decimation_table(\n+ *ei2,\neix2[i],\n*(ixtab2[i]),\ndecimated_quantized_weights + (2 * i + 1) * MAX_WEIGHTS_PER_BLOCK,\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "diff": "@@ -818,7 +818,8 @@ float compute_error_of_weight_set(\n/* See header for documentation. */\nvoid compute_ideal_weights_for_decimation_table(\n- const endpoints_and_weights& eai,\n+ const endpoints_and_weights& eai_in,\n+ endpoints_and_weights& eai_out,\nconst decimation_table& dt,\nfloat* RESTRICT weight_set,\nfloat* RESTRICT weights\n@@ -829,17 +830,36 @@ void compute_ideal_weights_for_decimation_table(\npromise(texel_count > 0);\npromise(weight_count > 0);\n- // If we have a 1:1 mapping just shortcut the computation\n+ // This function includes a copy of the epw from eai_in to eai_out. We do it\n+ // here because we want to load the data anyway, so we can avoid loading it\n+ // from memory twice.\n+ eai_out.ep = eai_in.ep;\n+\n+ // If we have a 1:1 mapping just shortcut the computation - clone the\n+ // weights into both the weight set and the output epw copy.\nif (texel_count == weight_count)\n{\nfor (int i = 0; i < texel_count; i++)\n{\nassert(i == dt.weight_texel[i][0]);\n- weight_set[i] = eai.weights[i];\n- weights[i] = eai.weight_error_scale[i];\n+ weight_set[i] = eai_in.weights[i];\n+ weights[i] = eai_in.weight_error_scale[i];\n+\n+ eai_out.weights[i] = eai_in.weights[i];\n+ eai_out.weight_error_scale[i] = eai_in.weight_error_scale[i];\n}\nreturn;\n}\n+ // If we don't have a 1:1 mapping just clone the weights into the output\n+ // epw copy and then do the full algorithm to decimate weights.\n+ else\n+ {\n+ for (int i = 0; i < texel_count; i++)\n+ {\n+ eai_out.weights[i] = eai_in.weights[i];\n+ eai_out.weight_error_scale[i] = eai_in.weight_error_scale[i];\n+ }\n+ }\n// Otherwise compute an estimate and perform single refinement iteration\nfloat infilled_weights[MAX_TEXELS_PER_BLOCK];\n@@ -859,9 +879,9 @@ void compute_ideal_weights_for_decimation_table(\n{\nint texel = dt.weight_texel[i][j];\nfloat weight = dt.weights_flt[i][j];\n- float contrib_weight = weight * eai.weight_error_scale[texel];\n+ float contrib_weight = weight * eai_in.weight_error_scale[texel];\nweight_weight += contrib_weight;\n- initial_weight += eai.weights[texel] * contrib_weight;\n+ initial_weight += eai_in.weights[texel] * contrib_weight;\n}\nweights[i] = weight_weight;\n@@ -902,9 +922,9 @@ void compute_ideal_weights_for_decimation_table(\nuint8_t texel = weight_texel_ptr[k];\nfloat contrib_weight = weights_ptr[k];\n- float scale = eai.weight_error_scale[texel] * contrib_weight;\n+ float scale = eai_in.weight_error_scale[texel] * contrib_weight;\nfloat old_weight = infilled_weights[texel];\n- float ideal_weight = eai.weights[texel];\n+ float ideal_weight = eai_in.weights[texel];\nerror_change0 += contrib_weight * scale;\nerror_change1 += (old_weight - ideal_weight) * scale;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -1088,13 +1088,15 @@ void compute_endpoints_and_ideal_weights_2_planes(\n* Compute the idealized weight set, assuming infinite precision and no\n* quantization. Later functions will use this as a staring points.\n*\n- * @param eai The non-decimated endpoints and weights.\n+ * @param eai_in The non-decimated endpoints and weights.\n+ * @param eai_out A copy of eai_in we can modify later.\n* @param dt The selected decimation table.\n* @param[out] weight_set The output decimated weight set.\n* @param[out] weights The output decimated weights.\n*/\nvoid compute_ideal_weights_for_decimation_table(\n- const endpoints_and_weights& eai,\n+ const endpoints_and_weights& eai_in,\n+ endpoints_and_weights& eai_out,\nconst decimation_table& dt,\nfloat* weight_set,\nfloat* weights);\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Avoid needless memcpy of large struct
61,745
21.02.2021 17:31:50
0
7d33dfb248ed301bc43686cbaf290b6824e38686
Add SIMD path to compute_ideal_weights_for_decimation_table
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "diff": "@@ -862,7 +862,7 @@ void compute_ideal_weights_for_decimation_table(\n}\n// Otherwise compute an estimate and perform single refinement iteration\n- float infilled_weights[MAX_TEXELS_PER_BLOCK];\n+ alignas(ASTCENC_VECALIGN) float infilled_weights[MAX_TEXELS_PER_BLOCK];\n// Compute an initial average for each decimated weight\nfor (int i = 0; i < weight_count; i++)\n@@ -889,11 +889,47 @@ void compute_ideal_weights_for_decimation_table(\n}\n// Populate the interpolated weight grid based on the initital average\n- for (int i = 0; i < texel_count; i++)\n+ int si = 0;\n+\n+#if ASTCENC_SIMD_WIDTH >= 8\n+ // Note: This vectorization for AVX2 mostly helps the larger block sizes;\n+ // it doesn't really help <= 5x5, but is worth 2-3% for >= 8x8.\n+\n+ // Process SIMD-width texel coordinates at at time while we can\n+ int clipped_texel_count = round_down_to_simd_multiple_vla(texel_count);\n+ for (/* */; si < clipped_texel_count; si += ASTCENC_SIMD_WIDTH)\n+ {\n+ vint texel_weights_0(dt.texel_weights_4t[0] + si);\n+ vint texel_weights_1(dt.texel_weights_4t[1] + si);\n+ vint texel_weights_2(dt.texel_weights_4t[2] + si);\n+ vint texel_weights_3(dt.texel_weights_4t[3] + si);\n+\n+ vfloat weight_set_0 = gatherf(weight_set, texel_weights_0);\n+ vfloat weight_set_1 = gatherf(weight_set, texel_weights_1);\n+ vfloat weight_set_2 = gatherf(weight_set, texel_weights_2);\n+ vfloat weight_set_3 = gatherf(weight_set, texel_weights_3);\n+\n+ vfloat texel_weights_float_0(dt.texel_weights_float_4t[0] + si);\n+ vfloat texel_weights_float_1(dt.texel_weights_float_4t[1] + si);\n+ vfloat texel_weights_float_2(dt.texel_weights_float_4t[2] + si);\n+ vfloat texel_weights_float_3(dt.texel_weights_float_4t[3] + si);\n+\n+ vfloat weight = (weight_set_0 * texel_weights_float_0\n+ + weight_set_1 * texel_weights_float_1)\n+ + (weight_set_2 * texel_weights_float_2\n+ + weight_set_3 * texel_weights_float_3);\n+\n+ storea(weight, infilled_weights + si);\n+ }\n+\n+#endif\n+\n+ // Loop tail\n+ for (/* */; si < texel_count; si++)\n{\n- const uint8_t *texel_weights = dt.texel_weights_t4[i];\n- const float *texel_weights_float = dt.texel_weights_float_t4[i];\n- infilled_weights[i] = (weight_set[texel_weights[0]] * texel_weights_float[0]\n+ const uint8_t *texel_weights = dt.texel_weights_t4[si];\n+ const float *texel_weights_float = dt.texel_weights_float_t4[si];\n+ infilled_weights[si] = (weight_set[texel_weights[0]] * texel_weights_float[0]\n+ weight_set[texel_weights[1]] * texel_weights_float[1])\n+ (weight_set[texel_weights[2]] * texel_weights_float[2]\n+ weight_set[texel_weights[3]] * texel_weights_float[3]);\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib.h", "new_path": "Source/astcenc_vecmathlib.h", "diff": "constexpr auto load1 = vfloat1::load1;\n#endif\n+/**\n+ * @brief Round a count down to the largest multiple of 4.\n+ *\n+ * @param count The unrounded value.\n+ *\n+ * @return The rounded value.\n+ */\n+ASTCENC_SIMD_INLINE int round_down_to_simd_multiple_4(int count)\n+{\n+ return count & ~(4 - 1);\n+}\n+\n/**\n* @brief Round a count down to the largest multiple of the SIMD width.\n*\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_sse_4.h", "new_path": "Source/astcenc_vecmathlib_sse_4.h", "diff": "@@ -594,9 +594,13 @@ ASTCENC_SIMD_INLINE void store_nbytes(vint4 a, uint8_t* p)\n*/\nASTCENC_SIMD_INLINE vint4 gatheri(const int* base, vint4 indices)\n{\n+#if ASTCENC_AVX >= 2\n+ return vint4(_mm_i32gather_epi32(base, indices.m, 4));\n+#else\nalignas(16) int idx[4];\nstorea(indices, idx);\nreturn vint4(base[idx[0]], base[idx[1]], base[idx[2]], base[idx[3]]);\n+#endif\n}\n/**\n@@ -967,9 +971,13 @@ ASTCENC_SIMD_INLINE vfloat4 select(vfloat4 a, vfloat4 b, vmask4 cond)\n*/\nASTCENC_SIMD_INLINE vfloat4 gatherf(const float* base, vint4 indices)\n{\n+#if ASTCENC_AVX >= 2\n+ return vfloat4(_mm_i32gather_ps(base, indices.m, 4));\n+#else\nalignas(16) int idx[4];\nstorea(indices, idx);\nreturn vfloat4(base[idx[0]], base[idx[1]], base[idx[2]], base[idx[3]]);\n+#endif\n}\n/**\n@@ -1168,6 +1176,4 @@ ASTCENC_SIMD_INLINE void print(vfloat4 a)\n(double)v[0], (double)v[1], (double)v[2], (double)v[3]);\n}\n-\n-\n#endif // #ifndef ASTC_VECMATHLIB_SSE_4_H_INCLUDED\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add SIMD path to compute_ideal_weights_for_decimation_table
61,745
22.02.2021 08:08:42
0
3db20de52068b4bc1fa29d5fa2bd7eba54ee6e9c
Add absolute scores to test image runner
[ { "change_type": "MODIFY", "old_path": "Test/testlib/resultset.py", "new_path": "Test/testlib/resultset.py", "diff": "@@ -66,14 +66,20 @@ class ResultSummary():\n\"\"\"\nCreate a new result summary.\n\"\"\"\n+ # Pass fail metrics\nself.notruns = 0\nself.passes = 0\nself.warnings = 0\nself.fails = 0\n- self.tTimes = []\n- self.cTimes = []\n- self.psnrs = []\n+ # Relative results\n+ self.tTimesRel = []\n+ self.cTimesRel = []\n+ self.psnrRel = []\n+\n+ # Absolute results\n+ self.cTime = []\n+ self.psnr = []\ndef add_record(self, record):\n\"\"\"\n@@ -92,9 +98,12 @@ class ResultSummary():\nself.notruns += 1\nif record.tTimeRel is not None:\n- self.tTimes.append(record.tTimeRel)\n- self.cTimes.append(record.cTimeRel)\n- self.psnrs.append(record.psnrRel)\n+ self.tTimesRel.append(record.tTimeRel)\n+ self.cTimesRel.append(record.cTimeRel)\n+ self.psnrRel.append(record.psnrRel)\n+\n+ self.cTime.append(record.cTime)\n+ self.psnr.append(record.psnr)\ndef get_worst_result(self):\n\"\"\"\n@@ -120,16 +129,22 @@ class ResultSummary():\ndat = (overall, self.passes, self.warnings, self.fails)\nresult = [\"\\nSet Status: %s (Pass: %u | Warn: %u | Fail: %u)\" % dat]\n- if (self.tTimes):\n+ if (self.tTimesRel):\n# Performance summaries\n- dat = (np.mean(self.tTimes), np.std(self.tTimes))\n- result.append(\"\\nTotal time: Mean: %+0.2fx Std: %0.2fx\" % dat)\n+ dat = (np.mean(self.tTimesRel), np.std(self.tTimesRel))\n+ result.append(\"\\nTotal speed: Mean: %+0.2f x Std: %0.2f x\" % dat)\n+\n+ dat = (np.mean(self.cTimesRel), np.std(self.cTimesRel))\n+ result.append(\"Coding speed: Mean: %+0.2f x Std: %0.2f x\" % dat)\n+\n+ dat = (np.mean(self.psnrRel), np.std(self.psnrRel))\n+ result.append(\"Quality diff: Mean: %+0.2f dB Std: %0.2f dB\" % dat)\n- dat = (np.mean(self.cTimes), np.std(self.cTimes))\n- result.append(\"Coding time: Mean: %+0.2fx Std: %0.2fx\" % dat)\n+ dat = (np.mean(self.cTime), np.std(self.cTime))\n+ result.append(\"Coding time: Mean: %+0.2f s Std: %0.2f s\" % dat)\n- dat = (np.mean(self.psnrs), np.std(self.psnrs))\n- result.append(\"Image quality: Mean: %+0.2f dB Std: %0.2f dB\" % dat)\n+ dat = (np.mean(self.psnr), np.std(self.psnr))\n+ result.append(\"Quality abs: Mean: %+0.2f dB Std: %0.2f dB\" % dat)\nreturn \"\\n\".join(result)\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add absolute scores to test image runner
61,745
22.02.2021 11:33:47
0
327da11270bf817bb3f1994322d9db24aeaade6a
Standardize on dts/dt for decimation table(s)
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -65,9 +65,8 @@ static int realign_weights(\nconst quantization_and_transfer_table *qat = &(quant_and_xfer_tables[weight_quant_level]);\n// Get the decimation table\n- const decimation_table *const *ixtab2 = bsd->decimation_tables;\n- const decimation_table *it = ixtab2[bm.decimation_mode];\n- int weight_count = it->weight_count;\n+ const decimation_table* dt = bsd->decimation_tables[bm.decimation_mode];\n+ int weight_count = dt->weight_count;\nint max_plane = bm.is_dual_plane;\nint plane2_component = bm.is_dual_plane ? scb->plane2_color_component : -1;\n@@ -138,13 +137,13 @@ static int realign_weights(\nfloat down_error = 0.0f;\n// Interpolate the colors to create the diffs\n- int texels_to_evaluate = it->weight_texel_count[we_idx];\n+ int texels_to_evaluate = dt->weight_texel_count[we_idx];\npromise(texels_to_evaluate > 0);\nfor (int te_idx = 0; te_idx < texels_to_evaluate; te_idx++)\n{\n- int texel = it->weight_texel[we_idx][te_idx];\n- const uint8_t *texel_weights = it->texel_weights_texel[we_idx][te_idx];\n- const float *texel_weights_float = it->texel_weights_float_texel[we_idx][te_idx];\n+ int texel = dt->weight_texel[we_idx][te_idx];\n+ const uint8_t *texel_weights = dt->texel_weights_texel[we_idx][te_idx];\n+ const float *texel_weights_float = dt->texel_weights_float_texel[we_idx][te_idx];\nfloat twf0 = texel_weights_float[0];\nfloat weight_base =\n((static_cast<float>(uqw) * twf0\n@@ -230,7 +229,7 @@ static float compress_symbolic_block_fixed_partition_1_plane(\ncompute_endpoints_and_ideal_weights_1_plane(bsd, pt, blk, ewb, ei);\n// next, compute ideal weights and endpoint colors for every decimation.\n- const decimation_table *const *ixtab2 = bsd->decimation_tables;\n+ const decimation_table *const *dts = bsd->decimation_tables;\nfloat *decimated_quantized_weights = tmpbuf->decimated_quantized_weights;\nfloat *decimated_weights = tmpbuf->decimated_weights;\n@@ -250,7 +249,7 @@ static float compress_symbolic_block_fixed_partition_1_plane(\ncompute_ideal_weights_for_decimation_table(\n*ei,\neix[i],\n- *(ixtab2[i]),\n+ *(dts[i]),\ndecimated_quantized_weights + i * MAX_WEIGHTS_PER_BLOCK,\ndecimated_weights + i * MAX_WEIGHTS_PER_BLOCK);\n}\n@@ -311,7 +310,7 @@ static float compress_symbolic_block_fixed_partition_1_plane(\n// compute weight bitcount for the mode\nint bits_used_by_weights = get_ise_sequence_bitcount(\n- ixtab2[decimation_mode]->weight_count,\n+ dts[decimation_mode]->weight_count,\n(quant_method)bm.quant_mode);\nint bitcount = free_bits_for_partition_count[partition_count] - bits_used_by_weights;\nif (bitcount <= 0 || bits_used_by_weights < 24 || bits_used_by_weights > 96)\n@@ -323,7 +322,7 @@ static float compress_symbolic_block_fixed_partition_1_plane(\n// then, generate the optimized set of weights for the weight mode.\ncompute_quantized_weights_for_decimation_table(\n- ixtab2[decimation_mode],\n+ dts[decimation_mode],\nweight_low_value[i], weight_high_value[i],\ndecimated_quantized_weights + MAX_WEIGHTS_PER_BLOCK * decimation_mode,\nflt_quantized_decimated_quantized_weights + MAX_WEIGHTS_PER_BLOCK * i,\n@@ -333,7 +332,7 @@ static float compress_symbolic_block_fixed_partition_1_plane(\n// then, compute weight-errors for the weight mode.\nqwt_errors[i] = compute_error_of_weight_set(\n&(eix[decimation_mode]),\n- ixtab2[decimation_mode],\n+ dts[decimation_mode],\nflt_quantized_decimated_quantized_weights + MAX_WEIGHTS_PER_BLOCK * i);\n}\n@@ -374,13 +373,13 @@ static float compress_symbolic_block_fixed_partition_1_plane(\nint decimation_mode = qw_bm.decimation_mode;\nint weight_quant_mode = qw_bm.quant_mode;\n- const decimation_table *it = ixtab2[decimation_mode];\n+ const decimation_table *dt = dts[decimation_mode];\nu8_weight_src = u8_quantized_decimated_quantized_weights + MAX_WEIGHTS_PER_BLOCK * qw_packed_index;\n- weights_to_copy = it->weight_count;\n+ weights_to_copy = dt->weight_count;\n- trace_add_data(\"weight_x\", it->weight_x);\n- trace_add_data(\"weight_y\", it->weight_y);\n- trace_add_data(\"weight_z\", it->weight_z);\n+ trace_add_data(\"weight_x\", dt->weight_x);\n+ trace_add_data(\"weight_y\", dt->weight_y);\n+ trace_add_data(\"weight_z\", dt->weight_z);\ntrace_add_data(\"weight_quant\", weight_quant_mode);\n// recompute the ideal color endpoints before storing them.\n@@ -393,7 +392,7 @@ static float compress_symbolic_block_fixed_partition_1_plane(\n{\nrecompute_ideal_colors_1plane(\nweight_quant_mode, &(eix[decimation_mode].ep),\n- rgbs_colors, rgbo_colors, u8_weight_src, pt, it, blk, ewb);\n+ rgbs_colors, rgbo_colors, u8_weight_src, pt, dt, blk, ewb);\n// quantize the chosen color\n@@ -581,7 +580,7 @@ static float compress_symbolic_block_fixed_partition_2_planes(\ncompute_endpoints_and_ideal_weights_2_planes(bsd, pt, blk, ewb, separate_component, ei1, ei2);\n// next, compute ideal weights and endpoint colors for every decimation.\n- const decimation_table *const *ixtab2 = bsd->decimation_tables;\n+ const decimation_table *const *dts = bsd->decimation_tables;\nfloat *decimated_quantized_weights = tmpbuf->decimated_quantized_weights;\nfloat *decimated_weights = tmpbuf->decimated_weights;\n@@ -600,14 +599,14 @@ static float compress_symbolic_block_fixed_partition_2_planes(\ncompute_ideal_weights_for_decimation_table(\n*ei1,\neix1[i],\n- *(ixtab2[i]),\n+ *(dts[i]),\ndecimated_quantized_weights + (2 * i) * MAX_WEIGHTS_PER_BLOCK,\ndecimated_weights + (2 * i) * MAX_WEIGHTS_PER_BLOCK);\ncompute_ideal_weights_for_decimation_table(\n*ei2,\neix2[i],\n- *(ixtab2[i]),\n+ *(dts[i]),\ndecimated_quantized_weights + (2 * i + 1) * MAX_WEIGHTS_PER_BLOCK,\ndecimated_weights + (2 * i + 1) * MAX_WEIGHTS_PER_BLOCK);\n}\n@@ -689,7 +688,7 @@ static float compress_symbolic_block_fixed_partition_2_planes(\n// compute weight bitcount for the mode\nint bits_used_by_weights = get_ise_sequence_bitcount(\n- 2 * ixtab2[decimation_mode]->weight_count,\n+ 2 * dts[decimation_mode]->weight_count,\n(quant_method)bm.quant_mode);\nint bitcount = free_bits_for_partition_count[partition_count] - bits_used_by_weights;\nif (bitcount <= 0 || bits_used_by_weights < 24 || bits_used_by_weights > 96)\n@@ -701,7 +700,7 @@ static float compress_symbolic_block_fixed_partition_2_planes(\n// then, generate the optimized set of weights for the mode.\ncompute_quantized_weights_for_decimation_table(\n- ixtab2[decimation_mode],\n+ dts[decimation_mode],\nweight_low_value1[i],\nweight_high_value1[i],\ndecimated_quantized_weights + MAX_WEIGHTS_PER_BLOCK * (2 * decimation_mode),\n@@ -709,7 +708,7 @@ static float compress_symbolic_block_fixed_partition_2_planes(\nu8_quantized_decimated_quantized_weights + MAX_WEIGHTS_PER_BLOCK * (2 * i), bm.quant_mode);\ncompute_quantized_weights_for_decimation_table(\n- ixtab2[decimation_mode],\n+ dts[decimation_mode],\nweight_low_value2[i],\nweight_high_value2[i],\ndecimated_quantized_weights + MAX_WEIGHTS_PER_BLOCK * (2 * decimation_mode + 1),\n@@ -720,12 +719,12 @@ static float compress_symbolic_block_fixed_partition_2_planes(\n// then, compute quantization errors for the block mode.\nqwt_errors[i] = compute_error_of_weight_set(\n&(eix1[decimation_mode]),\n- ixtab2[decimation_mode],\n+ dts[decimation_mode],\nflt_quantized_decimated_quantized_weights + MAX_WEIGHTS_PER_BLOCK * (2 * i))\n+ compute_error_of_weight_set(\n&(eix2[decimation_mode]),\n- ixtab2[decimation_mode],\n+ dts[decimation_mode],\nflt_quantized_decimated_quantized_weights + MAX_WEIGHTS_PER_BLOCK * (2 * i + 1));\n}\n@@ -768,15 +767,15 @@ static float compress_symbolic_block_fixed_partition_2_planes(\nint decimation_mode = qw_bm.decimation_mode;\nint weight_quant_mode = qw_bm.quant_mode;\n- const decimation_table *it = ixtab2[decimation_mode];\n+ const decimation_table *dt = dts[decimation_mode];\nu8_weight1_src = u8_quantized_decimated_quantized_weights + MAX_WEIGHTS_PER_BLOCK * (2 * qw_packed_index);\nu8_weight2_src = u8_quantized_decimated_quantized_weights + MAX_WEIGHTS_PER_BLOCK * (2 * qw_packed_index + 1);\n- weights_to_copy = it->weight_count;\n+ weights_to_copy = dt->weight_count;\n- trace_add_data(\"weight_x\", it->weight_x);\n- trace_add_data(\"weight_y\", it->weight_y);\n- trace_add_data(\"weight_z\", it->weight_z);\n+ trace_add_data(\"weight_x\", dt->weight_x);\n+ trace_add_data(\"weight_y\", dt->weight_y);\n+ trace_add_data(\"weight_z\", dt->weight_z);\ntrace_add_data(\"weight_quant\", weight_quant_mode);\n// recompute the ideal color endpoints before storing them.\n@@ -791,7 +790,7 @@ static float compress_symbolic_block_fixed_partition_2_planes(\n{\nrecompute_ideal_colors_2planes(\nweight_quant_mode, &epm, rgbs_colors, rgbo_colors,\n- u8_weight1_src, u8_weight2_src, separate_component, pt, it, blk, ewb);\n+ u8_weight1_src, u8_weight2_src, separate_component, pt, dt, blk, ewb);\n// store the colors for the block\nfor (int j = 0; j < partition_count; j++)\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_decompress_symbolic.cpp", "new_path": "Source/astcenc_decompress_symbolic.cpp", "diff": "static int compute_value_of_texel_int(\nint texel_to_get,\n- const decimation_table* it,\n+ const decimation_table* dt,\nconst int* weights\n) {\nint summed_value = 8;\n- int weights_to_evaluate = it->texel_weight_count[texel_to_get];\n+ int weights_to_evaluate = dt->texel_weight_count[texel_to_get];\nfor (int i = 0; i < weights_to_evaluate; i++)\n{\n- summed_value += weights[it->texel_weights_t4[texel_to_get][i]]\n- * it->texel_weights_int_t4[texel_to_get][i];\n+ summed_value += weights[dt->texel_weights_t4[texel_to_get][i]]\n+ * dt->texel_weights_int_t4[texel_to_get][i];\n}\nreturn summed_value >> 4;\n}\n@@ -182,12 +182,12 @@ void decompress_symbolic_block(\npt += scb->partition_index;\n// get the appropriate block descriptor\n- const decimation_table *const *ixtab2 = bsd->decimation_tables;\n+ const decimation_table *const *dts = bsd->decimation_tables;\nconst int packed_index = bsd->block_mode_packed_index[scb->block_mode];\nassert(packed_index >= 0 && packed_index < bsd->block_mode_count);\nconst block_mode& bm = bsd->block_modes[packed_index];\n- const decimation_table *it = ixtab2[bm.decimation_mode];\n+ const decimation_table *dt = dts[bm.decimation_mode];\nint is_dual_plane = bm.is_dual_plane;\n@@ -216,7 +216,7 @@ void decompress_symbolic_block(\n// first unquantize the weights\nint uq_plane1_weights[MAX_WEIGHTS_PER_BLOCK];\nint uq_plane2_weights[MAX_WEIGHTS_PER_BLOCK];\n- int weight_count = it->weight_count;\n+ int weight_count = dt->weight_count;\nconst quantization_and_transfer_table *qat = &(quant_and_xfer_tables[weight_quant_level]);\n@@ -239,14 +239,14 @@ void decompress_symbolic_block(\nfor (int i = 0; i < bsd->texel_count; i++)\n{\n- weights[i] = compute_value_of_texel_int(i, it, uq_plane1_weights);\n+ weights[i] = compute_value_of_texel_int(i, dt, uq_plane1_weights);\n}\nif (is_dual_plane)\n{\nfor (int i = 0; i < bsd->texel_count; i++)\n{\n- plane2_weights[i] = compute_value_of_texel_int(i, it, uq_plane2_weights);\n+ plane2_weights[i] = compute_value_of_texel_int(i, dt, uq_plane2_weights);\n}\n}\n@@ -302,17 +302,17 @@ float compute_symbolic_block_difference(\npt += scb->partition_index;\n// get the appropriate block descriptor\n- const decimation_table *const *ixtab2 = bsd->decimation_tables;\n+ const decimation_table *const *dts = bsd->decimation_tables;\nconst int packed_index = bsd->block_mode_packed_index[scb->block_mode];\nassert(packed_index >= 0 && packed_index < bsd->block_mode_count);\nconst block_mode& bm = bsd->block_modes[packed_index];\n- const decimation_table *it = ixtab2[bm.decimation_mode];\n+ const decimation_table *dt = dts[bm.decimation_mode];\nint is_dual_plane = bm.is_dual_plane;\nint weight_quant_level = bm.quant_mode;\n- int weight_count = it->weight_count;\n+ int weight_count = dt->weight_count;\nint texel_count = bsd->texel_count;\npromise(partition_count > 0);\n@@ -364,14 +364,14 @@ float compute_symbolic_block_difference(\nfor (int i = 0; i < texel_count; i++)\n{\n- weights[i] = compute_value_of_texel_int(i, it, uq_plane1_weights);\n+ weights[i] = compute_value_of_texel_int(i, dt, uq_plane1_weights);\n}\nif (is_dual_plane)\n{\nfor (int i = 0; i < texel_count; i++)\n{\n- plane2_weights[i] = compute_value_of_texel_int(i, it, uq_plane2_weights);\n+ plane2_weights[i] = compute_value_of_texel_int(i, dt, uq_plane2_weights);\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "diff": "@@ -739,12 +739,12 @@ void compute_endpoints_and_ideal_weights_2_planes(\nfloat compute_error_of_weight_set(\nconst endpoints_and_weights* eai,\n- const decimation_table* it,\n+ const decimation_table* dt,\nconst float* weights\n) {\nvfloat verror_summa(0.0f);\nfloat error_summa = 0.0f;\n- int texel_count = it->texel_count;\n+ int texel_count = dt->texel_count;\nint i = 0;\n@@ -755,10 +755,10 @@ float compute_error_of_weight_set(\nfor (/* */; i < clipped_texel_count; i += ASTCENC_SIMD_WIDTH)\n{\n// Load the bilinear filter texel weight indexes\n- vint weight_idx0 = vint(&(it->texel_weights_4t[0][i]));\n- vint weight_idx1 = vint(&(it->texel_weights_4t[1][i]));\n- vint weight_idx2 = vint(&(it->texel_weights_4t[2][i]));\n- vint weight_idx3 = vint(&(it->texel_weights_4t[3][i]));\n+ vint weight_idx0 = vint(&(dt->texel_weights_4t[0][i]));\n+ vint weight_idx1 = vint(&(dt->texel_weights_4t[1][i]));\n+ vint weight_idx2 = vint(&(dt->texel_weights_4t[2][i]));\n+ vint weight_idx3 = vint(&(dt->texel_weights_4t[3][i]));\n// Load the bilinear filter texel weights\nvfloat weight_val0 = gatherf(weights, weight_idx0);\n@@ -767,11 +767,11 @@ float compute_error_of_weight_set(\nvfloat weight_val3 = gatherf(weights, weight_idx3);\n// Load the weight contributions for each texel\n- // TODO: Should we rename this it->texel_weights_float field?\n- vfloat tex_weight_float0 = loada(&(it->texel_weights_float_4t[0][i]));\n- vfloat tex_weight_float1 = loada(&(it->texel_weights_float_4t[1][i]));\n- vfloat tex_weight_float2 = loada(&(it->texel_weights_float_4t[2][i]));\n- vfloat tex_weight_float3 = loada(&(it->texel_weights_float_4t[3][i]));\n+ // TODO: Should we rename this dt->texel_weights_float field?\n+ vfloat tex_weight_float0 = loada(&(dt->texel_weights_float_4t[0][i]));\n+ vfloat tex_weight_float1 = loada(&(dt->texel_weights_float_4t[1][i]));\n+ vfloat tex_weight_float2 = loada(&(dt->texel_weights_float_4t[2][i]));\n+ vfloat tex_weight_float3 = loada(&(dt->texel_weights_float_4t[3][i]));\n// Compute the bilinear interpolation\nvfloat current_values = (weight_val0 * tex_weight_float0 +\n@@ -798,10 +798,10 @@ float compute_error_of_weight_set(\n{\n// This isn't the ideal access pattern, but the cache lines are probably\n// already in the cache due to the vector loop above, so go with it ...\n- float current_value = (weights[it->texel_weights_4t[0][i]] * it->texel_weights_float_4t[0][i] +\n- weights[it->texel_weights_4t[1][i]] * it->texel_weights_float_4t[1][i]) +\n- (weights[it->texel_weights_4t[2][i]] * it->texel_weights_float_4t[2][i] +\n- weights[it->texel_weights_4t[3][i]] * it->texel_weights_float_4t[3][i]);\n+ float current_value = (weights[dt->texel_weights_4t[0][i]] * dt->texel_weights_float_4t[0][i] +\n+ weights[dt->texel_weights_4t[1][i]] * dt->texel_weights_float_4t[1][i]) +\n+ (weights[dt->texel_weights_4t[2][i]] * dt->texel_weights_float_4t[2][i] +\n+ weights[dt->texel_weights_4t[3][i]] * dt->texel_weights_float_4t[3][i]);\nfloat valuedif = current_value - eai->weights[i];\nfloat error = valuedif * valuedif * eai->weight_error_scale[i];\n@@ -982,7 +982,7 @@ void compute_ideal_weights_for_decimation_table(\ntriggering any perturbations *OR* we have run 4 full passes.\n*/\nvoid compute_quantized_weights_for_decimation_table(\n- const decimation_table* it,\n+ const decimation_table* dt,\nfloat low_bound,\nfloat high_bound,\nconst float* weight_set_in,\n@@ -990,7 +990,7 @@ void compute_quantized_weights_for_decimation_table(\nuint8_t* quantized_weight_set,\nint quant_level\n) {\n- int weight_count = it->weight_count;\n+ int weight_count = dt->weight_count;\nconst quantization_and_transfer_table *qat = &(quant_and_xfer_tables[quant_level]);\nstatic const int quant_levels[12] { 2,3,4,5,6,8,10,12,16,20,24,32 };\n@@ -1147,7 +1147,7 @@ void recompute_ideal_colors_2planes(\nconst uint8_t* plane2_weight_set8, // nullptr if plane 2 is not actually used.\nint plane2_color_component, // color component for 2nd plane of weights; -1 if the 2nd plane of weights is not present\nconst partition_info* pt,\n- const decimation_table* it,\n+ const decimation_table* dt,\nconst imageblock* blk, // picture-block containing the actual data.\nconst error_weight_block* ewb\n) {\n@@ -1156,14 +1156,14 @@ void recompute_ideal_colors_2planes(\nfloat weight_set[MAX_WEIGHTS_PER_BLOCK];\nfloat plane2_weight_set[MAX_WEIGHTS_PER_BLOCK];\n- for (int i = 0; i < it->weight_count; i++)\n+ for (int i = 0; i < dt->weight_count; i++)\n{\nweight_set[i] = qat->unquantized_value[weight_set8[i]] * (1.0f / 64.0f);\n}\nif (plane2_weight_set8)\n{\n- for (int i = 0; i < it->weight_count; i++)\n+ for (int i = 0; i < dt->weight_count; i++)\n{\nplane2_weight_set[i] = qat->unquantized_value[plane2_weight_set8[i]] * (1.0f / 64.0f);\n}\n@@ -1231,8 +1231,8 @@ void recompute_ideal_colors_2planes(\n// FIXME: move this calculation out to the color block.\nfloat ls_weight = hadd_rgb_s(color_weight);\n- const uint8_t *texel_weights = it->texel_weights_t4[tix];\n- const float *texel_weights_float = it->texel_weights_float_t4[tix];\n+ const uint8_t *texel_weights = dt->texel_weights_t4[tix];\n+ const float *texel_weights_float = dt->texel_weights_float_t4[tix];\nfloat idx0 = (weight_set[texel_weights[0]] * texel_weights_float[0]\n+ weight_set[texel_weights[1]] * texel_weights_float[1])\n+ (weight_set[texel_weights[2]] * texel_weights_float[2]\n@@ -1479,11 +1479,11 @@ void recompute_ideal_colors_1plane(\nvfloat4* rgbo_vectors, // used to return RGBO-vectors for endpoint mode #7\nconst uint8_t* weight_set8, // the current set of weight values\nconst partition_info* pt,\n- const decimation_table* it,\n+ const decimation_table* dt,\nconst imageblock* blk, // picture-block containing the actual data.\nconst error_weight_block* ewb\n) {\n- int weight_count = it->weight_count;\n+ int weight_count = dt->weight_count;\nint partition_count = pt->partition_count;\npromise(weight_count > 0);\n@@ -1553,8 +1553,8 @@ void recompute_ideal_colors_1plane(\n// FIXME: move this calculation out to the color block.\nfloat ls_weight = hadd_rgb_s(color_weight);\n- const uint8_t *texel_weights = it->texel_weights_t4[tix];\n- const float *texel_weights_float = it->texel_weights_float_t4[tix];\n+ const uint8_t *texel_weights = dt->texel_weights_t4[tix];\n+ const float *texel_weights_float = dt->texel_weights_float_t4[tix];\nfloat idx0 = (weight_set[texel_weights[0]] * texel_weights_float[0]\n+ weight_set[texel_weights[1]] * texel_weights_float[1])\n+ (weight_set[texel_weights[2]] * texel_weights_float[2]\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -1107,7 +1107,7 @@ void compute_ideal_weights_for_decimation_table(\n* Compute the quantized weight set, for a specific quant level.\n*/\nvoid compute_quantized_weights_for_decimation_table(\n- const decimation_table* it,\n+ const decimation_table* dt,\nfloat low_bound,\nfloat high_bound,\nconst float* weight_set_in,\n@@ -1117,7 +1117,7 @@ void compute_quantized_weights_for_decimation_table(\nfloat compute_error_of_weight_set(\nconst endpoints_and_weights* eai,\n- const decimation_table* it,\n+ const decimation_table* dt,\nconst float *weights);\nvoid merge_endpoints(\n@@ -1218,7 +1218,7 @@ void recompute_ideal_colors_1plane(\nvfloat4* rgbo_vectors, // used to return RGBS-vectors for endpoint mode #7 (HDR RGB base + scale)\nconst uint8_t* weight_set8, // the current set of weight values\nconst partition_info* pt,\n- const decimation_table* it,\n+ const decimation_table* dt,\nconst imageblock* blk, // picture-block containing the actual data.\nconst error_weight_block* ewb);\n@@ -1231,7 +1231,7 @@ void recompute_ideal_colors_2planes(\nconst uint8_t* plane2_weight_set8, // nullptr if plane 2 is not actually used.\nint plane2_color_component, // color component for 2nd plane of weights; -1 if the 2nd plane of weights is not present\nconst partition_info* pt,\n- const decimation_table* it,\n+ const decimation_table* dt,\nconst imageblock* blk, // picture-block containing the actual data.\nconst error_weight_block* ewb);\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_symbolic_physical.cpp", "new_path": "Source/astcenc_symbolic_physical.cpp", "diff": "@@ -124,13 +124,13 @@ void symbolic_to_physical(\nweightbuf[i] = 0;\n}\n- const decimation_table *const *ixtab2 = bsd.decimation_tables;\n+ const decimation_table *const *dts = bsd.decimation_tables;\nconst int packed_index = bsd.block_mode_packed_index[scb.block_mode];\nassert(packed_index >= 0 && packed_index < bsd.block_mode_count);\nconst block_mode& bm = bsd.block_modes[packed_index];\n- int weight_count = ixtab2[bm.decimation_mode]->weight_count;\n+ int weight_count = dts[bm.decimation_mode]->weight_count;\nint weight_quant_method = bm.quant_mode;\nint is_dual_plane = bm.is_dual_plane;\n@@ -257,7 +257,7 @@ void physical_to_symbolic(\nscb.error_block = 0;\n// get hold of the decimation tables.\n- const decimation_table *const *ixtab2 = bsd.decimation_tables;\n+ const decimation_table *const *dts = bsd.decimation_tables;\n// extract header fields\nint block_mode = read_bits(11, 0, pcb.data);\n@@ -333,7 +333,7 @@ void physical_to_symbolic(\nassert(packed_index >= 0 && packed_index < bsd.block_mode_count);\nconst struct block_mode& bm = bsd.block_modes[packed_index];\n- int weight_count = ixtab2[bm.decimation_mode]->weight_count;\n+ int weight_count = dts[bm.decimation_mode]->weight_count;\nint weight_quant_method = bm.quant_mode;\nint is_dual_plane = bm.is_dual_plane;\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Standardize on dts/dt for decimation table(s)
61,745
24.02.2021 21:38:08
0
adc5d13664421e5462f596174a28444859b2bfd8
Fix comment in SSE asr function
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_sse_4.h", "new_path": "Source/astcenc_vecmathlib_sse_4.h", "diff": "@@ -579,7 +579,7 @@ template <int s> ASTCENC_SIMD_INLINE vint4 lsl(vint4 a)\n}\n/**\n- * @brief Logical shift right.\n+ * @brief Arithmetic shift right.\n*/\ntemplate <int s> ASTCENC_SIMD_INLINE vint4 asr(vint4 a)\n{\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Fix comment in SSE asr function
61,745
24.02.2021 21:56:41
0
a7c3a6a33e9f0dd4301ae34e9df9c907639d9960
Fix diagnostics build
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -1396,9 +1396,10 @@ void compress_block(\n#if !defined(ASTCENC_DIAGNOSTICS)\nlowest_correl = prepare_block_statistics(bsd->texel_count, blk, ewb);\n- block_skip_two_plane = lowest_correl > ctx.config.tune_two_plane_early_out_limit;\n#endif\n+ block_skip_two_plane = lowest_correl > ctx.config.tune_two_plane_early_out_limit;\n+\n// next, test the four possible 1-partition, 2-planes modes\nfor (int i = 0; i < 4; i++)\n{\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Fix diagnostics build
61,745
25.02.2021 18:32:36
0
873824ab741cac2ee7cab5464a850a218e3fe313
Use vectorized accumulators in loop tails This change allows vector loop bodies to run for the full loop count for any vector width by making all loop tail accumulators behave the same as a vec4 accumulator in terms of floating point reassociation.
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_averages_and_directions.cpp", "new_path": "Source/astcenc_averages_and_directions.cpp", "diff": "@@ -378,11 +378,6 @@ void compute_error_squared_rgba(\nint i = 0;\n-#if ASTCENC_SIMD_WIDTH > 1\n- // This implementation is an example vectorization of this function.\n- // It works for - the codec is a 2-4% faster than not vectorizing - but\n- // the benefit is limited by the use of gathers and register pressure\n-\n// Vectorize some useful scalar inputs\nvfloat l_uncor_bs0(l_uncor.bs.lane<0>());\nvfloat l_uncor_bs1(l_uncor.bs.lane<1>());\n@@ -419,7 +414,7 @@ void compute_error_squared_rgba(\nvfloat samec_hiparamv(-1e10f);\nvfloat4 samec_errorsumv = vfloat4::zero();\n- int clipped_texel_count = round_down_to_simd_multiple_8(texel_count);\n+ int clipped_texel_count = round_down_to_simd_multiple_vla(texel_count);\nfor (/* */; i < clipped_texel_count; i += ASTCENC_SIMD_WIDTH)\n{\nvint texel_idxs(&(weights[i]));\n@@ -483,14 +478,16 @@ void compute_error_squared_rgba(\nuncor_loparam = hmin_s(uncor_loparamv);\nuncor_hiparam = hmax_s(uncor_hiparamv);\n- haccumulate(uncor_errorsum, uncor_errorsumv);\nsamec_loparam = hmin_s(samec_loparamv);\nsamec_hiparam = hmax_s(samec_hiparamv);\n- haccumulate(samec_errorsum, samec_errorsumv);\n-#endif\n// Loop tail\n+ // Error is buffered and accumulated in blocks of 4 to ensure that\n+ // the partial sums added to the accumulator are invariant with the\n+ // vector implementation, irrespective of vector size ...\n+ alignas(16) float uncor_errorsum_tmp[4] { 0 };\n+ alignas(16) float samec_errorsum_tmp[4] { 0 };\nfor (/* */; i < texel_count; i++)\n{\nint iwt = weights[i];\n@@ -508,11 +505,36 @@ void compute_error_squared_rgba(\nvfloat4 uncor_dist = (l_uncor.amod - dat)\n+ (uncor_param * l_uncor.bis);\n- uncor_errorsum += dot_s(ews, uncor_dist * uncor_dist);\n+ float uncor_error_tmp = dot_s(ews, uncor_dist * uncor_dist);\nvfloat4 samec_dist = samec_param * l_samec.bis - dat;\n- samec_errorsum += dot_s(ews, samec_dist * samec_dist);\n+ float samec_error_tmp = dot_s(ews, samec_dist * samec_dist);\n+\n+ // Accumulate error sum in the temporary array\n+ int error_index = i & 0x3;\n+ uncor_errorsum_tmp[error_index] = uncor_error_tmp;\n+ samec_errorsum_tmp[error_index] = samec_error_tmp;\n+\n+#if ASTCENC_SIMD_WIDTH == 8\n+ // Zero the temporary staging buffer every 4 items unless last iter\n+ if ((i & 0x7) == 0x03)\n+ {\n+ haccumulate(uncor_errorsumv, vfloat4::loada(uncor_errorsum_tmp));\n+ storea(vfloat4::zero(), uncor_errorsum_tmp);\n+\n+ haccumulate(samec_errorsumv, vfloat4::loada(samec_errorsum_tmp));\n+ storea(vfloat4::zero(), samec_errorsum_tmp);\n}\n+#endif\n+ }\n+\n+ // Accumulate the loop tail using the vfloat4 swizzle\n+ haccumulate(uncor_errorsumv, vfloat4::loada(uncor_errorsum_tmp));\n+ haccumulate(samec_errorsumv, vfloat4::loada(samec_errorsum_tmp));\n+\n+ // Resolve the final scalar accumulator sum\n+ haccumulate(uncor_errorsum, uncor_errorsumv);\n+ haccumulate(samec_errorsum, samec_errorsumv);\nfloat uncor_linelen = uncor_hiparam - uncor_loparam;\nfloat samec_linelen = samec_hiparam - samec_loparam;\n@@ -561,7 +583,6 @@ void compute_error_squared_rgb(\nint i = 0;\n-#if ASTCENC_SIMD_WIDTH > 1\n// This implementation is an example vectorization of this function.\n// It works for - the codec is a 2-4% faster than not vectorizing - but\n// the benefit is limited by the use of gathers and register pressure\n@@ -597,7 +618,7 @@ void compute_error_squared_rgb(\nvfloat samec_hiparamv(-1e10f);\nvfloat4 samec_errorsumv = vfloat4::zero();\n- int clipped_texel_count = round_down_to_simd_multiple_8(texel_count);\n+ int clipped_texel_count = round_down_to_simd_multiple_vla(texel_count);\nfor (/* */; i < clipped_texel_count; i += ASTCENC_SIMD_WIDTH)\n{\nvint texel_idxs(&(weights[i]));\n@@ -652,14 +673,16 @@ void compute_error_squared_rgb(\nuncor_loparam = hmin_s(uncor_loparamv);\nuncor_hiparam = hmax_s(uncor_hiparamv);\n- haccumulate(uncor_errorsum, uncor_errorsumv);\nsamec_loparam = hmin_s(samec_loparamv);\nsamec_hiparam = hmax_s(samec_hiparamv);\n- haccumulate(samec_errorsum, samec_errorsumv);\n-#endif\n// Loop tail\n+ // Error is buffered and accumulated in blocks of 4 to ensure that\n+ // the partial sums added to the accumulator are invariant with the\n+ // vector implementation, irrespective of vector size ...\n+ alignas(16) float uncor_errorsum_tmp[4] { 0 };\n+ alignas(16) float samec_errorsum_tmp[4] { 0 };\nfor (/* */; i < texel_count; i++)\n{\nint iwt = weights[i];\n@@ -677,12 +700,37 @@ void compute_error_squared_rgb(\nvfloat4 uncor_dist = (l_uncor.amod - dat)\n+ (uncor_param * l_uncor.bis);\n- uncor_errorsum += dot3_s(ews, uncor_dist * uncor_dist);\n+ float uncor_error_tmp = dot3_s(ews, uncor_dist * uncor_dist);\nvfloat4 samec_dist = samec_param * l_samec.bis - dat;\n- samec_errorsum += dot3_s(ews, samec_dist * samec_dist);\n+ float samec_error_tmp = dot3_s(ews, samec_dist * samec_dist);\n+\n+ // Accumulate error sum in the temporary array\n+ int error_index = i & 0x3;\n+ uncor_errorsum_tmp[error_index] = uncor_error_tmp;\n+ samec_errorsum_tmp[error_index] = samec_error_tmp;\n+\n+#if ASTCENC_SIMD_WIDTH == 8\n+ // Emit the staging buffer every 4 items unless last iteration\n+ if ((i & 0x7) == 0x03)\n+ {\n+ haccumulate(uncor_errorsumv, vfloat4::loada(uncor_errorsum_tmp));\n+ storea(vfloat4::zero(), uncor_errorsum_tmp);\n+\n+ haccumulate(samec_errorsumv, vfloat4::loada(samec_errorsum_tmp));\n+ storea(vfloat4::zero(), samec_errorsum_tmp);\n+ }\n+#endif\n}\n+ // Accumulate the loop tail using the vfloat4 swizzle\n+ haccumulate(uncor_errorsumv, vfloat4::loada(uncor_errorsum_tmp));\n+ haccumulate(samec_errorsumv, vfloat4::loada(samec_errorsum_tmp));\n+\n+ // Resolve the final scalar accumulator sum\n+ haccumulate(uncor_errorsum, uncor_errorsumv);\n+ haccumulate(samec_errorsum, samec_errorsumv);\n+\nfloat uncor_linelen = uncor_hiparam - uncor_loparam;\nfloat samec_linelen = samec_hiparam - samec_loparam;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "diff": "@@ -742,16 +742,14 @@ float compute_error_of_weight_set(\nconst decimation_table* dt,\nconst float* weights\n) {\n- vfloat4 verror_summa = vfloat4::zero();\n+ vfloat4 error_summav = vfloat4::zero();\nfloat error_summa = 0.0f;\nint texel_count = dt->texel_count;\nint i = 0;\n-#if ASTCENC_SIMD_WIDTH > 1\n-\n// Process SIMD-width texel coordinates at at time while we can\n- int clipped_texel_count = round_down_to_simd_multiple_8(texel_count);\n+ int clipped_texel_count = round_down_to_simd_multiple_vla(texel_count);\nfor (/* */; i < clipped_texel_count; i += ASTCENC_SIMD_WIDTH)\n{\n// Load the bilinear filter texel weight indexes\n@@ -785,14 +783,14 @@ float compute_error_of_weight_set(\nvfloat significance = loada(&(eai->weight_error_scale[i]));\nvfloat error = diff * diff * significance;\n- haccumulate(verror_summa, error);\n+ haccumulate(error_summav, error);\n}\n- // Accumulate the error vectors into a single error sum\n- haccumulate(error_summa, verror_summa);\n-#endif\n-\n// Loop tail\n+ // Error is buffered and accumulated in blocks of 4 to ensure that\n+ // the partial sums added to the accumulator are invariant with the\n+ // vector implementation, irrespective of vector size ...\n+ alignas(16) float errorsum_tmp[4] { 0 };\nfor (/* */; i < texel_count; i++)\n{\n// This isn't the ideal access pattern, but the cache lines are probably\n@@ -805,9 +803,28 @@ float compute_error_of_weight_set(\nfloat valuedif = current_value - eai->weights[i];\nfloat error = valuedif * valuedif * eai->weight_error_scale[i];\n- error_summa += error;\n+ // Accumulate error sum in the temporary array\n+ int error_index = i & 0x3;\n+ errorsum_tmp[error_index] = error;\n+\n+#if ASTCENC_SIMD_WIDTH == 8\n+ // Zero the temporary staging buffer every 4 items unless last. Note\n+ // that this block can only trigger for 6x5 blocks, all other partials\n+ // tails are shorter than 4 ...\n+ if ((i & 0x7) == 0x03)\n+ {\n+ haccumulate(error_summav, vfloat4::loada(errorsum_tmp));\n+ storea(vfloat4::zero(), errorsum_tmp);\n+ }\n+#endif\n}\n+ // Accumulate the loop tail using the vfloat4 swizzle\n+ haccumulate(error_summav, vfloat4::loada(errorsum_tmp));\n+\n+ // Resolve the final scalar accumulator sum\n+ haccumulate(error_summa, error_summav);\n+\nreturn error_summa;\n}\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Use vectorized accumulators in loop tails (#225) This change allows vector loop bodies to run for the full loop count for any vector width by making all loop tail accumulators behave the same as a vec4 accumulator in terms of floating point reassociation.
61,745
25.02.2021 20:23:51
0
fd9c64529cd603e8642a7e336b12bcb23dce55f6
Add cmake support static library builds
[ { "change_type": "MODIFY", "old_path": "Source/cmake_core.cmake", "new_path": "Source/cmake_core.cmake", "diff": "@@ -20,10 +20,8 @@ project(astc${CODEC}-${ISA_SIMD})\nset(GNU_LIKE \"GNU,Clang,AppleClang\")\nset(CLANG_LIKE \"Clang,AppleClang\")\n-add_executable(astc${CODEC}-${ISA_SIMD})\n-\n-target_sources(astc${CODEC}-${ISA_SIMD}\n- PRIVATE\n+add_library(astc${CODEC}-${ISA_SIMD}-static\n+ STATIC\nastcenc_averages_and_directions.cpp\nastcenc_block_sizes2.cpp\nastcenc_color_quantize.cpp\n@@ -48,7 +46,13 @@ target_sources(astc${CODEC}-${ISA_SIMD}\nastcenc_quantization.cpp\nastcenc_symbolic_physical.cpp\nastcenc_weight_align.cpp\n- astcenc_weight_quant_xfer_tables.cpp\n+ astcenc_weight_quant_xfer_tables.cpp)\n+\n+target_include_directories(astc${CODEC}-${ISA_SIMD}-static\n+ PUBLIC\n+ ${CMAKE_CURRENT_SOURCE_DIR})\n+\n+add_executable(astc${CODEC}-${ISA_SIMD}\nastcenccli_error_metrics.cpp\nastcenccli_image.cpp\nastcenccli_image_external.cpp\n@@ -57,28 +61,34 @@ target_sources(astc${CODEC}-${ISA_SIMD}\nastcenccli_toplevel.cpp\nastcenccli_toplevel_help.cpp)\n-target_compile_features(astc${CODEC}-${ISA_SIMD}\n+target_link_libraries(astc${CODEC}-${ISA_SIMD}\n+ PRIVATE\n+ astc${CODEC}-${ISA_SIMD}-static)\n+\n+macro(astcenc_set_properties NAME)\n+\n+ target_compile_features(${NAME}\nPRIVATE\ncxx_std_14)\n-target_compile_definitions(astc${CODEC}-${ISA_SIMD}\n+ target_compile_definitions(${NAME}\nPRIVATE\n# MSVC defines\n$<$<CXX_COMPILER_ID:MSVC>:_CRT_SECURE_NO_WARNINGS>)\nif(${DECOMPRESSOR})\n- target_compile_definitions(astc${CODEC}-${ISA_SIMD}\n+ target_compile_definitions(${NAME}\nPRIVATE\nASTCENC_DECOMPRESS_ONLY)\nendif()\nif(${DIAGNOSTICS})\n- target_compile_definitions(astc${CODEC}-${ISA_SIMD}\n- PRIVATE\n+ target_compile_definitions(${NAME}\n+ PUBLIC\nASTCENC_DIAGNOSTICS)\nendif()\n-target_compile_options(astc${CODEC}-${ISA_SIMD}\n+ target_compile_options(${NAME}\nPRIVATE\n# Use pthreads on Linux/macOS\n$<$<PLATFORM_ID:Linux,Darwin>:-pthread>\n@@ -112,44 +122,24 @@ target_compile_options(astc${CODEC}-${ISA_SIMD}\n$<$<CXX_COMPILER_ID:Clang>:-Wdocumentation>)\n-target_link_options(astc${CODEC}-${ISA_SIMD}\n+ target_link_options(${NAME}\nPRIVATE\n# Use pthreads on Linux/macOS\n$<$<PLATFORM_ID:Linux,Darwin>:-pthread>)\n# Enable LTO on release builds\n-set_property(TARGET astc${CODEC}-${ISA_SIMD} PROPERTY\n+ set_property(TARGET ${NAME}\n+ PROPERTY\nINTERPROCEDURAL_OPTIMIZATION_RELEASE True)\n# Use a static runtime on MSVC builds (ignored on non-MSVC compilers)\n-set_property(TARGET astc${CODEC}-${ISA_SIMD} PROPERTY\n+ set_property(TARGET ${NAME}\n+ PROPERTY\nMSVC_RUNTIME_LIBRARY \"MultiThreaded$<$<CONFIG:Debug>:Debug>\")\n-if(CMAKE_CXX_COMPILER_ID MATCHES \"GNU|Clang\")\n-\n- string(CONCAT EXTERNAL_CXX_FLAGS\n- \" $<$<NOT:$<CXX_COMPILER_ID:MSVC>>: -fno-strict-aliasing>\"\n- \" $<$<NOT:$<CXX_COMPILER_ID:MSVC>>: -Wno-unused-parameter>\"\n- \" $<$<NOT:$<CXX_COMPILER_ID:MSVC>>: -Wno-double-promotion>\"\n- \" $<$<NOT:$<CXX_COMPILER_ID:MSVC>>: -Wno-zero-as-null-pointer-constant>\"\n- \" $<$<NOT:$<CXX_COMPILER_ID:MSVC>>: -Wno-disabled-macro-expansion>\"\n- \" $<$<NOT:$<CXX_COMPILER_ID:MSVC>>: -Wno-reserved-id-macro>\"\n- \" $<$<NOT:$<CXX_COMPILER_ID:MSVC>>: -Wno-extra-semi-stmt>\"\n- \" $<$<NOT:$<CXX_COMPILER_ID:MSVC>>: -Wno-implicit-fallthrough>\"\n- \" $<$<NOT:$<CXX_COMPILER_ID:MSVC>>: -Wno-tautological-type-limit-compare>\"\n- \" $<$<NOT:$<CXX_COMPILER_ID:MSVC>>: -Wno-cast-qual>\"\n- \" $<$<CXX_COMPILER_ID:Clang>: -Wno-missing-prototypes>\"\n- )\n-\n-\n-\n- set_source_files_properties(astcenccli_image_external.cpp\n- PROPERTIES COMPILE_FLAGS ${EXTERNAL_CXX_FLAGS})\n-endif()\n-\n# Set up configuration for SIMD ISA builds\nif(${ISA_SIMD} MATCHES \"none\")\n- target_compile_definitions(astc${CODEC}-${ISA_SIMD}\n+ target_compile_definitions(${NAME}\nPRIVATE\nASTCENC_NEON=0\nASTCENC_SSE=0\n@@ -158,7 +148,7 @@ if(${ISA_SIMD} MATCHES \"none\")\nASTCENC_F16C=0)\nelseif(${ISA_SIMD} MATCHES \"neon\")\n- target_compile_definitions(astc${CODEC}-${ISA_SIMD}\n+ target_compile_definitions(${NAME}\nPRIVATE\nASTCENC_NEON=1\nASTCENC_SSE=0\n@@ -167,7 +157,7 @@ elseif(${ISA_SIMD} MATCHES \"neon\")\nASTCENC_F16C=0)\nelseif(${ISA_SIMD} MATCHES \"sse2\")\n- target_compile_definitions(astc${CODEC}-${ISA_SIMD}\n+ target_compile_definitions(${NAME}\nPRIVATE\nASTCENC_NEON=0\nASTCENC_SSE=20\n@@ -176,7 +166,7 @@ elseif(${ISA_SIMD} MATCHES \"sse2\")\nASTCENC_F16C=0)\nelseif(${ISA_SIMD} MATCHES \"sse4.1\")\n- target_compile_definitions(astc${CODEC}-${ISA_SIMD}\n+ target_compile_definitions(${NAME}\nPRIVATE\nASTCENC_NEON=0\nASTCENC_SSE=41\n@@ -184,12 +174,12 @@ elseif(${ISA_SIMD} MATCHES \"sse4.1\")\nASTCENC_POPCNT=1\nASTCENC_F16C=0)\n- target_compile_options(astc${CODEC}-${ISA_SIMD}\n+ target_compile_options(${NAME}\nPRIVATE\n$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-msse4.1 -mpopcnt>)\nelseif(${ISA_SIMD} MATCHES \"avx2\")\n- target_compile_definitions(astc${CODEC}-${ISA_SIMD}\n+ target_compile_definitions(${NAME}\nPRIVATE\nASTCENC_NEON=0\nASTCENC_SSE=41\n@@ -197,10 +187,35 @@ elseif(${ISA_SIMD} MATCHES \"avx2\")\nASTCENC_POPCNT=1\nASTCENC_F16C=1)\n- target_compile_options(astc${CODEC}-${ISA_SIMD}\n+ target_compile_options(${NAME}\nPRIVATE\n$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-mavx2 -mpopcnt -mf16c>\n$<$<CXX_COMPILER_ID:MSVC>:/arch:AVX2>)\nendif()\n+endmacro()\n+\n+if(CMAKE_CXX_COMPILER_ID MATCHES \"GNU|Clang\")\n+ string(CONCAT EXTERNAL_CXX_FLAGS\n+ \" $<$<NOT:$<CXX_COMPILER_ID:MSVC>>: -fno-strict-aliasing>\"\n+ \" $<$<NOT:$<CXX_COMPILER_ID:MSVC>>: -Wno-unused-parameter>\"\n+ \" $<$<NOT:$<CXX_COMPILER_ID:MSVC>>: -Wno-double-promotion>\"\n+ \" $<$<NOT:$<CXX_COMPILER_ID:MSVC>>: -Wno-zero-as-null-pointer-constant>\"\n+ \" $<$<NOT:$<CXX_COMPILER_ID:MSVC>>: -Wno-disabled-macro-expansion>\"\n+ \" $<$<NOT:$<CXX_COMPILER_ID:MSVC>>: -Wno-reserved-id-macro>\"\n+ \" $<$<NOT:$<CXX_COMPILER_ID:MSVC>>: -Wno-extra-semi-stmt>\"\n+ \" $<$<NOT:$<CXX_COMPILER_ID:MSVC>>: -Wno-implicit-fallthrough>\"\n+ \" $<$<NOT:$<CXX_COMPILER_ID:MSVC>>: -Wno-tautological-type-limit-compare>\"\n+ \" $<$<NOT:$<CXX_COMPILER_ID:MSVC>>: -Wno-cast-qual>\"\n+ \" $<$<CXX_COMPILER_ID:Clang>: -Wno-missing-prototypes>\")\n+\n+ set_source_files_properties(astcenccli_image_external.cpp\n+ PROPERTIES\n+ COMPILE_FLAGS ${EXTERNAL_CXX_FLAGS})\n+endif()\n+\n+astcenc_set_properties(astc${CODEC}-${ISA_SIMD})\n+\n+astcenc_set_properties(astc${CODEC}-${ISA_SIMD}-static)\n+\ninstall(TARGETS astc${CODEC}-${ISA_SIMD} DESTINATION ${PACKAGE_ROOT})\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add cmake support static library builds
61,745
27.02.2021 20:07:47
0
d04c640ef73b7e86cf6fc62041ebba5b7bc32ce4
Fix missing array transpose in debug assert
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "diff": "@@ -861,7 +861,7 @@ void compute_ideal_weights_for_decimation_table(\n{\nfor (int i = 0; i < texel_count; i++)\n{\n- assert(i == dt.weight_texel[i][0]);\n+ assert(i == dt.weight_texel[0][i]);\nweight_set[i] = eai_in.weights[i];\nweights[i] = eai_in.weight_error_scale[i];\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Fix missing array transpose in debug assert
61,764
27.02.2021 22:24:21
-7,200
f81b75728c59a7b567429ee6ca49063a3f467762
Use bool for have_z Easier to convert to other languages
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compute_variance.cpp", "new_path": "Source/astcenc_compute_variance.cpp", "diff": "@@ -117,7 +117,7 @@ static void compute_pixel_region_variance(\nfloat rgb_power = arg->rgb_power;\nfloat alpha_power = arg->alpha_power;\nastcenc_swizzle swz = arg->swz;\n- int have_z = arg->have_z;\n+ bool have_z = arg->have_z;\nint size_x = arg->size_x;\nint size_y = arg->size_y;\n@@ -590,7 +590,7 @@ unsigned int init_compute_averages_and_variances(\nint kernel_radius = astc::max(avg_var_kernel_radius, alpha_kernel_radius);\nint kerneldim = 2 * kernel_radius + 1;\n- int have_z = (size_z > 1);\n+ bool have_z = (size_z > 1);\nint max_blk_size_xy = have_z ? 16 : 32;\nint max_blk_size_z = astc::min(size_z, have_z ? 16 : 1);\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -957,7 +957,7 @@ struct pixel_region_variance_args\n/** The channel swizzle pattern. */\nastcenc_swizzle swz;\n/** Should the algorithm bother with Z axis processing? */\n- int have_z;\n+ bool have_z;\n/** The kernel radius for average and variance. */\nint avg_var_kernel_radius;\n/** The kernel radius for alpha processing. */\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Use bool for have_z (#226) Easier to convert to other languages
61,745
27.02.2021 21:09:40
0
4bf8a9859e8f0577558da535f2db81fcb258d2b1
clangcl.exe - Add default inititalizer
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -1447,8 +1447,8 @@ void compress_block(\n// find best blocks for 2, 3 and 4 partitions\nfor (int partition_count = 2; partition_count <= max_partitions; partition_count++)\n{\n- int partition_indices_1plane[2];\n- int partition_index_2planes;\n+ int partition_indices_1plane[2] { 0, 0 };\n+ int partition_index_2planes = 0;\nfind_best_partitionings(bsd, blk, ewb, partition_count,\nctx.config.tune_partition_index_limit,\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
clangcl.exe - Add default inititalizer
61,745
27.02.2021 21:09:59
0
9aaf0a465f087a88872da1a14a100aabf947399f
clangcl.exe - Add float LERP casts
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_entry.cpp", "new_path": "Source/astcenc_entry.cpp", "diff": "@@ -424,8 +424,10 @@ astcenc_error astcenc_config_init(\nfloat wt_node_b = (quality - node_a.quality) / wt_range;\n#define LERP(param) ((node_a.param * wt_node_a) + (node_b.param * wt_node_b))\n- #define LERPI(param) astc::flt2int_rtn((node_a.param * wt_node_a) + (node_b.param * wt_node_b))\n- #define LERPUI(param) (unsigned int)astc::flt2int_rtn((node_a.param * wt_node_a) + (node_b.param * wt_node_b))\n+ #define LERPI(param) astc::flt2int_rtn(\\\n+ (((float)node_a.param) * wt_node_a) + \\\n+ (((float)node_b.param) * wt_node_b))\n+ #define LERPUI(param) (unsigned int)LERPI(param)\nconfig.tune_partition_count_limit = LERPI(tune_partition_count_limit);\nconfig.tune_partition_index_limit = LERPI(tune_partition_index_limit);\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
clangcl.exe - Add float LERP casts
61,745
27.02.2021 21:10:26
0
942b38e0c27a382b7f6ba62ca2b47afa8afda816
clangcl.exe - Make constants floats
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_image.cpp", "new_path": "Source/astcenc_image.cpp", "diff": "@@ -152,7 +152,7 @@ void imageblock_initialize_deriv(\nvfloat4 dataf = float16_to_float(datai);\ndataf = max(dataf, 6e-5f);\n- vfloat4 data_lns1 = dataf * 1.05;\n+ vfloat4 data_lns1 = dataf * 1.05f;\ndata_lns1 = vfloat4(\nfloat_to_lns(data_lns1.lane<0>()),\nfloat_to_lns(data_lns1.lane<1>()),\n@@ -421,7 +421,7 @@ void fetch_imageblock(\na = data[swz.a];\n}\n- vfloat4 dataf = max(float16_to_float(vint4(r, g, b, a)), 1e-8);\n+ vfloat4 dataf = max(float16_to_float(vint4(r, g, b, a)), 1e-8f);\nblk->data_r[idx] = dataf.lane<0>();\nblk->data_g[idx] = dataf.lane<1>();\nblk->data_b[idx] = dataf.lane<2>();\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
clangcl.exe - Make constants floats
61,745
27.02.2021 21:11:01
0
e34fa221698532c89cf491b499b87b4235109e94
Remove spurious double ;;
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_kmeans_partitioning.cpp", "new_path": "Source/astcenc_kmeans_partitioning.cpp", "diff": "@@ -100,7 +100,7 @@ static void kmeans_init(\n}\n// update the distances with the new point.\n- center_color = blk->texel(sample);;\n+ center_color = blk->texel(sample);\ndistance_sum = 0.0f;\nfor (int i = 0; i < texels_per_block; i++)\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_pick_best_endpoint_format.cpp", "new_path": "Source/astcenc_pick_best_endpoint_format.cpp", "diff": "@@ -904,7 +904,7 @@ void determine_optimal_set_of_endpoint_formats_to_use(\nbest_quant_levels + i, best_quant_levels_mod + i,\nbest_ep_formats[i], &error_of_best_combination);\n- errors_of_best_combination[i] = error_of_best_combination + qwt_errors[i];;\n+ errors_of_best_combination[i] = error_of_best_combination + qwt_errors[i];\n}\n}\n// code for the case where the block contains 4 partitions\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_error_metrics.cpp", "new_path": "Source/astcenccli_error_metrics.cpp", "diff": "@@ -227,7 +227,7 @@ void compute_error_metrics(\ndata16[(4 * xsize2 * y) + (4 * x + 3)]);\ncolor2 = float16_to_float(color2i);\n- color2 = clamp(0, 65504.0f, color2);;\n+ color2 = clamp(0, 65504.0f, color2);\n}\nelse // if (img2->data_type == ASTCENC_TYPE_F32)\n{\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Remove spurious double ;;
61,745
27.02.2021 21:11:27
0
c858ed4d449b242f1773946f182ddaf64380272c
Make some TU-local functions static
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_mathlib_softfloat.cpp", "new_path": "Source/astcenc_mathlib_softfloat.cpp", "diff": "@@ -134,7 +134,7 @@ static uint32_t rtup_shift32(uint32_t inp, uint32_t shamt)\n}\n/* convert from FP16 to FP32. */\n-sf32 sf16_to_sf32(sf16 inp)\n+static sf32 sf16_to_sf32(sf16 inp)\n{\nuint32_t inpx = inp;\n@@ -185,7 +185,7 @@ sf32 sf16_to_sf32(sf16 inp)\n}\n/* Conversion routine that converts from FP32 to FP16. It supports denormals and all rounding modes. If a NaN is given as input, it is quietened. */\n-sf16 sf32_to_sf16(sf32 inp, roundmode rmode)\n+static sf16 sf32_to_sf16(sf32 inp, roundmode rmode)\n{\n/* for each possible sign/exponent combination, store a case index. This gives a 512-byte table */\nstatic const uint8_t tab[512] = {\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel.cpp", "new_path": "Source/astcenccli_toplevel.cpp", "diff": "@@ -119,7 +119,7 @@ struct compression_workload {\n/**\n* @brief Test if a string argument is a well formed float.\n*/\n-bool is_float(\n+static bool is_float(\nstd::string target\n) {\nfloat test;\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Make some TU-local functions static
61,745
27.02.2021 21:11:53
0
f516bb64fc7aaf5262e7f317b48dd7dbfee4a24f
Fix min/max type on vint4 clamp()
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_neon_4.h", "new_path": "Source/astcenc_vecmathlib_neon_4.h", "diff": "@@ -583,7 +583,7 @@ ASTCENC_SIMD_INLINE vint4 max(vint4 a, vint4 b)\n/**\n* @brief Return the clamped value between min and max.\n*/\n-ASTCENC_SIMD_INLINE vint4 clamp(float minv, float maxv, vint4 a)\n+ASTCENC_SIMD_INLINE vint4 clamp(int minv, int maxv, vint4 a)\n{\nreturn min(max(a, vint4(minv)), vint4(maxv));\n}\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_sse_4.h", "new_path": "Source/astcenc_vecmathlib_sse_4.h", "diff": "@@ -619,7 +619,7 @@ ASTCENC_SIMD_INLINE vint4 max(vint4 a, vint4 b)\n/**\n* @brief Return the clamped value between min and max.\n*/\n-ASTCENC_SIMD_INLINE vint4 clamp(float minv, float maxv, vint4 a)\n+ASTCENC_SIMD_INLINE vint4 clamp(int minv, int maxv, vint4 a)\n{\nreturn min(max(a, vint4(minv)), vint4(maxv));\n}\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Fix min/max type on vint4 clamp()
61,745
27.02.2021 21:17:25
0
5efaac8e8d3233b8cb3012761a141610957b7636
Fix type casts on float DDS/KTX loads
[ { "change_type": "MODIFY", "old_path": "Source/astcenccli_image_load_store.cpp", "new_path": "Source/astcenccli_image_load_store.cpp", "diff": "@@ -218,7 +218,7 @@ static void copy_scanline(\n#define id(x) (x)\n#define u16_sf16(x) float_to_float16(x * (1.0f/65535.0f))\n-#define f32_sf16(x) float16_to_float(x)\n+#define f32_sf16(x) float_to_float16(x)\n#define COPY_R(dsttype, srctype, convfunc, oneval) \\\ndo { \\\n@@ -418,21 +418,21 @@ static void copy_scanline(\nCOPY_LA(uint16_t, uint16_t, u16_sf16, 0x3C00);\ncase R32F_TO_RGBA16F:\n- COPY_R(uint16_t, uint32_t, f32_sf16, 0x3C00);\n+ COPY_R(uint16_t, float, f32_sf16, 0x3C00);\ncase RG32F_TO_RGBA16F:\n- COPY_RG(uint16_t, uint32_t, f32_sf16, 0x3C00);\n+ COPY_RG(uint16_t, float, f32_sf16, 0x3C00);\ncase RGB32F_TO_RGBA16F:\n- COPY_RGB(uint16_t, uint32_t, f32_sf16, 0x3C00);\n+ COPY_RGB(uint16_t, float, f32_sf16, 0x3C00);\ncase RGBA32F_TO_RGBA16F:\n- COPY_RGBA(uint16_t, uint32_t, f32_sf16, 0x3C00);\n+ COPY_RGBA(uint16_t, float, f32_sf16, 0x3C00);\ncase BGR32F_TO_RGBA16F:\n- COPY_BGR(uint16_t, uint32_t, f32_sf16, 0x3C00);\n+ COPY_BGR(uint16_t, float, f32_sf16, 0x3C00);\ncase BGRA32F_TO_RGBA16F:\n- COPY_BGRA(uint16_t, uint32_t, f32_sf16, 0x3C00);\n+ COPY_BGRA(uint16_t, float, f32_sf16, 0x3C00);\ncase L32F_TO_RGBA16F:\n- COPY_L(uint16_t, uint32_t, f32_sf16, 0x3C00);\n+ COPY_L(uint16_t, float, f32_sf16, 0x3C00);\ncase LA32F_TO_RGBA16F:\n- COPY_LA(uint16_t, uint32_t, f32_sf16, 0x3C00);\n+ COPY_LA(uint16_t, float, f32_sf16, 0x3C00);\n}\n}\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Fix type casts on float DDS/KTX loads
61,745
27.02.2021 21:21:33
0
67ca698688e0377e4419f8da667da33ad4bc5472
Remove F16C workaround for MSVC
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_sse_4.h", "new_path": "Source/astcenc_vecmathlib_sse_4.h", "diff": "@@ -1193,13 +1193,7 @@ ASTCENC_SIMD_INLINE vfloat4 int_to_float(vint4 a)\nASTCENC_SIMD_INLINE vint4 float_to_float16(vfloat4 a)\n{\n#if ASTCENC_F16C >= 1\n- // Workaround for MSVC bug not accepting _MM_FROUND_NO_EXC;\n- // https://developercommunity2.visualstudio.com/t/-mm-cvtps-ph-doesnt-accept-mm-fround-no-exc/1343857\n- #if !defined(__clang__) && defined(_MSC_VER)\n__m128i packedf16 = _mm_cvtps_ph(a.m, 0);\n- #else\n- __m128i packedf16 = _mm_cvtps_ph(a.m, _MM_FROUND_NO_EXC);\n- #endif\n__m128i f16 = _mm_cvtepu16_epi32(packedf16);\nreturn vint4(f16);\n#else\n@@ -1217,13 +1211,7 @@ ASTCENC_SIMD_INLINE vint4 float_to_float16(vfloat4 a)\nstatic inline uint16_t float_to_float16(float a)\n{\n#if ASTCENC_F16C >= 1\n- // Workaround for MSVC bug not accepting _MM_FROUND_NO_EXC;\n- // https://developercommunity2.visualstudio.com/t/-mm-cvtps-ph-doesnt-accept-mm-fround-no-exc/1343857\n- #if !defined(__clang__) && defined(_MSC_VER)\n__m128i f16 = _mm_cvtps_ph(_mm_set1_ps(a), 0);\n- #else\n- __m128i f16 = _mm_cvtps_ph(_mm_set1_ps(a), _MM_FROUND_NO_EXC);\n- #endif\nreturn (uint16_t)_mm_cvtsi128_si32(f16);\n#else\nreturn float_to_sf16(a);\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Remove F16C workaround for MSVC
61,745
27.02.2021 21:34:11
0
4bec970b9d309c9e0189bdf4691e918f4abc8d7b
Windows builds default to /fp:strict
[ { "change_type": "MODIFY", "old_path": "Source/cmake_core.cmake", "new_path": "Source/cmake_core.cmake", "diff": "@@ -95,6 +95,7 @@ macro(astcenc_set_properties NAME)\n# MSVC compiler defines\n$<$<CXX_COMPILER_ID:MSVC>:/EHsc>\n+ $<$<CXX_COMPILER_ID:MSVC>:/fp:strict>\n# G++ and Clang++ compiler defines\n$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall>\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Windows builds default to /fp:strict
61,745
27.02.2021 21:50:12
0
11e85ab3541a38f1fb31f14de2d3024e26bd331b
Only scale test counts if repeats > 1
[ { "change_type": "MODIFY", "old_path": "Test/astc_test_image.py", "new_path": "Test/astc_test_image.py", "diff": "@@ -462,9 +462,9 @@ def main():\n# The fast and fastest presets are now sufficiently fast that\n# the results are noisy without more repeats\ntestRepeats = args.testRepeats\n- if quality == \"fast\":\n+ if quality == \"fast\" and testRepeats > 1:\ntestRepeats *= 2\n- elif quality == \"fastest\":\n+ elif quality == \"fastest\" and testRepeats > 1:\ntestRepeats *= 4\nresultSet = run_test_set(encoder, testRef, testSet, quality,\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Only scale test counts if repeats > 1
61,745
27.02.2021 22:46:34
0
05cd4ccc7858fc644cec1c44d13fab6161363a1c
Add print() to no-SIMD vfloat4
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_none_4.h", "new_path": "Source/astcenc_vecmathlib_none_4.h", "diff": "#endif\n#include <algorithm>\n+#include <cstdio>\n#include <cstring>\n// ============================================================================\n@@ -744,6 +745,17 @@ ASTCENC_SIMD_INLINE vint4 select(vint4 a, vint4 b, vmask4 cond)\n(cond.m[3] & 0x80000000) ? b.m[3] : a.m[3]);\n}\n+/**\n+ * @brief Debug function to print a vector of ints.\n+ */\n+ASTCENC_SIMD_INLINE void print(vint4 a)\n+{\n+ alignas(16) int v[4];\n+ storea(a, v);\n+ printf(\"v4_i32:\\n %8u %8u %8u %8u\\n\",\n+ v[0], v[1], v[2], v[3]);\n+}\n+\n// ============================================================================\n// vfloat4 operators and functions\n// ============================================================================\n@@ -1279,4 +1291,15 @@ ASTCENC_SIMD_INLINE vfloat4 int_as_float(vint4 a)\nreturn r;\n}\n+/**\n+ * @brief Debug function to print a vector of floats.\n+ */\n+ASTCENC_SIMD_INLINE void print(vfloat4 a)\n+{\n+ alignas(16) float v[4];\n+ storea(a, v);\n+ printf(\"v4_f32:\\n %0.4f %0.4f %0.4f %0.4f\\n\",\n+ (double)v[0], (double)v[1], (double)v[2], (double)v[3]);\n+}\n+\n#endif // #ifndef ASTC_VECMATHLIB_NONE_4_H_INCLUDED\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add print() to no-SIMD vfloat4
61,745
27.02.2021 22:46:59
0
7f3362912c43153cf1b7b8662c7d70a58617c4b7
Add HDR test minification utility
[ { "change_type": "ADD", "old_path": null, "new_path": "Utils/astc_test_autoextract_hdr.cpp", "diff": "+// SPDX-License-Identifier: Apache-2.0\n+// ----------------------------------------------------------------------------\n+// Copyright 2021 Arm Limited\n+//\n+// Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n+// use this file except in compliance with the License. You may obtain a copy\n+// of the License at:\n+//\n+// http://www.apache.org/licenses/LICENSE-2.0\n+//\n+// Unless required by applicable law or agreed to in writing, software\n+// distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n+// License for the specific language governing permissions and limitations\n+// under the License.\n+// ----------------------------------------------------------------------------\n+\n+// Overview\n+// ========\n+//\n+// This is a utility tool to automatically generate single tile test vectors\n+// out of a larger test image. This tool takes three input images:\n+//\n+// - the uncompressed referenced,\n+// - the known-good compressed reference,\n+// - a new compressed image.\n+//\n+// The two compressed images are compared block-by-block, and if any block\n+// differences are found the worst block is extracted from the uncompressed\n+// reference and written back to disk as a single tile output image.\n+//\n+// Limitations\n+// ===========\n+//\n+// This tool only currently supports 2D LDR images.\n+//\n+// Build\n+// =====\n+//\n+// g++ astc_test_autoextract_hdr.cpp -I../Source -o astc_test_autoextract_hdr\n+\n+#include <stdio.h>\n+#include <stdlib.h>\n+\n+#define STB_IMAGE_IMPLEMENTATION\n+#include \"stb_image.h\"\n+\n+#define STB_IMAGE_WRITE_IMPLEMENTATION\n+#include \"stb_image_write.h\"\n+\n+/**\n+ * @brief Compute the array offset in a 2D image\n+ */\n+int pix(int x_pix, int y_idx, int x_idx, int chans, int p_idx)\n+{\n+ return ((y_idx * x_pix) + x_idx) * chans + p_idx;\n+}\n+\n+int main(int argc, char **argv)\n+{\n+\n+ // Parse command line\n+ if (argc < 6)\n+ {\n+ printf(\"Usage: astc_test_extract <blocksize> <ref> <good> <bad> <out>\\n\");\n+ return 1;\n+ }\n+\n+ int blockdim_x, blockdim_y;\n+ if (sscanf(argv[1], \"%dx%d\", &blockdim_x, &blockdim_y) < 2)\n+ {\n+ printf(\"blocksize must be of form WxH; e.g. 8x4\\n\");\n+ return 1;\n+ }\n+\n+ // Load the original reference image\n+ int ref_dim_x, ref_dim_y, ref_ncomp;\n+ float* data_ref = (float*)stbi_loadf(argv[2], &ref_dim_x, &ref_dim_y, &ref_ncomp, 4);\n+ if (!data_ref)\n+ {\n+ printf(\"Failed to load reference image.\\n\");\n+ return 1;\n+ }\n+\n+ // Load the good test image\n+ int good_dim_x, good_dim_y, good_ncomp;\n+ float* data_good = (float*)stbi_loadf(argv[3], &good_dim_x, &good_dim_y, &good_ncomp, 4);\n+ if (!data_good)\n+ {\n+ printf(\"Failed to load good test image.\\n\");\n+ return 1;\n+ }\n+\n+ // Load the bad test image\n+ int bad_dim_x, bad_dim_y, bad_ncomp;\n+ float* data_bad = (float*)stbi_loadf(argv[4], &bad_dim_x, &bad_dim_y, &bad_ncomp, 4);\n+ if (!data_bad)\n+ {\n+ printf(\"Failed to load bad test image.\\n\");\n+ return 1;\n+ }\n+\n+ if (ref_dim_x != good_dim_x || ref_dim_x != bad_dim_x ||\n+ ref_dim_y != good_dim_y || ref_dim_y != bad_dim_y)\n+ {\n+ printf(\"Failed as images are different resolutions.\\n\");\n+ return 1;\n+ }\n+\n+\n+ int x_blocks = (ref_dim_x + blockdim_x - 1) / blockdim_x;\n+ int y_blocks = (ref_dim_y + blockdim_y - 1) / blockdim_y;\n+\n+ float* errorsums = (float*)malloc(x_blocks * y_blocks * 4);\n+ for (int i = 0; i < x_blocks * y_blocks; i++)\n+ {\n+ errorsums[i] = 0;\n+ }\n+\n+ // Diff the two test images to find blocks that differ\n+ for (int y = 0; y < ref_dim_y; y++)\n+ {\n+ for (int x = 0; x < ref_dim_x; x++)\n+ {\n+ int x_block = x / blockdim_x;\n+ int y_block = y / blockdim_y;\n+\n+ float r_gd = data_good[pix(ref_dim_x, y, x, 4, 0)];\n+ float g_gd = data_good[pix(ref_dim_x, y, x, 4, 1)];\n+ float b_gd = data_good[pix(ref_dim_x, y, x, 4, 2)];\n+ float a_gd = data_good[pix(ref_dim_x, y, x, 4, 3)];\n+\n+ float r_bd = data_bad[pix(ref_dim_x, y, x, 4, 0)];\n+ float g_bd = data_bad[pix(ref_dim_x, y, x, 4, 1)];\n+ float b_bd = data_bad[pix(ref_dim_x, y, x, 4, 2)];\n+ float a_bd = data_bad[pix(ref_dim_x, y, x, 4, 3)];\n+\n+ float r_diff = (r_gd - r_bd) * (r_gd - r_bd);\n+ float g_diff = (g_gd - g_bd) * (g_gd - g_bd);\n+ float b_diff = (b_gd - b_bd) * (b_gd - b_bd);\n+ float a_diff = (a_gd - a_bd) * (a_gd - a_bd);\n+\n+ float diff = abs(r_diff) + abs(g_diff) + abs(b_diff) + abs(a_diff);\n+ errorsums[pix(x_blocks, y_block, x_block, 1, 0)] += diff;\n+ }\n+ }\n+\n+ // Diff the two test images to find blocks that differ\n+ float worst_error = 0.0f;\n+ int worst_x_block = 0;\n+ int worst_y_block = 0;\n+ for (int y = 0; y < y_blocks; y++)\n+ {\n+ for (int x = 0; x < x_blocks; x++)\n+ {\n+ float error = errorsums[pix(x_blocks, y, x, 1, 0)];\n+ if (error > worst_error)\n+ {\n+ worst_error = error;\n+ worst_x_block = x;\n+ worst_y_block = y;\n+ }\n+ }\n+ }\n+\n+ if (worst_error == 0.0f)\n+ {\n+ printf(\"No block errors found\\n\");\n+ }\n+ else\n+ {\n+ int start_y = worst_y_block * blockdim_y;\n+ int start_x = worst_x_block * blockdim_x;\n+\n+ int end_y = (worst_y_block + 1) * blockdim_y;\n+ int end_x = (worst_x_block + 1) * blockdim_x;\n+\n+ if (end_x > ref_dim_x)\n+ {\n+ end_x = ref_dim_x;\n+ }\n+\n+ if (end_y > ref_dim_y)\n+ {\n+ end_y = ref_dim_y;\n+ }\n+\n+ int outblk_x = end_x - start_x;\n+ int outblk_y = end_y - start_y;\n+\n+ printf(\"Block errors found at ~(%u, %u) px\\n\", start_x, start_y);\n+\n+ float* data_out = (float*)malloc(blockdim_x * blockdim_y * 4 * 4);\n+ for (int y = 0; y < outblk_y; y++)\n+ {\n+ for (int x = 0; x < outblk_x; x++)\n+ {\n+ data_out[(y * outblk_x * 4) + (x * 4) + 0] = data_ref[((start_y + y) * ref_dim_x * 4) + ((start_x + x) * 4) + 0];\n+ data_out[(y * outblk_x * 4) + (x * 4) + 1] = data_ref[((start_y + y) * ref_dim_x * 4) + ((start_x + x) * 4) + 1];\n+ data_out[(y * outblk_x * 4) + (x * 4) + 2] = data_ref[((start_y + y) * ref_dim_x * 4) + ((start_x + x) * 4) + 2];\n+ data_out[(y * outblk_x * 4) + (x * 4) + 3] = data_ref[((start_y + y) * ref_dim_x * 4) + ((start_x + x) * 4) + 3];\n+ }\n+ }\n+\n+ // Write out the worst bad block (from original reference)\n+ stbi_write_hdr(argv[5], outblk_x, outblk_y, 4, data_out);\n+\n+ free(data_out);\n+ }\n+\n+ free(errorsums);\n+ stbi_image_free(data_ref);\n+ stbi_image_free(data_good);\n+ stbi_image_free(data_bad);\n+ return 0;\n+}\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add HDR test minification utility
61,745
02.03.2021 16:59:55
0
b43d3a2736d9b4eb67b388743faa8f3282088ac5
Use vector versions of working pixel conversions Replace conversions between storage types (unorm16, LNS16), decode types(float16), and codec types (float), with vectorized versions of the same algorithms.
[ { "change_type": "MODIFY", "old_path": "Source/UnitTest/test_simd.cpp", "new_path": "Source/UnitTest/test_simd.cpp", "diff": "@@ -1663,6 +1663,47 @@ TEST(vint4, hadd_rgb_s)\nEXPECT_EQ(r2, 2);\n}\n+/** @brief Test vint4 clz. */\n+TEST(vint4, clz)\n+{\n+ vint4 a1(0x80000000, 0x40000000, 0x20000000, 0x10000000);\n+ vint4 r1 = clz(a1);\n+ EXPECT_EQ(r1.lane<0>(), 0);\n+ EXPECT_EQ(r1.lane<1>(), 1);\n+ EXPECT_EQ(r1.lane<2>(), 2);\n+ EXPECT_EQ(r1.lane<3>(), 3);\n+\n+ vint4 a2(0x0, 0x1, 0x2, 0x4);\n+ vint4 r2 = clz(a2);\n+ EXPECT_EQ(r2.lane<0>(), 32);\n+ EXPECT_EQ(r2.lane<1>(), 31);\n+ EXPECT_EQ(r2.lane<2>(), 30);\n+ EXPECT_EQ(r2.lane<3>(), 29);\n+}\n+\n+/** @brief Test vint4 two_to_the_n. */\n+TEST(vint4, two_to_the_n)\n+{\n+ vint4 a1(0, 1, 2, 3);\n+ vint4 r1 = two_to_the_n(a1);\n+ EXPECT_EQ(r1.lane<0>(), 1 << 0);\n+ EXPECT_EQ(r1.lane<1>(), 1 << 1);\n+ EXPECT_EQ(r1.lane<2>(), 1 << 2);\n+ EXPECT_EQ(r1.lane<3>(), 1 << 3);\n+\n+ vint4 a2(29, 30, 31, 32);\n+ vint4 r2 = two_to_the_n(a2);\n+ EXPECT_EQ(r2.lane<0>(), 1 << 29);\n+ EXPECT_EQ(r2.lane<1>(), 1 << 30);\n+ EXPECT_EQ(r2.lane<2>(), 1 << 31);\n+\n+ // This is just here for experimentation; the behavior of the actual\n+ // implementation here is undefined, as it shifts beyond the size of the\n+ // native type, and internally overflows the max value that can be stored\n+ // in a signed int. Behavior is different across instruction sets.\n+ // EXPECT_EQ(r2.lane<3>(), 1 << 32);\n+}\n+\n/** @brief Test vint4 storea. */\nTEST(vint4, storea)\n{\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_decompress_symbolic.cpp", "new_path": "Source/astcenc_decompress_symbolic.cpp", "diff": "@@ -132,13 +132,7 @@ void decompress_symbolic_block(\ncolori = asr<8>(colori) * 257;\n}\n- vint4 colorf16(\n- unorm16_to_sf16(colori.lane<0>()),\n- unorm16_to_sf16(colori.lane<1>()),\n- unorm16_to_sf16(colori.lane<2>()),\n- unorm16_to_sf16(colori.lane<3>())\n- );\n-\n+ vint4 colorf16 = unorm16_to_sf16(colori);\ncolor = float16_to_float(colorf16);\n}\nelse\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_image.cpp", "new_path": "Source/astcenc_image.cpp", "diff": "#include \"astcenc_internal.h\"\n-// conversion functions between the LNS representation and the FP16 representation.\n-static float float_to_lns(float p)\n-{\n- if (!(p > (1.0f / 67108864.0f)))\n- {\n- // underflow or NaN value, return 0.\n- // We count underflow if the input value is smaller than 2^-26.\n- return 0.0f;\n- }\n-\n- if (p >= 65536.0f)\n- {\n- // overflow, return a +INF value\n- return 65535.0f;\n- }\n-\n- int expo;\n- float normfrac = astc::frexp(p, &expo);\n- float p1;\n- if (expo < -13)\n- {\n- // input number is smaller than 2^-14. In this case, multiply by 2^25.\n- p1 = p * 33554432.0f;\n- expo = 0;\n- }\n- else\n- {\n- expo += 14;\n- p1 = (normfrac - 0.5f) * 4096.0f;\n- }\n-\n- if (p1 < 384.0f)\n- {\n- p1 *= 4.0f / 3.0f;\n- }\n- else if (p1 <= 1408.0f)\n- {\n- p1 += 128.0f;\n- }\n- else\n- {\n- p1 = (p1 + 512.0f) * (4.0f / 5.0f);\n- }\n-\n- p1 += ((float)expo) * 2048.0f;\n- return p1 + 1.0f;\n-}\n-\n-static uint16_t lns_to_sf16(uint16_t p)\n-{\n- uint16_t mc = p & 0x7FF;\n- uint16_t ec = p >> 11;\n- uint16_t mt;\n- if (mc < 512)\n- {\n- mt = 3 * mc;\n- }\n- else if (mc < 1536)\n- {\n- mt = 4 * mc - 512;\n- }\n- else\n- {\n- mt = 5 * mc - 2048;\n- }\n-\n- uint16_t res = (ec << 10) | (mt >> 3);\n- if (res > 0x7BFF)\n- {\n- res = 0x7BFF;\n- }\n- return res;\n-}\n-\n-// conversion function from 16-bit LDR value to FP16.\n-// note: for LDR interpolation, it is impossible to get a denormal result;\n-// this simplifies the conversion.\n-// FALSE; we can receive a very small UNORM16 through the constant-block.\n-uint16_t unorm16_to_sf16(uint16_t p)\n-{\n- if (p == 0xFFFF)\n- {\n- return 0x3C00; // value of 1.0\n- }\n-\n- if (p < 4)\n- {\n- return p << 8;\n- }\n-\n- int lz = clz32(p) - 16;\n- p <<= (lz + 1);\n- p >>= 6;\n- p |= (14 - lz) << 10;\n- return p;\n-}\n-\nvoid imageblock_initialize_deriv(\nconst imageblock* blk,\nint pixelcount,\n@@ -141,32 +44,16 @@ void imageblock_initialize_deriv(\nif (rgb_lns || a_lns)\n{\nvfloat4 data = blk->texel(i);\n-\n- vint4 datai(\n- lns_to_sf16((uint16_t)data.lane<0>()),\n- lns_to_sf16((uint16_t)data.lane<1>()),\n- lns_to_sf16((uint16_t)data.lane<2>()),\n- lns_to_sf16((uint16_t)data.lane<3>())\n- );\n+ vint4 datai = lns_to_sf16(float_to_int(data));\nvfloat4 dataf = float16_to_float(datai);\ndataf = max(dataf, 6e-5f);\nvfloat4 data_lns1 = dataf * 1.05f;\n- data_lns1 = vfloat4(\n- float_to_lns(data_lns1.lane<0>()),\n- float_to_lns(data_lns1.lane<1>()),\n- float_to_lns(data_lns1.lane<2>()),\n- float_to_lns(data_lns1.lane<3>())\n- );\n+ data_lns1 = float_to_lns(data_lns1);\nvfloat4 data_lns2 = dataf;\n- data_lns2 = vfloat4(\n- float_to_lns(data_lns2.lane<0>()),\n- float_to_lns(data_lns2.lane<1>()),\n- float_to_lns(data_lns2.lane<2>()),\n- float_to_lns(data_lns2.lane<3>())\n- );\n+ data_lns2 = float_to_lns(data_lns2);\nvfloat4 divisor_lns = dataf * 0.05f;\n@@ -197,28 +84,21 @@ static void imageblock_initialize_work_from_orig(\nfor (int i = 0; i < pixelcount; i++)\n{\nvfloat4 data = blk->texel(i);\n+ vfloat4 color_lns = vfloat4::zero();\n+ vfloat4 color_unorm = data * 65535.0f;\n- if (blk->rgb_lns[i])\n- {\n- data.set_lane<0>(float_to_lns(data.lane<0>()));\n- data.set_lane<1>(float_to_lns(data.lane<1>()));\n- data.set_lane<2>(float_to_lns(data.lane<2>()));\n- }\n- else\n- {\n- data.set_lane<0>(data.lane<0>() * 65535.0f);\n- data.set_lane<1>(data.lane<1>() * 65535.0f);\n- data.set_lane<2>(data.lane<2>() * 65535.0f);\n- }\n+ int rgb_lns = blk->rgb_lns[i];\n+ int a_lns = blk->alpha_lns[i];\n- if (blk->alpha_lns[i])\n- {\n- data.set_lane<3>(float_to_lns(data.lane<3>()));\n- }\n- else\n+ if (rgb_lns || a_lns)\n{\n- data.set_lane<3>(data.lane<3>() * 65535.0f);\n+ color_lns = float_to_lns(data);\n}\n+\n+ vint4 use_lns(rgb_lns, rgb_lns, rgb_lns, a_lns);\n+ vmask4 lns_mask = use_lns != vint4::zero();\n+ data = select(color_unorm, color_lns, lns_mask);\n+\n// Compute block metadata\ndata_min = min(data_min, data);\ndata_max = max(data_max, data);\n@@ -261,28 +141,14 @@ void imageblock_initialize_orig_from_work(\nint rgb_lns = blk->rgb_lns[i];\nint a_lns = blk->alpha_lns[i];\n- // TODO: Do a vector version of lns_to_sf16\n- // ... or do we even need the f16 intermediate?\nif (rgb_lns || a_lns)\n{\n- color_lns = vint4(\n- lns_to_sf16((uint16_t)data.lane<0>()),\n- lns_to_sf16((uint16_t)data.lane<1>()),\n- lns_to_sf16((uint16_t)data.lane<2>()),\n- lns_to_sf16((uint16_t)data.lane<3>())\n- );\n+ color_lns = lns_to_sf16(float_to_int(data));\n}\n- // TODO: Do a vector version of unorm16_to_sf16\n- // ... or do we even need the f16 intermediate?\nif ((!rgb_lns) || (!a_lns))\n{\n- color_unorm = vint4(\n- unorm16_to_sf16((uint16_t)data.lane<0>()),\n- unorm16_to_sf16((uint16_t)data.lane<1>()),\n- unorm16_to_sf16((uint16_t)data.lane<2>()),\n- unorm16_to_sf16((uint16_t)data.lane<3>())\n- );\n+ color_unorm = unorm16_to_sf16(float_to_int(data));\n}\n// Pick channels and then covert to FP16\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -1298,9 +1298,6 @@ void physical_to_symbolic(\nconst physical_compressed_block& pcb,\nsymbolic_compressed_block& scb);\n-uint16_t unorm16_to_sf16(\n- uint16_t p);\n-\n#if defined(ASTCENC_DIAGNOSTICS)\nclass TraceLog; // See astcenc_diagnostic_trace for details.\n#endif\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib.h", "new_path": "Source/astcenc_vecmathlib.h", "diff": "@@ -266,8 +266,7 @@ static ASTCENC_SIMD_INLINE vfloat4 normalize_safe(vfloat4 a, vfloat4 safe)\nreturn safe;\n}\n-// log2 and exp2 based on 5th degree minimax polynomials, ported from this blog\n-// https://jrfonseca.blogspot.com/2008/09/fast-sse2-pow-tables-or-polynomials.html\n+\n#define POLY0(x, c0) ( c0)\n#define POLY1(x, c0, c1) ((POLY0(x, c1) * x) + c0)\n@@ -276,6 +275,12 @@ static ASTCENC_SIMD_INLINE vfloat4 normalize_safe(vfloat4 a, vfloat4 safe)\n#define POLY4(x, c0, c1, c2, c3, c4) ((POLY3(x, c1, c2, c3, c4) * x) + c0)\n#define POLY5(x, c0, c1, c2, c3, c4, c5) ((POLY4(x, c1, c2, c3, c4, c5) * x) + c0)\n+/**\n+ * @brief Compute an approximate exp2(x) for each lane in the vector.\n+ *\n+ * Based on 5th degree minimax polynomials, ported from this blog\n+ * https://jrfonseca.blogspot.com/2008/09/fast-sse2-pow-tables-or-polynomials.html\n+ */\nstatic ASTCENC_SIMD_INLINE vfloat4 exp2(vfloat4 x)\n{\nx = clamp(-126.99999f, 129.0f, x);\n@@ -298,6 +303,12 @@ static ASTCENC_SIMD_INLINE vfloat4 exp2(vfloat4 x)\nreturn iexp * fexp;\n}\n+/**\n+ * @brief Compute an approximate log2(x) for each lane in the vector.\n+ *\n+ * Based on 5th degree minimax polynomials, ported from this blog\n+ * https://jrfonseca.blogspot.com/2008/09/fast-sse2-pow-tables-or-polynomials.html\n+ */\nstatic ASTCENC_SIMD_INLINE vfloat4 log2(vfloat4 x)\n{\nvint4 exp(0x7F800000);\n@@ -324,6 +335,11 @@ static ASTCENC_SIMD_INLINE vfloat4 log2(vfloat4 x)\nreturn p + e;\n}\n+/**\n+ * @brief Compute an approximate pow(x, y) for each lane in the vector.\n+ *\n+ * Power function based on the exp2(log2(x) * y) transform.\n+ */\nstatic ASTCENC_SIMD_INLINE vfloat4 pow(vfloat4 x, vfloat4 y)\n{\nvmask4 zero_mask = y == vfloat4(0.0f);\n@@ -333,6 +349,161 @@ static ASTCENC_SIMD_INLINE vfloat4 pow(vfloat4 x, vfloat4 y)\nreturn select(estimate, vfloat4(1.0f), zero_mask);\n}\n+/**\n+ * @brief Count the leading zeros for each lane in @c a.\n+ *\n+ * Valid for all data values of @c a; will return a per-lane value [0, 32].\n+ */\n+ASTCENC_SIMD_INLINE vint4 clz(vint4 a)\n+{\n+ // This function is a horrible abuse of floating point exponents to convert\n+ // the original integer value into a 2^N encoding we can recover easily.\n+\n+ // Convert to float without risk of rounding up by keeping only top 8 bits.\n+ // This trick is is guranteed to keep top 8 bits and clear the 9th.\n+ a = (~lsr<8>(a)) & a;\n+ a = float_as_int(int_to_float(a));\n+\n+ // Extract and unbias exponent\n+ a = vint4(127 + 31) - lsr<23>(a);\n+\n+ // Clamp result to a valid 32-bit range\n+ return clamp(0, 32, a);\n+}\n+\n+/**\n+ * @brief Return lanewise 2^a for each lane in @c a.\n+ *\n+ * Use of signed int mean that this is only valid for values in range [0, 31].\n+ */\n+ASTCENC_SIMD_INLINE vint4 two_to_the_n(vint4 a)\n+{\n+ // This function is a horrible abuse of floating point to use the exponent\n+ // and float conversion to generate a 2^N multiple.\n+\n+ // Bias the exponent\n+ vint4 exp = a + 127;\n+ exp = lsl<23>(exp);\n+\n+ // Reinterpret the bits as a float, and then convert to an int\n+ vfloat4 f = int_as_float(exp);\n+ return float_to_int(f);\n+}\n+\n+/**\n+ * @brief Convert unorm16 [0, 65535] to float16 in range [0, 1].\n+ */\n+ASTCENC_SIMD_INLINE vint4 unorm16_to_sf16(vint4 p)\n+{\n+ vint4 fp16_one = vint4(0x3C00);\n+ vint4 fp16_small = lsl<8>(p);\n+\n+ vmask4 is_one = p == vint4(0xFFFF);\n+ vmask4 is_small = p < vint4(4);\n+\n+ vint4 lz = clz(p) - 16;\n+\n+ // TODO: Could use AVX2 _mm_sllv_epi32() instead of p * 2^<shift>\n+ p = p * two_to_the_n(lz + 1);\n+ p = p & vint4(0xFFFF);\n+\n+ p = lsr<6>(p);\n+\n+ p = p | lsl<10>(vint4(14) - lz);\n+\n+ vint4 r = select(p, fp16_one, is_one);\n+ r = select(r, fp16_small, is_small);\n+ return r;\n+}\n+\n+/**\n+ * @brief Convert 16-bit LNS to float16.\n+ */\n+ASTCENC_SIMD_INLINE vint4 lns_to_sf16(vint4 p)\n+{\n+ vint4 mc = p & 0x7FF;\n+ vint4 ec = lsr<11>(p);\n+\n+ vint4 mc_512 = mc * 3;\n+ vmask4 mask_512 = mc < vint4(512);\n+\n+ vint4 mc_1536 = mc * 4 - 512;\n+ vmask4 mask_1536 = mc < vint4(1536);\n+\n+ vint4 mc_else = mc * 5 - 2048;\n+\n+ vint4 mt = mc_else;\n+ mt = select(mt, mc_1536, mask_1536);\n+ mt = select(mt, mc_512, mask_512);\n+\n+ vint4 res = lsl<10>(ec) | lsr<3>(mt);\n+ return min(res, vint4(0x7BFF));\n+}\n+\n+/**\n+ * @brief Extract mantissa and exponent of a float value.\n+ *\n+ * @param a The input value.\n+ * @param[out] exp The output exponent.\n+ *\n+ * @return The mantissa.\n+ */\n+static inline vfloat4 frexp(vfloat4 a, vint4& exp)\n+{\n+ // Interpret the bits as an integer\n+ vint4 ai = float_as_int(a);\n+\n+ // Extract and unbias the exponent\n+ exp = (lsr<23>(ai) & 0xFF) - 126;\n+\n+ // Extract and unbias the mantissa\n+ vint4 manti = (ai & 0x807FFFFF) | 0x3F000000;\n+ return int_as_float(manti);\n+}\n+\n+/**\n+ * @brief Convert float to 16-bit LNS.\n+ */\n+static inline vfloat4 float_to_lns(vfloat4 a)\n+{\n+ vint4 exp;\n+ vfloat4 mant = frexp(a, exp);\n+\n+ // Do these early before we start messing about ...\n+ vmask4 mask_underflow_nan = ~(a > vfloat4(1.0f / 67108864.0f));\n+ vmask4 mask_infinity = a >= vfloat4(65536.0f);\n+\n+ // If input is smaller than 2^-14, multiply by 2^25 and don't bias.\n+ vmask4 exp_lt_m13 = exp < vint4(-13);\n+\n+ vfloat4 a1a = a * 33554432.0f;\n+ vint4 expa = vint4::zero();\n+\n+ vfloat4 a1b = (mant - 0.5f) * 4096;\n+ vint4 expb = exp + 14;\n+\n+ a = select(a1b, a1a, exp_lt_m13);\n+ exp = select(expb, expa, exp_lt_m13);\n+\n+ vmask4 a_lt_384 = a < vfloat4(384.0f);\n+ vmask4 a_lt_1408 = a <= vfloat4(1408.0f);\n+\n+ vfloat4 a2a = a * (4.0f / 3.0f);\n+ vfloat4 a2b = a + 128.0f;\n+ vfloat4 a2c = (a + 512.0f) * (4.0f / 5.0f);\n+\n+ a = a2c;\n+ a = select(a, a2b, a_lt_1408);\n+ a = select(a, a2a, a_lt_384);\n+\n+ a = a + (int_to_float(exp) * 2048.0f) + 1.0f;\n+\n+ a = select(a, vfloat4(65535.0f), mask_infinity);\n+ a = select(a, vfloat4::zero(), mask_underflow_nan);\n+\n+ return a;\n+}\n+\nnamespace astc\n{\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_none_4.h", "new_path": "Source/astcenc_vecmathlib_none_4.h", "diff": "@@ -1222,14 +1222,16 @@ ASTCENC_SIMD_INLINE vfloat4 dot3(vfloat4 a, vfloat4 b)\n*/\nASTCENC_SIMD_INLINE vint4 float_to_int(vfloat4 a)\n{\n- return vint4(a.m[0],\n- a.m[1],\n- a.m[2],\n- a.m[3]);\n+ // Casting to unsigned buys us an extra bit of precision in cases where\n+ // we can use the integer as nasty bit hacks.\n+ return vint4((unsigned int)a.m[0],\n+ (unsigned int)a.m[1],\n+ (unsigned int)a.m[2],\n+ (unsigned int)a.m[3]);\n}\n-/**\n- * @brief Return a integer value for a float vector, using truncation.\n+/**f\n+ * @brief Return a integer value for a float vector, using round-to-nearest.\n*/\nASTCENC_SIMD_INLINE vint4 float_to_int_rtn(vfloat4 a)\n{\n@@ -1240,7 +1242,7 @@ ASTCENC_SIMD_INLINE vint4 float_to_int_rtn(vfloat4 a)\n}\n/**\n- * @brief Return a integer value for a float vector, using truncation.\n+ * @brief Return a float value for a integer vector.\n*/\nASTCENC_SIMD_INLINE vfloat4 int_to_float(vint4 a)\n{\n" }, { "change_type": "DELETE", "old_path": "Test/Images/Small/astc_reference-2.4-avx2_fast_results.csv", "new_path": null, "diff": "-Image Set,Block Size,Name,PSNR,Total Time,Coding Time,Coding Rate\n-Small,4x4,hdr-rgb-00.hdr,31.2191,0.1349,0.0369,1.7772\n-Small,4x4,ldr-rgb-00.png,37.6172,0.0301,0.0218,3.0115\n-Small,4x4,ldr-rgb-01.png,39.3611,0.0255,0.0175,3.7342\n-Small,4x4,ldr-rgb-02.png,34.4607,0.0374,0.0294,2.2290\n-Small,4x4,ldr-rgb-03.png,45.5383,0.0159,0.0084,7.7955\n-Small,4x4,ldr-rgb-04.png,41.4911,0.0222,0.0142,4.6302\n-Small,4x4,ldr-rgb-05.png,36.7925,0.0370,0.0285,2.2963\n-Small,4x4,ldr-rgb-06.png,34.5980,0.0346,0.0264,2.4844\n-Small,4x4,ldr-rgb-07.png,37.6407,0.0389,0.0303,2.1617\n-Small,4x4,ldr-rgb-08.png,43.0335,0.0208,0.0124,5.2652\n-Small,4x4,ldr-rgb-09.png,41.4868,0.0221,0.0140,4.6741\n-Small,4x4,ldr-rgb-10.png,44.2369,0.0095,0.0035,4.6066\n-Small,4x4,ldr-rgba-00.png,35.1510,0.0389,0.0303,2.1608\n-Small,4x4,ldr-rgba-01.png,38.5635,0.0224,0.0141,4.6559\n-Small,4x4,ldr-rgba-02.png,34.4379,0.0354,0.0264,2.4837\n-Small,4x4,ldr-xy-00.png,37.4349,0.0187,0.0107,6.1450\n-Small,4x4,ldr-xy-01.png,43.4397,0.0199,0.0121,5.4144\n-Small,4x4,ldr-xy-02.png,47.3279,0.0158,0.0074,8.8468\n-Small,4x4,ldrs-rgba-00.png,35.1568,0.0403,0.0318,2.0640\n-Small,4x4,ldrs-rgba-01.png,38.5796,0.0254,0.0170,3.8621\n-Small,4x4,ldrs-rgba-02.png,34.4422,0.0340,0.0256,2.5596\n-Small,5x5,hdr-rgb-00.hdr,25.4593,0.1362,0.0380,1.7245\n-Small,5x5,ldr-rgb-00.png,33.8446,0.0287,0.0191,3.4366\n-Small,5x5,ldr-rgb-01.png,35.9356,0.0219,0.0126,5.1856\n-Small,5x5,ldr-rgb-02.png,30.7962,0.0293,0.0202,3.2466\n-Small,5x5,ldr-rgb-03.png,42.1456,0.0151,0.0069,9.5633\n-Small,5x5,ldr-rgb-04.png,36.9837,0.0199,0.0109,6.0185\n-Small,5x5,ldr-rgb-05.png,32.9043,0.0328,0.0239,2.7388\n-Small,5x5,ldr-rgb-06.png,30.8271,0.0302,0.0207,3.1632\n-Small,5x5,ldr-rgb-07.png,34.1991,0.0295,0.0204,3.2186\n-Small,5x5,ldr-rgb-08.png,39.3388,0.0177,0.0092,7.1460\n-Small,5x5,ldr-rgb-09.png,37.0725,0.0219,0.0131,5.0096\n-Small,5x5,ldr-rgb-10.png,39.9741,0.0100,0.0036,4.5650\n-Small,5x5,ldr-rgba-00.png,31.4124,0.0386,0.0289,2.2638\n-Small,5x5,ldr-rgba-01.png,34.9689,0.0228,0.0138,4.7576\n-Small,5x5,ldr-rgba-02.png,30.8989,0.0373,0.0283,2.3163\n-Small,5x5,ldr-xy-00.png,36.5407,0.0190,0.0098,6.6711\n-Small,5x5,ldr-xy-01.png,39.2130,0.0192,0.0106,6.1862\n-Small,5x5,ldr-xy-02.png,43.0550,0.0158,0.0067,9.8167\n-Small,5x5,ldrs-rgba-00.png,31.4141,0.0377,0.0283,2.3130\n-Small,5x5,ldrs-rgba-01.png,34.9733,0.0231,0.0138,4.7401\n-Small,5x5,ldrs-rgba-02.png,30.8993,0.0375,0.0281,2.3284\n-Small,6x6,hdr-rgb-00.hdr,23.6123,0.1456,0.0452,1.4495\n-Small,6x6,ldr-rgb-00.png,31.2622,0.0386,0.0285,2.2989\n-Small,6x6,ldr-rgb-01.png,32.7097,0.0325,0.0225,2.9119\n-Small,6x6,ldr-rgb-02.png,27.2454,0.0489,0.0386,1.6957\n-Small,6x6,ldr-rgb-03.png,40.1903,0.0165,0.0066,9.9781\n-Small,6x6,ldr-rgb-04.png,33.6842,0.0294,0.0191,3.4231\n-Small,6x6,ldr-rgb-05.png,29.7493,0.0552,0.0450,1.4570\n-Small,6x6,ldr-rgb-06.png,27.2823,0.0498,0.0387,1.6954\n-Small,6x6,ldr-rgb-07.png,32.8710,0.0346,0.0243,2.7022\n-Small,6x6,ldr-rgb-08.png,37.4006,0.0211,0.0109,6.0064\n-Small,6x6,ldr-rgb-09.png,33.3123,0.0318,0.0218,3.0052\n-Small,6x6,ldr-rgb-10.png,36.3531,0.0123,0.0043,3.7718\n-Small,6x6,ldr-rgba-00.png,28.8488,0.0494,0.0388,1.6909\n-Small,6x6,ldr-rgba-01.png,31.9121,0.0269,0.0166,3.9463\n-Small,6x6,ldr-rgba-02.png,27.6705,0.0497,0.0393,1.6690\n-Small,6x6,ldr-xy-00.png,35.4447,0.0198,0.0096,6.8482\n-Small,6x6,ldr-xy-01.png,36.7592,0.0237,0.0139,4.7261\n-Small,6x6,ldr-xy-02.png,41.3844,0.0166,0.0059,11.0588\n-Small,6x6,ldrs-rgba-00.png,28.8502,0.0499,0.0394,1.6636\n-Small,6x6,ldrs-rgba-01.png,31.9174,0.0283,0.0176,3.7304\n-Small,6x6,ldrs-rgba-02.png,27.6695,0.0485,0.0380,1.7235\n-Small,8x8,hdr-rgb-00.hdr,21.0893,0.1532,0.0488,1.3431\n-Small,8x8,ldr-rgb-00.png,27.6412,0.0463,0.0311,2.1058\n-Small,8x8,ldr-rgb-01.png,28.5518,0.0410,0.0265,2.4759\n-Small,8x8,ldr-rgb-02.png,22.9165,0.0599,0.0448,1.4632\n-Small,8x8,ldr-rgb-03.png,36.9875,0.0219,0.0071,9.2499\n-Small,8x8,ldr-rgb-04.png,29.1009,0.0401,0.0251,2.6060\n-Small,8x8,ldr-rgb-05.png,25.5864,0.0674,0.0522,1.2566\n-Small,8x8,ldr-rgb-06.png,22.9618,0.0597,0.0445,1.4741\n-Small,8x8,ldr-rgb-07.png,29.6177,0.0344,0.0192,3.4096\n-Small,8x8,ldr-rgb-08.png,34.0657,0.0264,0.0114,5.7316\n-Small,8x8,ldr-rgb-09.png,28.4932,0.0443,0.0289,2.2683\n-Small,8x8,ldr-rgb-10.png,31.8599,0.0174,0.0048,3.3923\n-Small,8x8,ldr-rgba-00.png,24.6722,0.0554,0.0400,1.6386\n-Small,8x8,ldr-rgba-01.png,28.0809,0.0347,0.0194,3.3807\n-Small,8x8,ldr-rgba-02.png,23.7659,0.0585,0.0433,1.5144\n-Small,8x8,ldr-xy-00.png,32.8129,0.0263,0.0115,5.7003\n-Small,8x8,ldr-xy-01.png,33.8045,0.0283,0.0136,4.8117\n-Small,8x8,ldr-xy-02.png,39.5809,0.0191,0.0044,15.0034\n-Small,8x8,ldrs-rgba-00.png,24.6722,0.0564,0.0404,1.6216\n-Small,8x8,ldrs-rgba-01.png,28.0852,0.0356,0.0207,3.1622\n-Small,8x8,ldrs-rgba-02.png,23.7656,0.0607,0.0455,1.4404\n-Small,12x12,hdr-rgb-00.hdr,18.5091,0.1676,0.0542,1.2093\n-Small,12x12,ldr-rgb-00.png,23.4879,0.0400,0.0166,3.9420\n-Small,12x12,ldr-rgb-01.png,24.6686,0.0356,0.0132,4.9558\n-Small,12x12,ldr-rgb-02.png,19.1450,0.0709,0.0483,1.3557\n-Small,12x12,ldr-rgb-03.png,32.9538,0.0275,0.0050,12.9776\n-Small,12x12,ldr-rgb-04.png,24.3727,0.0380,0.0150,4.3618\n-Small,12x12,ldr-rgb-05.png,21.3484,0.0556,0.0323,2.0316\n-Small,12x12,ldr-rgb-06.png,19.0975,0.0669,0.0436,1.5025\n-Small,12x12,ldr-rgb-07.png,25.0646,0.0345,0.0107,6.1312\n-Small,12x12,ldr-rgb-08.png,29.8475,0.0303,0.0073,9.0331\n-Small,12x12,ldr-rgb-09.png,23.5994,0.0436,0.0205,3.1957\n-Small,12x12,ldr-rgb-10.png,27.1239,0.0244,0.0037,4.4043\n-Small,12x12,ldr-rgba-00.png,20.9578,0.0509,0.0274,2.3926\n-Small,12x12,ldr-rgba-01.png,24.3834,0.0369,0.0137,4.7680\n-Small,12x12,ldr-rgba-02.png,20.0934,0.0631,0.0396,1.6547\n-Small,12x12,ldr-xy-00.png,28.5829,0.0331,0.0103,6.3425\n-Small,12x12,ldr-xy-01.png,30.0953,0.0317,0.0089,7.3316\n-Small,12x12,ldr-xy-02.png,38.1044,0.0276,0.0040,16.2294\n-Small,12x12,ldrs-rgba-00.png,20.9523,0.0523,0.0286,2.2917\n-Small,12x12,ldrs-rgba-01.png,24.3849,0.0427,0.0171,3.8272\n-Small,12x12,ldrs-rgba-02.png,20.0933,0.0701,0.0442,1.4813\n-Small,3x3x3,ldr-l-00-3.dds,50.6030,0.0329,0.0235,11.1541\n-Small,3x3x3,ldr-l-01-3.dds,54.0343,0.0166,0.0094,7.3258\n-Small,6x6x6,ldr-l-00-3.dds,32.5264,0.0840,0.0540,4.8543\n-Small,6x6x6,ldr-l-01-3.dds,40.6338,0.0493,0.0213,3.2377\n" }, { "change_type": "DELETE", "old_path": "Test/Images/Small/astc_reference-2.4-avx2_fastest_results.csv", "new_path": null, "diff": "-Image Set,Block Size,Name,PSNR,Total Time,Coding Time,Coding Rate\n-Small,4x4,hdr-rgb-00.hdr,25.8935,0.1235,0.0243,2.6955\n-Small,4x4,ldr-rgb-00.png,35.0326,0.0184,0.0099,6.6441\n-Small,4x4,ldr-rgb-01.png,38.0662,0.0140,0.0061,10.6823\n-Small,4x4,ldr-rgb-02.png,33.4988,0.0185,0.0106,6.1961\n-Small,4x4,ldr-rgb-03.png,43.9215,0.0131,0.0053,12.4026\n-Small,4x4,ldr-rgb-04.png,40.1610,0.0140,0.0057,11.4552\n-Small,4x4,ldr-rgb-05.png,35.0692,0.0166,0.0083,7.8768\n-Small,4x4,ldr-rgb-06.png,33.5084,0.0195,0.0112,5.8426\n-Small,4x4,ldr-rgb-07.png,35.2206,0.0169,0.0082,7.9990\n-Small,4x4,ldr-rgb-08.png,40.6912,0.0142,0.0062,10.5893\n-Small,4x4,ldr-rgb-09.png,40.2872,0.0131,0.0048,13.5128\n-Small,4x4,ldr-rgb-10.png,41.7946,0.0082,0.0021,7.6929\n-Small,4x4,ldr-rgba-00.png,31.1448,0.0228,0.0141,4.6447\n-Small,4x4,ldr-rgba-01.png,38.0146,0.0142,0.0060,10.9152\n-Small,4x4,ldr-rgba-02.png,33.5960,0.0181,0.0098,6.7038\n-Small,4x4,ldr-xy-00.png,36.7640,0.0150,0.0066,9.9027\n-Small,4x4,ldr-xy-01.png,39.8881,0.0147,0.0069,9.5464\n-Small,4x4,ldr-xy-02.png,43.5791,0.0135,0.0054,12.2429\n-Small,4x4,ldrs-rgba-00.png,31.1465,0.0235,0.0149,4.3993\n-Small,4x4,ldrs-rgba-01.png,38.0256,0.0143,0.0060,10.8378\n-Small,4x4,ldrs-rgba-02.png,33.6005,0.0178,0.0094,6.9417\n-Small,5x5,hdr-rgb-00.hdr,24.3432,0.1206,0.0210,3.1273\n-Small,5x5,ldr-rgb-00.png,31.9371,0.0148,0.0060,10.9828\n-Small,5x5,ldr-rgb-01.png,34.6531,0.0126,0.0043,15.1248\n-Small,5x5,ldr-rgb-02.png,29.8852,0.0137,0.0052,12.7158\n-Small,5x5,ldr-rgb-03.png,40.5059,0.0124,0.0045,14.7238\n-Small,5x5,ldr-rgb-04.png,34.7445,0.0129,0.0042,15.4495\n-Small,5x5,ldr-rgb-05.png,30.9938,0.0137,0.0052,12.6783\n-Small,5x5,ldr-rgb-06.png,29.8549,0.0131,0.0045,14.5246\n-Small,5x5,ldr-rgb-07.png,31.8389,0.0133,0.0041,16.1617\n-Small,5x5,ldr-rgb-08.png,37.4098,0.0128,0.0041,15.9915\n-Small,5x5,ldr-rgb-09.png,34.4236,0.0123,0.0038,17.1296\n-Small,5x5,ldr-rgb-10.png,38.5353,0.0078,0.0015,10.9390\n-Small,5x5,ldr-rgba-00.png,28.6058,0.0179,0.0091,7.2399\n-Small,5x5,ldr-rgba-01.png,34.0529,0.0129,0.0042,15.6519\n-Small,5x5,ldr-rgba-02.png,30.3993,0.0141,0.0053,12.3070\n-Small,5x5,ldr-xy-00.png,35.2093,0.0135,0.0050,13.0552\n-Small,5x5,ldr-xy-01.png,35.6743,0.0139,0.0058,11.3328\n-Small,5x5,ldr-xy-02.png,42.0978,0.0128,0.0042,15.4608\n-Small,5x5,ldrs-rgba-00.png,28.6078,0.0180,0.0087,7.5087\n-Small,5x5,ldrs-rgba-01.png,34.0551,0.0131,0.0044,14.8639\n-Small,5x5,ldrs-rgba-02.png,30.4034,0.0143,0.0056,11.6173\n-Small,6x6,hdr-rgb-00.hdr,22.7999,0.1246,0.0247,2.6529\n-Small,6x6,ldr-rgb-00.png,28.8108,0.0152,0.0056,11.6925\n-Small,6x6,ldr-rgb-01.png,30.5107,0.0132,0.0042,15.6332\n-Small,6x6,ldr-rgb-02.png,25.4589,0.0154,0.0053,12.3797\n-Small,6x6,ldr-rgb-03.png,38.2811,0.0129,0.0042,15.6154\n-Small,6x6,ldr-rgb-04.png,30.1882,0.0136,0.0040,16.3103\n-Small,6x6,ldr-rgb-05.png,27.0820,0.0140,0.0045,14.4194\n-Small,6x6,ldr-rgb-06.png,25.6537,0.0140,0.0045,14.4482\n-Small,6x6,ldr-rgb-07.png,29.8604,0.0137,0.0041,16.0157\n-Small,6x6,ldr-rgb-08.png,34.9837,0.0129,0.0038,17.1648\n-Small,6x6,ldr-rgb-09.png,28.5351,0.0128,0.0037,17.7501\n-Small,6x6,ldr-rgb-10.png,31.4646,0.0087,0.0016,10.2762\n-Small,6x6,ldr-rgba-00.png,26.4225,0.0178,0.0079,8.3231\n-Small,6x6,ldr-rgba-01.png,30.2527,0.0133,0.0038,17.1788\n-Small,6x6,ldr-rgba-02.png,26.3776,0.0151,0.0053,12.2680\n-Small,6x6,ldr-xy-00.png,33.5163,0.0141,0.0049,13.3501\n-Small,6x6,ldr-xy-01.png,34.2597,0.0141,0.0051,12.7725\n-Small,6x6,ldr-xy-02.png,41.1165,0.0136,0.0043,15.0800\n-Small,6x6,ldrs-rgba-00.png,26.4284,0.0178,0.0081,8.1231\n-Small,6x6,ldrs-rgba-01.png,30.2561,0.0136,0.0039,16.5959\n-Small,6x6,ldrs-rgba-02.png,26.3739,0.0146,0.0053,12.3468\n-Small,8x8,hdr-rgb-00.hdr,20.7942,0.1345,0.0292,2.2452\n-Small,8x8,ldr-rgb-00.png,25.1154,0.0182,0.0052,12.6812\n-Small,8x8,ldr-rgb-01.png,26.7956,0.0167,0.0039,16.8296\n-Small,8x8,ldr-rgb-02.png,21.5941,0.0161,0.0037,17.8087\n-Small,8x8,ldr-rgb-03.png,34.7763,0.0160,0.0036,18.3069\n-Small,8x8,ldr-rgb-04.png,26.1376,0.0164,0.0036,18.4445\n-Small,8x8,ldr-rgb-05.png,23.0950,0.0170,0.0037,17.8087\n-Small,8x8,ldr-rgb-06.png,21.4626,0.0165,0.0036,18.2304\n-Small,8x8,ldr-rgb-07.png,26.2701,0.0172,0.0037,17.5607\n-Small,8x8,ldr-rgb-08.png,31.4678,0.0160,0.0034,19.2856\n-Small,8x8,ldr-rgb-09.png,25.2838,0.0167,0.0037,17.7318\n-Small,8x8,ldr-rgb-10.png,30.0851,0.0119,0.0015,10.8658\n-Small,8x8,ldr-rgba-00.png,22.5434,0.0203,0.0068,9.6418\n-Small,8x8,ldr-rgba-01.png,26.5711,0.0167,0.0037,17.9541\n-Small,8x8,ldr-rgba-02.png,22.6983,0.0170,0.0038,17.3655\n-Small,8x8,ldr-xy-00.png,29.7062,0.0171,0.0043,15.0725\n-Small,8x8,ldr-xy-01.png,29.6019,0.0168,0.0040,16.4165\n-Small,8x8,ldr-xy-02.png,39.5041,0.0170,0.0042,15.5412\n-Small,8x8,ldrs-rgba-00.png,22.5484,0.0211,0.0077,8.5212\n-Small,8x8,ldrs-rgba-01.png,26.5729,0.0166,0.0038,17.4526\n-Small,8x8,ldrs-rgba-02.png,22.6955,0.0173,0.0039,16.9166\n-Small,12x12,hdr-rgb-00.hdr,18.4124,0.1393,0.0314,2.0893\n-Small,12x12,ldr-rgb-00.png,21.8981,0.0213,0.0037,17.5652\n-Small,12x12,ldr-rgb-01.png,23.8592,0.0213,0.0037,17.8957\n-Small,12x12,ldr-rgb-02.png,18.3098,0.0218,0.0037,17.8957\n-Small,12x12,ldr-rgb-03.png,32.0890,0.0206,0.0034,18.9964\n-Small,12x12,ldr-rgb-04.png,22.8691,0.0212,0.0034,19.0174\n-Small,12x12,ldr-rgb-05.png,20.1230,0.0214,0.0035,18.8311\n-Small,12x12,ldr-rgb-06.png,18.1422,0.0216,0.0037,17.5517\n-Small,12x12,ldr-rgb-07.png,23.7844,0.0210,0.0031,21.1689\n-Small,12x12,ldr-rgb-08.png,28.1913,0.0221,0.0034,19.5281\n-Small,12x12,ldr-rgb-09.png,21.4310,0.0222,0.0045,14.5024\n-Small,12x12,ldr-rgb-10.png,26.3615,0.0166,0.0015,11.1428\n-Small,12x12,ldr-rgba-00.png,19.5067,0.0217,0.0034,19.2586\n-Small,12x12,ldr-rgba-01.png,23.6803,0.0217,0.0036,18.0746\n-Small,12x12,ldr-rgba-02.png,19.4701,0.0211,0.0035,18.8855\n-Small,12x12,ldr-xy-00.png,26.9326,0.0221,0.0042,15.6930\n-Small,12x12,ldr-xy-01.png,25.8774,0.0210,0.0037,17.7123\n-Small,12x12,ldr-xy-02.png,38.1044,0.0217,0.0038,17.3973\n-Small,12x12,ldrs-rgba-00.png,19.5053,0.0232,0.0035,18.9127\n-Small,12x12,ldrs-rgba-01.png,23.6816,0.0212,0.0037,17.9062\n-Small,12x12,ldrs-rgba-02.png,19.4687,0.0215,0.0035,18.8531\n-Small,3x3x3,ldr-l-00-3.dds,47.5277,0.0329,0.0237,11.0824\n-Small,3x3x3,ldr-l-01-3.dds,52.7373,0.0175,0.0105,6.5739\n-Small,6x6x6,ldr-l-00-3.dds,31.8998,0.0834,0.0534,4.9107\n-Small,6x6x6,ldr-l-01-3.dds,40.5942,0.0479,0.0198,3.4891\n" }, { "change_type": "DELETE", "old_path": "Test/Images/Small/astc_reference-2.4-avx2_medium_results.csv", "new_path": null, "diff": "-Image Set,Block Size,Name,PSNR,Total Time,Coding Time,Coding Rate\n-Small,4x4,hdr-rgb-00.hdr,32.3616,0.1717,0.0721,0.9085\n-Small,4x4,ldr-rgb-00.png,38.6186,0.0727,0.0636,1.0299\n-Small,4x4,ldr-rgb-01.png,39.9904,0.0641,0.0556,1.1789\n-Small,4x4,ldr-rgb-02.png,35.0864,0.0646,0.0561,1.1682\n-Small,4x4,ldr-rgb-03.png,46.9643,0.0446,0.0366,1.7905\n-Small,4x4,ldr-rgb-04.png,41.9794,0.0546,0.0460,1.4251\n-Small,4x4,ldr-rgb-05.png,37.6292,0.0714,0.0628,1.0434\n-Small,4x4,ldr-rgb-06.png,35.2309,0.0594,0.0508,1.2891\n-Small,4x4,ldr-rgb-07.png,38.6220,0.0871,0.0782,0.8380\n-Small,4x4,ldr-rgb-08.png,44.5908,0.0478,0.0392,1.6710\n-Small,4x4,ldr-rgb-09.png,41.9104,0.0569,0.0486,1.3493\n-Small,4x4,ldr-rgb-10.png,44.8283,0.0151,0.0090,1.8102\n-Small,4x4,ldr-rgba-00.png,36.1397,0.0851,0.0764,0.8582\n-Small,4x4,ldr-rgba-01.png,38.8010,0.0480,0.0391,1.6775\n-Small,4x4,ldr-rgba-02.png,34.7461,0.0682,0.0595,1.1007\n-Small,4x4,ldr-xy-00.png,37.6959,0.0401,0.0317,2.0649\n-Small,4x4,ldr-xy-01.png,44.9855,0.0545,0.0463,1.4168\n-Small,4x4,ldr-xy-02.png,50.9056,0.0559,0.0474,1.3813\n-Small,4x4,ldrs-rgba-00.png,36.1447,0.0864,0.0777,0.8439\n-Small,4x4,ldrs-rgba-01.png,38.8178,0.0475,0.0389,1.6835\n-Small,4x4,ldrs-rgba-02.png,34.7492,0.0702,0.0613,1.0693\n-Small,5x5,hdr-rgb-00.hdr,26.5177,0.1761,0.0777,0.8437\n-Small,5x5,ldr-rgb-00.png,35.0100,0.0813,0.0709,0.9238\n-Small,5x5,ldr-rgb-01.png,36.3412,0.0609,0.0513,1.2786\n-Small,5x5,ldr-rgb-02.png,30.9700,0.0633,0.0533,1.2299\n-Small,5x5,ldr-rgb-03.png,43.5605,0.0263,0.0169,3.8683\n-Small,5x5,ldr-rgb-04.png,37.5544,0.0564,0.0465,1.4080\n-Small,5x5,ldr-rgb-05.png,33.4512,0.0857,0.0756,0.8672\n-Small,5x5,ldr-rgb-06.png,30.9908,0.0602,0.0502,1.3044\n-Small,5x5,ldr-rgb-07.png,35.6054,0.0891,0.0792,0.8279\n-Small,5x5,ldr-rgb-08.png,41.1640,0.0404,0.0308,2.1245\n-Small,5x5,ldr-rgb-09.png,37.4846,0.0515,0.0416,1.5755\n-Small,5x5,ldr-rgb-10.png,40.4607,0.0177,0.0106,1.5407\n-Small,5x5,ldr-rgba-00.png,32.7046,0.1034,0.0932,0.7035\n-Small,5x5,ldr-rgba-01.png,35.2093,0.0539,0.0441,1.4863\n-Small,5x5,ldr-rgba-02.png,31.0406,0.0877,0.0777,0.8432\n-Small,5x5,ldr-xy-00.png,37.1119,0.0401,0.0304,2.1571\n-Small,5x5,ldr-xy-01.png,40.9199,0.0511,0.0413,1.5864\n-Small,5x5,ldr-xy-02.png,48.7008,0.0344,0.0249,2.6365\n-Small,5x5,ldrs-rgba-00.png,32.7058,0.1039,0.0938,0.6986\n-Small,5x5,ldrs-rgba-01.png,35.2165,0.0542,0.0442,1.4827\n-Small,5x5,ldrs-rgba-02.png,31.0419,0.0875,0.0777,0.8431\n-Small,6x6,hdr-rgb-00.hdr,24.7323,0.1852,0.0843,0.7776\n-Small,6x6,ldr-rgb-00.png,32.3215,0.0905,0.0791,0.8288\n-Small,6x6,ldr-rgb-01.png,33.0336,0.0816,0.0705,0.9297\n-Small,6x6,ldr-rgb-02.png,27.3867,0.0961,0.0846,0.7744\n-Small,6x6,ldr-rgb-03.png,41.4371,0.0248,0.0142,4.6026\n-Small,6x6,ldr-rgb-04.png,34.1260,0.0742,0.0632,1.0362\n-Small,6x6,ldr-rgb-05.png,30.1074,0.1104,0.0995,0.6587\n-Small,6x6,ldr-rgb-06.png,27.4381,0.0954,0.0840,0.7801\n-Small,6x6,ldr-rgb-07.png,33.9556,0.0966,0.0853,0.7686\n-Small,6x6,ldr-rgb-08.png,39.0372,0.0381,0.0271,2.4210\n-Small,6x6,ldr-rgb-09.png,33.6201,0.0726,0.0617,1.0629\n-Small,6x6,ldr-rgb-10.png,36.8847,0.0196,0.0106,1.5320\n-Small,6x6,ldr-rgba-00.png,30.1133,0.1143,0.1029,0.6368\n-Small,6x6,ldr-rgba-01.png,32.1295,0.0561,0.0445,1.4742\n-Small,6x6,ldr-rgba-02.png,27.7849,0.1045,0.0933,0.7021\n-Small,6x6,ldr-xy-00.png,36.0271,0.0389,0.0280,2.3416\n-Small,6x6,ldr-xy-01.png,37.9588,0.0482,0.0360,1.8209\n-Small,6x6,ldr-xy-02.png,45.0705,0.0353,0.0227,2.8900\n-Small,6x6,ldrs-rgba-00.png,30.1144,0.1168,0.1040,0.6299\n-Small,6x6,ldrs-rgba-01.png,32.1349,0.0583,0.0470,1.3952\n-Small,6x6,ldrs-rgba-02.png,27.7835,0.0941,0.0830,0.7893\n-Small,8x8,hdr-rgb-00.hdr,21.4320,0.1875,0.0804,0.8153\n-Small,8x8,ldr-rgb-00.png,28.6493,0.1156,0.0988,0.6632\n-Small,8x8,ldr-rgb-01.png,28.8554,0.0953,0.0788,0.8312\n-Small,8x8,ldr-rgb-02.png,23.0793,0.1122,0.0959,0.6837\n-Small,8x8,ldr-rgb-03.png,38.2658,0.0313,0.0154,4.2686\n-Small,8x8,ldr-rgb-04.png,29.5754,0.0905,0.0741,0.8846\n-Small,8x8,ldr-rgb-05.png,25.8717,0.1272,0.1111,0.5901\n-Small,8x8,ldr-rgb-06.png,23.1192,0.1134,0.0966,0.6785\n-Small,8x8,ldr-rgb-07.png,30.6667,0.1045,0.0877,0.7477\n-Small,8x8,ldr-rgb-08.png,35.6982,0.0453,0.0292,2.2427\n-Small,8x8,ldr-rgb-09.png,28.9985,0.0889,0.0724,0.9049\n-Small,8x8,ldr-rgb-10.png,32.1108,0.0269,0.0127,1.2805\n-Small,8x8,ldr-rgba-00.png,26.0222,0.1318,0.1150,0.5699\n-Small,8x8,ldr-rgba-01.png,28.2807,0.0639,0.0474,1.3840\n-Small,8x8,ldr-rgba-02.png,23.8775,0.1043,0.0878,0.7467\n-Small,8x8,ldr-xy-00.png,33.9706,0.0504,0.0340,1.9267\n-Small,8x8,ldr-xy-01.png,35.0076,0.0490,0.0330,1.9843\n-Small,8x8,ldr-xy-02.png,40.7561,0.0276,0.0116,5.6736\n-Small,8x8,ldrs-rgba-00.png,26.0229,0.1374,0.1203,0.5449\n-Small,8x8,ldrs-rgba-01.png,28.2841,0.0637,0.0468,1.4018\n-Small,8x8,ldrs-rgba-02.png,23.8771,0.1029,0.0866,0.7568\n-Small,12x12,hdr-rgb-00.hdr,18.7253,0.2096,0.0942,0.6960\n-Small,12x12,ldr-rgb-00.png,24.4659,0.1173,0.0907,0.7227\n-Small,12x12,ldr-rgb-01.png,24.9925,0.1119,0.0858,0.7638\n-Small,12x12,ldr-rgb-02.png,19.2481,0.1289,0.1018,0.6437\n-Small,12x12,ldr-rgb-03.png,34.6525,0.0432,0.0168,3.9026\n-Small,12x12,ldr-rgb-04.png,24.8440,0.1079,0.0811,0.8082\n-Small,12x12,ldr-rgb-05.png,21.5754,0.1530,0.1260,0.5202\n-Small,12x12,ldr-rgb-06.png,19.1991,0.1286,0.1015,0.6456\n-Small,12x12,ldr-rgb-07.png,26.5936,0.1054,0.0787,0.8325\n-Small,12x12,ldr-rgb-08.png,31.1465,0.0557,0.0286,2.2933\n-Small,12x12,ldr-rgb-09.png,24.2324,0.1102,0.0831,0.7882\n-Small,12x12,ldr-rgb-10.png,27.8888,0.0407,0.0161,1.0126\n-Small,12x12,ldr-rgba-00.png,21.7589,0.1261,0.0990,0.6623\n-Small,12x12,ldr-rgba-01.png,24.5625,0.0741,0.0473,1.3855\n-Small,12x12,ldr-rgba-02.png,20.1486,0.1162,0.0893,0.7341\n-Small,12x12,ldr-xy-00.png,29.7046,0.0604,0.0335,1.9547\n-Small,12x12,ldr-xy-01.png,31.9137,0.0529,0.0268,2.4419\n-Small,12x12,ldr-xy-02.png,38.1657,0.0305,0.0042,15.4713\n-Small,12x12,ldrs-rgba-00.png,21.7593,0.1237,0.0973,0.6736\n-Small,12x12,ldrs-rgba-01.png,24.5645,0.0729,0.0463,1.4152\n-Small,12x12,ldrs-rgba-02.png,20.1484,0.1128,0.0861,0.7609\n-Small,3x3x3,ldr-l-00-3.dds,51.8519,0.0453,0.0360,7.2733\n-Small,3x3x3,ldr-l-01-3.dds,54.3882,0.0181,0.0108,6.3774\n-Small,6x6x6,ldr-l-00-3.dds,32.9180,0.1038,0.0732,3.5802\n-Small,6x6x6,ldr-l-01-3.dds,40.8335,0.0491,0.0212,3.2509\n" }, { "change_type": "DELETE", "old_path": "Test/Images/Small/astc_reference-2.4-avx2_thorough_results.csv", "new_path": null, "diff": "-Image Set,Block Size,Name,PSNR,Total Time,Coding Time,Coding Rate\n-Small,4x4,hdr-rgb-00.hdr,32.6257,0.2486,0.1506,0.4353\n-Small,4x4,ldr-rgb-00.png,39.1011,0.1620,0.1526,0.4296\n-Small,4x4,ldr-rgb-01.png,40.2753,0.1549,0.1457,0.4497\n-Small,4x4,ldr-rgb-02.png,35.3312,0.1392,0.1304,0.5024\n-Small,4x4,ldr-rgb-03.png,47.6552,0.1620,0.1538,0.4260\n-Small,4x4,ldr-rgb-04.png,42.2447,0.1379,0.1291,0.5078\n-Small,4x4,ldr-rgb-05.png,37.9471,0.1529,0.1442,0.4545\n-Small,4x4,ldr-rgb-06.png,35.4333,0.1309,0.1222,0.5364\n-Small,4x4,ldr-rgb-07.png,39.6965,0.1756,0.1663,0.3940\n-Small,4x4,ldr-rgb-08.png,45.6560,0.1710,0.1621,0.4042\n-Small,4x4,ldr-rgb-09.png,42.1582,0.1542,0.1455,0.4504\n-Small,4x4,ldr-rgb-10.png,44.9944,0.0307,0.0245,0.6630\n-Small,4x4,ldr-rgba-00.png,36.7422,0.1763,0.1671,0.3921\n-Small,4x4,ldr-rgba-01.png,39.0115,0.1554,0.1466,0.4471\n-Small,4x4,ldr-rgba-02.png,34.9453,0.1737,0.1648,0.3977\n-Small,4x4,ldr-xy-00.png,37.7350,0.1405,0.1320,0.4963\n-Small,4x4,ldr-xy-01.png,45.4829,0.1373,0.1289,0.5084\n-Small,4x4,ldr-xy-02.png,51.0007,0.1679,0.1593,0.4115\n-Small,4x4,ldrs-rgba-00.png,36.7505,0.1765,0.1673,0.3918\n-Small,4x4,ldrs-rgba-01.png,39.0325,0.1535,0.1448,0.4527\n-Small,4x4,ldrs-rgba-02.png,34.9504,0.1646,0.1558,0.4206\n-Small,5x5,hdr-rgb-00.hdr,27.4762,0.2610,0.1614,0.4061\n-Small,5x5,ldr-rgb-00.png,35.3221,0.1762,0.1662,0.3944\n-Small,5x5,ldr-rgb-01.png,36.4859,0.1667,0.1568,0.4180\n-Small,5x5,ldr-rgb-02.png,31.1011,0.1537,0.1441,0.4548\n-Small,5x5,ldr-rgb-03.png,44.4621,0.1680,0.1586,0.4131\n-Small,5x5,ldr-rgb-04.png,37.7979,0.1469,0.1370,0.4782\n-Small,5x5,ldr-rgb-05.png,33.6558,0.1664,0.1563,0.4194\n-Small,5x5,ldr-rgb-06.png,31.0952,0.1467,0.1367,0.4793\n-Small,5x5,ldr-rgb-07.png,36.5891,0.1885,0.1782,0.3677\n-Small,5x5,ldr-rgb-08.png,42.2366,0.1589,0.1492,0.4392\n-Small,5x5,ldr-rgb-09.png,37.6643,0.1553,0.1456,0.4501\n-Small,5x5,ldr-rgb-10.png,40.7404,0.0323,0.0246,0.6612\n-Small,5x5,ldr-rgba-00.png,33.1224,0.1859,0.1759,0.3726\n-Small,5x5,ldr-rgba-01.png,35.3488,0.1624,0.1523,0.4302\n-Small,5x5,ldr-rgba-02.png,31.1475,0.1959,0.1860,0.3523\n-Small,5x5,ldr-xy-00.png,37.2677,0.1296,0.1197,0.5476\n-Small,5x5,ldr-xy-01.png,41.7309,0.1609,0.1515,0.4327\n-Small,5x5,ldr-xy-02.png,49.2472,0.1812,0.1711,0.3830\n-Small,5x5,ldrs-rgba-00.png,33.1249,0.1860,0.1758,0.3727\n-Small,5x5,ldrs-rgba-01.png,35.3573,0.1648,0.1545,0.4241\n-Small,5x5,ldrs-rgba-02.png,31.1476,0.1999,0.1896,0.3457\n-Small,6x6,hdr-rgb-00.hdr,24.8349,0.2520,0.1495,0.4384\n-Small,6x6,ldr-rgb-00.png,32.6463,0.2078,0.1949,0.3362\n-Small,6x6,ldr-rgb-01.png,33.1760,0.2068,0.1955,0.3352\n-Small,6x6,ldr-rgb-02.png,27.4903,0.2081,0.1966,0.3333\n-Small,6x6,ldr-rgb-03.png,42.5136,0.1510,0.1397,0.4692\n-Small,6x6,ldr-rgb-04.png,34.3341,0.3051,0.2933,0.2235\n-Small,6x6,ldr-rgb-05.png,30.2804,0.2984,0.2863,0.2289\n-Small,6x6,ldr-rgb-06.png,27.5520,0.2821,0.2681,0.2445\n-Small,6x6,ldr-rgb-07.png,34.3789,0.2577,0.2456,0.2668\n-Small,6x6,ldr-rgb-08.png,39.8926,0.1291,0.1170,0.5600\n-Small,6x6,ldr-rgb-09.png,33.8281,0.1961,0.1849,0.3544\n-Small,6x6,ldr-rgb-10.png,37.1218,0.0386,0.0297,0.5473\n-Small,6x6,ldr-rgba-00.png,30.4829,0.2233,0.2115,0.3098\n-Small,6x6,ldr-rgba-01.png,32.2487,0.1881,0.1760,0.3723\n-Small,6x6,ldr-rgba-02.png,27.8831,0.2725,0.2610,0.2511\n-Small,6x6,ldr-xy-00.png,36.3665,0.1213,0.1065,0.6156\n-Small,6x6,ldr-xy-01.png,38.4666,0.1908,0.1797,0.3647\n-Small,6x6,ldr-xy-02.png,47.4520,0.2240,0.2110,0.3106\n-Small,6x6,ldrs-rgba-00.png,30.4838,0.2174,0.2051,0.3196\n-Small,6x6,ldrs-rgba-01.png,32.2549,0.2003,0.1886,0.3474\n-Small,6x6,ldrs-rgba-02.png,27.8824,0.2877,0.2751,0.2382\n-Small,8x8,hdr-rgb-00.hdr,21.7370,0.3004,0.1882,0.3483\n-Small,8x8,ldr-rgb-00.png,28.9325,0.2344,0.2174,0.3015\n-Small,8x8,ldr-rgb-01.png,29.0009,0.2589,0.2413,0.2715\n-Small,8x8,ldr-rgb-02.png,23.1717,0.2889,0.2715,0.2414\n-Small,8x8,ldr-rgb-03.png,39.4327,0.0912,0.0710,0.9233\n-Small,8x8,ldr-rgb-04.png,29.7722,0.2645,0.2471,0.2652\n-Small,8x8,ldr-rgb-05.png,26.0309,0.3197,0.3020,0.2170\n-Small,8x8,ldr-rgb-06.png,23.2299,0.2544,0.2368,0.2767\n-Small,8x8,ldr-rgb-07.png,31.1331,0.2435,0.2251,0.2912\n-Small,8x8,ldr-rgb-08.png,36.4987,0.1505,0.1334,0.4914\n-Small,8x8,ldr-rgb-09.png,29.1978,0.1842,0.1672,0.3920\n-Small,8x8,ldr-rgb-10.png,32.3450,0.0469,0.0325,0.5004\n-Small,8x8,ldr-rgba-00.png,26.4881,0.2310,0.2139,0.3063\n-Small,8x8,ldr-rgba-01.png,28.3958,0.2071,0.1900,0.3449\n-Small,8x8,ldr-rgba-02.png,23.9557,0.2741,0.2566,0.2554\n-Small,8x8,ldr-xy-00.png,34.2722,0.1049,0.0880,0.7451\n-Small,8x8,ldr-xy-01.png,35.4903,0.1088,0.0923,0.7102\n-Small,8x8,ldr-xy-02.png,44.4205,0.1189,0.1013,0.6468\n-Small,8x8,ldrs-rgba-00.png,26.4899,0.2560,0.2387,0.2746\n-Small,8x8,ldrs-rgba-01.png,28.3990,0.2238,0.2064,0.3174\n-Small,8x8,ldrs-rgba-02.png,23.9552,0.2829,0.2647,0.2476\n-Small,12x12,hdr-rgb-00.hdr,18.8998,0.3521,0.2200,0.2979\n-Small,12x12,ldr-rgb-00.png,24.9028,0.3054,0.2764,0.2371\n-Small,12x12,ldr-rgb-01.png,25.1435,0.2791,0.2491,0.2631\n-Small,12x12,ldr-rgb-02.png,19.3029,0.3581,0.3299,0.1987\n-Small,12x12,ldr-rgb-03.png,36.1094,0.1190,0.0755,0.8679\n-Small,12x12,ldr-rgb-04.png,25.0031,0.2304,0.2028,0.3232\n-Small,12x12,ldr-rgb-05.png,21.7060,0.2655,0.2315,0.2831\n-Small,12x12,ldr-rgb-06.png,19.2656,0.2520,0.2242,0.2923\n-Small,12x12,ldr-rgb-07.png,27.0496,0.2375,0.2095,0.3129\n-Small,12x12,ldr-rgb-08.png,32.1972,0.1025,0.0750,0.8740\n-Small,12x12,ldr-rgb-09.png,24.4312,0.2078,0.1804,0.3633\n-Small,12x12,ldr-rgb-10.png,28.1634,0.0606,0.0354,0.4587\n-Small,12x12,ldr-rgba-00.png,22.2648,0.2503,0.2222,0.2949\n-Small,12x12,ldr-rgba-01.png,24.6914,0.1865,0.1577,0.4157\n-Small,12x12,ldr-rgba-02.png,20.2045,0.2039,0.1761,0.3722\n-Small,12x12,ldr-xy-00.png,30.4261,0.1287,0.1013,0.6471\n-Small,12x12,ldr-xy-01.png,32.4701,0.0948,0.0672,0.9751\n-Small,12x12,ldr-xy-02.png,39.8495,0.0639,0.0364,1.8004\n-Small,12x12,ldrs-rgba-00.png,22.2650,0.2509,0.2227,0.2943\n-Small,12x12,ldrs-rgba-01.png,24.6931,0.1837,0.1558,0.4206\n-Small,12x12,ldrs-rgba-02.png,20.2044,0.2011,0.1734,0.3780\n-Small,3x3x3,ldr-l-00-3.dds,52.4074,0.0967,0.0874,2.9996\n-Small,3x3x3,ldr-l-01-3.dds,55.4199,0.0423,0.0349,1.9749\n-Small,6x6x6,ldr-l-00-3.dds,33.2677,0.1558,0.1259,2.0821\n-Small,6x6x6,ldr-l-01-3.dds,41.7102,0.0597,0.0319,2.1621\n" }, { "change_type": "MODIFY", "old_path": "Test/astc_test_image.py", "new_path": "Test/astc_test_image.py", "diff": "@@ -41,17 +41,10 @@ import testlib.encoder as te\nimport testlib.testset as tts\nimport testlib.resultset as trs\n-# Some behavior is CPU specific (precision of frcp is implementation-defined)\n-# so only require very tight thresholds on the reference test machine. Other\n-# machines must pass within 0.1dB of the reference scores.\n-if \"BSE2NGQ\" in platform.node():\n- RESULT_THRESHOLD_WARN = -0.01\n- RESULT_THRESHOLD_FAIL = -0.05\n- RESULT_THRESHOLD_3D_FAIL = -0.02\n-else:\n- RESULT_THRESHOLD_WARN = -0.05\n- RESULT_THRESHOLD_FAIL = -0.1\n- RESULT_THRESHOLD_3D_FAIL = -0.1\n+# Require bit exact with reference scores\n+RESULT_THRESHOLD_WARN = -0.00\n+RESULT_THRESHOLD_FAIL = -0.00\n+RESULT_THRESHOLD_3D_FAIL = -0.00\nTEST_BLOCK_SIZES = [\"4x4\", \"5x5\", \"6x6\", \"8x8\", \"12x12\",\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Use vector versions of working pixel conversions (#230) Replace conversions between storage types (unorm16, LNS16), decode types(float16), and codec types (float), with vectorized versions of the same algorithms.
61,745
02.03.2021 22:09:26
0
1d24b684022d75ad3f2bed3233a999959bf78ea4
Use nearbyint to get bankers rounding
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_none_4.h", "new_path": "Source/astcenc_vecmathlib_none_4.h", "diff": "@@ -1041,10 +1041,10 @@ ASTCENC_SIMD_INLINE vfloat4 abs(vfloat4 a)\n*/\nASTCENC_SIMD_INLINE vfloat4 round(vfloat4 a)\n{\n- return vfloat4(std::round(a.m[0]),\n- std::round(a.m[1]),\n- std::round(a.m[2]),\n- std::round(a.m[3]));\n+ return vfloat4(std::nearbyint(a.m[0]),\n+ std::nearbyint(a.m[1]),\n+ std::nearbyint(a.m[2]),\n+ std::nearbyint(a.m[3]));\n}\n/**\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Use nearbyint to get bankers rounding
61,745
02.03.2021 22:20:55
0
0dc660eaf5b2c1f5b5dfcee82e031575e162e8fd
Add bankers rounding unit test
[ { "change_type": "MODIFY", "old_path": "Source/UnitTest/test_simd.cpp", "new_path": "Source/UnitTest/test_simd.cpp", "diff": "@@ -742,9 +742,10 @@ TEST(vfloat4, round)\nEXPECT_EQ(r1.lane<2>(), 2.0f);\nEXPECT_EQ(r1.lane<3>(), 4.0f);\n- vfloat4 a2(-3.5f);\n+ vfloat4 a2(-2.5f, -2.5f, -3.5f, -3.5f);\nvfloat4 r2 = round(a2);\n- EXPECT_EQ(r2.lane<0>(), -4.0f);\n+ EXPECT_EQ(r2.lane<0>(), -2.0f);\n+ EXPECT_EQ(r2.lane<2>(), -4.0f);\n}\n/** @brief Test vfloat4 hmin. */\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add bankers rounding unit test
61,745
02.03.2021 22:21:10
0
6dce35d7cb52f66d954896c8703ef031c3aab2b7
Remove redundant select
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_weight_align.cpp", "new_path": "Source/astcenc_weight_align.cpp", "diff": "@@ -196,7 +196,6 @@ static void compute_lowest_and_highest_weight(\n// Accumulate on min hit\nmask = idxv == minidx;\n- minidx = select(minidx, idxv, mask);\nvfloat accum = cut_low_weight_err + wt - vfloat(2.0f) * dwt;\ncut_low_weight_err = select(cut_low_weight_err, accum, mask);\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Remove redundant select
61,745
02.03.2021 23:37:21
0
985cec051786cf85de9f946e1e2f940894504ad4
Inline block initialization for decompression
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_decompress_symbolic.cpp", "new_path": "Source/astcenc_decompress_symbolic.cpp", "diff": "@@ -39,7 +39,7 @@ static int compute_value_of_texel_int(\nreturn summed_value >> 4;\n}\n-static vfloat4 lerp_color_int(\n+static vint4 lerp_color_int(\nastcenc_profile decode_mode,\nvint4 color0,\nvint4 color1,\n@@ -64,7 +64,30 @@ static vfloat4 lerp_color_int(\ncolor = color * vint4(257);\n}\n- return int_to_float(color);\n+ return color;\n+}\n+\n+// Turn packed unorm16 or LNS data into generic float data\n+static inline vfloat4 decode_texel(\n+ vint4 data,\n+ vmask4 lns_mask\n+) {\n+ vint4 color_lns = vint4::zero();\n+ vint4 color_unorm = vint4::zero();\n+\n+ if (any(lns_mask))\n+ {\n+ color_lns = lns_to_sf16(data);\n+ }\n+\n+ if (!all(lns_mask))\n+ {\n+ color_unorm = unorm16_to_sf16(data);\n+ }\n+\n+ // Pick channels and then covert to FP16\n+ vint4 datai = select(color_unorm, color_lns, lns_mask);\n+ return float16_to_float(datai);\n}\nvoid decompress_symbolic_block(\n@@ -80,6 +103,10 @@ void decompress_symbolic_block(\nblk->ypos = ypos;\nblk->zpos = zpos;\n+ blk->data_min = vfloat4::zero();\n+ blk->data_max = vfloat4::zero();\n+ blk->grayscale = false;\n+\n// if we detected an error-block, blow up immediately.\nif (scb->error_block)\n{\n@@ -248,31 +275,35 @@ void decompress_symbolic_block(\nint plane2_color_component = is_dual_plane ? scb->plane2_color_component : -1;\nvmask4 plane2_mask = vint4::lane_id() == vint4(plane2_color_component);\n- for (int i = 0; i < bsd->texel_count; i++)\n+ for (int i = 0; i < partition_count; i++)\n{\n- int partition = pt->partition_of_texel[i];\n-\n- vint4 ep0 = color_endpoint0[partition];\n- vint4 ep1 = color_endpoint1[partition];\n-\n- vfloat4 color = lerp_color_int(decode_mode,\n+ vint4 ep0 = color_endpoint0[i];\n+ vint4 ep1 = color_endpoint1[i];\n+ bool rgb_lns = rgb_hdr_endpoint[i];\n+ bool nan = nan_endpoint[i];\n+ bool a_lns = alpha_hdr_endpoint[i];\n+ vmask4 lns_mask(rgb_lns, rgb_lns, rgb_lns, a_lns);\n+\n+ int texel_count = pt->partition_texel_count[i];\n+ for (int j = 0; j < texel_count; j++)\n+ {\n+ int tix = pt->texels_of_partition[i][j];\n+ vint4 color = lerp_color_int(decode_mode,\nep0,\nep1,\n- weights[i],\n- plane2_weights[i],\n+ weights[tix],\n+ plane2_weights[tix],\nplane2_mask);\n- blk->rgb_lns[i] = rgb_hdr_endpoint[partition];\n- blk->alpha_lns[i] = alpha_hdr_endpoint[partition];\n- blk->nan_texel[i] = nan_endpoint[partition];\n+ vfloat4 colorf = decode_texel(color, lns_mask);\n- blk->data_r[i] = color.lane<0>();\n- blk->data_g[i] = color.lane<1>();\n- blk->data_b[i] = color.lane<2>();\n- blk->data_a[i] = color.lane<3>();\n+ blk->nan_texel[tix] = nan;\n+ blk->data_r[tix] = colorf.lane<0>();\n+ blk->data_g[tix] = colorf.lane<1>();\n+ blk->data_b[tix] = colorf.lane<2>();\n+ blk->data_a[tix] = colorf.lane<3>();\n+ }\n}\n-\n- imageblock_initialize_orig_from_work(blk, bsd->texel_count);\n}\nfloat compute_symbolic_block_difference(\n@@ -381,24 +412,22 @@ float compute_symbolic_block_difference(\nvint4 ep0 = color_endpoint0[partition];\nvint4 ep1 = color_endpoint1[partition];\n- vfloat4 color = lerp_color_int(decode_mode,\n+ vint4 colori = lerp_color_int(decode_mode,\nep0,\nep1,\nweights[i],\nplane2_weights[i],\nplane2_mask);\n+ vfloat4 color = int_to_float(colori);\nvfloat4 oldColor = blk->texel(i);\nvfloat4 error = oldColor - color;\n-\nerror = min(abs(error), 1e15f);\nerror = error * error;\n- vfloat4 errorWeight = ewb->error_weights[i];\n-\n- float metric = dot_s(error, errorWeight);\n- summa += astc::clamp(metric, 0.0f, 1e30f);\n+ float metric = dot_s(error, ewb->error_weights[i]);\n+ summa += astc::min(metric, 1e30f);\n}\nreturn summa;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_image.cpp", "new_path": "Source/astcenc_image.cpp", "diff": "@@ -121,64 +121,6 @@ static void imageblock_initialize_work_from_orig(\nblk->grayscale = grayscale;\n}\n-// helper function to initialize the orig-data from the work-data\n-void imageblock_initialize_orig_from_work(\n- imageblock* blk,\n- int pixelcount\n-) {\n- vfloat4 data_min(1e38f);\n- vfloat4 data_max(-1e38f);\n- bool grayscale = true;\n-\n- for (int i = 0; i < pixelcount; i++)\n- {\n- vfloat4 data = blk->texel(i);\n-\n- vint4 color_lns = vint4::zero();\n- vint4 color_unorm = vint4::zero();\n-\n- // TODO: Pack these into bits and avoid the disjoint fetch\n- int rgb_lns = blk->rgb_lns[i];\n- int a_lns = blk->alpha_lns[i];\n-\n- if (rgb_lns || a_lns)\n- {\n- color_lns = lns_to_sf16(float_to_int(data));\n- }\n-\n- if ((!rgb_lns) || (!a_lns))\n- {\n- color_unorm = unorm16_to_sf16(float_to_int(data));\n- }\n-\n- // Pick channels and then covert to FP16\n- vint4 use_lns(rgb_lns, rgb_lns, rgb_lns, a_lns);\n- vmask4 lns_mask = use_lns != vint4::zero();\n- vint4 datai = select(color_unorm, color_lns, lns_mask);\n- data = float16_to_float(datai);\n-\n- // Compute block metadata\n- data_min = min(data_min, data);\n- data_max = max(data_max, data);\n-\n- if (grayscale && (data.lane<0>() != data.lane<1>() || data.lane<0>() != data.lane<2>()))\n- {\n- grayscale = false;\n- }\n-\n- // Store block data\n- blk->data_r[i] = data.lane<0>();\n- blk->data_g[i] = data.lane<1>();\n- blk->data_b[i] = data.lane<2>();\n- blk->data_a[i] = data.lane<3>();\n- }\n-\n- // Store block metadata\n- blk->data_min = data_min;\n- blk->data_max = data_max;\n- blk->grayscale = grayscale;\n-}\n-\n// fetch an imageblock from the input file.\nvoid fetch_imageblock(\nastcenc_profile decode_mode,\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -575,10 +575,6 @@ static inline int imageblock_is_lumalp(const imageblock * blk)\nreturn blk->grayscale && !alpha1;\n}\n-void imageblock_initialize_orig_from_work(\n- imageblock * blk,\n- int pixelcount);\n-\n/*\nData structure representing error weighting for one block of an image. this is used as\na multiplier for the error weight to apply to each color component when computing PSNR.\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Inline block initialization for decompression
61,745
03.03.2021 00:19:17
0
ecef2d20446613caf0d4ebc7c7a3fd03bfb6b470
Cleanup write_imageblock
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_image.cpp", "new_path": "Source/astcenc_image.cpp", "diff": "@@ -317,6 +317,17 @@ void write_imageblock(\nint ysize = img.dim_y;\nint zsize = img.dim_z;\n+ int x_start = xpos;\n+ int x_end = std::min(xsize, xpos + bsd->xdim);\n+ int x_nudge = bsd->xdim - (x_end - x_start);\n+\n+ int y_start = ypos;\n+ int y_end = std::min(ysize, ypos + bsd->ydim);\n+ int y_nudge = (bsd->ydim - (y_end - y_start)) * bsd->xdim;\n+\n+ int z_start = zpos;\n+ int z_end = std::min(zsize, zpos + bsd->zdim);\n+\nfloat data[7];\ndata[ASTCENC_SWZ_0] = 0.0f;\ndata[ASTCENC_SWZ_1] = 1.0f;\n@@ -332,30 +343,21 @@ void write_imageblock(\nint idx = 0;\nif (img.data_type == ASTCENC_TYPE_U8)\n{\n- for (int z = 0; z < bsd->zdim; z++)\n+ for (int z = z_start; z < z_end; z++)\n{\n- int zc = astc::min(zpos + z, zsize - 1);\n- uint8_t* data8 = static_cast<uint8_t*>(img.data[zc]);\n+ // Fetch the image plane\n+ uint8_t* data8 = static_cast<uint8_t*>(img.data[z]);\n- for (int y = 0; y < bsd->ydim; y++)\n- {\n- for (int x = 0; x < bsd->xdim; x++)\n+ for (int y = y_start; y < y_end; y++)\n{\n- int xi = xpos + x;\n- int yi = ypos + y;\n- int zi = zpos + z;\n-\n- if (xi >= 0 && yi >= 0 && zi >= 0 && xi < xsize && yi < ysize && zi < zsize)\n+ for (int x = x_start; x < x_end; x++)\n{\n- int ri, gi, bi, ai;\n+ vint4 colori = vint4::zero();\nif (*nptr)\n{\n- // NaN-pixel, but we can't display it. Display purple instead.\n- ri = 0xFF;\n- gi = 0x00;\n- bi = 0xFF;\n- ai = 0xFF;\n+ // Can't display NaN - show magenta error color\n+ colori = vint4(0xFF, 0x00, 0xFF, 0xFF);\n}\nelse if (needs_swz)\n{\n@@ -376,46 +378,38 @@ void write_imageblock(\ndata[ASTCENC_SWZ_Z] = (astc::sqrt(zcoord) * 0.5f) + 0.5f;\n}\n- ri = astc::flt2int_rtn(astc::min(data[swz.r], 1.0f) * 255.0f);\n- gi = astc::flt2int_rtn(astc::min(data[swz.g], 1.0f) * 255.0f);\n- bi = astc::flt2int_rtn(astc::min(data[swz.b], 1.0f) * 255.0f);\n- ai = astc::flt2int_rtn(astc::min(data[swz.a], 1.0f) * 255.0f);\n+ vfloat4 color = vfloat4(data[swz.r], data[swz.g], data[swz.b], data[swz.a]);\n+ colori = float_to_int_rtn(min(color, 1.0f) * 255.0f);\n}\nelse\n{\n- ri = astc::flt2int_rtn(astc::min(blk->data_r[idx], 1.0f) * 255.0f);\n- gi = astc::flt2int_rtn(astc::min(blk->data_g[idx], 1.0f) * 255.0f);\n- bi = astc::flt2int_rtn(astc::min(blk->data_b[idx], 1.0f) * 255.0f);\n- ai = astc::flt2int_rtn(astc::min(blk->data_a[idx], 1.0f) * 255.0f);\n+ vfloat4 color = blk->texel(idx);\n+ colori = float_to_int_rtn(min(color, 1.0f) * 255.0f);\n}\n- data8[(4 * xsize * yi) + (4 * xi )] = ri;\n- data8[(4 * xsize * yi) + (4 * xi + 1)] = gi;\n- data8[(4 * xsize * yi) + (4 * xi + 2)] = bi;\n- data8[(4 * xsize * yi) + (4 * xi + 3)] = ai;\n- }\n+ colori = pack_low_bytes(colori);\n+ store_nbytes(colori, data8 + (4 * xsize * y) + (4 * x ));\n+\nidx++;\nnptr++;\n}\n+ idx += x_nudge;\n+ nptr += x_nudge;\n}\n+ idx += y_nudge;\n+ nptr += y_nudge;\n}\n}\nelse if (img.data_type == ASTCENC_TYPE_F16)\n{\n- for (int z = 0; z < bsd->zdim; z++)\n+ for (int z = z_start; z < z_end; z++)\n{\n- int zc = astc::min(zpos + z, zsize - 1);\n- uint16_t* data16 = static_cast<uint16_t*>(img.data[zc]);\n+ // Fetch the image plane\n+ uint16_t* data16 = static_cast<uint16_t*>(img.data[z]);\n- for (int y = 0; y < bsd->ydim; y++)\n+ for (int y = y_start; y < y_end; y++)\n{\n- for (int x = 0; x < bsd->xdim; x++)\n- {\n- int xi = xpos + x;\n- int yi = ypos + y;\n- int zi = zpos + z;\n-\n- if (xi >= 0 && yi >= 0 && zi >= 0 && xi < xsize && yi < ysize && zi < zsize)\n+ for (int x = x_start; x < x_end; x++)\n{\nvint4 color;\n@@ -451,51 +445,46 @@ void write_imageblock(\ncolor = float_to_float16(colorf);\n}\n- data16[(4 * xsize * yi) + (4 * xi )] = (uint16_t)color.lane<0>();\n- data16[(4 * xsize * yi) + (4 * xi + 1)] = (uint16_t)color.lane<1>();\n- data16[(4 * xsize * yi) + (4 * xi + 2)] = (uint16_t)color.lane<2>();\n- data16[(4 * xsize * yi) + (4 * xi + 3)] = (uint16_t)color.lane<3>();\n- }\n+ data16[(4 * xsize * y) + (4 * x )] = (uint16_t)color.lane<0>();\n+ data16[(4 * xsize * y) + (4 * x + 1)] = (uint16_t)color.lane<1>();\n+ data16[(4 * xsize * y) + (4 * x + 2)] = (uint16_t)color.lane<2>();\n+ data16[(4 * xsize * y) + (4 * x + 3)] = (uint16_t)color.lane<3>();\n+\nidx++;\nnptr++;\n}\n+ idx += x_nudge;\n+ nptr += x_nudge;\n}\n+ idx += y_nudge;\n+ nptr += y_nudge;\n}\n}\nelse // if (img.data_type == ASTCENC_TYPE_F32)\n{\nassert(img.data_type == ASTCENC_TYPE_F32);\n- for (int z = 0; z < bsd->zdim; z++)\n+ for (int z = z_start; z < z_end; z++)\n{\n- int zc = astc::min(zpos + z, zsize - 1);\n- float* data32 = static_cast<float*>(img.data[zc]);\n+ // Fetch the image plane\n+ float* data32 = static_cast<float*>(img.data[z]);\n- for (int y = 0; y < bsd->ydim; y++)\n- {\n- for (int x = 0; x < bsd->xdim; x++)\n+ for (int y = y_start; y < y_end; y++)\n{\n- int xi = xpos + x;\n- int yi = ypos + y;\n- int zi = zpos + z;\n-\n- if (xi >= 0 && yi >= 0 && zi >= 0 && xi < xsize && yi < ysize && zi < zsize)\n+ for (int x = x_start; x < x_end; x++)\n{\n- float rf, gf, bf, af;\n+ vfloat4 color = blk->texel(idx);\nif (*nptr)\n{\n- rf = std::numeric_limits<float>::quiet_NaN();\n- gf = std::numeric_limits<float>::quiet_NaN();\n- bf = std::numeric_limits<float>::quiet_NaN();\n- af = std::numeric_limits<float>::quiet_NaN();\n+ color = vfloat4(std::numeric_limits<float>::quiet_NaN());\n}\nelse if (needs_swz)\n{\n- data[ASTCENC_SWZ_R] = blk->data_r[idx];\n- data[ASTCENC_SWZ_G] = blk->data_g[idx];\n- data[ASTCENC_SWZ_B] = blk->data_b[idx];\n- data[ASTCENC_SWZ_A] = blk->data_a[idx];\n+ data[ASTCENC_SWZ_R] = color.lane<0>();\n+ data[ASTCENC_SWZ_G] = color.lane<1>();\n+ data[ASTCENC_SWZ_B] = color.lane<2>();\n+ data[ASTCENC_SWZ_A] = color.lane<3>();\nif (needs_z)\n{\n@@ -509,28 +498,19 @@ void write_imageblock(\ndata[ASTCENC_SWZ_Z] = (astc::sqrt(zN) * 0.5f) + 0.5f;\n}\n- rf = data[swz.r];\n- gf = data[swz.g];\n- bf = data[swz.b];\n- af = data[swz.a];\n- }\n- else\n- {\n- rf = blk->data_r[idx];\n- gf = blk->data_g[idx];\n- bf = blk->data_b[idx];\n- af = blk->data_a[idx];\n+ color = vfloat4(data[swz.r], data[swz.g], data[swz.b], data[swz.a]);\n}\n- data32[(4 * xsize * yi) + (4 * xi )] = rf;\n- data32[(4 * xsize * yi) + (4 * xi + 1)] = gf;\n- data32[(4 * xsize * yi) + (4 * xi + 2)] = bf;\n- data32[(4 * xsize * yi) + (4 * xi + 3)] = af;\n- }\n+ store(color, data32 + (4 * xsize * y) + (4 * x ));\n+\nidx++;\nnptr++;\n}\n+ idx += x_nudge;\n+ nptr += x_nudge;\n}\n+ idx += y_nudge;\n+ nptr += y_nudge;\n}\n}\n}\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Cleanup write_imageblock
61,745
03.03.2021 13:43:17
0
cea746f30631d9ee5755a21adf968d089efb3e19
Make public API C-only, and exportable
[ { "change_type": "MODIFY", "old_path": "Source/astcenc.h", "new_path": "Source/astcenc.h", "diff": "#include <cstddef>\n#include <cstdint>\n+#if defined(ASTCENC_DYNAMIC_LIBRARY)\n+ #if defined(_MSC_VER)\n+ #define ASTCENC_PUBLIC extern \"C\" __declspec(dllexport)\n+ #else\n+ #define ASTCENC_PUBLIC extern \"C\" __attribute__ ((visibility (\"default\")))\n+ #endif\n+#else\n+ #define ASTCENC_PUBLIC\n+#endif\n+\n/* ============================================================================\nData declarations\n============================================================================ */\n@@ -548,14 +558,14 @@ struct astcenc_image {\n* @return ASTCENC_SUCCESS on success, or an error if the inputs are invalid\n* either individually, or in combination.\n*/\n-astcenc_error astcenc_config_init(\n+ASTCENC_PUBLIC astcenc_error astcenc_config_init(\nastcenc_profile profile,\nunsigned int block_x,\nunsigned int block_y,\nunsigned int block_z,\nfloat quality,\nunsigned int flags,\n- astcenc_config& config);\n+ astcenc_config* config);\n/**\n* @brief Allocate a new codec context based on a config.\n@@ -578,8 +588,8 @@ astcenc_error astcenc_config_init(\n*\n* @return ASTCENC_SUCCESS on success, or an error if context creation failed.\n*/\n-astcenc_error astcenc_context_alloc(\n- const astcenc_config& config,\n+ASTCENC_PUBLIC astcenc_error astcenc_context_alloc(\n+ const astcenc_config* config,\nunsigned int thread_count,\nastcenc_context** context);\n@@ -601,9 +611,9 @@ astcenc_error astcenc_context_alloc(\n*\n* @return ASTCENC_SUCCESS on success, or an error if compression failed.\n*/\n-astcenc_error astcenc_compress_image(\n+ASTCENC_PUBLIC astcenc_error astcenc_compress_image(\nastcenc_context* context,\n- astcenc_image& image,\n+ astcenc_image* image,\nastcenc_swizzle swizzle,\nuint8_t* data_out,\nsize_t data_len,\n@@ -621,7 +631,7 @@ astcenc_error astcenc_compress_image(\n*\n* @return ASTCENC_SUCCESS on success, or an error if reset failed.\n*/\n-astcenc_error astcenc_compress_reset(\n+ASTCENC_PUBLIC astcenc_error astcenc_compress_reset(\nastcenc_context* context);\n/**\n@@ -635,11 +645,11 @@ astcenc_error astcenc_compress_reset(\n*\n* @return ASTCENC_SUCCESS on success, or an error if decompression failed.\n*/\n-astcenc_error astcenc_decompress_image(\n+ASTCENC_PUBLIC astcenc_error astcenc_decompress_image(\nastcenc_context* context,\nconst uint8_t* data,\nsize_t data_len,\n- astcenc_image& image_out,\n+ astcenc_image* image_out,\nastcenc_swizzle swizzle);\n/**\n@@ -647,7 +657,7 @@ astcenc_error astcenc_decompress_image(\n*\n* @param context The codec context.\n*/\n-void astcenc_context_free(\n+ASTCENC_PUBLIC void astcenc_context_free(\nastcenc_context* context);\n/**\n@@ -657,7 +667,7 @@ void astcenc_context_free(\n*\n* @return A human readable nul-terminated string.\n*/\n-const char* astcenc_get_error_string(\n+ASTCENC_PUBLIC const char* astcenc_get_error_string(\nastcenc_error status);\n#endif\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_entry.cpp", "new_path": "Source/astcenc_entry.cpp", "diff": "@@ -345,9 +345,10 @@ astcenc_error astcenc_config_init(\nunsigned int block_z,\nfloat quality,\nunsigned int flags,\n- astcenc_config& config\n+ astcenc_config* configp\n) {\nastcenc_error status;\n+ astcenc_config& config = *configp;\n// Zero init all config fields; although most of will be over written\nstd::memset(&config, 0, sizeof(config));\n@@ -402,8 +403,6 @@ astcenc_error astcenc_config_init(\nconfig.tune_db_limit = astc::max(preset_configs[start].tune_db_limit_a_base - 35 * ltexels,\npreset_configs[start].tune_db_limit_b_base - 19 * ltexels);\n- // Fast and loose - exit as soon as we get a block within the target.\n- // This costs an average of around 0.7 dB PSNR ...\nconfig.tune_mode0_mse_overshoot = preset_configs[start].tune_mode0_mse_overshoot;\nconfig.tune_refinement_mse_overshoot = preset_configs[start].tune_refinement_mse_overshoot;\n@@ -438,8 +437,6 @@ astcenc_error astcenc_config_init(\nconfig.tune_db_limit = astc::max(LERP(tune_db_limit_a_base) - 35 * ltexels,\nLERP(tune_db_limit_b_base) - 19 * ltexels);\n- // Fast and loose - exit as soon as we get a block within the target.\n- // This costs an average of around 0.7 dB PSNR ...\nconfig.tune_mode0_mse_overshoot = LERP(tune_mode0_mse_overshoot);\nconfig.tune_refinement_mse_overshoot = LERP(tune_refinement_mse_overshoot);\n@@ -556,13 +553,14 @@ astcenc_error astcenc_config_init(\n}\nastcenc_error astcenc_context_alloc(\n- astcenc_config const& config,\n+ const astcenc_config* configp,\nunsigned int thread_count,\nastcenc_context** context\n) {\nastcenc_error status;\nastcenc_context* ctx = nullptr;\nblock_size_descriptor* bsd = nullptr;\n+ const astcenc_config& config = *configp;\nstatus = validate_cpu_float();\nif (status != ASTCENC_SUCCESS)\n@@ -797,7 +795,7 @@ static void compress_image(\nastcenc_error astcenc_compress_image(\nastcenc_context* ctx,\n- astcenc_image& image,\n+ astcenc_image* imagep,\nastcenc_swizzle swizzle,\nuint8_t* data_out,\nsize_t data_len,\n@@ -805,7 +803,7 @@ astcenc_error astcenc_compress_image(\n) {\n#if defined(ASTCENC_DECOMPRESS_ONLY)\n(void)ctx;\n- (void)image;\n+ (void)imagep;\n(void)swizzle;\n(void)data_out;\n(void)data_len;\n@@ -813,6 +811,7 @@ astcenc_error astcenc_compress_image(\nreturn ASTCENC_ERR_BAD_CONTEXT;\n#else\nastcenc_error status;\n+ astcenc_image& image = *imagep;\nif (ctx->config.flags & ASTCENC_FLG_DECOMPRESS_ONLY)\n{\n@@ -919,10 +918,11 @@ astcenc_error astcenc_decompress_image(\nastcenc_context* context,\nconst uint8_t* data,\nsize_t data_len,\n- astcenc_image& image_out,\n+ astcenc_image* image_outp,\nastcenc_swizzle swizzle\n) {\nastcenc_error status;\n+ astcenc_image& image_out = *image_outp;\nstatus = validate_decompression_swizzle(swizzle);\nif (status != ASTCENC_SUCCESS)\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel.cpp", "new_path": "Source/astcenccli_toplevel.cpp", "diff": "@@ -152,7 +152,7 @@ static void compression_workload_runner(\ncompression_workload* work = static_cast<compression_workload*>(payload);\nastcenc_error error = astcenc_compress_image(\n- work->context, *work->image, work->swizzle,\n+ work->context, work->image, work->swizzle,\nwork->data_out, work->data_len, thread_id);\n// This is a racy update, so which error gets returned is a random, but it\n@@ -527,7 +527,7 @@ static int init_astcenc_config(\n#endif\nastcenc_error status = astcenc_config_init(profile, block_x, block_y, block_z,\n- quality, flags, config);\n+ quality, flags, &config);\nif (status == ASTCENC_ERR_BAD_BLOCK_SIZE)\n{\nprintf(\"ERROR: Block size '%s' is invalid\\n\", argv[4]);\n@@ -1388,7 +1388,7 @@ int main(\nastcenc_error codec_status;\nastcenc_context* codec_context;\n- codec_status = astcenc_context_alloc(config, cli_config.thread_count, &codec_context);\n+ codec_status = astcenc_context_alloc(&config, cli_config.thread_count, &codec_context);\nif (codec_status != ASTCENC_SUCCESS)\n{\nprintf(\"ERROR: Codec context alloc failed: %s\\n\", astcenc_get_error_string(codec_status));\n@@ -1499,7 +1499,7 @@ int main(\nelse\n{\nwork.error = astcenc_compress_image(\n- work.context, *work.image, work.swizzle,\n+ work.context, work.image, work.swizzle,\nwork.data_out, work.data_len, 0);\n}\n@@ -1534,7 +1534,7 @@ int main(\nout_bitness, image_comp.dim_x, image_comp.dim_y, image_comp.dim_z);\ncodec_status = astcenc_decompress_image(codec_context, image_comp.data, image_comp.data_len,\n- *image_decomp_out, cli_config.swz_decode);\n+ image_decomp_out, cli_config.swz_decode);\nif (codec_status != ASTCENC_SUCCESS)\n{\nprintf(\"ERROR: Codec decompress failed: %s\\n\", astcenc_get_error_string(codec_status));\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Make public API C-only, and exportable (#234)
61,745
03.03.2021 15:08:13
0
f1d73f3ad3db80573081c80d4eb021c23c1e35f7
Add multithreaded decompression
[ { "change_type": "MODIFY", "old_path": "Source/astcenc.h", "new_path": "Source/astcenc.h", "diff": "* allocate multiple contexts and assign each context to a thread.\n* * An application wishing to process a single image in using multiple\n* threads can configure the context for multi-threaded use, and invoke\n- * astcenc_compress() once per thread for faster compression. The caller\n- * is responsible for creating the worker threads. Note that\n- * decompression is always single-threaded.\n+ * astcenc_compress/decompress() once per thread for faster processing.\n+ * The caller is responsible for creating the worker threads, and\n+ * synchronizing between images.\n*\n* Threading\n* =========\n@@ -620,7 +620,7 @@ ASTCENC_PUBLIC astcenc_error astcenc_compress_image(\nunsigned int thread_index);\n/**\n- * @brief Reset the compressor state for a new compression.\n+ * @brief Reset the codec state for a new compression.\n*\n* The caller is responsible for synchronizing threads in the worker thread\n* pool. This function must only be called when all threads have exited the\n@@ -642,6 +642,7 @@ ASTCENC_PUBLIC astcenc_error astcenc_compress_reset(\n* @param data_len Length of the compressed data, in bytes.\n* @param[in,out] image_out Output image.\n* @param swizzle Decompression data swizzle.\n+ * @param thread_index Thread index [0..N-1] of calling thread.\n*\n* @return ASTCENC_SUCCESS on success, or an error if decompression failed.\n*/\n@@ -650,7 +651,23 @@ ASTCENC_PUBLIC astcenc_error astcenc_decompress_image(\nconst uint8_t* data,\nsize_t data_len,\nastcenc_image* image_out,\n- astcenc_swizzle swizzle);\n+ astcenc_swizzle swizzle,\n+ unsigned int thread_index);\n+\n+/**\n+ * @brief Reset the codec state for a new decompression.\n+ *\n+ * The caller is responsible for synchronizing threads in the worker thread\n+ * pool. This function must only be called when all threads have exited the\n+ * astcenc_decompress_image() function for image N, but before any thread\n+ * enters it for image N + 1.\n+ *\n+ * @param context Codec context.\n+ *\n+ * @return ASTCENC_SUCCESS on success, or an error if reset failed.\n+ */\n+ASTCENC_PUBLIC astcenc_error astcenc_decompress_reset(\n+ astcenc_context* context);\n/**\n* Free the compressor context.\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_entry.cpp", "new_path": "Source/astcenc_entry.cpp", "diff": "@@ -258,8 +258,7 @@ static astcenc_error validate_decompression_swizzle(\n* make no sense algorithmically will return an error.\n*/\nstatic astcenc_error validate_config(\n- astcenc_config &config,\n- unsigned int thread_count\n+ astcenc_config &config\n) {\nastcenc_error status;\n@@ -281,12 +280,6 @@ static astcenc_error validate_config(\nreturn status;\n}\n- // Decompress-only contexts must be single threaded\n- if ((config.flags & ASTCENC_FLG_DECOMPRESS_ONLY) && (thread_count > 1))\n- {\n- return ASTCENC_ERR_BAD_PARAM;\n- }\n-\n#if defined(ASTCENC_DECOMPRESS_ONLY)\n// Decompress-only builds only support decompress-only contexts\nif (!(config.flags & ASTCENC_FLG_DECOMPRESS_ONLY))\n@@ -598,7 +591,7 @@ astcenc_error astcenc_context_alloc(\nctx->input_alpha_averages = nullptr;\n// Copy the config first and validate the copy (we may modify it)\n- status = validate_config(ctx->config, thread_count);\n+ status = validate_config(ctx->config);\nif (status != ASTCENC_SUCCESS)\n{\ndelete ctx;\n@@ -688,15 +681,17 @@ static void compress_image(\nuint8_t* buffer\n) {\nconst block_size_descriptor *bsd = ctx.bsd;\n+ astcenc_profile decode_mode = ctx.config.profile;\n+ imageblock blk;\n+\nint block_x = bsd->xdim;\nint block_y = bsd->ydim;\nint block_z = bsd->zdim;\n- astcenc_profile decode_mode = ctx.config.profile;\n- imageblock blk;\nint dim_x = image.dim_x;\nint dim_y = image.dim_y;\nint dim_z = image.dim_z;\n+\nint xblocks = (dim_x + block_x - 1) / block_x;\nint yblocks = (dim_y + block_y - 1) / block_y;\nint zblocks = (dim_z + block_z - 1) / block_z;\n@@ -714,7 +709,11 @@ static void compress_image(\nwhile (true)\n{\nunsigned int count;\n- unsigned int base = ctx.manage_compress.get_task_assignment(4, count);\n+ // TODO: Task assignment has been tuned empirically as the current\n+ // approach is expensive. Consider using atomic tracker for task\n+ // assignment, not a mutex-managed tracker, at which point we can\n+ // reduce these down again.\n+ unsigned int base = ctx.manage_compress.get_task_assignment(64, count);\nif (!count)\n{\nbreak;\n@@ -915,29 +914,39 @@ astcenc_error astcenc_compress_reset(\n}\nastcenc_error astcenc_decompress_image(\n- astcenc_context* context,\n+ astcenc_context* ctx,\nconst uint8_t* data,\nsize_t data_len,\nastcenc_image* image_outp,\n- astcenc_swizzle swizzle\n+ astcenc_swizzle swizzle,\n+ unsigned int thread_index\n) {\nastcenc_error status;\nastcenc_image& image_out = *image_outp;\n+ // Today this doesn't matter (working set on stack) but might in future ...\n+ if (thread_index >= ctx->thread_count)\n+ {\n+ return ASTCENC_ERR_BAD_PARAM;\n+ }\n+\nstatus = validate_decompression_swizzle(swizzle);\nif (status != ASTCENC_SUCCESS)\n{\nreturn status;\n}\n- unsigned int block_x = context->config.block_x;\n- unsigned int block_y = context->config.block_y;\n- unsigned int block_z = context->config.block_z;\n+ unsigned int block_x = ctx->config.block_x;\n+ unsigned int block_y = ctx->config.block_y;\n+ unsigned int block_z = ctx->config.block_z;\nunsigned int xblocks = (image_out.dim_x + block_x - 1) / block_x;\nunsigned int yblocks = (image_out.dim_y + block_y - 1) / block_y;\nunsigned int zblocks = (image_out.dim_z + block_z - 1) / block_z;\n+ int row_blocks = xblocks;\n+ int plane_blocks = xblocks * yblocks;\n+\n// Check we have enough output space (16 bytes per block)\nsize_t size_needed = xblocks * yblocks * zblocks * 16;\nif (data_len < size_needed)\n@@ -947,29 +956,54 @@ astcenc_error astcenc_decompress_image(\nimageblock blk;\n- for (unsigned int z = 0; z < zblocks; z++)\n+ // Only the first thread actually runs the initializer\n+ ctx->manage_decompress.init(zblocks * yblocks * xblocks);\n+\n+ // All threads run this processing loop until there is no work remaining\n+ while (true)\n{\n- for (unsigned int y = 0; y < yblocks; y++)\n+ unsigned int count;\n+ // TODO: Task assignment has been tuned empirically as the current\n+ // approach is expensive. Consider using atomic tracker for task\n+ // assignment, not a mutex-managed tracker, at which point we can\n+ // reduce these down again.\n+ unsigned int base = ctx->manage_decompress.get_task_assignment(128, count);\n+ if (!count)\n{\n- for (unsigned int x = 0; x < xblocks; x++)\n+ break;\n+ }\n+\n+ for (unsigned int i = base; i < base + count; i++)\n{\n+ // Decode i into x, y, z block indices\n+ int z = i / plane_blocks;\n+ unsigned int rem = i - (z * plane_blocks);\n+ int y = rem / row_blocks;\n+ int x = rem - (y * row_blocks);\n+\nunsigned int offset = (((z * yblocks + y) * xblocks) + x) * 16;\nconst uint8_t* bp = data + offset;\nphysical_compressed_block pcb = *(const physical_compressed_block*)bp;\nsymbolic_compressed_block scb;\n- physical_to_symbolic(*context->bsd, pcb, scb);\n+ physical_to_symbolic(*ctx->bsd, pcb, scb);\n- decompress_symbolic_block(context->config.profile, context->bsd,\n+ decompress_symbolic_block(ctx->config.profile, ctx->bsd,\nx * block_x, y * block_y, z * block_z,\n&scb, &blk);\n- write_imageblock(image_out, &blk, context->bsd,\n+ write_imageblock(image_out, &blk, ctx->bsd,\nx * block_x, y * block_y, z * block_z, swizzle);\n}\n}\n+\n+ return ASTCENC_SUCCESS;\n}\n+astcenc_error astcenc_decompress_reset(\n+ astcenc_context* ctx\n+) {\n+ ctx->manage_decompress.reset();\nreturn ASTCENC_SUCCESS;\n}\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -1327,6 +1327,8 @@ struct astcenc_context\nParallelManager manage_compress;\n#endif\n+ ParallelManager manage_decompress;\n+\n#if defined(ASTCENC_DIAGNOSTICS)\nTraceLog* trace_log;\n#endif\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel.cpp", "new_path": "Source/astcenccli_toplevel.cpp", "diff": "@@ -116,6 +116,15 @@ struct compression_workload {\nastcenc_error error;\n};\n+struct decompression_workload {\n+ astcenc_context* context;\n+ uint8_t* data;\n+ size_t data_len;\n+ astcenc_image* image_out;\n+ astcenc_swizzle swizzle;\n+ astcenc_error error;\n+};\n+\n/**\n* @brief Test if a string argument is a well formed float.\n*/\n@@ -163,6 +172,26 @@ static void compression_workload_runner(\n}\n}\n+static void decompression_workload_runner(\n+ int thread_count,\n+ int thread_id,\n+ void* payload\n+) {\n+ (void)thread_count;\n+\n+ decompression_workload* work = static_cast<decompression_workload*>(payload);\n+ astcenc_error error = astcenc_decompress_image(\n+ work->context, work->data, work->data_len,\n+ work->image_out, work->swizzle, thread_id);\n+\n+ // This is a racy update, so which error gets returned is a random, but it\n+ // will reliably report an error if an error occurs\n+ if (error != ASTCENC_SUCCESS)\n+ {\n+ work->error = error;\n+ }\n+}\n+\n/**\n* @brief Utility to generate a slice file name from a pattern.\n*\n@@ -960,16 +989,10 @@ static int edit_astcenc_config(\ncli_config.thread_count = get_cpu_count();\n}\n-#if defined(ASTCENC_DECOMPRESS_ONLY) || defined(ASTCENC_DIAGNOSTICS)\n- cli_config.thread_count = 1;\n-#else\n- if (operation == ASTCENC_OP_DECOMPRESS)\n- {\n+#if defined(ASTCENC_DIAGNOSTICS)\n+ // Force single threaded for diagnostic builds\ncli_config.thread_count = 1;\n- }\n-#endif\n-#if defined(ASTCENC_DIAGNOSTICS)\nif (!config.trace_file_path)\n{\nprintf(\"ERROR: Diagnostics builds must set -dtrace-out\\n\");\n@@ -1533,9 +1556,28 @@ int main(\nimage_decomp_out = alloc_image(\nout_bitness, image_comp.dim_x, image_comp.dim_y, image_comp.dim_z);\n- codec_status = astcenc_decompress_image(codec_context, image_comp.data, image_comp.data_len,\n- image_decomp_out, cli_config.swz_decode);\n- if (codec_status != ASTCENC_SUCCESS)\n+ decompression_workload work;\n+ work.context = codec_context;\n+ work.data = image_comp.data;\n+ work.data_len = image_comp.data_len;\n+ work.image_out = image_decomp_out;\n+ work.swizzle = cli_config.swz_decode;\n+ work.error = ASTCENC_SUCCESS;\n+\n+ // Only launch worker threads for multi-threaded use - it makes basic\n+ // single-threaded profiling and debugging a little less convoluted\n+ if (cli_config.thread_count > 1)\n+ {\n+ launch_threads(cli_config.thread_count, decompression_workload_runner, &work);\n+ }\n+ else\n+ {\n+ work.error = astcenc_decompress_image(\n+ work.context, work.data, work.data_len,\n+ work.image_out, work.swizzle, 0);\n+ }\n+\n+ if (work.error != ASTCENC_SUCCESS)\n{\nprintf(\"ERROR: Codec decompress failed: %s\\n\", astcenc_get_error_string(codec_status));\nreturn 1;\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add multithreaded decompression
61,745
03.03.2021 15:32:37
0
22096645df3a11ac25a68ec6ccbf099f00955bc1
Add decompress parallel tracker
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_entry.cpp", "new_path": "Source/astcenc_entry.cpp", "diff": "@@ -995,6 +995,8 @@ astcenc_error astcenc_decompress_image(\nwrite_imageblock(image_out, &blk, ctx->bsd,\nx * block_x, y * block_y, z * block_z, swizzle);\n}\n+\n+ ctx->manage_decompress.complete_task_assignment(count);\n}\nreturn ASTCENC_SUCCESS;\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add decompress parallel tracker
61,745
03.03.2021 16:10:30
0
738863bb8891228f8598152533936e3e530ce01a
Increase thread granule for var\avg SAT gen
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compute_variance.cpp", "new_path": "Source/astcenc_compute_variance.cpp", "diff": "@@ -535,15 +535,16 @@ void compute_averages_and_variances(\nwhile (true)\n{\nunsigned int count;\n- unsigned int base = ctx.manage_avg_var.get_task_assignment(1, count);\n+ unsigned int base = ctx.manage_avg_var.get_task_assignment(16, count);\nif (!count)\n{\nbreak;\n}\n- assert(count == 1);\n- int z = (base / (y_tasks)) * step_z;\n- int y = (base - (z * y_tasks)) * step_xy;\n+ for (unsigned int i = base; i < base + count; i++)\n+ {\n+ int z = (i / (y_tasks)) * step_z;\n+ int y = (i - (z * y_tasks)) * step_xy;\narg.size_z = astc::min(step_z, size_z - z);\narg.offset_z = z;\n@@ -557,6 +558,7 @@ void compute_averages_and_variances(\narg.offset_x = x;\ncompute_pixel_region_variance(ctx, &arg);\n}\n+ }\nctx.manage_avg_var.complete_task_assignment(count);\n}\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Increase thread granule for var\avg SAT gen
61,745
03.03.2021 16:12:20
0
4d2d01f6999162ac6f8e1e276e8f9dccfe1ce760
Use atomics for task tracking
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_entry.cpp", "new_path": "Source/astcenc_entry.cpp", "diff": "@@ -709,11 +709,7 @@ static void compress_image(\nwhile (true)\n{\nunsigned int count;\n- // TODO: Task assignment has been tuned empirically as the current\n- // approach is expensive. Consider using atomic tracker for task\n- // assignment, not a mutex-managed tracker, at which point we can\n- // reduce these down again.\n- unsigned int base = ctx.manage_compress.get_task_assignment(64, count);\n+ unsigned int base = ctx.manage_compress.get_task_assignment(16, count);\nif (!count)\n{\nbreak;\n@@ -963,10 +959,6 @@ astcenc_error astcenc_decompress_image(\nwhile (true)\n{\nunsigned int count;\n- // TODO: Task assignment has been tuned empirically as the current\n- // approach is expensive. Consider using atomic tracker for task\n- // assignment, not a mutex-managed tracker, at which point we can\n- // reduce these down again.\nunsigned int base = ctx->manage_decompress.get_task_assignment(128, count);\nif (!count)\n{\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "#define ASTCENC_INTERNAL_INCLUDED\n#include <algorithm>\n+#include <atomic>\n#include <cstddef>\n#include <cstdint>\n#include <cstdio>\n@@ -194,10 +195,10 @@ private:\nstd::condition_variable m_complete;\n/** @brief Number of tasks started, but not necessarily finished. */\n- unsigned int m_start_count;\n+ std::atomic<unsigned int> m_start_count;\n/** @brief Number of tasks finished. */\n- unsigned int m_done_count;\n+ std::atomic<unsigned int> m_done_count;\n/** @brief Number of tasks that need to be processed. */\nunsigned int m_task_count;\n@@ -277,10 +278,14 @@ public:\n*/\nunsigned int get_task_assignment(unsigned int granule, unsigned int& count)\n{\n- std::lock_guard<std::mutex> lck(m_lock);\n- unsigned int base = m_start_count;\n- count = std::min(granule, m_task_count - m_start_count);\n- m_start_count += count;\n+ unsigned int base = m_start_count.fetch_add(granule, std::memory_order_relaxed);\n+ if (base >= m_task_count)\n+ {\n+ count = 0;\n+ return 0;\n+ }\n+\n+ count = astc::min(m_task_count - base, granule);\nreturn base;\n}\n@@ -294,11 +299,9 @@ public:\n*/\nvoid complete_task_assignment(unsigned int count)\n{\n- std::unique_lock<std::mutex> lck(m_lock);\n- this->m_done_count += count;\n- if (m_done_count == m_task_count)\n+ unsigned int base = m_done_count.fetch_add(count, std::memory_order_relaxed);\n+ if ((base + count) == m_task_count)\n{\n- lck.unlock();\nm_complete.notify_all();\n}\n}\n@@ -1408,6 +1411,3 @@ void aligned_free(T* ptr)\n}\n#endif\n-\n-\n-\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Use atomics for task tracking
61,745
03.03.2021 18:21:27
0
3c3c2843df829fe509a08a3756c9084a1c7c4162
Updated change log for 2.5
[ { "change_type": "MODIFY", "old_path": "Docs/ChangeLog.md", "new_path": "Docs/ChangeLog.md", "diff": "@@ -9,16 +9,36 @@ clocked at 4.2 GHz, running astcenc using 6 threads.\n<!-- ---------------------------------------------------------------------- -->\n## 2.5\n-**Status:** In development\n+**Status:** In development, due late March 2021\n-The 2.5 release is the sixth release in the 2.x series. For this release\n-onwards the 2.x series is aiming to freeze image quality compared to 2.4,\n-allowing only minor differences caused by rounding and association changes.\n+The 2.5 release is planned to be the last major release in the 2.x series.\n+After this release a `2.x` branch will be created to provide stable long-term\n+support, and the `main` branch will switch to focusing on more radical changes\n+for the 3.x series.\n+\n+Reminder for users of the library interface - the API is not designed to be\n+stable across versions, and this release is not compatible with earlier 2.x\n+releases. Please update and rebuild your client-side code using the updated\n+`astcenc.h` header.\n**General:**\n* **Feature:** The `ISA_INVARIANCE` build option is no longer supported, as\nthere is no longer any performance benefit from the variant paths. All\n- builds are now using the equivalent of the `ISA_INVARIANCE=ON` setting.\n+ builds are now using the equivalent of the `ISA_INVARIANCE=ON` setting, and\n+ all builds are now believed to be invariant across operating systems,\n+ compilers, CPU architectures, and SIMD instruction sets.\n+* **Core API:**\n+ * **API Change:** The core API has been changed to be a pure C API, making it\n+ easier to wrap the codec in a stable shared library ABI. Some entry points\n+ that used to accept references now expect pointers.\n+ * **API Change:** The decompression functionality in the core API has been\n+ changed to allow use of multiple threads. The design pattern matches the\n+ compression functionality, requiring the caller to create the threads,\n+ synchronize them between images, and call the new\n+ `astcenc_decompress_reset()` function between images.\n+ * **API Feature:** Defines to support exporting public API entry point\n+ symbols from a shared object are provided, but not exposed off-the-shelf by\n+ the CMake provided by the project.\n<!-- ---------------------------------------------------------------------- -->\n## 2.4\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Updated change log for 2.5
61,745
04.03.2021 17:45:55
0
4555c6f4c0ed6b82b4a97bce28d30e88e0972108
Fix quality calculation for float32 outputs
[ { "change_type": "MODIFY", "old_path": "Source/astcenccli_error_metrics.cpp", "new_path": "Source/astcenccli_error_metrics.cpp", "diff": "@@ -234,7 +234,7 @@ void compute_error_metrics(\nassert(img2->data_type == ASTCENC_TYPE_F32);\nfloat* data32 = static_cast<float*>(img2->data[z]);\n- color1 = vfloat4(\n+ color2 = vfloat4(\ndata32[(4 * xsize2 * y) + (4 * x )],\ndata32[(4 * xsize2 * y) + (4 * x + 1)],\ndata32[(4 * xsize2 * y) + (4 * x + 2)],\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Fix quality calculation for float32 outputs
61,745
04.03.2021 17:47:57
0
3bfa41f80416e4c494291247c9029a0e3efd66ce
Fix LDR/HDR decode mismatch error handling
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_color_unquantize.cpp", "new_path": "Source/astcenc_color_unquantize.cpp", "diff": "@@ -810,7 +810,7 @@ void unpack_color_endpoints(\nvint4 output_scale = ldr_scale;\n// An LDR profile image\n- if ((decode_mode == ASTCENC_PRF_LDR_SRGB) ||\n+ if ((decode_mode == ASTCENC_PRF_LDR) ||\n(decode_mode == ASTCENC_PRF_LDR_SRGB))\n{\n// Also matches HDR alpha, as cannot have HDR alpha without HDR RGB\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Fix LDR/HDR decode mismatch error handling
61,745
03.03.2021 21:08:05
0
c167435e41ca24593c81e92a19d6dcf122a21ba4
Stop creating copies of LDR images in the write path
[ { "change_type": "MODIFY", "old_path": "Source/astcenccli_image_load_store.cpp", "new_path": "Source/astcenccli_image_load_store.cpp", "diff": "@@ -115,9 +115,12 @@ static int store_png_image_with_stb(\nconst char* filename,\nint y_flip\n) {\n- uint8_t* buf = unorm8x4_array_from_astc_img(img, y_flip);\n+ assert(img->data_type == ASTCENC_TYPE_U8);\n+ uint8_t* buf = (uint8_t*)img->data[0];\n+\n+ stbi_flip_vertically_on_write(y_flip);\nint res = stbi_write_png(filename, img->dim_x, img->dim_y, 4, buf, img->dim_x * 4);\n- delete[] buf;\n+\nreturn (res == 0) ? -1 : 4;\n}\n@@ -126,9 +129,12 @@ static int store_tga_image_with_stb(\nconst char* filename,\nint y_flip\n) {\n- uint8_t* buf = unorm8x4_array_from_astc_img(img, y_flip);\n+ assert(img->data_type == ASTCENC_TYPE_U8);\n+ uint8_t* buf = (uint8_t*)img->data[0];\n+\n+ stbi_flip_vertically_on_write(y_flip);\nint res = stbi_write_tga(filename, img->dim_x, img->dim_y, 4, buf);\n- delete[] buf;\n+\nreturn (res == 0) ? -1 : 4;\n}\n@@ -137,9 +143,12 @@ static int store_bmp_image_with_stb(\nconst char* filename,\nint y_flip\n) {\n- uint8_t* buf = unorm8x4_array_from_astc_img(img, y_flip);\n+ assert(img->data_type == ASTCENC_TYPE_U8);\n+ uint8_t* buf = (uint8_t*)img->data[0];\n+\n+ stbi_flip_vertically_on_write(y_flip);\nint res = stbi_write_bmp(filename, img->dim_x, img->dim_y, 4, buf);\n- delete[] buf;\n+\nreturn (res == 0) ? -1 : 4;\n}\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Stop creating copies of LDR images in the write path
61,745
09.03.2021 08:26:51
0
869bd414c5e66c1084446e734e442571ce7e5284
Typo fix in help text
[ { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel_help.cpp", "new_path": "Source/astcenccli_toplevel_help.cpp", "diff": "@@ -373,7 +373,7 @@ ADVANCED COMPRESSION\n-exhaustive : 1000.0\n-planecorlimit <factor>\n- Stop compression after testing only one planes of weights,\n+ Stop compression after testing only one plane of weights,\nunless the minimum color correlation factor between any pair of\ncolor channels is below this factor. This option is ineffective\nfor normal maps. Preset defaults are:\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Typo fix in help text
61,745
10.03.2021 13:05:58
0
7aa58499041cbd65f96c53666f03df12ac7d36da
Fix two_to_the_n test on NEON
[ { "change_type": "MODIFY", "old_path": "Source/UnitTest/test_simd.cpp", "new_path": "Source/UnitTest/test_simd.cpp", "diff": "@@ -1700,12 +1700,14 @@ TEST(vint4, two_to_the_n)\nvint4 r2 = two_to_the_n(a2);\nEXPECT_EQ(r2.lane<0>(), 1 << 29);\nEXPECT_EQ(r2.lane<1>(), 1 << 30);\n- EXPECT_EQ(r2.lane<2>(), 1 << 31);\n// This is just here for experimentation; the behavior of the actual\n// implementation here is undefined, as it shifts beyond the size of the\n// native type, and internally overflows the max value that can be stored\n// in a signed int. Behavior is different across instruction sets.\n+ // Shifts into sign bit\n+ // EXPECT_EQ(r2.lane<2>(), 1 << 31);\n+ // Shifts off the end of the word\n// EXPECT_EQ(r2.lane<3>(), 1 << 32);\n}\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib.h", "new_path": "Source/astcenc_vecmathlib.h", "diff": "@@ -378,6 +378,9 @@ ASTCENC_SIMD_INLINE vint4 clz(vint4 a)\n*/\nASTCENC_SIMD_INLINE vint4 two_to_the_n(vint4 a)\n{\n+ // 2^30 is the largest signed number than can be represented\n+ assert(all(a <= vint4(30)));\n+\n// This function is a horrible abuse of floating point to use the exponent\n// and float conversion to generate a 2^N multiple.\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Fix two_to_the_n test on NEON
61,750
11.03.2021 10:10:46
0
ab66c43bb6b6a332b6d461ccd3e7d1933b4f9a5a
Update CI Pipelines for AWS build infrastructure
[ { "change_type": "MODIFY", "old_path": "jenkins/build-image.sh", "new_path": "jenkins/build-image.sh", "diff": "#!/usr/bin/env bash\n-DOCKER_REGISTRY=mobile-studio--docker.artifactory.geo.arm.com\n+DOCKER_REGISTRY=mobile-studio--docker.eu-west-1.artifactory.aws.arm.com\nIMAGE_NAME=astcenc\n-IMAGE_VERSION=2.4.0\n+IMAGE_VERSION=3.0.0\n# Check Artifactory credentials are set\nif [[ -z \"${ARTIFACTORY_CREDENTIALS}\" ]]\n@@ -17,7 +17,7 @@ rm -fr tmp\nmkdir -p tmp\necho \"Get static analysis tools\"\n-curl --user ${ARTIFACTORY_CREDENTIALS} https://artifactory.geo.arm.com:443/artifactory/mobile-studio.tools/coverity201909.tar.xz --output tmp/coverity.tar.xz\n+curl --user ${ARTIFACTORY_CREDENTIALS} https://eu-west-1.artifactory.aws.arm.com/artifactory/mobile-studio.tools/coverity201909.tar.xz --output tmp/coverity.tar.xz\npushd tmp\ntar xf coverity.tar.xz\nrm coverity.tar.xz\n@@ -39,14 +39,14 @@ then\necho \"Pushing to $DOCKER_REGISTRY\"\ndocker login -u ${ARTIFACTORY_CREDENTIALS%:*} -p ${ARTIFACTORY_CREDENTIALS#*:} $DOCKER_REGISTRY\ndocker push $DOCKER_REGISTRY/$IMAGE_NAME:$IMAGE_VERSION\n- docker push $DOCKER_REGISTRY/$IMAGE_NAME:latest\n+ # docker push $DOCKER_REGISTRY/$IMAGE_NAME:latest\necho \"Clean up images\"\ndocker rmi $IMAGE_NAME:latest $IMAGE_NAME:$IMAGE_VERSION $DOCKER_REGISTRY/$IMAGE_NAME:latest $DOCKER_REGISTRY/$IMAGE_NAME:$IMAGE_VERSION\nelse\necho \"Build complete. To manually push to registry, run:\"\necho \" docker login -u ${ARTIFACTORY_CREDENTIALS%:*} -p ${ARTIFACTORY_CREDENTIALS#*:} $DOCKER_REGISTRY\"\necho \" docker push \\\"$DOCKER_REGISTRY/$IMAGE_NAME:$IMAGE_VERSION\\\"\"\n- echo \" docker push \\\"$DOCKER_REGISTRY/$IMAGE_NAME:latest\\\"\"\n+ # echo \" docker push \\\"$DOCKER_REGISTRY/$IMAGE_NAME:latest\\\"\"\nfi\necho \"Script Completed\"\n" }, { "change_type": "MODIFY", "old_path": "jenkins/build.Dockerfile", "new_path": "jenkins/build.Dockerfile", "diff": "FROM ubuntu:18.04\n-RUN useradd -u 1001 -U -m -c Jenkins jenkins\n+RUN useradd -u 1000 -U -m -c Jenkins jenkins\nRUN apt update && apt-get install -y \\\nsoftware-properties-common \\\n" }, { "change_type": "MODIFY", "old_path": "jenkins/dockerimage.Jenkinsfile", "new_path": "jenkins/dockerimage.Jenkinsfile", "diff": "pipeline {\nagent {\n- label 'streamline-linux'\n+ kubernetes {\n+ yaml '''\n+apiVersion: v1\n+kind: Pod\n+spec:\n+ imagePullSecrets:\n+ - name: artifactory-ms-docker\n+ containers:\n+ - name: dind\n+ image: mobile-studio--docker.eu-west-1.artifactory.aws.arm.com/docker:dind\n+ tty: true\n+ resources:\n+ requests:\n+ cpu: 2\n+ memory: 4Gi\n+ securityContext:\n+ privileged: true\n+ volumeMounts:\n+ - name: dind-storage\n+ mountPath: /var/lib/docker\n+ volumes:\n+ - name: dind-storage\n+ emptyDir: {}\n+'''\n+ defaultContainer 'dind'\n+ }\n}\nenvironment {\nARTIFACTORY_CREDENTIALS = credentials('cepe-artifactory-jenkins')\n@@ -12,7 +37,9 @@ pipeline {\nstages {\nstage('Build and Push Image') {\nsteps {\n+ sh 'docker info'\nsh '''\n+ apk add --no-cache bash curl\nchmod u+x ./jenkins/build-image.sh\n./jenkins/build-image.sh push\n'''\n" }, { "change_type": "MODIFY", "old_path": "jenkins/nightly.Jenkinsfile", "new_path": "jenkins/nightly.Jenkinsfile", "diff": "* similarly on different operating systems, so we test one compiler per OS.\n*/\n-@Library('hive-infra-library@changes/88/287488/3') _\n+@Library('hive-infra-library@changes/86/295486/1') _\npipeline {\nagent none\n@@ -29,12 +29,32 @@ pipeline {\n/* Build for Linux on x86-64 using GCC */\nstage('Linux') {\nagent {\n- docker {\n- image 'astcenc:2.3.0'\n- registryUrl 'https://mobile-studio--docker.artifactory.geo.arm.com'\n- registryCredentialsId 'cepe-artifactory-jenkins'\n- label 'docker'\n- alwaysPull true\n+ kubernetes {\n+ yaml '''\\\n+ apiVersion: v1\n+ kind: Pod\n+ spec:\n+ securityContext:\n+ runAsUser: 1000\n+ runAsGroup: 1000\n+ imagePullSecrets:\n+ - name: artifactory-ms-docker\n+ containers:\n+ - name: astcenc\n+ image: mobile-studio--docker.eu-west-1.artifactory.aws.arm.com/astcenc:3.0.0\n+ command:\n+ - sleep\n+ args:\n+ - infinity\n+ resources:\n+ requests:\n+ cpu: 4\n+ memory: 8Gi\n+ limits:\n+ cpu: 8\n+ memory: 16Gi\n+ '''.stripIndent()\n+ defaultContainer 'astcenc'\n}\n}\nstages {\n@@ -93,7 +113,7 @@ pipeline {\n/* Build for Windows on x86-64 using MSVC */\nstage('Windows') {\nagent {\n- label 'Windows && x86_64'\n+ label 'Windows'\n}\nstages {\nstage('Clean') {\n@@ -143,7 +163,7 @@ pipeline {\n/* Build for macOS on x86-64 using Clang */\nstage('macOS') {\nagent {\n- label 'mac && x86_64'\n+ label 'mac'\n}\nstages {\nstage('Clean') {\n@@ -192,12 +212,29 @@ pipeline {\n}\nstage('Artifactory') {\nagent {\n- docker {\n- image 'astcenc:2.3.0'\n- registryUrl 'https://mobile-studio--docker.artifactory.geo.arm.com'\n- registryCredentialsId 'cepe-artifactory-jenkins'\n- label 'docker'\n- alwaysPull true\n+ kubernetes {\n+ yaml '''\n+apiVersion: v1\n+kind: Pod\n+spec:\n+ securityContext:\n+ runAsUser: 1000\n+ runAsGroup: 1000\n+ imagePullSecrets:\n+ - name: artifactory-ms-docker\n+ containers:\n+ - name: astcenc\n+ image: mobile-studio--docker.eu-west-1.artifactory.aws.arm.com/astcenc:3.0.0\n+ command:\n+ - sleep\n+ args:\n+ - infinity\n+ resources:\n+ requests:\n+ cpu: 1\n+ memory: 4Gi\n+'''\n+ defaultContainer 'astcenc'\n}\n}\noptions {\n" }, { "change_type": "MODIFY", "old_path": "jenkins/release.Jenkinsfile", "new_path": "jenkins/release.Jenkinsfile", "diff": "* similarly on different operating systems, so we test one compiler per OS.\n*/\n-@Library('hive-infra-library@changes/88/287488/3') _\n+@Library('hive-infra-library@changes/86/295486/1') _\npipeline {\nagent none\n@@ -31,12 +31,29 @@ pipeline {\n/* Run static analysis on Linux */\nstage('Coverity') {\nagent {\n- docker {\n- image 'astcenc:2.4.0'\n- registryUrl 'https://mobile-studio--docker.artifactory.geo.arm.com'\n- registryCredentialsId 'cepe-artifactory-jenkins'\n- label 'docker'\n- alwaysPull true\n+ kubernetes {\n+ yaml '''\n+apiVersion: v1\n+kind: Pod\n+spec:\n+ securityContext:\n+ runAsUser: 1000\n+ runAsGroup: 1000\n+ imagePullSecrets:\n+ - name: artifactory-ms-docker\n+ containers:\n+ - name: astcenc\n+ image: mobile-studio--docker.eu-west-1.artifactory.aws.arm.com/astcenc:3.0.0\n+ command:\n+ - sleep\n+ args:\n+ - infinity\n+ resources:\n+ requests:\n+ cpu: 4\n+ memory: 8Gi\n+'''\n+ defaultContainer 'astcenc'\n}\n}\nstages {\n@@ -76,12 +93,32 @@ pipeline {\n/* Build for Linux on x86-64 using Clang */\nstage('Linux') {\nagent {\n- docker {\n- image 'astcenc:2.3.0'\n- registryUrl 'https://mobile-studio--docker.artifactory.geo.arm.com'\n- registryCredentialsId 'cepe-artifactory-jenkins'\n- label 'docker'\n- alwaysPull true\n+ kubernetes {\n+ yaml '''\\\n+ apiVersion: v1\n+ kind: Pod\n+ spec:\n+ securityContext:\n+ runAsUser: 1000\n+ runAsGroup: 1000\n+ imagePullSecrets:\n+ - name: artifactory-ms-docker\n+ containers:\n+ - name: astcenc\n+ image: mobile-studio--docker.eu-west-1.artifactory.aws.arm.com/astcenc:3.0.0\n+ command:\n+ - sleep\n+ args:\n+ - infinity\n+ resources:\n+ requests:\n+ cpu: 4\n+ memory: 8Gi\n+ limits:\n+ cpu: 8\n+ memory: 16Gi\n+ '''.stripIndent()\n+ defaultContainer 'astcenc'\n}\n}\nstages {\n@@ -133,7 +170,7 @@ pipeline {\n/* Build for Windows on x86-64 using MSVC */\nstage('Windows') {\nagent {\n- label 'Windows && x86_64'\n+ label 'Windows'\n}\nstages {\nstage('Clean') {\n@@ -173,7 +210,7 @@ pipeline {\n/* Build for macOS on x86-64 using Clang */\nstage('macOS') {\nagent {\n- label 'mac && x86_64 && notarizer'\n+ label 'mac && notarizer'\n}\nstages {\nstage('Clean') {\n@@ -197,10 +234,7 @@ pipeline {\n}\nsteps {\ndir('build_rel') {\n- withCredentials([sshUserPrivateKey(credentialsId: 'gerrit-jenkins-ssh',\n- keyFileVariable: 'SSH_AUTH_FILE')]) {\n- sh 'GIT_SSH_COMMAND=\"ssh -i $SSH_AUTH_FILE -o StrictHostKeyChecking=no\" git clone ssh://eu-gerrit-1.euhpc.arm.com:29418/Hive/shared/signing'\n- }\n+ sh 'git clone ssh://eu-gerrit-1.euhpc.arm.com:29418/Hive/shared/signing'\nwithCredentials([usernamePassword(credentialsId: 'win-signing',\nusernameVariable: 'USERNAME',\npasswordVariable: 'PASSWORD')]) {\n@@ -231,7 +265,7 @@ pipeline {\n/* Build for macOS on x86-64 using Clang */\nstage('macOS arm64') {\nagent {\n- label 'mac && x86_64 && notarizer'\n+ label 'mac && notarizer'\n}\nstages {\nstage('Clean') {\n@@ -255,10 +289,7 @@ pipeline {\n}\nsteps {\ndir('build_rel') {\n- withCredentials([sshUserPrivateKey(credentialsId: 'gerrit-jenkins-ssh',\n- keyFileVariable: 'SSH_AUTH_FILE')]) {\n- sh 'GIT_SSH_COMMAND=\"ssh -i $SSH_AUTH_FILE -o StrictHostKeyChecking=no\" git clone ssh://eu-gerrit-1.euhpc.arm.com:29418/Hive/shared/signing'\n- }\n+ sh 'git clone ssh://eu-gerrit-1.euhpc.arm.com:29418/Hive/shared/signing'\nwithCredentials([usernamePassword(credentialsId: 'win-signing',\nusernameVariable: 'USERNAME',\npasswordVariable: 'PASSWORD')]) {\n@@ -283,12 +314,29 @@ pipeline {\n}\nstage('Artifactory') {\nagent {\n- docker {\n- image 'astcenc:2.3.0'\n- registryUrl 'https://mobile-studio--docker.artifactory.geo.arm.com'\n- registryCredentialsId 'cepe-artifactory-jenkins'\n- label 'docker'\n- alwaysPull true\n+ kubernetes {\n+ yaml '''\n+apiVersion: v1\n+kind: Pod\n+spec:\n+ securityContext:\n+ runAsUser: 1000\n+ runAsGroup: 1000\n+ imagePullSecrets:\n+ - name: artifactory-ms-docker\n+ containers:\n+ - name: astcenc\n+ image: mobile-studio--docker.eu-west-1.artifactory.aws.arm.com/astcenc:3.0.0\n+ command:\n+ - sleep\n+ args:\n+ - infinity\n+ resources:\n+ requests:\n+ cpu: 1\n+ memory: 4Gi\n+'''\n+ defaultContainer 'astcenc'\n}\n}\noptions {\n@@ -308,10 +356,14 @@ pipeline {\n}\ndir('upload/windows-x64') {\nunstash 'astcenc-windows-x64'\n- withCredentials([sshUserPrivateKey(credentialsId: 'gerrit-jenkins-ssh',\n- keyFileVariable: 'SSH_AUTH_FILE')]) {\n- sh 'GIT_SSH_COMMAND=\"ssh -i $SSH_AUTH_FILE -o StrictHostKeyChecking=no\" git clone ssh://eu-gerrit-1.euhpc.arm.com:29418/Hive/shared/signing'\n- }\n+ checkout changelog: false,\n+ poll: false,\n+ scm: [$class: 'GitSCM',\n+ branches: [[name: '*/master']],\n+ doGenerateSubmoduleConfigurations: false,\n+ extensions: [],\n+ submoduleCfg: [],\n+ userRemoteConfigs: [[credentialsId: 'gerrit-jenkins', url: 'ssh://eu-gerrit-1.euhpc.arm.com:29418/Hive/shared/signing']]]\nwithCredentials([usernamePassword(credentialsId: 'win-signing',\nusernameVariable: 'USERNAME',\npasswordVariable: 'PASSWORD')]) {\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Update CI Pipelines for AWS build infrastructure (#238)
61,745
11.03.2021 11:20:29
0
94592a284d5e22c8708ec7db9e454cea922b8e37
Fix vint4.two_to_the_n tests
[ { "change_type": "MODIFY", "old_path": "Source/UnitTest/test_simd.cpp", "new_path": "Source/UnitTest/test_simd.cpp", "diff": "@@ -1696,19 +1696,18 @@ TEST(vint4, two_to_the_n)\nEXPECT_EQ(r1.lane<2>(), 1 << 2);\nEXPECT_EQ(r1.lane<3>(), 1 << 3);\n- vint4 a2(29, 30, 31, 32);\n+ vint4 a2(27, 28, 29, 30);\nvint4 r2 = two_to_the_n(a2);\n- EXPECT_EQ(r2.lane<0>(), 1 << 29);\n- EXPECT_EQ(r2.lane<1>(), 1 << 30);\n-\n- // This is just here for experimentation; the behavior of the actual\n- // implementation here is undefined, as it shifts beyond the size of the\n- // native type, and internally overflows the max value that can be stored\n- // in a signed int. Behavior is different across instruction sets.\n- // Shifts into sign bit\n- // EXPECT_EQ(r2.lane<2>(), 1 << 31);\n- // Shifts off the end of the word\n- // EXPECT_EQ(r2.lane<3>(), 1 << 32);\n+ EXPECT_EQ(r2.lane<0>(), 1 << 27);\n+ EXPECT_EQ(r2.lane<1>(), 1 << 28);\n+ EXPECT_EQ(r2.lane<2>(), 1 << 29);\n+ EXPECT_EQ(r2.lane<3>(), 1 << 30);\n+\n+ // Shifts higher than 30 are not allowed as it overflows the int type;\n+ // and results in implementation-defined behavior because of how we\n+ // generate the shifted result in two_to_the_n().\n+ // - Shift by 31 shifts into sign bit\n+ // - Shift by 32 shifts off the end\n}\n/** @brief Test vint4 storea. */\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Fix vint4.two_to_the_n tests
61,754
11.03.2021 20:03:18
-28,800
36557da84fbb840ea1f19b25f1165c8cc97cfa00
Support Armv7
[ { "change_type": "MODIFY", "old_path": "CMakeLists.txt", "new_path": "CMakeLists.txt", "diff": "@@ -35,7 +35,7 @@ function(printopt optName optVal optArch tgtArch)\nendif()\nendfunction()\n-set(VALID_ARCH aarch64 x64)\n+set(VALID_ARCH aarch64 armv7 x64)\nset(ARCH x64 CACHE STRING \"Target architecture\")\nset_property(CACHE ARCH PROPERTY STRINGS ${VALID_ARCH})\n@@ -66,8 +66,8 @@ if(${ISA_SSE2} AND ${ARCH} MATCHES \"x64\")\nendif()\noption(ISA_NEON \"Enable builds for NEON SIMD\")\n-printopt(\"NEON\" ${ISA_NEON} \"aarch64\" ${ARCH})\n-if(${ISA_NEON} AND ${ARCH} MATCHES \"aarch64\")\n+printopt(\"NEON\" ${ISA_NEON} \"armv7|aarch64\" ${ARCH})\n+if(${ISA_NEON} AND ${ARCH} MATCHES \"armv7|aarch64\")\nset(ANY_ISA 1)\nendif()\n@@ -110,6 +110,28 @@ endif()\n# or it gets overriden (this contradicts the official docs)\nif(${ARCH} MATCHES \"aarch64\")\nset(CMAKE_OSX_ARCHITECTURES \"arm64\")\n+elseif(${ARCH} MATCHES \"armv7\")\n+ set(CMAKE_OSX_ARCHITECTURES \"armv7\")\n+ set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -march=armv7-a\")\n+ if (CMAKE_CXX_COMPILER_ID STREQUAL \"Clang\")\n+ # using Clang\n+ set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -mfpu=neon-vfpv4\")\n+ set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -Wno-unused-command-line-argument\")\n+ set(CMAKE_CXX_FLAGS_RELEASE \"-O3\")\n+ elseif (CMAKE_CXX_COMPILER_ID STREQUAL \"GNU\")\n+ # using GCC\n+ # softfp for arm-linux-gnueabi-g++\n+ # hard for arm-linux-gnueabihf-g++\n+ set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -mfloat-abi=softfp\")\n+ # arm-linux-gnueabi(hf)-gcc uses #pragma GCC target (\"fpu=neon-fp-armv8\")\n+ # to declare more intrinsics (including vminnmq/vmaxnmq)\n+ set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -mfpu=neon-fp-armv8\")\n+ # support fp16 in GCC\n+ set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -mfp16-format=ieee\")\n+ set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -flax-vector-conversions\")\n+ # For Source/tinyexr.h:11025\n+ set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -Wno-type-limits\")\n+ endif()\nelse()\nset(CMAKE_OSX_ARCHITECTURES \"x86_64\")\nendif()\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_mathlib.h", "new_path": "Source/astcenc_mathlib.h", "diff": "#endif\n#ifndef ASTCENC_NEON\n- #if defined(__aarch64__)\n+ #if defined(__aarch64__) || defined(__arm__)\n#define ASTCENC_NEON 1\n#else\n#define ASTCENC_NEON 0\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_neon_4.h", "new_path": "Source/astcenc_vecmathlib_neon_4.h", "diff": "#include <cstdio>\n+#if defined(__arm__)\n+ #include \"astcenc_vecmathlib_neon_armv7_4.h\"\n+#endif\n+\n// ============================================================================\n// vfloat4 data type\n// ============================================================================\n" }, { "change_type": "ADD", "old_path": null, "new_path": "Source/astcenc_vecmathlib_neon_armv7_4.h", "diff": "+// SPDX-License-Identifier: Apache-2.0\n+// ----------------------------------------------------------------------------\n+// Copyright 2021 Arm Limited\n+//\n+// Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n+// use this file except in compliance with the License. You may obtain a copy\n+// of the License at:\n+//\n+// http://www.apache.org/licenses/LICENSE-2.0\n+//\n+// Unless required by applicable law or agreed to in writing, software\n+// distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n+// License for the specific language governing permissions and limitations\n+// under the License.\n+// ----------------------------------------------------------------------------\n+\n+/**\n+ * @brief Intrinsics for Armv7 NEON.\n+ *\n+ * This module implements a few Armv7-compatible intrinsics indentical to Armv8\n+ * ones. Thus, astcenc can be compiled using Armv7 architecture.\n+ */\n+\n+#ifndef ASTC_VECMATHLIB_NEON_ARMV7_4_H_INCLUDED\n+#define ASTC_VECMATHLIB_NEON_ARMV7_4_H_INCLUDED\n+\n+#ifndef ASTCENC_SIMD_INLINE\n+ #error \"Include astcenc_vecmathlib.h, do not include directly\"\n+#endif\n+\n+#include <algorithm>\n+#include <cfenv>\n+\n+\n+// arm-linux-gnueabi-gcc contains the following functions by using\n+// #pragma GCC target (\"fpu=neon-fp-armv8\"), while clang does not.\n+#if defined(__clang__)\n+\n+/**\n+ * @brief Return the max vector of two vectors.\n+ *\n+ * If one vector element is numeric and the other is a quiet NaN,\n+ * the result placed in the vector is the numerical value.\n+ */\n+ASTCENC_SIMD_INLINE float32x4_t vmaxnmq_f32(float32x4_t a, float32x4_t b)\n+{\n+ uint32x4_t amask = vceqq_f32(a, a);\n+ uint32x4_t bmask = vceqq_f32(b, b);\n+ a = vbslq_f32(amask, a, b);\n+ b = vbslq_f32(bmask, b, a);\n+ return vmaxq_f32(a, b);\n+}\n+\n+/**\n+ * @brief Return the min vector of two vectors.\n+ *\n+ * If one vector element is numeric and the other is a quiet NaN,\n+ * the result placed in the vector is the numerical value.\n+ */\n+ASTCENC_SIMD_INLINE float32x4_t vminnmq_f32(float32x4_t a, float32x4_t b)\n+{\n+ uint32x4_t amask = vceqq_f32(a, a);\n+ uint32x4_t bmask = vceqq_f32(b, b);\n+ a = vbslq_f32(amask, a, b);\n+ b = vbslq_f32(bmask, b, a);\n+ return vminq_f32(a, b);\n+}\n+\n+#endif\n+\n+/**\n+ * @brief Return the horizontal maximum of a vector.\n+ */\n+ASTCENC_SIMD_INLINE float vmaxvq_f32(float32x4_t a)\n+{\n+ float a0 = vgetq_lane_f32(a, 0);\n+ float a1 = vgetq_lane_f32(a, 1);\n+ float a2 = vgetq_lane_f32(a, 2);\n+ float a3 = vgetq_lane_f32(a, 3);\n+ return std::max(std::max(a0, a1), std::max(a2, a3));\n+}\n+\n+/**\n+ * @brief Return the horizontal maximum of a vector.\n+ */\n+ASTCENC_SIMD_INLINE float vminvq_f32(float32x4_t a)\n+{\n+ float a0 = vgetq_lane_f32(a, 0);\n+ float a1 = vgetq_lane_f32(a, 1);\n+ float a2 = vgetq_lane_f32(a, 2);\n+ float a3 = vgetq_lane_f32(a, 3);\n+ return std::min(std::min(a0, a1), std::min(a2, a3));\n+}\n+\n+/**\n+ * @brief Return the horizontal maximum of a vector.\n+ */\n+ASTCENC_SIMD_INLINE int32_t vmaxvq_s32(int32x4_t a)\n+{\n+ int32_t a0 = vgetq_lane_s32(a, 0);\n+ int32_t a1 = vgetq_lane_s32(a, 1);\n+ int32_t a2 = vgetq_lane_s32(a, 2);\n+ int32_t a3 = vgetq_lane_s32(a, 3);\n+ return std::max(std::max(a0, a1), std::max(a2, a3));\n+}\n+\n+/**\n+ * @brief Return the horizontal maximum of a vector.\n+ */\n+ASTCENC_SIMD_INLINE int32_t vminvq_s32(int32x4_t a)\n+{\n+ int32_t a0 = vgetq_lane_s32(a, 0);\n+ int32_t a1 = vgetq_lane_s32(a, 1);\n+ int32_t a2 = vgetq_lane_s32(a, 2);\n+ int32_t a3 = vgetq_lane_s32(a, 3);\n+ return std::min(std::min(a0, a1), std::min(a2, a3));\n+}\n+\n+/**\n+ * @brief Return the sqrt of the lanes in the vector.\n+ */\n+ASTCENC_SIMD_INLINE float32x4_t vsqrtq_f32(float32x4_t a)\n+{\n+ float a0 = std::sqrt(vgetq_lane_f32(a, 0));\n+ float a1 = std::sqrt(vgetq_lane_f32(a, 1));\n+ float a2 = std::sqrt(vgetq_lane_f32(a, 2));\n+ float a3 = std::sqrt(vgetq_lane_f32(a, 3));\n+ float32x4_t c { a0, a1, a2, a3 };\n+ return c;\n+}\n+\n+/**\n+ * @brief Return a float rounded to the nearest integer value.\n+ */\n+ASTCENC_SIMD_INLINE float32x4_t vrndnq_f32(float32x4_t a)\n+{\n+ assert( std::fegetround() == FE_TONEAREST);\n+ float a0 = std::nearbyintf(vgetq_lane_f32(a, 0));\n+ float a1 = std::nearbyintf(vgetq_lane_f32(a, 1));\n+ float a2 = std::nearbyintf(vgetq_lane_f32(a, 2));\n+ float a3 = std::nearbyintf(vgetq_lane_f32(a, 3));\n+ float32x4_t c { a0, a1, a2, a3 };\n+ return c;\n+}\n+\n+/**\n+ * @brief Vector by vector division.\n+ */\n+ASTCENC_SIMD_INLINE float32x4_t vdivq_f32(float32x4_t a, float32x4_t b)\n+{\n+ float a0 = vgetq_lane_f32(a, 0), b0 = vgetq_lane_f32(b, 0);\n+ float a1 = vgetq_lane_f32(a, 1), b1 = vgetq_lane_f32(b, 1);\n+ float a2 = vgetq_lane_f32(a, 2), b2 = vgetq_lane_f32(b, 2);\n+ float a3 = vgetq_lane_f32(a, 3), b3 = vgetq_lane_f32(b, 3);\n+ float32x4_t c { a0 / b0, a1 / b1, a2 / b2, a3 / b3 };\n+ return c;\n+}\n+\n+/**\n+ * @brief Table vector lookup.\n+ */\n+ASTCENC_SIMD_INLINE int8x16_t vqtbl1q_s8(int8x16_t t, uint8x16_t idx)\n+{\n+ int8x8x2_t tab;\n+ tab.val[0] = vget_low_s8(t);\n+ tab.val[1] = vget_high_s8(t);\n+ int8x16_t id = vreinterpretq_s8_u8(idx);\n+ return vcombine_s8(\n+ vtbl2_s8(tab, vget_low_s8(id)),\n+ vtbl2_s8(tab, vget_high_s8(id)));\n+}\n+\n+/**\n+ * @brief Horizontal integer addition.\n+ */\n+ASTCENC_SIMD_INLINE uint32_t vaddvq_u32(uint32x4_t a)\n+{\n+ uint32_t a0 = vgetq_lane_u32(a, 0);\n+ uint32_t a1 = vgetq_lane_u32(a, 1);\n+ uint32_t a2 = vgetq_lane_u32(a, 2);\n+ uint32_t a3 = vgetq_lane_u32(a, 3);\n+ return a0 + a1 + a2 + a3;\n+}\n+\n+#endif\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Support Armv7 (#237)
61,745
11.03.2021 13:03:11
0
3554a5d7449734d672430624f8cb837882a2da37
Split armv7 into armv7 and armv7hf
[ { "change_type": "MODIFY", "old_path": "CMakeLists.txt", "new_path": "CMakeLists.txt", "diff": "@@ -35,7 +35,7 @@ function(printopt optName optVal optArch tgtArch)\nendif()\nendfunction()\n-set(VALID_ARCH aarch64 armv7 x64)\n+set(VALID_ARCH aarch64 armv7 armv7hf x64)\nset(ARCH x64 CACHE STRING \"Target architecture\")\nset_property(CACHE ARCH PROPERTY STRINGS ${VALID_ARCH})\n@@ -66,8 +66,8 @@ if(${ISA_SSE2} AND ${ARCH} MATCHES \"x64\")\nendif()\noption(ISA_NEON \"Enable builds for NEON SIMD\")\n-printopt(\"NEON\" ${ISA_NEON} \"armv7|aarch64\" ${ARCH})\n-if(${ISA_NEON} AND ${ARCH} MATCHES \"armv7|aarch64\")\n+printopt(\"NEON\" ${ISA_NEON} \"armv7|armv7hf|aarch64\" ${ARCH})\n+if(${ISA_NEON} AND ${ARCH} MATCHES \"armv7|armv7hf|aarch64\")\nset(ANY_ISA 1)\nendif()\n@@ -110,26 +110,31 @@ endif()\n# or it gets overriden (this contradicts the official docs)\nif(${ARCH} MATCHES \"aarch64\")\nset(CMAKE_OSX_ARCHITECTURES \"arm64\")\n-elseif(${ARCH} MATCHES \"armv7\")\n+elseif(${ARCH} MATCHES \"armv7|armv7hf\")\nset(CMAKE_OSX_ARCHITECTURES \"armv7\")\nset(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -march=armv7-a\")\nif(CMAKE_CXX_COMPILER_ID STREQUAL \"Clang\")\n- # using Clang\n+ # Using Clang\nset(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -mfpu=neon-vfpv4\")\nset(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -Wno-unused-command-line-argument\")\nset(CMAKE_CXX_FLAGS_RELEASE \"-O3\")\nelseif (CMAKE_CXX_COMPILER_ID STREQUAL \"GNU\")\n- # using GCC\n+ # Using GCC\n+ if(${ARCH} STREQUAL \"armv7\")\n# softfp for arm-linux-gnueabi-g++\n- # hard for arm-linux-gnueabihf-g++\nset(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -mfloat-abi=softfp\")\n- # arm-linux-gnueabi(hf)-gcc uses #pragma GCC target (\"fpu=neon-fp-armv8\")\n- # to declare more intrinsics (including vminnmq/vmaxnmq)\n+ elseif(${ARCH} STREQUAL \"armv7hf\")\n+ # hard for arm-linux-gnueabihf-g++\n+ set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -mfloat-abi=hard\")\n+ endif()\n+\n+ # Using fpu=neon-fp-armv8 emulates many aarch64 intrinsics\nset(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -mfpu=neon-fp-armv8\")\n- # support fp16 in GCC\n+\n+ # Enable fp16 support in GCC\nset(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -mfp16-format=ieee\")\n- set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -flax-vector-conversions\")\n- # For Source/tinyexr.h:11025\n+\n+ # Workaround for Source/tinyexr.h:11025\nset(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -Wno-type-limits\")\nendif()\nelse()\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Split armv7 into armv7 and armv7hf
61,745
11.03.2021 14:10:15
0
59a34e483ded36b34644a29d276ff9d8913f0c28
Add Armv7 support to Build docs
[ { "change_type": "MODIFY", "old_path": "Docs/Building.md", "new_path": "Docs/Building.md", "diff": "@@ -105,6 +105,30 @@ To enable this binary variant add `-DISA_NONE=ON` to the CMake command line\nwhen configuring. It is NOT recommended to use this for production; it is\nsignificantly slower than the vectorized SIMD builds.\n+### Armv7 builds\n+\n+The build system includes support for building for Armv7 32-bit binaries on\n+Linux and macOS, using GCC 9.3 or higher, or Clang 9 or higher. The `armv7`\n+build uses the soft-float ABI and `armv7hf` uses the hard-float ABI.\n+\n+:warning: Armv7 NEON is not IEEE-754 strict compliant, so these builds may not\n+be invariant with other build targets.\n+\n+We tested these builds using the following cross-compilers on Ubuntu 20.04:\n+\n+* `armv7`: arm-linux-gnueabi-g++-9 (v 9.3.0)\n+* `armv7hf`: arm-linux-gnueabihf-g++-9 (v 9.3.0)\n+\n+```shell\n+# Arm armv7 using the soft-float ABI\n+cmake -G \"Unix Makefiles\" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=./ \\\n+ -DARCH=armv7 -DISA_NEON=ON ..\n+\n+# Arm armv7hf using the hard-float ABI\n+cmake -G \"Unix Makefiles\" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=./ \\\n+ -DARCH=armv7hf -DISA_NEON=ON ..\n+```\n+\n### Build Types\nWe support and test the following `CMAKE_BUILD_TYPE` options.\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add Armv7 support to Build docs
61,745
12.03.2021 09:58:26
0
d12e06f00b2b10e2d172833dd42d9ed5ef96aa7e
Add default case for old compiler support
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -676,6 +676,8 @@ static inline int get_quant_method_levels(quant_method method)\ncase QUANT_160: return 160;\ncase QUANT_192: return 192;\ncase QUANT_256: return 256;\n+ // Unreachable - the enum is fully described\n+ default: return 0;\n}\n}\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add default case for old compiler support
61,745
12.03.2021 22:16:31
0
6713c0cd08be18304750606efea457df58b2079e
Arm 32-bit builds are really Armv8 A32 so rename
[ { "change_type": "MODIFY", "old_path": "CMakeLists.txt", "new_path": "CMakeLists.txt", "diff": "@@ -35,7 +35,7 @@ function(printopt optName optVal optArch tgtArch)\nendif()\nendfunction()\n-set(VALID_ARCH aarch64 armv7 armv7hf x64)\n+set(VALID_ARCH aarch64 aarch32 aarch32hf x64)\nset(ARCH x64 CACHE STRING \"Target architecture\")\nset_property(CACHE ARCH PROPERTY STRINGS ${VALID_ARCH})\n@@ -66,8 +66,8 @@ if(${ISA_SSE2} AND ${ARCH} MATCHES \"x64\")\nendif()\noption(ISA_NEON \"Enable builds for NEON SIMD\")\n-printopt(\"NEON\" ${ISA_NEON} \"armv7|armv7hf|aarch64\" ${ARCH})\n-if(${ISA_NEON} AND ${ARCH} MATCHES \"armv7|armv7hf|aarch64\")\n+printopt(\"NEON\" ${ISA_NEON} \"aarch32|aarch32hf|aarch64\" ${ARCH})\n+if(${ISA_NEON} AND ${ARCH} MATCHES \"aarch32|aarch32hf|aarch64\")\nset(ANY_ISA 1)\nendif()\n@@ -110,30 +110,31 @@ endif()\n# or it gets overriden (this contradicts the official docs)\nif(${ARCH} MATCHES \"aarch64\")\nset(CMAKE_OSX_ARCHITECTURES \"arm64\")\n-elseif(${ARCH} MATCHES \"armv7|armv7hf\")\n+\n+elseif(${ARCH} MATCHES \"aarch32|aarch32hf\")\n+ # Deliberately use Armv7 for Clang - its most compatible with the current\n+ # code; we provide some fallbacks for a few missing v8 intrinsics.\n+ if(CMAKE_CXX_COMPILER_ID STREQUAL \"Clang\")\n+\nset(CMAKE_OSX_ARCHITECTURES \"armv7\")\nset(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -march=armv7-a\")\n- if(CMAKE_CXX_COMPILER_ID STREQUAL \"Clang\")\n- # Using Clang\nset(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -mfpu=neon-vfpv4\")\nset(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -Wno-unused-command-line-argument\")\nset(CMAKE_CXX_FLAGS_RELEASE \"-O3\")\n+\n+ # For GCC we directly target Armv8-A A32, and provide some emulated\n+ # fallback intrinsics for functionality that exists for A64 but not A32.\nelseif (CMAKE_CXX_COMPILER_ID STREQUAL \"GNU\")\n- # Using GCC\n- if(${ARCH} STREQUAL \"armv7\")\n- # softfp for arm-linux-gnueabi-g++\n+ set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -march=armv8-a\")\n+ set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -mfpu=neon-fp-armv8\")\n+ set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -mfp16-format=ieee\")\n+\n+ if(${ARCH} STREQUAL \"aarch32\") # arm-linux-gnueabi-g++\nset(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -mfloat-abi=softfp\")\n- elseif(${ARCH} STREQUAL \"armv7hf\")\n- # hard for arm-linux-gnueabihf-g++\n+ elseif(${ARCH} STREQUAL \"aarch32hf\") # arm-linux-gnueabihf-g++\nset(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -mfloat-abi=hard\")\nendif()\n- # Using fpu=neon-fp-armv8 emulates many aarch64 intrinsics\n- set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -mfpu=neon-fp-armv8\")\n-\n- # Enable fp16 support in GCC\n- set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -mfp16-format=ieee\")\n-\n# Workaround for Source/tinyexr.h:11025\nset(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -Wno-type-limits\")\nendif()\n" }, { "change_type": "MODIFY", "old_path": "Docs/Building.md", "new_path": "Docs/Building.md", "diff": "@@ -105,28 +105,27 @@ To enable this binary variant add `-DISA_NONE=ON` to the CMake command line\nwhen configuring. It is NOT recommended to use this for production; it is\nsignificantly slower than the vectorized SIMD builds.\n-### Armv7 builds\n+### 32-bit Armv8 builds\n-The build system includes support for building for Armv7 32-bit binaries on\n-Linux and macOS, using GCC 9.3 or higher, or Clang 9 or higher. The `armv7`\n-build uses the soft-float ABI and `armv7hf` uses the hard-float ABI.\n-\n-:warning: Armv7 NEON is not IEEE-754 strict compliant, so these builds may not\n-be invariant with other build targets.\n+The build system includes support for building for Armv8 32-bit binaries on\n+Linux, using GCC 9.3 or higher, or Clang 9 or higher. The `aarch32` build uses\n+the soft-float ABI and `aarch32hf` uses the hard-float ABI.\nWe tested these builds using the following cross-compilers on Ubuntu 20.04:\n-* `armv7`: arm-linux-gnueabi-g++-9 (v 9.3.0)\n-* `armv7hf`: arm-linux-gnueabihf-g++-9 (v 9.3.0)\n+* `aarch32`: arm-linux-gnueabi-g++-9 (v 9.3.0)\n+* `aarch32hf`: arm-linux-gnueabihf-g++-9 (v 9.3.0)\n```shell\n-# Arm armv7 using the soft-float ABI\n+# Arm aarch32 using the soft-float ABI\n+export CXX=arm-linux-gnueabi-g++-9\ncmake -G \"Unix Makefiles\" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=./ \\\n- -DARCH=armv7 -DISA_NEON=ON ..\n+ -DARCH=aarch32 -DISA_NEON=ON ..\n-# Arm armv7hf using the hard-float ABI\n+# Arm aarch32 using the hard-float ABI\n+export CXX=arm-linux-gnueabihf-g++-9\ncmake -G \"Unix Makefiles\" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=./ \\\n- -DARCH=armv7hf -DISA_NEON=ON ..\n+ -DARCH=aarch32hf -DISA_NEON=ON ..\n```\n### Build Types\n" }, { "change_type": "MODIFY", "old_path": "Docs/ChangeLog.md", "new_path": "Docs/ChangeLog.md", "diff": "@@ -27,12 +27,10 @@ releases. Please update and rebuild your client-side code using the updated\nbuilds are now using the equivalent of the `ISA_INVARIANCE=ON` setting, and\nall builds (except Armv7) are now believed to be invariant across operating\nsystems, compilers, CPU architectures, and SIMD instruction sets.\n- * **Feature:** 32-bit Armv7 builds with NEON are now supported, with\n- out-of-the-box support for Arm Linux soft-float and hard-float ABIs. These\n- are NOT guaranteed to be invariant with other architectures, as Armv7 NEON\n- does not support IEEE-754 strict mode. There are no pre-built binaries for\n- these targets; support is included for library users targeting older\n- Android and iOS devices.\n+ * **Feature:** Armv8 32-bit builds with NEON are now supported, with\n+ out-of-the-box support for Arm Linux soft-float and hard-float ABIs. There\n+ are no pre-built binaries for these targets; support is included for\n+ library users targeting older 32-bit Android and iOS devices.\n* **Feature:** A compressor mode for encoding HDR textures that have been\nencoded into LDR RGBM wrapper format is now supported. Note that this\nencoding has some strong recomendations for how the RGBM encoding is\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Arm 32-bit builds are really Armv8 A32 so rename
61,745
12.03.2021 22:17:54
0
b83b2134a6b9b5a2dead1591ad5307b4fc8bdcc6
Move instrinsic to A32 clang only
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_neon_armv7_4.h", "new_path": "Source/astcenc_vecmathlib_neon_armv7_4.h", "diff": "@@ -67,6 +67,20 @@ ASTCENC_SIMD_INLINE float32x4_t vminnmq_f32(float32x4_t a, float32x4_t b)\nreturn vminq_f32(a, b);\n}\n+/**\n+ * @brief Return a float rounded to the nearest integer value.\n+ */\n+ASTCENC_SIMD_INLINE float32x4_t vrndnq_f32(float32x4_t a)\n+{\n+ assert( std::fegetround() == FE_TONEAREST);\n+ float a0 = std::nearbyintf(vgetq_lane_f32(a, 0));\n+ float a1 = std::nearbyintf(vgetq_lane_f32(a, 1));\n+ float a2 = std::nearbyintf(vgetq_lane_f32(a, 2));\n+ float a3 = std::nearbyintf(vgetq_lane_f32(a, 3));\n+ float32x4_t c { a0, a1, a2, a3 };\n+ return c;\n+}\n+\n#endif\n/**\n@@ -130,20 +144,6 @@ ASTCENC_SIMD_INLINE float32x4_t vsqrtq_f32(float32x4_t a)\nreturn c;\n}\n-/**\n- * @brief Return a float rounded to the nearest integer value.\n- */\n-ASTCENC_SIMD_INLINE float32x4_t vrndnq_f32(float32x4_t a)\n-{\n- assert( std::fegetround() == FE_TONEAREST);\n- float a0 = std::nearbyintf(vgetq_lane_f32(a, 0));\n- float a1 = std::nearbyintf(vgetq_lane_f32(a, 1));\n- float a2 = std::nearbyintf(vgetq_lane_f32(a, 2));\n- float a3 = std::nearbyintf(vgetq_lane_f32(a, 3));\n- float32x4_t c { a0, a1, a2, a3 };\n- return c;\n-}\n-\n/**\n* @brief Vector by vector division.\n*/\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Move instrinsic to A32 clang only
61,745
15.03.2021 08:21:24
0
f919eb19b0178f4f7265f6a077193b6a4d0c9113
Remove obsolete comment in Doxygen
[ { "change_type": "MODIFY", "old_path": "Source/astcenc.h", "new_path": "Source/astcenc.h", "diff": "@@ -693,8 +693,7 @@ ASTCENC_PUBLIC astcenc_error astcenc_config_init(\n* be set when creating ay context.\n*\n* @param[in] config Codec config.\n- * @param thread_count Thread count to configure for. Decompress-only\n- * contexts must have a thread_count of 1.\n+ * @param thread_count Thread count to configure for.\n* @param[out] context Location to store an opaque context pointer.\n*\n* @return ASTCENC_SUCCESS on success, or an error if context creation failed.\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Remove obsolete comment in Doxygen
61,756
15.03.2021 02:47:36
25,200
723a9a6890e7b421c30477cfd5e6f97a6483533b
Ensure bm percentile_always and percentile_hit are initialized
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_block_sizes2.cpp", "new_path": "Source/astcenc_block_sizes2.cpp", "diff": "@@ -802,6 +802,11 @@ static void construct_block_size_descriptor_2d(\nbsd.block_modes[packed_idx].percentile_hit = true;\nbsd.decimation_modes[decimation_mode].percentile_hit = true;\n}\n+ else\n+ {\n+ bsd.block_modes[packed_idx].percentile_always = false;\n+ bsd.block_modes[packed_idx].percentile_hit = false;\n+ }\n#endif\nbsd.block_modes[packed_idx].decimation_mode = decimation_mode;\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Ensure bm percentile_always and percentile_hit are initialized (#239)
61,750
15.03.2021 14:03:05
0
838811796db4d40e2b6e7289e058c7482ec3e93f
Arm CI fixes
[ { "change_type": "MODIFY", "old_path": "jenkins/release.Jenkinsfile", "new_path": "jenkins/release.Jenkinsfile", "diff": "@@ -356,6 +356,7 @@ spec:\n}\ndir('upload/windows-x64') {\nunstash 'astcenc-windows-x64'\n+ dir('signing') {\ncheckout changelog: false,\npoll: false,\nscm: [$class: 'GitSCM',\n@@ -363,7 +364,9 @@ spec:\ndoGenerateSubmoduleConfigurations: false,\nextensions: [],\nsubmoduleCfg: [],\n- userRemoteConfigs: [[credentialsId: 'gerrit-jenkins', url: 'ssh://eu-gerrit-1.euhpc.arm.com:29418/Hive/shared/signing']]]\n+ userRemoteConfigs: [[credentialsId: 'gerrit-jenkins-ssh',\n+ url: 'ssh://mirror.eu-west-1.gerrit-eu01.aws.arm.com:29418/Hive/shared/signing']]]\n+ }\nwithCredentials([usernamePassword(credentialsId: 'win-signing',\nusernameVariable: 'USERNAME',\npasswordVariable: 'PASSWORD')]) {\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Arm CI fixes (#240)
61,745
17.03.2021 17:43:45
0
33bf0d857c511a0e68c020c3667808ff713e9209
Prepare for a 2.5 stable build
[ { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel_help.cpp", "new_path": "Source/astcenccli_toplevel_help.cpp", "diff": "#include \"astcenccli_internal.h\"\nstatic const char *astcenc_copyright_string =\n-R\"(astcenc v2.5-develop, %u-bit %s%s\n+R\"(astcenc v2.5, %u-bit %s%s\nCopyright 2011-2021 Arm Limited, all rights reserved\n)\";\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Prepare for a 2.5 stable build
61,745
18.03.2021 15:38:44
0
ba930e3c647973ca863c66ab5a60ace09d376998
Cleanup README for 2.5
[ { "change_type": "MODIFY", "old_path": "Docs/Roadmap.md", "new_path": "Docs/Roadmap.md", "diff": "@@ -7,8 +7,6 @@ most of the engineering work here is done by volunteers.\n## astcenc 3.0\nThe next milestone for astcenc will be a new major release, version 3.0.\n-Objective is to have this release around SIGGRAPH (start of August 2021), which\n-is one year after the 2.0 release.\nThe 2.x series has seen many changes to both the image quality, where we've\ntraded off quality to gain performance, and the core codec API. Now that we've\n@@ -33,8 +31,6 @@ out for any given bitrate, especially for non-color data such as normal maps\nand PBR material textures. We'd like to produce a short training course or\nvideo series explaining the format, the compressor, and how to use them.\n-This should align with the 3.0 release, so we can release both together.\n-\n## Normal maps and HDR texture performance\nThe current codec disables PSNR thresholds for both normal maps and HDR\n@@ -44,17 +40,6 @@ significantly slower than color LDR textures, and it feels like we should be\nable to come up with a criteria to exit \"easy blocks\" faster. Simple linear\nPSNR may not be a good choice, but _something_ should be possible.\n-This is a quality change, so we'd like to get this changed done before 3.0.\n-\n-## Compression effort level\n-\n-Today we have a set of distinct quality profiles (fast, medium, etc) which\n-have relatively large gaps between them in terms of quality and performance.\n-We'd like to expose a more granular \"effort level\", which would give users more\n-control over the quality-vs-time tradeoff. Existing presets would remain,\n-mapping to specific effort levels.\n-\n-This is an API change, so we'd like to get this changed done before 3.0.\n## Command line front-end implementation\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Cleanup README for 2.5
61,745
19.03.2021 22:06:37
0
eaaa9d1c4c4e5bee822185050ec428ecc3ef797f
Add += operator for vfloat4 class
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_averages_and_directions.cpp", "new_path": "Source/astcenc_averages_and_directions.cpp", "diff": "@@ -84,16 +84,16 @@ void compute_avgs_and_dirs_4_comp(\nvfloat4 zero = vfloat4::zero();\nvmask4 tdm0 = vfloat4(texel_datum.lane<0>()) > zero;\n- sum_xp = sum_xp + select(zero, texel_datum, tdm0);\n+ sum_xp += select(zero, texel_datum, tdm0);\nvmask4 tdm1 = vfloat4(texel_datum.lane<1>()) > zero;\n- sum_yp = sum_yp + select(zero, texel_datum, tdm1);\n+ sum_yp += select(zero, texel_datum, tdm1);\nvmask4 tdm2 = vfloat4(texel_datum.lane<2>()) > zero;\n- sum_zp = sum_zp + select(zero, texel_datum, tdm2);\n+ sum_zp += select(zero, texel_datum, tdm2);\nvmask4 tdm3 = vfloat4(texel_datum.lane<3>()) > zero;\n- sum_wp = sum_wp + select(zero, texel_datum, tdm3);\n+ sum_wp += select(zero, texel_datum, tdm3);\n}\nfloat prod_xp = dot_s(sum_xp, sum_xp);\n@@ -209,13 +209,13 @@ void compute_avgs_and_dirs_3_comp(\nvfloat4 zero = vfloat4::zero();\nvmask4 tdm0 = vfloat4(texel_datum.lane<0>()) > zero;\n- sum_xp = sum_xp + select(zero, texel_datum, tdm0);\n+ sum_xp += select(zero, texel_datum, tdm0);\nvmask4 tdm1 = vfloat4(texel_datum.lane<1>()) > zero;\n- sum_yp = sum_yp + select(zero, texel_datum, tdm1);\n+ sum_yp += select(zero, texel_datum, tdm1);\nvmask4 tdm2 = vfloat4(texel_datum.lane<2>()) > zero;\n- sum_zp = sum_zp + select(zero, texel_datum, tdm2);\n+ sum_zp += select(zero, texel_datum, tdm2);\n}\nfloat prod_xp = dot3_s(sum_xp, sum_xp);\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_common_4.h", "new_path": "Source/astcenc_vecmathlib_common_4.h", "diff": "@@ -135,6 +135,12 @@ ASTCENC_SIMD_INLINE void print(vint4 a)\n// vfloat4 operators and functions\n// ============================================================================\n+ASTCENC_SIMD_INLINE vfloat4& operator+=(vfloat4& a, const vfloat4& b)\n+{\n+ a = a + b;\n+ return a;\n+}\n+\n/**\n* @brief Overload: vector by scalar addition.\n*/\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add += operator for vfloat4 class
61,745
20.03.2021 16:54:40
0
5834ef436505ce173a4b771c5354220a95c02725
Retune to boost quality of -fast by ~0.2dB
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_entry.cpp", "new_path": "Source/astcenc_entry.cpp", "diff": "@@ -115,7 +115,7 @@ static const std::array<astcenc_preset_config, 5> preset_configs {{\n4, 2, 25, 1, 1, 75, 53, 1.0f, 1.0f, 1.0f, 0.5f\n}, {\nASTCENC_PRE_FAST,\n- 4, 4, 50, 1, 2, 85, 63, 2.5f, 2.5f, 1.0f, 0.5f\n+ 4, 4, 50, 2, 2, 85, 63, 3.5f, 3.5f, 1.0f, 0.5f\n}, {\nASTCENC_PRE_MEDIUM,\n4, 25, 75, 2, 2, 95, 70, 1.75f, 1.75f, 1.2f, 0.75f\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Retune to boost quality of -fast by ~0.2dB
61,745
20.03.2021 19:04:30
0
5b219c4d5c0d43626699aed1006dce1ed85390a6
Retune to boost quality of -fastest by up to 1.5 dB
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_entry.cpp", "new_path": "Source/astcenc_entry.cpp", "diff": "@@ -112,7 +112,7 @@ struct astcenc_preset_config {\nstatic const std::array<astcenc_preset_config, 5> preset_configs {{\n{\nASTCENC_PRE_FASTEST,\n- 4, 2, 25, 1, 1, 75, 53, 1.0f, 1.0f, 1.0f, 0.5f\n+ 4, 2, 30, 1, 1, 79, 57, 2.0f, 2.0f, 1.0f, 0.5f\n}, {\nASTCENC_PRE_FAST,\n4, 4, 50, 2, 2, 85, 63, 3.5f, 3.5f, 1.0f, 0.5f\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Retune to boost quality of -fastest by up to 1.5 dB
61,745
26.03.2021 07:36:19
0
1dd9eb7994ce60dec96f871e49f1fb1fa2a78aaf
Check for constant blocks before decoding info
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_entry.cpp", "new_path": "Source/astcenc_entry.cpp", "diff": "@@ -1028,15 +1028,6 @@ astcenc_error astcenc_get_block_info(\n// Fetch the appropriate partition and decimation tables\nblock_size_descriptor& bsd = *ctx->bsd;\n- int partition_count = scb.partition_count;\n- const partition_info* pt = get_partition_table(&bsd, partition_count);\n- pt += scb.partition_index;\n-\n- const int packed_index = bsd.block_mode_packed_index[scb.block_mode];\n- assert(packed_index >= 0 && packed_index < bsd.block_mode_count);\n- const block_mode& bm = bsd.block_modes[packed_index];\n- const decimation_table& dt = *bsd.decimation_tables[bm.decimation_mode];\n-\n// Start from a clean slate\nmemset(info, 0, sizeof(*info));\n@@ -1048,21 +1039,31 @@ astcenc_error astcenc_get_block_info(\ninfo->block_z = ctx->config.block_z;\ninfo->texel_count = bsd.texel_count;\n- // Check for error blocks first ...\n+ // Check for error blocks first - block_mode will be negative\ninfo->is_error_block = scb.error_block != 0;\nif (info->is_error_block)\n{\nreturn ASTCENC_SUCCESS;\n}\n- // Check for constant color blocks second ...\n+ // Check for constant color blocks second - block_mode will be negative\ninfo->is_constant_block = scb.block_mode < 0;\nif (info->is_constant_block)\n{\nreturn ASTCENC_SUCCESS;\n}\n- // Otherwise, handle a full block with partition payload ...\n+ // Otherwise, handle a full block with partition payload; values are known\n+ // to be valid once the two conditions above have been checked\n+ int partition_count = scb.partition_count;\n+ const partition_info* pt = get_partition_table(&bsd, partition_count);\n+ pt += scb.partition_index;\n+\n+ const int packed_index = bsd.block_mode_packed_index[scb.block_mode];\n+ assert(packed_index >= 0 && packed_index < bsd.block_mode_count);\n+ const block_mode& bm = bsd.block_modes[packed_index];\n+ const decimation_table& dt = *bsd.decimation_tables[bm.decimation_mode];\n+\ninfo->weight_x = dt.weight_x;\ninfo->weight_y = dt.weight_y;\ninfo->weight_z = dt.weight_z;\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Check for constant blocks before decoding info
61,745
28.03.2021 14:32:15
-3,600
46083bc877f15e81ccdd278a93154eab2585f19b
Make platform_isa_detection use compiler config
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_platform_isa_detection.cpp", "new_path": "Source/astcenc_platform_isa_detection.cpp", "diff": "// under the License.\n// ----------------------------------------------------------------------------\n-#if (ASTCENC_SSE > 0) || (ASTCENC_AVX > 0) || \\\n- (ASTCENC_POPCNT > 0) || (ASTCENC_F16C > 0)\n-\n/**\n* @brief Platform-specific function implementations.\n*\n* This module contains functions for querying the host extended ISA support.\n*/\n+// Include before the defines below to pick up any auto-setup based on compiler\n+// built-in config, if not being set explicitly by the build system\n#include \"astcenc_internal.h\"\n+#if (ASTCENC_SSE > 0) || (ASTCENC_AVX > 0) || \\\n+ (ASTCENC_POPCNT > 0) || (ASTCENC_F16C > 0)\n+\nstatic int g_cpu_has_sse41 = -1;\nstatic int g_cpu_has_avx2 = -1;\nstatic int g_cpu_has_popcnt = -1;\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Make platform_isa_detection use compiler config
61,745
30.03.2021 00:16:45
-3,600
7884c49cbe70b9268612664c45af3d9c33275729
Whitespace - wrap sone long lines
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_weight_align.cpp", "new_path": "Source/astcenc_weight_align.cpp", "diff": "@@ -367,9 +367,11 @@ void compute_angular_endpoints_1plane(\n}\nint samplecount = bsd->decimation_tables[i]->weight_count;\n- compute_angular_endpoints_for_quant_levels(samplecount,\n+ compute_angular_endpoints_for_quant_levels(\n+ samplecount,\ndecimated_quantized_weights + i * MAX_WEIGHTS_PER_BLOCK,\n- decimated_weights + i * MAX_WEIGHTS_PER_BLOCK, dm.maxprec_1plane, low_values[i], high_values[i]);\n+ decimated_weights + i * MAX_WEIGHTS_PER_BLOCK,\n+ dm.maxprec_1plane, low_values[i], high_values[i]);\n}\nfor (int i = 0; i < bsd->block_mode_count; ++i)\n@@ -413,13 +415,17 @@ void compute_angular_endpoints_2planes(\nint samplecount = bsd->decimation_tables[i]->weight_count;\n- compute_angular_endpoints_for_quant_levels(samplecount,\n+ compute_angular_endpoints_for_quant_levels(\n+ samplecount,\ndecimated_quantized_weights + 2 * i * MAX_WEIGHTS_PER_BLOCK,\n- decimated_weights + 2 * i * MAX_WEIGHTS_PER_BLOCK, dm.maxprec_2planes, low_values1[i], high_values1[i]);\n+ decimated_weights + 2 * i * MAX_WEIGHTS_PER_BLOCK,\n+ dm.maxprec_2planes, low_values1[i], high_values1[i]);\n- compute_angular_endpoints_for_quant_levels(samplecount,\n+ compute_angular_endpoints_for_quant_levels(\n+ samplecount,\ndecimated_quantized_weights + (2 * i + 1) * MAX_WEIGHTS_PER_BLOCK,\n- decimated_weights + (2 * i + 1) * MAX_WEIGHTS_PER_BLOCK, dm.maxprec_2planes, low_values2[i], high_values2[i]);\n+ decimated_weights + (2 * i + 1) * MAX_WEIGHTS_PER_BLOCK,\n+ dm.maxprec_2planes, low_values2[i], high_values2[i]);\n}\nfor (int i = 0; i < bsd->block_mode_count; ++i)\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Whitespace - wrap sone long lines
61,745
30.03.2021 00:19:33
-3,600
233c0d776eac863e06c9becd23e1975b1b0668f9
Add static_assert on alignment check
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_entry.cpp", "new_path": "Source/astcenc_entry.cpp", "diff": "@@ -630,7 +630,9 @@ astcenc_error astcenc_context_alloc(\n}\nsize_t worksize = sizeof(compress_symbolic_block_buffers) * thread_count;\n- ctx->working_buffers = aligned_malloc<compress_symbolic_block_buffers>(worksize , 32);\n+ ctx->working_buffers = aligned_malloc<compress_symbolic_block_buffers>(worksize, ASTCENC_VECALIGN);\n+ static_assert((sizeof(compress_symbolic_block_buffers) % ASTCENC_VECALIGN) == 0,\n+ \"compress_symbolic_block_buffers size must be multiple of vector alignment\");\nif (!ctx->working_buffers)\n{\nterm_block_size_descriptor(bsd);\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add static_assert on alignment check
61,745
30.03.2021 01:01:35
-3,600
61644ae72a32afce726108478d63fd27b1836f73
Move decimated grid bilinear infill to function
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "diff": "@@ -752,30 +752,8 @@ float compute_error_of_weight_set(\nint clipped_texel_count = round_down_to_simd_multiple_vla(texel_count);\nfor (/* */; i < clipped_texel_count; i += ASTCENC_SIMD_WIDTH)\n{\n- // Load the bilinear filter texel weight indexes\n- vint weight_idx0 = vint(&(dt->texel_weights_4t[0][i]));\n- vint weight_idx1 = vint(&(dt->texel_weights_4t[1][i]));\n- vint weight_idx2 = vint(&(dt->texel_weights_4t[2][i]));\n- vint weight_idx3 = vint(&(dt->texel_weights_4t[3][i]));\n-\n- // Load the bilinear filter texel weights\n- vfloat weight_val0 = gatherf(weights, weight_idx0);\n- vfloat weight_val1 = gatherf(weights, weight_idx1);\n- vfloat weight_val2 = gatherf(weights, weight_idx2);\n- vfloat weight_val3 = gatherf(weights, weight_idx3);\n-\n- // Load the weight contributions for each texel\n- // TODO: Should we rename this dt->texel_weights_float field?\n- vfloat tex_weight_float0 = loada(&(dt->texel_weights_float_4t[0][i]));\n- vfloat tex_weight_float1 = loada(&(dt->texel_weights_float_4t[1][i]));\n- vfloat tex_weight_float2 = loada(&(dt->texel_weights_float_4t[2][i]));\n- vfloat tex_weight_float3 = loada(&(dt->texel_weights_float_4t[3][i]));\n-\n- // Compute the bilinear interpolation\n- vfloat current_values = (weight_val0 * tex_weight_float0 +\n- weight_val1 * tex_weight_float1) +\n- (weight_val2 * tex_weight_float2 +\n- weight_val3 * tex_weight_float3);\n+ // Compute the bilinear interpolation of the decimated weight grid\n+ vfloat current_values = bilinear_infill_vla(*dt, weights, i);\n// Compute the error between the computed value and the ideal weight\nvfloat actual_values = loada(&(eai->weights[i]));\n@@ -793,13 +771,7 @@ float compute_error_of_weight_set(\nalignas(16) float errorsum_tmp[4] { 0 };\nfor (/* */; i < texel_count; i++)\n{\n- // This isn't the ideal access pattern, but the cache lines are probably\n- // already in the cache due to the vector loop above, so go with it ...\n- float current_value = (weights[dt->texel_weights_4t[0][i]] * dt->texel_weights_float_4t[0][i] +\n- weights[dt->texel_weights_4t[1][i]] * dt->texel_weights_float_4t[1][i]) +\n- (weights[dt->texel_weights_4t[2][i]] * dt->texel_weights_float_4t[2][i] +\n- weights[dt->texel_weights_4t[3][i]] * dt->texel_weights_float_4t[3][i]);\n-\n+ float current_value = bilinear_infill(*dt, weights, i);\nfloat valuedif = current_value - eai->weights[i];\nfloat error = valuedif * valuedif * eai->weight_error_scale[i];\n@@ -949,37 +921,13 @@ void compute_ideal_weights_for_decimation_table(\nint clipped_texel_count = round_up_to_simd_multiple_vla(texel_count);\nfor (int i = 0; i < clipped_texel_count; i += ASTCENC_SIMD_WIDTH)\n{\n- vint texel_weights_0(dt.texel_weights_4t[0] + i);\n- vint texel_weights_1(dt.texel_weights_4t[1] + i);\n- vint texel_weights_2(dt.texel_weights_4t[2] + i);\n- vint texel_weights_3(dt.texel_weights_4t[3] + i);\n-\n- vfloat weight_set_0 = gatherf(weight_set, texel_weights_0);\n- vfloat weight_set_1 = gatherf(weight_set, texel_weights_1);\n- vfloat weight_set_2 = gatherf(weight_set, texel_weights_2);\n- vfloat weight_set_3 = gatherf(weight_set, texel_weights_3);\n-\n- vfloat texel_weights_float_0 = loada(dt.texel_weights_float_4t[0] + i);\n- vfloat texel_weights_float_1 = loada(dt.texel_weights_float_4t[1] + i);\n- vfloat texel_weights_float_2 = loada(dt.texel_weights_float_4t[2] + i);\n- vfloat texel_weights_float_3 = loada(dt.texel_weights_float_4t[3] + i);\n-\n- vfloat weight = (weight_set_0 * texel_weights_float_0\n- + weight_set_1 * texel_weights_float_1)\n- + (weight_set_2 * texel_weights_float_2\n- + weight_set_3 * texel_weights_float_3);\n-\n+ vfloat weight = bilinear_infill_vla(dt, weight_set, i);\nstorea(weight, infilled_weights + i);\n}\n#else\nfor (int i = 0; i < texel_count; i++)\n{\n- const uint8_t *texel_weights = dt.texel_weights_t4[i];\n- const float *texel_weights_float = dt.texel_weights_float_t4[i];\n- infilled_weights[i] = (weight_set[texel_weights[0]] * texel_weights_float[0]\n- + weight_set[texel_weights[1]] * texel_weights_float[1])\n- + (weight_set[texel_weights[2]] * texel_weights_float[2]\n- + weight_set[texel_weights[3]] * texel_weights_float[3]);\n+ infilled_weights[i] = bilinear_infill(dt, weight_set, i);\n}\n#endif\n@@ -1322,12 +1270,7 @@ void recompute_ideal_colors_2planes(\n// FIXME: move this calculation out to the color block.\nfloat ls_weight = hadd_rgb_s(color_weight);\n- const uint8_t *texel_weights = dt->texel_weights_t4[tix];\n- const float *texel_weights_float = dt->texel_weights_float_t4[tix];\n- float idx0 = (weight_set[texel_weights[0]] * texel_weights_float[0]\n- + weight_set[texel_weights[1]] * texel_weights_float[1])\n- + (weight_set[texel_weights[2]] * texel_weights_float[2]\n- + weight_set[texel_weights[3]] * texel_weights_float[3]);\n+ float idx0 = bilinear_infill(*dt, weight_set, tix);\nfloat om_idx0 = 1.0f - idx0;\nwmin1 = astc::min(idx0, wmin1);\n@@ -1357,10 +1300,7 @@ void recompute_ideal_colors_2planes(\nif (plane2_weight_set8)\n{\n- idx1 = (plane2_weight_set[texel_weights[0]] * texel_weights_float[0]\n- + plane2_weight_set[texel_weights[1]] * texel_weights_float[1])\n- + (plane2_weight_set[texel_weights[2]] * texel_weights_float[2]\n- + plane2_weight_set[texel_weights[3]] * texel_weights_float[3]);\n+ idx1 = bilinear_infill(*dt, plane2_weight_set, tix);\nom_idx1 = 1.0f - idx1;\nwmin2 = astc::min(idx1, wmin2);\n@@ -1643,13 +1583,7 @@ void recompute_ideal_colors_1plane(\n// FIXME: move this calculation out to the color block.\nfloat ls_weight = hadd_rgb_s(color_weight);\n-\n- const uint8_t *texel_weights = dt->texel_weights_t4[tix];\n- const float *texel_weights_float = dt->texel_weights_float_t4[tix];\n- float idx0 = (weight_set[texel_weights[0]] * texel_weights_float[0]\n- + weight_set[texel_weights[1]] * texel_weights_float[1])\n- + (weight_set[texel_weights[2]] * texel_weights_float[2]\n- + weight_set[texel_weights[3]] * texel_weights_float[3]);\n+ float idx0 = bilinear_infill(*dt, weight_set, tix);\nfloat om_idx0 = 1.0f - idx0;\nwmin1 = astc::min(idx0, wmin1);\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -1153,6 +1153,55 @@ void compute_quantized_weights_for_decimation_table(\nuint8_t* quantized_weight_set,\nint quant_level);\n+/*********************************\n+ Utilties for bilinear filtering\n+*********************************/\n+\n+/**\n+ * @brief Compute the infilled weight for a texel index in a decimated grid.\n+ */\n+static inline float bilinear_infill(\n+ const decimation_table& dt,\n+ const float* weights,\n+ int index\n+) {\n+ return (weights[dt.texel_weights_t4[index][0]] * dt.texel_weights_float_t4[index][0] +\n+ weights[dt.texel_weights_t4[index][1]] * dt.texel_weights_float_t4[index][1]) +\n+ (weights[dt.texel_weights_t4[index][2]] * dt.texel_weights_float_t4[index][2] +\n+ weights[dt.texel_weights_t4[index][3]] * dt.texel_weights_float_t4[index][3]);\n+}\n+\n+/**\n+ * @brief Compute the infilled weight for N texel indices in a decimated grid.\n+ */\n+static inline vfloat bilinear_infill_vla(\n+ const decimation_table& dt,\n+ const float* weights,\n+ int index\n+) {\n+ // Load the bilinear filter texel weight indexes in the decimated grid\n+ vint weight_idx0 = vint(dt.texel_weights_4t[0] + index);\n+ vint weight_idx1 = vint(dt.texel_weights_4t[1] + index);\n+ vint weight_idx2 = vint(dt.texel_weights_4t[2] + index);\n+ vint weight_idx3 = vint(dt.texel_weights_4t[3] + index);\n+\n+ // Load the bilinear filter weights from the decimated grid\n+ vfloat weight_val0 = gatherf(weights, weight_idx0);\n+ vfloat weight_val1 = gatherf(weights, weight_idx1);\n+ vfloat weight_val2 = gatherf(weights, weight_idx2);\n+ vfloat weight_val3 = gatherf(weights, weight_idx3);\n+\n+ // Load the weight contribution factors for each decimated weight\n+ vfloat tex_weight_float0 = loada(dt.texel_weights_float_4t[0] + index);\n+ vfloat tex_weight_float1 = loada(dt.texel_weights_float_4t[1] + index);\n+ vfloat tex_weight_float2 = loada(dt.texel_weights_float_4t[2] + index);\n+ vfloat tex_weight_float3 = loada(dt.texel_weights_float_4t[3] + index);\n+\n+ // Compute the bilinear interpolation to generate the per-texel weight\n+ return (weight_val0 * tex_weight_float0 + weight_val1 * tex_weight_float1) +\n+ (weight_val2 * tex_weight_float2 + weight_val3 * tex_weight_float3);\n+}\n+\nfloat compute_error_of_weight_set(\nconst endpoints_and_weights* eai,\nconst decimation_table* dt,\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Move decimated grid bilinear infill to function
61,745
30.03.2021 09:25:19
-3,600
9a85552f2afbc99c7c5934c569cd7e4a35937923
Standardize on "plane2_component" name
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -572,7 +572,7 @@ static float compress_symbolic_block_fixed_partition_2_planes(\nconst block_size_descriptor* bsd,\nint partition_count,\nint partition_index,\n- int separate_component,\n+ int plane2_component,\nconst imageblock* blk,\nconst error_weight_block* ewb,\nsymbolic_compressed_block& scb,\n@@ -590,7 +590,7 @@ static float compress_symbolic_block_fixed_partition_2_planes(\nendpoints_and_weights *ei2 = &tmpbuf->ei2;\nendpoints_and_weights *eix1 = tmpbuf->eix1;\nendpoints_and_weights *eix2 = tmpbuf->eix2;\n- compute_endpoints_and_ideal_weights_2_planes(bsd, pt, blk, ewb, separate_component, ei1, ei2);\n+ compute_endpoints_and_ideal_weights_2_planes(bsd, pt, blk, ewb, plane2_component, ei1, ei2);\n// next, compute ideal weights and endpoint colors for every decimation.\nconst decimation_table *const *dts = bsd->decimation_tables;\n@@ -650,14 +650,14 @@ static float compress_symbolic_block_fixed_partition_2_planes(\n}\nvfloat4 err_max(1e30f);\n- vmask4 err_mask = vint4::lane_id() == vint4(separate_component);\n+ vmask4 err_mask = vint4::lane_id() == vint4(plane2_component);\n- // Set the separate component to max error in ep1\n+ // Set the plane2 component to max error in ep1\nmin_ep1 = select(min_ep1, err_max, err_mask);\nfloat min_wt_cutoff1 = hmin_s(min_ep1);\n- // Set the minwt2 to the separate component min in ep2\n+ // Set the minwt2 to the plane2 component min in ep2\nfloat min_wt_cutoff2 = hmin_s(select(err_max, min_ep2, err_mask));\nfloat weight_low_value1[MAX_WEIGHT_MODES];\n@@ -748,10 +748,10 @@ static float compress_symbolic_block_fixed_partition_2_planes(\nint color_quant_level_mod[TUNE_MAX_TRIAL_CANDIDATES];\nendpoints epm;\n- merge_endpoints(&(ei1->ep), &(ei2->ep), separate_component, &epm);\n+ merge_endpoints(&(ei1->ep), &(ei2->ep), plane2_component, &epm);\ndetermine_optimal_set_of_endpoint_formats_to_use(\n- bsd, pt, blk, ewb, &epm, separate_component, qwt_bitcounts, qwt_errors,\n+ bsd, pt, blk, ewb, &epm, plane2_component, qwt_bitcounts, qwt_errors,\ntune_candidate_limit, partition_format_specifiers, quantized_weight,\ncolor_quant_level, color_quant_level_mod);\n@@ -792,7 +792,7 @@ static float compress_symbolic_block_fixed_partition_2_planes(\ntrace_add_data(\"weight_quant\", weight_quant_mode);\n// recompute the ideal color endpoints before storing them.\n- merge_endpoints(&(eix1[decimation_mode].ep), &(eix2[decimation_mode].ep), separate_component, &epm);\n+ merge_endpoints(&(eix1[decimation_mode].ep), &(eix2[decimation_mode].ep), plane2_component, &epm);\nvfloat4 rgbs_colors[4];\nvfloat4 rgbo_colors[4];\n@@ -803,7 +803,7 @@ static float compress_symbolic_block_fixed_partition_2_planes(\n{\nrecompute_ideal_colors_2planes(\nweight_quant_mode, &epm, rgbs_colors, rgbo_colors,\n- u8_weight1_src, u8_weight2_src, separate_component, pt, dt, blk, ewb);\n+ u8_weight1_src, u8_weight2_src, plane2_component, pt, dt, blk, ewb);\n// store the colors for the block\nfor (int j = 0; j < partition_count; j++)\n@@ -863,7 +863,7 @@ static float compress_symbolic_block_fixed_partition_2_planes(\nworkscb.partition_index = partition_index;\nworkscb.color_quant_level = workscb.color_formats_matched ? color_quant_level_mod[i] : color_quant_level[i];\nworkscb.block_mode = qw_bm.mode_index;\n- workscb.plane2_component = separate_component;\n+ workscb.plane2_component = plane2_component;\nworkscb.error_block = 0;\nif (workscb.color_quant_level < 4)\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_encoding_choice_error.cpp", "new_path": "Source/astcenc_encoding_choice_error.cpp", "diff": "void merge_endpoints(\nconst endpoints* ep1, // contains three of the color components\nconst endpoints* ep2, // contains the remaining color component\n- int separate_component,\n+ int plane2_component,\nendpoints* res\n) {\nint partition_count = ep1->partition_count;\n- vmask4 sep_mask = vint4::lane_id() == vint4(separate_component);\n+ vmask4 sep_mask = vint4::lane_id() == vint4(plane2_component);\nres->partition_count = partition_count;\npromise(partition_count > 0);\n@@ -154,7 +154,7 @@ void compute_encoding_choice_errors(\nconst imageblock* blk,\nconst partition_info* pt,\nconst error_weight_block* ewb,\n- int separate_component, // component that is separated out in 2-plane mode, -1 in 1-plane mode\n+ int plane2_component, // component that is separated out in 2-plane mode, -1 in 1-plane mode\nencoding_choice_errors* eci)\n{\nint partition_count = pt->partition_count;\n@@ -170,7 +170,7 @@ void compute_encoding_choice_errors(\ncompute_avgs_and_dirs_3_comp(pt, blk, ewb, 3, pms);\nendpoints ep;\n- if (separate_component == -1)\n+ if (plane2_component == -1)\n{\nendpoints_and_weights ei;\ncompute_endpoints_and_ideal_weights_1_plane(bsd, pt, blk, ewb, &ei);\n@@ -179,8 +179,8 @@ void compute_encoding_choice_errors(\nelse\n{\nendpoints_and_weights ei1, ei2;\n- compute_endpoints_and_ideal_weights_2_planes(bsd, pt, blk, ewb, separate_component, &ei1, &ei2);\n- merge_endpoints(&(ei1.ep), &(ei2.ep), separate_component, &ep);\n+ compute_endpoints_and_ideal_weights_2_planes(bsd, pt, blk, ewb, plane2_component, &ei1, &ei2);\n+ merge_endpoints(&(ei1.ep), &(ei2.ep), plane2_component, &ep);\n}\nfor (int i = 0; i < partition_count; i++)\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "diff": "@@ -649,14 +649,14 @@ void compute_endpoints_and_ideal_weights_2_planes(\nconst partition_info* pt,\nconst imageblock* blk,\nconst error_weight_block* ewb,\n- int separate_component,\n+ int plane2_component,\nendpoints_and_weights* ei1,\nendpoints_and_weights* ei2\n) {\nint uses_alpha = imageblock_uses_alpha(blk);\n- assert(separate_component < 4);\n- switch (separate_component)\n+ assert(plane2_component < 4);\n+ switch (plane2_component)\n{\ncase 0: // separate weights for red\nif (uses_alpha)\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -747,7 +747,7 @@ struct symbolic_compressed_block\nint color_formats[4]; // color format for each endpoint color pair.\nint color_formats_matched; // color format for all endpoint pairs are matched.\nint color_quant_level;\n- int plane2_component; // color component for the secondary plane of weights\n+ int plane2_component; // color component for second plane of weights\n// TODO: Under what circumstances is this ever more than 8 (4 pairs) colors\nint color_values[4][12]; // quantized endpoint color pairs.\n@@ -1116,9 +1116,9 @@ void compute_endpoints_and_ideal_weights_2_planes(\nconst partition_info* pt,\nconst imageblock* blk,\nconst error_weight_block* ewb,\n- int separate_component,\n- endpoints_and_weights* ei1, // primary plane weights\n- endpoints_and_weights* ei2); // secondary plane weights\n+ int plane2_component,\n+ endpoints_and_weights* ei1, // First weight plane\n+ endpoints_and_weights* ei2); // Second weight plane\n/**\n* @brief Compute the optimal weights for a decimation table.\n@@ -1210,7 +1210,8 @@ float compute_error_of_weight_set(\nvoid merge_endpoints(\nconst endpoints* ep1, // contains three of the color components\nconst endpoints* ep2, // contains the remaining color component\n- int separate_component, endpoints* res);\n+ int plane2_component,\n+ endpoints* res);\n// functions dealing with color endpoints\n@@ -1288,7 +1289,7 @@ void compute_encoding_choice_errors(\nconst imageblock* blk,\nconst partition_info* pt,\nconst error_weight_block* ewb,\n- int separate_component, // component that is separated out in 2-plane mode, -1 in 1-plane mode\n+ int plane2_component, // component that is separated out in 2-plane mode, -1 in 1-plane mode\nencoding_choice_errors* eci);\nvoid determine_optimal_set_of_endpoint_formats_to_use(\n@@ -1297,7 +1298,7 @@ void determine_optimal_set_of_endpoint_formats_to_use(\nconst imageblock* blk,\nconst error_weight_block* ewb,\nconst endpoints* ep,\n- int separate_component, // separate color component for 2-plane mode; -1 for single-plane mode\n+ int plane2_component, // separate color component for 2-plane mode; -1 for single-plane mode\n// bitcounts and errors computed for the various quantization methods\nconst int* qwt_bitcounts,\nconst float* qwt_errors,\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_pick_best_endpoint_format.cpp", "new_path": "Source/astcenc_pick_best_endpoint_format.cpp", "diff": "@@ -778,7 +778,7 @@ void determine_optimal_set_of_endpoint_formats_to_use(\nconst imageblock* blk,\nconst error_weight_block* ewb,\nconst endpoints* ep,\n- int separate_component, // separate color component for 2-plane mode; -1 for single-plane mode\n+ int plane2_component, // separate color component for 2-plane mode; -1 for single-plane mode\n// bitcounts and errors computed for the various quantization methods\nconst int* qwt_bitcounts,\nconst float* qwt_errors,\n@@ -798,7 +798,7 @@ void determine_optimal_set_of_endpoint_formats_to_use(\n// encoding choices (such as using luminance instead of RGB, discarding Alpha,\n// using RGB-scale in place of two separate RGB endpoints and so on)\nencoding_choice_errors eci[4];\n- compute_encoding_choice_errors(bsd, blk, pt, ewb, separate_component, eci);\n+ compute_encoding_choice_errors(bsd, blk, pt, ewb, plane2_component, eci);\n// for each partition, compute the error weights to apply for that partition.\npartition_metrics pms[4];\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Standardize on "plane2_component" name
61,745
30.03.2021 09:26:37
-3,600
2436c1b394259e307cae5a6ea7b0ed73cf67f6be
Set build version to 3.0-develop
[ { "change_type": "MODIFY", "old_path": "CMakeLists.txt", "new_path": "CMakeLists.txt", "diff": "@@ -20,7 +20,7 @@ cmake_minimum_required(VERSION 3.15)\ncmake_policy(SET CMP0069 NEW) # LTO support\ncmake_policy(SET CMP0091 NEW) # MSVC runtime support\n-project(astcenc VERSION 2.5.0)\n+project(astcenc VERSION 3.0.0)\n# Command line configuration\nfunction(printopt optName optVal optArch tgtArch)\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel_help.cpp", "new_path": "Source/astcenccli_toplevel_help.cpp", "diff": "#include \"astcenccli_internal.h\"\nstatic const char *astcenc_copyright_string =\n-R\"(astcenc v2.5, %u-bit %s%s\n+R\"(astcenc v3.0-develop, %u-bit %s%s\nCopyright 2011-2021 Arm Limited, all rights reserved\n)\";\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Set build version to 3.0-develop
61,745
30.03.2021 21:08:08
-3,600
63d343dc625ac597fd433b9088b8d31614d1c357
Add float2 operator+=
[ { "change_type": "MODIFY", "old_path": "Source/UnitTest/test_simd.cpp", "new_path": "Source/UnitTest/test_simd.cpp", "diff": "@@ -433,6 +433,27 @@ TEST(vfloat4, vadd)\nEXPECT_EQ(a.lane<3>(), 4.0f + 0.4f);\n}\n+/** @brief Test vfloat4 self-add. */\n+TEST(vfloat4, vselfadd1)\n+{\n+ vfloat4 a(1.0f, 2.0f, 3.0f, 4.0f);\n+ vfloat4 b(0.1f, 0.2f, 0.3f, 0.4f);\n+\n+ // Test increment by another variable\n+ a += b;\n+ EXPECT_EQ(a.lane<0>(), 1.0f + 0.1f);\n+ EXPECT_EQ(a.lane<1>(), 2.0f + 0.2f);\n+ EXPECT_EQ(a.lane<2>(), 3.0f + 0.3f);\n+ EXPECT_EQ(a.lane<3>(), 4.0f + 0.4f);\n+\n+ // Test increment by an expression\n+ a += b + b;\n+ EXPECT_NEAR(a.lane<0>(), 1.0f + 0.3f, 0.001f);\n+ EXPECT_NEAR(a.lane<1>(), 2.0f + 0.6f, 0.001f);\n+ EXPECT_NEAR(a.lane<2>(), 3.0f + 0.9f, 0.001f);\n+ EXPECT_NEAR(a.lane<3>(), 4.0f + 1.2f, 0.001f);\n+}\n+\n/** @brief Test vfloat4 sub. */\nTEST(vfloat4, vsub)\n{\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_mathlib.h", "new_path": "Source/astcenc_mathlib.h", "diff": "@@ -451,6 +451,12 @@ vtype2<T> operator+(vtype2<T> p, vtype2<T> q) {\nreturn vtype2<T> { p.r + q.r, p.g + q.g };\n}\n+template <typename T>\n+vtype2<T>& operator+=(vtype2<T>& p, const vtype2<T>& q) {\n+ p = p + q;\n+ return p;\n+}\n+\n// Vector by vector subtraction\ntemplate <typename T>\nvtype2<T> operator-(vtype2<T> p, vtype2<T> q) {\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_common_4.h", "new_path": "Source/astcenc_vecmathlib_common_4.h", "diff": "@@ -135,6 +135,9 @@ ASTCENC_SIMD_INLINE void print(vint4 a)\n// vfloat4 operators and functions\n// ============================================================================\n+/**\n+ * @brief Overload: vector by vector incremental addition.\n+ */\nASTCENC_SIMD_INLINE vfloat4& operator+=(vfloat4& a, const vfloat4& b)\n{\na = a + b;\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add float2 operator+=
61,745
30.03.2021 21:15:17
-3,600
c25e83a68b8f391361041e7ba544831f046a37e8
Style - use += when possible for accumulators
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_averages_and_directions.cpp", "new_path": "Source/astcenc_averages_and_directions.cpp", "diff": "@@ -63,7 +63,7 @@ void compute_avgs_and_dirs_4_comp(\nvfloat4 texel_datum = blk->texel(iwt);\npartition_weight += weight;\n- base_sum = base_sum + texel_datum * weight;\n+ base_sum += texel_datum * weight;\n}\nvfloat4 average = base_sum * (1.0f / astc::max(partition_weight, 1e-7f));\n@@ -184,7 +184,7 @@ void compute_avgs_and_dirs_3_comp(\n0.0f);\npartition_weight += weight;\n- base_sum = base_sum + texel_datum * weight;\n+ base_sum += texel_datum * weight;\n}\nvfloat4 csf = pm[partition].color_scale;\n@@ -299,7 +299,7 @@ void compute_avgs_and_dirs_2_comp(\nfloat2 texel_datum = float2(data_vr[iwt], data_vg[iwt]) * weight;\npartition_weight += weight;\n- base_sum = base_sum + texel_datum;\n+ base_sum += texel_datum;\n}\nfloat2 csf = color_scalefactors[partition];\n@@ -319,12 +319,12 @@ void compute_avgs_and_dirs_2_comp(\nif (texel_datum.r > 0.0f)\n{\n- sum_xp = sum_xp + texel_datum;\n+ sum_xp += texel_datum;\n}\nif (texel_datum.g > 0.0f)\n{\n- sum_yp = sum_yp + texel_datum;\n+ sum_yp += texel_datum;\n}\n}\n@@ -462,7 +462,6 @@ void compute_error_squared_rgba(\nsamec_loparamv = min(samec_param, samec_loparamv);\nsamec_hiparamv = max(samec_param, samec_hiparamv);\n-\nvfloat samec_dist0 = samec_param * l_samec_bis0 - data_r;\nvfloat samec_dist1 = samec_param * l_samec_bis1 - data_g;\nvfloat samec_dist2 = samec_param * l_samec_bis2 - data_b;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "diff": "@@ -1264,9 +1264,6 @@ void recompute_ideal_colors_2planes(\nvfloat4 rgba = blk->texel(tix);\nvfloat4 color_weight(ewb->texel_weight_r[tix], ewb->texel_weight_g[tix], ewb->texel_weight_b[tix], ewb->texel_weight_a[tix]);\n- vfloat4 color_weight3 = color_weight.swz<0, 1, 2>();\n- vfloat4 rgb = rgba.swz<0, 1, 2>();\n-\n// FIXME: move this calculation out to the color block.\nfloat ls_weight = hadd_rgb_s(color_weight);\n@@ -1276,7 +1273,7 @@ void recompute_ideal_colors_2planes(\nwmin1 = astc::min(idx0, wmin1);\nwmax1 = astc::max(idx0, wmax1);\n- float scale = dot3_s(scale_direction, rgb);\n+ float scale = dot3_s(scale_direction, rgba);\nscale_min = astc::min(scale, scale_min);\nscale_max = astc::max(scale, scale_max);\n@@ -1320,19 +1317,17 @@ void recompute_ideal_colors_2planes(\n(plane2_component == 2) ? idx1 : idx0,\n(plane2_component == 3) ? idx1 : idx0);\n- vfloat4 color_idx3 = color_idx.swz<0, 1, 2>();\n-\nvfloat4 cwprod = color_weight * rgba;\nvfloat4 cwiprod = cwprod * color_idx;\ncolor_vec_y = color_vec_y + cwiprod;\ncolor_vec_x = color_vec_x + (cwprod - cwiprod);\n- scale_vec = scale_vec + float2(om_idx0, idx0) * (ls_weight * scale);\n+ scale_vec += float2(om_idx0, idx0) * (ls_weight * scale);\n- weight_weight_sum = weight_weight_sum + (color_weight3 * color_idx3);\n+ weight_weight_sum += (color_weight * color_idx);\n- psum += dot3_s(color_weight3 * color_idx3, color_idx3);\n+ psum += dot3_s(color_weight * color_idx, color_idx);\n}\n// calculations specific to mode #7, the HDR RGB-scale mode.\n@@ -1578,9 +1573,6 @@ void recompute_ideal_colors_1plane(\nvfloat4 rgba = blk->texel(tix);\nvfloat4 color_weight(ewb->texel_weight_r[tix], ewb->texel_weight_g[tix], ewb->texel_weight_b[tix], ewb->texel_weight_a[tix]);\n- vfloat4 color_weight3 = color_weight.swz<0, 1, 2>();\n- vfloat4 rgb = rgba.swz<0, 1, 2>();\n-\n// FIXME: move this calculation out to the color block.\nfloat ls_weight = hadd_rgb_s(color_weight);\nfloat idx0 = bilinear_infill(*dt, weight_set, tix);\n@@ -1589,7 +1581,7 @@ void recompute_ideal_colors_1plane(\nwmin1 = astc::min(idx0, wmin1);\nwmax1 = astc::max(idx0, wmax1);\n- float scale = dot3_s(scale_direction, rgb);\n+ float scale = dot3_s(scale_direction, rgba);\nscale_min = astc::min(scale, scale_min);\nscale_max = astc::max(scale, scale_max);\n@@ -1609,19 +1601,17 @@ void recompute_ideal_colors_1plane(\nlmrs_sum = lmrs_sum + lmrs;\nvfloat4 color_idx(idx0);\n- vfloat4 color_idx3(idx0);\n-\nvfloat4 cwprod = color_weight * rgba;\nvfloat4 cwiprod = cwprod * color_idx;\ncolor_vec_y = color_vec_y + cwiprod;\ncolor_vec_x = color_vec_x + (cwprod - cwiprod);\n- scale_vec = scale_vec + float2(om_idx0, idx0) * (ls_weight * scale);\n+ scale_vec += (float2(om_idx0, idx0) * (ls_weight * scale));\n- weight_weight_sum = weight_weight_sum + (color_weight3 * color_idx3);\n+ weight_weight_sum += color_weight * color_idx;\n- psum += dot3_s(color_weight3 * color_idx3, color_idx3);\n+ psum += dot3_s(color_weight * color_idx, color_idx);\n}\n// calculations specific to mode #7, the HDR RGB-scale mode.\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_pick_best_endpoint_format.cpp", "new_path": "Source/astcenc_pick_best_endpoint_format.cpp", "diff": "@@ -102,8 +102,7 @@ static void compute_color_error_for_every_integer_count_and_quant_level(\n(ep0_range_error_high * ep0_range_error_high) +\n(ep1_range_error_high * ep1_range_error_high);\n- float rgb_range_error = dot3_s(sum_range_error.swz<0, 1, 2>(),\n- error_weight.swz<0, 1, 2>())\n+ float rgb_range_error = dot3_s(sum_range_error, error_weight)\n* 0.5f * static_cast<float>(partition_size);\nfloat alpha_range_error = sum_range_error.lane<3>() * error_weight.lane<3>()\n* 0.5f * static_cast<float>(partition_size);\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_error_metrics.cpp", "new_path": "Source/astcenccli_error_metrics.cpp", "diff": "@@ -36,19 +36,10 @@ class kahan_accum4\n{\npublic:\n/** The running sum. */\n- vfloat4 sum;\n+ vfloat4 sum { vfloat4::zero() };\n/** The current compensation factor. */\n- vfloat4 comp;\n-\n- /**\n- * @brief Create a new Kahan accumulator\n- */\n- kahan_accum4()\n- {\n- sum = vfloat4::zero();\n- comp = vfloat4::zero();\n- }\n+ vfloat4 comp { vfloat4::zero() };\n};\n/**\n@@ -365,9 +356,14 @@ void compute_error_metrics(\nfloat mpsnr;\nif (mpsnr_num == 0.0f)\n+ {\nmpsnr = 999.0f;\n+ }\nelse\n+ {\nmpsnr = 10.0f * log10f(mpsnr_denom / mpsnr_num);\n+ }\n+\nprintf(\" mPSNR (RGB): %9.4f dB (fstops %+d to %+d)\\n\",\n(double)mpsnr, fstop_lo, fstop_hi);\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Style - use += when possible for accumulators
61,745
31.03.2021 00:11:49
-3,600
537b514285ad29a354090e6e75f99cc06744ae88
Clean up kmeans partitioning
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_kmeans_partitioning.cpp", "new_path": "Source/astcenc_kmeans_partitioning.cpp", "diff": "#include \"astcenc_internal.h\"\n-// for k++ means, we need pseudo-random numbers, however using random numbers\n-// directly results in unreproducible encoding results. As such, we will\n-// instead just supply a handful of numbers from random.org, and apply an\n-// algorithm similar to XKCD #221. (http://xkcd.com/221/)\n-\n-// cluster the texels using the k++ means clustering initialization algorithm.\n+/**\n+ * @brief Pick some initital kmeans cluster centers.\n+ */\nstatic void kmeans_init(\n- int texels_per_block,\n+ const imageblock& blk,\n+ int texel_count,\nint partition_count,\n- const imageblock* blk,\n- vfloat4* cluster_centers\n+ vfloat4 cluster_centers[4]\n) {\n- int cluster_center_samples[4];\n- // pick a random sample as first center-point.\n- cluster_center_samples[0] = 145897 /* number from random.org */ % texels_per_block;\n- int samples_selected = 1;\n+ promise(texel_count > 0);\n+ promise(partition_count > 0);\n+ int clusters_selected = 0;\nfloat distances[MAX_TEXELS_PER_BLOCK];\n- // compute the distance to the first point.\n- int sample = cluster_center_samples[0];\n- vfloat4 center_color = blk->texel(sample);\n+ // Pick a random sample as first cluster center; 145897 from random.org\n+ int sample = 145897 % texel_count;\n+ vfloat4 center_color = blk.texel(sample);\n+ cluster_centers[clusters_selected] = center_color;\n+ clusters_selected++;\n+ // Compute the distance to the first cluster center\nfloat distance_sum = 0.0f;\n- for (int i = 0; i < texels_per_block; i++)\n+ for (int i = 0; i < texel_count; i++)\n{\n- vfloat4 color = blk->texel(i);\n+ vfloat4 color = blk.texel(i);\nvfloat4 diff = color - center_color;\nfloat distance = dot_s(diff, diff);\ndistance_sum += distance;\ndistances[i] = distance;\n}\n- // more numbers from random.org\n- float cluster_cutoffs[25] = {\n- 0.952312f, 0.206893f, 0.835984f, 0.507813f, 0.466170f,\n- 0.872331f, 0.488028f, 0.866394f, 0.363093f, 0.467905f,\n- 0.812967f, 0.626220f, 0.932770f, 0.275454f, 0.832020f,\n- 0.362217f, 0.318558f, 0.240113f, 0.009190f, 0.983995f,\n- 0.566812f, 0.347661f, 0.731960f, 0.156391f, 0.297786f\n+ // More numbers from random.org for weighted-random center selection\n+ const float cluster_cutoffs[9] = {\n+ 0.626220f, 0.932770f, 0.275454f,\n+ 0.318558f, 0.240113f, 0.009190f,\n+ 0.347661f, 0.731960f, 0.156391f\n};\n- while (1)\n+ int cutoff = (clusters_selected - 1) + 3 * (partition_count - 2);\n+\n+ // Pick the remaining samples as needed\n+ while (true)\n{\n- // pick a point in a weighted-random fashion.\n+ // Pick the next center in a weighted-random fashion.\nfloat summa = 0.0f;\n- float distance_cutoff = distance_sum * cluster_cutoffs[samples_selected + 5 * partition_count];\n- for (sample = 0; sample < texels_per_block; sample++)\n+ float distance_cutoff = distance_sum * cluster_cutoffs[cutoff++];\n+ for (sample = 0; sample < texel_count; sample++)\n{\nsumma += distances[sample];\nif (summa >= distance_cutoff)\n@@ -87,25 +87,21 @@ static void kmeans_init(\n}\n}\n- if (sample >= texels_per_block)\n- {\n- sample = texels_per_block - 1;\n- }\n+ // Clamp to a valid range and store the selected cluster center\n+ sample = astc::min(sample, texel_count - 1);\n- cluster_center_samples[samples_selected] = sample;\n- samples_selected++;\n- if (samples_selected >= partition_count)\n+ center_color = blk.texel(sample);\n+ cluster_centers[clusters_selected++] = center_color;\n+ if (clusters_selected >= partition_count)\n{\nbreak;\n}\n- // update the distances with the new point.\n- center_color = blk->texel(sample);\n-\n+ // Compute the distance to the new cluster center, keep the min dist\ndistance_sum = 0.0f;\n- for (int i = 0; i < texels_per_block; i++)\n+ for (int i = 0; i < texel_count; i++)\n{\n- vfloat4 color = blk->texel(i);\n+ vfloat4 color = blk.texel(i);\nvfloat4 diff = color - center_color;\nfloat distance = dot_s(diff, diff);\ndistance = astc::min(distance, distances[i]);\n@@ -113,67 +109,50 @@ static void kmeans_init(\ndistances[i] = distance;\n}\n}\n-\n- // finally, gather up the results.\n- for (int i = 0; i < partition_count; i++)\n- {\n- int center_sample = cluster_center_samples[i];\n- cluster_centers[i] = blk->texel(center_sample);\n- }\n}\n-// basic K-means clustering: given a set of cluster centers,\n-// assign each texel to a partition\n+/**\n+ * @brief Assign texels to clusters, based on a set of chosen center points.\n+ */\nstatic void kmeans_assign(\n- int texels_per_block,\n+ const imageblock& blk,\n+ int texel_count,\nint partition_count,\n- const imageblock* blk,\n- const vfloat4* cluster_centers,\n- int* partition_of_texel\n+ const vfloat4 cluster_centers[4],\n+ int partition_of_texel[MAX_TEXELS_PER_BLOCK]\n) {\n- float distances[MAX_TEXELS_PER_BLOCK];\n+ promise(texel_count > 0);\n+ promise(partition_count > 0);\n- int partition_texel_count[4];\n+ int partition_texel_count[4] { 0 };\n- partition_texel_count[0] = texels_per_block;\n- for (int i = 1; i < partition_count; i++)\n+ // Find the best partition for every texel\n+ for (int i = 0; i < texel_count; i++)\n{\n- partition_texel_count[i] = 0;\n- }\n+ float best_distance = std::numeric_limits<float>::max();\n+ int best_partition = -1;\n- for (int i = 0; i < texels_per_block; i++)\n+ vfloat4 color = blk.texel(i);\n+ for (int j = 0; j < partition_count; j++)\n{\n- vfloat4 color = blk->texel(i);\n- vfloat4 diff = color - cluster_centers[0];\n+ vfloat4 diff = color - cluster_centers[j];\nfloat distance = dot_s(diff, diff);\n- distances[i] = distance;\n- partition_of_texel[i] = 0;\n- }\n-\n- for (int j = 1; j < partition_count; j++)\n+ if (distance < best_distance)\n{\n- vfloat4 center_color = cluster_centers[j];\n-\n- for (int i = 0; i < texels_per_block; i++)\n- {\n- vfloat4 color = blk->texel(i);\n- vfloat4 diff = color - center_color;\n- float distance = dot_s(diff, diff);\n- if (distance < distances[i])\n- {\n- distances[i] = distance;\n- partition_texel_count[partition_of_texel[i]]--;\n- partition_texel_count[j]++;\n- partition_of_texel[i] = j;\n+ best_distance = distance;\n+ best_partition = j;\n}\n}\n+\n+ partition_of_texel[i] = best_partition;\n+ partition_texel_count[best_partition]++;\n}\n- // it is possible to get a situation where one of the partitions ends up\n- // without any texels. In this case, we assign texel N to partition N;\n- // this is silly, but ensures that every partition retains at least one texel.\n- // Reassigning a texel in this manner may cause another partition to go empty,\n- // so if we actually did a reassignment, we run the whole loop over again.\n+ // It is possible to get a situation where a partition ends up without any\n+ // texels. In this case, we assign texel N to partition N. This is silly,\n+ // but ensures that every partition retains at least one texel. Reassigning\n+ // a texel in this manner may cause another partition to go empty, so if we\n+ // actually did a reassignment, we run the whole loop over again.\nint problem_case;\ndo\n{\n@@ -188,44 +167,50 @@ static void kmeans_assign(\nproblem_case = 1;\n}\n}\n- }\n- while (problem_case != 0);\n+ } while (problem_case != 0);\n}\n-// basic k-means clustering: given a set of cluster assignments\n-// for the texels, find the center position of each cluster.\n+/**\n+ * @brief Compute new cluster centers based on their center of gravity.\n+ */\nstatic void kmeans_update(\n- int texels_per_block,\n+ const imageblock& blk,\n+ int texel_count,\nint partition_count,\n- const imageblock* blk,\n- const int* partition_of_texel,\n- vfloat4* cluster_centers\n+ vfloat4 cluster_centers[4],\n+ const int partition_of_texel[MAX_TEXELS_PER_BLOCK]\n) {\n- vfloat4 color_sum[4];\n- int weight_sum[4];\n+ promise(texel_count > 0);\n+ promise(partition_count > 0);\n+\n+ vfloat4 color_sum[4] {\n+ vfloat4::zero(),\n+ vfloat4::zero(),\n+ vfloat4::zero(),\n+ vfloat4::zero()\n+ };\n- for (int i = 0; i < partition_count; i++)\n- {\n- color_sum[i] = vfloat4::zero();\n- weight_sum[i] = 0;\n- }\n+ int partition_texel_count[4] { 0 };\n- // first, find the center-of-gravity in each cluster\n- for (int i = 0; i < texels_per_block; i++)\n+ // Find the center-of-gravity in each cluster\n+ for (int i = 0; i < texel_count; i++)\n{\n- vfloat4 color = blk->texel(i);\n- int part = partition_of_texel[i];\n- color_sum[part] = color_sum[part] + color;\n- weight_sum[part]++;\n+ int partition = partition_of_texel[i];\n+ color_sum[partition] += blk.texel(i);;\n+ partition_texel_count[partition]++;\n}\n+ // Set the center of gravity to be the new cluster center\nfor (int i = 0; i < partition_count; i++)\n{\n- cluster_centers[i] = color_sum[i] * (1.0f / static_cast<float>(weight_sum[i]));\n+ float scale = 1.0f / static_cast<float>(partition_texel_count[i]);\n+ cluster_centers[i] = color_sum[i] * scale;\n}\n}\n-// compute the bit-mismatch for a partitioning in 2-partition mode\n+/**\n+ * @brief Compute bit-mismatch for partitioning in 2-partition mode.\n+ */\nstatic inline int partition_mismatch2(\nuint64_t a0,\nuint64_t a1,\n@@ -237,7 +222,9 @@ static inline int partition_mismatch2(\nreturn astc::min(v1, v2);\n}\n-// compute the bit-mismatch for a partitioning in 3-partition mode\n+/**\n+ * @brief Compute bit-mismatch for partitioning in 3-partition mode.\n+ */\nstatic inline int partition_mismatch3(\nuint64_t a0,\nuint64_t a1,\n@@ -273,7 +260,9 @@ static inline int partition_mismatch3(\nreturn astc::min(v0, v1, v2);\n}\n-// compute the bit-mismatch for a partitioning in 4-partition mode\n+/**\n+ * @brief Compute bit-mismatch for partitioning in 4-partition mode.\n+ */\nstatic inline int partition_mismatch4(\nuint64_t a0,\nuint64_t a1,\n@@ -319,6 +308,9 @@ static inline int partition_mismatch4(\nreturn astc::min(v0, v1, v2, v3);\n}\n+/**\n+ * @brief Count the partition table mismatches vs the data clustering.\n+ */\nstatic void count_partition_mismatch_bits(\nconst block_size_descriptor* bsd,\nint partition_count,\n@@ -362,8 +354,9 @@ static void count_partition_mismatch_bits(\npt++;\n}\n}\n- else if (partition_count == 4)\n+ else // if (partition_count == 4)\n{\n+ assert(partition_count == 4);\nuint64_t bm0 = bitmaps[0];\nuint64_t bm1 = bitmaps[1];\nuint64_t bm2 = bitmaps[2];\n@@ -381,7 +374,6 @@ static void count_partition_mismatch_bits(\npt++;\n}\n}\n-\n}\n/**\n@@ -432,14 +424,14 @@ void kmeans_compute_partition_ordering(\n{\nif (i == 0)\n{\n- kmeans_init(bsd->texel_count, partition_count, blk, cluster_centers);\n+ kmeans_init(*blk, bsd->texel_count, partition_count, cluster_centers);\n}\nelse\n{\n- kmeans_update(bsd->texel_count, partition_count, blk, partition_of_texel, cluster_centers);\n+ kmeans_update(*blk, bsd->texel_count, partition_count, cluster_centers, partition_of_texel);\n}\n- kmeans_assign(bsd->texel_count, partition_count, blk, cluster_centers, partition_of_texel);\n+ kmeans_assign(*blk, bsd->texel_count, partition_count, cluster_centers, partition_of_texel);\n}\n// Construct the block bitmaps of texel assignments to each partition\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Clean up kmeans partitioning
61,745
31.03.2021 20:57:07
-3,600
5d6225522bc245b0a8ceb4f6016fe4027e69bc65
Cleanup kmeans clustering
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_find_best_partitioning.cpp", "new_path": "Source/astcenc_find_best_partitioning.cpp", "diff": "@@ -151,7 +151,7 @@ void find_best_partitionings(\nint partition_sequence[PARTITION_COUNT];\n- kmeans_compute_partition_ordering(bsd, partition_count, blk, partition_sequence);\n+ kmeans_compute_partition_ordering(*bsd, *blk, partition_count, partition_sequence);\nint uses_alpha = imageblock_uses_alpha(blk);\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -964,10 +964,10 @@ void find_best_partitionings(\n// use k-means clustering to compute a partition ordering for a block.\nvoid kmeans_compute_partition_ordering(\n- const block_size_descriptor* bsd,\n+ const block_size_descriptor& bsd,\n+ const imageblock& blk,\nint partition_count,\n- const imageblock* blk,\n- int *ordering);\n+ int partition_ordering[PARTITION_COUNT]);\n// *********************************************************\n// functions and data pertaining to images and imageblocks\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_kmeans_partitioning.cpp", "new_path": "Source/astcenc_kmeans_partitioning.cpp", "diff": "@@ -312,12 +312,12 @@ static inline int partition_mismatch4(\n* @brief Count the partition table mismatches vs the data clustering.\n*/\nstatic void count_partition_mismatch_bits(\n- const block_size_descriptor* bsd,\n+ const block_size_descriptor& bsd,\nint partition_count,\nconst uint64_t bitmaps[4],\nint bitcounts[PARTITION_COUNT]\n) {\n- const partition_info *pt = get_partition_table(bsd, partition_count);\n+ const partition_info *pt = get_partition_table(&bsd, partition_count);\nif (partition_count == 2)\n{\n@@ -325,14 +325,13 @@ static void count_partition_mismatch_bits(\nuint64_t bm1 = bitmaps[1];\nfor (int i = 0; i < PARTITION_COUNT; i++)\n{\n+ int bitcount = 255;\nif (pt->partition_count == 2)\n{\n- bitcounts[i] = partition_mismatch2(bm0, bm1, pt->coverage_bitmaps[0], pt->coverage_bitmaps[1]);\n- }\n- else\n- {\n- bitcounts[i] = 255;\n+ bitcount = partition_mismatch2(bm0, bm1, pt->coverage_bitmaps[0], pt->coverage_bitmaps[1]);\n}\n+\n+ bitcounts[i] = bitcount;\npt++;\n}\n}\n@@ -343,14 +342,13 @@ static void count_partition_mismatch_bits(\nuint64_t bm2 = bitmaps[2];\nfor (int i = 0; i < PARTITION_COUNT; i++)\n{\n+ int bitcount = 255;\nif (pt->partition_count == 3)\n{\n- bitcounts[i] = partition_mismatch3(bm0, bm1, bm2, pt->coverage_bitmaps[0], pt->coverage_bitmaps[1], pt->coverage_bitmaps[2]);\n- }\n- else\n- {\n- bitcounts[i] = 255;\n+ bitcount = partition_mismatch3(bm0, bm1, bm2, pt->coverage_bitmaps[0], pt->coverage_bitmaps[1], pt->coverage_bitmaps[2]);\n}\n+\n+ bitcounts[i] = bitcount;\npt++;\n}\n}\n@@ -363,14 +361,13 @@ static void count_partition_mismatch_bits(\nuint64_t bm3 = bitmaps[3];\nfor (int i = 0; i < PARTITION_COUNT; i++)\n{\n+ int bitcount = 255;\nif (pt->partition_count == 4)\n{\n- bitcounts[i] = partition_mismatch4(bm0, bm1, bm2, bm3, pt->coverage_bitmaps[0], pt->coverage_bitmaps[1], pt->coverage_bitmaps[2], pt->coverage_bitmaps[3]);\n- }\n- else\n- {\n- bitcounts[i] = 255;\n+ bitcount = partition_mismatch4(bm0, bm1, bm2, bm3, pt->coverage_bitmaps[0], pt->coverage_bitmaps[1], pt->coverage_bitmaps[2], pt->coverage_bitmaps[3]);\n}\n+\n+ bitcounts[i] = bitcount;\npt++;\n}\n}\n@@ -411,36 +408,37 @@ static void get_partition_ordering_by_mismatch_bits(\n}\nvoid kmeans_compute_partition_ordering(\n- const block_size_descriptor* bsd,\n+ const block_size_descriptor& bsd,\n+ const imageblock& blk,\nint partition_count,\n- const imageblock* blk,\n- int* ordering\n+ int partition_ordering[PARTITION_COUNT]\n) {\nvfloat4 cluster_centers[4];\n- int partition_of_texel[MAX_TEXELS_PER_BLOCK];\n+ int texel_partitions[MAX_TEXELS_PER_BLOCK];\n// Use three passes of k-means clustering to partition the block data\nfor (int i = 0; i < 3; i++)\n{\nif (i == 0)\n{\n- kmeans_init(*blk, bsd->texel_count, partition_count, cluster_centers);\n+ kmeans_init(blk, bsd.texel_count, partition_count, cluster_centers);\n}\nelse\n{\n- kmeans_update(*blk, bsd->texel_count, partition_count, cluster_centers, partition_of_texel);\n+ kmeans_update(blk, bsd.texel_count, partition_count, cluster_centers, texel_partitions);\n}\n- kmeans_assign(*blk, bsd->texel_count, partition_count, cluster_centers, partition_of_texel);\n+ kmeans_assign(blk, bsd.texel_count, partition_count, cluster_centers, texel_partitions);\n}\n// Construct the block bitmaps of texel assignments to each partition\nuint64_t bitmaps[4] { 0 };\n- int texels_to_process = bsd->kmeans_texel_count;\n+ int texels_to_process = bsd.kmeans_texel_count;\n+ promise(texels_to_process > 0);\nfor (int i = 0; i < texels_to_process; i++)\n{\n- int idx = bsd->kmeans_texels[i];\n- bitmaps[partition_of_texel[idx]] |= 1ULL << i;\n+ int idx = bsd.kmeans_texels[i];\n+ bitmaps[texel_partitions[idx]] |= 1ULL << i;\n}\n// Count the mismatch between the block and the format's partition tables\n@@ -448,7 +446,7 @@ void kmeans_compute_partition_ordering(\ncount_partition_mismatch_bits(bsd, partition_count, bitmaps, mismatch_counts);\n// Sort the partitions based on the number of mismatched bits\n- get_partition_ordering_by_mismatch_bits(mismatch_counts, ordering);\n+ get_partition_ordering_by_mismatch_bits(mismatch_counts, partition_ordering);\n}\n#endif\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Cleanup kmeans clustering
61,745
31.03.2021 22:21:57
-3,600
493c91132751f29109fd326741f8ade1f20521e3
Optimize compute_angular_offsets
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_avx2_8.h", "new_path": "Source/astcenc_vecmathlib_avx2_8.h", "diff": "@@ -571,6 +571,15 @@ ASTCENC_SIMD_INLINE vfloat8 operator+(vfloat8 a, vfloat8 b)\nreturn vfloat8(_mm256_add_ps(a.m, b.m));\n}\n+/**\n+ * @brief Overload: vector by vector incremental addition.\n+ */\n+ASTCENC_SIMD_INLINE vfloat8& operator+=(vfloat8& a, const vfloat8& b)\n+{\n+ a = a + b;\n+ return a;\n+}\n+\n/**\n* @brief Overload: vector by vector subtraction.\n*/\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_weight_align.cpp", "new_path": "Source/astcenc_weight_align.cpp", "diff": "@@ -97,54 +97,47 @@ void prepare_angular_tables()\n// angular sums, compute alignment factor and offset.\nstatic void compute_angular_offsets(\n- int samplecount,\n+ int sample_count,\nconst float* samples,\nconst float* sample_weights,\nint max_angular_steps,\nfloat* offsets\n) {\n- promise(samplecount > 0);\n+ promise(sample_count > 0);\npromise(max_angular_steps > 0);\n- alignas(ASTCENC_VECALIGN) float anglesum_x[ANGULAR_STEPS] { 0 };\n- alignas(ASTCENC_VECALIGN) float anglesum_y[ANGULAR_STEPS] { 0 };\n-\n- // compute the angle-sums.\n- for (int i = 0; i < samplecount; i++)\n- {\n- float sample = samples[i];\n- float sample_weight = sample_weights[i];\n- if32 p;\n- p.f = (sample * (SINCOS_STEPS - 1.0f)) + 12582912.0f;\n- unsigned int isample = p.u & (SINCOS_STEPS - 1);\n-\n- const float *sinptr = sin_table[isample];\n- const float *cosptr = cos_table[isample];\n+ alignas(ASTCENC_VECALIGN) int isamplev[MAX_WEIGHTS_PER_BLOCK] { 0 };\n- vfloat sample_weightv(sample_weight);\n- // Arrays are multiple of SIMD width (ANGULAR_STEPS), safe to overshoot max\n- for (int j = 0; j < max_angular_steps; j += ASTCENC_SIMD_WIDTH)\n+ // Precompute isample; arrays are always allocated 64 elements long\n+ for (int i = 0; i < sample_count; i += ASTCENC_SIMD_WIDTH)\n{\n- vfloat cp = loada(&cosptr[j]);\n- vfloat sp = loada(&sinptr[j]);\n- vfloat ax = loada(&anglesum_x[j]) + cp * sample_weightv;\n- vfloat ay = loada(&anglesum_y[j]) + sp * sample_weightv;\n- storea(ax, &anglesum_x[j]);\n- storea(ay, &anglesum_y[j]);\n- }\n+ vfloat sample = loada(samples + i) * (SINCOS_STEPS - 1.0f) + vfloat(12582912.0f);\n+ vint isample = float_as_int(sample) & vint((SINCOS_STEPS - 1));\n+ storea(isample, isamplev + i);\n}\n- // post-process the angle-sums\n+ // Arrays are multiple of SIMD width (ANGULAR_STEPS), safe to overshoot max\nvfloat mult = vfloat(1.0f / (2.0f * astc::PI));\nvfloat rcp_stepsize = vfloat::lane_id() + vfloat(1.0f);\n- // Arrays are multiple of SIMD width (ANGULAR_STEPS), safe to overshoot max\n+\nfor (int i = 0; i < max_angular_steps; i += ASTCENC_SIMD_WIDTH)\n{\n+ vfloat anglesum_x = vfloat::zero();\n+ vfloat anglesum_y = vfloat::zero();\n+\n+ for (int j = 0; j < sample_count; j++)\n+ {\n+ int isample = isamplev[j];\n+ vfloat sample_weightv(sample_weights[j]);\n+ anglesum_x += loada(cos_table[isample] + i) * sample_weightv;\n+ anglesum_y += loada(sin_table[isample] + i) * sample_weightv;\n+ }\n+\nvfloat ssize = 1.0f / rcp_stepsize;\n- rcp_stepsize = rcp_stepsize + vfloat(ASTCENC_SIMD_WIDTH);\n- vfloat angle = atan2(loada(&anglesum_y[i]), loada(&anglesum_x[i]));\n+ rcp_stepsize += vfloat(ASTCENC_SIMD_WIDTH);\n+ vfloat angle = atan2(anglesum_y, anglesum_x);\nvfloat ofs = angle * ssize * mult;\n- storea(ofs, &offsets[i]);\n+ storea(ofs, offsets + i);\n}\n}\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Optimize compute_angular_offsets
61,745
31.03.2021 22:46:30
-3,600
b2e3cc2c18617ffb3f606c3abc86f336c43d2682
Factorize out redundant computation
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_weight_align.cpp", "new_path": "Source/astcenc_weight_align.cpp", "diff": "@@ -118,7 +118,6 @@ static void compute_angular_offsets(\n// Arrays are multiple of SIMD width (ANGULAR_STEPS), safe to overshoot max\nvfloat mult = vfloat(1.0f / (2.0f * astc::PI));\n- vfloat rcp_stepsize = vfloat::lane_id() + vfloat(1.0f);\nfor (int i = 0; i < max_angular_steps; i += ASTCENC_SIMD_WIDTH)\n{\n@@ -133,10 +132,8 @@ static void compute_angular_offsets(\nanglesum_y += loada(sin_table[isample] + i) * sample_weightv;\n}\n- vfloat ssize = 1.0f / rcp_stepsize;\n- rcp_stepsize += vfloat(ASTCENC_SIMD_WIDTH);\nvfloat angle = atan2(anglesum_y, anglesum_x);\n- vfloat ofs = angle * ssize * mult;\n+ vfloat ofs = angle * mult;\nstorea(ofs, offsets + i);\n}\n}\n@@ -151,8 +148,8 @@ static void compute_lowest_and_highest_weight(\nint max_angular_steps,\nint max_quantization_steps,\nconst float* offsets,\n- int32_t * lowest_weight,\n- int32_t * weight_span,\n+ int* lowest_weight,\n+ int* weight_span,\nfloat* error,\nfloat* cut_low_weight_error,\nfloat* cut_high_weight_error\n@@ -171,16 +168,16 @@ static void compute_lowest_and_highest_weight(\nvfloat cut_low_weight_err = vfloat::zero();\nvfloat cut_high_weight_err = vfloat::zero();\nvfloat offset = loada(&offsets[sp]);\n- vfloat scaled_offset = rcp_stepsize * offset;\n+\nfor (int j = 0; j < samplecount; ++j)\n{\nvfloat wt = load1(&sample_weights[j]);\n- vfloat sval = load1(&samples[j]) * rcp_stepsize - scaled_offset;\n+ vfloat sval = load1(&samples[j]) * rcp_stepsize - offset;\nvfloat svalrte = round(sval);\nvint idxv = float_to_int(svalrte);\nvfloat dif = sval - svalrte;\nvfloat dwt = dif * wt;\n- errval = errval + dwt * dif;\n+ errval += dwt * dif;\n// Reset tracker on min hit\nvmask mask = idxv < minidx;\n@@ -331,8 +328,8 @@ else\nfloat stepsize = 1.0f / (1.0f + (float)bsi);\nint lwi = lowest_weight[bsi] + cut_low_weight[q];\nint hwi = lwi + q - 1;\n- float offset = angular_offsets[bsi];\n+ float offset = angular_offsets[bsi] * stepsize;\nlow_value[i] = offset + static_cast<float>(lwi) * stepsize;\nhigh_value[i] = offset + static_cast<float>(hwi) * stepsize;\n}\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Factorize out redundant computation
61,745
31.03.2021 23:35:09
-3,600
dfd61b71bccf874cb40d57f9d0624c2d7cbe9cf6
Cleanup use of accumulators
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "diff": "@@ -1224,8 +1224,8 @@ void recompute_ideal_colors_2planes(\nvfloat4 rgba = blk->texel(tix);\nvfloat4 error_weight(ewb->texel_weight_r[tix], ewb->texel_weight_g[tix], ewb->texel_weight_b[tix], ewb->texel_weight_a[tix]);\n- rgba_sum = rgba_sum + (rgba * error_weight);\n- rgba_weight_sum = rgba_weight_sum + error_weight;\n+ rgba_sum += rgba * error_weight;\n+ rgba_weight_sum += error_weight;\n}\nvfloat4 scale_direction = normalize((rgba_sum * (1.0f / rgba_weight_sum)).swz<0, 1, 2>());\n@@ -1245,8 +1245,7 @@ void recompute_ideal_colors_2planes(\nvfloat4 left2_sum = vfloat4::zero();\nvfloat4 middle2_sum = vfloat4::zero();\nvfloat4 right2_sum = vfloat4::zero();\n-\n- vfloat4 lmrs_sum = vfloat4(0.0f);\n+ vfloat4 lmrs_sum = vfloat4::zero();\nvfloat4 color_vec_x = vfloat4::zero();\nvfloat4 color_vec_y = vfloat4::zero();\n@@ -1286,11 +1285,10 @@ void recompute_ideal_colors_2planes(\nidx0 * idx0,\n0.0f) * ls_weight;\n- left_sum = left_sum + left;\n- middle_sum = middle_sum + middle;\n- right_sum = right_sum + right;\n-\n- lmrs_sum = lmrs_sum + lmrs;\n+ left_sum += left;\n+ middle_sum += middle;\n+ right_sum += right;\n+ lmrs_sum += lmrs;\nfloat idx1 = 0.0f;\nfloat om_idx1 = 0.0f;\n@@ -1307,9 +1305,9 @@ void recompute_ideal_colors_2planes(\nvfloat4 middle2 = color_weight * (om_idx1 * idx1);\nvfloat4 right2 = color_weight * (idx1 * idx1);\n- left2_sum = left2_sum + left2;\n- middle2_sum = middle2_sum + middle2;\n- right2_sum = right2_sum + right2;\n+ left2_sum += left2;\n+ middle2_sum += middle2;\n+ right2_sum += right2;\n}\nvfloat4 color_idx((plane2_component == 0) ? idx1 : idx0,\n@@ -1320,13 +1318,11 @@ void recompute_ideal_colors_2planes(\nvfloat4 cwprod = color_weight * rgba;\nvfloat4 cwiprod = cwprod * color_idx;\n- color_vec_y = color_vec_y + cwiprod;\n- color_vec_x = color_vec_x + (cwprod - cwiprod);\n+ color_vec_y += cwiprod;\n+ color_vec_x += cwprod - cwiprod;\nscale_vec += float2(om_idx0, idx0) * (ls_weight * scale);\n-\nweight_weight_sum += (color_weight * color_idx);\n-\npsum += dot3_s(color_weight * color_idx, color_idx);\n}\n@@ -1486,6 +1482,7 @@ void recompute_ideal_colors_2planes(\n{\nvfloat4 v0 = ep->endpt0[i];\nvfloat4 v1 = ep->endpt1[i];\n+\nfloat avgdif = hadd_rgb_s(v1 - v0) * (1.0f / 3.0f);\navgdif = astc::max(avgdif, 0.0f);\n@@ -1539,8 +1536,8 @@ void recompute_ideal_colors_1plane(\nvfloat4 rgba = blk->texel(tix);\nvfloat4 error_weight(ewb->texel_weight_r[tix], ewb->texel_weight_g[tix], ewb->texel_weight_b[tix], ewb->texel_weight_a[tix]);\n- rgba_sum = rgba_sum + (rgba * error_weight);\n- rgba_weight_sum = rgba_weight_sum + error_weight;\n+ rgba_sum += rgba * error_weight;\n+ rgba_weight_sum += error_weight;\n}\nvfloat4 scale_direction = normalize((rgba_sum * (1.0f / rgba_weight_sum)).swz<0, 1, 2>());\n@@ -1554,8 +1551,7 @@ void recompute_ideal_colors_1plane(\nvfloat4 left_sum = vfloat4::zero();\nvfloat4 middle_sum = vfloat4::zero();\nvfloat4 right_sum = vfloat4::zero();\n-\n- vfloat4 lmrs_sum = vfloat4(0.0f);\n+ vfloat4 lmrs_sum = vfloat4::zero();\nvfloat4 color_vec_x = vfloat4::zero();\nvfloat4 color_vec_y = vfloat4::zero();\n@@ -1594,23 +1590,20 @@ void recompute_ideal_colors_1plane(\nidx0 * idx0,\n0.0f) * ls_weight;\n- left_sum = left_sum + left;\n- middle_sum = middle_sum + middle;\n- right_sum = right_sum + right;\n-\n- lmrs_sum = lmrs_sum + lmrs;\n+ left_sum += left;\n+ middle_sum += middle;\n+ right_sum += right;\n+ lmrs_sum += lmrs;\nvfloat4 color_idx(idx0);\nvfloat4 cwprod = color_weight * rgba;\nvfloat4 cwiprod = cwprod * color_idx;\n- color_vec_y = color_vec_y + cwiprod;\n- color_vec_x = color_vec_x + (cwprod - cwiprod);\n+ color_vec_y += cwiprod;\n+ color_vec_x += cwprod - cwiprod;\nscale_vec += (float2(om_idx0, idx0) * (ls_weight * scale));\n-\nweight_weight_sum += color_weight * color_idx;\n-\npsum += dot3_s(color_weight * color_idx, color_idx);\n}\n@@ -1719,7 +1712,8 @@ void recompute_ideal_colors_1plane(\n{\nvfloat4 v0 = ep->endpt0[i];\nvfloat4 v1 = ep->endpt1[i];\n- float avgdif = ((v1.lane<0>() - v0.lane<0>()) + (v1.lane<1>() - v0.lane<1>()) + (v1.lane<2>() - v0.lane<2>())) * (1.0f / 3.0f);\n+\n+ float avgdif = hadd_rgb_s(v1 - v0) * (1.0f / 3.0f);\navgdif = astc::max(avgdif, 0.0f);\nvfloat4 avg = (v0 + v1) * 0.5f;\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Cleanup use of accumulators
61,745
31.03.2021 23:47:34
-3,600
b0bbae8d894ae478fc3a423eed536359e7da3719
Vectorization in compute_rgbovec call site
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "diff": "@@ -1115,11 +1115,8 @@ void compute_quantized_weights_for_decimation_table(\nstatic inline vfloat4 compute_rgbovec(\nvfloat4 rgba_weight_sum,\nvfloat4 weight_weight_sum,\n- float red_sum,\n- float green_sum,\n- float blue_sum,\n- float psum,\n- float qsum\n+ vfloat4 rgbq_sum,\n+ float psum\n) {\n// Compute the rgb+offset for HDR endpoint mode #7. Since the matrix needed\n// has a regular structure, we can simplify the inverse calculation. This\n@@ -1164,7 +1161,7 @@ static inline vfloat4 compute_rgbovec(\nvfloat4 mat1(ZQP, SZmRR * X - Z * PP, RQX, mZQX);\nvfloat4 mat2(RYP, RQX, (S * Y - QQ) * X - Y * PP, mRYX);\nvfloat4 mat3(mZYP, mZQX, mRYX, Z * YX);\n- vfloat4 vect = vfloat4(red_sum, green_sum, blue_sum, qsum) * rdet;\n+ vfloat4 vect = rgbq_sum * rdet;\n#ifdef DEBUG_CAPTURE_NAN\nfedisableexcept(FE_DIVBYZERO | FE_INVALID);\n@@ -1310,10 +1307,8 @@ void recompute_ideal_colors_2planes(\nright2_sum += right2;\n}\n- vfloat4 color_idx((plane2_component == 0) ? idx1 : idx0,\n- (plane2_component == 1) ? idx1 : idx0,\n- (plane2_component == 2) ? idx1 : idx0,\n- (plane2_component == 3) ? idx1 : idx0);\n+ vmask4 p2_mask = vint4::lane_id() == vint4(plane2_component);\n+ vfloat4 color_idx = select(vfloat4(idx0), vfloat4(idx1), p2_mask);\nvfloat4 cwprod = color_weight * rgba;\nvfloat4 cwiprod = cwprod * color_idx;\n@@ -1328,17 +1323,15 @@ void recompute_ideal_colors_2planes(\n// calculations specific to mode #7, the HDR RGB-scale mode.\n// FIXME: Can we skip this for LDR textures?\n- float red_sum = color_vec_x.lane<0>() + color_vec_y.lane<0>();\n- float green_sum = color_vec_x.lane<1>() + color_vec_y.lane<1>();\n- float blue_sum = color_vec_x.lane<2>() + color_vec_y.lane<2>();\n- float qsum = hadd_rgb_s(color_vec_y);\n+ vfloat4 rgbq_sum = color_vec_x + color_vec_y;\n+ rgbq_sum.set_lane<3>(hadd_rgb_s(color_vec_y));\n#ifdef DEBUG_CAPTURE_NAN\nfedisableexcept(FE_DIVBYZERO | FE_INVALID);\n#endif\nvfloat4 rgbovec = compute_rgbovec(rgba_weight_sum, weight_weight_sum,\n- red_sum, green_sum, blue_sum, psum, qsum);\n+ rgbq_sum, psum);\nrgbo_vectors[i] = rgbovec;\n// We will occasionally get a failure due to the use of a singular\n@@ -1609,17 +1602,15 @@ void recompute_ideal_colors_1plane(\n// calculations specific to mode #7, the HDR RGB-scale mode.\n// FIXME: Can we skip this for LDR textures?\n- float red_sum = color_vec_x.lane<0>() + color_vec_y.lane<0>();\n- float green_sum = color_vec_x.lane<1>() + color_vec_y.lane<1>();\n- float blue_sum = color_vec_x.lane<2>() + color_vec_y.lane<2>();\n- float qsum = hadd_rgb_s(color_vec_y);\n+ vfloat4 rgbq_sum = color_vec_x + color_vec_y;\n+ rgbq_sum.set_lane<3>(hadd_rgb_s(color_vec_y));\n#ifdef DEBUG_CAPTURE_NAN\nfedisableexcept(FE_DIVBYZERO | FE_INVALID);\n#endif\nvfloat4 rgbovec = compute_rgbovec(rgba_weight_sum, weight_weight_sum,\n- red_sum, green_sum, blue_sum, psum, qsum);\n+ rgbq_sum, psum);\nrgbo_vectors[i] = rgbovec;\n// We will occasionally get a failure due to the use of a singular\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Vectorization in compute_rgbovec call site
61,745
31.03.2021 23:56:55
-3,600
8962dba78608363a94551b18f2f0b38d92f0aad4
Remove if check that is always true
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "diff": "@@ -1290,8 +1290,6 @@ void recompute_ideal_colors_2planes(\nfloat idx1 = 0.0f;\nfloat om_idx1 = 0.0f;\n- if (plane2_weight_set8)\n- {\nidx1 = bilinear_infill(*dt, plane2_weight_set, tix);\nom_idx1 = 1.0f - idx1;\n@@ -1305,7 +1303,6 @@ void recompute_ideal_colors_2planes(\nleft2_sum += left2;\nmiddle2_sum += middle2;\nright2_sum += right2;\n- }\nvmask4 p2_mask = vint4::lane_id() == vint4(plane2_component);\nvfloat4 color_idx = select(vfloat4(idx0), vfloat4(idx1), p2_mask);\n@@ -1422,8 +1419,6 @@ void recompute_ideal_colors_2planes(\n#endif\n}\n- if (plane2_weight_set8)\n- {\nif (wmin2 >= wmax2 * 0.999f)\n{\n// if all weights in the partition were equal, then just take average\n@@ -1467,7 +1462,6 @@ void recompute_ideal_colors_2planes(\nfeenableexcept(FE_DIVBYZERO | FE_INVALID);\n#endif\n}\n- }\n// if the calculation of an RGB-offset vector failed, try to compute\n// a somewhat-sensible value anyway\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Remove if check that is always true
61,745
04.04.2021 23:14:26
-3,600
79c9896169609e7469513606e7d8f8d55a235a91
Use explicit loop tail rather than over-fetching
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "diff": "@@ -816,6 +816,7 @@ void compute_ideal_weights_for_decimation_table(\nfloat* RESTRICT weight_set,\nfloat* RESTRICT weights\n) {\n+ int i;\nint texel_count = dt.texel_count;\nint weight_count = dt.weight_count;\n@@ -831,7 +832,7 @@ void compute_ideal_weights_for_decimation_table(\n// weights into both the weight set and the output epw copy.\nif (texel_count == weight_count)\n{\n- for (int i = 0; i < texel_count; i++)\n+ for (i = 0; i < texel_count; i++)\n{\nassert(i == dt.weight_texel[0][i]);\nweight_set[i] = eai_in.weights[i];\n@@ -846,7 +847,7 @@ void compute_ideal_weights_for_decimation_table(\n// epw copy and then do the full algorithm to decimate weights.\nelse\n{\n- for (int i = 0; i < texel_count; i++)\n+ for (i = 0; i < texel_count; i++)\n{\neai_out.weights[i] = eai_in.weights[i];\neai_out.weight_error_scale[i] = eai_in.weight_error_scale[i];\n@@ -857,9 +858,11 @@ void compute_ideal_weights_for_decimation_table(\nalignas(ASTCENC_VECALIGN) float infilled_weights[MAX_TEXELS_PER_BLOCK];\n// Compute an initial average for each decimated weight\n+ i = 0;\n+\n#if ASTCENC_SIMD_WIDTH >= 8\n- int clipped_weight_count = round_up_to_simd_multiple_vla(weight_count);\n- for (int i = 0; i < clipped_weight_count; i += ASTCENC_SIMD_WIDTH)\n+ int clipped_weight_count = round_down_to_simd_multiple_vla(weight_count);\n+ for (/* */; i < clipped_weight_count; i += ASTCENC_SIMD_WIDTH)\n{\n// Start with a small value to avoid div-by-zero later\nvfloat weight_weight(1e-10f);\n@@ -890,8 +893,10 @@ void compute_ideal_weights_for_decimation_table(\nstorea(weight_weight, weights + i);\nstorea(initial_weight / weight_weight, weight_set + i);\n}\n-#else\n- for (int i = 0; i < weight_count; i++)\n+#endif\n+\n+ // Loop tail\n+ for (/* */; i < weight_count; i++)\n{\n// Start with a small value to avoid div-by-zero later\nfloat weight_weight = 1e-10f;\n@@ -913,30 +918,33 @@ void compute_ideal_weights_for_decimation_table(\nweights[i] = weight_weight;\nweight_set[i] = initial_weight / weight_weight;\n}\n-#endif\n// Populate the interpolated weight grid based on the initital average\n+ i = 0;\n+\n#if ASTCENC_SIMD_WIDTH >= 8\n// Process SIMD-width texel coordinates at at time while we can\n- int clipped_texel_count = round_up_to_simd_multiple_vla(texel_count);\n- for (int i = 0; i < clipped_texel_count; i += ASTCENC_SIMD_WIDTH)\n+ int clipped_texel_count = round_down_to_simd_multiple_vla(texel_count);\n+ for (/* */; i < clipped_texel_count; i += ASTCENC_SIMD_WIDTH)\n{\nvfloat weight = bilinear_infill_vla(dt, weight_set, i);\nstorea(weight, infilled_weights + i);\n}\n-#else\n- for (int i = 0; i < texel_count; i++)\n+#endif\n+\n+ // Loop tail\n+ for (/* */; i < texel_count; i++)\n{\ninfilled_weights[i] = bilinear_infill(dt, weight_set, i);\n}\n-#endif\n// Perform a single iteration of refinement\nconstexpr float stepsize = 0.25f;\nconstexpr float chd_scale = -TEXEL_WEIGHT_SUM;\n+ i = 0;\n#if ASTCENC_SIMD_WIDTH >= 8\n- for (int i = 0; i < clipped_weight_count; i += ASTCENC_SIMD_WIDTH)\n+ for (/* */; i < clipped_weight_count; i += ASTCENC_SIMD_WIDTH)\n{\n// Start with a small value to avoid div-by-zero later\nvfloat weight_val = loada(weight_set + i);\n@@ -975,8 +983,10 @@ void compute_ideal_weights_for_decimation_table(\n// update the weight\nstorea(weight_val + step, weight_set + i);\n}\n-#else\n- for (int i = 0; i < weight_count; i++)\n+#endif\n+\n+ // Loop tail\n+ for (/* */; i < weight_count; i++)\n{\nfloat weight_val = weight_set[i];\n@@ -1006,7 +1016,6 @@ void compute_ideal_weights_for_decimation_table(\n// update the weight\nweight_set[i] = weight_val + step;\n}\n-#endif\n}\n/*\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Use explicit loop tail rather than over-fetching
61,745
04.04.2021 23:51:23
-3,600
656c6f7e2994a9c3593f086f6b98ff38570024c2
Add memcheck instructions
[ { "change_type": "MODIFY", "old_path": "Docs/Testing.md", "new_path": "Docs/Testing.md", "diff": "@@ -106,3 +106,11 @@ Once this is done, run the command:\ntest suite gets exclusive use of the machine to avoid other processing slowing\ndown the compression and disturbing the performance data. It is recommended to\nshutdown or disable any background applications that are running.\n+\n+## Valgrind memcheck\n+\n+It is always worth running the Valgrind memcheck tool to validate that we have\n+not introduced any obvious memory errors. Build a release build with symbols\n+information with `-DCMAKE_BUILD_TYPE=RelWithDebInfo` and then run:\n+\n+ valgrind --tool=memcheck --track-origins=yes <command>\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add memcheck instructions
61,745
08.04.2021 23:16:09
-3,600
7dfed5ae38e8edc79c333729e06a2224eee84cda
Use swz() to avoid cl.exe bug for ARM64
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "new_path": "Source/astcenc_ideal_endpoints_and_weights.cpp", "diff": "@@ -370,33 +370,25 @@ static void compute_endpoints_and_ideal_weights_3_comp(\nfor (int i = 0; i < partition_count; i++)\n{\n- float s1 = 0, s2 = 0, s3 = 0;\n+ vfloat4 color_scale;\nassert(omitted_component < 4);\nswitch (omitted_component)\n{\ncase 0:\n- s1 = pms[i].color_scale.lane<1>();\n- s2 = pms[i].color_scale.lane<2>();\n- s3 = pms[i].color_scale.lane<3>();\n+ color_scale = pms[i].color_scale.swz<1, 2, 3>();\nbreak;\ncase 1:\n- s1 = pms[i].color_scale.lane<0>();\n- s2 = pms[i].color_scale.lane<2>();\n- s3 = pms[i].color_scale.lane<3>();\n+ color_scale = pms[i].color_scale.swz<0, 2, 3>();\nbreak;\ncase 2:\n- s1 = pms[i].color_scale.lane<0>();\n- s2 = pms[i].color_scale.lane<1>();\n- s3 = pms[i].color_scale.lane<3>();\n+ color_scale = pms[i].color_scale.swz<0, 1, 3>();\nbreak;\ndefault:\n- s1 = pms[i].color_scale.lane<0>();\n- s2 = pms[i].color_scale.lane<1>();\n- s3 = pms[i].color_scale.lane<2>();\n+ color_scale = pms[i].color_scale.swz<0, 1, 2>();\nbreak;\n}\n- pms[i].color_scale = normalize(vfloat4(s1, s2, s3, 0.0f)) * 1.73205080f;\n+ pms[i].color_scale = normalize(color_scale) * 1.73205080f;\n}\nfloat lowparam[4] { 1e10f, 1e10f, 1e10f, 1e10f };\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Use swz() to avoid cl.exe bug for ARM64
61,745
09.04.2021 00:10:06
-3,600
e0602a6c249a8d4ec18b97e152380c08ec4496f1
Use array loads for NEON vector init
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_neon_4.h", "new_path": "Source/astcenc_vecmathlib_neon_4.h", "diff": "@@ -85,8 +85,8 @@ struct vfloat4\n*/\nASTCENC_SIMD_INLINE explicit vfloat4(float a, float b, float c, float d)\n{\n- float32x4_t v { a, b, c, d };\n- m = v;\n+ float v[4] = { a, b, c, d };\n+ m = vld1q_f32(v);\n}\n/**\n@@ -234,8 +234,8 @@ struct vint4\n*/\nASTCENC_SIMD_INLINE explicit vint4(int a, int b, int c, int d)\n{\n- int32x4_t v { a, b, c, d };\n- m = v;\n+ int v[4] = { a, b, c, d };\n+ m = vld1q_s32(v);\n}\n/**\n@@ -318,6 +318,7 @@ struct vmask4\nm = a;\n}\n+#if !defined(_MSC_VER)\n/**\n* @brief Construct from an existing SIMD register.\n*/\n@@ -325,20 +326,22 @@ struct vmask4\n{\nm = vreinterpretq_u32_s32(a);\n}\n+#endif\n/**\n* @brief Construct from an existing SIMD register.\n*/\nASTCENC_SIMD_INLINE explicit vmask4(bool a, bool b, bool c, bool d)\n{\n- int32x4_t v {\n+ int v[4] = {\na == true ? -1 : 0,\nb == true ? -1 : 0,\nc == true ? -1 : 0,\nd == true ? -1 : 0\n};\n- m = vreinterpretq_u32_s32(v);\n+ int32x4_t ms = vld1q_s32(v);\n+ m = vreinterpretq_u32_s32(ms);\n}\n@@ -391,7 +394,9 @@ ASTCENC_SIMD_INLINE vmask4 operator~(vmask4 a)\n*/\nASTCENC_SIMD_INLINE unsigned int mask(vmask4 a)\n{\n- static const int32x4_t shift { 0, 1, 2, 3 };\n+ static const int shifta[4] = { 0, 1, 2, 3 };\n+ static const int32x4_t shift = vld1q_s32(shifta);\n+\nuint32x4_t tmp = vshrq_n_u32(a.m, 31);\nreturn vaddvq_u32(vshlq_u32(tmp, shift));\n}\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Use array loads for NEON vector init
61,745
12.04.2021 21:49:04
-3,600
13d0020d1e736abc07e6f1ebfbdddf8df4e85509
Relocate unpack_color_endpoint in partition loop
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_color_unquantize.cpp", "new_path": "Source/astcenc_color_unquantize.cpp", "diff": "@@ -669,21 +669,20 @@ void unpack_color_endpoints(\nint format,\nint quant_level,\nconst int* input,\n- int* rgb_hdr,\n- int* alpha_hdr,\n- int* nan_endpoint,\n+ bool* rgb_hdr,\n+ bool* alpha_hdr,\n+ bool* nan_endpoint,\nvint4* output0,\nvint4* output1\n) {\n- // TODO: Make these bools ...\n-\n// Assume no NaNs and LDR endpoints\n// TODO: Review use of NaN endpoint. It's never set for HDR images ...\n- *nan_endpoint = 0;\n- *rgb_hdr = 0;\n- *alpha_hdr = 0;\n+ *nan_endpoint = false;\n+ *rgb_hdr = false;\n+ *alpha_hdr = false;\n+ bool alpha_hdr_default = false;\nswitch (format)\n{\n@@ -696,14 +695,14 @@ void unpack_color_endpoints(\nbreak;\ncase FMT_HDR_LUMINANCE_SMALL_RANGE:\n- *rgb_hdr = 1;\n- *alpha_hdr = -1;\n+ *rgb_hdr = true;\n+ alpha_hdr_default = true;\nhdr_luminance_small_range_unpack(input, quant_level, output0, output1);\nbreak;\ncase FMT_HDR_LUMINANCE_LARGE_RANGE:\n- *rgb_hdr = 1;\n- *alpha_hdr = -1;\n+ *rgb_hdr = true;\n+ alpha_hdr_default = true;\nhdr_luminance_large_range_unpack(input, quant_level, output0, output1);\nbreak;\n@@ -733,8 +732,8 @@ void unpack_color_endpoints(\nbreak;\ncase FMT_HDR_RGB_SCALE:\n- *rgb_hdr = 1;\n- *alpha_hdr = -1;\n+ *rgb_hdr = true;\n+ alpha_hdr_default = true;\nhdr_rgbo_unpack3(input, quant_level, output0, output1);\nbreak;\n@@ -755,8 +754,8 @@ void unpack_color_endpoints(\nbreak;\ncase FMT_HDR_RGB:\n- *rgb_hdr = 1;\n- *alpha_hdr = -1;\n+ *rgb_hdr = true;\n+ alpha_hdr_default = true;\nhdr_rgb_unpack3(input, quant_level, output0, output1);\nbreak;\n@@ -777,31 +776,31 @@ void unpack_color_endpoints(\nbreak;\ncase FMT_HDR_RGB_LDR_ALPHA:\n- *rgb_hdr = 1;\n+ *rgb_hdr = true;\nhdr_rgb_ldr_alpha_unpack3(input, quant_level, output0, output1);\nbreak;\ncase FMT_HDR_RGBA:\n- *rgb_hdr = 1;\n- *alpha_hdr = 1;\n+ *rgb_hdr = true;\n+ *alpha_hdr = true;\nhdr_rgb_hdr_alpha_unpack3(input, quant_level, output0, output1);\nbreak;\n}\n// Assign a correct default alpha\n- if (*alpha_hdr == -1)\n+ if (alpha_hdr_default)\n{\nif (decode_mode == ASTCENC_PRF_HDR)\n{\noutput0->set_lane<3>(0x7800);\noutput1->set_lane<3>(0x7800);\n- *alpha_hdr = 1;\n+ *alpha_hdr = true;\n}\nelse\n{\noutput0->set_lane<3>(0x00FF);\noutput1->set_lane<3>(0x00FF);\n- *alpha_hdr = 0;\n+ *alpha_hdr = false;\n}\n}\n@@ -814,22 +813,20 @@ void unpack_color_endpoints(\n(decode_mode == ASTCENC_PRF_LDR_SRGB))\n{\n// Also matches HDR alpha, as cannot have HDR alpha without HDR RGB\n- if (*rgb_hdr == 1)\n+ if (*rgb_hdr == true)\n{\n*output0 = vint4(0xFF00, 0x0000, 0xFF00, 0xFF00);\n*output1 = vint4(0xFF00, 0x0000, 0xFF00, 0xFF00);\noutput_scale = hdr_scale;\n- *rgb_hdr = 0;\n- *alpha_hdr = 0;\n+ *rgb_hdr = false;\n+ *alpha_hdr = false;\n}\n}\n// An HDR profile image\nelse\n{\n- bool hrgb = *rgb_hdr == 1;\n- bool ha = *alpha_hdr == 1;\n- vmask4 hdr_lanes(hrgb, hrgb, hrgb, ha);\n+ vmask4 hdr_lanes(*rgb_hdr, *rgb_hdr, *rgb_hdr, *alpha_hdr);\noutput_scale = select(ldr_scale, hdr_scale, hdr_lanes);\n}\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -73,9 +73,9 @@ static int realign_weights(\nvmask4 plane_mask = vint4::lane_id() == vint4(plane2_component);\n// Decode the color endpoints\n- int rgb_hdr;\n- int alpha_hdr;\n- int nan_endpoint;\n+ bool rgb_hdr;\n+ bool alpha_hdr;\n+ bool nan_endpoint;\nvint4 endpnt0[4];\nvint4 endpnt1[4];\nvfloat4 endpnt0f[4];\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_decompress_symbolic.cpp", "new_path": "Source/astcenc_decompress_symbolic.cpp", "diff": "@@ -151,10 +151,11 @@ void decompress_symbolic_block(\nblk->data_max = vfloat4::zero();\nblk->grayscale = false;\n- // if we detected an error-block, blow up immediately.\n+ // If we detected an error-block, blow up immediately.\nif (scb->error_block)\n{\n// TODO: Check this - isn't linear LDR magenta too? Same below ...\n+ // Yes, but currently applied later as special case during block copy.\nif (decode_mode == ASTCENC_PRF_LDR_SRGB)\n{\nfor (int i = 0; i < bsd->texel_count; i++)\n@@ -219,7 +220,7 @@ void decompress_symbolic_block(\nbreak;\ncase ASTCENC_PRF_HDR_RGB_LDR_A:\ncase ASTCENC_PRF_HDR:\n- // constant-color block; unpack from FP16 to FP32.\n+ // Constant-color block; unpack from FP16 to FP32.\ncolor = float16_to_float(vint4(scb->constant_color));\nuse_lns = 1;\nbreak;\n@@ -241,12 +242,12 @@ void decompress_symbolic_block(\nreturn;\n}\n- // get the appropriate partition-table entry\n+ // Get the appropriate partition-table entry\nint partition_count = scb->partition_count;\nconst partition_info *pt = get_partition_table(bsd, partition_count);\npt += scb->partition_index;\n- // get the appropriate block descriptor\n+ // Get the appropriate block descriptor\nconst decimation_table *const *dts = bsd->decimation_tables;\nconst int packed_index = bsd->block_mode_packed_index[scb->block_mode];\n@@ -258,26 +259,6 @@ void decompress_symbolic_block(\nint weight_quant_level = bm.quant_mode;\n- // decode the color endpoints\n- vint4 color_endpoint0[4];\n- vint4 color_endpoint1[4];\n- int rgb_hdr_endpoint[4];\n- int alpha_hdr_endpoint[4];\n- int nan_endpoint[4];\n-\n- for (int i = 0; i < partition_count; i++)\n- {\n- unpack_color_endpoints(decode_mode,\n- scb->color_formats[i],\n- scb->color_quant_level,\n- scb->color_values[i],\n- &(rgb_hdr_endpoint[i]),\n- &(alpha_hdr_endpoint[i]),\n- &(nan_endpoint[i]),\n- &(color_endpoint0[i]),\n- &(color_endpoint1[i]));\n- }\n-\n// Unquantize and undecimate the weights\nint weights[MAX_TEXELS_PER_BLOCK];\nint plane2_weights[MAX_TEXELS_PER_BLOCK];\n@@ -289,11 +270,23 @@ void decompress_symbolic_block(\nfor (int i = 0; i < partition_count; i++)\n{\n- vint4 ep0 = color_endpoint0[i];\n- vint4 ep1 = color_endpoint1[i];\n- bool rgb_lns = rgb_hdr_endpoint[i];\n- bool nan = nan_endpoint[i];\n- bool a_lns = alpha_hdr_endpoint[i];\n+ // Decode the color endpoints for this partition\n+ vint4 ep0;\n+ vint4 ep1;\n+ bool rgb_lns;\n+ bool nan;\n+ bool a_lns;\n+\n+ unpack_color_endpoints(decode_mode,\n+ scb->color_formats[i],\n+ scb->color_quant_level,\n+ scb->color_values[i],\n+ &rgb_lns,\n+ &a_lns,\n+ &nan,\n+ &ep0,\n+ &ep1);\n+\nvmask4 lns_mask(rgb_lns, rgb_lns, rgb_lns, a_lns);\nint texel_count = pt->partition_texel_count[i];\n@@ -327,7 +320,7 @@ float compute_symbolic_block_difference(\nconst imageblock* blk,\nconst error_weight_block *ewb\n) {\n- // if we detected an error-block, blow up immediately.\n+ // If we detected an error-block, blow up immediately.\nif (scb->error_block)\n{\nreturn 1e29f;\n@@ -335,85 +328,69 @@ float compute_symbolic_block_difference(\nassert(scb->block_mode >= 0);\n- // get the appropriate partition-table entry\n+ // Get the appropriate partition-table entry\nint partition_count = scb->partition_count;\n+\nconst partition_info *pt = get_partition_table(bsd, partition_count);\npt += scb->partition_index;\n- // get the appropriate block descriptor\n- const decimation_table *const *dts = bsd->decimation_tables;\n-\n+ // Get the appropriate block descriptor\nconst int packed_index = bsd->block_mode_packed_index[scb->block_mode];\nassert(packed_index >= 0 && packed_index < bsd->block_mode_count);\nconst block_mode& bm = bsd->block_modes[packed_index];\n- const decimation_table *dt = dts[bm.decimation_mode];\n+ const decimation_table *dt = bsd->decimation_tables[bm.decimation_mode];\n- int is_dual_plane = bm.is_dual_plane;\n- int weight_quant_level = bm.quant_mode;\n-\n- int weight_count = dt->weight_count;\n- int texel_count = bsd->texel_count;\n-\n- promise(partition_count > 0);\n- promise(weight_count > 0);\n- promise(texel_count > 0);\n-\n- // decode the color endpoints\n- vint4 color_endpoint0[4];\n- vint4 color_endpoint1[4];\n- int rgb_hdr_endpoint[4];\n- int alpha_hdr_endpoint[4];\n- int nan_endpoint[4];\n-\n- for (int i = 0; i < partition_count; i++)\n- {\n- unpack_color_endpoints(config.profile,\n- scb->color_formats[i],\n- scb->color_quant_level,\n- scb->color_values[i],\n- &(rgb_hdr_endpoint[i]),\n- &(alpha_hdr_endpoint[i]),\n- &(nan_endpoint[i]),\n- &(color_endpoint0[i]),\n- &(color_endpoint1[i]));\n- }\n+ bool is_dual_plane = bm.is_dual_plane != 0;\n// Unquantize and undecimate the weights\nint weights[MAX_TEXELS_PER_BLOCK];\nint plane2_weights[MAX_TEXELS_PER_BLOCK];\n- unpack_weights(*bsd, *scb, *dt, is_dual_plane, weight_quant_level, weights, plane2_weights);\n+ unpack_weights(*bsd, *scb, *dt, is_dual_plane, bm.quant_mode, weights, plane2_weights);\n- // Now that we have endpoint colors and weights, we can unpack texel colors\nint plane2_component = is_dual_plane ? scb->plane2_component : -1;\nvmask4 plane2_mask = vint4::lane_id() == vint4(plane2_component);\nfloat summa = 0.0f;\n- for (int i = 0; i < texel_count; i++)\n+ for (int i = 0; i < partition_count; i++)\n{\n- int partition = pt->partition_of_texel[i];\n+ // Decode the color endpoints for this partition\n+ vint4 ep0;\n+ vint4 ep1;\n+ bool rgb_lns;\n+ bool nan;\n+ bool a_lns;\n- vint4 ep0 = color_endpoint0[partition];\n- vint4 ep1 = color_endpoint1[partition];\n+ unpack_color_endpoints(config.profile,\n+ scb->color_formats[i],\n+ scb->color_quant_level,\n+ scb->color_values[i],\n+ &rgb_lns, &a_lns, &nan,\n+ &ep0, &ep1);\n+ vmask4 lns_mask(rgb_lns, rgb_lns, rgb_lns, a_lns);\n+\n+ // Unpack and compute error for each texel in the partition\n+ int texel_count = pt->partition_texel_count[i];\n+ for (int j = 0; j < texel_count; j++)\n+ {\n+ int tix = pt->texels_of_partition[i][j];\nvint4 colori = lerp_color_int(config.profile,\n- ep0,\n- ep1,\n- weights[i],\n- plane2_weights[i],\n- plane2_mask);\n+ ep0, ep1,\n+ weights[tix],\n+ plane2_weights[tix], plane2_mask);\nvfloat4 color = int_to_float(colori);\n- vfloat4 oldColor = blk->texel(i);\n+ vfloat4 oldColor = blk->texel(tix);\n+ // Compare error using a perceptual decode metric for RGBM textures\nif (config.flags & ASTCENC_FLG_MAP_RGBM)\n{\n- // Fail encodings that result in zero weight M pixels. Note that\n- // this can cause \"interesting\" artifacts if we reject all useful\n- // encodings - we typically get max brightness encodings instead\n- // which look just as bad. We recommend users apply a bias to their\n- // stored M value, limiting the lower value to 16 or 32 to avoid\n- // getting small M values post-quantization, but we can't prove it\n- // would never happen, especially at low bit rates ...\n+ // Fail encodings that result in zero weight M pixels. Note that this can cause\n+ // \"interesting\" artifacts if we reject all useful encodings - we typically get max\n+ // brightness encodings instead which look just as bad. We recommend users apply a\n+ // bias to their stored M value, limiting the lower value to 16 or 32 to avoid\n+ // getting small M values post-quantization, but we can't prove it would never\n+ // happen, especially at low bit rates ...\nif (color.lane<3>() == 0.0f)\n{\nreturn -1e30f;\n@@ -442,6 +419,8 @@ float compute_symbolic_block_difference(\nfloat metric = dot_s(error, ewb->error_weights[i]);\nsumma += astc::min(metric, 1e30f);\n}\n+ }\n+\nreturn summa;\n}\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_entry.cpp", "new_path": "Source/astcenc_entry.cpp", "diff": "@@ -1082,9 +1082,9 @@ astcenc_error astcenc_get_block_info(\n// Unpack color endpoints for each active partition\nfor (int i = 0; i < scb.partition_count; i++)\n{\n- int rgb_hdr;\n- int a_hdr;\n- int nan;\n+ bool rgb_hdr;\n+ bool a_hdr;\n+ bool nan;\nvint4 endpnt[2];\nunpack_color_endpoints(ctx->config.profile,\n@@ -1096,7 +1096,7 @@ astcenc_error astcenc_get_block_info(\n// Store the color endpoint mode info\ninfo->color_endpoint_modes[i] = scb.color_formats[i];\n- info->is_hdr_block |= (rgb_hdr != 0) | (a_hdr != 0);\n+ info->is_hdr_block = info->is_hdr_block || rgb_hdr || a_hdr;\n// Store the unpacked and decoded color endpoint\nvmask4 hdr_mask(rgb_hdr, rgb_hdr, rgb_hdr, a_hdr);\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -1233,9 +1233,9 @@ void unpack_color_endpoints(\nint format,\nint quant_level,\nconst int* input,\n- int* rgb_hdr,\n- int* alpha_hdr,\n- int* nan_endpoint,\n+ bool* rgb_hdr,\n+ bool* alpha_hdr,\n+ bool* nan_endpoint,\nvint4* output0,\nvint4* output1);\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Relocate unpack_color_endpoint in partition loop