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 |
(...skipping 23 matching lines...) Expand all Loading... |
34 virtual const GrCaps* caps() const = 0; | 34 virtual const GrCaps* caps() const = 0; |
35 virtual const GrGLSLCaps* glslCaps() const = 0; | 35 virtual const GrGLSLCaps* glslCaps() const = 0; |
36 | 36 |
37 const GrPrimitiveProcessor& primitiveProcessor() const { return fPrimProc; } | 37 const GrPrimitiveProcessor& primitiveProcessor() const { return fPrimProc; } |
38 const GrPipeline& pipeline() const { return fPipeline; } | 38 const GrPipeline& pipeline() const { return fPipeline; } |
39 const GrProgramDesc& desc() const { return fDesc; } | 39 const GrProgramDesc& desc() const { return fDesc; } |
40 const GrProgramDesc::KeyHeader& header() const { return fDesc.header(); } | 40 const GrProgramDesc::KeyHeader& header() const { return fDesc.header(); } |
41 | 41 |
42 void appendUniformDecls(GrShaderFlags visibility, SkString*) const; | 42 void appendUniformDecls(GrShaderFlags visibility, SkString*) const; |
43 | 43 |
| 44 typedef GrGLSLUniformHandler::SamplerHandle SamplerHandle; |
| 45 |
| 46 const GrGLSLSampler& getSampler(SamplerHandle handle) const; |
| 47 |
44 // Handles for program uniforms (other than per-effect uniforms) | 48 // Handles for program uniforms (other than per-effect uniforms) |
45 struct BuiltinUniformHandles { | 49 struct BuiltinUniformHandles { |
46 UniformHandle fRTAdjustmentUni; | 50 UniformHandle fRTAdjustmentUni; |
47 | 51 |
48 // We use the render target height to provide a y-down frag coord when s
pecifying | 52 // We use the render target height to provide a y-down frag coord when s
pecifying |
49 // origin_upper_left is not supported. | 53 // origin_upper_left is not supported. |
50 UniformHandle fRTHeightUni; | 54 UniformHandle fRTHeightUni; |
51 }; | 55 }; |
52 | 56 |
53 // Used to add a uniform in the vertex shader for transforming into normaliz
ed device space. | 57 // Used to add a uniform in the vertex shader for transforming into normaliz
ed device space. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 const GrProgramDesc&); | 101 const GrProgramDesc&); |
98 | 102 |
99 void addFeature(GrShaderFlags shaders, uint32_t featureBit, const char* exte
nsionName); | 103 void addFeature(GrShaderFlags shaders, uint32_t featureBit, const char* exte
nsionName); |
100 | 104 |
101 bool emitAndInstallProcs(GrGLSLExpr4* inputColor, GrGLSLExpr4* inputCoverage
); | 105 bool emitAndInstallProcs(GrGLSLExpr4* inputColor, GrGLSLExpr4* inputCoverage
); |
102 | 106 |
103 void cleanupFragmentProcessors(); | 107 void cleanupFragmentProcessors(); |
104 | 108 |
105 void finalizeShaders(); | 109 void finalizeShaders(); |
106 | 110 |
107 SkTArray<UniformHandle> fSamplerUniforms; | |
108 | |
109 private: | 111 private: |
110 // reset is called by program creator between each processor's emit code. I
t increments the | 112 // reset is called by program creator between each processor's emit code. I
t increments the |
111 // stage offset for variable name mangling, and also ensures verfication var
iables in the | 113 // stage offset for variable name mangling, and also ensures verfication var
iables in the |
112 // fragment shader are cleared. | 114 // fragment shader are cleared. |
113 void reset() { | 115 void reset() { |
114 this->addStage(); | 116 this->addStage(); |
115 SkDEBUGCODE(fFS.resetVerification();) | 117 SkDEBUGCODE(fFS.resetVerification();) |
116 } | 118 } |
117 void addStage() { fStageIndex++; } | 119 void addStage() { fStageIndex++; } |
118 | 120 |
(...skipping 20 matching lines...) Expand all Loading... |
139 void emitAndInstallFragProcs(int procOffset, int numProcs, GrGLSLExpr4* inOu
t); | 141 void emitAndInstallFragProcs(int procOffset, int numProcs, GrGLSLExpr4* inOu
t); |
140 void emitAndInstallFragProc(const GrFragmentProcessor&, | 142 void emitAndInstallFragProc(const GrFragmentProcessor&, |
141 int index, | 143 int index, |
142 const GrGLSLExpr4& input, | 144 const GrGLSLExpr4& input, |
143 GrGLSLExpr4* output); | 145 GrGLSLExpr4* output); |
144 void emitAndInstallXferProc(const GrXferProcessor&, | 146 void emitAndInstallXferProc(const GrXferProcessor&, |
145 const GrGLSLExpr4& colorIn, | 147 const GrGLSLExpr4& colorIn, |
146 const GrGLSLExpr4& coverageIn, | 148 const GrGLSLExpr4& coverageIn, |
147 bool ignoresCoverage, | 149 bool ignoresCoverage, |
148 GrPixelLocalStorageState plsState); | 150 GrPixelLocalStorageState plsState); |
| 151 |
149 void emitSamplers(const GrProcessor& processor, | 152 void emitSamplers(const GrProcessor& processor, |
150 GrGLSLSampler::SamplerArray* outTexSamplers, | 153 SkTArray<SamplerHandle>* outTexSamplers, |
151 GrGLSLSampler::SamplerArray* outBufferSamplers); | 154 SkTArray<SamplerHandle>* outBufferSamplers); |
152 void emitSampler(GrSLType samplerType, | 155 void emitSampler(GrSLType samplerType, |
153 GrPixelConfig, | 156 GrPixelConfig, |
154 const char* name, | 157 const char* name, |
155 GrShaderFlags visibility, | 158 GrShaderFlags visibility, |
156 GrGLSLSampler::SamplerArray* outSamplers); | 159 SkTArray<SamplerHandle>* outSamplers); |
157 void emitFSOutputSwizzle(bool hasSecondaryOutput); | 160 void emitFSOutputSwizzle(bool hasSecondaryOutput); |
158 bool checkSamplerCounts(); | 161 bool checkSamplerCounts(); |
159 | 162 |
160 #ifdef SK_DEBUG | 163 #ifdef SK_DEBUG |
161 void verify(const GrPrimitiveProcessor&); | 164 void verify(const GrPrimitiveProcessor&); |
162 void verify(const GrXferProcessor&); | 165 void verify(const GrXferProcessor&); |
163 void verify(const GrFragmentProcessor&); | 166 void verify(const GrFragmentProcessor&); |
164 #endif | 167 #endif |
165 | 168 |
166 GrGLSLPrimitiveProcessor::TransformsIn fCoordTransforms; | 169 GrGLSLPrimitiveProcessor::TransformsIn fCoordTransforms; |
167 GrGLSLPrimitiveProcessor::TransformsOut fOutCoords; | 170 GrGLSLPrimitiveProcessor::TransformsOut fOutCoords; |
168 int fNumVertexSamplers; | 171 int fNumVertexSamplers; |
169 int fNumGeometrySamplers; | 172 int fNumGeometrySamplers; |
170 int fNumFragmentSamplers; | 173 int fNumFragmentSamplers; |
171 }; | 174 }; |
172 | 175 |
173 #endif | 176 #endif |
OLD | NEW |