OLD | NEW |
---|---|
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 Loading... | |
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)); |
121 | 119 |
122 const VkCommandPoolCreateInfo cmdPoolInfo = { | 120 const VkCommandPoolCreateInfo cmdPoolInfo = { |
123 VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, // sType | 121 VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, // sType |
124 nullptr, // pNext | 122 nullptr, // pNext |
125 VK_COMMAND_POOL_CREATE_TRANSIENT_BIT, // CmdPoolCreateFlags | 123 VK_COMMAND_POOL_CREATE_TRANSIENT_BIT, // CmdPoolCreateFlags |
126 backendCtx->fGraphicsQueueIndex, // queueFamilyIndex | 124 backendCtx->fGraphicsQueueIndex, // queueFamilyIndex |
127 }; | 125 }; |
128 GR_VK_CALL_ERRCHECK(this->vkInterface(), CreateCommandPool(fDevice, &cmdPool Info, nullptr, | 126 GR_VK_CALL_ERRCHECK(this->vkInterface(), CreateCommandPool(fDevice, &cmdPool Info, nullptr, |
129 &fCmdPool)); | 127 &fCmdPool)); |
130 | 128 |
131 // must call this after creating the CommandPool | 129 // must call this after creating the CommandPool |
132 fResourceProvider.init(); | 130 fResourceProvider.init(); |
133 fCurrentCmdBuffer = fResourceProvider.createCommandBuffer(); | 131 fCurrentCmdBuffer = fResourceProvider.createCommandBuffer(); |
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); |
djsollen
2016/05/02 19:17:44
spaces not tabs.
jvanverth1
2016/05/02 19:56:33
Done.
| |
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 sp ec) |
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 , fCallback, 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 1627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1794 aglSwapBuffers(aglGetCurrentContext()); | 1795 aglSwapBuffers(aglGetCurrentContext()); |
1795 int set_a_break_pt_here = 9; | 1796 int set_a_break_pt_here = 9; |
1796 aglSwapBuffers(aglGetCurrentContext()); | 1797 aglSwapBuffers(aglGetCurrentContext()); |
1797 #elif defined(SK_BUILD_FOR_WIN32) | 1798 #elif defined(SK_BUILD_FOR_WIN32) |
1798 SwapBuf(); | 1799 SwapBuf(); |
1799 int set_a_break_pt_here = 9; | 1800 int set_a_break_pt_here = 9; |
1800 SwapBuf(); | 1801 SwapBuf(); |
1801 #endif | 1802 #endif |
1802 #endif | 1803 #endif |
1803 } | 1804 } |
OLD | NEW |