summaryrefslogtreecommitdiffstats
path: root/virtual-programs
diff options
context:
space:
mode:
authorOmar Rizwan <omar@omar.website>2023-09-28 21:44:20 +0000
committerOmar Rizwan <omar@omar.website>2023-09-28 21:44:20 +0000
commit75403d327b82d10e62e3c32a47b98cc23ea095c8 (patch)
tree2c8106ce333eb8bc1853ae0df7ba1e3215ba1b0c /virtual-programs
parentcalibrate: Cleanup, kill tcls. (diff)
downloadfolk-75403d327b82d10e62e3c32a47b98cc23ea095c8.tar.gz
folk-75403d327b82d10e62e3c32a47b98cc23ea095c8.zip
display: Load images before starting Gpu frame
Diffstat (limited to 'virtual-programs')
-rw-r--r--virtual-programs/display.folk17
1 files changed, 13 insertions, 4 deletions
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 }