diff options
| author | Omar Rizwan <omar@omar.website> | 2023-10-13 21:04:21 +0000 |
|---|---|---|
| committer | Omar Rizwan <omar@omar.website> | 2023-10-13 21:04:21 +0000 |
| commit | 2c2163396b0aec16bc608e2c6c329e1b4f2e0a56 (patch) | |
| tree | ab57e70a58b0a7aab78e665cfd24d0b4416a4607 /virtual-programs | |
| parent | image: Actually fix cache math (diff) | |
| download | folk-2c2163396b0aec16bc608e2c6c329e1b4f2e0a56.tar.gz folk-2c2163396b0aec16bc608e2c6c329e1b4f2e0a56.zip | |
display,mask-tags,fill: Add layer support
Only implemented minimum for mask-tags for now.
Diffstat (limited to 'virtual-programs')
| -rw-r--r-- | virtual-programs/display.folk | 39 | ||||
| -rw-r--r-- | virtual-programs/display/fill.folk | 4 | ||||
| -rw-r--r-- | virtual-programs/mask-tags.folk | 2 |
3 files changed, 25 insertions, 20 deletions
diff --git a/virtual-programs/display.folk b/virtual-programs/display.folk index ed3fb62d..826d37f0 100644 --- a/virtual-programs/display.folk +++ b/virtual-programs/display.folk @@ -8,19 +8,13 @@ namespace eval ::Display { regexp {mode "(\d+)x(\d+)"} [exec fbset] -> WIDTH HEIGHT } - proc drawOnTop {func args} { - set ::Display::LAYER 1 - uplevel [list $func {*}$args] - set ::Display::LAYER 0 - } - # Create proxy versions of drawing primitives for the main Folk # process (that will forward those draw commands to the display # subprocess). - foreach func {stroke circle text fillTriangle fillQuad fillPolygon} { + foreach func {stroke circle text fillTriangle fillQuad fillPolygon image} { proc $func args { set func [lindex [info level 0] 0] - error "$func has been removed; use GPU shaders" + error "$func has been removed; use GPU wishes/shaders" } } } @@ -98,11 +92,7 @@ Start process "display" { } Wish $::thisProcess receives statements like \ - [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/] + [list /someone/ wishes the GPU /...anything/] Wish $::thisProcess shares statements like \ [list /someone/ claims the display time is /displayTime/] @@ -112,21 +102,36 @@ Start process "display" { } while true { - set ::displayList [list] + set ::displayList [dict create] ;# Keys are layer numbers; values are lists of commands 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]] + dict lappend ::displayList 0 [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 arguments /args/ layer /layer/}] { + dict lappend ::displayList [dict get $match layer] \ + [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] + dict lappend ::displayList 0 [list Gpu::draw $pipeline {*}$instance] } } + foreach match [Statements::findMatches {/someone/ wishes the GPU draws pipeline /name/ with instances /instances/ layer /layer/}] { + set layer [dict get $match layer] + set pipeline [dict get $::pipelines [dict get $match name]] + foreach instance [dict get $match instances] { + dict lappend ::displayList $layer [list Gpu::draw $pipeline {*}$instance] + } + } + # TODO: Sort by layer set renderTime [baretime { Gpu::drawStart - foreach displayCommand $::displayList { {*}$displayCommand } + foreach layer [lsort -real [dict keys $::displayList]] { + set layerDisplayList [dict get $::displayList $layer] + foreach displayCommand $layerDisplayList { {*}$displayCommand } + } Gpu::drawEnd }] diff --git a/virtual-programs/display/fill.folk b/virtual-programs/display/fill.folk index dd9e199d..52039661 100644 --- a/virtual-programs/display/fill.folk +++ b/virtual-programs/display/fill.folk @@ -16,9 +16,9 @@ When /someone/ wishes to draw a triangle with /...options/ { When /someone/ wishes to draw a quad with /...options/ { dict with options { Wish the GPU draws pipeline "fillTriangle" with arguments \ - [list $p0 $p1 $p2 [getColor $color]] + [list $p0 $p1 $p2 [getColor $color]] layer $layer Wish the GPU draws pipeline "fillTriangle" with arguments \ - [list $p0 $p1 $p3 [getColor $color]] + [list $p0 $p1 $p3 [getColor $color]] layer $layer } } When /someone/ wishes to draw a polygon with /...options/ { diff --git a/virtual-programs/mask-tags.folk b/virtual-programs/mask-tags.folk index 6bf9d474..749bb26c 100644 --- a/virtual-programs/mask-tags.folk +++ b/virtual-programs/mask-tags.folk @@ -12,5 +12,5 @@ When tag /something/ has corners /corners/ { set p1 [lindex $corners 1] set p2 [lindex $corners 2] set p3 [lindex $corners 3] - Wish to draw a quad with p0 $p0 p1 $p1 p2 $p2 p3 $p3 color black + Wish to draw a quad with p0 $p0 p1 $p1 p2 $p2 p3 $p3 color black layer 1 }
\ No newline at end of file |
