Chromium Code Reviews| Index: src/gpu/vk/GrVkProgram.h |
| diff --git a/src/gpu/vk/GrVkProgram.h b/src/gpu/vk/GrVkProgram.h |
| index 9b4eeb1e93089ad8c0e2007a6b03e85f3f1df0da..c6f244366770137acb8c48b1d0fbda51063db7bc 100644 |
| --- a/src/gpu/vk/GrVkProgram.h |
| +++ b/src/gpu/vk/GrVkProgram.h |
| @@ -55,8 +55,6 @@ private: |
| GrVkPipeline* pipeline, |
| VkPipelineLayout layout, |
| VkDescriptorSetLayout dsLayout[2], |
| - GrVkDescriptorPool* descriptorPool, |
| - VkDescriptorSet descriptorSets[2], |
| const BuiltinUniformHandles& builtinUniformHandles, |
| const UniformInfoArray& uniforms, |
| uint32_t vertexUniformSize, |
| @@ -66,6 +64,44 @@ private: |
| GrGLSLXferProcessor* xferProcessor, |
| const GrGLSLFragProcs& fragmentProcessors); |
| + // Each pool will manage one type of descriptor. Thus each descriptor set we use will all be of |
| + // one VkDescriptorType. |
| + struct DescriptorPoolManager { |
| + DescriptorPoolManager(VkDescriptorSetLayout layout, VkDescriptorType type, |
| + uint8_t descCount, GrVkGpu* gpu) |
| + : fDescLayout(layout) |
| + , fDescType(type) |
| + , fDescCount(descCount) |
| + , fMaxDescriptorSets(4) |
| + , fCurrentDescriptorSet(0) |
| + , fPool(nullptr) { |
| + if (fDescCount * fMaxDescriptorSets > 1 << 8) { |
|
jvanverth1
2016/03/07 19:04:11
Use a constant rather than 1 << 8? And why 256?
egdaniel
2016/03/07 20:02:25
The descriptorpool type count struct I made previo
|
| + fMaxDescriptorSets = 1; |
| + } |
| + this->getNewPool(gpu); |
| + } |
| + |
| + ~DescriptorPoolManager() { |
| + SkASSERT(!fDescLayout); |
| + SkASSERT(!fPool); |
| + } |
| + |
| + void getNewDescriptorSet(GrVkGpu* gpu, VkDescriptorSet* ds); |
| + |
| + void freeGPUResources(const GrVkGpu* gpu); |
| + void abandonGPUResources(); |
| + |
| + VkDescriptorSetLayout fDescLayout; |
| + VkDescriptorType fDescType; |
| + uint8_t fDescCount; |
| + uint8_t fMaxDescriptorSets; |
| + uint8_t fCurrentDescriptorSet; |
| + GrVkDescriptorPool* fPool; |
| + |
| + private: |
| + void getNewPool(GrVkGpu* gpu); |
| + }; |
| + |
| void writeUniformBuffers(const GrVkGpu* gpu); |
| void writeSamplers(GrVkGpu* gpu, const SkTArray<const GrTextureAccess*>& textureBindings); |
| @@ -110,28 +146,24 @@ private: |
| // Helper for setData() that sets the view matrix and loads the render target height uniform |
| void setRenderTargetState(const GrPipeline&); |
| -// GrVkGpu* fGpu; |
| - |
| // GrVkResources |
| - GrVkDescriptorPool* fDescriptorPool; |
| GrVkPipeline* fPipeline; |
| // Used for binding DescriptorSets to the command buffer but does not need to survive during |
| // command buffer execution. Thus this is not need to be a GrVkResource. |
| VkPipelineLayout fPipelineLayout; |
| - // The first set (index 0) will be used for samplers and the second set (index 1) will be |
| - // used for uniform buffers. |
| - // The DSLayouts only are needed for allocating the descriptor sets and must survive until after |
| - // descriptor sets have been updated. Thus the lifetime of the layouts will just be the life of |
| - //the GrVkProgram. |
| - VkDescriptorSetLayout fDSLayout[2]; |
| // The DescriptorSets need to survive until the gpu has finished all draws that use them. |
| // However, they will only be freed by the descriptor pool. Thus by simply keeping the |
| // descriptor pool alive through the draw, the descritor sets will also stay alive. Thus we do |
| - // not need a GrVkResource versions of VkDescriptorSet. |
| + // not need a GrVkResource versions of VkDescriptorSet. We hold on to these in the program since |
| + // we update the descriptor sets and bind them at separate times; |
| VkDescriptorSet fDescriptorSets[2]; |
| + // Meta data so we know which descriptor sets we are using and need to bind. |
| + int fStartDS; |
| + int fDSCount; |
| + |
| SkAutoTDelete<GrVkUniformBuffer> fVertexUniformBuffer; |
| SkAutoTDelete<GrVkUniformBuffer> fFragmentUniformBuffer; |
| @@ -151,6 +183,9 @@ private: |
| GrVkProgramDataManager fProgramDataManager; |
| + DescriptorPoolManager fSamplerPoolManager; |
| + DescriptorPoolManager fUniformPoolManager; |
| + |
| #ifdef SK_DEBUG |
| int fNumSamplers; |
| #endif |