Enable Vulkan Debug layers

Bug: skia:8709
Change-Id: Ie7033d4545df10011af1c1f207bce9ceaff829c0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/187921
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Ben Wagner aka dogben <benjaminwagner@google.com>
Auto-Submit: Ben Wagner aka dogben <benjaminwagner@google.com>
This commit is contained in:
Ben Wagner 2020-01-02 11:22:39 -05:00 committed by Skia Commit-Bot
parent 250138d95c
commit c2b6d7f50b
11 changed files with 40 additions and 17 deletions

View File

@ -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:

View File

@ -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": {

View File

@ -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": {

View File

@ -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": {

View File

@ -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'))

View File

@ -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": "<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"
},

View File

@ -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": "<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"
},

View File

@ -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": "<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"
},

View File

@ -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": "<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"
},

View File

@ -405,7 +405,9 @@
"env": {
"CHROME_HEADLESS": "1",
"LD_LIBRARY_PATH": "[START_DIR]/linux_vulkan_sdk/lib",
"PATH": "<PATH>:RECIPE_REPO[depot_tools]:[START_DIR]/linux_vulkan_sdk/bin"
"PATH": "<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"
},

View File

@ -17,6 +17,9 @@
#endif
#endif
#if defined(SK_BUILD_FOR_UNIX)
#include <execinfo.h>
#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);
}