skia2/site/user/special/vulkan.md

56 lines
2.5 KiB
Markdown
Raw Normal View History

Vulkan
======
Skia has a Vulkan implementation of its GPU backend. The Vulkan backend can be
built alongside the OpenGL backend. The client can select between the OpenGL
and Vulkan implementation at runtime. The Vulkan backend has reached feature
parity with the OpenGL backend. At this time we find that many Vulkan drivers
have bugs that Skia triggers for which we have no workaround. We are reporting
bugs to vendors as we find them.
Windows and Linux
-----------------
To build the Vulkan backend, set `skia_use_vulkan=true` in `args.gn`.
Android
-------
The Vulkan backend can run on any device with Vulkan drivers, including all Android N+ devices.
To build the Vulkan backend, set `ndk_api = 24` in `args.gn` to target Android N.
Using the Vulkan Backend
------------------------
To create a GrContext that is backed by Vulkan the client creates a Vulkan device and queue, initializes a GrVkBackendContext to describe the context, and then calls GrContext::MakeVulkan:
<!--?prettify lang=c++?-->
sk_sp<GrVkBackendContext> vkContext = new GrVkBackendContext;
vkBackendContext.fInstance = vkInstance;
vkBackendContext.fPhysicalDevice = vkPhysDevice;
...
vkBackendContext.fInterface.reset(GrVkCreateInterface(instance, vkPhysDevice, extensionFlags);
...
sk_sp<GrContext> context = GrContext::MakeVulkan(vkBackendContext);
Revert "Revert "Revert "Revert "Remove GrBackendRenderTargetDesc in favor of GrBackendRenderTarget."""" This reverts commit 6df4d6be0d025211400de6a910e17f2a87219887. Reason for revert: Google3 fix landed Original change's description: > Revert "Revert "Revert "Remove GrBackendRenderTargetDesc in favor of GrBackendRenderTarget.""" > > This reverts commit 71554bc256b705fe959b7aa2fb2f24ed48782362. > > Reason for revert: Google3 > > Original change's description: > > Revert "Revert "Remove GrBackendRenderTargetDesc in favor of GrBackendRenderTarget."" > > > > This reverts commit 807371c15bd742efb98a9df6e1dee73e8bda8af5. > > > > Docs-Preview: https://skia.org/?cl=40260 > > Change-Id: I28e0434c455155ff39a5aaa4141abdf442474e87 > > Reviewed-on: https://skia-review.googlesource.com/40260 > > Reviewed-by: Greg Daniel <egdaniel@google.com> > > Commit-Queue: Brian Salomon <bsalomon@google.com> > > TBR=egdaniel@google.com,bsalomon@google.com > > Change-Id: Ifdfa896a70db69935473276d12dce54de5c6b6f7 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Reviewed-on: https://skia-review.googlesource.com/41500 > Reviewed-by: Brian Salomon <bsalomon@google.com> > Commit-Queue: Brian Salomon <bsalomon@google.com> TBR=egdaniel@google.com,bsalomon@google.com Change-Id: I827419bb19972c3644929a8c984bb9534baab0ba No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://skia-review.googlesource.com/41700 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
2017-08-31 20:04:00 +00:00
When using the Vulkan backend, GrVkImageInfo is used to construct GrBackendTexture
and GrBackendRenderTarget objects that in turn are used to create SkSurface and SkImage
objects that refer to VkImages created by the Skia client.
Revert "Revert "Revert "Revert "Remove GrBackendRenderTargetDesc in favor of GrBackendRenderTarget."""" This reverts commit 6df4d6be0d025211400de6a910e17f2a87219887. Reason for revert: Google3 fix landed Original change's description: > Revert "Revert "Revert "Remove GrBackendRenderTargetDesc in favor of GrBackendRenderTarget.""" > > This reverts commit 71554bc256b705fe959b7aa2fb2f24ed48782362. > > Reason for revert: Google3 > > Original change's description: > > Revert "Revert "Remove GrBackendRenderTargetDesc in favor of GrBackendRenderTarget."" > > > > This reverts commit 807371c15bd742efb98a9df6e1dee73e8bda8af5. > > > > Docs-Preview: https://skia.org/?cl=40260 > > Change-Id: I28e0434c455155ff39a5aaa4141abdf442474e87 > > Reviewed-on: https://skia-review.googlesource.com/40260 > > Reviewed-by: Greg Daniel <egdaniel@google.com> > > Commit-Queue: Brian Salomon <bsalomon@google.com> > > TBR=egdaniel@google.com,bsalomon@google.com > > Change-Id: Ifdfa896a70db69935473276d12dce54de5c6b6f7 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Reviewed-on: https://skia-review.googlesource.com/41500 > Reviewed-by: Brian Salomon <bsalomon@google.com> > Commit-Queue: Brian Salomon <bsalomon@google.com> TBR=egdaniel@google.com,bsalomon@google.com Change-Id: I827419bb19972c3644929a8c984bb9534baab0ba No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://skia-review.googlesource.com/41700 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
2017-08-31 20:04:00 +00:00
The GrBackendObject returned by SkImage::getTextureHandle(),
SkSurface::getTextureHandle(), and SkSurface::getRenderTargetHandle() should be
interpreted as a GrVkImageInfo*. This allows a client to get the backing VkImage
of a SkImage or SkSurface.
GrVkImageInfo specifies a VkImage and associated state (tiling, layout, format, etc).
After getting a GrVkImageInfo* via getTextureHandle() or
getRenderTargetHandle(), the client should check the fImageLayout field to know
what layout Skia left the VkImage in before using the VkImage. If the client
changes the layout of the VkImage,
GrVkImageInfo::updateImageLayout(VkImageLayout layout) should be called before
resuming Skia rendering.
The client is responsible for any synchronization or barriers needed before
Skia performs I/O on a VkImage imported into Skia via GrVkImageInfo. Skia will
assume it can start issuing commands referencing the VkImage without the need
for additional synchronization.