• Home
Name Date Size #Lines LOC

..--

android/06-Sep-2024-1,223814

doc/06-Sep-2024-814600

fuchsia/06-Sep-2024-205120

ggp/06-Sep-2024-196118

linux/06-Sep-2024-2,4661,670

mac/06-Sep-2024-603447

null/06-Sep-2024-9956

shaders/06-Sep-2024-36,59434,427

win32/06-Sep-2024-316217

AllocatorHelperPool.cppD06-Sep-20241.8 KiB6645

AllocatorHelperPool.hD06-Sep-20245.4 KiB161106

AllocatorHelperRing.cppD06-Sep-20243.4 KiB127100

AllocatorHelperRing.hD06-Sep-20245.2 KiB159113

BUILD.gnD06-Sep-20245.7 KiB184155

BufferVk.cppD06-Sep-202450.1 KiB1,293945

BufferVk.hD06-Sep-202410.7 KiB259194

CLCommandQueueVk.cppD06-Sep-202436.2 KiB850678

CLCommandQueueVk.hD06-Sep-202413.5 KiB278212

CLContextVk.cppD06-Sep-20249.5 KiB277232

CLContextVk.hD06-Sep-20244.6 KiB12182

CLDeviceVk.cppD06-Sep-202411.6 KiB282228

CLDeviceVk.hD06-Sep-20241.9 KiB5534

CLEventVk.cppD06-Sep-20243 KiB10063

CLEventVk.hD06-Sep-20241.9 KiB6138

CLKernelVk.cppD06-Sep-20247.2 KiB189148

CLKernelVk.hD06-Sep-20243.5 KiB10983

CLMemoryVk.cppD06-Sep-20246.5 KiB232190

CLMemoryVk.hD06-Sep-20243 KiB10268

CLPlatformVk.cppD06-Sep-20249.2 KiB302256

CLPlatformVk.hD06-Sep-20242.7 KiB8554

CLProgramVk.cppD06-Sep-202439.6 KiB965831

CLProgramVk.hD06-Sep-20249.9 KiB289234

CLSamplerVk.cppD06-Sep-2024451 186

CLSamplerVk.hD06-Sep-2024677 2814

CommandGraph.cppD06-Sep-202450.7 KiB1,3791,097

CommandGraph.hD06-Sep-202431 KiB814507

CommandProcessor.cppD06-Sep-202465.8 KiB1,8531,480

CommandProcessor.hD06-Sep-202427.6 KiB717515

CompilerVk.cppD06-Sep-2024537 2711

CompilerVk.hD06-Sep-2024735 3114

ContextVk.cppD06-Sep-2024375.1 KiB8,9956,660

ContextVk.hD06-Sep-202491.7 KiB1,8001,263

DebugAnnotatorVk.cppD06-Sep-20241.9 KiB6347

DebugAnnotatorVk.hD06-Sep-20241.1 KiB3621

DeviceVk.cppD06-Sep-20246.9 KiB223182

DeviceVk.hD06-Sep-20242.1 KiB6140

DisplayVk.cppD06-Sep-202424.5 KiB684544

DisplayVk.hD06-Sep-20246.3 KiB14396

DisplayVk_api.hD06-Sep-20242.3 KiB6843

FenceNVVk.cppD06-Sep-20241.3 KiB5232

FenceNVVk.hD06-Sep-2024960 3520

FramebufferVk.cppD06-Sep-2024165.3 KiB3,7912,813

FramebufferVk.hD06-Sep-202415.7 KiB339249

ImageVk.cppD06-Sep-20245.4 KiB172127

ImageVk.hD06-Sep-20241.6 KiB6136

MemoryObjectVk.cppD06-Sep-20248.8 KiB256205

MemoryObjectVk.hD06-Sep-20242.4 KiB6946

MemoryTracking.cppD06-Sep-202423.6 KiB610499

MemoryTracking.hD06-Sep-20247.7 KiB222160

