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

Unified Diff: src/gpu/vk/GrVkProgram.h

Issue 1765923002: Add DescriptorPool and set manager to GrVkProgram (Closed) Base URL: https://skia.googlesource.com/skia.git@samplerDesc
Patch Set: rebase Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/vk/GrVkDescriptorPool.cpp ('k') | src/gpu/vk/GrVkProgram.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/vk/GrVkProgram.h
diff --git a/src/gpu/vk/GrVkProgram.h b/src/gpu/vk/GrVkProgram.h
index 9b4eeb1e93089ad8c0e2007a6b03e85f3f1df0da..1a024f2f2a6da81c9cec0f1c82145a4314ad5225 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,40 @@ 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,
+ uint32_t descCount, GrVkGpu* gpu)
+ : fDescLayout(layout)
+ , fDescType(type)
+ , fCurrentDescriptorSet(0)
+ , fPool(nullptr) {
+ SkASSERT(descCount < (SK_MaxU32 >> 2));
+ fMaxDescriptorSets = descCount << 2;
+ 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;
+ uint32_t fMaxDescriptorSets;
+ uint32_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 +142,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 +179,9 @@ private:
GrVkProgramDataManager fProgramDataManager;
+ DescriptorPoolManager fSamplerPoolManager;
+ DescriptorPoolManager fUniformPoolManager;
+
#ifdef SK_DEBUG
int fNumSamplers;
#endif
« no previous file with comments | « src/gpu/vk/GrVkDescriptorPool.cpp ('k') | src/gpu/vk/GrVkProgram.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698