diff options
author | Greg Daniel <egdaniel@google.com> | 2018-06-28 23:30:23 +0000 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-06-28 23:30:30 +0000 |
commit | 3148f802af419297c466e6bf5efc003b6c498f0a (patch) | |
tree | cb1a426ff485b0b2aa37dfd91e55765d3b2251f3 /src/gpu/vk | |
parent | dc13c21b1e49ca1e16251d01bd1062157c5c1c2b (diff) |
Revert "Reland "Move Vulkan DebugCallback code into tools.""
This reverts commit be0ab883e796b190cd20a4b1cfaedea932f9e0bf.
Reason for revert: fuchsia change reverted
Original change's description:
> Reland "Move Vulkan DebugCallback code into tools."
>
> This reverts commit 05d3fe3f100b794abe3f99a770734057960d7da5.
>
> Reason for revert: relanding after fuchsia fixes are in
>
> Original change's description:
> > 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>
>
> 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: Idb88f21018b9c0e23b62f0a5b12f0fab60373921
> Reviewed-on: https://skia-review.googlesource.com/138300
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Commit-Queue: Greg Daniel <egdaniel@google.com>
TBR=egdaniel@google.com,jvanverth@google.com,bsalomon@google.com
Change-Id: I40d5ba1067248066403f843c0739b885a2bfc834
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/138421
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; |