| OLD | NEW |
| 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 #ifndef GrGLSLProgramBuilder_DEFINED | 8 #ifndef GrGLSLProgramBuilder_DEFINED |
| 9 #define GrGLSLProgramBuilder_DEFINED | 9 #define GrGLSLProgramBuilder_DEFINED |
| 10 | 10 |
| 11 #include "GrGeometryProcessor.h" | 11 #include "GrGeometryProcessor.h" |
| 12 #include "GrGpu.h" | 12 #include "GrGpu.h" |
| 13 #include "glsl/GrGLSLFragmentShaderBuilder.h" | 13 #include "glsl/GrGLSLFragmentShaderBuilder.h" |
| 14 #include "glsl/GrGLSLGeometryShaderBuilder.h" | 14 #include "glsl/GrGLSLGeometryShaderBuilder.h" |
| 15 #include "glsl/GrGLSLPrimitiveProcessor.h" | 15 #include "glsl/GrGLSLPrimitiveProcessor.h" |
| 16 #include "glsl/GrGLSLProgramDataManager.h" | 16 #include "glsl/GrGLSLProgramDataManager.h" |
| 17 #include "glsl/GrGLSLUniformHandler.h" | 17 #include "glsl/GrGLSLUniformHandler.h" |
| 18 #include "glsl/GrGLSLTextureSampler.h" | 18 #include "glsl/GrGLSLTextureSampler.h" |
| 19 #include "glsl/GrGLSLVertexShaderBuilder.h" | 19 #include "glsl/GrGLSLVertexShaderBuilder.h" |
| 20 #include "glsl/GrGLSLXferProcessor.h" | 20 #include "glsl/GrGLSLXferProcessor.h" |
| 21 | 21 |
| 22 class GrGLSLCaps; | 22 class GrGLSLCaps; |
| 23 class GrGLSLShaderVar; | 23 class GrGLSLShaderVar; |
| 24 class GrGLSLVaryingHandler; | 24 class GrGLSLVaryingHandler; |
| 25 | 25 |
| 26 typedef SkSTArray<8, GrGLSLFragmentProcessor*, true> GrGLSLFragProcs; | 26 typedef SkSTArray<8, GrGLSLFragmentProcessor*, true> GrGLSLFragProcs; |
| 27 | 27 |
| 28 class GrGLSLProgramBuilder { | 28 class GrGLSLProgramBuilder { |
| 29 public: | 29 public: |
| 30 typedef GrGpu::DrawArgs DrawArgs; | |
| 31 typedef GrGLSLUniformHandler::UniformHandle UniformHandle; | 30 typedef GrGLSLUniformHandler::UniformHandle UniformHandle; |
| 32 | 31 |
| 33 virtual ~GrGLSLProgramBuilder() {} | 32 virtual ~GrGLSLProgramBuilder() {} |
| 34 | 33 |
| 35 virtual const GrCaps* caps() const = 0; | 34 virtual const GrCaps* caps() const = 0; |
| 36 virtual const GrGLSLCaps* glslCaps() const = 0; | 35 virtual const GrGLSLCaps* glslCaps() const = 0; |
| 37 | 36 |
| 38 const GrPrimitiveProcessor& primitiveProcessor() const { return *fArgs.fPrim
itiveProcessor; } | 37 const GrPrimitiveProcessor& primitiveProcessor() const { return fPrimProc; } |
| 39 const GrPipeline& pipeline() const { return *fArgs.fPipeline; } | 38 const GrPipeline& pipeline() const { return fPipeline; } |
| 40 const GrProgramDesc& desc() const { return *fArgs.fDesc; } | 39 const GrProgramDesc& desc() const { return fDesc; } |
| 41 const GrProgramDesc::KeyHeader& header() const { return fArgs.fDesc->header(
); } | 40 const GrProgramDesc::KeyHeader& header() const { return fDesc.header(); } |
| 42 | 41 |
| 43 void appendUniformDecls(GrShaderFlags visibility, SkString*) const; | 42 void appendUniformDecls(GrShaderFlags visibility, SkString*) const; |
| 44 | 43 |
| 45 // Handles for program uniforms (other than per-effect uniforms) | 44 // Handles for program uniforms (other than per-effect uniforms) |
| 46 struct BuiltinUniformHandles { | 45 struct BuiltinUniformHandles { |
| 47 UniformHandle fRTAdjustmentUni; | 46 UniformHandle fRTAdjustmentUni; |
| 48 | 47 |
| 49 // We use the render target height to provide a y-down frag coord when s
pecifying | 48 // We use the render target height to provide a y-down frag coord when s
pecifying |
| 50 // origin_upper_left is not supported. | 49 // origin_upper_left is not supported. |
| 51 UniformHandle fRTHeightUni; | 50 UniformHandle fRTHeightUni; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 75 | 74 |
| 76 // number of each input/output type in a single allocation block, used by ma
ny builders | 75 // number of each input/output type in a single allocation block, used by ma
ny builders |
| 77 static const int kVarsPerBlock; | 76 static const int kVarsPerBlock; |
| 78 | 77 |
| 79 GrGLSLVertexBuilder fVS; | 78 GrGLSLVertexBuilder fVS; |
| 80 GrGLSLGeometryBuilder fGS; | 79 GrGLSLGeometryBuilder fGS; |
| 81 GrGLSLFragmentShaderBuilder fFS; | 80 GrGLSLFragmentShaderBuilder fFS; |
| 82 | 81 |
| 83 int fStageIndex; | 82 int fStageIndex; |
| 84 | 83 |
| 85 const DrawArgs& fArgs; | 84 const GrPipeline& fPipeline; |
| 85 const GrPrimitiveProcessor& fPrimProc; |
| 86 const GrProgramDesc& fDesc; |
| 86 | 87 |
| 87 BuiltinUniformHandles fUniformHandles; | 88 BuiltinUniformHandles fUniformHandles; |
| 88 | 89 |
| 89 GrGLSLPrimitiveProcessor* fGeometryProcessor; | 90 GrGLSLPrimitiveProcessor* fGeometryProcessor; |
| 90 GrGLSLXferProcessor* fXferProcessor; | 91 GrGLSLXferProcessor* fXferProcessor; |
| 91 GrGLSLFragProcs fFragmentProcessors; | 92 GrGLSLFragProcs fFragmentProcessors; |
| 92 | 93 |
| 93 protected: | 94 protected: |
| 94 explicit GrGLSLProgramBuilder(const DrawArgs& args); | 95 explicit GrGLSLProgramBuilder(const GrPipeline&, |
| 96 const GrPrimitiveProcessor&, |
| 97 const GrProgramDesc&); |
| 95 | 98 |
| 96 void addFeature(GrShaderFlags shaders, uint32_t featureBit, const char* exte
nsionName); | 99 void addFeature(GrShaderFlags shaders, uint32_t featureBit, const char* exte
nsionName); |
| 97 | 100 |
| 98 bool emitAndInstallProcs(GrGLSLExpr4* inputColor, GrGLSLExpr4* inputCoverage
); | 101 bool emitAndInstallProcs(GrGLSLExpr4* inputColor, GrGLSLExpr4* inputCoverage
); |
| 99 | 102 |
| 100 void cleanupFragmentProcessors(); | 103 void cleanupFragmentProcessors(); |
| 101 | 104 |
| 102 void finalizeShaders(); | 105 void finalizeShaders(); |
| 103 | 106 |
| 104 SkTArray<UniformHandle> fSamplerUniforms; | 107 SkTArray<UniformHandle> fSamplerUniforms; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 #endif | 158 #endif |
| 156 | 159 |
| 157 GrGLSLPrimitiveProcessor::TransformsIn fCoordTransforms; | 160 GrGLSLPrimitiveProcessor::TransformsIn fCoordTransforms; |
| 158 GrGLSLPrimitiveProcessor::TransformsOut fOutCoords; | 161 GrGLSLPrimitiveProcessor::TransformsOut fOutCoords; |
| 159 int fNumVertexSamplers; | 162 int fNumVertexSamplers; |
| 160 int fNumGeometrySamplers; | 163 int fNumGeometrySamplers; |
| 161 int fNumFragmentSamplers; | 164 int fNumFragmentSamplers; |
| 162 }; | 165 }; |
| 163 | 166 |
| 164 #endif | 167 #endif |
| OLD | NEW |