Flutter Engine
The Flutter Engine
|
#include <GrGLSLShaderBuilder.h>
Classes | |
class | ShaderBlock |
Public Types | |
using | SamplerHandle = GrGLSLUniformHandler::SamplerHandle |
Public Member Functions | |
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) |
GrGLSLProgramBuilder * | getProgramBuilder () |
Public Attributes | |
void va_list | args |
this | args |
n | |
Protected Types | |
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< GrShaderVar > | VarArray |
Protected Member Functions | |
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 () |
SkString & | extensions () |
SkString & | definitions () |
SkString & | precisionQualifier () |
SkString & | layoutQualifiers () |
SkString & | uniforms () |
SkString & | inputs () |
SkString & | outputs () |
SkString & | functions () |
SkString & | main () |
SkString & | code () |
virtual void | onFinalize ()=0 |
Protected Attributes | |
GrGLSLProgramBuilder * | fProgramBuilder |
std::string | fCompilerString |
skia_private::STArray< kPrealloc, SkString > | fShaderStrings |
SkString | fCode |
SkString | fFunctions |
SkString | fExtensions |
SkSL::StatementArray | fDeclarations |
VarArray | fInputs |
VarArray | fOutputs |
uint32_t | fFeaturesAddedMask |
skia_private::STArray< 1, SkString > | fLayoutParams [kLastInterfaceQualifier+1] |
int | fCodeIndex |
bool | fFinalized |
int | fTmpVariableCounter |
Friends | |
class | GrGLSLProgramBuilder |
class | GrGLProgramBuilder |
class | GrD3DPipelineStateBuilder |
class | GrDawnProgramBuilder |
class | GrGLSLVaryingHandler |
class | GrGLPathProgramBuilder |
class | GrVkPipelineStateBuilder |
class | GrMtlPipelineStateBuilder |
base class for all shaders builders
Definition at line 34 of file GrGLSLShaderBuilder.h.
using GrGLSLShaderBuilder::SamplerHandle = GrGLSLUniformHandler::SamplerHandle |
Definition at line 39 of file GrGLSLShaderBuilder.h.
|
protected |
Definition at line 185 of file GrGLSLShaderBuilder.h.
|
protected |
Enumerator | |
---|---|
kExtensions | |
kDefinitions | |
kPrecisionQualifier | |
kLayoutQualifiers | |
kUniforms | |
kInputs | |
kOutputs | |
kFunctions | |
kMain | |
kCode | |
kPrealloc |
Definition at line 252 of file GrGLSLShaderBuilder.h.
|
protected |
Features that should only be enabled internally by the builders.
Definition at line 195 of file GrGLSLShaderBuilder.h.
|
protected |
Enumerator | |
---|---|
kIn_InterfaceQualifier | |
kOut_InterfaceQualifier | |
kLastInterfaceQualifier |
Definition at line 212 of file GrGLSLShaderBuilder.h.
GrGLSLShaderBuilder::GrGLSLShaderBuilder | ( | GrGLSLProgramBuilder * | program | ) |
Definition at line 23 of file GrGLSLShaderBuilder.cpp.
|
inlinevirtual |
Definition at line 37 of file GrGLSLShaderBuilder.h.
|
protected |
Definition at line 258 of file GrGLSLShaderBuilder.cpp.
|
protected |
Definition at line 274 of file GrGLSLShaderBuilder.cpp.
void GrGLSLShaderBuilder::appendColorGamutXform | ( | const char * | srcColor, |
GrGLSLColorSpaceXformHelper * | colorXformHelper | ||
) |
Version of above that appends the result to the shader code instead.
Definition at line 251 of file GrGLSLShaderBuilder.cpp.
void GrGLSLShaderBuilder::appendColorGamutXform | ( | SkString * | out, |
const char * | srcColor, | ||
GrGLSLColorSpaceXformHelper * | colorXformHelper | ||
) |
Adds a helper function to facilitate color gamut transformation, and produces code that returns the srcColor transformed into a new gamut (via multiplication by the xform from colorXformHelper). Premultiplied sources are also handled correctly (colorXformHelper determines if the source is premultipled or not).
Definition at line 141 of file GrGLSLShaderBuilder.cpp.
Definition at line 267 of file GrGLSLShaderBuilder.cpp.
|
protected |
Definition at line 54 of file GrGLSLShaderBuilder.cpp.
void GrGLSLShaderBuilder::appendInputLoad | ( | SamplerHandle | samplerHandle | ) |
Appends a load of an input attachment into the shader code.
Definition at line 133 of file GrGLSLShaderBuilder.cpp.
void GrGLSLShaderBuilder::appendTextureLookup | ( | SamplerHandle | samplerHandle, |
const char * | coordName, | ||
GrGLSLColorSpaceXformHelper * | colorXformHelper = nullptr |
||
) |
Version of above that appends the result to the shader code instead.
Definition at line 109 of file GrGLSLShaderBuilder.cpp.
void GrGLSLShaderBuilder::appendTextureLookup | ( | SkString * | out, |
SamplerHandle | samplerHandle, | ||
const char * | coordName | ||
) | const |
Appends a 2D texture sample with projection if necessary. The vec length and swizzle order of the result depends on the GrProcessor::TextureSampler associated with the SamplerHandle.
Definition at line 101 of file GrGLSLShaderBuilder.cpp.
void GrGLSLShaderBuilder::appendTextureLookupAndBlend | ( | const char * | dst, |
SkBlendMode | mode, | ||
SamplerHandle | samplerHandle, | ||
const char * | coordName, | ||
GrGLSLColorSpaceXformHelper * | colorXformHelper = nullptr |
||
) |
Does the work of appendTextureLookup and blends the result by dst, treating the texture lookup as the src input to the blend. The dst is assumed to be half4 and the result is always a half4. If dst is nullptr we use half4(1) as the blend dst.
Definition at line 117 of file GrGLSLShaderBuilder.cpp.
|
inlineprotected |
Definition at line 248 of file GrGLSLShaderBuilder.h.
this GrGLSLShaderBuilder::code | ( | ) |
this GrGLSLShaderBuilder::code | ( | ) |
|
inline |
Definition at line 120 of file GrGLSLShaderBuilder.h.
|
inline |
Definition at line 122 of file GrGLSLShaderBuilder.h.
void GrGLSLShaderBuilder::codeAppendf | ( | const char | format[], |
... | |||
) |
Called by GrGLSLProcessors to add code to one of the shaders.
void GrGLSLShaderBuilder::codePrependf | ( | const char | format[], |
... | |||
) |
|
protected |
Definition at line 280 of file GrGLSLShaderBuilder.cpp.
void GrGLSLShaderBuilder::declAppend | ( | const GrShaderVar & | var | ) |
Appends a variable declaration to one of the shaders
Definition at line 39 of file GrGLSLShaderBuilder.cpp.
void GrGLSLShaderBuilder::declareGlobal | ( | const GrShaderVar & | v | ) |
Definition at line 45 of file GrGLSLShaderBuilder.cpp.
|
inline |
Definition at line 85 of file GrGLSLShaderBuilder.h.
|
inline |
Definition at line 81 of file GrGLSLShaderBuilder.h.
|
inline |
Adds a constant declaration to the top of the shader.
Definition at line 77 of file GrGLSLShaderBuilder.h.
void GrGLSLShaderBuilder::defineConstantf | ( | const char * | type, |
const char * | name, | ||
const char * | fmt, | ||
... | |||
) |
|
inline |
Definition at line 99 of file GrGLSLShaderBuilder.h.
|
inlineprotected |
Definition at line 240 of file GrGLSLShaderBuilder.h.
this GrGLSLShaderBuilder::definitions | ( | ) |
this GrGLSLShaderBuilder::definitions | ( | ) |
|
inlineprotected |
Definition at line 234 of file GrGLSLShaderBuilder.h.
void GrGLSLShaderBuilder::emitFunction | ( | const char * | declaration, |
const char * | body | ||
) |
Definition at line 78 of file GrGLSLShaderBuilder.cpp.
void GrGLSLShaderBuilder::emitFunction | ( | SkSLType | returnType, |
const char * | mangledName, | ||
SkSpan< const GrShaderVar > | args, | ||
const char * | body | ||
) |
Emits a helper function outside of main() in the fragment shader.
Definition at line 68 of file GrGLSLShaderBuilder.cpp.
void GrGLSLShaderBuilder::emitFunctionPrototype | ( | const char * | declaration | ) |
Definition at line 91 of file GrGLSLShaderBuilder.cpp.
void GrGLSLShaderBuilder::emitFunctionPrototype | ( | SkSLType | returnType, |
const char * | mangledName, | ||
SkSpan< const GrShaderVar > | args | ||
) |
Emits a prototype for a helper function outside of main() in the fragment shader.
Definition at line 84 of file GrGLSLShaderBuilder.cpp.
|
inlineprotected |
Definition at line 239 of file GrGLSLShaderBuilder.h.
void GrGLSLShaderBuilder::finalize | ( | uint32_t | visibility | ) |
Combines the various parts of the shader to create a single finalized shader string.
Definition at line 303 of file GrGLSLShaderBuilder.cpp.
|
inlineprotected |
Definition at line 246 of file GrGLSLShaderBuilder.h.
SkString GrGLSLShaderBuilder::getMangledFunctionName | ( | const char * | baseName | ) |
Generates a mangled name for a helper function in the fragment shader. Will give consistent results if called more than once.
Definition at line 50 of file GrGLSLShaderBuilder.cpp.
|
inline |
|
inlineprotected |
Definition at line 244 of file GrGLSLShaderBuilder.h.
|
inlineprotected |
Definition at line 242 of file GrGLSLShaderBuilder.h.
|
inlineprotected |
Definition at line 247 of file GrGLSLShaderBuilder.h.
|
inline |
Definition at line 105 of file GrGLSLShaderBuilder.h.
|
inlineprotected |
Definition at line 229 of file GrGLSLShaderBuilder.h.
|
protectedpure virtual |
|
inlineprotected |
Definition at line 245 of file GrGLSLShaderBuilder.h.
|
inlineprotected |
Definition at line 241 of file GrGLSLShaderBuilder.h.
|
inlineprotected |
Definition at line 243 of file GrGLSLShaderBuilder.h.
GrGLSLShaderBuilder::va_end | ( | args | ) |
GrGLSLShaderBuilder::va_end | ( | args | ) |
GrGLSLShaderBuilder::va_end | ( | args | ) |
|
friend |
Definition at line 288 of file GrGLSLShaderBuilder.h.
|
friend |
Definition at line 289 of file GrGLSLShaderBuilder.h.
|
friend |
Definition at line 291 of file GrGLSLShaderBuilder.h.
|
friend |
Definition at line 287 of file GrGLSLShaderBuilder.h.
|
friend |
Definition at line 286 of file GrGLSLShaderBuilder.h.
|
friend |
Definition at line 290 of file GrGLSLShaderBuilder.h.
|
friend |
Definition at line 293 of file GrGLSLShaderBuilder.h.
|
friend |
Definition at line 292 of file GrGLSLShaderBuilder.h.
this GrGLSLShaderBuilder::args |
Definition at line 92 of file GrGLSLShaderBuilder.h.
this GrGLSLShaderBuilder::args |
Definition at line 94 of file GrGLSLShaderBuilder.h.
|
protected |
Definition at line 270 of file GrGLSLShaderBuilder.h.
|
protected |
Definition at line 280 of file GrGLSLShaderBuilder.h.
|
protected |
Definition at line 268 of file GrGLSLShaderBuilder.h.
|
protected |
Definition at line 274 of file GrGLSLShaderBuilder.h.
|
protected |
Definition at line 272 of file GrGLSLShaderBuilder.h.
|
protected |
Definition at line 278 of file GrGLSLShaderBuilder.h.
|
protected |
Definition at line 281 of file GrGLSLShaderBuilder.h.
|
protected |
Definition at line 271 of file GrGLSLShaderBuilder.h.
|
protected |
Definition at line 276 of file GrGLSLShaderBuilder.h.
|
protected |
Definition at line 279 of file GrGLSLShaderBuilder.h.
|
protected |
Definition at line 277 of file GrGLSLShaderBuilder.h.
|
protected |
Definition at line 267 of file GrGLSLShaderBuilder.h.
|
protected |
Definition at line 269 of file GrGLSLShaderBuilder.h.
|
protected |
Definition at line 284 of file GrGLSLShaderBuilder.h.
GrGLSLShaderBuilder::n |
Definition at line 96 of file GrGLSLShaderBuilder.h.