OLD | NEW |
1 Building the Vulkan backend | 1 Vulkan |
2 =========================== | 2 ====== |
3 | 3 |
4 Introduction | 4 Skis has a Vulkan implementation of its GPU backend. The Vulkan backend can be b
uilt 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 ve
ndors as we find them. |
5 ------------ | |
6 | 5 |
7 The Vulkan backend is experimental and not built by default. It currently replac
es the 'gpu' config in the dm tool rather than running in addition to OpenGL. Vu
lkan has been built on Windows and Linux. | 6 Build for Windows and Linux |
| 7 --------------------------- |
| 8 To build the Vulkan backend add skia_vulkan=1 to your GYP_DEFINES and rerun gyp_
skia. For example: |
8 | 9 |
9 Details | 10 <!--?prettify lang=sh?--> |
10 ------- | 11 export GYP_DEFINES="$GYP_DEFINES skia_vulkan=1" |
| 12 python ./gyp_skia |
11 | 13 |
12 Add `skia_vulkan=1` to your `GYP_DEFINES` environment variable. Ensure cmake is
installed and in your path. On Windows install the prebuilt cmake from https://c
make.org/download/. The Vulkan SDK must also be installed. | 14 The Vulkan SDK must be installed and the VULKAN_SDK environment variable must po
int to the installation location. The Windows installer will set the environment
variable. However, on Linux it must be set after installation. |
13 | 15 |
14 On Windows the 'msvs' gyp generator will not work. Use msvs-ninja for MSVS integ
ration. | 16 Build as usual for your platform. |
15 | 17 |
16 Run: | |
17 | 18 |
18 python gyp_skia | 19 Build for Android |
| 20 ----------------- |
| 21 The Vulkan backend will run on a device running the N release with Vulkan driver
s. To build the Vulkan backend simply add --vulkan to the flags passed to ./plat
form_tools/android/bin/android_ninja |
19 | 22 |
20 and build Skia as usual. | 23 |
| 24 Using the Vulkan Backend |
| 25 ------------------------ |
| 26 |
| 27 To create a GrContext that is backed by Vulkan the client creates a Vulkan devic
e and queue, initializes a GrVkBackendContext to describe the context, and then
calls GrContext::Create: |
| 28 |
| 29 <!--?prettify lang=c++?--> |
| 30 sk_sp<GrVkBackendContext> vkContext = new GrVkBackendContext; |
| 31 vkBackendContext.fInstance = vkInstance; |
| 32 vkBackendContext.fPhysicalDevice = vkPhysDevice; |
| 33 ... |
| 34 vkBackendContext.fInterface.reset(GrVkCreateInterface(instance, vkPhysDevice
, extensionFlags); |
| 35 ... |
| 36 |
| 37 sk_sp<GrContext> context = GrContext::Create(kVulkan_GrBackend, (GrBackendCo
ntext) vkBackendContext); |
| 38 |
| 39 When using the Vulkan backend the GrBackendObject field in GrBackendRenderTarget
Desc and GrBackendTextureDesc is interpeted as a pointer to a GrVkImageInfo obje
ct. GrVkImageInfo specifies a VkImage and associated state (tiling, layout, form
at, etc). This allows the client to import externally created Vulkan images as d
estinations for Skia rendering via SkSurface factory functions or for to composi
te Skia rendered content using SkImage::getTextureHandle(). |
| 40 |
| 41 After getting a GrVkImageInfo* via getTextureHandle() or getRenderTargetHandle()
, the client should check the fImageLayout field to know what layout Skia left t
he 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. |
| 42 |
| 43 The client is responsible for any synchronization or barriers needed before Skia
performs I/O on a VkImage imported into Skia via GrVkImageInfo. |
| 44 Skia will assume it can start issuing commands referencing the VkImage without t
he need for additional synchronization. |
OLD | NEW |