From cc418917fcf9a95873401a3f59b68771c8c4a1e7 Mon Sep 17 00:00:00 2001 From: Omar Rizwan Date: Thu, 12 Oct 2023 12:42:56 -0400 Subject: text: Batch glyphs into one wish -- fixes performance. --- virtual-programs/display/text.folk | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'virtual-programs/display') 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 } } -- cgit v1.2.3