 Chromium Code Reviews
 Chromium Code Reviews Issue 304383002:
  Make GrGLShaderBuilder store a GenProgramOutput  (Closed) 
  Base URL: https://skia.googlecode.com/svn/trunk
    
  
    Issue 304383002:
  Make GrGLShaderBuilder store a GenProgramOutput  (Closed) 
  Base URL: https://skia.googlecode.com/svn/trunk| Index: src/gpu/gl/GrGLShaderBuilder.h | 
| diff --git a/src/gpu/gl/GrGLShaderBuilder.h b/src/gpu/gl/GrGLShaderBuilder.h | 
| index bf166936e1435d534d8c8d7a1fcb256678def643..1f6c56c44a729e3d61cdc98a14907ab5434445fd 100644 | 
| --- a/src/gpu/gl/GrGLShaderBuilder.h | 
| +++ b/src/gpu/gl/GrGLShaderBuilder.h | 
| @@ -61,20 +61,27 @@ public: | 
| }; | 
| struct GenProgramOutput { | 
| + GenProgramOutput() | 
| + : fColorEffects(NULL) | 
| + , fCoverageEffects(NULL) | 
| + , fHasVertexShader(false) | 
| + , fTexCoordSetCnt(0) | 
| + , fProgramID(0) {} | 
| + | 
| GrGLProgramEffects* fColorEffects; | 
| GrGLProgramEffects* fCoverageEffects; | 
| - UniformHandles fUniformHandles; | 
| - bool fHasVS; | 
| - int fNumTexCoordSets; | 
| - GrGLuint fProgramID; | 
| + UniformHandles fUniformHandles; | 
| + bool fHasVertexShader; | 
| + int fTexCoordSetCnt; | 
| + GrGLuint fProgramID; | 
| }; | 
| static bool GenProgram(GrGpuGL* gpu, | 
| 
robertphillips
2014/05/29 21:12:25
Are we no longer aligning the parameters (here and
 
bsalomon
2014/05/29 21:15:11
Visual Studio 2013 is driving me bananas reformatt
 | 
| - GrGLUniformManager* uman, | 
| - const GrGLProgramDesc& desc, | 
| - const GrEffectStage* inColorStages[], | 
| - const GrEffectStage* inCoverageStages[], | 
| - GenProgramOutput* output); | 
| + GrGLUniformManager* uman, | 
| + const GrGLProgramDesc& desc, | 
| + const GrEffectStage* inColorStages[], | 
| + const GrEffectStage* inCoverageStages[], | 
| + GenProgramOutput* output); | 
| virtual ~GrGLShaderBuilder() {} | 
| @@ -110,14 +117,14 @@ public: | 
| Vec3f. The latter is interpreted as projective texture coords. The vec length and swizzle | 
| order of the result depends on the GrTextureAccess associated with the TextureSampler. */ | 
| void appendTextureLookup(SkString* out, | 
| - const TextureSampler&, | 
| - const char* coordName, | 
| - GrSLType coordType = kVec2f_GrSLType) const; | 
| + const TextureSampler&, | 
| + const char* coordName, | 
| + GrSLType coordType = kVec2f_GrSLType) const; | 
| /** Version of above that appends the result to the fragment shader code instead.*/ | 
| void fsAppendTextureLookup(const TextureSampler&, | 
| - const char* coordName, | 
| - GrSLType coordType = kVec2f_GrSLType); | 
| + const char* coordName, | 
| + GrSLType coordType = kVec2f_GrSLType); | 
| /** Does the work of appendTextureLookup and modulates the result by modulation. The result is | 
| @@ -159,8 +166,7 @@ public: | 
| uniform should be accessible. At least one bit must be set. Geometry shader uniforms are not | 
| supported at this time. The actual uniform name will be mangled. If outName is not NULL then | 
| it will refer to the final uniform name after return. Use the addUniformArray variant to add | 
| - an array of uniforms. | 
| - */ | 
| + an array of uniforms. */ | 
| GrGLUniformManager::UniformHandle addUniform(uint32_t visibility, | 
| GrSLType type, | 
| const char* name, | 
| @@ -235,10 +241,10 @@ protected: | 
| // Helper for emitEffects(). | 
| void createAndEmitEffects(GrGLProgramEffectsBuilder*, | 
| - const GrEffectStage* effectStages[], | 
| - const EffectKey effectKeys[], | 
| - int effectCnt, | 
| - GrGLSLExpr4* inOutFSColor); | 
| + const GrEffectStage* effectStages[], | 
| + const EffectKey effectKeys[], | 
| + int effectCnt, | 
| + GrGLSLExpr4* inOutFSColor); | 
| // Generates a name for a variable. The generated string will be name prefixed by the prefix | 
| // char (unless the prefix is '\0'). It also mangles the name to be stage-specific if we're | 
| @@ -252,6 +258,10 @@ protected: | 
| void appendDecls(const VarArray&, SkString*) const; | 
| void appendUniformDecls(ShaderVisibility, SkString*) const; | 
| + const GenProgramOutput& getOutput() const { return fOutput; } | 
| + | 
| 
robertphillips
2014/05/29 21:12:25
Is this supposed to be out here?
 
bsalomon
2014/05/29 21:15:11
Yeah, it's in protected so that subclasses can set
 | 
| + GenProgramOutput fOutput; | 
| + | 
| private: | 
| class CodeStage : SkNoncopyable { | 
| public: | 
| @@ -304,9 +314,7 @@ private: | 
| const GrEffectStage* fEffectStage; | 
| } fCodeStage; | 
| - bool genProgram(const GrEffectStage* colorStages[], | 
| - const GrEffectStage* coverageStages[], | 
| - GenProgramOutput* output); | 
| + bool genProgram(const GrEffectStage* colorStages[], const GrEffectStage* coverageStages[]); | 
| /** | 
| * Adds code for effects and returns a GrGLProgramEffects* object. The caller is responsible for | 
| @@ -327,7 +335,11 @@ private: | 
| /** Gets the name of the primary color output. */ | 
| const char* getColorOutputName() const; | 
| - bool finish(GrGLuint* outProgramId); | 
| + /** | 
| + * Compiles all the shaders, links them into a program, and writes the program id to the output | 
| + * struct. | 
| + **/ | 
| + bool finish(); | 
| const GrGLSLExpr4& getInputColor() const { | 
| return fInputColor; | 
| @@ -353,16 +365,16 @@ private: | 
| // Interpretation of DstReadKey when generating code | 
| enum { | 
| 
robertphillips
2014/05/29 21:12:25
I kind of liked the aligned enum values ...
 
bsalomon
2014/05/29 21:15:11
Argh, yes, I agree.
 | 
| - kNoDstRead_DstReadKey = 0, | 
| - kYesDstRead_DstReadKeyBit = 0x1, // Set if we do a dst-copy-read. | 
| + kNoDstRead_DstReadKey = 0, | 
| + kYesDstRead_DstReadKeyBit = 0x1, // Set if we do a dst-copy-read. | 
| kUseAlphaConfig_DstReadKeyBit = 0x2, // Set if dst-copy config is alpha only. | 
| - kTopLeftOrigin_DstReadKeyBit = 0x4, // Set if dst-copy origin is top-left. | 
| + kTopLeftOrigin_DstReadKeyBit = 0x4, // Set if dst-copy origin is top-left. | 
| }; | 
| enum { | 
| - kNoFragPosRead_FragPosKey = 0, // The fragment positition will not be needed. | 
| - kTopLeftFragPosRead_FragPosKey = 0x1,// Read frag pos relative to top-left. | 
| - kBottomLeftFragPosRead_FragPosKey = 0x2,// Read frag pos relative to bottom-left. | 
| + kNoFragPosRead_FragPosKey = 0, // The fragment positition will not be needed. | 
| + kTopLeftFragPosRead_FragPosKey = 0x1,// Read frag pos relative to top-left. | 
| + kBottomLeftFragPosRead_FragPosKey = 0x2,// Read frag pos relative to bottom-left. | 
| }; | 
| const GrGLProgramDesc& fDesc; | 
| @@ -378,21 +390,13 @@ private: | 
| SkString fFSCode; | 
| bool fSetupFragPosition; | 
| - GrGLUniformManager::UniformHandle fDstCopySamplerUniform; | 
| + bool fTopLeftFragPosRead; | 
| GrGLSLExpr4 fInputColor; | 
| GrGLSLExpr4 fInputCoverage; | 
| bool fHasCustomColorOutput; | 
| bool fHasSecondaryOutput; | 
| - | 
| - GrGLUniformManager::UniformHandle fRTHeightUniform; | 
| - GrGLUniformManager::UniformHandle fDstCopyTopLeftUniform; | 
| - GrGLUniformManager::UniformHandle fDstCopyScaleUniform; | 
| - GrGLUniformManager::UniformHandle fColorUniform; | 
| - GrGLUniformManager::UniformHandle fCoverageUniform; | 
| - | 
| - bool fTopLeftFragPosRead; | 
| }; | 
| //////////////////////////////////////////////////////////////////////////////// | 
| @@ -443,17 +447,6 @@ public: | 
| bool addEffectAttribute(int attributeIndex, GrSLType type, const SkString& name); | 
| const SkString* getEffectAttributeName(int attributeIndex) const; | 
| - /** | 
| - * The view matrix uniform is only valid in the VS. It is always mat33. | 
| - */ | 
| - GrGLUniformManager::UniformHandle getViewMatrixUniform() const { | 
| - return fViewMatrixUniform; | 
| - } | 
| - | 
| - GrGLUniformManager::UniformHandle getRTAdjustmentVecUniform() const { | 
| - return fRTAdustmentVecUniform; | 
| - } | 
| - | 
| private: | 
| virtual GrGLProgramEffects* createAndEmitEffects(const GrEffectStage* effectStages[], | 
| const EffectKey effectKeys[], | 
| @@ -480,8 +473,6 @@ private: | 
| }; | 
| SkSTArray<10, AttributePair, true> fEffectAttributes; | 
| - GrGLUniformManager::UniformHandle fViewMatrixUniform; | 
| - GrGLUniformManager::UniformHandle fRTAdustmentVecUniform; | 
| GrGLShaderVar* fPositionVar; | 
| GrGLShaderVar* fLocalCoordsVar; | 
| @@ -494,7 +485,6 @@ class GrGLFragmentOnlyShaderBuilder : public GrGLShaderBuilder { | 
| public: | 
| GrGLFragmentOnlyShaderBuilder(GrGpuGL*, GrGLUniformManager*, const GrGLProgramDesc&); | 
| - int getNumTexCoordSets() const { return fNumTexCoordSets; } | 
| int addTexCoordSets(int count); | 
| private: | 
| @@ -504,8 +494,6 @@ private: | 
| int effectCnt, | 
| GrGLSLExpr4* inOutFSColor) SK_OVERRIDE; | 
| - int fNumTexCoordSets; | 
| - | 
| typedef GrGLShaderBuilder INHERITED; | 
| }; |