39 {
41 asset_name);
43 std::shared_ptr<AssetManager> asset_manager =
44 ui_dart_state->platform_configuration()->client()->GetAssetManager();
45
46 std::unique_ptr<fml::Mapping>
data = asset_manager->GetAsMapping(asset_name);
47 if (
data ==
nullptr) {
48 return std::string("Asset '") + asset_name + std::string("' not found");
49 }
50
51 auto runtime_stages =
53
54 if (runtime_stages.empty()) {
55 return std::string("Asset '") + asset_name +
56 std::string("' does not contain any shader data.");
57 }
58
60 ui_dart_state->GetRuntimeStageBackend();
61 std::shared_ptr<impeller::RuntimeStage> runtime_stage =
63 if (!runtime_stage) {
65 stream <<
"Asset '" << asset_name
66 << "' does not contain appropriate runtime stage data for current "
67 "backend ("
69 << "Found stages: ";
70 for (const auto& kvp : runtime_stages) {
71 if (kvp.second) {
73 }
74 }
76 }
77
78 int sampled_image_count = 0;
79 size_t other_uniforms_bytes = 0;
80 for (const auto& uniform_description : runtime_stage->GetUniforms()) {
81 if (uniform_description.type ==
83 sampled_image_count++;
84 } else {
85 other_uniforms_bytes += uniform_description.GetSize();
86 }
87 }
88
90
91
93 ui_dart_state->GetTaskRunners().GetRasterTaskRunner()->PostTask(
94 [runtime_stage, snapshot_controller]() {
95 if (!snapshot_controller) {
96 return;
97 }
98 snapshot_controller->CacheRuntimeStage(runtime_stage);
99 });
101 } else {
102 const auto& code_mapping = runtime_stage->GetCodeMapping();
103 auto code_size = code_mapping->GetSize();
104 const char* sksl =
105 reinterpret_cast<const char*>(code_mapping->GetMapping());
106
109 if (
result.effect ==
nullptr) {
110 return std::string("Invalid SkSL:\n") + sksl +
111 std::string(
"\nSkSL Error:\n") +
result.errorText.c_str();
112 }
114 }
115
119 }
120
124 return "Failed to set sampler count for fragment program.";
125 }
126
127 size_t rounded_uniform_bytes =
128 (other_uniforms_bytes +
sizeof(
float) - 1) & ~(
sizeof(
float) - 1);
129 size_t float_count = rounded_uniform_bytes /
sizeof(
float);
130
134 return "Failed to set uniform float count for fragment program.";
135 }
136
137 return "";
138}
static Result MakeForShader(SkString sksl, const Options &)
static sk_sp< DlRuntimeEffect > MakeSkia(const sk_sp< SkRuntimeEffect > &runtime_effect)
static sk_sp< DlRuntimeEffect > MakeImpeller(std::shared_ptr< impeller::RuntimeStage > runtime_stage)
fml::TaskRunnerAffineWeakPtr< SnapshotDelegate > GetSnapshotDelegate() const
static UIDartState * Current()
static Map DecodeRuntimeStages(const std::shared_ptr< fml::Mapping > &payload)
Dart_WeakPersistentHandle dart_wrapper() const
struct _Dart_Handle * Dart_Handle
DART_EXPORT void Dart_PropagateError(Dart_Handle handle)
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_SetField(Dart_Handle container, Dart_Handle name, Dart_Handle value)
DART_EXPORT Dart_Handle Dart_NewInteger(int64_t value)
DART_EXPORT bool Dart_IsError(Dart_Handle handle)
DART_EXPORT Dart_Handle Dart_HandleFromWeakPersistent(Dart_WeakPersistentHandle object)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
static std::string RuntimeStageBackendToString(impeller::RuntimeStageBackend backend)
Dart_Handle ToDart(const T &object)
#define FML_TRACE_EVENT(category_group, name,...)