From 75403d327b82d10e62e3c32a47b98cc23ea095c8 Mon Sep 17 00:00:00 2001 From: Omar Rizwan Date: Thu, 28 Sep 2023 17:44:20 -0400 Subject: display: Load images before starting Gpu frame --- virtual-programs/display.folk | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'virtual-programs') diff --git a/virtual-programs/display.folk b/virtual-programs/display.folk index 0bb0b88e..268e462d 100644 --- a/virtual-programs/display.folk +++ b/virtual-programs/display.folk @@ -334,15 +334,18 @@ On process { return vec4(0.0, 0.0, 0.0, 0.0); }] variable imCache [dict create] - proc image {x y im radians {scale 1.0}} { - # TODO: Implement scale. - # TODO: Free images from cache. - variable image + proc checkImCacheAndCopyIfNeeded {im} { variable imCache if {![dict exists $imCache $im]} { set gim [Gpu::ImageManager::copyImageToGpu $im] dict set imCache $im $gim } + } + proc image {x y im radians {scale 1.0}} { + # TODO: Implement scale. + # TODO: Free images from cache. + variable image + variable imCache set gim [dict get $imCache $im] Gpu::draw $image $gim [list [::image width $im] [::image height $im]] \ [list $x $y] $radians $scale @@ -386,6 +389,12 @@ On process { } set displayCommands [lmap sublist [lsort -command lcomp $displayList] {lindex $sublist 1}] + foreach command $displayCommands { + if {[lindex $command 0] eq "Display::image"} { + set im [lindex $command 3] + Display::checkImCacheAndCopyIfNeeded $im + } + } set renderTime [baretime { Display::start foreach command $displayCommands { {*}$command } -- cgit v1.2.3