Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 1 | /* |
| 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 | |
| 20 | class GrVkGpu; |
| 21 | class GrVkRenderPass; |
| 22 | class GrVkProgram; |
egdaniel | 0e1853c | 2016-03-17 11:35:45 -0700 | [diff] [blame] | 23 | class GrVkProgramDesc; |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 24 | |
| 25 | class GrVkProgramBuilder : public GrGLSLProgramBuilder { |
| 26 | public: |
| 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*, |
egdaniel | 0e1853c | 2016-03-17 11:35:45 -0700 | [diff] [blame] | 35 | const GrPipeline&, |
| 36 | const GrPrimitiveProcessor&, |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 37 | GrPrimitiveType, |
egdaniel | 0e1853c | 2016-03-17 11:35:45 -0700 | [diff] [blame] | 38 | const GrVkProgramDesc&, |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 39 | 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 | |
| 48 | private: |
egdaniel | 0e1853c | 2016-03-17 11:35:45 -0700 | [diff] [blame] | 49 | GrVkProgramBuilder(GrVkGpu*, |
| 50 | const GrPipeline&, |
| 51 | const GrPrimitiveProcessor&, |
| 52 | const GrVkProgramDesc&); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 53 | |
egdaniel | 0e1853c | 2016-03-17 11:35:45 -0700 | [diff] [blame] | 54 | GrVkProgram* finalize(GrPrimitiveType primitiveType, const GrVkRenderPass& renderPass); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 55 | |
| 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 Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 70 | typedef GrGLSLProgramBuilder INHERITED; |
| 71 | }; |
| 72 | |
cdalton | 9c3f143 | 2016-03-11 10:07:37 -0800 | [diff] [blame] | 73 | #endif |