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

  • getOutsideRenderPassCommandBuffer: returns a secondary command buffer outside a RenderPass instance.
  • flushAndBeginRenderPass: returns a secondary command buffer inside a RenderPass instance.

Note: All of these commands may write out (aka flush) prior pending commands into a primary command buffer. When a RenderPass is open getOutsideRenderPassCommandBuffer 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 getOutsideRenderPassCommandBuffer.

The back-end (mostly) records Image and Buffer barriers through additional ContextVk APIs:

  • 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 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.
    ANGLE_TRY(contextVk->onBufferTransferWrite(destBuffer));
    ANGLE_TRY(contextVk->onBufferTransferRead(srcBuffer));

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