Skip to content

Commit ffbccca

Browse files
committed
Fix error block output color handling
1 parent cd4ebfa commit ffbccca

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

Source/astcenc_entry.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1119,7 +1119,7 @@ astcenc_error astcenc_decompress_image(
11191119
scb, blk);
11201120

11211121
write_image_block(image_out, blk, *ctx->bsd,
1122-
x * block_x, y * block_y, z * block_z, *swizzle);
1122+
x * block_x, y * block_y, z * block_z, *swizzle);
11231123
}
11241124

11251125
ctx->manage_decompress.complete_task_assignment(count);

Source/astcenc_image.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,9 @@ void write_image_block(
318318
{
319319
vint4 colori = vint4::zero();
320320

321-
if (blk.data_r[idx] == std::numeric_limits<float>::quiet_NaN())
321+
// Errors are NaN encoded - convert to magenta error color
322+
if (blk.data_r[idx] != blk.data_r[idx])
322323
{
323-
// Can't display NaN - show magenta error color
324324
colori = vint4(0xFF, 0x00, 0xFF, 0xFF);
325325
}
326326
else if (needs_swz)
@@ -374,7 +374,8 @@ void write_image_block(
374374
{
375375
vint4 color;
376376

377-
if (blk.data_r[idx] == std::numeric_limits<float>::quiet_NaN())
377+
// Errors are NaN encoded - convert to FP16 NaN
378+
if (blk.data_r[idx] != blk.data_r[idx])
378379
{
379380
color = vint4(0xFFFF);
380381
}
@@ -433,7 +434,8 @@ void write_image_block(
433434
{
434435
vfloat4 color = blk.texel(idx);
435436

436-
if (color.lane<0>() == std::numeric_limits<float>::quiet_NaN())
437+
// Errors are NaN encoded - convert to FP32 NaN
438+
if (color.lane<0>() != color.lane<0>())
437439
{
438440
color = vfloat4(std::numeric_limits<float>::quiet_NaN());
439441
}

0 commit comments

Comments
 (0)