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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/gpu/vk/GrVkDescriptorPool.cpp ('k') | src/gpu/vk/GrVkProgram.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 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 8
9 #ifndef GrVkProgram_DEFINED 9 #ifndef GrVkProgram_DEFINED
10 #define GrVkProgram_DEFINED 10 #define GrVkProgram_DEFINED
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 void abandonGPUResources(); 48 void abandonGPUResources();
49 49
50 private: 50 private:
51 typedef GrVkProgramDataManager::UniformInfoArray UniformInfoArray; 51 typedef GrVkProgramDataManager::UniformInfoArray UniformInfoArray;
52 typedef GrGLSLProgramDataManager::UniformHandle UniformHandle; 52 typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
53 53
54 GrVkProgram(GrVkGpu* gpu, 54 GrVkProgram(GrVkGpu* gpu,
55 GrVkPipeline* pipeline, 55 GrVkPipeline* pipeline,
56 VkPipelineLayout layout, 56 VkPipelineLayout layout,
57 VkDescriptorSetLayout dsLayout[2], 57 VkDescriptorSetLayout dsLayout[2],
58 GrVkDescriptorPool* descriptorPool,
59 VkDescriptorSet descriptorSets[2],
60 const BuiltinUniformHandles& builtinUniformHandles, 58 const BuiltinUniformHandles& builtinUniformHandles,
61 const UniformInfoArray& uniforms, 59 const UniformInfoArray& uniforms,
62 uint32_t vertexUniformSize, 60 uint32_t vertexUniformSize,
63 uint32_t fragmentUniformSize, 61 uint32_t fragmentUniformSize,
64 uint32_t numSamplers, 62 uint32_t numSamplers,
65 GrGLSLPrimitiveProcessor* geometryProcessor, 63 GrGLSLPrimitiveProcessor* geometryProcessor,
66 GrGLSLXferProcessor* xferProcessor, 64 GrGLSLXferProcessor* xferProcessor,
67 const GrGLSLFragProcs& fragmentProcessors); 65 const GrGLSLFragProcs& fragmentProcessors);
68 66
67 // Each pool will manage one type of descriptor. Thus each descriptor set we use will all be of
68 // one VkDescriptorType.
69 struct DescriptorPoolManager {
70 DescriptorPoolManager(VkDescriptorSetLayout layout, VkDescriptorType typ e,
71 uint32_t descCount, GrVkGpu* gpu)
72 : fDescLayout(layout)
73 , fDescType(type)
74 , fCurrentDescriptorSet(0)
75 , fPool(nullptr) {
76 SkASSERT(descCount < (SK_MaxU32 >> 2));
77 fMaxDescriptorSets = descCount << 2;
78 this->getNewPool(gpu);
79 }
80
81 ~DescriptorPoolManager() {
82 SkASSERT(!fDescLayout);
83 SkASSERT(!fPool);
84 }
85
86 void getNewDescriptorSet(GrVkGpu* gpu, VkDescriptorSet* ds);
87
88 void freeGPUResources(const GrVkGpu* gpu);
89 void abandonGPUResources();
90
91 VkDescriptorSetLayout fDescLayout;
92 VkDescriptorType fDescType;
93 uint32_t fMaxDescriptorSets;
94 uint32_t fCurrentDescriptorSet;
95 GrVkDescriptorPool* fPool;
96
97 private:
98 void getNewPool(GrVkGpu* gpu);
99 };
100
69 void writeUniformBuffers(const GrVkGpu* gpu); 101 void writeUniformBuffers(const GrVkGpu* gpu);
70 102
71 void writeSamplers(GrVkGpu* gpu, const SkTArray<const GrTextureAccess*>& tex tureBindings); 103 void writeSamplers(GrVkGpu* gpu, const SkTArray<const GrTextureAccess*>& tex tureBindings);
72 104
73 105
74 /** 106 /**
75 * We use the RT's size and origin to adjust from Skia device space to OpenGL normalized device 107 * We use the RT's size and origin to adjust from Skia device space to OpenGL normalized device
76 * space and to make device space positions have the correct origin for proce ssors that require 108 * space and to make device space positions have the correct origin for proce ssors that require
77 * them. 109 * them.
78 */ 110 */
(...skipping 24 matching lines...) Expand all
103 } else { 135 } else {
104 destVec[2] = 2.f / fRenderTargetSize.fHeight; 136 destVec[2] = 2.f / fRenderTargetSize.fHeight;
105 destVec[3] = -1.f; 137 destVec[3] = -1.f;
106 } 138 }
107 } 139 }
108 }; 140 };
109 141
110 // Helper for setData() that sets the view matrix and loads the render targe t height uniform 142 // Helper for setData() that sets the view matrix and loads the render targe t height uniform
111 void setRenderTargetState(const GrPipeline&); 143 void setRenderTargetState(const GrPipeline&);
112 144
113 // GrVkGpu* fGpu;
114
115 // GrVkResources 145 // GrVkResources
116 GrVkDescriptorPool* fDescriptorPool;
117 GrVkPipeline* fPipeline; 146 GrVkPipeline* fPipeline;
118 147
119 // Used for binding DescriptorSets to the command buffer but does not need t o survive during 148 // Used for binding DescriptorSets to the command buffer but does not need t o survive during
120 // command buffer execution. Thus this is not need to be a GrVkResource. 149 // command buffer execution. Thus this is not need to be a GrVkResource.
121 VkPipelineLayout fPipelineLayout; 150 VkPipelineLayout fPipelineLayout;
122 151
123 // The first set (index 0) will be used for samplers and the second set (ind ex 1) will be
124 // used for uniform buffers.
125 // The DSLayouts only are needed for allocating the descriptor sets and must survive until after
126 // descriptor sets have been updated. Thus the lifetime of the layouts will just be the life of
127 //the GrVkProgram.
128 VkDescriptorSetLayout fDSLayout[2];
129 // The DescriptorSets need to survive until the gpu has finished all draws t hat use them. 152 // The DescriptorSets need to survive until the gpu has finished all draws t hat use them.
130 // However, they will only be freed by the descriptor pool. Thus by simply k eeping the 153 // However, they will only be freed by the descriptor pool. Thus by simply k eeping the
131 // descriptor pool alive through the draw, the descritor sets will also stay alive. Thus we do 154 // descriptor pool alive through the draw, the descritor sets will also stay alive. Thus we do
132 // not need a GrVkResource versions of VkDescriptorSet. 155 // not need a GrVkResource versions of VkDescriptorSet. We hold on to these in the program since
156 // we update the descriptor sets and bind them at separate times;
133 VkDescriptorSet fDescriptorSets[2]; 157 VkDescriptorSet fDescriptorSets[2];
134 158
159 // Meta data so we know which descriptor sets we are using and need to bind.
160 int fStartDS;
161 int fDSCount;
162
135 SkAutoTDelete<GrVkUniformBuffer> fVertexUniformBuffer; 163 SkAutoTDelete<GrVkUniformBuffer> fVertexUniformBuffer;
136 SkAutoTDelete<GrVkUniformBuffer> fFragmentUniformBuffer; 164 SkAutoTDelete<GrVkUniformBuffer> fFragmentUniformBuffer;
137 165
138 // GrVkResources used for sampling textures 166 // GrVkResources used for sampling textures
139 SkTDArray<GrVkSampler*> fSamplers; 167 SkTDArray<GrVkSampler*> fSamplers;
140 SkTDArray<const GrVkImageView*> fTextureViews; 168 SkTDArray<const GrVkImageView*> fTextureViews;
141 SkTDArray<const GrVkImage::Resource*> fTextures; 169 SkTDArray<const GrVkImage::Resource*> fTextures;
142 170
143 // Tracks the current render target uniforms stored in the vertex buffer. 171 // Tracks the current render target uniforms stored in the vertex buffer.
144 RenderTargetState fRenderTargetState; 172 RenderTargetState fRenderTargetState;
145 BuiltinUniformHandles fBuiltinUniformHandles; 173 BuiltinUniformHandles fBuiltinUniformHandles;
146 174
147 // Processors in the program 175 // Processors in the program
148 SkAutoTDelete<GrGLSLPrimitiveProcessor> fGeometryProcessor; 176 SkAutoTDelete<GrGLSLPrimitiveProcessor> fGeometryProcessor;
149 SkAutoTDelete<GrGLSLXferProcessor> fXferProcessor; 177 SkAutoTDelete<GrGLSLXferProcessor> fXferProcessor;
150 GrGLSLFragProcs fFragmentProcessors; 178 GrGLSLFragProcs fFragmentProcessors;
151 179
152 GrVkProgramDataManager fProgramDataManager; 180 GrVkProgramDataManager fProgramDataManager;
153 181
182 DescriptorPoolManager fSamplerPoolManager;
183 DescriptorPoolManager fUniformPoolManager;
184
154 #ifdef SK_DEBUG 185 #ifdef SK_DEBUG
155 int fNumSamplers; 186 int fNumSamplers;
156 #endif 187 #endif
157 188
158 friend class GrVkProgramBuilder; 189 friend class GrVkProgramBuilder;
159 }; 190 };
160 191
161 #endif 192 #endif
OLDNEW
« 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