From 7569de1ec615d02363df5f3e5b810eec4462f52c Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Thu, 25 May 2023 21:08:48 -0700 Subject: [PATCH 1/2] Enabled validation layers for vulkan --- DEPS | 2 +- impeller/BUILD.gn | 7 ++++++- testing/run_tests.py | 36 +++++++++++++++--------------------- tools/gn | 3 ++- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/DEPS b/DEPS index f8cd20c9afec3..835435ac670c1 100644 --- a/DEPS +++ b/DEPS @@ -256,7 +256,7 @@ allowed_hosts = [ ] deps = { - 'src': 'https://github.com/flutter/buildroot.git' + '@' + 'e522d38d629d7522f0589e754886ed2b82232d9e', + 'src': 'https://github.com/flutter/buildroot.git' + '@' + '859e7ccc38f55f89dac8aea49367b7a4c1656490', # Fuchsia compatibility # diff --git a/impeller/BUILD.gn b/impeller/BUILD.gn index a3c5e743f5211..7d18e8550c234 100644 --- a/impeller/BUILD.gn +++ b/impeller/BUILD.gn @@ -103,7 +103,12 @@ impeller_component("impeller_unittests") { } if (glfw_vulkan_library != "") { - deps += [ "//third_party/swiftshader" ] + deps += [ + "//third_party/swiftshader", + "//third_party/vulkan-deps/vulkan-loader/src:libvulkan", + "//third_party/vulkan_validation_layers", + "//third_party/vulkan_validation_layers:vulkan_gen_json_files", + ] } if (impeller_enable_compute) { diff --git a/testing/run_tests.py b/testing/run_tests.py index c17bf210f9487..bb7991c744a18 100755 --- a/testing/run_tests.py +++ b/testing/run_tests.py @@ -75,19 +75,23 @@ def run_cmd( print(f'Running command "{command_string}"') start_time = time.time() - collect_output = forbidden_output or allowed_failure_output - stdout_pipe = sys.stdout if not collect_output else subprocess.PIPE - stderr_pipe = sys.stderr if not collect_output else subprocess.PIPE process = subprocess.Popen( cmd, - stdout=stdout_pipe, - stderr=stderr_pipe, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, env=env, universal_newlines=True, **kwargs ) - stdout, stderr = process.communicate() + output = '' + + for line in iter(process.stdout.readline, ''): + output += line + sys.stdout.write(line) + + sys.stdout.flush() + process.wait() end_time = time.time() if process.returncode != 0 and not expect_failure: @@ -97,18 +101,11 @@ def run_cmd( f'Failed Command:\n\n{command_string}\n\nExit Code: {process.returncode}\n' ) - if stdout: - print(f'STDOUT: \n{stdout}') - - if stderr: - print(f'STDERR: \n{stderr}') - print_divider('!') allowed_failure = False for allowed_string in allowed_failure_output: - if (stdout and allowed_string in stdout) or (stderr and - allowed_string in stderr): + if allowed_string in output: allowed_failure = True if not allowed_failure: @@ -116,13 +113,8 @@ def run_cmd( f'Command "{command_string}" exited with code {process.returncode}.' ) - if stdout or stderr: - print(stdout) - print(stderr) - for forbidden_string in forbidden_output: - if (stdout and forbidden_string in stdout) or (stderr and - forbidden_string in stderr): + if forbidden_string in output: raise RuntimeError( f'command "{command_string}" contained forbidden string {forbidden_string}' ) @@ -490,6 +482,8 @@ def make_test(name, flags=None, extra_env=None): 'MTL_SHADER_VALIDATION_TEXTURE_USAGE': '1', # Validates that texture references are not nil. 'VK_ICD_FILENAMES': os.path.join(build_dir, 'vk_swiftshader_icd.json'), + 'VK_LAYER_PATH': os.path.join(build_dir, 'vulkan-data'), + 'VK_INSTANCE_LAYERS': 'VK_LAYER_KHRONOS_validation', } if is_aarm64(): extra_env.update({ @@ -501,7 +495,7 @@ def make_test(name, flags=None, extra_env=None): build_dir, 'impeller_unittests', executable_filter, - shuffle_flags, + shuffle_flags + ['--enable_vulkan_validation'], coverage=coverage, extra_env=extra_env, # TODO(117122): Remove this allowlist. diff --git a/tools/gn b/tools/gn index 03eacfb1a8eb0..25899f4d0edb3 100755 --- a/tools/gn +++ b/tools/gn @@ -594,7 +594,8 @@ def to_gn_args(args): gn_args['impeller_malioc_path'] = malioc_path if args.use_glfw_swiftshader: - gn_args['glfw_vulkan_library'] = r'\"libvk_swiftshader.dylib\"' + if (get_host_os() == "mac"): + gn_args['glfw_vulkan_library'] = r'\"libvulkan.dylib\"' # ANGLE is exclusively used for: # - Windows at runtime From ecaba22708018d5ed5f7a1bbb8ae373986f042d1 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Fri, 26 May 2023 11:20:33 -0700 Subject: [PATCH 2/2] lint and zach feedback --- testing/run_tests.py | 3 +++ tools/gn | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/testing/run_tests.py b/testing/run_tests.py index bb7991c744a18..0b21befeaa7b7 100755 --- a/testing/run_tests.py +++ b/testing/run_tests.py @@ -481,7 +481,10 @@ def make_test(name, flags=None, extra_env=None): '1', # Validates accesses to threadgroup memory. 'MTL_SHADER_VALIDATION_TEXTURE_USAGE': '1', # Validates that texture references are not nil. + # Note: built from //third_party/swiftshader 'VK_ICD_FILENAMES': os.path.join(build_dir, 'vk_swiftshader_icd.json'), + # Note: built from //third_party/vulkan_validation_layers:vulkan_gen_json_files + # and //third_party/vulkan_validation_layers. 'VK_LAYER_PATH': os.path.join(build_dir, 'vulkan-data'), 'VK_INSTANCE_LAYERS': 'VK_LAYER_KHRONOS_validation', } diff --git a/tools/gn b/tools/gn index 25899f4d0edb3..d94ba6e56ffc9 100755 --- a/tools/gn +++ b/tools/gn @@ -594,7 +594,7 @@ def to_gn_args(args): gn_args['impeller_malioc_path'] = malioc_path if args.use_glfw_swiftshader: - if (get_host_os() == "mac"): + if get_host_os() == 'mac': gn_args['glfw_vulkan_library'] = r'\"libvulkan.dylib\"' # ANGLE is exclusively used for: