Allow plugins to request loading models by path.

PiperOrigin-RevId: 936638157
Change-Id: If594c6a9abac5eb0d62e7d6dce4dc2f558989969
This commit is contained in:
Haroon Qureshi
2026-06-23 06:50:08 -07:00
committed by Copybara-Service
parent c499f7f2b0
commit 94a912d349
2 changed files with 5 additions and 2 deletions
+2 -1
View File
@@ -68,7 +68,8 @@ struct ModelPlugin final {
// Callback for when the plugin wants to load a new model. This function will
// return a buffer containing the model data as well as the content type of
// the buffer. Returns nullptr if no model needs to be loaded.s
// the buffer. If buf == model_name, then we assume that model_name stores the
// path of the model to load. Returns nullptr if no model needs to be loaded.
GetModelToLoadFn get_model_to_load = nullptr;
// Callback when a new model is loaded.
+3 -1
View File
@@ -421,7 +421,9 @@ void App::ProcessPendingLoads() {
const char* buf = plugin->get_model_to_load(
plugin, &size, content_type, sizeof(content_type), model_name,
sizeof(model_name));
if (buf && size) {
if (buf && buf == model_name) {
LoadModelFromFile(model_name);
} else if (buf && size) {
const std::byte* bytes = reinterpret_cast<const std::byte*>(buf);
LoadModelFromBuffer({bytes, bytes + size}, content_type, model_name);
}