Skip to content

Commit 315c954

Browse files
authored
Swap to manifest.json for install config (#83)
Switch to using standard Vulkan layer manifest.json files for configuring the Android installer, allowing the same manifest to be used for both Android and Linux. This commit also changes layer tag names to match Khronos convention, where tags are of the form VK_LAYER_LGL_layer_name.
1 parent 0112895 commit 315c954

File tree

18 files changed

+107
-46
lines changed

18 files changed

+107
-46
lines changed

docs/running_android.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ For users with existing configuration flows, Vulkan layers can be manually
8787
configured using `adb` to copy the files and set the system properties.
8888

8989
For layers with configuration files, the configuration file must be named
90-
after the layer (e.g. `VK_LAYER_LGL_GPUSUPPORT.json`) and then pushed to
90+
after the layer (e.g. `VK_LAYER_LGL_gpu_support.json`) and then pushed to
9191
the `/data/local/tmp` directory with global (`0666`) access permissions.
9292

9393
**Note:** Android will fail to start an application if it has a layer enabled,

generator/generate_vulkan_layer.py

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ def load_template(path: str) -> str:
5656
def get_layer_api_name(vendor: str, layer: str) -> str:
5757
'''
5858
Generate the layer string name for the new layer used by the loader.
59-
Names are of the form "VK_LAYER_<VENDOR>_<LAYER>" in upper case.
59+
Names are of the form "VK_LAYER_<VENDOR>_<layer>_<name>" where vendor
60+
is in upper case, and the layer name is in lower case.
6061
6162
Args:
6263
vendor: The layer vendor tag.
@@ -69,7 +70,25 @@ def get_layer_api_name(vendor: str, layer: str) -> str:
6970
match = pattern.match(layer)
7071
assert match
7172

72-
name_parts = ('VK_LAYER', vendor.upper(), match.group(1).upper())
73+
name = match.group(1)
74+
parts = []
75+
part = None
76+
77+
for char in name:
78+
is_uc = char.isupper()
79+
is_last_uc = False if not part else part[-1].isupper()
80+
81+
if (is_uc and not is_last_uc) or not part:
82+
if part:
83+
parts.append(part.lower())
84+
part = char
85+
else:
86+
part += char
87+
88+
if part:
89+
parts.append(part.lower())
90+
91+
name_parts = ('VK_LAYER', vendor.upper(), *parts)
7392
return '_'.join(name_parts)
7493

7594

@@ -125,16 +144,16 @@ def generate_source_cmake(file: TextIO, vendor: str, layer: str) -> None:
125144
file.write(data)
126145

127146

128-
def generate_install_helper(file: TextIO, vendor: str, layer: str) -> None:
147+
def generate_install_manifest(file: TextIO, vendor: str, layer: str) -> None:
129148
'''
130-
Generate the Android installer helper with placeholders replaced.
149+
Generate the layer manifest with placeholders replaced.
131150
132151
Args:
133152
file: The file handle to write to.
134153
vendor: The layer vendor tag.
135154
layer: The name of the layer.
136155
'''
137-
data = load_template('android_install.json')
156+
data = load_template('manifest.json')
138157
data = data.replace('{LAYER_NAME}', layer)
139158

140159
name = get_layer_api_name(vendor, layer)
@@ -228,9 +247,9 @@ def main() -> int:
228247
with open(outfile, 'w', encoding='utf-8', newline='\n') as handle:
229248
generate_source_cmake(handle, args.vendor_name, args.layer_name)
230249

231-
outfile = os.path.join(outdir, 'android_install.json')
250+
outfile = os.path.join(outdir, 'manifest.json')
232251
with open(outfile, 'w', encoding='utf-8', newline='\n') as handle:
233-
generate_install_helper(handle, args.vendor_name, args.layer_name)
252+
generate_install_manifest(handle, args.vendor_name, args.layer_name)
234253

235254
return 0
236255

generator/vk_codegen/android_install.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

generator/vk_codegen/manifest.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"file_format_version": "1.0.0",
3+
"layer": {
4+
"name": "{LGL_LAYER_NAME}",
5+
"type": "INSTANCE",
6+
"library_path": "lib{LAYER_NAME}.so",
7+
"api_version": "1.0.0",
8+
"implementation_version": "1",
9+
"description": "Layer for ..."
10+
}
11+
}

layer_example/android_install.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

layer_example/manifest.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"file_format_version": "1.0.0",
3+
"layer": {
4+
"name": "VK_LAYER_LGL_example",
5+
"type": "INSTANCE",
6+
"library_path": "libVkLayerExample.so",
7+
"api_version": "1.0.0",
8+
"implementation_version": "1",
9+
"description": "Layer generator skeleton no-op example layer"
10+
}
11+
}

layer_example/source/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ else()
3030
endif()
3131

3232
# Set strings used by configure
33-
set(LGL_LAYER_NAME_STR "VK_LAYER_LGL_EXAMPLE")
33+
set(LGL_LAYER_NAME_STR "VK_LAYER_LGL_example")
3434
set(LGL_LAYER_DESC_STR "VkLayerExample by LGL")
3535

3636
# Vulkan layer library

layer_gpu_support/android_install.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

layer_gpu_support/layer_config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"layer": "VK_LAYER_LGL_GPUSUPPORT",
2+
"layer": "VK_LAYER_LGL_gpu_support",
33
"serialize": {
44
"all": false,
55
"none": false,

layer_gpu_support/manifest.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"file_format_version": "1.0.0",
3+
"layer": {
4+
"name": "VK_LAYER_LGL_gpu_support",
5+
"type": "INSTANCE",
6+
"library_path": "libVkLayerGPUSupport.so",
7+
"api_version": "1.0.0",
8+
"implementation_version": "1",
9+
"description": "Layer for quick triage experimentation"
10+
}
11+
}

0 commit comments

Comments
 (0)