diff options
author | Greg Daniel <egdaniel@google.com> | 2018-06-27 15:04:39 +0000 |
---|---|---|
committer | Greg Daniel <egdaniel@google.com> | 2018-06-27 15:24:23 +0000 |
commit | 05d3fe3f100b794abe3f99a770734057960d7da5 (patch) | |
tree | 5498a44126c8c190894def22a623db80a3db6965 /src/gpu/vk | |
parent | 05f83d9ea31b589502f3a46f79221726013b5581 (diff) |
Revert "Move Vulkan DebugCallback code into tools."
This reverts commit d4b2adeaa929edd1664754ac6621ec524992ef03.
Reason for revert: Need to revert earlier changes cause of fucshia
Original change's description:
> Move Vulkan DebugCallback code into tools.
>
> Bug: skia:
> Change-Id: Ib356200e86e54f9ff0ba16396874e6fd10cf0465
> Reviewed-on: https://skia-review.googlesource.com/137424
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Greg Daniel <egdaniel@google.com>
TBR=egdaniel@google.com,jvanverth@google.com,bsalomon@google.com
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: skia:
Change-Id: I38d4e71dc29c6503f92712be54e22c58956498c5
Reviewed-on: https://skia-review.googlesource.com/137902
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'src/gpu/vk')
-rw-r--r-- | src/gpu/vk/GrVkGpu.cpp | 54 | ||||
-rw-r--r-- | src/gpu/vk/GrVkGpu.h | 5 |
2 files changed, 59 insertions, 0 deletions
diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp index 65225d919d..0b160a6ade 100644 --- a/src/gpu/vk/GrVkGpu.cpp +++ b/src/gpu/vk/GrVkGpu.cpp @@ -49,6 +49,30 @@ #define VK_CALL_RET(RET, X) GR_VK_CALL_RET(this->vkInterface(), RET, X) #define VK_CALL_ERRCHECK(X) GR_VK_CALL_ERRCHECK(this->vkInterface(), X) +#ifdef SK_ENABLE_VK_LAYERS +VKAPI_ATTR VkBool32 VKAPI_CALL DebugReportCallback( + VkDebugReportFlagsEXT flags, + VkDebugReportObjectTypeEXT objectType, + uint64_t object, + size_t location, + int32_t messageCode, + const char* pLayerPrefix, + const char* pMessage, + void* pUserData) { + if (flags & VK_DEBUG_REPORT_ERROR_BIT_EXT) { + SkDebugf("Vulkan error [%s]: code: %d: %s\n", pLayerPrefix, messageCode, pMessage); + return VK_TRUE; // skip further layers + } else if (flags & VK_DEBUG_REPORT_WARNING_BIT_EXT) { + SkDebugf("Vulkan warning [%s]: code: %d: %s\n", pLayerPrefix, messageCode, pMessage); + } else if (flags & VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT) { + SkDebugf("Vulkan perf warning [%s]: code: %d: %s\n", pLayerPrefix, messageCode, pMessage); + } else { + SkDebugf("Vulkan info/debug [%s]: code: %d: %s\n", pLayerPrefix, messageCode, pMessage); + } + return VK_FALSE; +} +#endif + sk_sp<GrGpu> GrVkGpu::Make(const GrVkBackendContext& backendContext, const GrContextOptions& options, GrContext* context) { if (backendContext.fInstance == VK_NULL_HANDLE || @@ -78,6 +102,27 @@ GrVkGpu::GrVkGpu(GrContext* context, const GrContextOptions& options, , fResourceProvider(this) , fDisconnected(false) { SkASSERT(!backendContext.fOwnsInstanceAndDevice); +#ifdef SK_ENABLE_VK_LAYERS + fCallback = VK_NULL_HANDLE; + if (backendContext.fExtensions & kEXT_debug_report_GrVkExtensionFlag) { + // Setup callback creation information + VkDebugReportCallbackCreateInfoEXT callbackCreateInfo; + callbackCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT; + callbackCreateInfo.pNext = nullptr; + callbackCreateInfo.flags = VK_DEBUG_REPORT_ERROR_BIT_EXT | + VK_DEBUG_REPORT_WARNING_BIT_EXT | + //VK_DEBUG_REPORT_INFORMATION_BIT_EXT | + //VK_DEBUG_REPORT_DEBUG_BIT_EXT | + VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT; + callbackCreateInfo.pfnCallback = &DebugReportCallback; + callbackCreateInfo.pUserData = nullptr; + + // Register the callback + GR_VK_CALL_ERRCHECK(this->vkInterface(), + CreateDebugReportCallbackEXT(backendContext.fInstance, + &callbackCreateInfo, nullptr, &fCallback)); + } +#endif if (!fMemoryAllocator) { // We were not given a memory allocator at creation @@ -159,6 +204,12 @@ void GrVkGpu::destroyResources() { VK_CALL(DestroyCommandPool(fDevice, fCmdPool, nullptr)); } +#ifdef SK_ENABLE_VK_LAYERS + if (fCallback) { + VK_CALL(DestroyDebugReportCallbackEXT(fInstance, fCallback, nullptr)); + } +#endif + fMemoryAllocator.reset(); fQueue = VK_NULL_HANDLE; @@ -194,6 +245,9 @@ void GrVkGpu::disconnect(DisconnectType type) { } fSemaphoresToWaitOn.reset(); fSemaphoresToSignal.reset(); +#ifdef SK_ENABLE_VK_LAYERS + fCallback = VK_NULL_HANDLE; +#endif fCurrentCmdBuffer = nullptr; fCmdPool = VK_NULL_HANDLE; fDisconnected = true; diff --git a/src/gpu/vk/GrVkGpu.h b/src/gpu/vk/GrVkGpu.h index 266c916cad..f506d28b0e 100644 --- a/src/gpu/vk/GrVkGpu.h +++ b/src/gpu/vk/GrVkGpu.h @@ -244,6 +244,11 @@ private: GrVkCopyManager fCopyManager; +#ifdef SK_ENABLE_VK_LAYERS + // For reporting validation layer errors + VkDebugReportCallbackEXT fCallback; +#endif + // compiler used for compiling sksl into spirv. We only want to create the compiler once since // there is significant overhead to the first compile of any compiler. SkSL::Compiler* fCompiler; |