8#ifndef GrGeometryProcessor_DEFINED
9#define GrGeometryProcessor_DEFINED
23#include <unordered_map>
98 constexpr const char*
name()
const {
return fName; }
107 if (fOffset != kImplicitOffset) {
114 inline constexpr size_t size()
const;
121 static constexpr uint32_t kImplicitOffset = 1;
123 const char* fName =
nullptr;
126 uint32_t fOffset = kImplicitOffset;
138 Iter(
const Iter& iter) =
default;
139 Iter&
operator=(
const Iter& iter) =
default;
142 this->skipUninitialized();
145 bool operator!=(
const Iter& that)
const {
return fCurr != that.fCurr; }
150 void skipUninitialized();
154 size_t fImplicitOffset = 0;
161 int count()
const {
return fCount; }
162 size_t stride()
const {
return fStride; }
230 fVertexAttributes.
initExplicit(attrs, attrCount, stride);
234 fInstanceAttributes.
initExplicit(attrs, attrCount, stride);
246 fTextureSamplerCnt = cnt;
255 int fTextureSamplerCnt = 0;
271 using FPCoordsMap = std::unordered_map<const GrFragmentProcessor*, FPCoords>;
282 const char* outputColor,
283 const char* outputCoverage,
371 const char* outputName,
442 struct TransformInfo {
454 std::unordered_map<const GrFragmentProcessor*, TransformInfo> fTransformVaryingsMap;
457 enum class BaseCoord { kNone, kLocal, kPosition };
494 bool fIsInitialized =
false;
507 return sizeof(
float);
509 return 2 *
sizeof(
float);
511 return 3 *
sizeof(
float);
513 return 4 *
sizeof(
float);
515 return sizeof(uint16_t);
517 return 2 *
sizeof(uint16_t);
519 return 4 *
sizeof(uint16_t);
521 return 2 *
sizeof(int32_t);
523 return 3 *
sizeof(int32_t);
525 return 4 *
sizeof(int32_t);
527 return 1 *
sizeof(char);
529 return 2 *
sizeof(char);
531 return 4 *
sizeof(char);
533 return 1 *
sizeof(char);
535 return 2 *
sizeof(char);
537 return 4 *
sizeof(char);
539 return 1 *
sizeof(char);
541 return 4 *
sizeof(char);
543 return 2 *
sizeof(int16_t);
545 return 4 *
sizeof(int16_t);
548 return 2 *
sizeof(uint16_t);
550 return sizeof(int32_t);
552 return sizeof(uint32_t);
554 return sizeof(uint16_t);
556 return 4 *
sizeof(uint16_t);
560#if defined(__clang__) || !defined(__GNUC__)
561 SK_ABORT(
"Unsupported type conversion");
static constexpr size_t GrVertexAttribTypeSize(GrVertexAttribType type)
@ kUShort_norm_GrVertexAttribType
@ kFloat2_GrVertexAttribType
@ kUShort2_GrVertexAttribType
@ kUInt_GrVertexAttribType
@ kUByte4_norm_GrVertexAttribType
@ kUByte_GrVertexAttribType
@ kShort2_GrVertexAttribType
@ kUShort4_norm_GrVertexAttribType
@ kInt_GrVertexAttribType
@ kByte_GrVertexAttribType
@ kByte4_GrVertexAttribType
@ kFloat3_GrVertexAttribType
@ kFloat_GrVertexAttribType
@ kByte2_GrVertexAttribType
@ kFloat4_GrVertexAttribType
@ kShort4_GrVertexAttribType
@ kUShort2_norm_GrVertexAttribType
@ kInt3_GrVertexAttribType
@ kHalf2_GrVertexAttribType
@ kHalf4_GrVertexAttribType
@ kUByte4_GrVertexAttribType
@ kUByte2_GrVertexAttribType
@ kInt4_GrVertexAttribType
@ kUByte_norm_GrVertexAttribType
@ kInt2_GrVertexAttribType
@ kHalf_GrVertexAttribType
static constexpr T SkAlign4(T x)
#define SK_ABORT(message,...)
static constexpr bool SkToBool(const T &x)
constexpr uint32_t SkToU32(S x)
void initImplicit(const Attribute *attrs, int count)
void addToKey(skgpu::KeyBuilder *b) const
void initExplicit(const Attribute *attrs, int count, size_t stride)
constexpr Attribute(const Attribute &)=default
GrShaderVar asShaderVar() const
std::optional< size_t > offset() const
constexpr GrVertexAttribType cpuType() const
static constexpr size_t AlignOffset(size_t offset)
constexpr bool isInitialized() const
Attribute & operator=(const Attribute &)=default
constexpr const char * name() const
constexpr size_t size() const
constexpr SkSLType gpuType() const
constexpr Attribute(const char *name, GrVertexAttribType cpuType, SkSLType gpuType)
constexpr Attribute()=default
constexpr Attribute(const char *name, GrVertexAttribType cpuType, SkSLType gpuType, size_t offset)
GrGLSLUniformHandler::SamplerHandle SamplerHandle
virtual ~ProgramImpl()=default
void emitTransformCode(GrGLSLVertexBuilder *vb, GrGLSLUniformHandler *uniformHandler)
static uint32_t ComputeMatrixKeys(const GrShaderCaps &shaderCaps, const SkMatrix &viewMatrix, const SkMatrix &localMatrix)
void setupUniformColor(GrGLSLFPFragmentBuilder *fragBuilder, GrGLSLUniformHandler *uniformHandler, const char *outputName, UniformHandle *colorUniform)
virtual void onEmitCode(EmitArgs &, GrGPArgs *)=0
static void WriteOutputPosition(GrGLSLVertexBuilder *, GrGLSLUniformHandler *, const GrShaderCaps &, GrGPArgs *, const char *posName, const SkMatrix &viewMatrix, UniformHandle *viewMatrixUniform)
GrGLSLProgramDataManager::UniformHandle UniformHandle
static uint32_t AddMatrixKeys(const GrShaderCaps &shaderCaps, uint32_t flags, const SkMatrix &viewMatrix, const SkMatrix &localMatrix)
static void WriteOutputPosition(GrGLSLVertexBuilder *, GrGPArgs *, const char *posName)
std::tuple< FPCoordsMap, GrShaderVar > emitCode(EmitArgs &, const GrPipeline &pipeline)
std::unordered_map< const GrFragmentProcessor *, FPCoords > FPCoordsMap
virtual void setData(const GrGLSLProgramDataManager &, const GrShaderCaps &, const GrGeometryProcessor &)=0
static void WriteLocalCoord(GrGLSLVertexBuilder *, GrGLSLUniformHandler *, const GrShaderCaps &, GrGPArgs *, GrShaderVar localVar, const SkMatrix &localMatrix, UniformHandle *localMatrixUniform)
static constexpr int kMatrixKeyBits
static uint32_t ComputeMatrixKey(const GrShaderCaps &caps, const SkMatrix &mat)
static void SetTransform(const GrGLSLProgramDataManager &, const GrShaderCaps &, const UniformHandle &uniform, const SkMatrix &matrix, SkMatrix *state=nullptr)
void reset(GrSamplerState, const GrBackendFormat &, const skgpu::Swizzle &)
TextureSampler & operator=(const TextureSampler &)=delete
GrTextureType textureType() const
TextureSampler(TextureSampler &&)=default
const GrBackendFormat & backendFormat() const
TextureSampler & operator=(TextureSampler &&)=default
TextureSampler(const TextureSampler &)=delete
bool isInitialized() const
const skgpu::Swizzle & swizzle() const
GrSamplerState samplerState() const
GrGeometryProcessor(ClassID)
int numVertexAttributes() const
void setInstanceAttributesWithImplicitOffsets(const Attribute *attrs, int attrCount)
virtual std::unique_ptr< ProgramImpl > makeProgramImpl(const GrShaderCaps &) const =0
const TextureSampler & textureSampler(int index) const
int numInstanceAttributes() const
void setVertexAttributes(const Attribute *attrs, int attrCount, size_t stride)
int numTextureSamplers() const
size_t vertexStride() const
static constexpr int kCoordTransformKeyBits
void setInstanceAttributes(const Attribute *attrs, int attrCount, size_t stride)
bool hasInstanceAttributes() const
const AttributeSet & vertexAttributes() const
void setTextureSamplerCnt(int cnt)
virtual const TextureSampler & onTextureSampler(int) const
const AttributeSet & instanceAttributes() const
virtual void addToKey(const GrShaderCaps &, skgpu::KeyBuilder *) const =0
static uint32_t ComputeCoordTransformsKey(const GrFragmentProcessor &fp)
void getAttributeKey(skgpu::KeyBuilder *b) const
size_t instanceStride() const
bool hasVertexAttributes() const
static Attribute MakeColorAttribute(const char *name, bool wideColor)
void setVertexAttributesWithImplicitOffsets(const Attribute *attrs, int attrCount)
GrProcessor(ClassID classID)
GrProcessor & operator=(const GrProcessor &)=delete
virtual const char * name() const =0
bool isScaleTranslate() const
bool hasPerspective() const
FlutterSemanticsFlag flags
unsigned useCenter Optional< SkMatrix > matrix
bool operator!=(C p1, const scoped_nsprotocol< C > &p2)
constexpr Color operator*(T value, const Color &c)
const GrShaderCaps * fShaderCaps
GrGLSLUniformHandler * fUniformHandler
GrGLSLFPFragmentBuilder * fFragBuilder
const GrGeometryProcessor & fGeomProc
const SamplerHandle * fTexSamplers
GrGLSLUniformHandler * fUniformHandler
GrGLSLFPFragmentBuilder * fFragBuilder
EmitArgs(GrGLSLVertexBuilder *vertBuilder, GrGLSLFPFragmentBuilder *fragBuilder, GrGLSLVaryingHandler *varyingHandler, GrGLSLUniformHandler *uniformHandler, const GrShaderCaps *caps, const GrGeometryProcessor &geomProc, const char *outputColor, const char *outputCoverage, const SamplerHandle *texSamplers)
GrGLSLVaryingHandler * fVaryingHandler
const char * fOutputCoverage
GrGLSLVertexBuilder * fVertBuilder
const GrShaderCaps * fShaderCaps
const char * fOutputColor
GrShaderVar coordsVarying
GrShaderVar fLocalCoordVar
GrShaderType fLocalCoordShader