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 #ifndef GrVkGpu_DEFINED | 8 #ifndef GrVkGpu_DEFINED |
9 #define GrVkGpu_DEFINED | 9 #define GrVkGpu_DEFINED |
10 | 10 |
11 #include "GrGpu.h" | 11 #include "GrGpu.h" |
12 #include "GrGpuFactory.h" | 12 #include "GrGpuFactory.h" |
13 #include "vk/GrVkBackendContext.h" | 13 #include "vk/GrVkBackendContext.h" |
14 #include "GrVkCaps.h" | 14 #include "GrVkCaps.h" |
15 #include "GrVkIndexBuffer.h" | 15 #include "GrVkIndexBuffer.h" |
| 16 #include "GrVkMemory.h" |
16 #include "GrVkResourceProvider.h" | 17 #include "GrVkResourceProvider.h" |
17 #include "GrVkVertexBuffer.h" | 18 #include "GrVkVertexBuffer.h" |
18 #include "GrVkUtil.h" | 19 #include "GrVkUtil.h" |
19 | 20 |
20 #include "shaderc/shaderc.h" | 21 #include "shaderc/shaderc.h" |
21 #include "vk/GrVkDefines.h" | 22 #include "vk/GrVkDefines.h" |
22 | 23 |
23 class GrPipeline; | 24 class GrPipeline; |
24 class GrNonInstancedMesh; | 25 class GrNonInstancedMesh; |
25 | 26 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 shaderc_compiler_t shadercCompiler() const { | 116 shaderc_compiler_t shadercCompiler() const { |
116 return fCompiler; | 117 return fCompiler; |
117 } | 118 } |
118 | 119 |
119 void submitSecondaryCommandBuffer(const GrVkSecondaryCommandBuffer*); | 120 void submitSecondaryCommandBuffer(const GrVkSecondaryCommandBuffer*); |
120 | 121 |
121 void finishDrawTarget() override; | 122 void finishDrawTarget() override; |
122 | 123 |
123 void generateMipmap(GrVkTexture* tex) const; | 124 void generateMipmap(GrVkTexture* tex) const; |
124 | 125 |
| 126 // Heaps |
| 127 enum Heap { |
| 128 kLinearImage_Heap = 0, |
| 129 // We separate out small (i.e., <= 16K) images to reduce fragmentation |
| 130 // in the main heap. |
| 131 kOptimalImage_Heap, |
| 132 kSmallOptimalImage_Heap, |
| 133 // We have separate vertex and image heaps, because it's possible that |
| 134 // a given Vulkan driver may allocate them separately. |
| 135 kVertexBuffer_Heap, |
| 136 kIndexBuffer_Heap, |
| 137 kUniformBuffer_Heap, |
| 138 kCopyReadBuffer_Heap, |
| 139 kCopyWriteBuffer_Heap, |
| 140 |
| 141 kLastHeap = kCopyWriteBuffer_Heap |
| 142 }; |
| 143 static const int kHeapCount = kLastHeap + 1; |
| 144 |
| 145 GrVkHeap* getHeap(Heap heap) const { return fHeaps[heap]; } |
| 146 |
125 private: | 147 private: |
126 GrVkGpu(GrContext* context, const GrContextOptions& options, | 148 GrVkGpu(GrContext* context, const GrContextOptions& options, |
127 const GrVkBackendContext* backendContext); | 149 const GrVkBackendContext* backendContext); |
128 | 150 |
129 void onResetContext(uint32_t resetBits) override {} | 151 void onResetContext(uint32_t resetBits) override {} |
130 | 152 |
131 GrTexture* onCreateTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted, | 153 GrTexture* onCreateTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted, |
132 const SkTArray<GrMipLevel>&) override; | 154 const SkTArray<GrMipLevel>&) override; |
133 | 155 |
134 GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, SkBudgeted, | 156 GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, SkBudgeted, |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 // They're copied here for convenient access. | 241 // They're copied here for convenient access. |
220 VkDevice fDevice; | 242 VkDevice fDevice; |
221 VkQueue fQueue; // Must be Graphics queue | 243 VkQueue fQueue; // Must be Graphics queue |
222 | 244 |
223 // Created by GrVkGpu | 245 // Created by GrVkGpu |
224 GrVkResourceProvider fResourceProvider; | 246 GrVkResourceProvider fResourceProvider; |
225 VkCommandPool fCmdPool; | 247 VkCommandPool fCmdPool; |
226 GrVkPrimaryCommandBuffer* fCurrentCmdBuffer; | 248 GrVkPrimaryCommandBuffer* fCurrentCmdBuffer; |
227 VkPhysicalDeviceMemoryProperties fPhysDevMemProps; | 249 VkPhysicalDeviceMemoryProperties fPhysDevMemProps; |
228 | 250 |
| 251 SkAutoTDelete<GrVkHeap> fHeaps[kHeapCount]; |
| 252 |
229 #ifdef ENABLE_VK_LAYERS | 253 #ifdef ENABLE_VK_LAYERS |
230 // For reporting validation layer errors | 254 // For reporting validation layer errors |
231 VkDebugReportCallbackEXT fCallback; | 255 VkDebugReportCallbackEXT fCallback; |
232 #endif | 256 #endif |
233 | 257 |
234 // Shaderc compiler used for compiling glsl in spirv. We only want to create
the compiler once | 258 // Shaderc compiler used for compiling glsl in spirv. We only want to create
the compiler once |
235 // since there is significant overhead to the first compile of any compiler. | 259 // since there is significant overhead to the first compile of any compiler. |
236 shaderc_compiler_t fCompiler; | 260 shaderc_compiler_t fCompiler; |
237 | 261 |
238 | 262 |
239 typedef GrGpu INHERITED; | 263 typedef GrGpu INHERITED; |
240 }; | 264 }; |
241 | 265 |
242 #endif | 266 #endif |
OLD | NEW |