Skip to content

Commit f09cf0a

Browse files
committed
rdo-partitions precedes no-multithreading
1 parent a428388 commit f09cf0a

4 files changed

+8
-44
lines changed

Source/astcenc.h

-5
Original file line numberDiff line numberDiff line change
@@ -576,11 +576,6 @@ struct astcenc_config
576576
*/
577577
bool rdo_enabled;
578578

579-
/**
580-
* @brief Disable RDO multithreading (slightly higher compression, deterministic).
581-
*/
582-
bool rdo_no_multithreading;
583-
584579
/**
585580
* @brief RDO quality scalar (lambda).
586581
*/

Source/astcenc_rate_distortion.cpp

+8-30
Original file line numberDiff line numberDiff line change
@@ -38,29 +38,12 @@ static constexpr uint32_t ASTCENC_BYTES_PER_BLOCK = 16;
3838

3939
template<typename T> T sqr(T v) { return v * v; }
4040

41+
extern "C" void progress_emitter(float value);
42+
4143
extern "C" void rdo_progress_emitter(
4244
float value
4345
) {
4446
static float previous_value = 100.0f;
45-
const uint32_t bar_size = 25;
46-
auto parts = static_cast<uint32_t>(value / 4.0f);
47-
48-
char buffer[bar_size + 3];
49-
buffer[0] = '[';
50-
51-
for (uint32_t i = 0; i < parts; i++)
52-
{
53-
buffer[i + 1] = '=';
54-
}
55-
56-
for (uint32_t i = parts; i < bar_size; i++)
57-
{
58-
buffer[i + 1] = ' ';
59-
}
60-
61-
buffer[bar_size + 1] = ']';
62-
buffer[bar_size + 2] = '\0';
63-
6447
if (previous_value == 100.0f)
6548
{
6649
printf("\n\n");
@@ -69,8 +52,7 @@ extern "C" void rdo_progress_emitter(
6952
}
7053
previous_value = value;
7154

72-
printf(" Progress: %s %03.1f%%\r", buffer, static_cast<double>(value));
73-
fflush(stdout);
55+
progress_emitter(value);
7456
}
7557

7658
static uint32_t init_rdo_context(
@@ -419,15 +401,11 @@ void rate_distortion_optimize(
419401
uint32_t zblocks = (image.dim_z + ctx.bsd->zdim - 1u) / ctx.bsd->zdim;
420402
uint32_t total_blocks = xblocks * yblocks * zblocks;
421403

422-
uint32_t blocks_per_task = total_blocks;
423-
if (!ctx.config.rdo_no_multithreading)
424-
{
425-
blocks_per_task = astc::min(ctx.config.rdo_lookback, total_blocks);
426-
// There is no way to losslessly partition the job (sequentially dependent on previous output)
427-
// So we reserve only one task for each thread to minimize the quality impact.
428-
uint32_t partitions = ctx.config.rdo_partitions ? ctx.config.rdo_partitions : ctx.thread_count;
429-
blocks_per_task = astc::max(blocks_per_task, (total_blocks - 1) / partitions + 1);
430-
}
404+
uint32_t blocks_per_task = astc::min(ctx.config.rdo_lookback, total_blocks);
405+
// There is no way to losslessly partition the job (sequentially dependent on previous output)
406+
// So we reserve up to one task for each thread to minimize the quality impact.
407+
uint32_t partitions = ctx.config.rdo_partitions ? ctx.config.rdo_partitions : ctx.thread_count;
408+
blocks_per_task = astc::max(blocks_per_task, (total_blocks - 1) / partitions + 1);
431409

432410
uint32_t total_modified = 0;
433411
while (true)

Source/astcenccli_toplevel.cpp

-6
Original file line numberDiff line numberDiff line change
@@ -1180,11 +1180,6 @@ static int edit_astcenc_config(
11801180
argidx += 1;
11811181
config.rdo_enabled = true;
11821182
}
1183-
else if (!strcmp(argv[argidx], "-rdo-no-multithreading"))
1184-
{
1185-
argidx += 1;
1186-
config.rdo_no_multithreading = true;
1187-
}
11881183
else if (!strcmp(argv[argidx], "-rdo-quality"))
11891184
{
11901185
argidx += 2;
@@ -1350,7 +1345,6 @@ static void print_astcenc_config(
13501345
printf(" Rate-distortion opt: %s\n", config.rdo_enabled ? "Enabled" : "Disabled");
13511346
if (config.rdo_enabled)
13521347
{
1353-
printf(" RDO multithreading: %s\n", config.rdo_no_multithreading ? "Disabled" : "Enabled");
13541348
printf(" RDO quality: %g\n", static_cast<double>(config.rdo_quality));
13551349
printf(" RDO lookback: %u blocks\n", config.rdo_lookback);
13561350
printf(" RDO max error scale: %g\n", static_cast<double>(config.rdo_max_smooth_block_error_scale));

Source/astcenccli_toplevel_help.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -389,9 +389,6 @@ ADVANCED COMPRESSION
389389
-rdo
390390
Enable Rate Distortion Optimization (RDO) post-processing.
391391
392-
-rdo-no-multithreading
393-
Disable RDO multithreading (slightly higher compression, deterministic).
394-
395392
-rdo-quality <factor>
396393
RDO quality scalar (lambda). Lower values yield higher
397394
quality/larger LZ compressed files, higher values yield lower

0 commit comments

Comments
 (0)