From c1755d345d84e8c06b69a1f8bc2c69c7e4752885 Mon Sep 17 00:00:00 2001
From: ggfan
This page explains how to:
On this page
+
+
+ NDK release 12 and higher includes pre-built validation layer binaries. At + instance and device creation time, when requested by your application, the + Vulkan loader finds them in the APK installed location and loads them. +
+ ++ To use the pre-built validation layer binaries, either modify the gradle build + configuration of your project or manually add the binaries into the JNI + libraries directory of your project. +
+ + ++ You can add the validation layer your project using either Andorid Studio's + support for CMake and Ndk-build, or using Studio's experimental plugin for + Gradle. In general, you should use the CMake and Ndk-build configuration. +
+ + ++ To add the libraries using Android Studio's support for CMake/Ndk-build, + add the following to your project's gradle configuration: +
+ +
+sourceSets {
+ main {
+ jniLibs {
+ srcDir "${your-ndk-dir}/sources/third_party/vulkan/src/build-android/jniLibs"
+ }
+ }
+}
+
++ To add the libraries using Android Studio's experimental plugin for Gradle, + add the following to your project's gradle configuration: +
+ +
+sources {
+ main {
+ jniLibs {
+ source.srcDir "${your-ndk-dir}/sources/third_party/vulkan/src/build-android/jniLibs"
+ }
+ }
+}
+
+
++ If configuring your project's gradle build file is not working, you can + manually add the validation layer binaries to your project's JNI libraries + directory by using the following command line options: +
+ +
+$ cd ${your-app-project-root}
+$ mkdir -p app/src/main
+$ cp -fr ${your-ndk-dir}/sources/third_party/vulkan/src/build-android/jniLibs app/src/main/
+
+
+
-This section explains how to build layers from source. -If you have precompiled layers, you can skip this section, and instead read about how to -install your layers using Android Studio or from the -command line. -
--NDK Revision 12 and later contains source -code for Android validation layers that is known-good, and ready to build. This code resides under -the {@code <ndk-root>/sources/third_party/vulkan/src/build-android/generated/gradle-build} -directory. This version of the layers should be sufficient for most needs. If so, your next task is -to build them. Alternatively, you can pull source code from the -Khronos Group repository. - -
- --Although we recommend that you use the source code provided with the NDK, you can also pull more -recent versions of the source code directly from the +If your app needs the latest validation layer, you can pull the latest source from the Khronos Group -GitHub repository belonging to the Khronos Group. To do so, perform the following steps. +GitHub repository and follow the build instructions there.
--$ git clone git@github.com:KhronosGroup/Vulkan-LoaderAndValidationLayers.git -- -
Note: You must have a private SSH key associated with -GitHub, or this command fails with a {@code Permission denied (publickey)} message.
--$ cd Vulkan-LoaderAndValidationLayers -$ git checkout android_layers --
-$ cd build-android -$ ./android-generate-
-> cd build-android -> android-generate.bat-
-Android Studio builds the validation layers when it builds the rest of the app. -This flow makes it easier for you to trace through the layers at runtime. Each layer's -source code corresponds to a single Gradle project, which you can specify directly in your Android -Studio app. For example, there is a {@code build.gradle} project for threading, and another -one for parameter validation. -
- --To integrate layers directory into Android Studio application, perform these steps: -
-
-// configure your path to the source code generated on your machine
-def layerProjRoot = file('/path/to/ndk-root/.../build-android/generated/gradle-build')
-String[] layers = ['threading',
- 'parameter_validation',
- 'object_tracker',
- 'core_validation',
- 'device_limits',
- 'image',
- 'swapchain',
- 'unique_objects']
-for (layer in layers) {
- include ":"+ layer
- project(":" + layer.toString()).projectDir = new File("${layerProjRoot}/${layer}")
-}
-
-
-android.sources {
- main {
- jni { ... }
- jniLibs {
- dependencies {
- project ":threading"
- project ":parameter_validation"
- project ":object_tracker"
- project ":core_validation"
- project ":device_limits"
- project ":image"
- project ":swapchain"
- project ":unique_objects"
- }
- }
- }
-} // android.sources
-
--To build validation layers on Linux or OS X, enter these commands on the command line: -
--$ cd generated/gradle-build -$ # configure SDK and NDK path in local.properties -$ gradlew assembleAllDebug --
-$ ndk-build-
-To build validation layers on Windows, enter these commands on the command line: -
--> cd generated\gradle-build -> REM configure SDK and NDK path in local.properties -> gradlew.bat assembleAllDebug --
-> ndk-build.cmd --
-After building the layers, you must provide them to your app. To do so, you must first -create a {@code jniLibs} folder in your app's project directory under -{@code ./src/main/}, and copy the libs to it. The following example shows how to do this. -
- --$ mkdir ./src/main/jniLibs -- -
-The next step depends on whether you are using Gradle or Android makefiles. If you're using -Gradle, each built layer resides in its own directory. Consolidate the layers into a single -directory, as the following example shows: -
- --$ cp -r .../build-android/generated/gradle-build/threading/build/outputs/native/debug/all/lib/* ./src/main/jniLibs/ -$ cp -r .../build-android/generated/gradle-build/parameter_validation/build/outputs/native/debug/all/lib/* ./src/main/jniLibs/ -$ cp -r .../build-android/generated/gradle-build/object_tracker/build/outputs/native/debug/all/lib/* ./src/main/jniLibs/ -$ cp -r .../build-android/generated/gradle-build/core_validation/build/outputs/native/debug/all/lib/* ./src/main/jniLibs/ -$ cp -r .../build-android/generated/gradle-build/device_limits/build/outputs/native/debug/all/lib/* ./src/main/jniLibs/ -$ cp -r .../build-android/generated/gradle-build/image/build/outputs/native/debug/all/lib/* ./src/main/jniLibs/ -$ cp -r .../build-android/generated/gradle-build/swapchain/build/outputs/native/debug/all/lib/* ./src/main/jniLibs/ -$ cp -r .../build-android/generated/gradle-build/unique_objects/build/outputs/native/debug/all/lib/* ./src/main/jniLibs/ -- -If you're using Android makefiles, the built layers reside in {@code lib} folders, -with one {@code lib} folder under each architecture’s root directory. Consolidate the -makefiles under the {@code jniLibs} directory as this example shows: - -
-$ cp -r .../build-android/libs/* ./src/main/jniLibs/ -- - -
-Regardless of whether you build using Gradle or Android makefiles, the build process produces -a file structure like the following: +Regardless of whether you build with NDK's prebuilt layers or you build from the latest source code, +the build process produces final file structure like the following:
@@ -571,6 +382,7 @@ if (vkDestroyDebugReportCallbackEXT) {
+Once your app has registered and enabled the debug callback, the system routes debugging messages to a callback that you register. An example of such a callback appears below: