blob: 65fe54667c4908e2d30490a386d172e37a6ad4f0 [file] [log] [blame]
Greg Daniel164a9f02016-02-22 09:56:40 -05001/*
2* Copyright 2016 Google Inc.
3*
4* Use of this source code is governed by a BSD-style license that can be
5* found in the LICENSE file.
6*/
7
8#ifndef GrVkProgramBuilder_DEFINED
9#define GrVkProgramBuilder_DEFINED
10
11#include "glsl/GrGLSLProgramBuilder.h"
12
13#include "GrPipeline.h"
14#include "vk/GrVkUniformHandler.h"
15#include "vk/GrVkVaryingHandler.h"
16
17#include "shaderc/shaderc.h"
18#include "vulkan/vulkan.h"
19
20class GrVkGpu;
21class GrVkRenderPass;
22class GrVkProgram;
egdaniel0e1853c2016-03-17 11:35:45 -070023class GrVkProgramDesc;
Greg Daniel164a9f02016-02-22 09:56:40 -050024
25class GrVkProgramBuilder : public GrGLSLProgramBuilder {
26public:
27 /** Generates a shader program.
28 *
29 * The program implements what is specified in the stages given as input.
30 * After successful generation, the builder result objects are available
31 * to be used.
32 * @return true if generation was successful.
33 */
34 static GrVkProgram* CreateProgram(GrVkGpu*,
egdaniel0e1853c2016-03-17 11:35:45 -070035 const GrPipeline&,
36 const GrPrimitiveProcessor&,
Greg Daniel164a9f02016-02-22 09:56:40 -050037 GrPrimitiveType,
egdaniel0e1853c2016-03-17 11:35:45 -070038 const GrVkProgramDesc&,
Greg Daniel164a9f02016-02-22 09:56:40 -050039 const GrVkRenderPass& renderPass);
40
41 const GrCaps* caps() const override;
42 const GrGLSLCaps* glslCaps() const override;
43
44 GrVkGpu* gpu() const { return fGpu; }
45
46 void finalizeFragmentOutputColor(GrGLSLShaderVar& outputColor) override;
47
48private:
egdaniel0e1853c2016-03-17 11:35:45 -070049 GrVkProgramBuilder(GrVkGpu*,
50 const GrPipeline&,
51 const GrPrimitiveProcessor&,
52 const GrVkProgramDesc&);
Greg Daniel164a9f02016-02-22 09:56:40 -050053
egdaniel0e1853c2016-03-17 11:35:45 -070054 GrVkProgram* finalize(GrPrimitiveType primitiveType, const GrVkRenderPass& renderPass);
Greg Daniel164a9f02016-02-22 09:56:40 -050055
56 static bool CreateVkShaderModule(const GrVkGpu* gpu,
57 VkShaderStageFlagBits stage,
58 const GrGLSLShaderBuilder& builder,
59 VkShaderModule* shaderModule,
60 VkPipelineShaderStageCreateInfo* stageInfo);
61
62 GrGLSLUniformHandler* uniformHandler() override { return &fUniformHandler; }
63 const GrGLSLUniformHandler* uniformHandler() const override { return &fUniformHandler; }
64 GrGLSLVaryingHandler* varyingHandler() override { return &fVaryingHandler; }
65
66 GrVkGpu* fGpu;
67 GrVkVaryingHandler fVaryingHandler;
68 GrVkUniformHandler fUniformHandler;
69
Greg Daniel164a9f02016-02-22 09:56:40 -050070 typedef GrGLSLProgramBuilder INHERITED;
71};
72
cdalton9c3f1432016-03-11 10:07:37 -080073#endif