Let's take the following 6 VkFormats
for example:
VK_FORMAT_R8_UNORM
VK_FORMAT_R8_SNORM
VK_FORMAT_R8_USCALED
VK_FORMAT_R8_SSCALED
VK_FORMAT_R8_UINT
VK_FORMAT_R8_SINT
All of these specify a one-component 8-bit format that has a single 8-bit R component.
The formats differ in whether they are (a) normalized, (b) scaled; or (c) integer. What does that mean? What are the differences between those three things? Where is that specified?
Are all 256 possible values of 8-bits meaningful and valid in all six formats?
(They also differ in whether they are signed or unsigned. I assume this means whether their underlying types are like the C types int8_t
or uint8_t
?)
A Normalized Integer is an integer which is used to store a decimal floating point number. When formats use such an integer, OpenGL will automatically convert them to/from floating point values as needed.
UNORM. Unsigned normalized integer, meaning that for an n-bit number, all 0's means 0.0f, and all 1's means 1.0f. A sequence of evenly spaced floating point values from 0.0f to 1.0f are represented. e.g. a 2-bit UNORM represents 0.0f, 1/3, 2/3, and 1.0f.
Refer to Identification of Formats and Conversion from Normalized Fixed-Point to Floating-Point in the specification.
UNORM
is a float
in the range of [0, 1]
.SNORM
is the same but in the range of [-1, 1]
USCALED
is the unsigned integer value converted to float
SSCALED
is the integer value converted to float
UINT
is an unsigned integerSINT
is a signed integerI.e. for the VK_FORMAT_R8_*
:
UNORM
raw 0
would give 0.0f
, raw 255
would give 1.0f
SNORM
raw -127
(resp. 129
) would give -1.0f
, raw 127
would give 1.0f
USCALED
raw 0
would give 0.0f
, raw 255
would give 255.0f
SSCALED
raw -128
(resp. 128
) would give -128.0f
, raw 127
would give 127.0f
-128
(-2n-1) is not meaningful in SNORM
, and simply clamps to -1.0f
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With