15

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 ?)

1 Answer 1

27

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 integer
  • SINT is a signed integer

I.e. for the VK_FORMAT_R8_*:

  • for UNORM raw 0 would give 0.0f, raw 255 would give 1.0f
  • for 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
  • SSCALEDraw -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.

1
  • Thanks @krOoze, 32.1.3 was sneakily hiding between the lengthy 31.1 and 31.2 :) Jan 8, 2020 at 11:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.