Hoist channel_weight setup out of block loop
@@ -825,15 +825,22 @@ static void compress_image(
int xblocks = (dim_x + block_x - 1) / block_x;
int yblocks = (dim_y + block_y - 1) / block_y;
int zblocks = (dim_z + block_z - 1) / block_z;
+ int block_count = zblocks * yblocks * xblocks;
int row_blocks = xblocks;
int plane_blocks = xblocks * yblocks;
+ // Populate the block channel weights
+ blk.channel_weight = vfloat4(ctx.config.cw_r_weight,
+ ctx.config.cw_g_weight,
+ ctx.config.cw_b_weight,
+ ctx.config.cw_a_weight);
+
// Use preallocated scratch buffer
auto& temp_buffers = ctx.working_buffers[thread_index];
// Only the first thread actually runs the initializer
- ctx.manage_compress.init(zblocks * yblocks * xblocks);
+ ctx.manage_compress.init(block_count);
// All threads run this processing loop until there is no work remaining
while (true)
@@ -905,12 +912,6 @@ static void compress_image(
blk.grayscale = true;
}
- // Populate the block channel weights
- blk.channel_weight = vfloat4(ctx.config.cw_r_weight,
- ctx.config.cw_g_weight,
- ctx.config.cw_b_weight,
- ctx.config.cw_a_weight);
-
int offset = ((z * yblocks + y) * xblocks + x) * 16;
uint8_t *bp = buffer + offset;
physical_compressed_block* pcb = reinterpret_cast<physical_compressed_block*>(bp);
