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 18 matching lines...) Expand all Loading... |
29 #include "GrVkTextureRenderTarget.h" | 29 #include "GrVkTextureRenderTarget.h" |
30 #include "GrVkTransferBuffer.h" | 30 #include "GrVkTransferBuffer.h" |
31 #include "GrVkVertexBuffer.h" | 31 #include "GrVkVertexBuffer.h" |
32 | 32 |
33 #include "SkConfig8888.h" | 33 #include "SkConfig8888.h" |
34 #include "SkMipMap.h" | 34 #include "SkMipMap.h" |
35 | 35 |
36 #include "vk/GrVkInterface.h" | 36 #include "vk/GrVkInterface.h" |
37 #include "vk/GrVkTypes.h" | 37 #include "vk/GrVkTypes.h" |
38 | 38 |
| 39 #if USE_SKSL |
| 40 #include "SkSLCompiler.h" |
| 41 #endif |
| 42 |
39 #define VK_CALL(X) GR_VK_CALL(this->vkInterface(), X) | 43 #define VK_CALL(X) GR_VK_CALL(this->vkInterface(), X) |
40 #define VK_CALL_RET(RET, X) GR_VK_CALL_RET(this->vkInterface(), RET, X) | 44 #define VK_CALL_RET(RET, X) GR_VK_CALL_RET(this->vkInterface(), RET, X) |
41 #define VK_CALL_ERRCHECK(X) GR_VK_CALL_ERRCHECK(this->vkInterface(), X) | 45 #define VK_CALL_ERRCHECK(X) GR_VK_CALL_ERRCHECK(this->vkInterface(), X) |
42 | 46 |
43 #ifdef ENABLE_VK_LAYERS | 47 #ifdef ENABLE_VK_LAYERS |
44 VKAPI_ATTR VkBool32 VKAPI_CALL DebugReportCallback( | 48 VKAPI_ATTR VkBool32 VKAPI_CALL DebugReportCallback( |
45 VkDebugReportFlagsEXT flags, | 49 VkDebugReportFlagsEXT flags, |
46 VkDebugReportObjectTypeEXT objectType, | 50 VkDebugReportObjectTypeEXT objectType, |
47 uint64_t object, | 51 uint64_t object, |
48 size_t location, | 52 size_t location, |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT; | 107 VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT; |
104 callbackCreateInfo.pfnCallback = &DebugReportCallback; | 108 callbackCreateInfo.pfnCallback = &DebugReportCallback; |
105 callbackCreateInfo.pUserData = nullptr; | 109 callbackCreateInfo.pUserData = nullptr; |
106 | 110 |
107 // Register the callback | 111 // Register the callback |
108 GR_VK_CALL_ERRCHECK(this->vkInterface(), CreateDebugReportCallbackEXT( | 112 GR_VK_CALL_ERRCHECK(this->vkInterface(), CreateDebugReportCallbackEXT( |
109 backendCtx->fInstance, &callbackCreateInfo, nullptr,
&fCallback)); | 113 backendCtx->fInstance, &callbackCreateInfo, nullptr,
&fCallback)); |
110 } | 114 } |
111 #endif | 115 #endif |
112 | 116 |
| 117 #if USE_SKSL |
| 118 fCompiler = new SkSL::Compiler(); |
| 119 #else |
113 fCompiler = shaderc_compiler_initialize(); | 120 fCompiler = shaderc_compiler_initialize(); |
| 121 #endif |
114 | 122 |
115 fVkCaps.reset(new GrVkCaps(options, this->vkInterface(), backendCtx->fPhysic
alDevice, | 123 fVkCaps.reset(new GrVkCaps(options, this->vkInterface(), backendCtx->fPhysic
alDevice, |
116 backendCtx->fFeatures, backendCtx->fExtensions)); | 124 backendCtx->fFeatures, backendCtx->fExtensions)); |
117 fCaps.reset(SkRef(fVkCaps.get())); | 125 fCaps.reset(SkRef(fVkCaps.get())); |
118 | 126 |
119 VK_CALL(GetPhysicalDeviceMemoryProperties(backendCtx->fPhysicalDevice, &fPhy
sDevMemProps)); | 127 VK_CALL(GetPhysicalDeviceMemoryProperties(backendCtx->fPhysicalDevice, &fPhy
sDevMemProps)); |
120 | 128 |
121 const VkCommandPoolCreateInfo cmdPoolInfo = { | 129 const VkCommandPoolCreateInfo cmdPoolInfo = { |
122 VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, // sType | 130 VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, // sType |
123 nullptr, // pNext | 131 nullptr, // pNext |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 #endif | 177 #endif |
170 | 178 |
171 // VK_ERROR_DEVICE_LOST is acceptable when tearing down (see 4.2.4 in spec) | 179 // VK_ERROR_DEVICE_LOST is acceptable when tearing down (see 4.2.4 in spec) |
172 SkASSERT(VK_SUCCESS == res || VK_ERROR_DEVICE_LOST == res); | 180 SkASSERT(VK_SUCCESS == res || VK_ERROR_DEVICE_LOST == res); |
173 | 181 |
174 // must call this just before we destroy the VkDevice | 182 // must call this just before we destroy the VkDevice |
175 fResourceProvider.destroyResources(); | 183 fResourceProvider.destroyResources(); |
176 | 184 |
177 VK_CALL(DestroyCommandPool(fDevice, fCmdPool, nullptr)); | 185 VK_CALL(DestroyCommandPool(fDevice, fCmdPool, nullptr)); |
178 | 186 |
| 187 #if USE_SKSL |
| 188 delete fCompiler; |
| 189 #else |
179 shaderc_compiler_release(fCompiler); | 190 shaderc_compiler_release(fCompiler); |
| 191 #endif |
180 | 192 |
181 #ifdef ENABLE_VK_LAYERS | 193 #ifdef ENABLE_VK_LAYERS |
182 if (fCallback) { | 194 if (fCallback) { |
183 VK_CALL(DestroyDebugReportCallbackEXT(fBackendContext->fInstance, fCallb
ack, nullptr)); | 195 VK_CALL(DestroyDebugReportCallbackEXT(fBackendContext->fInstance, fCallb
ack, nullptr)); |
184 fCallback = VK_NULL_HANDLE; | 196 fCallback = VK_NULL_HANDLE; |
185 } | 197 } |
186 #endif | 198 #endif |
187 } | 199 } |
188 | 200 |
189 /////////////////////////////////////////////////////////////////////////////// | 201 /////////////////////////////////////////////////////////////////////////////// |
(...skipping 1298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1488 GrVkRenderTarget* target, | 1500 GrVkRenderTarget* target, |
1489 const SkIRect& bounds) { | 1501 const SkIRect& bounds) { |
1490 // Currently it is fine for us to always pass in 1 for the clear count even
if no attachment | 1502 // Currently it is fine for us to always pass in 1 for the clear count even
if no attachment |
1491 // uses it. In the current state, we also only use the LOAD_OP_CLEAR for the
color attachment | 1503 // uses it. In the current state, we also only use the LOAD_OP_CLEAR for the
color attachment |
1492 // which is always at the first attachment. | 1504 // which is always at the first attachment. |
1493 fCurrentCmdBuffer->beginRenderPass(this, renderPass, 1, colorClear, *target,
bounds, true); | 1505 fCurrentCmdBuffer->beginRenderPass(this, renderPass, 1, colorClear, *target,
bounds, true); |
1494 fCurrentCmdBuffer->executeCommands(this, buffer); | 1506 fCurrentCmdBuffer->executeCommands(this, buffer); |
1495 fCurrentCmdBuffer->endRenderPass(this); | 1507 fCurrentCmdBuffer->endRenderPass(this); |
1496 } | 1508 } |
1497 | 1509 |
OLD | NEW |