39 static std::string load_module_file(
const char* moduleFilename) {
43 std::ifstream in(std::string{modulePath.
c_str()});
44 std::string moduleSource{std::istreambuf_iterator<char>(in),
45 std::istreambuf_iterator<char>()};
52 #define MODULE_DATA(name) #name, load_module_file(#name ".sksl")
57 #if defined(SK_ENABLE_OPTIMIZE_SIZE) || !defined(SK_DEBUG)
58 #include "src/sksl/generated/sksl_shared.minified.sksl"
59 #include "src/sksl/generated/sksl_compute.minified.sksl"
60 #include "src/sksl/generated/sksl_frag.minified.sksl"
61 #include "src/sksl/generated/sksl_gpu.minified.sksl"
62 #include "src/sksl/generated/sksl_public.minified.sksl"
63 #include "src/sksl/generated/sksl_rt_shader.minified.sksl"
64 #include "src/sksl/generated/sksl_vert.minified.sksl"
65 #if defined(SK_GRAPHITE)
66 #include "src/sksl/generated/sksl_graphite_frag.minified.sksl"
67 #include "src/sksl/generated/sksl_graphite_vert.minified.sksl"
68 #include "src/sksl/generated/sksl_graphite_frag_es2.minified.sksl"
69 #include "src/sksl/generated/sksl_graphite_vert_es2.minified.sksl"
72 #include "src/sksl/generated/sksl_shared.unoptimized.sksl"
73 #include "src/sksl/generated/sksl_compute.unoptimized.sksl"
74 #include "src/sksl/generated/sksl_frag.unoptimized.sksl"
75 #include "src/sksl/generated/sksl_gpu.unoptimized.sksl"
76 #include "src/sksl/generated/sksl_public.unoptimized.sksl"
77 #include "src/sksl/generated/sksl_rt_shader.unoptimized.sksl"
78 #include "src/sksl/generated/sksl_vert.unoptimized.sksl"
79 #if defined(SK_GRAPHITE)
80 #include "src/sksl/generated/sksl_graphite_frag.unoptimized.sksl"
81 #include "src/sksl/generated/sksl_graphite_vert.unoptimized.sksl"
82 #include "src/sksl/generated/sksl_graphite_frag_es2.unoptimized.sksl"
83 #include "src/sksl/generated/sksl_graphite_vert_es2.unoptimized.sksl"
87 #define MODULE_DATA(name) #name, std::string(SKSL_MINIFIED_##name)
93#define TYPE(t) &BuiltinTypes::f ## t
134 TYPE(Sampler2D),
TYPE(SamplerExternalOES),
TYPE(Sampler2DRect),
136 TYPE(SubpassInput),
TYPE(SubpassInputMS),
139 TYPE(Texture2D_sample),
140 TYPE(Texture2D),
TYPE(ReadOnlyTexture2D),
TYPE(WriteOnlyTexture2D),
141 TYPE(GenTexture2D),
TYPE(ReadableTexture2D),
TYPE(WritableTexture2D),
182 fModuleLoader.
fMutex.acquire();
186 fModuleLoader.
fMutex.release();
207 const char* moduleName,
208 std::string moduleSource,
210 std::unique_ptr<Module> m =
compiler->compileModule(kind,
212 std::move(moduleSource),
216 SK_ABORT(
"Unable to load module %s", moduleName);
222 m->fElements.erase(std::remove_if(m->fElements.begin(), m->fElements.end(),
223 [](
const std::unique_ptr<ProgramElement>& element) {
224 switch (element->kind()) {
225 case ProgramElement::Kind::kFunction:
226 case ProgramElement::Kind::kGlobalVar:
227 case ProgramElement::Kind::kInterfaceBlock:
228 case ProgramElement::Kind::kStructDefinition:
232 case ProgramElement::Kind::kFunctionPrototype:
238 SkDEBUGFAILF(
"Unsupported element: %s\n",
239 element->description().c_str());
245 m->fElements.shrink_to_fit();
262 symbols->addWithoutOwnershipOrDie(types.
fVec2.get());
263 symbols->addWithoutOwnershipOrDie(types.
fVec3.get());
264 symbols->addWithoutOwnershipOrDie(types.
fVec4.get());
266 symbols->addWithoutOwnershipOrDie(types.
fIVec2.get());
267 symbols->addWithoutOwnershipOrDie(types.
fIVec3.get());
268 symbols->addWithoutOwnershipOrDie(types.
fIVec4.get());
270 symbols->addWithoutOwnershipOrDie(types.
fBVec2.get());
271 symbols->addWithoutOwnershipOrDie(types.
fBVec3.get());
272 symbols->addWithoutOwnershipOrDie(types.
fBVec4.get());
274 symbols->addWithoutOwnershipOrDie(types.
fMat2.get());
275 symbols->addWithoutOwnershipOrDie(types.
fMat3.get());
276 symbols->addWithoutOwnershipOrDie(types.
fMat4.get());
278 symbols->addWithoutOwnershipOrDie(types.
fMat2x2.get());
279 symbols->addWithoutOwnershipOrDie(types.
fMat2x3.get());
280 symbols->addWithoutOwnershipOrDie(types.
fMat2x4.get());
281 symbols->addWithoutOwnershipOrDie(types.
fMat3x2.get());
282 symbols->addWithoutOwnershipOrDie(types.
fMat3x3.get());
283 symbols->addWithoutOwnershipOrDie(types.
fMat3x4.get());
284 symbols->addWithoutOwnershipOrDie(types.
fMat4x2.get());
285 symbols->addWithoutOwnershipOrDie(types.
fMat4x3.get());
286 symbols->addWithoutOwnershipOrDie(types.
fMat4x4.get());
374#if defined(SK_GRAPHITE)
389#if defined(SK_GRAPHITE)
405#if defined(SK_GRAPHITE)
420#if defined(SK_GRAPHITE)
457 Variable::Storage::kGlobal));
#define SK_ABORT(message,...)
std::string SkGetExecutablePath()
#define MODULE_DATA(name)
static SkString Join(const char *rootPath, const char *relativePath)
static SkString Dirname(const char *fullPath)
const std::unique_ptr< Type > fMat4x4
const std::unique_ptr< Type > fMat4x2
const std::unique_ptr< Type > fSkCaps
const std::unique_ptr< Type > fMat2x4
const std::unique_ptr< Type > fMat2
const std::unique_ptr< Type > fBVec2
const std::unique_ptr< Type > fMat4
const std::unique_ptr< Type > fMat4x3
const std::unique_ptr< Type > fMat2x2
const std::unique_ptr< Type > fInvalid
const std::unique_ptr< Type > fBVec3
const std::unique_ptr< Type > fBVec4
const std::unique_ptr< Type > fVec4
const std::unique_ptr< Type > fVec3
const std::unique_ptr< Type > fIVec3
const std::unique_ptr< Type > fIVec4
const std::unique_ptr< Type > fIVec2
const std::unique_ptr< Type > fMat3
const std::unique_ptr< Type > fMat3x4
const std::unique_ptr< Type > fMat3x3
const std::unique_ptr< Type > fMat2x3
const std::unique_ptr< Type > fMat3x2
const std::unique_ptr< Type > fVec2
const Module * loadComputeModule(SkSL::Compiler *compiler)
const Module * loadPublicModule(SkSL::Compiler *compiler)
const Module * loadGPUModule(SkSL::Compiler *compiler)
const Module * loadSharedModule(SkSL::Compiler *compiler)
const Module * rootModule()
const Module * loadPrivateRTShaderModule(SkSL::Compiler *compiler)
const BuiltinTypes & builtinTypes()
const Module * loadGraphiteFragmentES2Module(SkSL::Compiler *compiler)
void addPublicTypeAliases(const SkSL::Module *module)
const Module * loadGraphiteFragmentModule(SkSL::Compiler *compiler)
const Module * loadGraphiteVertexModule(SkSL::Compiler *compiler)
static ModuleLoader Get()
const Module * loadFragmentModule(SkSL::Compiler *compiler)
const Module * loadGraphiteVertexES2Module(SkSL::Compiler *compiler)
ModuleLoader(ModuleLoader::Impl &)
const Module * loadVertexModule(SkSL::Compiler *compiler)
static std::unique_ptr< Type > MakeAliasType(std::string_view name, const Type &targetType)
static std::unique_ptr< Variable > Make(Position pos, Position modifiersPosition, const Layout &layout, ModifierFlags flags, const Type *type, std::string_view name, std::string mangledName, bool builtin, Storage storage)
const char * c_str() const
const std::unique_ptr< Type > BuiltinTypes::* BuiltinTypePtr
static constexpr BuiltinTypePtr kPrivateTypes[]
static std::unique_ptr< Module > compile_and_shrink(SkSL::Compiler *compiler, ProgramKind kind, const char *moduleName, std::string moduleSource, const Module *parent)
static constexpr BuiltinTypePtr kRootTypes[]
std::unique_ptr< const Module > fGraphiteVertexModule
std::unique_ptr< const Module > fGraphiteFragmentModule
std::unique_ptr< const Module > fGPUModule
std::unique_ptr< const Module > fGraphiteVertexES2Module
std::unique_ptr< const Module > fGraphiteFragmentES2Module
std::unique_ptr< const Module > fComputeModule
std::unique_ptr< const Module > fFragmentModule
std::unique_ptr< const Module > fVertexModule
std::unique_ptr< const Module > fPublicModule
std::unique_ptr< const Module > fSharedModule
void makeRootSymbolTable()
const BuiltinTypes fBuiltinTypes
std::unique_ptr< const Module > fRootModule
std::unique_ptr< const Module > fRuntimeShaderModule
std::unique_ptr< SymbolTable > fSymbols