Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid regressing in progress reporting in resource load #86845

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions core/io/resource_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,20 +520,20 @@ Ref<ResourceLoader::LoadToken> ResourceLoader::_load_start(const String &p_path,
float ResourceLoader::_dependency_get_progress(const String &p_path) {
if (thread_load_tasks.has(p_path)) {
ThreadLoadTask &load_task = thread_load_tasks[p_path];
float current_progress = 0.0;
int dep_count = load_task.sub_tasks.size();
if (dep_count > 0) {
float dep_progress = 0;
for (const String &E : load_task.sub_tasks) {
dep_progress += _dependency_get_progress(E);
current_progress += _dependency_get_progress(E);
}
dep_progress /= float(dep_count);
dep_progress *= 0.5;
dep_progress += load_task.progress * 0.5;
return dep_progress;
current_progress /= float(dep_count);
current_progress *= 0.5;
current_progress += load_task.progress * 0.5;
} else {
return load_task.progress;
current_progress = load_task.progress;
}

load_task.max_reported_progress = MAX(load_task.max_reported_progress, current_progress);
return load_task.max_reported_progress;
} else {
return 1.0; //assume finished loading it so it no longer exists
}
Expand Down
3 changes: 2 additions & 1 deletion core/io/resource_loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ class ResourceLoader {
String remapped_path;
String dependent_path;
String type_hint;
float progress = 0.0;
float progress = 0.0f;
float max_reported_progress = 0.0f;
ThreadLoadStatus status = THREAD_LOAD_IN_PROGRESS;
ResourceFormatLoader::CacheMode cache_mode = ResourceFormatLoader::CACHE_MODE_REUSE;
Error error = OK;
Expand Down
Loading