summaryrefslogtreecommitdiffstats
path: root/virtual-programs
diff options
context:
space:
mode:
authorOmar Rizwan <omar@omar.website>2023-10-06 21:57:29 +0000
committerOmar Rizwan <omar@omar.website>2023-10-06 21:57:29 +0000
commit7b7a4b895f99a305263e03687b4f7cfa3065dd73 (patch)
treea83f74259a3ad65744f886baf9cde6b767bc961a /virtual-programs
parentdisplay: WIP: Refactor into files; use wishes, not Display:: (diff)
downloadfolk-7b7a4b895f99a305263e03687b4f7cfa3065dd73.tar.gz
folk-7b7a4b895f99a305263e03687b4f7cfa3065dd73.zip
display/text: Write glyphs straight to displaylist. Hack, but faster
Diffstat (limited to 'virtual-programs')
-rw-r--r--virtual-programs/display.folk8
-rw-r--r--virtual-programs/display/text.folk16
2 files changed, 13 insertions, 11 deletions
diff --git a/virtual-programs/display.folk b/virtual-programs/display.folk
index 0cfc63b2..07b94825 100644
--- a/virtual-programs/display.folk
+++ b/virtual-programs/display.folk
@@ -110,13 +110,15 @@ Start process "display" {
}
while true {
+ set ::displayList [list]
Step
+ 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]]
+ }
set renderTime [baretime {
Gpu::drawStart
- foreach match [Statements::findMatches {/someone/ wishes the GPU draws pipeline /name/ with arguments /args/}] {
- Gpu::draw [dict get $::pipelines [dict get $match name]] {*}[dict get $match args]
- }
+ foreach displayCommand $::displayList { {*}$displayCommand }
Gpu::drawEnd
}]
diff --git a/virtual-programs/display/text.folk b/virtual-programs/display/text.folk
index 3f2b4b5c..412ce266 100644
--- a/virtual-programs/display/text.folk
+++ b/virtual-programs/display/text.folk
@@ -38,12 +38,12 @@ On process "display" {
set median [Gpu::fn {float r float g float b} float {
return max(min(r, g), min(max(r, g), b));
}]
- dict set ::pipelines "glyph" [Gpu::pipeline \
- {sampler2D atlas vec2 atlasSize
- vec4 atlasGlyphBounds
- vec4 planeGlyphBounds
- vec2 pos float radians float em
- fn rotate} {
+ set glyph [Gpu::pipeline \
+ {sampler2D atlas vec2 atlasSize
+ vec4 atlasGlyphBounds
+ vec4 planeGlyphBounds
+ vec2 pos float radians float em
+ fn rotate} {
float left = planeGlyphBounds[0] * em;
float bottom = planeGlyphBounds[1] * em;
float right = planeGlyphBounds[2] * em;
@@ -139,8 +139,8 @@ On process "display" {
}
lassign $glyphInfo advance planeBounds atlasBounds
if {$char ne " "} {
- Wish the GPU draws pipeline "glyph" with arguments \
- [list $fontAtlas $fontAtlasSize \
+ lappend ::displayList \
+ [list Gpu::draw $glyph $fontAtlas $fontAtlasSize \
$atlasBounds $planeBounds [list $x $y] $radians $em]
}
lassign [vec2 add [list $x $y] \