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

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

Issue 2163673002: Setup system in Vulkan to reuse VkDescriptorSet allocations. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: nit 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 "GrVkDescriptorSetManager.h"
14 #include "GrVkPipelineState.h" 15 #include "GrVkPipelineState.h"
15 #include "GrVkRenderPass.h" 16 #include "GrVkRenderPass.h"
16 #include "GrVkResource.h" 17 #include "GrVkResource.h"
17 #include "GrVkUtil.h" 18 #include "GrVkUtil.h"
18 #include "SkTArray.h" 19 #include "SkTArray.h"
19 #include "SkTDynamicHash.h" 20 #include "SkTDynamicHash.h"
20 #include "SkTHash.h" 21 #include "SkTHash.h"
21 #include "SkTInternalLList.h" 22 #include "SkTInternalLList.h"
22 23
23 #include "vk/GrVkDefines.h" 24 #include "vk/GrVkDefines.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 94
94 // Finds or creates a compatible GrVkSampler based on the GrTextureParams. 95 // Finds or creates a compatible GrVkSampler based on the GrTextureParams.
95 // The refcount is incremented and a pointer returned. 96 // The refcount is incremented and a pointer returned.
96 GrVkSampler* findOrCreateCompatibleSampler(const GrTextureParams&, uint32_t mipLevels); 97 GrVkSampler* findOrCreateCompatibleSampler(const GrTextureParams&, uint32_t mipLevels);
97 98
98 sk_sp<GrVkPipelineState> findOrCreateCompatiblePipelineState(const GrPipelin e&, 99 sk_sp<GrVkPipelineState> findOrCreateCompatiblePipelineState(const GrPipelin e&,
99 const GrPrimiti veProcessor&, 100 const GrPrimiti veProcessor&,
100 GrPrimitiveType , 101 GrPrimitiveType ,
101 const GrVkRende rPass& renderPass); 102 const GrVkRende rPass& renderPass);
102 103
103 // For all our GrVkPipelineState objects, we require a layout where the firs t set contains two 104 // Returns a handle which the GrVkResourceProvider uses to know which compat ible
104 // uniform buffers, one for the vertex shader and one for the fragment shade r. Thus it is 105 // GrVkDescriptorSetManager to use when getting or recycling a GrVkDescripto rSet. Passing in a
105 // possible for us to use a shadered descriptor pool to allocate all these s imilar descriptor 106 // value of 0 for numSamplers is used to signal this is for the uniform desc riptor set.
106 // sets. The caller is responsible for reffing the outPool for as long as th e returned 107 void getDescSetHandle(uint32_t numSamplers, VkDescriptorSetLayout layout,
107 // VkDescriptor set is in use. 108 GrVkDescriptorSetManager::Handle* handle);
108 void getUniformDescriptorSet(VkDescriptorSet*, const GrVkDescriptorPool** ou tPool); 109
110 // Returns a GrVkDescriptorSet that can be used for uniform buffers. The GrV kDescriptorSet
111 // is already reffed for the caller.
112 const GrVkDescriptorSet* getUniformDescriptorSet();
113
114 // Returns a GrVkDescriptorSet that can be used for sampler descriptors that are compatible with
115 // the GrVkDescriptorSetManager::Handle passed int.. The GrVkDescriptorSet i s already reffed for
116 // the caller.
117 // TODO: Move samplers in GrVkPipelineState to use the GrVkResourceProvider to allocate
118 // descriptor sets from.
119 const GrVkDescriptorSet* getSamplerDescriptorSet(const GrVkDescriptorSetMana ger::Handle&);
109 120
110 // Returns the compatible VkDescriptorSetLayout to use for uniform buffers. The caller does not 121 // Returns the compatible VkDescriptorSetLayout to use for uniform buffers. The caller does not
111 // own the VkDescriptorSetLayout and thus should not delete it. This functio n should be used 122 // own the VkDescriptorSetLayout and thus should not delete it. This functio n should be used
112 // when the caller needs the layout to create a VkPipelineLayout. 123 // when the caller needs the layout to create a VkPipelineLayout.
113 VkDescriptorSetLayout getUniDSLayout() const { return fUniformDescLayout; } 124 VkDescriptorSetLayout getUniDSLayout() const { return fUniformDescLayout; }
114 125
126 // Signals that the descriptor set passed it, which is compatible with the p assed in handle,
127 // can be reused by the next allocation request.
128 void recycleDescriptorSet(const GrVkDescriptorSet* descSet,
129 const GrVkDescriptorSetManager::Handle&);
130
115 // Destroy any cached resources. To be called before destroying the VkDevice . 131 // Destroy any cached resources. To be called before destroying the VkDevice .
116 // The assumption is that all queues are idle and all command buffers are fi nished. 132 // The assumption is that all queues are idle and all command buffers are fi nished.
117 // For resource tracing to work properly, this should be called after unrefi ng all other 133 // For resource tracing to work properly, this should be called after unrefi ng all other
118 // resource usages. 134 // resource usages.
119 void destroyResources(); 135 void destroyResources();
120 136
121 // Abandon any cached resources. To be used when the context/VkDevice is los t. 137 // Abandon any cached resources. To be used when the context/VkDevice is los t.
122 // For resource tracing to work properly, this should be called after unrefi ng all other 138 // For resource tracing to work properly, this should be called after unrefi ng all other
123 // resource usages. 139 // resource usages.
124 void abandonResources(); 140 void abandonResources();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 SkTInternalLList<Entry> fLRUList; 172 SkTInternalLList<Entry> fLRUList;
157 173
158 GrVkGpu* fGpu; 174 GrVkGpu* fGpu;
159 175
160 #ifdef GR_PIPELINE_STATE_CACHE_STATS 176 #ifdef GR_PIPELINE_STATE_CACHE_STATS
161 int fTotalRequests; 177 int fTotalRequests;
162 int fCacheMisses; 178 int fCacheMisses;
163 #endif 179 #endif
164 }; 180 };
165 181
166
167 class CompatibleRenderPassSet { 182 class CompatibleRenderPassSet {
168 public: 183 public:
169 // This will always construct the basic load store render pass (all atta chments load and 184 // This will always construct the basic load store render pass (all atta chments load and
170 // store their data) so that there is at least one compatible VkRenderPa ss that can be used 185 // store their data) so that there is at least one compatible VkRenderPa ss that can be used
171 // with this set. 186 // with this set.
172 CompatibleRenderPassSet(const GrVkGpu* gpu, const GrVkRenderTarget& targ et); 187 CompatibleRenderPassSet(const GrVkGpu* gpu, const GrVkRenderTarget& targ et);
173 188
174 bool isCompatible(const GrVkRenderTarget& target) const; 189 bool isCompatible(const GrVkRenderTarget& target) const;
175 190
176 GrVkRenderPass* getCompatibleRenderPass() const { 191 GrVkRenderPass* getCompatibleRenderPass() const {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 // Array of available secondary command buffers 226 // Array of available secondary command buffers
212 SkSTArray<16, GrVkSecondaryCommandBuffer*> fAvailableSecondaryCommandBuffers ; 227 SkSTArray<16, GrVkSecondaryCommandBuffer*> fAvailableSecondaryCommandBuffers ;
213 228
214 // Stores GrVkSampler objects that we've already created so we can reuse the m across multiple 229 // Stores GrVkSampler objects that we've already created so we can reuse the m across multiple
215 // GrVkPipelineStates 230 // GrVkPipelineStates
216 SkTDynamicHash<GrVkSampler, uint16_t> fSamplers; 231 SkTDynamicHash<GrVkSampler, uint16_t> fSamplers;
217 232
218 // Cache of GrVkPipelineStates 233 // Cache of GrVkPipelineStates
219 PipelineStateCache* fPipelineStateCache; 234 PipelineStateCache* fPipelineStateCache;
220 235
236 SkSTArray<4, GrVkDescriptorSetManager> fDescriptorSetManagers;
237
238 GrVkDescriptorSetManager::Handle fUniformDSHandle;
239
221 // Current pool to allocate uniform descriptor sets from 240 // Current pool to allocate uniform descriptor sets from
222 const GrVkDescriptorPool* fUniformDescPool;
223 VkDescriptorSetLayout fUniformDescLayout; 241 VkDescriptorSetLayout fUniformDescLayout;
224 //Curent number of uniform descriptors allocated from the pool 242 //Curent number of uniform descriptors allocated from the pool
225 int fCurrentUniformDescCount; 243 int fCurrentUniformDescCount;
226 int fCurrMaxUniDescriptors; 244 int fCurrMaxUniDescriptors;
227 245
228 enum { 246 enum {
229 kMaxUniformDescriptors = 1024, 247 kMaxUniformDescriptors = 1024,
230 kNumUniformDescPerSet = 2, 248 kNumUniformDescPerSet = 2,
231 kStartNumUniformDescriptors = 16, // must be less than kMaxUniformDescri ptors 249 kStartNumUniformDescriptors = 16, // must be less than kMaxUniformDescri ptors
232 }; 250 };
233 }; 251 };
234 252
235 #endif 253 #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