Skip to content

Commit 04c80fc

Browse files
Trevor BlackAndroid (Google) Code Review
authored andcommitted
Merge "Refactor Vulkan-Profiles interaction into vkprofiles" into main
2 parents 5ecb69f + 1b7d420 commit 04c80fc

12 files changed

Lines changed: 14426 additions & 0 deletions

vulkan/Android.bp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,5 @@ subdirs = [
4242
"nulldrv",
4343
"libvulkan",
4444
"vkjson",
45+
"vkprofiles",
4546
]

vulkan/vkprofiles/Android.bp

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package {
2+
// See: http://go/android-license-faq
3+
// A large-scale-change added 'default_applicable_licenses' to import
4+
// all of the 'license_kinds' from "frameworks_native_license"
5+
// to get the below license kinds:
6+
// SPDX-license-identifier-Apache-2.0
7+
default_applicable_licenses: ["frameworks_native_license"],
8+
}
9+
10+
cc_defaults {
11+
name: "libvkprofiles_deps",
12+
shared_libs: [
13+
"libvulkan",
14+
],
15+
}
16+
17+
cc_library_static {
18+
name: "libvkprofiles",
19+
defaults: [
20+
"libvkprofiles_deps",
21+
],
22+
srcs: [
23+
"vkprofiles.cpp",
24+
"generated/vulkan_profiles.cpp",
25+
],
26+
cflags: [
27+
"-Wall",
28+
"-Werror",
29+
"-Wimplicit-fallthrough",
30+
],
31+
cppflags: [
32+
"-Wno-error=unused-parameter",
33+
"-Wno-error=missing-braces",
34+
"-Wno-sign-compare",
35+
],
36+
export_include_dirs: [
37+
".",
38+
],
39+
export_shared_lib_headers: [
40+
"libvulkan",
41+
],
42+
}
43+
44+
cc_library_static {
45+
name: "libvkprofiles_ndk",
46+
srcs: [
47+
"vkprofiles.cpp",
48+
"generated/vulkan_profiles.cpp",
49+
],
50+
cflags: [
51+
"-Wall",
52+
"-Werror",
53+
"-Wimplicit-fallthrough",
54+
],
55+
cppflags: [
56+
"-Wno-error=unused-parameter",
57+
"-Wno-error=missing-braces",
58+
"-Wno-sign-compare",
59+
],
60+
export_include_dirs: [
61+
".",
62+
],
63+
header_libs: [
64+
"vulkan_headers",
65+
],
66+
sdk_version: "24",
67+
stl: "libc++_static",
68+
}

vulkan/vkprofiles/README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
2+
Get a local copy of the Vulkan-Profiles repository (https://github.com/KhronosGroup/Vulkan-Profiles/)
3+
4+
NOTE: If the Vulkan-Headers you need for generation is later than the one that exists in
5+
`external/vulkan-headers`, then `external/vulkan-headers` will need to be updated to match.
6+
These updates to `external/vulkan` need to be made in AOSP. Changes to `ndk_translation` may
7+
need to be first made in internal-main.
8+
9+
Run Vulkan-Profiles/scripts/gen_profiles_solutions.py in debug mode.
10+
11+
Debug mode (at time of writing) requires a dedicated debug folder within the output-library location.
12+
~/Vulkan-Profiles$ mkdir debug
13+
~/Vulkan-Profiles$ python3 scripts/gen_profiles_solution.py --debug --registry ~/<PATH_TO_YOUR_ANDROID_REPO>/external/vulkan-headers/registry/vk.xml --input ~/android/main/frameworks/native/vulkan/vkprofiles/profiles/ --output-library-inc . --output-library-src .
14+
15+
Take the generated vulkan_profiles.h and vulkan_profiles.cpp from the debug directory you just created.
16+
17+
~/Vulkan-Profiles$ cp debug/vulkan_profiles.cpp <PATH_TO_YOUR_ANDROID_REPO>/frameworks/native/vulkan/vkprofile/generated/
18+
~/Vulkan-Profiles$ cp debug/vulkan_profiles.h <PATH_TO_YOUR_ANDROID_REPO>/frameworks/native/vulkan/vkprofile/generated/
19+
20+
21+
The files need to be modified to land.
22+
1. Replace the generated license with the correct Android license
23+
(https://cs.android.com/android/platform/superproject/main/+/main:development/docs/copyright-templates/c.txt).
24+
Make sure to set the copyright to the current year. You should also remove the `This file is ***GENERATED***` part.
25+
2. Add VK_USE_PLATFORM_ANDROID_KHR between the license and the first includes for vulkan_profiles.cpp
26+
```
27+
*/
28+
29+
#ifndef VK_USE_PLATFORM_ANDROID_KHR
30+
#define VK_USE_PLATFORM_ANDROID_KHR
31+
#endif
32+
33+
#include ...
34+
```
35+
3. Rewrite the includes so that `vulkan_profiles.h` is correctly included
36+
4. Modify the #define `VP_DEBUG_MESSAGE_CALLBACK(MSG) ...` from "Profiles ERROR/WARNING" to "vkprofiles ERROR/WARNING"
37+
5. You may need to modify the Android.bp to remove warnings as errors, e.g. `"-Wno-error=unused-parameter",`
38+
6. Add `clang-format off` to the beginning and `clang-format on` to the end of the files
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Take the outputted source files from gen_profiles_solution.py and don't format
2+
DisableFormat: true
3+
SortIncludes: Never

0 commit comments

Comments
 (0)