OWNERSD06-Sep-202440 32

OverlayVk.cppD06-Sep-20247.1 KiB173123

OverlayVk.hD06-Sep-20241.2 KiB4727

PersistentCommandPool.cppD06-Sep-20243.6 KiB11979

PersistentCommandPool.hD06-Sep-20241.2 KiB5328

ProgramExecutableVk.cppD06-Sep-202499.8 KiB2,4491,908

ProgramExecutableVk.hD06-Sep-202429.6 KiB615488

ProgramPipelineVk.cppD06-Sep-20244.7 KiB11782

ProgramPipelineVk.hD06-Sep-20241.3 KiB4526

ProgramVk.cppD06-Sep-202415.4 KiB408286

ProgramVk.hD06-Sep-20241.9 KiB5738

QueryVk.cppD06-Sep-202423.2 KiB659465

QueryVk.hD06-Sep-20243.3 KiB8751

README.mdD06-Sep-20244.9 KiB9672

RenderTargetVk.cppD06-Sep-202415.4 KiB407315

RenderTargetVk.hD06-Sep-202411.1 KiB250127

RenderbufferVk.cppD06-Sep-202416.3 KiB410320

RenderbufferVk.hD06-Sep-20245.9 KiB13591

SamplerVk.cppD06-Sep-20241.2 KiB4929

SamplerVk.hD06-Sep-20241 KiB4224

SecondaryCommandBuffer.cppD06-Sep-202441.4 KiB871838

SecondaryCommandBuffer.hD06-Sep-202476.5 KiB2,1571,772

SecondaryCommandPool.cppD06-Sep-20244 KiB12796

SecondaryCommandPool.hD06-Sep-20242.2 KiB7134

SemaphoreVk.cppD06-Sep-202410 KiB261177

SemaphoreVk.hD06-Sep-20241.6 KiB5030

ShaderInterfaceVariableInfoMap.cppD06-Sep-20248.7 KiB255216

ShaderInterfaceVariableInfoMap.hD06-Sep-20247.4 KiB183147

ShaderVk.cppD06-Sep-20247 KiB240187

ShaderVk.hD06-Sep-2024819 3316

ShareGroupVk.cppD06-Sep-202412.8 KiB385288

ShareGroupVk.hD06-Sep-20246.6 KiB169101

Suballocation.cppD06-Sep-20246.6 KiB203165

Suballocation.hD06-Sep-202415.5 KiB490400

SurfaceVk.cppD06-Sep-2024132.4 KiB3,3172,370

SurfaceVk.hD06-Sep-202425.5 KiB562335

SyncVk.cppD06-Sep-202423.8 KiB714531

SyncVk.hD06-Sep-20247.2 KiB206146

TextureVk.cppD06-Sep-2024186.1 KiB4,3063,220

TextureVk.hD06-Sep-202433.6 KiB680474

TransformFeedbackVk.cppD06-Sep-202411.5 KiB306246

TransformFeedbackVk.hD06-Sep-20244.6 KiB13793

UtilsVk.cppD06-Sep-2024190.8 KiB4,5293,345

UtilsVk.hD06-Sep-202427.3 KiB697549

VertexArrayVk.cppD06-Sep-202457.2 KiB1,2621,012

VertexArrayVk.hD06-Sep-20249.1 KiB227167

VkImageImageSiblingVk.cppD06-Sep-20244.6 KiB142103

VkImageImageSiblingVk.hD06-Sep-20241.6 KiB5431

VulkanSecondaryCommandBuffer.cppD06-Sep-20243.7 KiB11184

VulkanSecondaryCommandBuffer.hD06-Sep-202428.2 KiB692596

cl_types.hD06-Sep-2024538 2411

gen_vk_format_table.pyD06-Sep-20249.6 KiB300223

gen_vk_internal_shaders.pyD06-Sep-202429.5 KiB821568

gen_vk_mandatory_format_support_table.pyD06-Sep-20245.2 KiB147109

