Flutter Engine
The Flutter Engine
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Friends | List of all members
GrGLSLUniformHandler Class Referenceabstract

#include <GrGLSLUniformHandler.h>

Inheritance diagram for GrGLSLUniformHandler:
GrGLUniformHandler GrMtlUniformHandler GrSPIRVUniformHandler GrVkUniformHandler

Classes

struct  UniformInfo
 

Public Types

using UniformHandle = GrGLSLProgramDataManager::UniformHandle
 

Public Member Functions

virtual ~GrGLSLUniformHandler ()
 
UniformHandle addUniform (const GrProcessor *owner, uint32_t visibility, SkSLType type, const char *name, const char **outName=nullptr)
 
UniformHandle addUniformArray (const GrProcessor *owner, uint32_t visibility, SkSLType type, const char *name, int arrayCount, const char **outName=nullptr)
 
virtual const GrShaderVargetUniformVariable (UniformHandle u) const =0
 
virtual const char * getUniformCStr (UniformHandle u) const =0
 
virtual int numUniforms () const =0
 
virtual UniformInfouniform (int idx)=0
 
virtual const UniformInfouniform (int idx) const =0
 
GrShaderVar getUniformMapping (const GrProcessor &owner, SkString rawName) const
 
GrShaderVar liftUniformToVertexShader (const GrProcessor &owner, SkString rawName)
 

Protected Member Functions

 GrGLSLUniformHandler (GrGLSLProgramBuilder *program)
 

Protected Attributes

GrGLSLProgramBuilderfProgramBuilder
 

Private Member Functions

virtual const char * samplerVariable (SamplerHandle) const =0
 
virtual skgpu::Swizzle samplerSwizzle (SamplerHandle) const =0
 
virtual const char * inputSamplerVariable (SamplerHandle) const
 
virtual skgpu::Swizzle inputSamplerSwizzle (SamplerHandle) const
 
virtual SamplerHandle addSampler (const GrBackendFormat &, GrSamplerState, const skgpu::Swizzle &, const char *name, const GrShaderCaps *)=0
 
virtual SamplerHandle addInputSampler (const skgpu::Swizzle &swizzle, const char *name)
 
virtual UniformHandle internalAddUniformArray (const GrProcessor *owner, uint32_t visibility, SkSLType type, const char *name, bool mangleName, int arrayCount, const char **outName)=0
 
virtual void appendUniformDecls (GrShaderFlags visibility, SkString *) const =0
 

Friends

class GrGLSLProgramBuilder
 

Detailed Description

Definition at line 41 of file GrGLSLUniformHandler.h.

Member Typedef Documentation

◆ UniformHandle

using GrGLSLUniformHandler::UniformHandle = GrGLSLProgramDataManager::UniformHandle

Definition at line 52 of file GrGLSLUniformHandler.h.

Constructor & Destructor Documentation

◆ ~GrGLSLUniformHandler()

virtual GrGLSLUniformHandler::~GrGLSLUniformHandler ( )
inlinevirtual

Definition at line 50 of file GrGLSLUniformHandler.h.

50{}

◆ GrGLSLUniformHandler()

GrGLSLUniformHandler::GrGLSLUniformHandler ( GrGLSLProgramBuilder program)
inlineexplicitprotected

Definition at line 104 of file GrGLSLUniformHandler.h.

104: fProgramBuilder(program) {}
GrGLSLProgramBuilder * fProgramBuilder

Member Function Documentation

◆ addInputSampler()

virtual SamplerHandle GrGLSLUniformHandler::addInputSampler ( const skgpu::Swizzle swizzle,
const char *  name 
)
inlineprivatevirtual

Definition at line 125 of file GrGLSLUniformHandler.h.

125 {
126 SkDEBUGFAIL("Trying to add input sampler to unsupported backend");
127 return {};
128 }
#define SkDEBUGFAIL(message)
Definition: SkAssert.h:118

◆ addSampler()

virtual SamplerHandle GrGLSLUniformHandler::addSampler ( const GrBackendFormat ,
GrSamplerState  ,
const skgpu::Swizzle ,
const char *  name,
const GrShaderCaps  
)
privatepure virtual

◆ addUniform()

UniformHandle GrGLSLUniformHandler::addUniform ( const GrProcessor owner,
uint32_t  visibility,
SkSLType  type,
const char *  name,
const char **  outName = nullptr 
)
inline

Add a uniform variable to the current program, that has visibility in one or more shaders. visibility is a bitfield of GrShaderFlag values indicating from which shaders the 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 nullptr then it will refer to the final uniform name after return. Use the addUniformArray variant to add an array of uniforms.

Definition at line 62 of file GrGLSLUniformHandler.h.

66 {
68 return this->addUniformArray(owner, visibility, type, name, 0, outName);
69 }
#define SkASSERT(cond)
Definition: SkAssert.h:116
bool SkSLTypeIsCombinedSamplerType(SkSLType type)
GLenum type
UniformHandle addUniformArray(const GrProcessor *owner, uint32_t visibility, SkSLType type, const char *name, int arrayCount, const char **outName=nullptr)
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32

◆ addUniformArray()

UniformHandle GrGLSLUniformHandler::addUniformArray ( const GrProcessor owner,
uint32_t  visibility,
SkSLType  type,
const char *  name,
int  arrayCount,
const char **  outName = nullptr 
)
inline

Definition at line 71 of file GrGLSLUniformHandler.h.

76 {
78 bool mangle = strncmp(name, GR_NO_MANGLE_PREFIX, strlen(GR_NO_MANGLE_PREFIX));
79 return this->internalAddUniformArray(owner, visibility, type, name, mangle, arrayCount,
80 outName);
81 }
#define GR_NO_MANGLE_PREFIX
virtual UniformHandle internalAddUniformArray(const GrProcessor *owner, uint32_t visibility, SkSLType type, const char *name, bool mangleName, int arrayCount, const char **outName)=0

◆ appendUniformDecls()

virtual void GrGLSLUniformHandler::appendUniformDecls ( GrShaderFlags  visibility,
SkString  
) const
privatepure virtual

◆ getUniformCStr()

virtual const char * GrGLSLUniformHandler::getUniformCStr ( UniformHandle  u) const
pure virtual

Shortcut for getUniformVariable(u).c_str()

Implemented in GrGLUniformHandler, GrSPIRVUniformHandler, GrMtlUniformHandler, and GrVkUniformHandler.

◆ getUniformMapping()

GrShaderVar GrGLSLUniformHandler::getUniformMapping ( const GrProcessor owner,
SkString  rawName 
) const

Definition at line 10 of file GrGLSLUniformHandler.cpp.

11 {
12 for (int i = this->numUniforms() - 1; i >= 0; i--) {
13 const UniformInfo& u = this->uniform(i);
14 if (u.fOwner == &owner && u.fRawName == rawName) {
15 return u.fVariable;
16 }
17 }
18 return GrShaderVar();
19}
virtual UniformInfo & uniform(int idx)=0
virtual int numUniforms() const =0

◆ getUniformVariable()

virtual const GrShaderVar & GrGLSLUniformHandler::getUniformVariable ( UniformHandle  u) const
pure virtual

◆ inputSamplerSwizzle()

virtual skgpu::Swizzle GrGLSLUniformHandler::inputSamplerSwizzle ( SamplerHandle  ) const
inlineprivatevirtual

Definition at line 117 of file GrGLSLUniformHandler.h.

117 {
118 SkDEBUGFAIL("Trying to get input sampler swizzle from unsupported backend");
119 return {};
120 }

◆ inputSamplerVariable()

virtual const char * GrGLSLUniformHandler::inputSamplerVariable ( SamplerHandle  ) const
inlineprivatevirtual

Definition at line 113 of file GrGLSLUniformHandler.h.

113 {
114 SkDEBUGFAIL("Trying to get input sampler from unsupported backend");
115 return nullptr;
116 }

◆ internalAddUniformArray()

virtual UniformHandle GrGLSLUniformHandler::internalAddUniformArray ( const GrProcessor owner,
uint32_t  visibility,
SkSLType  type,
const char *  name,
bool  mangleName,
int  arrayCount,
const char **  outName 
)
privatepure virtual

◆ liftUniformToVertexShader()

GrShaderVar GrGLSLUniformHandler::liftUniformToVertexShader ( const GrProcessor owner,
SkString  rawName 
)

Definition at line 21 of file GrGLSLUniformHandler.cpp.

22 {
23 for (int i = this->numUniforms() - 1; i >= 0; i--) {
24 UniformInfo& u = this->uniform(i);
25 if (u.fOwner == &owner && u.fRawName == rawName) {
26 u.fVisibility |= kVertex_GrShaderFlag;
27 return u.fVariable;
28 }
29 }
30 // Uniform not found; it's better to return a void variable than to assert because sample
31 // matrices that are uniform are treated the same for most of the code. When the sample
32 // matrix expression can't be found as a uniform, we can infer it's a constant.
33 return GrShaderVar();
34}
@ kVertex_GrShaderFlag
Definition: GrTypesPriv.h:286

◆ numUniforms()

virtual int GrGLSLUniformHandler::numUniforms ( ) const
pure virtual

◆ samplerSwizzle()

virtual skgpu::Swizzle GrGLSLUniformHandler::samplerSwizzle ( SamplerHandle  ) const
privatepure virtual

◆ samplerVariable()

virtual const char * GrGLSLUniformHandler::samplerVariable ( SamplerHandle  ) const
privatepure virtual

◆ uniform() [1/2]

virtual const UniformInfo & GrGLSLUniformHandler::uniform ( int  idx) const
pure virtual

◆ uniform() [2/2]

virtual UniformInfo & GrGLSLUniformHandler::uniform ( int  idx)
pure virtual

Friends And Related Function Documentation

◆ GrGLSLProgramBuilder

friend class GrGLSLProgramBuilder
friend

Definition at line 140 of file GrGLSLUniformHandler.h.

Member Data Documentation

◆ fProgramBuilder

GrGLSLProgramBuilder* GrGLSLUniformHandler::fProgramBuilder
protected

Definition at line 107 of file GrGLSLUniformHandler.h.


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