| OLD | NEW |
| 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" | |
| 13 | 12 |
| 14 GrVkProgram* GrVkProgramBuilder::CreateProgram(GrVkGpu* gpu, | 13 GrVkProgram* GrVkProgramBuilder::CreateProgram(GrVkGpu* gpu, |
| 15 const GrPipeline& pipeline, | 14 const GrPipeline& pipeline, |
| 16 const GrPrimitiveProcessor& primP
roc, | 15 const GrPrimitiveProcessor& primP
roc, |
| 17 GrPrimitiveType primitiveType, | 16 GrPrimitiveType primitiveType, |
| 18 const GrVkProgramDesc& desc, | 17 const GrVkProgram::PipelineDesc&
desc, |
| 19 const GrVkRenderPass& renderPass)
{ | 18 const GrVkRenderPass& renderPass)
{ |
| 20 // create a builder. This will be handed off to effects so they can use it
to add | 19 // create a builder. This will be handed off to effects so they can use it
to add |
| 21 // uniforms, varyings, textures, etc | 20 // uniforms, varyings, textures, etc |
| 22 GrVkProgramBuilder builder(gpu, pipeline, primProc, desc); | 21 GrVkProgramBuilder builder(gpu, pipeline, primProc, desc.fProgramDesc); |
| 23 | 22 |
| 24 GrGLSLExpr4 inputColor; | 23 GrGLSLExpr4 inputColor; |
| 25 GrGLSLExpr4 inputCoverage; | 24 GrGLSLExpr4 inputCoverage; |
| 26 | 25 |
| 27 if (!builder.emitAndInstallProcs(&inputColor, &inputCoverage)) { | 26 if (!builder.emitAndInstallProcs(&inputColor, &inputCoverage)) { |
| 28 builder.cleanupFragmentProcessors(); | 27 builder.cleanupFragmentProcessors(); |
| 29 return nullptr; | 28 return nullptr; |
| 30 } | 29 } |
| 31 | 30 |
| 32 return builder.finalize(primitiveType, renderPass); | 31 return builder.finalize(primitiveType, renderPass, desc); |
| 33 } | 32 } |
| 34 | 33 |
| 35 GrVkProgramBuilder::GrVkProgramBuilder(GrVkGpu* gpu, | 34 GrVkProgramBuilder::GrVkProgramBuilder(GrVkGpu* gpu, |
| 36 const GrPipeline& pipeline, | 35 const GrPipeline& pipeline, |
| 37 const GrPrimitiveProcessor& primProc, | 36 const GrPrimitiveProcessor& primProc, |
| 38 const GrVkProgramDesc& desc) | 37 const GrVkProgramDesc& desc) |
| 39 : INHERITED(pipeline, primProc, desc) | 38 : INHERITED(pipeline, primProc, desc) |
| 40 , fGpu(gpu) | 39 , fGpu(gpu) |
| 41 , fVaryingHandler(this) | 40 , fVaryingHandler(this) |
| 42 , fUniformHandler(this) { | 41 , fUniformHandler(this) { |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 stageInfo->flags = 0; | 133 stageInfo->flags = 0; |
| 135 stageInfo->stage = stage; | 134 stageInfo->stage = stage; |
| 136 stageInfo->module = *shaderModule; | 135 stageInfo->module = *shaderModule; |
| 137 stageInfo->pName = "main"; | 136 stageInfo->pName = "main"; |
| 138 stageInfo->pSpecializationInfo = nullptr; | 137 stageInfo->pSpecializationInfo = nullptr; |
| 139 | 138 |
| 140 return true; | 139 return true; |
| 141 } | 140 } |
| 142 | 141 |
| 143 GrVkProgram* GrVkProgramBuilder::finalize(GrPrimitiveType primitiveType, | 142 GrVkProgram* GrVkProgramBuilder::finalize(GrPrimitiveType primitiveType, |
| 144 const GrVkRenderPass& renderPass) { | 143 const GrVkRenderPass& renderPass, |
| 144 const GrVkProgram::PipelineDesc& desc)
{ |
| 145 VkDescriptorSetLayout dsLayout[2]; | 145 VkDescriptorSetLayout dsLayout[2]; |
| 146 VkPipelineLayout pipelineLayout; | 146 VkPipelineLayout pipelineLayout; |
| 147 VkShaderModule vertShaderModule; | 147 VkShaderModule vertShaderModule; |
| 148 VkShaderModule fragShaderModule; | 148 VkShaderModule fragShaderModule; |
| 149 | 149 |
| 150 uint32_t numSamplers = fSamplerUniforms.count(); | 150 uint32_t numSamplers = fSamplerUniforms.count(); |
| 151 | 151 |
| 152 SkAutoTDeleteArray<VkDescriptorSetLayoutBinding> dsSamplerBindings( | 152 SkAutoTDeleteArray<VkDescriptorSetLayoutBinding> dsSamplerBindings( |
| 153 new VkDescriptorSetLayoutBi
nding[numSamplers]); | 153 new VkDescriptorSetLayoutBi
nding[numSamplers]); |
| 154 for (uint32_t i = 0; i < numSamplers; ++i) { | 154 for (uint32_t i = 0; i < numSamplers; ++i) { |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 GR_VK_CALL(fGpu->vkInterface(), DestroyPipelineLayout(fGpu->device(), pi
pelineLayout, | 266 GR_VK_CALL(fGpu->vkInterface(), DestroyPipelineLayout(fGpu->device(), pi
pelineLayout, |
| 267 nullptr)); | 267 nullptr)); |
| 268 GR_VK_CALL(fGpu->vkInterface(), DestroyDescriptorSetLayout(fGpu->device(
), dsLayout[0], | 268 GR_VK_CALL(fGpu->vkInterface(), DestroyDescriptorSetLayout(fGpu->device(
), dsLayout[0], |
| 269 nullptr)); | 269 nullptr)); |
| 270 GR_VK_CALL(fGpu->vkInterface(), DestroyDescriptorSetLayout(fGpu->device(
), dsLayout[1], | 270 GR_VK_CALL(fGpu->vkInterface(), DestroyDescriptorSetLayout(fGpu->device(
), dsLayout[1], |
| 271 nullptr)); | 271 nullptr)); |
| 272 return nullptr; | 272 return nullptr; |
| 273 } | 273 } |
| 274 | 274 |
| 275 return new GrVkProgram(fGpu, | 275 return new GrVkProgram(fGpu, |
| 276 desc, |
| 276 pipeline, | 277 pipeline, |
| 277 pipelineLayout, | 278 pipelineLayout, |
| 278 dsLayout, | 279 dsLayout, |
| 279 fUniformHandles, | 280 fUniformHandles, |
| 280 fUniformHandler.fUniforms, | 281 fUniformHandler.fUniforms, |
| 281 fUniformHandler.fCurrentVertexUBOOffset, | 282 fUniformHandler.fCurrentVertexUBOOffset, |
| 282 fUniformHandler.fCurrentFragmentUBOOffset, | 283 fUniformHandler.fCurrentFragmentUBOOffset, |
| 283 numSamplers, | 284 numSamplers, |
| 284 fGeometryProcessor, | 285 fGeometryProcessor, |
| 285 fXferProcessor, | 286 fXferProcessor, |
| 286 fFragmentProcessors); | 287 fFragmentProcessors); |
| 287 } | 288 } |
| OLD | NEW |