spv_utils.cppD06-Sep-2024211.3 KiB5,4053,934

spv_utils.hD06-Sep-20246.7 KiB177118

vk_cache_utils.cppD06-Sep-2024323.2 KiB7,7026,176

vk_cache_utils.hD06-Sep-2024107.1 KiB2,7551,952

vk_caps_utils.cppD06-Sep-202474.5 KiB1,548976

vk_caps_utils.hD06-Sep-20242.8 KiB8854

vk_command_buffer_utils.hD06-Sep-20241.6 KiB5833

vk_format_map.jsonD06-Sep-202423.2 KiB644639

vk_format_table_autogen.cppD06-Sep-2024154.8 KiB3,1842,845

vk_format_utils.cppD06-Sep-202427.2 KiB664517

vk_format_utils.hD06-Sep-202411.6 KiB303200

vk_helpers.cppD06-Sep-2024510.7 KiB12,4579,794

vk_helpers.hD06-Sep-2024170.4 KiB3,9122,840

vk_internal_shaders_autogen.cppD06-Sep-202433.7 KiB618573

vk_internal_shaders_autogen.gniD06-Sep-20247.3 KiB162160

vk_internal_shaders_autogen.hD06-Sep-20249.7 KiB306272

vk_mandatory_format_support_data.jsonD06-Sep-202417.7 KiB439439

vk_mandatory_format_support_table_autogen.cppD06-Sep-202414.4 KiB309291

vk_mem_alloc_wrapper.cppD06-Sep-202412.5 KiB314264

vk_mem_alloc_wrapper.hD06-Sep-20246.6 KiB155117

vk_ref_counted_event.cppD06-Sep-202414.6 KiB436359

vk_ref_counted_event.hD06-Sep-202418.5 KiB487320

vk_renderer.cppD06-Sep-2024267.5 KiB6,1904,326

vk_renderer.hD06-Sep-202451.8 KiB1,226933

vk_resource.cppD06-Sep-20242.7 KiB11080

vk_resource.hD06-Sep-202414.4 KiB422307

vk_utils.cppD06-Sep-202464.6 KiB1,7561,423

vk_utils.hD06-Sep-202449.9 KiB1,4961,120

vk_wrapper.hD06-Sep-202473.4 KiB2,0561,705

vulkan_backend.gniD06-Sep-20245.6 KiB239226

README.md

