tree: ac5fa796b2fd105889bb19904adb44e6dc28bf51 [path history] [tgz]
  1. android/
  2. doc/
  3. fuchsia/
  4. ggp/
  5. mac/
  6. shaders/
  7. win32/
  8. xcb/
  9. BufferVk.cpp
  10. BufferVk.h
  12. CompilerVk.cpp
  13. CompilerVk.h
  14. ContextVk.cpp
  15. ContextVk.h
  16. DeviceVk.cpp
  17. DeviceVk.h
  18. DisplayVk.cpp
  19. DisplayVk.h
  20. DisplayVk_api.h
  21. FenceNVVk.cpp
  22. FenceNVVk.h
  23. FramebufferVk.cpp
  24. FramebufferVk.h
  28. GlslangWrapperVk.cpp
  29. GlslangWrapperVk.h
  30. ImageVk.cpp
  31. ImageVk.h
  32. MemoryObjectVk.cpp
  33. MemoryObjectVk.h
  34. OverlayVk.cpp
  35. OverlayVk.h
  36. OWNERS
  37. PersistentCommandPool.cpp
  38. PersistentCommandPool.h
  39. ProgramExecutableVk.cpp
  40. ProgramExecutableVk.h
  41. ProgramPipelineVk.cpp
  42. ProgramPipelineVk.h
  43. ProgramVk.cpp
  44. ProgramVk.h
  45. QueryVk.cpp
  46. QueryVk.h
  48. RenderbufferVk.cpp
  49. RenderbufferVk.h
  50. RendererVk.cpp
  51. RendererVk.h
  52. RenderTargetVk.cpp
  53. RenderTargetVk.h
  54. ResourceVk.cpp
  55. ResourceVk.h
  56. SamplerVk.cpp
  57. SamplerVk.h
  58. SecondaryCommandBuffer.cpp
  59. SecondaryCommandBuffer.h
  60. SemaphoreVk.cpp
  61. SemaphoreVk.h
  62. ShaderVk.cpp
  63. ShaderVk.h
  64. SurfaceVk.cpp
  65. SurfaceVk.h
  66. SyncVk.cpp
  67. SyncVk.h
  68. TextureVk.cpp
  69. TextureVk.h
  70. TransformFeedbackVk.cpp
  71. TransformFeedbackVk.h
  72. UtilsVk.cpp
  73. UtilsVk.h
  74. VertexArrayVk.cpp
  75. VertexArrayVk.h
  76. vk_cache_utils.cpp
  77. vk_cache_utils.h
  78. vk_caps_utils.cpp
  79. vk_caps_utils.h
  80. vk_ext_provoking_vertex.h
  81. vk_format_map.json
  82. vk_format_table_autogen.cpp
  83. vk_format_utils.cpp
  84. vk_format_utils.h
  85. vk_headers.h
  86. vk_helpers.cpp
  87. vk_helpers.h
  88. vk_internal_shaders_autogen.cpp
  89. vk_internal_shaders_autogen.gni
  90. vk_internal_shaders_autogen.h
  91. vk_mandatory_format_support_data.json
  92. vk_mandatory_format_support_table_autogen.cpp
  93. vk_mem_alloc_wrapper.cpp
  94. vk_mem_alloc_wrapper.h
  95. vk_utils.cpp
  96. vk_utils.h
  97. vk_wrapper.h

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 the following ContextVk APIs:

  • endRenderPassAndGetCommandBuffer: returns a secondary command buffer outside a RenderPass instance.
  • flushAndBeginRenderPass: returns a secondary command buffer inside a RenderPass instance.
  • flushAndGetPrimaryCommandBuffer: returns the primary command buffer. You should rarely need this API.

Note: All of these commands may write out (aka flush) prior pending commands into a primary command buffer. When a RenderPass is open endRenderPassAndGetCommandBuffer will flush the pending RenderPass commands. flushAndBeginRenderPass will flush out pending commands outside a RenderPass to a primary buffer. On submit ANGLE submits the primary command buffer to a VkQueue.

If you need to record inside a RenderPass, use flushAndBeginRenderPass. Otherwise, use endRenderPassAndGetCommandBuffer. You should rarely need to call flushAndGetPrimaryCommandBuffer. It's there for commands like debug labels, barriers and queries that need to be recorded serially on the primary command buffer.

The back-end usually records Image and Buffer barriers through additional ContextVk APIs:

  • onBufferTransferRead/onBufferComputeShaderRead and onBufferTransferWrite/onBufferComputeShaderWrite accumulate VkBuffer barriers.
  • onImageRead and onImageWrite accumulate VkImage barriers.
  • onRenderPassImageWrite is a special API for write barriers inside a RenderPass instance.

After the back-end records commands to the primary buffer we flush (e.g. on swap) or when we call ContextVk::finishToSerial.

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.

    # Get a pointer to a secondary command buffer for command recording. May "flush" the RP.
    vk::CommandBuffer *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: