constexpr int SK_FRAGCOLOR_BUILTIN = 10001;
constexpr int SK_LASTFRAGCOLOR_BUILTIN = 10008;
constexpr int SK_SECONDARYFRAGCOLOR_BUILTIN = 10012;
constexpr int SK_FRAGCOORD_BUILTIN = 15;
constexpr int SK_CLOCKWISE_BUILTIN = 17;
constexpr int SK_SAMPLEMASKIN_BUILTIN = 20;
constexpr int SK_SAMPLEMASK_BUILTIN = 10020;
constexpr int SK_VERTEXID_BUILTIN = 42;
constexpr int SK_INSTANCEID_BUILTIN = 43;
constexpr int SK_POSITION_BUILTIN = 0;
constexpr int SK_POINTSIZE_BUILTIN = 1;
constexpr int SK_NUMWORKGROUPS_BUILTIN = 24;
constexpr int SK_WORKGROUPID_BUILTIN = 26;
constexpr int SK_LOCALINVOCATIONID_BUILTIN = 27;
constexpr int SK_GLOBALINVOCATIONID_BUILTIN = 28;
constexpr int SK_LOCALINVOCATIONINDEX_BUILTIN = 29;
namespace SkSL {
class Inliner; struct Module; enumclass ModuleType : int8_t; class Pool; struct ProgramConfig; class ProgramUsage; enumclass ProgramKind : int8_t; struct Program; class ProgramElement; struct ProgramSettings; class SymbolTable;
/** * Main compiler entry point. The compiler parses the SkSL text directly into a tree of IRNodes, * while performing basic optimizations such as constant-folding and dead-code elimination. Then the * Program is passed into a CodeGenerator to produce compiled output. * * See the README for information about SkSL.
*/ class SK_API Compiler { public: inlinestatic constexpr constchar FRAGCOLOR_NAME[] = "sk_FragColor"; inlinestatic constexpr constchar RTADJUST_NAME[] = "sk_RTAdjust"; inlinestatic constexpr constchar POSITION_NAME[] = "sk_Position"; inlinestatic constexpr constchar POISON_TAG[] = "<POISON>";
/** * Gets a float4 that adjusts the position from Skia device coords to normalized device coords, * used to populate sk_RTAdjust. Assuming the transformed position, pos, is a homogeneous * float4, the vec, v, is applied as such: * float4((pos.xy * v.xz) + sk_Position.ww * v.yw, 0, pos.w);
*/ static std::array<float, 4> GetRTAdjustVector(SkISize rtDims, bool flipY) {
std::array<float, 4> result;
result[0] = 2.f/rtDims.width();
result[2] = 2.f/rtDims.height();
result[1] = -1.f;
result[3] = -1.f; if (flipY) {
result[2] = -result[2];
result[3] = -result[3];
} return result;
}
/** * Uniform values used by the compiler to implement origin-neutral dFdy, sk_Clockwise, and * sk_FragCoord.
*/ static std::array<float, 2> GetRTFlipVector(int rtHeight, bool flipY) {
std::array<float, 2> result;
result[0] = flipY ? rtHeight : 0.f;
result[1] = flipY ? -1.f : 1.f; return result;
}
/** * Allows optimization settings to be unilaterally overridden. This is meant to allow tools like * Viewer or Nanobench to override the compiler's ProgramSettings and ShaderCaps for debugging.
*/ enumclass OverrideFlag {
kDefault,
kOff,
kOn,
}; staticvoid EnableOptimizer(OverrideFlag flag) { sOptimizer = flag; } staticvoid EnableInliner(OverrideFlag flag) { sInliner = flag; }
/** Optimize a module at minification time, before writing it out. */ bool optimizeModuleBeforeMinifying(ProgramKind kind, Module& module, bool shrinkSymbols);
/** Run the inliner on a program which was compiled earlier (with inlining turned off). */ void runInliner(Program& program);
private: class CompilerErrorReporter : public ErrorReporter { public:
CompilerErrorReporter(Compiler* compiler)
: fCompiler(*compiler) {}
void handleError(std::string_view msg, Position pos) override {
fCompiler.handleError(msg, pos);
}
private:
Compiler& fCompiler;
};
/** Updates ProgramSettings to eliminate contradictions and to honor the ProgramKind. */ staticvoid FinalizeSettings(ProgramSettings* settings, ProgramKind kind);
/** Prepares the Context for compilation of a program or module. */ void initializeContext(const SkSL::Module* module,
ProgramKind kind,
ProgramSettings settings,
std::string_view source,
ModuleType moduleType);
/** Cleans up the Context post-compilation. */ void cleanupContext();
/** * Returns all global elements (functions and global variables) as a self-contained Program. * The optional source string is retained as the program's source.
*/
std::unique_ptr<SkSL::Program> releaseProgram(
std::unique_ptr<std::string> source,
std::vector<std::unique_ptr<SkSL::ProgramElement>> programElements);
/** Optimize every function in the program. */ bool optimize(Program& program);
/** Performs final checks to confirm that a fully-assembled/optimized is valid. */ bool finalize(Program& program);
/** Optimize a module at Skia runtime, after loading it. */ bool optimizeModuleAfterLoading(ProgramKind kind, Module& module);
/** Flattens out function calls when it is safe to do so. */ bool runInliner(Inliner* inliner, const std::vector<std::unique_ptr<ProgramElement>>& elements,
SymbolTable* symbols,
ProgramUsage* usage);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.