Skip to content
This repository was archived by the owner on Sep 8, 2024. It is now read-only.
Open
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
8 changes: 7 additions & 1 deletion comfy-core/src/global_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ static UNPAUSED_TIME: AtomicU64 =

static ASSETS_QUEUED: AtomicUsize = AtomicUsize::new(0);
static ASSETS_LOADED: AtomicUsize = AtomicUsize::new(0);
static ASSETS_LOADED_THIS_FRAME: AtomicUsize = AtomicUsize::new(0);

/// Returns the total number of assets queued for loading
/// by the parallel asset loader.
Expand All @@ -46,9 +47,14 @@ pub fn assets_loaded() -> usize {
}

pub fn inc_assets_loaded(newly_loaded_count: usize) {
ASSETS_LOADED.fetch_add(newly_loaded_count, Ordering::SeqCst);
ASSETS_LOADED_THIS_FRAME.fetch_add(newly_loaded_count, Ordering::SeqCst);
}

pub fn apply_assets_loaded_this_frame() {
let assets_loaded_this_frame =
ASSETS_LOADED_THIS_FRAME.swap(0, Ordering::SeqCst);
ASSETS_LOADED.fetch_add(assets_loaded_this_frame, Ordering::SeqCst);
}

pub fn frame_time() -> f32 {
f32::from_bits(FRAME_TIME.load(Ordering::SeqCst))
Expand Down
1 change: 1 addition & 0 deletions comfy/src/update_stages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ fn run_mid_update_stages(c: &mut EngineContext) {

// TODO: Some of the ordering in the update stages is definitely incorrect.
pub(crate) fn run_late_update_stages(c: &mut EngineContext, delta: f32) {
apply_assets_loaded_this_frame();
update_animated_sprites(c);
update_trails(c);
update_drawables(c);
Expand Down