29 uint32_t
key =
static_cast<uint32_t
>(
fp.sampleUsage().kind()) << 1;
31 if (
fp.sampleUsage().hasPerspective()) {
38 b->appendComment(
"vertex attributes");
40 b->appendComment(
"instance attributes");
51 return requestedFilter;
63 fSamplerState = samplerState;
68 fBackendFormat = backendFormat;
70 fIsInitialized =
true;
77std::tuple<ProgramImpl::FPCoordsMap, GrShaderVar>
85 gpArgs.fLocalCoordShader,
86 gpArgs.fLocalCoordVar,
95 gpArgs.fPositionVar.getType());
97 args.fVaryingHandler->setNoPerspective();
100 return {transformMap, gpArgs.fLocalCoordVar};
117 auto baseLocalCoordFSVar = [&, baseLocalCoordVarying =
GrGLSLVarying()]()
mutable {
119 return localCoordsVar;
126 varyingHandler->
addVarying(
"LocalCoord", &baseLocalCoordVarying);
128 baseLocalCoordVarying.vsOut(),
131 return baseLocalCoordVarying.fsInVar();
140 auto liftTransforms = [&, traversalIndex = 0](
145 int lastMatrixTraversalIndex = -1,
146 BaseCoord baseCoord = BaseCoord::kLocal)
mutable ->
void {
149 switch (
fp.sampleUsage().kind()) {
158 hasPerspective |=
fp.sampleUsage().hasPerspective();
160 lastMatrixTraversalIndex = traversalIndex;
164 lastMatrixFP =
nullptr;
165 lastMatrixTraversalIndex = -1;
166 baseCoord = BaseCoord::kPosition;
178 auto& [varyingFSVar, hasCoordsParam] =
result[&
fp];
179 hasCoordsParam =
fp.usesSampleCoordsDirectly();
185 if (
fp.usesSampleCoordsDirectly() &&
186 (baseCoord == BaseCoord::kLocal ||
187 (baseCoord == BaseCoord::kPosition && lastMatrixFP && canUsePosition))) {
192 varyingFSVar = baseLocalCoordFSVar();
196 auto& [varying, inputCoords, varyingIdx] = fTransformVaryingsMap[lastMatrixFP];
200 lastMatrixTraversalIndex);
202 inputCoords = baseCoord == BaseCoord::kLocal ? localCoordsVar : positionVar;
203 varyingIdx = lastMatrixTraversalIndex;
205 SkASSERT(varyingIdx == lastMatrixTraversalIndex);
207 varyingFSVar = varying.fsInVar();
209 hasCoordsParam =
false;
212 for (
int c = 0; c <
fp.numChildProcessors(); ++c) {
213 if (
auto* child =
fp.childProcessor(c)) {
218 lastMatrixTraversalIndex,
223 !child->sampleUsage().isExplicit() &&
224 !child->sampleUsage().isFragCoord() &&
225 result[child].hasCoordsParam;
241 using FPAndInfo = std::tuple<const GrFragmentProcessor*, TransformInfo>;
242 auto compare = [](
const FPAndInfo&
a,
const FPAndInfo&
b) {
245 std::priority_queue<FPAndInfo, std::vector<FPAndInfo>,
decltype(
compare)> pq(
compare);
246 std::for_each(fTransformVaryingsMap.begin(), fTransformVaryingsMap.end(), [&pq](
auto entry) {
249 for (; !pq.empty(); pq.pop()) {
250 const auto& [
fp,
info] = pq.top();
252 SkASSERT(
fp->sampleUsage().isUniformMatrix());
264 if (
auto iter = fTransformVaryingsMap.find(
base); iter != fTransformVaryingsMap.end()) {
268 inputCoords = iter->second.varying.vsOutVar();
270 }
else if (
base->sampleUsage().isUniformMatrix()) {
278 }
else if (
base->sampleUsage().isFragCoord()) {
284 SkASSERT(
base->sampleUsage().isPassThrough() || !
base->sampleUsage().isSampled());
293 inputStr = inputCoords.
getName();
300 info.varying.vsOut(),
301 transformExpression.
c_str(),
305 info.varying.vsOut(),
306 transformExpression.
c_str(),
312 info.varying.vsOut(),
313 transformExpression.
c_str(),
320 fTransformVaryingsMap.clear();
325 const char* outputName,
328 const char* stagedLocalVarName;
329 *colorUniform = uniformHandler->
addUniform(
nullptr,
333 &stagedLocalVarName);
334 fragBuilder->
codeAppendf(
"%s = %s;", outputName, stagedLocalVarName);
336 fragBuilder->
codeAppendf(
"%s = max(%s, half4(0));", outputName, outputName);
380 const char* matrixName,
393 const char* mangledMatrixName;
394 *matrixUniform = uniformHandler->
addUniform(
nullptr,
403 if (useCompactTransform) {
404 vertBuilder->
codeAppendf(
"float3 %s = %s.xz1 * %s + %s.yw0;\n",
418 if (
matrix.hasPerspective()) {
421 vertBuilder->
codeAppendf(
"float3 %s = (%s * %s.xy1);",
428 if (useCompactTransform) {
429 vertBuilder->
codeAppendf(
"float2 %s = %s.xz * %s + %s.yw;\n",
435 vertBuilder->
codeAppendf(
"float2 %s = float3x2(%s) * %s.xy1;\n",
440 vertBuilder->
codeAppendf(
"float2 %s = (%s * %s.xy1).xy;\n",
450 const char* posName) {
462 UniformHandle* viewMatrixUniform) {
470 &gpArgs->fPositionVar,
497 if (fCurr->offset().has_value()) {
500 return Attribute(fCurr->name(), fCurr->cpuType(), fCurr->gpuType(), fImplicitOffset);
503void AttributeSet::Iter::operator++() {
508 this->skipUninitialized();
512void AttributeSet::Iter::skipUninitialized() {
516 while (!fCurr->isInitialized()) {
528 if (attrs[
i].isInitialized()) {
550 int rawCount =
SkAbs32(fRawCount);
552 b->
addBits(16, rawCount,
"attribute count");
553 size_t implicitOffset = 0;
554 for (
int i = 0;
i < rawCount; ++
i) {
564 if (attr.
offset().has_value()) {
571 b->addBits(16,
static_cast<uint16_t
>(
offset),
"attrOffset");
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
static void write_passthrough_vertex_position(GrGLSLVertexBuilder *vertBuilder, const GrShaderVar &inPos, GrShaderVar *outPos)
GrGeometryProcessor::Attribute Attribute
GrGeometryProcessor::ProgramImpl ProgramImpl
static GrSamplerState::Filter clamp_filter(GrTextureType type, GrSamplerState::Filter requestedFilter)
static void write_vertex_position(GrGLSLVertexBuilder *vertBuilder, GrGLSLUniformHandler *uniformHandler, const GrShaderCaps &shaderCaps, const GrShaderVar &inPos, const SkMatrix &matrix, const char *matrixName, GrShaderVar *outPos, ProgramImpl::UniformHandle *matrixUniform)
GrGeometryProcessor::AttributeSet AttributeSet
static const int kGrVertexAttribTypeCount
static bool GrTextureTypeHasRestrictedSampling(GrTextureType type)
static const int kSkSLTypeCount
static constexpr bool SkSLTypeIsFloatType(SkSLType type)
static constexpr int SkSLTypeVecLength(SkSLType type)
static int32_t SkAbs32(int32_t value)
SK_API SkString SkStringPrintf(const char *format,...) SK_PRINTF_LIKE(1
Creates a new string and writes into it using a printf()-style format.
constexpr uint16_t SkToU16(S x)
GrGLSLUniformHandler::UniformHandle UniformHandle
const GrShaderCaps * shaderCaps() const
virtual void set4fv(UniformHandle, int arrayCount, const float v[]) const =0
void setSkMatrix(UniformHandle, const SkMatrix &) const
void codeAppend(const char *str)
void codeAppendf(const char format[],...) SK_PRINTF_LIKE(2
SkString newTmpVarName(const char *suffix)
GrGLSLProgramBuilder * getProgramBuilder()
void addVarying(const char *name, GrGLSLVarying *varying, Interpolation=Interpolation::kInterpolated)
void emitNormalizedSkPosition(const char *devPos, SkSLType devPosType=SkSLType::kFloat2)
void initImplicit(const Attribute *attrs, int count)
void addToKey(skgpu::KeyBuilder *b) const
void initExplicit(const Attribute *attrs, int count, size_t stride)
std::optional< size_t > offset() const
constexpr GrVertexAttribType cpuType() const
static constexpr size_t AlignOffset(size_t offset)
constexpr bool isInitialized() const
constexpr const char * name() const
constexpr size_t size() const
constexpr SkSLType gpuType() const
void emitTransformCode(GrGLSLVertexBuilder *vb, GrGLSLUniformHandler *uniformHandler)
void setupUniformColor(GrGLSLFPFragmentBuilder *fragBuilder, GrGLSLUniformHandler *uniformHandler, const char *outputName, UniformHandle *colorUniform)
virtual void onEmitCode(EmitArgs &, GrGPArgs *)=0
GrGLSLProgramDataManager::UniformHandle UniformHandle
static void WriteOutputPosition(GrGLSLVertexBuilder *, GrGPArgs *, const char *posName)
std::tuple< FPCoordsMap, GrShaderVar > emitCode(EmitArgs &, const GrPipeline &pipeline)
std::unordered_map< const GrFragmentProcessor *, FPCoords > FPCoordsMap
static void WriteLocalCoord(GrGLSLVertexBuilder *, GrGLSLUniformHandler *, const GrShaderCaps &, GrGPArgs *, GrShaderVar localVar, const SkMatrix &localMatrix, UniformHandle *localMatrixUniform)
static void SetTransform(const GrGLSLProgramDataManager &, const GrShaderCaps &, const UniformHandle &uniform, const SkMatrix &matrix, SkMatrix *state=nullptr)
void reset(GrSamplerState, const GrBackendFormat &, const skgpu::Swizzle &)
const GrBackendFormat & backendFormat() const
const skgpu::Swizzle & swizzle() const
GrGeometryProcessor(ClassID)
const TextureSampler & textureSampler(int index) const
int numTextureSamplers() const
virtual const TextureSampler & onTextureSampler(int) const
static uint32_t ComputeCoordTransformsKey(const GrFragmentProcessor &fp)
void getAttributeKey(skgpu::KeyBuilder *b) const
int numFragmentProcessors() const
const GrFragmentProcessor & getFragmentProcessor(int idx) const
constexpr WrapMode wrapModeX() const
constexpr Filter filter() const
constexpr MipmapMode mipmapMode() const
constexpr WrapMode wrapModeY() const
void set(SkSLType type, const char *name)
const SkString & getName() const
static bool CheapEqual(const SkMatrix &a, const SkMatrix &b)
static const char * MatrixUniformName()
const char * c_str() const
void void void appendf(const char format[],...) SK_PRINTF_LIKE(2
virtual void addBits(uint32_t numBits, uint32_t val, std::string_view label)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
static float min(float r, float g, float b)
unsigned useCenter Optional< SkMatrix > matrix
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
constexpr Color operator*(T value, const Color &c)
const myers::Point & get< 1 >(const myers::Segment &s)
int compare(const void *untyped_lhs, const void *untyped_rhs)
GrShaderVar fLocalCoordVar
bool fMustObfuscateUniformColor
bool fNonsquareMatrixSupport