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

Side by Side Diff: src/gpu/vk/GrVkResourceProvider.h

Issue 2115993002: Add resource tracking output and command buffer recycling (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address comments Created 4 years, 5 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/GrVkResource.h ('k') | src/gpu/vk/GrVkResourceProvider.cpp » ('j') | 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 2016 Google Inc. 2 * Copyright 2016 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 GrVkResourceProvider_DEFINED 8 #ifndef GrVkResourceProvider_DEFINED
9 #define GrVkResourceProvider_DEFINED 9 #define GrVkResourceProvider_DEFINED
10 10
11 #include "GrGpu.h" 11 #include "GrGpu.h"
12 #include "GrResourceHandle.h" 12 #include "GrResourceHandle.h"
13 #include "GrVkDescriptorPool.h" 13 #include "GrVkDescriptorPool.h"
14 #include "GrVkPipelineState.h" 14 #include "GrVkPipelineState.h"
15 #include "GrVkRenderPass.h" 15 #include "GrVkRenderPass.h"
16 #include "GrVkResource.h" 16 #include "GrVkResource.h"
17 #include "GrVkUtil.h" 17 #include "GrVkUtil.h"
18 #include "SkTArray.h" 18 #include "SkTArray.h"
19 #include "SkTDynamicHash.h" 19 #include "SkTDynamicHash.h"
20 #include "SkTHash.h" 20 #include "SkTHash.h"
21 #include "SkTInternalLList.h" 21 #include "SkTInternalLList.h"
22 22
23 #include "vk/GrVkDefines.h" 23 #include "vk/GrVkDefines.h"
24 24
25 class GrPipeline; 25 class GrPipeline;
26 class GrPrimitiveProcessor; 26 class GrPrimitiveProcessor;
27 class GrTextureParams; 27 class GrTextureParams;
28 class GrVkPrimaryCommandBuffer;
29 class GrVkGpu; 28 class GrVkGpu;
30 class GrVkPipeline; 29 class GrVkPipeline;
30 class GrVkPrimaryCommandBuffer;
31 class GrVkRenderTarget; 31 class GrVkRenderTarget;
32 class GrVkSampler; 32 class GrVkSampler;
33 class GrVkSecondaryCommandBuffer;
33 34
34 class GrVkResourceProvider { 35 class GrVkResourceProvider {
35 public: 36 public:
36 GrVkResourceProvider(GrVkGpu* gpu); 37 GrVkResourceProvider(GrVkGpu* gpu);
37 ~GrVkResourceProvider(); 38 ~GrVkResourceProvider();
38 39
39 // Set up any initial vk objects 40 // Set up any initial vk objects
40 void init(); 41 void init();
41 42
42 GrVkPipeline* createPipeline(const GrPipeline& pipeline, 43 GrVkPipeline* createPipeline(const GrPipeline& pipeline,
(...skipping 26 matching lines...) Expand all
69 const GrVkRenderPass::LoadStoreOps& ste ncilOps, 70 const GrVkRenderPass::LoadStoreOps& ste ncilOps,
70 CompatibleRPHandle* compatibleHandle = nullptr); 71 CompatibleRPHandle* compatibleHandle = nullptr);
71 72
72 // The CompatibleRPHandle must be a valid handle previously set by a call to findRenderPass or 73 // The CompatibleRPHandle must be a valid handle previously set by a call to findRenderPass or
73 // findCompatibleRenderPass. 74 // findCompatibleRenderPass.
74 const GrVkRenderPass* findRenderPass(const CompatibleRPHandle& compatibleHan dle, 75 const GrVkRenderPass* findRenderPass(const CompatibleRPHandle& compatibleHan dle,
75 const GrVkRenderPass::LoadStoreOps& col orOps, 76 const GrVkRenderPass::LoadStoreOps& col orOps,
76 const GrVkRenderPass::LoadStoreOps& res olveOps, 77 const GrVkRenderPass::LoadStoreOps& res olveOps,
77 const GrVkRenderPass::LoadStoreOps& ste ncilOps); 78 const GrVkRenderPass::LoadStoreOps& ste ncilOps);
78 79
80 GrVkPrimaryCommandBuffer* findOrCreatePrimaryCommandBuffer();
81 void checkCommandBuffers();
79 82
80 GrVkPrimaryCommandBuffer* createPrimaryCommandBuffer(); 83 GrVkSecondaryCommandBuffer* findOrCreateSecondaryCommandBuffer();
81 void checkCommandBuffers(); 84 void recycleSecondaryCommandBuffer(GrVkSecondaryCommandBuffer* cb);
82 85
83 // Finds or creates a compatible GrVkDescriptorPool for the requested type a nd count. 86 // Finds or creates a compatible GrVkDescriptorPool for the requested type a nd count.
84 // The refcount is incremented and a pointer returned. 87 // The refcount is incremented and a pointer returned.
85 // TODO: Currently this will just create a descriptor pool without holding o nto a ref itself 88 // TODO: Currently this will just create a descriptor pool without holding o nto a ref itself
86 // so we currently do not reuse them. Rquires knowing if another draw is currently using 89 // so we currently do not reuse them. Rquires knowing if another draw is currently using
87 // the GrVkDescriptorPool, the ability to reset pools, and the ability to purge pools out 90 // the GrVkDescriptorPool, the ability to reset pools, and the ability to purge pools out
88 // of our cache of GrVkDescriptorPools. 91 // of our cache of GrVkDescriptorPools.
89 GrVkDescriptorPool* findOrCreateCompatibleDescriptorPool(VkDescriptorType ty pe, uint32_t count); 92 GrVkDescriptorPool* findOrCreateCompatibleDescriptorPool(VkDescriptorType ty pe, uint32_t count);
90 93
91 // Finds or creates a compatible GrVkSampler based on the GrTextureParams. 94 // Finds or creates a compatible GrVkSampler based on the GrTextureParams.
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 // Initialiaze the vkDescriptorSetLayout used for allocating new uniform buf fer descritpor sets. 196 // Initialiaze the vkDescriptorSetLayout used for allocating new uniform buf fer descritpor sets.
194 void initUniformDescObjects(); 197 void initUniformDescObjects();
195 198
196 GrVkGpu* fGpu; 199 GrVkGpu* fGpu;
197 200
198 // Central cache for creating pipelines 201 // Central cache for creating pipelines
199 VkPipelineCache fPipelineCache; 202 VkPipelineCache fPipelineCache;
200 203
201 SkSTArray<4, CompatibleRenderPassSet> fRenderPassArray; 204 SkSTArray<4, CompatibleRenderPassSet> fRenderPassArray;
202 205
203 // Array of CommandBuffers that are currently in flight 206 // Array of PrimaryCommandBuffers that are currently in flight
204 SkSTArray<4, GrVkPrimaryCommandBuffer*> fActiveCommandBuffers; 207 SkSTArray<4, GrVkPrimaryCommandBuffer*> fActiveCommandBuffers;
208 // Array of available primary command buffers that are not in flight
209 SkSTArray<4, GrVkPrimaryCommandBuffer*> fAvailableCommandBuffers;
210
211 // Array of available secondary command buffers
212 SkSTArray<16, GrVkSecondaryCommandBuffer*> fAvailableSecondaryCommandBuffers ;
205 213
206 // Stores GrVkSampler objects that we've already created so we can reuse the m across multiple 214 // Stores GrVkSampler objects that we've already created so we can reuse the m across multiple
207 // GrVkPipelineStates 215 // GrVkPipelineStates
208 SkTDynamicHash<GrVkSampler, uint16_t> fSamplers; 216 SkTDynamicHash<GrVkSampler, uint16_t> fSamplers;
209 217
210 // Cache of GrVkPipelineStates 218 // Cache of GrVkPipelineStates
211 PipelineStateCache* fPipelineStateCache; 219 PipelineStateCache* fPipelineStateCache;
212 220
213 // Current pool to allocate uniform descriptor sets from 221 // Current pool to allocate uniform descriptor sets from
214 const GrVkDescriptorPool* fUniformDescPool; 222 const GrVkDescriptorPool* fUniformDescPool;
215 VkDescriptorSetLayout fUniformDescLayout; 223 VkDescriptorSetLayout fUniformDescLayout;
216 //Curent number of uniform descriptors allocated from the pool 224 //Curent number of uniform descriptors allocated from the pool
217 int fCurrentUniformDescCount; 225 int fCurrentUniformDescCount;
218 int fCurrMaxUniDescriptors; 226 int fCurrMaxUniDescriptors;
219 227
220 enum { 228 enum {
221 kMaxUniformDescriptors = 1024, 229 kMaxUniformDescriptors = 1024,
222 kNumUniformDescPerSet = 2, 230 kNumUniformDescPerSet = 2,
223 kStartNumUniformDescriptors = 16, // must be less than kMaxUniformDescri ptors 231 kStartNumUniformDescriptors = 16, // must be less than kMaxUniformDescri ptors
224 }; 232 };
225 }; 233 };
226 234
227 #endif 235 #endif
OLDNEW
« no previous file with comments | « src/gpu/vk/GrVkResource.h ('k') | src/gpu/vk/GrVkResourceProvider.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698