xref: /aosp_15_r20/external/angle/src/libANGLE/renderer/vulkan/doc/FormatTablesAndEmulation.md (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1# Format Tables and Format Emulation
2
3## Overrides and Fallbacks
4
5The [required Vulkan format support][VulkanRequiredSupport] tables do not implement the full set of
6formats needed for OpenGL conformance with extensions. ANGLE emulates missing formats using *format
7overrides* and *format fallbacks*.
8
9An *override* implements a missing GL format with a required format in all cases. For example, the
10luminance texture format `L8_UNORM` does not exist in Vulkan. We override `L8_UNORM` with the
11required image format `R8_UNORM`.
12
13A *fallback* is one or more non-required formats ANGLE checks for support at runtime. For example,
14`R8_UNORM` is not a required vertex buffer format. Some drivers do support `R8_UNORM` for vertex
15buffers. So at runtime we check for sampled image support and fall back to `R32_FLOAT` if `R8_UNORM`
16is not supported.
17
18## The Vulkan Format Table
19
20Overrides and fallbacks are implemented in ANGLE's [Vulkan format table][../vk_format_table_autogen.cpp].
21The table is auto-generated by [`gen_vk_format_table.py`](../gen_vk_format_table.py). We store the mapping from
22[`angle::Format::ID`](../../FormatID_autogen.h) to [VkFormat][VkFormat] in
23[`vk_format_map.json`](../vk_format_map.json). The format map also lists the overrides and fallbacks.
24To update the tables please modify the format map JSON and then run
25[`scripts/run_code_generation.py`][RunCodeGeneration].
26
27The [`vk::Format`](../vk_format_utils.h) class describes the information ANGLE needs for a particular
28`VkFormat`. The 'intended' format ID is a reference to the front-end format. The 'actual Image' and
29'actual Buffer' formats are the native Vulkan formats that implement a particular front-end format
30for `VkImages` and `VkBuffers`. For the above example of `R8_UNORM` overriding `L8_UNORM`,
31`L8_UNORM` is the intended format and `R8_UNORM` is the actual Image format.
32
33For more information please see the source files.
34
35[VulkanRequiredSupport]: https://renderdoc.org/vkspec_chunked/chap37.html#features-required-format-support
36[VkFormat]: https://renderdoc.org/vkspec_chunked/chap37.html#VkFormat
37[RunCodeGeneration]: ../../../../scripts/run_code_generation.py
38