summaryrefslogtreecommitdiffstats
path: root/virtual-programs
diff options
context:
space:
mode:
authorOmar Rizwan <omar@omar.website>2023-10-12 16:42:56 +0000
committerOmar Rizwan <omar@omar.website>2023-10-12 16:42:56 +0000
commitcc418917fcf9a95873401a3f59b68771c8c4a1e7 (patch)
treeeb9ab1f520cabcbe3f6665002ec4bf6f64ee0665 /virtual-programs
parenttext: Draw with wish; stops the blinking bug. (diff)
downloadfolk-cc418917fcf9a95873401a3f59b68771c8c4a1e7.tar.gz
folk-cc418917fcf9a95873401a3f59b68771c8c4a1e7.zip
text: Batch glyphs into one wish -- fixes performance.
Diffstat (limited to 'virtual-programs')
-rw-r--r--virtual-programs/display.folk8
-rw-r--r--virtual-programs/display/text.folk7
2 files changed, 14 insertions, 1 deletions
diff --git a/virtual-programs/display.folk b/virtual-programs/display.folk
index 07b94825..387d300a 100644
--- a/virtual-programs/display.folk
+++ b/virtual-programs/display.folk
@@ -101,6 +101,8 @@ Start process "display" {
[list /someone/ wishes the GPU compiles pipeline /name/ /source/]
Wish $::thisProcess receives statements like \
[list /someone/ wishes the GPU draws pipeline /name/ with arguments /args/]
+ Wish $::thisProcess receives statements like \
+ [list /someone/ wishes the GPU draws pipeline /name/ with instances /args/]
Wish $::thisProcess shares statements like \
[list /someone/ claims the display time is /displayTime/]
@@ -115,6 +117,12 @@ Start process "display" {
foreach match [Statements::findMatches {/someone/ wishes the GPU draws pipeline /name/ with arguments /args/}] {
lappend ::displayList [list Gpu::draw [dict get $::pipelines [dict get $match name]] {*}[dict get $match args]]
}
+ foreach match [Statements::findMatches {/someone/ wishes the GPU draws pipeline /name/ with instances /instances/}] {
+ set pipeline [dict get $::pipelines [dict get $match name]]
+ foreach instance [dict get $match instances] {
+ lappend ::displayList [list Gpu::draw $pipeline {*}$instance]
+ }
+ }
set renderTime [baretime {
Gpu::drawStart
diff --git a/virtual-programs/display/text.folk b/virtual-programs/display/text.folk
index 992e77b1..a6c828b9 100644
--- a/virtual-programs/display/text.folk
+++ b/virtual-programs/display/text.folk
@@ -124,6 +124,7 @@ On process "display" {
set x $x0; set y $y0
set lineNum 0
+ set instances [list]
for {set i 0} {$i < [string length $text]} {incr i} {
set char [string index $text $i]
if {$char eq "\n"} {
@@ -140,12 +141,16 @@ On process "display" {
}
lassign $glyphInfo advance planeBounds atlasBounds
if {$char ne " "} {
- Wish the GPU draws pipeline "glyph" with arguments \
+ lappend instances \
[list $fontAtlas $fontAtlasSize \
$atlasBounds $planeBounds [list $x $y] $radians $em]
}
lassign [vec2 add [list $x $y] \
[vec2 rotate [list [* $advance $em] 0] $radians]] x y
}
+
+ # We need to batch into one wish so we don't deal with n^2
+ # checks for existing statements for n glyphs.
+ Wish the GPU draws pipeline "glyph" with instances $instances
}
}