4
$\begingroup$

As stated in documentation possible values for layout qualifiers of image formats are (for example floating point):

Floating-point layout image formats:

  • rgba32f
  • rgba16f
  • rg32f
  • rg16f
  • r11f_g11f_b10f
  • r32f
  • r16f
  • rgba16
  • rgb10_a2
  • rgba8
  • rg16
  • rg8
  • r16
  • r8
  • rgba16_snorm
  • rgba8_snorm
  • rg16_snorm
  • rg8_snorm
  • r16_snorm
  • r8_snorm

So we can use R, RG and RGBA formats. But why RGB (except r11f_g11f_b10f) is not allowed?

$\endgroup$
3
  • $\begingroup$ R11F_G11F_B10F is an RGB format. $\endgroup$ Jan 15, 2017 at 1:44
  • $\begingroup$ Keep in mind that the docs don't list all possible formats. There are often vendor-specific formats, and formats that came after the docs were written. $\endgroup$ Jan 15, 2017 at 3:04
  • $\begingroup$ @NicolBolas Yeah because it has 32 bits overall, now I see it. $\endgroup$
    – mdkdy
    Jan 15, 2017 at 10:19

1 Answer 1

8
$\begingroup$

RGB8 format and similar are often not supported by GPUs (or only supported for a subset of GPU operations) because they don't have a power-of-two number of bytes per pixel. RGB8 would be 24 bits or 3 bytes per pixel. All the formats in that list have 1, 2, 4, 8, or 16 bytes per pixel.

Using a power of two simplifies addressing calculations in the hardware, because it can be implemented using a shift instead of a full multiply. (A shift by a fixed value such as 2 bits can even be implemented in hardware without any actual "calculations" at all, just by routing wires.) It also means that pixels are always nicely aligned with respect to boundaries of memory pages, cache lines, etc., which no doubt simplifies many things in the hardware.

$\endgroup$

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.