KhronosGroup / KhronosGroup/DataFormat

RGB9E5 representation / custom float formats

Đang mở
#13 11 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
C
Star
43
Fork
8
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

I am trying to understand how to represent the RGB9E5 format as shown for:
- GL : https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_texture_shared_exponent.txt
- VK : https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#textures-sexp-RGB

Note that the conversion to a value is given in both of the above as `value = mantissa x 2^(exponent - bias - bits_in_mantissa)`
For this format, bias = 15 and bits_in_mantissa = 9, and there is no implicit 1 or sign bit.

The data format spec (section 10.4, non-standard float formats) explains how to encode custom formats, and it gives an example of RGB9E5 as well (table 98), but I think I'm missing how that follows.

`sampleUpper` is supposed to be the mantissa value that represents 1 for exponent (after bias) 0.
`sampleLower` is supposed to be the mantissa value that represents 0 for exponent (after bias) 0.
For RGB9E5, substituting `0` for `exponent - bias`, we are left with `value = mantissa x 2^(0 - 9)`.
To represent the value 1, mantissa should then be `512` because `1 = 512 x 2^-9`.
To represent the value 0, mantissa should then be `0` because `0 = 0 x 2^-9`.

However, in Table 98 (the example for RGB9E5) `sampleUpper` is set to 256, not 512.
(As expected though, sampleLower = 0, bitLength = 9 and bias (sampleUpper for the exponent sample) = 15).

I wonder if Table 98 contains a mistake, or if I am missing something somewhere.

PS: if 512 is indeed the correct value, then that runs afoul of the "implicit one detection", because 512 is one larger than the representable mantissa value. Moreover, to actually represent the value 1 in RGB9E5, I believe you need to use exponent-after-bias 1 (or higher) or you run out of mantissa bits.

PS2: And by extension, there is no single representation of 1 in RGB9E5 either, because I can arbitrarily bump the exponent by one and shift the mantissa by one, and it's still a value of 1. Is there a specific "representation of 1" that should be used?

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

Read section 10.4 and Table 98 of the data format specification, then compare the RGB9E5 definitions in the linked OpenGL and Vulkan specifications. Determine whether sampleUpper and the representation-of-one guidance are consistent, and document or correct the specification accordingly.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Lĩnh vực
documentation
Loại issue
Tài liệu
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
25/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.