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

Side by Side Diff: src/gpu/vk/GrVkProgramBuilder.cpp

Issue 1806983002: Update how we send draws to gpu backend to reduce state setting. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: nit 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/GrVkProgramBuilder.h ('k') | no next file » | 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 #include "vk/GrVkProgramBuilder.h" 8 #include "vk/GrVkProgramBuilder.h"
9 9
10 #include "vk/GrVkGpu.h" 10 #include "vk/GrVkGpu.h"
11 #include "vk/GrVkRenderPass.h" 11 #include "vk/GrVkRenderPass.h"
12 #include "vk/GrVkProgram.h" 12 #include "vk/GrVkProgram.h"
13 13
14 GrVkProgram* GrVkProgramBuilder::CreateProgram(GrVkGpu* gpu, 14 GrVkProgram* GrVkProgramBuilder::CreateProgram(GrVkGpu* gpu,
15 const DrawArgs& args, 15 const GrPipeline& pipeline,
16 const GrPrimitiveProcessor& primP roc,
16 GrPrimitiveType primitiveType, 17 GrPrimitiveType primitiveType,
18 const GrVkProgramDesc& desc,
17 const GrVkRenderPass& renderPass) { 19 const GrVkRenderPass& renderPass) {
18 // create a builder. This will be handed off to effects so they can use it to add 20 // create a builder. This will be handed off to effects so they can use it to add
19 // uniforms, varyings, textures, etc 21 // uniforms, varyings, textures, etc
20 GrVkProgramBuilder builder(gpu, args); 22 GrVkProgramBuilder builder(gpu, pipeline, primProc, desc);
21 23
22 GrGLSLExpr4 inputColor; 24 GrGLSLExpr4 inputColor;
23 GrGLSLExpr4 inputCoverage; 25 GrGLSLExpr4 inputCoverage;
24 26
25 if (!builder.emitAndInstallProcs(&inputColor, &inputCoverage)) { 27 if (!builder.emitAndInstallProcs(&inputColor, &inputCoverage)) {
26 builder.cleanupFragmentProcessors(); 28 builder.cleanupFragmentProcessors();
27 return nullptr; 29 return nullptr;
28 } 30 }
29 31
30 return builder.finalize(args, primitiveType, renderPass); 32 return builder.finalize(primitiveType, renderPass);
31 } 33 }
32 34
33 GrVkProgramBuilder::GrVkProgramBuilder(GrVkGpu* gpu, const DrawArgs& args) 35 GrVkProgramBuilder::GrVkProgramBuilder(GrVkGpu* gpu,
34 : INHERITED(args) 36 const GrPipeline& pipeline,
37 const GrPrimitiveProcessor& primProc,
38 const GrVkProgramDesc& desc)
39 : INHERITED(pipeline, primProc, desc)
35 , fGpu(gpu) 40 , fGpu(gpu)
36 , fVaryingHandler(this) 41 , fVaryingHandler(this)
37 , fUniformHandler(this) { 42 , fUniformHandler(this) {
38 } 43 }
39 44
40 const GrCaps* GrVkProgramBuilder::caps() const { 45 const GrCaps* GrVkProgramBuilder::caps() const {
41 return fGpu->caps(); 46 return fGpu->caps();
42 } 47 }
43 const GrGLSLCaps* GrVkProgramBuilder::glslCaps() const { 48 const GrGLSLCaps* GrVkProgramBuilder::glslCaps() const {
44 return fGpu->vkCaps().glslCaps(); 49 return fGpu->vkCaps().glslCaps();
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 stageInfo->pNext = nullptr; 133 stageInfo->pNext = nullptr;
129 stageInfo->flags = 0; 134 stageInfo->flags = 0;
130 stageInfo->stage = stage; 135 stageInfo->stage = stage;
131 stageInfo->module = *shaderModule; 136 stageInfo->module = *shaderModule;
132 stageInfo->pName = "main"; 137 stageInfo->pName = "main";
133 stageInfo->pSpecializationInfo = nullptr; 138 stageInfo->pSpecializationInfo = nullptr;
134 139
135 return true; 140 return true;
136 } 141 }
137 142
138 GrVkProgram* GrVkProgramBuilder::finalize(const DrawArgs& args, 143 GrVkProgram* GrVkProgramBuilder::finalize(GrPrimitiveType primitiveType,
139 GrPrimitiveType primitiveType,
140 const GrVkRenderPass& renderPass) { 144 const GrVkRenderPass& renderPass) {
141 VkDescriptorSetLayout dsLayout[2]; 145 VkDescriptorSetLayout dsLayout[2];
142 VkPipelineLayout pipelineLayout; 146 VkPipelineLayout pipelineLayout;
143 VkShaderModule vertShaderModule; 147 VkShaderModule vertShaderModule;
144 VkShaderModule fragShaderModule; 148 VkShaderModule fragShaderModule;
145 149
146 uint32_t numSamplers = fSamplerUniforms.count(); 150 uint32_t numSamplers = fSamplerUniforms.count();
147 151
148 SkAutoTDeleteArray<VkDescriptorSetLayoutBinding> dsSamplerBindings( 152 SkAutoTDeleteArray<VkDescriptorSetLayoutBinding> dsSamplerBindings(
149 new VkDescriptorSetLayoutBi nding[numSamplers]); 153 new VkDescriptorSetLayoutBi nding[numSamplers]);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 &vertShaderModule, 243 &vertShaderModule,
240 &shaderStageInfo[0])); 244 &shaderStageInfo[0]));
241 245
242 SkAssertResult(CreateVkShaderModule(fGpu, 246 SkAssertResult(CreateVkShaderModule(fGpu,
243 VK_SHADER_STAGE_FRAGMENT_BIT, 247 VK_SHADER_STAGE_FRAGMENT_BIT,
244 fFS, 248 fFS,
245 &fragShaderModule, 249 &fragShaderModule,
246 &shaderStageInfo[1])); 250 &shaderStageInfo[1]));
247 251
248 GrVkResourceProvider& resourceProvider = fGpu->resourceProvider(); 252 GrVkResourceProvider& resourceProvider = fGpu->resourceProvider();
249 GrVkPipeline* pipeline = resourceProvider.createPipeline(*args.fPipeline, 253 GrVkPipeline* pipeline = resourceProvider.createPipeline(fPipeline,
250 *args.fPrimitivePro cessor, 254 fPrimProc,
251 shaderStageInfo, 255 shaderStageInfo,
252 2, 256 2,
253 primitiveType, 257 primitiveType,
254 renderPass, 258 renderPass,
255 pipelineLayout); 259 pipelineLayout);
256 GR_VK_CALL(fGpu->vkInterface(), DestroyShaderModule(fGpu->device(), vertShad erModule, 260 GR_VK_CALL(fGpu->vkInterface(), DestroyShaderModule(fGpu->device(), vertShad erModule,
257 nullptr)); 261 nullptr));
258 GR_VK_CALL(fGpu->vkInterface(), DestroyShaderModule(fGpu->device(), fragShad erModule, 262 GR_VK_CALL(fGpu->vkInterface(), DestroyShaderModule(fGpu->device(), fragShad erModule,
259 nullptr)); 263 nullptr));
260 264
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 descriptorSets, 301 descriptorSets,
298 fUniformHandles, 302 fUniformHandles,
299 fUniformHandler.fUniforms, 303 fUniformHandler.fUniforms,
300 fUniformHandler.fCurrentVertexUBOOffset, 304 fUniformHandler.fCurrentVertexUBOOffset,
301 fUniformHandler.fCurrentFragmentUBOOffset, 305 fUniformHandler.fCurrentFragmentUBOOffset,
302 numSamplers, 306 numSamplers,
303 fGeometryProcessor, 307 fGeometryProcessor,
304 fXferProcessor, 308 fXferProcessor,
305 fFragmentProcessors); 309 fFragmentProcessors);
306 } 310 }
OLDNEW
« no previous file with comments | « src/gpu/vk/GrVkProgramBuilder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698