Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Friends | List of all members
GrGLSLFragmentShaderBuilder Class Reference

#include <GrGLSLFragmentShaderBuilder.h>

Inheritance diagram for GrGLSLFragmentShaderBuilder:
GrGLSLFPFragmentBuilder GrGLSLXPFragmentBuilder GrGLSLShaderBuilder GrGLSLShaderBuilder

Public Member Functions

 GrGLSLFragmentShaderBuilder (GrGLSLProgramBuilder *program)
 
const char * dstColor () override
 
void forceHighPrecision () override
 
bool hasSecondaryOutput () const override
 
void enableAdvancedBlendEquationIfNeeded (skgpu::BlendEquation) override
 
- Public Member Functions inherited from GrGLSLFPFragmentBuilder
 GrGLSLFPFragmentBuilder ()
 
- Public Member Functions inherited from GrGLSLShaderBuilder
 GrGLSLShaderBuilder (GrGLSLProgramBuilder *program)
 
virtual ~GrGLSLShaderBuilder ()
 
void appendTextureLookup (SkString *out, SamplerHandle, const char *coordName) const
 
void appendTextureLookup (SamplerHandle, const char *coordName, GrGLSLColorSpaceXformHelper *colorXformHelper=nullptr)
 
void appendTextureLookupAndBlend (const char *dst, SkBlendMode, SamplerHandle, const char *coordName, GrGLSLColorSpaceXformHelper *colorXformHelper=nullptr)
 
void appendInputLoad (SamplerHandle)
 
void appendColorGamutXform (SkString *out, const char *srcColor, GrGLSLColorSpaceXformHelper *colorXformHelper)
 
void appendColorGamutXform (const char *srcColor, GrGLSLColorSpaceXformHelper *colorXformHelper)
 
void defineConstant (const char *type, const char *name, const char *value)
 
void defineConstant (const char *name, int value)
 
void defineConstant (const char *name, float value)
 
