Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(520)

Side by Side Diff: src/gpu/vk/GrVkGpu.cpp

Issue 1935163002: Make sure that Vulkan debug callback ptr is non-null. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix one more tab Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/vk/GrVkGpu.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrVkGpu.h" 8 #include "GrVkGpu.h"
9 9
10 #include "GrContextOptions.h" 10 #include "GrContextOptions.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 } 76 }
77 77
78 return new GrVkGpu(context, options, vkBackendContext); 78 return new GrVkGpu(context, options, vkBackendContext);
79 } 79 }
80 80
81 //////////////////////////////////////////////////////////////////////////////// 81 ////////////////////////////////////////////////////////////////////////////////
82 82
83 GrVkGpu::GrVkGpu(GrContext* context, const GrContextOptions& options, 83 GrVkGpu::GrVkGpu(GrContext* context, const GrContextOptions& options,
84 const GrVkBackendContext* backendCtx) 84 const GrVkBackendContext* backendCtx)
85 : INHERITED(context) 85 : INHERITED(context)
86 #ifdef ENABLE_VK_LAYERS
87 , fVkInstance(backendCtx->fInstance)
88 #endif
89 , fDevice(backendCtx->fDevice) 86 , fDevice(backendCtx->fDevice)
90 , fQueue(backendCtx->fQueue) 87 , fQueue(backendCtx->fQueue)
91 , fResourceProvider(this) { 88 , fResourceProvider(this) {
92 fBackendContext.reset(backendCtx); 89 fBackendContext.reset(backendCtx);
93 90
94 #ifdef ENABLE_VK_LAYERS 91 #ifdef ENABLE_VK_LAYERS
92 fCallback = nullptr;
95 if (backendCtx->fExtensions & kEXT_debug_report_GrVkExtensionFlag) { 93 if (backendCtx->fExtensions & kEXT_debug_report_GrVkExtensionFlag) {
96 // Setup callback creation information 94 // Setup callback creation information
97 VkDebugReportCallbackCreateInfoEXT callbackCreateInfo; 95 VkDebugReportCallbackCreateInfoEXT callbackCreateInfo;
98 callbackCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EX T; 96 callbackCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EX T;
99 callbackCreateInfo.pNext = nullptr; 97 callbackCreateInfo.pNext = nullptr;
100 callbackCreateInfo.flags = VK_DEBUG_REPORT_ERROR_BIT_EXT | 98 callbackCreateInfo.flags = VK_DEBUG_REPORT_ERROR_BIT_EXT |
101 VK_DEBUG_REPORT_WARNING_BIT_EXT | 99 VK_DEBUG_REPORT_WARNING_BIT_EXT |
102 //VK_DEBUG_REPORT_INFORMATION_BIT_EXT | 100 //VK_DEBUG_REPORT_INFORMATION_BIT_EXT |
103 //VK_DEBUG_REPORT_DEBUG_BIT_EXT | 101 //VK_DEBUG_REPORT_DEBUG_BIT_EXT |
104 VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT; 102 VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT;
105 callbackCreateInfo.pfnCallback = &DebugReportCallback; 103 callbackCreateInfo.pfnCallback = &DebugReportCallback;
106 callbackCreateInfo.pUserData = nullptr; 104 callbackCreateInfo.pUserData = nullptr;
107 105
108 // Register the callback 106 // Register the callback
109 GR_VK_CALL_ERRCHECK(this->vkInterface(), CreateDebugReportCallbackEXT(fV kInstance, 107 GR_VK_CALL_ERRCHECK(this->vkInterface(), CreateDebugReportCallbackEXT(
110 &callbackCreateInfo, nullptr, &fCallback)); 108 backendCtx->fInstance, &callbackCreateInfo, nullptr, &fCallback));
111 } 109 }
112 #endif 110 #endif
113 111
114 fCompiler = shaderc_compiler_initialize(); 112 fCompiler = shaderc_compiler_initialize();
115 113
116 fVkCaps.reset(new GrVkCaps(options, this->vkInterface(), backendCtx->fPhysic alDevice, 114 fVkCaps.reset(new GrVkCaps(options, this->vkInterface(), backendCtx->fPhysic alDevice,
117 backendCtx->fFeatures, backendCtx->fExtensions)); 115 backendCtx->fFeatures, backendCtx->fExtensions));
118 fCaps.reset(SkRef(fVkCaps.get())); 116 fCaps.reset(SkRef(fVkCaps.get()));
119 117
120 VK_CALL(GetPhysicalDeviceMemoryProperties(backendCtx->fPhysicalDevice, &fPhy sDevMemProps)); 118 VK_CALL(GetPhysicalDeviceMemoryProperties(backendCtx->fPhysicalDevice, &fPhy sDevMemProps));
(...skipping 13 matching lines...) Expand all
134 SkASSERT(fCurrentCmdBuffer); 132 SkASSERT(fCurrentCmdBuffer);
135 fCurrentCmdBuffer->begin(this); 133 fCurrentCmdBuffer->begin(this);
136 } 134 }
137 135
138 GrVkGpu::~GrVkGpu() { 136 GrVkGpu::~GrVkGpu() {
139 fCurrentCmdBuffer->end(this); 137 fCurrentCmdBuffer->end(this);
140 fCurrentCmdBuffer->unref(this); 138 fCurrentCmdBuffer->unref(this);
141 139
142 // wait for all commands to finish 140 // wait for all commands to finish
143 fResourceProvider.checkCommandBuffers(); 141 fResourceProvider.checkCommandBuffers();
144 SkDEBUGCODE(VkResult res =) VK_CALL(QueueWaitIdle(fQueue)); 142 SkDEBUGCODE(VkResult res = ) VK_CALL(QueueWaitIdle(fQueue));
145 // VK_ERROR_DEVICE_LOST is acceptable when tearing down (see 4.2.4 in spec) 143 // VK_ERROR_DEVICE_LOST is acceptable when tearing down (see 4.2.4 in spec)
146 SkASSERT(VK_SUCCESS == res || VK_ERROR_DEVICE_LOST == res); 144 SkASSERT(VK_SUCCESS == res || VK_ERROR_DEVICE_LOST == res);
147 145
148 // must call this just before we destroy the VkDevice 146 // must call this just before we destroy the VkDevice
149 fResourceProvider.destroyResources(); 147 fResourceProvider.destroyResources();
150 148
151 VK_CALL(DestroyCommandPool(fDevice, fCmdPool, nullptr)); 149 VK_CALL(DestroyCommandPool(fDevice, fCmdPool, nullptr));
152 150
153 shaderc_compiler_release(fCompiler); 151 shaderc_compiler_release(fCompiler);
154 152
155 #ifdef ENABLE_VK_LAYERS 153 #ifdef ENABLE_VK_LAYERS
156 VK_CALL(DestroyDebugReportCallbackEXT(fVkInstance, fCallback, nullptr)); 154 if (fCallback) {
155 VK_CALL(DestroyDebugReportCallbackEXT(fBackendContext->fInstance, fCallb ack, nullptr));
156 fCallback = nullptr;
157 }
157 #endif 158 #endif
158 } 159 }
159 160
160 /////////////////////////////////////////////////////////////////////////////// 161 ///////////////////////////////////////////////////////////////////////////////
161 162
162 void GrVkGpu::submitCommandBuffer(SyncQueue sync) { 163 void GrVkGpu::submitCommandBuffer(SyncQueue sync) {
163 SkASSERT(fCurrentCmdBuffer); 164 SkASSERT(fCurrentCmdBuffer);
164 fCurrentCmdBuffer->end(this); 165 fCurrentCmdBuffer->end(this);
165 166
166 fCurrentCmdBuffer->submitToQueue(this, fQueue, sync); 167 fCurrentCmdBuffer->submitToQueue(this, fQueue, sync);
(...skipping 1640 matching lines...) Expand 10 before | Expand all | Expand 10 after
1807 aglSwapBuffers(aglGetCurrentContext()); 1808 aglSwapBuffers(aglGetCurrentContext());
1808 int set_a_break_pt_here = 9; 1809 int set_a_break_pt_here = 9;
1809 aglSwapBuffers(aglGetCurrentContext()); 1810 aglSwapBuffers(aglGetCurrentContext());
1810 #elif defined(SK_BUILD_FOR_WIN32) 1811 #elif defined(SK_BUILD_FOR_WIN32)
1811 SwapBuf(); 1812 SwapBuf();
1812 int set_a_break_pt_here = 9; 1813 int set_a_break_pt_here = 9;
1813 SwapBuf(); 1814 SwapBuf();
1814 #endif 1815 #endif
1815 #endif 1816 #endif
1816 } 1817 }
OLDNEW
« no previous file with comments | « src/gpu/vk/GrVkGpu.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698