tree: ed2873af3365a9d7b82f9641ad1b4ac66391799b [path history] [tgz]
  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. CLContextVk.cpp
  15. CLContextVk.h
  16. CLDeviceVk.cpp
  17. CLDeviceVk.h
  18. CLPlatformVk.cpp
  19. CLPlatformVk.h
  20. CommandGraph.cpp
  21. CommandGraph.h
  22. CommandProcessor.cpp
  23. CommandProcessor.h
  24. CompilerVk.cpp
  25. CompilerVk.h
  26. ContextVk.cpp
  27. ContextVk.h
  28. DebugAnnotatorVk.cpp
  29. DebugAnnotatorVk.h
  30. DeviceVk.cpp
  31. DeviceVk.h
  32. DisplayVk.cpp
  33. DisplayVk.h
  34. DisplayVk_api.h
  35. FenceNVVk.cpp
  36. FenceNVVk.h
  37. FramebufferVk.cpp
  38. FramebufferVk.h
  39. gen_vk_format_table.py
  40. gen_vk_internal_shaders.py
  41. gen_vk_mandatory_format_support_table.py
  42. GlslangWrapperVk.cpp
  43. GlslangWrapperVk.h
  44. ImageVk.cpp
  45. ImageVk.h
  46. MemoryObjectVk.cpp
  47. MemoryObjectVk.h
  48. OverlayVk.cpp
  49. OverlayVk.h
  50. OWNERS
  51. PersistentCommandPool.cpp
  52. PersistentCommandPool.h
  53. ProgramExecutableVk.cpp
  54. ProgramExecutableVk.h
  55. ProgramPipelineVk.cpp
  56. ProgramPipelineVk.h
  57. ProgramVk.cpp
  58. ProgramVk.h
  59. QueryVk.cpp
  60. QueryVk.h
  61. README.md
  62. RenderbufferVk.cpp
  63. RenderbufferVk.h
  64. RendererVk.cpp
  65. RendererVk.h
  66. RenderTargetVk.cpp
  67. RenderTargetVk.h
  68. ResourceVk.cpp
  69. ResourceVk.h
  70. SamplerVk.cpp
  71. SamplerVk.h
  72. SecondaryCommandBuffer.cpp
  73. SecondaryCommandBuffer.h
  74. SemaphoreVk.cpp
  75. SemaphoreVk.h
  76. ShaderVk.cpp
  77. ShaderVk.h
  78. SurfaceVk.cpp
  79. SurfaceVk.h
  80. SyncVk.cpp
  81. SyncVk.h
  82. TextureVk.cpp
  83. TextureVk.h
  84. TransformFeedbackVk.cpp
  85. TransformFeedbackVk.h
  86. UtilsVk.cpp
  87. UtilsVk.h
  88. VertexArrayVk.cpp
  89. VertexArrayVk.h
  90. vk_cache_utils.cpp
  91. vk_cache_utils.h
  92. vk_caps_utils.cpp
  93. vk_caps_utils.h
  94. vk_format_map.json
  95. vk_format_table_autogen.cpp
  96. vk_format_utils.cpp
  97. vk_format_utils.h
  98. vk_helpers.cpp
  99. vk_helpers.h
  100. vk_internal_shaders_autogen.cpp
  101. vk_internal_shaders_autogen.gni
  102. vk_internal_shaders_autogen.h
  103. vk_mandatory_format_support_data.json
  104. vk_mandatory_format_support_table_autogen.cpp
  105. vk_mem_alloc_wrapper.cpp
  106. vk_mem_alloc_wrapper.h
  107. vk_utils.cpp
  108. vk_utils.h
  109. 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: