DataFormat icon indicating copy to clipboard operation
DataFormat copied to clipboard

Table 63, ASTC DFD example is wrong

Open MarkCallow opened this issue 1 year ago • 3 comments

It has two errors.

  1. It gives sampleUpper as 0x7F800000U which is NaN (infinity). It should be 0x3F800000U for 1.0f.
  2. It shows it as signed (sign bit set and sampleLower is -1.0f). ASTC cannot encode values < 0.

MarkCallow avatar Sep 11 '24 03:09 MarkCallow

ASTC can encode negative values but only in void-extent (solid-color) HDR blocks.

lexaknyazev avatar Sep 11 '24 06:09 lexaknyazev

ASTC can encode negative values but only in void-extent (solid-color) HDR blocks.

Then what should the DFD show? I understand from @fluppeteer that the Vulkan spec is going to be changed to say the ASTC HDR formats are unsigned and VK_FORMAT_ASTC_*_UFLOAT aliases will be added.

UASTC HDR has just been released with sampleLower 0.0f and the channelType sign bit unset. If it needs to be changed we need to act quickly.

Regardless of the answer to the above, sampleUpper is broken.

MarkCallow avatar Sep 11 '24 12:09 MarkCallow

Then what should the DFD show?

Based on the current state of the ASTC specs, solid color ASTC HDR blocks can technically represent both positive and negative infinities as well as NaNs because they simply contain raw half-float values. The spec says however:

In the HDR case, if the color component values are infinity or NaN, this will result in undefined behavior.

I'm reading this as "hardware sampling from such blocks is undefined", but there's nothing inherently wrong with data itself.

It may be that formal support for infinities, NaNs, and negative values in solid-color ASTC HDR blocks is just a spec oversight and therefore all ASTC users should assume only non-negative finite values.

lexaknyazev avatar Sep 11 '24 12:09 lexaknyazev

Sorry for the delay in this (and everything else). I believe the consensus is that everyone's hardware actually does pass through negative void extent blocks correctly - so, while it would be kind of esoteric to do so, I don't think it's actually invalid for a user to encode negative values in ASTC, and if someone wanted to encode void extent blocks with a negative then they could. I think we leave ASTC HDR as signed (which seemed to be the consensus from the Vulkan discussions, unless I'm mis-remembering), and it's up to UASTC HDR to report that the encoding of negative void-extent blocks is unsupported. I don't think that's a problem - not all the other things that ASTC can represent are supported either (notably in terms of block sizes).

I'm assuming I can close this as "won't fix" unless there's push back?

fluppeteer avatar Dec 06 '24 04:12 fluppeteer

Should sampleUpper be set to 1.0?

lexaknyazev avatar Dec 06 '24 08:12 lexaknyazev

Oh, sorry. Yes, I do have that fix applied locally, and should be in whatever I share today. "Partial fix", then. :-)

fluppeteer avatar Dec 06 '24 11:12 fluppeteer

Fixed (hopefully) in 1.4.0.

fluppeteer avatar Feb 13 '25 02:02 fluppeteer