Commit b9d1daa0 by Tobin Ehlis Committed by Commit Bot

Add Vulkan mock_icd to the build

Bug: angleproject:2159 Add Vulkan mock_icd from validation layer source to the standard Vulkan build. This can act as a NULL driver for Vulkan. Once the mock is built set VK_ICD_FILENAMES env variable to "<build_out_dir>/angledata/VkICD_mock_icd.json" to point loader to the mock driver and make sure the built mock icd library resides in the system's shared object search path. Change-Id: Iea86325cf076df75fa82a4974c8a3a6249cdf8e0 Reviewed-on: https://chromium-review.googlesource.com/850892 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org>
parent fd66b81e
...@@ -17,6 +17,10 @@ if len(sys.argv) != 3: ...@@ -17,6 +17,10 @@ if len(sys.argv) != 3:
source_dir = sys.argv[1] source_dir = sys.argv[1]
target_dir = sys.argv[2] target_dir = sys.argv[2]
data_key = 'layer'
if 'icd' in source_dir:
data_key = 'ICD'
if not os.path.isdir(source_dir): if not os.path.isdir(source_dir):
print(source_dir + " is not a directory.") print(source_dir + " is not a directory.")
sys.exit(1) sys.exit(1)
...@@ -29,13 +33,13 @@ for json_fname in glob.glob(os.path.join(source_dir, "*.json")): ...@@ -29,13 +33,13 @@ for json_fname in glob.glob(os.path.join(source_dir, "*.json")):
data = json.load(infile) data = json.load(infile)
# update the path # update the path
if not 'layer' in data: if not data_key in data:
raise Exception("Could not find a layer key in " + json_fname) raise Exception("Could not find '" + data_key + "' key in " + json_fname)
# The standard validation layer has no library path. # The standard validation layer has no library path.
if 'library_path' in data['layer']: if 'library_path' in data[data_key]:
prev_name = os.path.basename(data['layer']['library_path']) prev_name = os.path.basename(data[data_key]['library_path'])
data['layer']['library_path'] = prev_name data[data_key]['library_path'] = prev_name
target_fname = os.path.join(target_dir, os.path.basename(json_fname)) target_fname = os.path.join(target_dir, os.path.basename(json_fname))
with open(target_fname, "w") as outfile: with open(target_fname, "w") as outfile:
......
...@@ -99,6 +99,16 @@ helper_script_and_deps = [ ...@@ -99,6 +99,16 @@ helper_script_and_deps = [
"unique_objects_wrappers.h", "unique_objects_wrappers.h",
"unique_objects_generator.py", "unique_objects_generator.py",
], ],
[
"vulkan_mock_icd_cpp",
"mock_icd.cpp",
"mock_icd_generator.py",
],
[
"vulkan_mock_icd_h",
"mock_icd.h",
"mock_icd_generator.py",
],
] ]
foreach(script_and_dep, helper_script_and_deps) { foreach(script_and_dep, helper_script_and_deps) {
...@@ -460,6 +470,57 @@ if (!is_android) { ...@@ -460,6 +470,57 @@ if (!is_android) {
data = vulkan_gen_json_files_outputs data = vulkan_gen_json_files_outputs
args += [ rebase_path("$root_out_dir/$data_dir", root_build_dir) ] args += [ rebase_path("$root_out_dir/$data_dir", root_build_dir) ]
} }
# Vulkan Mock ICD
# ---------------
group("vulkan_generate_mock_icd_files") {
public_deps = [
":vulkan_generate_helper_files",
":vulkan_mock_icd_cpp",
":vulkan_mock_icd_h",
]
}
mock_icd_sources = [
"$vulkan_gen_dir/mock_icd.cpp",
"$vulkan_gen_dir/mock_icd.h",
]
shared_library("VkICD_mock_icd") {
configs -= vulkan_undefine_configs
public_configs = [
":vulkan_config",
]
deps = [
"//build/config:exe_and_shlib_deps",
]
deps += [ ":vulkan_generate_mock_icd_files" ]
sources = mock_icd_sources
if (is_win) {
sources += [ "$vulkan_layers_dir/icd/VkICD_mock_icd.def" ]
}
}
action("vulkan_gen_icd_json_file") {
script = "$angle_root/scripts/generate_vulkan_layers_json.py"
if (is_win) {
sources = [
"$vulkan_layers_dir/icd/windows/VkICD_mock_icd.json",
]
args = [ "$raw_vulkan_layers_dir/icd/windows" ]
}
if (is_linux) {
sources = [
"$vulkan_layers_dir/icd/linux/VkICD_mock_icd.json",
]
args = [ "$raw_vulkan_layers_dir/icd/linux" ]
}
# The layer JSON files are part of the necessary data deps.
outputs = [ "$root_out_dir/$data_dir/VkICD_mock_icd.json", ]
data = [ "$root_out_dir/$data_dir/VkICD_mock_icd.json", ]
args += [ rebase_path("$root_out_dir/$data_dir", root_build_dir) ]
}
} }
source_set("vulkan_layer_utils") { source_set("vulkan_layer_utils") {
...@@ -552,3 +613,4 @@ foreach(layer_info, layers) { ...@@ -552,3 +613,4 @@ foreach(layer_info, layers) {
} }
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment