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 "GrVkCaps.h" | 14 #include "GrVkCaps.h" |
14 #include "GrVkIndexBuffer.h" | 15 #include "GrVkIndexBuffer.h" |
15 #include "GrVkProgram.h" | 16 #include "GrVkProgram.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 "vulkan/vulkan.h" | 22 #include "vulkan/vulkan.h" |
22 | 23 |
23 class GrPipeline; | 24 class GrPipeline; |
24 class GrNonInstancedMesh; | 25 class GrNonInstancedMesh; |
25 | 26 |
26 class GrVkBufferImpl; | 27 class GrVkBufferImpl; |
27 class GrVkCommandBuffer; | 28 class GrVkCommandBuffer; |
28 class GrVkPipeline; | 29 class GrVkPipeline; |
29 class GrVkRenderPass; | 30 class GrVkRenderPass; |
30 class GrVkTexture; | 31 class GrVkTexture; |
31 struct GrVkInterface; | 32 struct GrVkInterface; |
32 | 33 |
33 #ifdef SK_DEBUG | 34 #ifdef SK_DEBUG |
34 #define ENABLE_VK_LAYERS | 35 #define ENABLE_VK_LAYERS |
35 #endif | 36 #endif |
36 | 37 |
37 class GrVkGpu : public GrGpu { | 38 class GrVkGpu : public GrGpu { |
38 public: | 39 public: |
39 // Currently passing in the inst so that we can properly delete it when we a
re done. | 40 static GrGpu* Create(GrBackendContext backendContext, const GrContextOptions
& options, |
40 // Normally this would be done by the client. | 41 GrContext* context); |
41 GrVkGpu(GrContext* context, const GrContextOptions& options, | 42 |
42 VkPhysicalDevice physDev, VkDevice device, VkQueue queue, VkCommandP
ool cmdPool, | |
43 VkInstance inst); | |
44 ~GrVkGpu() override; | 43 ~GrVkGpu() override; |
45 | 44 |
46 const GrVkInterface* vkInterface() const { return fInterface.get(); } | 45 const GrVkInterface* vkInterface() const { return fBackendContext->fInterfac
e; } |
47 const GrVkCaps& vkCaps() const { return *fVkCaps; } | 46 const GrVkCaps& vkCaps() const { return *fVkCaps; } |
48 | 47 |
49 VkDevice device() const { return fDevice; } | 48 VkDevice device() const { return fDevice; } |
50 VkQueue queue() const { return fQueue; } | 49 VkQueue queue() const { return fQueue; } |
51 VkCommandPool cmdPool() const { return fCmdPool; } | 50 VkCommandPool cmdPool() const { return fCmdPool; } |
52 VkPhysicalDeviceMemoryProperties physicalDeviceMemoryProperties() const { | 51 VkPhysicalDeviceMemoryProperties physicalDeviceMemoryProperties() const { |
53 return fPhysDevMemProps; | 52 return fPhysDevMemProps; |
54 } | 53 } |
55 | 54 |
56 GrVkResourceProvider& resourceProvider() { return fResourceProvider; } | 55 GrVkResourceProvider& resourceProvider() { return fResourceProvider; } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 bool byRegion, | 116 bool byRegion, |
118 VkImageMemoryBarrier* barrier) const; | 117 VkImageMemoryBarrier* barrier) const; |
119 | 118 |
120 shaderc_compiler_t shadercCompiler() const { | 119 shaderc_compiler_t shadercCompiler() const { |
121 return fCompiler; | 120 return fCompiler; |
122 } | 121 } |
123 | 122 |
124 void finishDrawTarget() override; | 123 void finishDrawTarget() override; |
125 | 124 |
126 private: | 125 private: |
| 126 GrVkGpu(GrContext* context, const GrContextOptions& options, |
| 127 const GrVkBackendContext* backendContext); |
| 128 |
127 void onResetContext(uint32_t resetBits) override {} | 129 void onResetContext(uint32_t resetBits) override {} |
128 | 130 |
129 GrTexture* onCreateTexture(const GrSurfaceDesc& desc, GrGpuResource::LifeCyc
le, | 131 GrTexture* onCreateTexture(const GrSurfaceDesc& desc, GrGpuResource::LifeCyc
le, |
130 const SkTArray<GrMipLevel>&) override; | 132 const SkTArray<GrMipLevel>&) override; |
131 | 133 |
132 GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, GrGpuResourc
e::LifeCycle, | 134 GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, GrGpuResourc
e::LifeCycle, |
133 const SkTArray<GrMipLevel>&) override { | 135 const SkTArray<GrMipLevel>&) override { |
134 SkDebugf("onCreateCompressedTexture not yet implemented for Vulkan\n"); | 136 SkDebugf("onCreateCompressedTexture not yet implemented for Vulkan\n"); |
135 return NULL; | 137 return NULL; |
136 } | 138 } |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 const SkIRect& srcRect, | 206 const SkIRect& srcRect, |
205 const SkIPoint& dstPoint); | 207 const SkIPoint& dstPoint); |
206 | 208 |
207 // helper for onCreateTexture and writeTexturePixels | 209 // helper for onCreateTexture and writeTexturePixels |
208 bool uploadTexData(GrVkTexture* tex, | 210 bool uploadTexData(GrVkTexture* tex, |
209 int left, int top, int width, int height, | 211 int left, int top, int width, int height, |
210 GrPixelConfig dataConfig, | 212 GrPixelConfig dataConfig, |
211 const void* data, | 213 const void* data, |
212 size_t rowBytes); | 214 size_t rowBytes); |
213 | 215 |
214 SkAutoTUnref<const GrVkInterface> fInterface; | 216 SkAutoTUnref<const GrVkBackendContext> fBackendContext; |
215 SkAutoTUnref<GrVkCaps> fVkCaps; | 217 SkAutoTUnref<GrVkCaps> fVkCaps; |
216 VkPhysicalDeviceMemoryProperties fPhysDevMemProps; | 218 |
217 VkDevice fDevice; | 219 // These Vulkan objects are provided by the client, and also stored in fBack
endContext. |
218 VkQueue fQueue; // for now, one queue | 220 // They're copied here for convenient access. |
219 VkCommandPool fCmdPool; | 221 VkInstance fVkInstance; |
220 GrVkCommandBuffer* fCurrentCmdBuffer; | 222 VkDevice fDevice; |
221 GrVkResourceProvider fResourceProvider; | 223 VkQueue fQueue; // Must be Graphics queue |
| 224 |
| 225 // Created by GrVkGpu |
| 226 GrVkResourceProvider fResourceProvider; |
| 227 VkCommandPool fCmdPool; |
| 228 GrVkCommandBuffer* fCurrentCmdBuffer; |
| 229 VkPhysicalDeviceMemoryProperties fPhysDevMemProps; |
222 | 230 |
223 #ifdef ENABLE_VK_LAYERS | 231 #ifdef ENABLE_VK_LAYERS |
224 // For reporting validation layer errors | 232 // For reporting validation layer errors |
225 VkDebugReportCallbackEXT fCallback; | 233 VkDebugReportCallbackEXT fCallback; |
226 #endif | 234 #endif |
227 | 235 |
228 // Shaderc compiler used for compiling glsl in spirv. We only want to create
the compiler once | 236 // Shaderc compiler used for compiling glsl in spirv. We only want to create
the compiler once |
229 // since there is significant overhead to the first compile of any compiler. | 237 // since there is significant overhead to the first compile of any compiler. |
230 shaderc_compiler_t fCompiler; | 238 shaderc_compiler_t fCompiler; |
231 | 239 |
232 // This is only for our current testing and building. The client should be h
olding on to the | |
233 // VkInstance. | |
234 VkInstance fVkInstance; | |
235 | 240 |
236 typedef GrGpu INHERITED; | 241 typedef GrGpu INHERITED; |
237 }; | 242 }; |
238 | 243 |
239 #endif | 244 #endif |
OLD | NEW |