From c2b6d7f50b05675475459d7cc1393ba2d78624d5 Mon Sep 17 00:00:00 2001 From: Ben Wagner Date: Thu, 2 Jan 2020 11:22:39 -0500 Subject: [PATCH] Enable Vulkan Debug layers Bug: skia:8709 Change-Id: Ie7033d4545df10011af1c1f207bce9ceaff829c0 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/187921 Reviewed-by: Greg Daniel Commit-Queue: Ben Wagner aka dogben Auto-Submit: Ben Wagner aka dogben --- infra/bots/recipe_modules/build/default.py | 2 +- ...d-Debian9-Clang-x86_64-Release-Vulkan.json | 2 +- ...-Clang-x86_64-Release-MoltenVK_Vulkan.json | 2 +- ...Build-Win-Clang-x86_64-Release-Vulkan.json | 2 +- infra/bots/recipe_modules/flavor/default.py | 3 +++ ...-IntelIris640-x86_64-Debug-All-Vulkan.json | 4 ++- ...PU-IntelHD405-x86_64-Debug-All-Vulkan.json | 4 ++- ...-IntelHD405-x86_64-Release-All-Vulkan.json | 4 ++- ...-IntelIris640-x86_64-Debug-All-Vulkan.json | 4 ++- ...PU-QuadroP400-x86_64-Debug-All-Vulkan.json | 4 ++- tools/gpu/vk/VkTestUtils.cpp | 26 +++++++++++++------ 11 files changed, 40 insertions(+), 17 deletions(-) diff --git a/infra/bots/recipe_modules/build/default.py b/infra/bots/recipe_modules/build/default.py index 3d2b13ed1a..fac7266f93 100644 --- a/infra/bots/recipe_modules/build/default.py +++ b/infra/bots/recipe_modules/build/default.py @@ -229,7 +229,7 @@ def compile_fn(api, checkout_root, out_dir): args['is_component_build'] = 'true' if 'Vulkan' in extra_tokens and not 'Android' in extra_tokens: args['skia_use_vulkan'] = 'true' - args['skia_enable_vulkan_debug_layers'] = 'false' + args['skia_enable_vulkan_debug_layers'] = 'true' if 'MoltenVK' in extra_tokens: args['skia_moltenvk_path'] = '"%s"' % moltenvk if 'Metal' in extra_tokens: diff --git a/infra/bots/recipe_modules/build/examples/full.expected/Build-Debian9-Clang-x86_64-Release-Vulkan.json b/infra/bots/recipe_modules/build/examples/full.expected/Build-Debian9-Clang-x86_64-Release-Vulkan.json index 68a951eb8a..3a7444e1c9 100644 --- a/infra/bots/recipe_modules/build/examples/full.expected/Build-Debian9-Clang-x86_64-Release-Vulkan.json +++ b/infra/bots/recipe_modules/build/examples/full.expected/Build-Debian9-Clang-x86_64-Release-Vulkan.json @@ -36,7 +36,7 @@ "[START_DIR]/cache/work/skia/bin/gn", "gen", "[START_DIR]/cache/work/skia/out/Build-Debian9-Clang-x86_64-Release-Vulkan/Release", - "--args=cc=\"[START_DIR]/clang_linux/bin/clang\" cxx=\"[START_DIR]/clang_linux/bin/clang++\" extra_cflags=[\"-B[START_DIR]/clang_linux/bin\", \"-DDUMMY_clang_linux_version=42\"] extra_ldflags=[\"-B[START_DIR]/clang_linux/bin\", \"-fuse-ld=lld\"] is_debug=false skia_enable_vulkan_debug_layers=false skia_use_vulkan=true target_cpu=\"x86_64\" werror=true" + "--args=cc=\"[START_DIR]/clang_linux/bin/clang\" cxx=\"[START_DIR]/clang_linux/bin/clang++\" extra_cflags=[\"-B[START_DIR]/clang_linux/bin\", \"-DDUMMY_clang_linux_version=42\"] extra_ldflags=[\"-B[START_DIR]/clang_linux/bin\", \"-fuse-ld=lld\"] is_debug=false skia_enable_vulkan_debug_layers=true skia_use_vulkan=true target_cpu=\"x86_64\" werror=true" ], "cwd": "[START_DIR]/cache/work/skia", "env": { diff --git a/infra/bots/recipe_modules/build/examples/full.expected/Build-Mac-Clang-x86_64-Release-MoltenVK_Vulkan.json b/infra/bots/recipe_modules/build/examples/full.expected/Build-Mac-Clang-x86_64-Release-MoltenVK_Vulkan.json index 3a2a6ddcce..3e866220ad 100644 --- a/infra/bots/recipe_modules/build/examples/full.expected/Build-Mac-Clang-x86_64-Release-MoltenVK_Vulkan.json +++ b/infra/bots/recipe_modules/build/examples/full.expected/Build-Mac-Clang-x86_64-Release-MoltenVK_Vulkan.json @@ -53,7 +53,7 @@ "[START_DIR]/cache/work/skia/bin/gn", "gen", "[START_DIR]/cache/work/skia/out/Build-Mac-Clang-x86_64-Release-MoltenVK_Vulkan/Release", - "--args=cc=\"clang\" cxx=\"clang++\" extra_cflags=[\"-DDUMMY_xcode_build_version=10g8\"] is_debug=false skia_enable_vulkan_debug_layers=false skia_moltenvk_path=\"[START_DIR]/moltenvk\" skia_use_vulkan=true target_cpu=\"x86_64\" werror=true" + "--args=cc=\"clang\" cxx=\"clang++\" extra_cflags=[\"-DDUMMY_xcode_build_version=10g8\"] is_debug=false skia_enable_vulkan_debug_layers=true skia_moltenvk_path=\"[START_DIR]/moltenvk\" skia_use_vulkan=true target_cpu=\"x86_64\" werror=true" ], "cwd": "[START_DIR]/cache/work/skia", "env": { diff --git a/infra/bots/recipe_modules/build/examples/full.expected/Build-Win-Clang-x86_64-Release-Vulkan.json b/infra/bots/recipe_modules/build/examples/full.expected/Build-Win-Clang-x86_64-Release-Vulkan.json index 6024779e9d..45f014d537 100644 --- a/infra/bots/recipe_modules/build/examples/full.expected/Build-Win-Clang-x86_64-Release-Vulkan.json +++ b/infra/bots/recipe_modules/build/examples/full.expected/Build-Win-Clang-x86_64-Release-Vulkan.json @@ -36,7 +36,7 @@ "[START_DIR]\\cache\\work\\skia\\bin\\gn", "gen", "[START_DIR]\\cache\\work\\skia\\out\\Build-Win-Clang-x86_64-Release-Vulkan\\Release_x64", - "--args=cc=\"clang\" clang_win=\"[START_DIR]\\clang_win\" cxx=\"clang++\" extra_cflags=[\"-DDUMMY_clang_win_version=42\"] is_debug=false skia_enable_vulkan_debug_layers=false skia_use_vulkan=true target_cpu=\"x86_64\" werror=true win_sdk=\"[START_DIR]\\win_toolchain/win_sdk\" win_vc=\"[START_DIR]\\win_toolchain/VC\"" + "--args=cc=\"clang\" clang_win=\"[START_DIR]\\clang_win\" cxx=\"clang++\" extra_cflags=[\"-DDUMMY_clang_win_version=42\"] is_debug=false skia_enable_vulkan_debug_layers=true skia_use_vulkan=true target_cpu=\"x86_64\" werror=true win_sdk=\"[START_DIR]\\win_toolchain/win_sdk\" win_vc=\"[START_DIR]\\win_toolchain/VC\"" ], "cwd": "[START_DIR]\\cache\\work\\skia", "env": { diff --git a/infra/bots/recipe_modules/flavor/default.py b/infra/bots/recipe_modules/flavor/default.py index 4fe9e4e678..25e517d66d 100644 --- a/infra/bots/recipe_modules/flavor/default.py +++ b/infra/bots/recipe_modules/flavor/default.py @@ -136,8 +136,11 @@ class DefaultFlavor(object): env['VK_ICD_FILENAMES'] = str(dri_path.join('intel_icd.x86_64.json')) if 'Vulkan' in extra_tokens: + env['VULKAN_SDK'] = str(slave_dir.join('linux_vulkan_sdk')) path.append(slave_dir.join('linux_vulkan_sdk', 'bin')) ld_library_path.append(slave_dir.join('linux_vulkan_sdk', 'lib')) + env['VK_LAYER_PATH'] = str(slave_dir.join( + 'linux_vulkan_sdk', 'etc', 'explicit_layer.d')) if 'OpenCL' in extra_tokens: ld_library_path.append(slave_dir.join('opencl_ocl_icd_linux')) diff --git a/infra/bots/recipe_modules/flavor/examples/full.expected/Test-Debian9-Clang-NUC7i5BNK-GPU-IntelIris640-x86_64-Debug-All-Vulkan.json b/infra/bots/recipe_modules/flavor/examples/full.expected/Test-Debian9-Clang-NUC7i5BNK-GPU-IntelIris640-x86_64-Debug-All-Vulkan.json index 86ea6669ca..f204ff465d 100644 --- a/infra/bots/recipe_modules/flavor/examples/full.expected/Test-Debian9-Clang-NUC7i5BNK-GPU-IntelIris640-x86_64-Debug-All-Vulkan.json +++ b/infra/bots/recipe_modules/flavor/examples/full.expected/Test-Debian9-Clang-NUC7i5BNK-GPU-IntelIris640-x86_64-Debug-All-Vulkan.json @@ -209,7 +209,9 @@ "LD_LIBRARY_PATH": "[START_DIR]/mesa_intel_driver_linux:[START_DIR]/linux_vulkan_sdk/lib", "LIBGL_DRIVERS_PATH": "[START_DIR]/mesa_intel_driver_linux", "PATH": ":RECIPE_REPO[depot_tools]:[START_DIR]/linux_vulkan_sdk/bin", - "VK_ICD_FILENAMES": "[START_DIR]/mesa_intel_driver_linux/intel_icd.x86_64.json" + "VK_ICD_FILENAMES": "[START_DIR]/mesa_intel_driver_linux/intel_icd.x86_64.json", + "VK_LAYER_PATH": "[START_DIR]/linux_vulkan_sdk/etc/explicit_layer.d", + "VULKAN_SDK": "[START_DIR]/linux_vulkan_sdk" }, "name": "symbolized dm" }, diff --git a/infra/bots/recipes/perf.expected/Perf-Debian9-Clang-NUC5PPYH-GPU-IntelHD405-x86_64-Debug-All-Vulkan.json b/infra/bots/recipes/perf.expected/Perf-Debian9-Clang-NUC5PPYH-GPU-IntelHD405-x86_64-Debug-All-Vulkan.json index aab6ba5635..5fad925316 100644 --- a/infra/bots/recipes/perf.expected/Perf-Debian9-Clang-NUC5PPYH-GPU-IntelHD405-x86_64-Debug-All-Vulkan.json +++ b/infra/bots/recipes/perf.expected/Perf-Debian9-Clang-NUC5PPYH-GPU-IntelHD405-x86_64-Debug-All-Vulkan.json @@ -231,7 +231,9 @@ "LD_LIBRARY_PATH": "[START_DIR]/mesa_intel_driver_linux:[START_DIR]/linux_vulkan_sdk/lib", "LIBGL_DRIVERS_PATH": "[START_DIR]/mesa_intel_driver_linux", "PATH": ":RECIPE_REPO[depot_tools]:[START_DIR]/linux_vulkan_sdk/bin", - "VK_ICD_FILENAMES": "[START_DIR]/mesa_intel_driver_linux/intel_icd.x86_64.json" + "VK_ICD_FILENAMES": "[START_DIR]/mesa_intel_driver_linux/intel_icd.x86_64.json", + "VK_LAYER_PATH": "[START_DIR]/linux_vulkan_sdk/etc/explicit_layer.d", + "VULKAN_SDK": "[START_DIR]/linux_vulkan_sdk" }, "name": "symbolized nanobench" }, diff --git a/infra/bots/recipes/test.expected/Test-Debian9-Clang-NUC5PPYH-GPU-IntelHD405-x86_64-Release-All-Vulkan.json b/infra/bots/recipes/test.expected/Test-Debian9-Clang-NUC5PPYH-GPU-IntelHD405-x86_64-Release-All-Vulkan.json index aaae0a3e57..81f65aa7fb 100644 --- a/infra/bots/recipes/test.expected/Test-Debian9-Clang-NUC5PPYH-GPU-IntelHD405-x86_64-Release-All-Vulkan.json +++ b/infra/bots/recipes/test.expected/Test-Debian9-Clang-NUC5PPYH-GPU-IntelHD405-x86_64-Release-All-Vulkan.json @@ -479,7 +479,9 @@ "LD_LIBRARY_PATH": "[START_DIR]/mesa_intel_driver_linux:[START_DIR]/linux_vulkan_sdk/lib", "LIBGL_DRIVERS_PATH": "[START_DIR]/mesa_intel_driver_linux", "PATH": ":RECIPE_REPO[depot_tools]:[START_DIR]/linux_vulkan_sdk/bin", - "VK_ICD_FILENAMES": "[START_DIR]/mesa_intel_driver_linux/intel_icd.x86_64.json" + "VK_ICD_FILENAMES": "[START_DIR]/mesa_intel_driver_linux/intel_icd.x86_64.json", + "VK_LAYER_PATH": "[START_DIR]/linux_vulkan_sdk/etc/explicit_layer.d", + "VULKAN_SDK": "[START_DIR]/linux_vulkan_sdk" }, "name": "symbolized dm" }, diff --git a/infra/bots/recipes/test.expected/Test-Debian9-Clang-NUC7i5BNK-GPU-IntelIris640-x86_64-Debug-All-Vulkan.json b/infra/bots/recipes/test.expected/Test-Debian9-Clang-NUC7i5BNK-GPU-IntelIris640-x86_64-Debug-All-Vulkan.json index 930e53acdc..3d1cb25d05 100644 --- a/infra/bots/recipes/test.expected/Test-Debian9-Clang-NUC7i5BNK-GPU-IntelIris640-x86_64-Debug-All-Vulkan.json +++ b/infra/bots/recipes/test.expected/Test-Debian9-Clang-NUC7i5BNK-GPU-IntelIris640-x86_64-Debug-All-Vulkan.json @@ -461,7 +461,9 @@ "LD_LIBRARY_PATH": "[START_DIR]/mesa_intel_driver_linux:[START_DIR]/linux_vulkan_sdk/lib", "LIBGL_DRIVERS_PATH": "[START_DIR]/mesa_intel_driver_linux", "PATH": ":RECIPE_REPO[depot_tools]:[START_DIR]/linux_vulkan_sdk/bin", - "VK_ICD_FILENAMES": "[START_DIR]/mesa_intel_driver_linux/intel_icd.x86_64.json" + "VK_ICD_FILENAMES": "[START_DIR]/mesa_intel_driver_linux/intel_icd.x86_64.json", + "VK_LAYER_PATH": "[START_DIR]/linux_vulkan_sdk/etc/explicit_layer.d", + "VULKAN_SDK": "[START_DIR]/linux_vulkan_sdk" }, "name": "symbolized dm" }, diff --git a/infra/bots/recipes/test.expected/Test-Ubuntu18-Clang-Golo-GPU-QuadroP400-x86_64-Debug-All-Vulkan.json b/infra/bots/recipes/test.expected/Test-Ubuntu18-Clang-Golo-GPU-QuadroP400-x86_64-Debug-All-Vulkan.json index e70d132aa7..ff16ea49d6 100644 --- a/infra/bots/recipes/test.expected/Test-Ubuntu18-Clang-Golo-GPU-QuadroP400-x86_64-Debug-All-Vulkan.json +++ b/infra/bots/recipes/test.expected/Test-Ubuntu18-Clang-Golo-GPU-QuadroP400-x86_64-Debug-All-Vulkan.json @@ -405,7 +405,9 @@ "env": { "CHROME_HEADLESS": "1", "LD_LIBRARY_PATH": "[START_DIR]/linux_vulkan_sdk/lib", - "PATH": ":RECIPE_REPO[depot_tools]:[START_DIR]/linux_vulkan_sdk/bin" + "PATH": ":RECIPE_REPO[depot_tools]:[START_DIR]/linux_vulkan_sdk/bin", + "VK_LAYER_PATH": "[START_DIR]/linux_vulkan_sdk/etc/explicit_layer.d", + "VULKAN_SDK": "[START_DIR]/linux_vulkan_sdk" }, "name": "symbolized dm" }, diff --git a/tools/gpu/vk/VkTestUtils.cpp b/tools/gpu/vk/VkTestUtils.cpp index 5b7e8c29ae..399263d878 100644 --- a/tools/gpu/vk/VkTestUtils.cpp +++ b/tools/gpu/vk/VkTestUtils.cpp @@ -17,6 +17,9 @@ #endif #endif +#if defined(SK_BUILD_FOR_UNIX) +#include +#endif #include "include/gpu/vk/GrVkBackendContext.h" #include "include/gpu/vk/GrVkExtensions.h" #include "src/core/SkAutoMalloc.h" @@ -98,6 +101,16 @@ static int should_include_debug_layer(const char* layerName, return -1; } +static void print_backtrace() { +#if defined(SK_BUILD_FOR_UNIX) + void* stack[64]; + int count = backtrace(stack, SK_ARRAY_COUNT(stack)); + backtrace_symbols_fd(stack, count, 2); +#else + // Please add implementations for other platforms. +#endif +} + VKAPI_ATTR VkBool32 VKAPI_CALL DebugReportCallback( VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, @@ -109,18 +122,15 @@ VKAPI_ATTR VkBool32 VKAPI_CALL DebugReportCallback( void* pUserData) { if (flags & VK_DEBUG_REPORT_ERROR_BIT_EXT) { SkDebugf("Vulkan error [%s]: code: %d: %s\n", pLayerPrefix, messageCode, pMessage); + print_backtrace(); + SkDEBUGFAIL("Vulkan debug layer error"); return VK_TRUE; // skip further layers } else if (flags & VK_DEBUG_REPORT_WARNING_BIT_EXT) { - // There is currently a bug in the spec which doesn't have - // VK_STRUCTURE_TYPE_BLEND_OPERATION_ADVANCED_FEATURES_EXT as an allowable pNext struct in - // VkDeviceCreateInfo. So we ignore that warning since it is wrong. - if (!strstr(pMessage, - "pCreateInfo->pNext chain includes a structure with unexpected VkStructureType " - "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BLEND_OPERATION_ADVANCED_FEATURES_EXT")) { - SkDebugf("Vulkan warning [%s]: code: %d: %s\n", pLayerPrefix, messageCode, pMessage); - } + SkDebugf("Vulkan warning [%s]: code: %d: %s\n", pLayerPrefix, messageCode, pMessage); + print_backtrace(); } else if (flags & VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT) { SkDebugf("Vulkan perf warning [%s]: code: %d: %s\n", pLayerPrefix, messageCode, pMessage); + print_backtrace(); } else { SkDebugf("Vulkan info/debug [%s]: code: %d: %s\n", pLayerPrefix, messageCode, pMessage); }