1# ANGLE: Vulkan Back-end
2
3ANGLE's Vulkan back-end implementation lives in this folder.
4
5[Vulkan](https://www.khronos.org/vulkan/) is an explicit graphics API. It has a lot in common with
6other explicit APIs such as Microsoft's [D3D12][D3D12 Guide] and Apple's
7[Metal](https://developer.apple.com/metal/). Compared to APIs like OpenGL or D3D11 explicit APIs can
8offer a number of significant benefits:
9
10 * Lower API call CPU overhead.
11 * A smaller API surface with more direct hardware control.
12 * Better support for multi-core programming.
13 * Vulkan in particular has open-source tooling and tests.
14
15[D3D12 Guide]: https://docs.microsoft.com/en-us/windows/desktop/direct3d12/directx-12-programming-guide
16
17## Back-end Design
18
19The [`vk::Renderer`](vk::Renderer.cpp) class represents an `EGLDisplay`. `vk::Renderer` owns shared global
20resources like the [VkDevice][VkDevice], [VkQueue][VkQueue], the [Vulkan format tables](vk_format_utils.h)
21and [internal Vulkan shaders](shaders). The [ContextVk](ContextVk.cpp) class implements the back-end
22of a front-end OpenGL Context. ContextVk processes state changes and handles action commands like
23`glDrawArrays` and `glDrawElements`.
24
25## Command recording
26
27A render pass has three states: `unstarted`, started and active (we call it `active` in short),
28started but inactive (we call it `inactive` in short). The back-end records commands into command
29buffers via the following `ContextVk` APIs:
30
31 * `beginNewRenderPass`: Writes out (aka flushes) prior pending commands into a primary command
32   buffer, then starts a new render pass. Returns a secondary command buffer *inside* a render pass
33instance.
34 * `getOutsideRenderPassCommandBuffer`: May flush prior command buffers and close the render pass if
35   necessary, in addition to issuing the appropriate barriers. Returns a secondary command buffer
36*outside* a render pass instance.
37 * `getStartedRenderPassCommands`: Returns a reference to the currently open render pass' commands
38   buffer.
39 * `onRenderPassFinished`: Puts render pass into inactive state where you can not record more
40   commands into secondary command buffer, except in some special cases where ANGLE does some
41optimization internally.
42 * `flushCommandsAndEndRenderPassWithoutSubmit`: Marks the end of render pass. It flushes secondary
43   command buffer into vulkan's primary command buffer, puts secondary command buffer back to
44unstarted state and then goes into recycler for reuse.
45
46The back-end (mostly) records Image and Buffer barriers through additional `CommandBufferAccess`
47APIs, the result of which is passed to `getOutsideRenderPassCommandBuffer`.  Note that the barriers
48are not actually recorded until `getOutsideRenderPassCommandBuffer` is called:
49
50 * `onBufferTransferRead` and `onBufferComputeShaderRead` accumulate `VkBuffer` read barriers.
51 * `onBufferTransferWrite` and `onBufferComputeShaderWrite` accumulate `VkBuffer` write barriers.
52 * `onBuffferSelfCopy` is a special case for `VkBuffer` self copies. It behaves the same as write.
53 * `onImageTransferRead` and `onImageComputerShadeRead` accumulate `VkImage` read barriers.
54 * `onImageTransferWrite` and `onImageComputerShadeWrite` accumulate `VkImage` write barriers.
55 * `onImageRenderPassRead` and `onImageRenderPassWrite` accumulate `VkImage` barriers inside a
56   started RenderPass.
57
58After the back-end records commands to the primary buffer and we flush (e.g. on swap) or when we call
59`vk::Renderer::finishQueueSerial`, ANGLE submits the primary command buffer to a `VkQueue`.
60
61See the [code][CommandAPIs] for more details.
62
63### Simple command recording example
64
65In this example we'll be recording a buffer copy command:
66
67```
68    // Ensure that ANGLE sets proper read and write barriers for the Buffers.
69    vk::CommandBufferAccess access;
70    access.onBufferTransferWrite(dstBuffer);
71    access.onBufferTransferRead(srcBuffer);
72
73    // Get a pointer to a secondary command buffer for command recording.
74    vk::OutsideRenderPassCommandBuffer *commandBuffer;
75    ANGLE_TRY(contextVk->getOutsideRenderPassCommandBuffer(access, &commandBuffer));
76
77    // Record the copy command into the secondary buffer. We're done!
78    commandBuffer->copyBuffer(srcBuffer->getBuffer(), dstBuffer->getBuffer(), copyCount, copies);
79```
80
81## Additional Reading
82
83More implementation details can be found in the `doc` directory:
84
85- [Fast OpenGL State Transitions](doc/FastOpenGLStateTransitions.md)
86- [Shader Module Compilation](doc/ShaderModuleCompilation.md)
87- [OpenGL Line Segment Rasterization](doc/OpenGLLineSegmentRasterization.md)
88- [Format Tables and Emulation](doc/FormatTablesAndEmulation.md)
89- [Deferred Clears](doc/DeferredClears.md)
90- [Queries](doc/Queries.md)
91
92[VkDevice]: https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VkDevice.html
93[VkQueue]: https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VkQueue.html
94[CommandAPIs]: https://chromium.googlesource.com/angle/angle/+/df31624eaf3df986a0bdf3f58a87b79b0cc8db5c/src/libANGLE/renderer/vulkan/ContextVk.h#620
95
96