void defineConstantf (const char *type, const char *name, const char *fmt,...) SK_PRINTF_LIKE(4
 
 va_start (args, fmt)
 
this definitions ().appendVAList(fmt
 
 va_end (args)
 
this definitions ().append("
 
void definitionAppend (const char *str)
 
void declareGlobal (const GrShaderVar &)
 
SkString newTmpVarName (const char *suffix)
 
void codeAppendf (const char format[],...) SK_PRINTF_LIKE(2
 
void va_start (args, format)
 
this code ().appendVAList(format
 
 va_end (args)
 
void codeAppend (const char *str)
 
void codeAppend (const char *str, size_t length)
 
void codePrependf (const char format[],...) SK_PRINTF_LIKE(2
 
void va_start (args, format)
 
this code ().prependVAList(format
 
 va_end (args)
 
void declAppend (const GrShaderVar &var)
 
SkString getMangledFunctionName (const char *baseName)
 
void emitFunctionPrototype (SkSLType returnType, const char *mangledName, SkSpan< const GrShaderVar > args)
 
void emitFunctionPrototype (const char *declaration)
 
void emitFunction (SkSLType returnType, const char *mangledName, SkSpan< const GrShaderVar > args, const char *body)
 
void emitFunction (const char *declaration, const char *body)
 
void finalize (uint32_t visibility)
 
GrGLSLProgramBuildergetProgramBuilder ()
 
- Public Member Functions inherited from GrGLSLXPFragmentBuilder
 GrGLSLXPFragmentBuilder ()
 

Private Member Functions

void onFinalize () override
 

Friends

class GrGLSLProgramBuilder
 
class GrGLProgramBuilder
 
class GrVkPipelineStateBuilder
 

Additional Inherited Members

- Public Types inherited from GrGLSLFPFragmentBuilder
enum class  ScopeFlags { kTopLevel = 0 , kInsidePerPrimitiveBranch = (1 << 0) , kInsidePerPixelBranch = (1 << 1) , kInsideLoop = (1 << 2) }
 
- Public Types inherited from GrGLSLShaderBuilder
using SamplerHandle = GrGLSLUniformHandler::SamplerHandle
 
- Public Attributes inherited from GrGLSLShaderBuilder
void va_list args
 
this args
 
 n
 
- Protected Types inherited from GrGLSLShaderBuilder
enum  GLSLPrivateFeature {
  kFragCoordConventions_GLSLPrivateFeature , kBlendEquationAdvanced_GLSLPrivateFeature , kBlendFuncExtended_GLSLPrivateFeature , kFramebufferFetch_GLSLPrivateFeature ,
  kNoPerspectiveInterpolation_GLSLPrivateFeature , kSampleVariables_GLSLPrivateFeature , kLastGLSLPrivateFeature = kSampleVariables_GLSLPrivateFeature
}
 
enum  InterfaceQualifier { kIn_InterfaceQualifier , kOut_InterfaceQualifier , kLastInterfaceQualifier = kOut_InterfaceQualifier }
 
enum  {
  kExtensions , kDefinitions , kPrecisionQualifier , kLayoutQualifiers ,
  kUniforms , kInputs , kOutputs , kFunctions ,
  kMain , kCode , kPrealloc = kCode + 6
}
 
typedef SkTBlockList< GrShaderVarVarArray
 
- Protected Member Functions inherited from GrGLSLShaderBuilder
void appendDecls (const VarArray &vars, SkString *out) const
 
void appendFunctionDecl (SkSLType returnType, const char *mangledName, SkSpan< const GrShaderVar > args)
 
bool addFeature (uint32_t featureBit, const char *extensionName)
 
void addLayoutQualifier (const char *param, InterfaceQualifier)
 
void compileAndAppendLayoutQualifiers ()
 
void nextStage ()
 
void deleteStage ()
 
SkStringextensions ()
 
SkStringdefinitions ()
 
SkStringprecisionQualifier ()
 
SkStringlayoutQualifiers ()
 
SkStringuniforms ()
 
SkStringinputs ()
 
SkStringoutputs ()
 
SkStringfunctions ()
 
SkStringmain ()
 
SkStringcode ()
 
- Protected Attributes inherited from GrGLSLShaderBuilder
GrGLSLProgramBuilderfProgramBuilder
 
std::string fCompilerString
 
skia_private::STArray< kPrealloc, SkStringfShaderStrings
 
SkString fCode
 
SkString fFunctions
 
SkString fExtensions
 
SkSL::StatementArray fDeclarations
 
VarArray fInputs
 
VarArray fOutputs
 
uint32_t fFeaturesAddedMask
 
skia_private::STArray< 1, SkStringfLayoutParams [kLastInterfaceQualifier+1]
 
int fCodeIndex
 
bool fFinalized
 
int fTmpVariableCounter
 

Detailed Description

Definition at line 83 of file GrGLSLFragmentShaderBuilder.h.

Constructor & Destructor Documentation

◆ GrGLSLFragmentShaderBuilder()

GrGLSLFragmentShaderBuilder::GrGLSLFragmentShaderBuilder ( GrGLSLProgramBuilder program)

Member Function Documentation

◆ dstColor()

const char * GrGLSLFragmentShaderBuilder::dstColor ( )
overridevirtual

Returns the variable name that holds the color of the destination pixel. This may be nullptr if no effect advertised that it will read the destination.

Implements GrGLSLFPFragmentBuilder.

Definition at line 21 of file GrGLSLFragmentShaderBuilder.cpp.

21 {
22 SkDEBUGCODE(fHasReadDstColorThisStage_DebugOnly = true;)
23
24 const GrShaderCaps* shaderCaps = fProgramBuilder->shaderCaps();
25 if (shaderCaps->fFBFetchSupport) {
27 shaderCaps->fFBFetchExtensionString);
28
29 // Some versions of this extension string require declaring custom color output on ES 3.0+
30 const char* fbFetchColorName = "sk_LastFragColor";
31 if (shaderCaps->fFBFetchNeedsCustomOutput) {
32 fPrimaryColorIsInOut = true;
33 fbFetchColorName = DeclaredColorOutputName();
34 // Set the dstColor to an intermediate variable so we don't override it with the output
35 this->codeAppendf("half4 %s = %s;", kDstColorName, fbFetchColorName);
36 } else {
37 return fbFetchColorName;
38 }
39 }
40 return kDstColorName;
41}
#define SkDEBUGCODE(...)
Definition SkDebug.h:23
const GrShaderCaps * shaderCaps() const
bool addFeature(uint32_t featureBit, const char *extensionName)
void codeAppendf(const char format[],...) SK_PRINTF_LIKE(2
GrGLSLProgramBuilder * fProgramBuilder

◆ enableAdvancedBlendEquationIfNeeded()

void GrGLSLFragmentShaderBuilder::enableAdvancedBlendEquationIfNeeded ( skgpu::BlendEquation  )
overridevirtual

Adds any necessary layout qualifiers in order to legalize the supplied blend equation with this shader. It is only legal to call this method with an advanced blend equation, and only if these equations are supported.

Implements GrGLSLXPFragmentBuilder.

Definition at line 43 of file GrGLSLFragmentShaderBuilder.cpp.

44 {
46
49 "GL_KHR_blend_equation_advanced");
50 this->addLayoutQualifier("blend_support_all_equations", kOut_InterfaceQualifier);
51 }
52}
#define SkASSERT(cond)
Definition SkAssert.h:116
void addLayoutQualifier(const char *param, InterfaceQualifier)
static constexpr bool BlendEquationIsAdvanced(BlendEquation equation)
Definition Blend.h:129
bool mustEnableAdvBlendEqs() const
Definition SkSLUtil.h:39

◆ forceHighPrecision()

void GrGLSLFragmentShaderBuilder::forceHighPrecision ( )
inlineoverridevirtual

Implements GrGLSLFPFragmentBuilder.

Definition at line 91 of file GrGLSLFragmentShaderBuilder.h.

91{ fForceHighPrecision = true; }

◆ hasSecondaryOutput()

bool GrGLSLFragmentShaderBuilder::hasSecondaryOutput ( ) const
inlineoverridevirtual

Implements GrGLSLXPFragmentBuilder.

Definition at line 94 of file GrGLSLFragmentShaderBuilder.h.

94{ return fHasSecondaryOutput; }

◆ onFinalize()

void GrGLSLFragmentShaderBuilder::onFinalize ( )
overrideprivatevirtual

Implements GrGLSLShaderBuilder.

Definition at line 94 of file GrGLSLFragmentShaderBuilder.cpp.

94 {
96}
virtual GrGLSLVaryingHandler * varyingHandler()=0
void getFragDecls(SkString *inputDecls, SkString *outputDecls) const

Friends And Related Symbol Documentation

◆ GrGLProgramBuilder

friend class GrGLProgramBuilder
friend

Definition at line 130 of file GrGLSLFragmentShaderBuilder.h.

◆ GrGLSLProgramBuilder

friend class GrGLSLProgramBuilder
friend

Definition at line 129 of file GrGLSLFragmentShaderBuilder.h.

◆ GrVkPipelineStateBuilder

friend class GrVkPipelineStateBuilder
friend

Definition at line 131 of file GrGLSLFragmentShaderBuilder.h.


The documentation for this class was generated from the following files: