Make sure that Vulkan debug callback ptr is non-null.

BUG=skia:5244
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1935163002

Review-Url: https://codereview.chromium.org/1935163002
This commit is contained in:
jvanverth 2016-05-02 13:24:48 -07:00 committed by Commit bot
parent 40ef48580b
commit a00980e580
2 changed files with 8 additions and 10 deletions

View File

@ -83,15 +83,13 @@ GrGpu* GrVkGpu::Create(GrBackendContext backendContext, const GrContextOptions&
GrVkGpu::GrVkGpu(GrContext* context, const GrContextOptions& options,
const GrVkBackendContext* backendCtx)
: INHERITED(context)
#ifdef ENABLE_VK_LAYERS
, fVkInstance(backendCtx->fInstance)
#endif
, fDevice(backendCtx->fDevice)
, fQueue(backendCtx->fQueue)
, fResourceProvider(this) {
fBackendContext.reset(backendCtx);
#ifdef ENABLE_VK_LAYERS
fCallback = nullptr;
if (backendCtx->fExtensions & kEXT_debug_report_GrVkExtensionFlag) {
// Setup callback creation information
VkDebugReportCallbackCreateInfoEXT callbackCreateInfo;
@ -106,8 +104,8 @@ GrVkGpu::GrVkGpu(GrContext* context, const GrContextOptions& options,
callbackCreateInfo.pUserData = nullptr;
// Register the callback
GR_VK_CALL_ERRCHECK(this->vkInterface(), CreateDebugReportCallbackEXT(fVkInstance,
&callbackCreateInfo, nullptr, &fCallback));
GR_VK_CALL_ERRCHECK(this->vkInterface(), CreateDebugReportCallbackEXT(
backendCtx->fInstance, &callbackCreateInfo, nullptr, &fCallback));
}
#endif
@ -141,7 +139,7 @@ GrVkGpu::~GrVkGpu() {
// wait for all commands to finish
fResourceProvider.checkCommandBuffers();
SkDEBUGCODE(VkResult res =) VK_CALL(QueueWaitIdle(fQueue));
SkDEBUGCODE(VkResult res = ) VK_CALL(QueueWaitIdle(fQueue));
// VK_ERROR_DEVICE_LOST is acceptable when tearing down (see 4.2.4 in spec)
SkASSERT(VK_SUCCESS == res || VK_ERROR_DEVICE_LOST == res);
@ -153,7 +151,10 @@ GrVkGpu::~GrVkGpu() {
shaderc_compiler_release(fCompiler);
#ifdef ENABLE_VK_LAYERS
VK_CALL(DestroyDebugReportCallbackEXT(fVkInstance, fCallback, nullptr));
if (fCallback) {
VK_CALL(DestroyDebugReportCallbackEXT(fBackendContext->fInstance, fCallback, nullptr));
fCallback = nullptr;
}
#endif
}

View File

@ -208,9 +208,6 @@ private:
// These Vulkan objects are provided by the client, and also stored in fBackendContext.
// They're copied here for convenient access.
#ifdef ENABLE_VK_LAYERS
VkInstance fVkInstance;
#endif
VkDevice fDevice;
VkQueue fQueue; // Must be Graphics queue