tree: d9c7bbbdd65d6201b60ad285a317f68069de5613
  1. android/
  2. display/
  3. doc/
  4. fuchsia/
  5. ggp/
  6. headless/
  7. mac/
  8. shaders/
  9. win32/
  10. xcb/
  11. BufferVk.cpp
  12. BufferVk.h
  13. BUILD.gn
  14. cl_types.h
  15. CLCommandQueueVk.cpp
  16. CLCommandQueueVk.h
  17. CLContextVk.cpp
  18. CLContextVk.h
  19. CLDeviceVk.cpp
  20. CLDeviceVk.h
  21. CLEventVk.cpp
  22. CLEventVk.h
  23. CLKernelVk.cpp
  24. CLKernelVk.h
  25. CLMemoryVk.cpp
  26. CLMemoryVk.h
  27. CLPlatformVk.cpp
  28. CLPlatformVk.h
  29. CLProgramVk.cpp
  30. CLProgramVk.h
  31. CLSamplerVk.cpp
  32. CLSamplerVk.h
  33. CommandProcessor.cpp
  34. CommandProcessor.h
  35. CompilerVk.cpp
  36. CompilerVk.h
  37. ContextVk.cpp
  38. ContextVk.h
  39. DebugAnnotatorVk.cpp
  40. DebugAnnotatorVk.h
  41. DeviceVk.cpp
  42. DeviceVk.h
  43. DisplayVk.cpp
  44. DisplayVk.h
  45. DisplayVk_api.h
  46. FenceNVVk.cpp
  47. FenceNVVk.h
  48. FramebufferVk.cpp
  49. FramebufferVk.h
  50. gen_vk_format_table.py
  51. gen_vk_internal_shaders.py
  52. gen_vk_mandatory_format_support_table.py
  53. GlslangWrapperVk.cpp
  54. GlslangWrapperVk.h
  55. ImageVk.cpp
  56. ImageVk.h
  57. MemoryObjectVk.cpp
  58. MemoryObjectVk.h
  59. OverlayVk.cpp
  60. OverlayVk.h
  61. OWNERS
  62. PersistentCommandPool.cpp
  63. PersistentCommandPool.h
  64. ProgramExecutableVk.cpp
  65. ProgramExecutableVk.h
  66. ProgramPipelineVk.cpp
  67. ProgramPipelineVk.h
  68. ProgramVk.cpp
  69. ProgramVk.h
  70. QueryVk.cpp
  71. QueryVk.h
  72. README.md
  73. RenderbufferVk.cpp
  74. RenderbufferVk.h
  75. RendererVk.cpp
  76. RendererVk.h
  77. RenderTargetVk.cpp
  78. RenderTargetVk.h
  79. ResourceVk.cpp
  80. ResourceVk.h
  81. SamplerVk.cpp
  82. SamplerVk.h
  83. SecondaryCommandBuffer.cpp
  84. SecondaryCommandBuffer.h
  85. SemaphoreVk.cpp
  86. SemaphoreVk.h
  87. ShaderVk.cpp
  88. ShaderVk.h
  89. SurfaceVk.cpp
  90. SurfaceVk.h
  91. SyncVk.cpp
  92. SyncVk.h
  93. TextureVk.cpp
  94. TextureVk.h
  95. TransformFeedbackVk.cpp
  96. TransformFeedbackVk.h
  97. UtilsVk.cpp
  98. UtilsVk.h
  99. VertexArrayVk.cpp
  100. VertexArrayVk.h
  101. vk_cache_utils.cpp
  102. vk_cache_utils.h
  103. vk_caps_utils.cpp
  104. vk_caps_utils.h
  105. vk_format_map.json
  106. vk_format_table_autogen.cpp
  107. vk_format_utils.cpp
  108. vk_format_utils.h
  109. vk_helpers.cpp
  110. vk_helpers.h
  111. vk_internal_shaders_autogen.cpp
  112. vk_internal_shaders_autogen.gni
  113. vk_internal_shaders_autogen.h
  114. vk_mandatory_format_support_data.json
  115. vk_mandatory_format_support_table_autogen.cpp
  116. vk_mem_alloc_wrapper.cpp
  117. vk_mem_alloc_wrapper.h
  118. vk_utils.cpp
  119. vk_utils.h
  120. vk_wrapper.h
src/libANGLE/renderer/vulkan/README.md

ANGLE: Vulkan Back-end

ANGLE's Vulkan back-end implementation lives in this folder.

Vulkan is an explicit graphics API. It has a lot in common with other explicit APIs such as Microsoft‘s D3D12 and Apple’s Metal. Compared to APIs like OpenGL or D3D11 explicit APIs can offer a number of significant benefits:

  • Lower API call CPU overhead.
  • A smaller API surface with more direct hardware control.
  • Better support for multi-core programming.
  • Vulkan in particular has open-source tooling and tests.

Back-end Design

The RendererVk class represents an EGLDisplay. RendererVk owns shared global resources like the VkDevice, VkQueue, the Vulkan format tables and internal Vulkan shaders. The ContextVk class implements the back-end of a front-end OpenGL Context. ContextVk processes state changes and handles action commands like glDrawArrays and glDrawElements.

Command recording

The back-end records commands into command buffers via the following ContextVk APIs:

  • beginNewRenderPass: Writes out (aka flushes) prior pending commands into a primary command buffer, then starts a new render pass. Returns a secondary command buffer inside a render pass instance.
  • getOutsideRenderPassCommandBuffer: May flush prior command buffers and close the render pass if necessary, in addition to issuing the appropriate barriers. Returns a secondary command buffer outside a render pass instance.
  • getStartedRenderPassCommands: Returns a reference to the currently open render pass' commands buffer.

The back-end (mostly) records Image and Buffer barriers through additional CommandBufferAccess APIs, the result of which is passed to getOutsideRenderPassCommandBuffer. Note that the barriers are not actually recorded until getOutsideRenderPassCommandBuffer is called:

  • onBufferTransferRead and onBufferComputeShaderRead accumulate VkBuffer read barriers.
  • onBufferTransferWrite and onBufferComputeShaderWrite accumulate VkBuffer write barriers.
  • onBuffferSelfCopy is a special case for VkBuffer self copies. It behaves the same as write.
  • onImageTransferRead and onImageComputerShadeRead accumulate VkImage read barriers.
  • onImageTransferWrite and onImageComputerShadeWrite accumulate VkImage write barriers.
  • onImageRenderPassRead and onImageRenderPassWrite accumulate VkImage barriers inside a started RenderPass.

After the back-end records commands to the primary buffer and we flush (e.g. on swap) or when we call ContextVk::finishToSerial, ANGLE submits the primary command buffer to a VkQueue.

See the code for more details.

Simple command recording example

In this example we'll be recording a buffer copy command:

    // Ensure that ANGLE sets proper read and write barriers for the Buffers.
    vk::CommandBufferAccess access;
    access.onBufferTransferWrite(destBuffer);
    access.onBufferTransferRead(srcBuffer);

    // Get a pointer to a secondary command buffer for command recording.
    vk::CommandBuffer *commandBuffer;
    ANGLE_TRY(contextVk->getOutsideRenderPassCommandBuffer(access, &commandBuffer));

    // Record the copy command into the secondary buffer. We're done!
    commandBuffer->copyBuffer(srcBuffer->getBuffer(), destBuffer->getBuffer(), copyCount, copies);

Additional Reading

More implementation details can be found in the doc directory: