diff options
author | joshualitt <joshualitt@chromium.org> | 2014-10-07 12:42:26 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-10-07 12:42:26 -0700 |
commit | db0d3ca07008ea2c1f24d0fd9ceecf10af6ae63b (patch) | |
tree | 12ff0bd9f07193593b7db1d52ef2fe0478c00aeb /src/gpu/gl/builders/GrGLFragmentShaderBuilder.h | |
parent | fe1233c3f12f81bb675718516bbb32f72af726ec (diff) |
Revert of Cleanup of shader building system (patchset #25 id:470001 of https://codereview.chromium.org/611653002/)
Reason for revert:
Seems to have messed up windows 7 gms
Original issue's description:
> Cleanup of shader building system
>
> this is a huge refactor and cleanup of the gl shader building system in
> Skia. The entire shader building pipeline is now part of
> GrGLProgramCreator, which takes a gp, and some fps, and creates a
> program. I added some subclasses of GrGLProgram to handle the
> eccentricities of Nvpr/Nvpres. Outside of the builders folder
> and GrGLPrograms, this change is basically just a rename
>
>
> solo gp
>
> BUG=skia:
>
> Committed: https://skia.googlesource.com/skia/+/fe1233c3f12f81bb675718516bbb32f72af726ec
TBR=bsalomon@google.com
NOTREECHECKS=true
NOTRY=true
BUG=skia:
Review URL: https://codereview.chromium.org/635533005
Diffstat (limited to 'src/gpu/gl/builders/GrGLFragmentShaderBuilder.h')
-rw-r--r-- | src/gpu/gl/builders/GrGLFragmentShaderBuilder.h | 80 |
1 files changed, 34 insertions, 46 deletions
diff --git a/src/gpu/gl/builders/GrGLFragmentShaderBuilder.h b/src/gpu/gl/builders/GrGLFragmentShaderBuilder.h index fdf685cc09..38d569e734 100644 --- a/src/gpu/gl/builders/GrGLFragmentShaderBuilder.h +++ b/src/gpu/gl/builders/GrGLFragmentShaderBuilder.h @@ -7,16 +7,18 @@ #ifndef GrGLFragmentShaderBuilder_DEFINED #define GrGLFragmentShaderBuilder_DEFINED - #include "GrGLShaderBuilder.h" +class GrGLProgramBuilder; + /* - * This base class encapsulates the functionality which the GP uses to build fragment shaders + * This base class encapsulates the functionality which all GrProcessors are allowed to use in their + * fragment shader */ -class GrGLGPFragmentBuilder : public GrGLShaderBuilder { +class GrGLProcessorFragmentShaderBuilder : public GrGLShaderBuilder { public: - GrGLGPFragmentBuilder(GrGLProgramBuilder* program) : INHERITED(program) {} - virtual ~GrGLGPFragmentBuilder() {} + GrGLProcessorFragmentShaderBuilder(GrGLProgramBuilder* program) : INHERITED(program) {} + virtual ~GrGLProcessorFragmentShaderBuilder() {} /** * Use of these features may require a GLSL extension to be enabled. Shaders may not compile * if code is added that uses one of these features without calling enableFeature() @@ -51,23 +53,20 @@ private: /* * Fragment processor's, in addition to all of the above, may need to use dst color so they use - * this builder to create their shader. Because this is the only shader builder the FP sees, we - * just call it FPShaderBuilder + * this builder to create their shader */ -class GrGLFPFragmentBuilder : public GrGLGPFragmentBuilder { +class GrGLFragmentProcessorShaderBuilder : public GrGLProcessorFragmentShaderBuilder { public: - GrGLFPFragmentBuilder(GrGLProgramBuilder* program) : INHERITED(program) {} - + GrGLFragmentProcessorShaderBuilder(GrGLProgramBuilder* program) : INHERITED(program) {} /** Returns the variable name that holds the color of the destination pixel. This may be NULL if no effect advertised that it will read the destination. */ virtual const char* dstColor() = 0; private: - typedef GrGLGPFragmentBuilder INHERITED; + typedef GrGLProcessorFragmentShaderBuilder INHERITED; }; -// TODO rename to Fragment Builder -class GrGLFragmentShaderBuilder : public GrGLFPFragmentBuilder { +class GrGLFragmentShaderBuilder : public GrGLFragmentProcessorShaderBuilder { public: typedef uint8_t DstReadKey; typedef uint8_t FragPosKey; @@ -84,42 +83,39 @@ public: GrGLFragmentShaderBuilder(GrGLProgramBuilder* program, const GrGLProgramDesc& desc); - // true public interface, defined explicitly in the abstract interfaces above + virtual const char* dstColor() SK_OVERRIDE; + virtual bool enableFeature(GLSLFeature) SK_OVERRIDE; + virtual SkString ensureFSCoords2D(const GrGLProcessor::TransformedCoordsArray& coords, int index) SK_OVERRIDE; - virtual const char* fragmentPosition() SK_OVERRIDE; - virtual const char* dstColor() SK_OVERRIDE; - // Private public interface, used by GrGLProgramBuilder to build a fragment shader - void emitCodeToReadDstTexture(); - void enableCustomOutput(); - void enableSecondaryOutput(); - const char* getPrimaryColorOutputName() const; - const char* getSecondaryColorOutputName() const; - void enableSecondaryOutput(const GrGLSLExpr4& inputColor, const GrGLSLExpr4& inputCoverage); - void combineColorAndCoverage(const GrGLSLExpr4& inputColor, const GrGLSLExpr4& inputCoverage); - bool compileAndAttachShaders(GrGLuint programId, SkTDArray<GrGLuint>* shaderIds) const; - void bindFragmentShaderLocations(GrGLuint programID); + virtual const char* fragmentPosition() SK_OVERRIDE; +private: /* - * An internal call for GrGLProgramBuilder to use to add varyings to the vertex shader + * An internal call for GrGLFullProgramBuilder to use to add varyings to the vertex shader */ void addVarying(GrSLType type, const char* name, const char** fsInName, GrGLShaderVar::Precision fsPrecision = GrGLShaderVar::kDefault_Precision); - // As GLProcessors emit code, there are some conditions we need to verify. We use the below - // state to track this. The reset call is called per processor emitted. - bool hasReadDstColor() const { return fHasReadDstColor; } - bool hasReadFragmentPosition() const { return fHasReadFragmentPosition; } - void reset() { - fHasReadDstColor = false; - fHasReadFragmentPosition = false; - } + /* + * Private functions used by GrGLProgramBuilder for compilation + */ + void bindProgramLocations(GrGLuint programId); + bool compileAndAttachShaders(GrGLuint programId, SkTDArray<GrGLuint>* shaderIds) const; + void emitCodeBeforeEffects(); + void emitCodeAfterEffects(const GrGLSLExpr4& inputColor, const GrGLSLExpr4& inputCoverage); + + /** Enables using the secondary color output and returns the name of the var in which it is + to be stored */ + const char* enableSecondaryOutput(); + + /** Gets the name of the primary color output. */ + const char* getColorOutputName() const; -private: /** * Features that should only be enabled by GrGLFragmentShaderBuilder itself. */ @@ -136,29 +132,21 @@ private: kTopLeftOrigin_DstReadKeyBit = 0x4, // Set if dst-copy origin is top-left. }; - // Interpretation of FragPosKey when generating code 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. }; - static const char* kDstCopyColorName; - bool fHasCustomColorOutput; bool fHasSecondaryOutput; bool fSetupFragPosition; bool fTopLeftFragPosRead; - // some state to verify shaders and effects are consistent, this is reset between effects by - // the program creator - bool fHasReadDstColor; - bool fHasReadFragmentPosition; - - friend class GrGLNvprProgramBuilder; friend class GrGLProgramBuilder; + friend class GrGLFullProgramBuilder; - typedef GrGLFPFragmentBuilder INHERITED; + typedef GrGLFragmentProcessorShaderBuilder INHERITED; }; #endif |