fc0a1d2c964c — Leonard Ritter a month ago
* `draw` supports viewport
* moved func argument for both `dispatch` and `draw`
2 files changed, 14 insertions(+), 15 deletions(-)

M lib/tukan/FIR.sc
M testing/tukdag.sc
M lib/tukan/FIR.sc +6 -7
@@ 237,7 237,7 @@ define-type "imagestorage"  (RIFF "IMST"
     typecolor...
 define-type "undef"         (RIFF "UNDF") (tuple (type = AnyId))
     instrcolor...
-define-type "dispatch"      (RIFF "DISP") (tuple (func = AnyId) (x = AnyId) (y = AnyId) (z = AnyId) (bindings = (array AnyId)))
+define-type "dispatch"      (RIFF "DISP") (tuple (x = AnyId) (y = AnyId) (z = AnyId) (func = AnyId) (bindings = (array AnyId)))
     mutinstrcolor...
 define-type "rimage"        (RIFF "RIMG") (tuple (type = AnyId) (binding = u32))
     funccolor...

          
@@ 283,12 283,11 @@ define-type "block"         (RIFF "BLOK"
     instrcolor...
 define-type "draw"          (RIFF "DRAI")
     struct Draw plain
-        func : AnyId
-        x : AnyId; y : AnyId # viewport size
-        depthtest : DepthTestType
         mode : PrimitiveType
         count : AnyId
         instancecount : AnyId
+        viewport : AnyId # viewport rect
+        func : AnyId
         bindings : (array AnyId)
     mutinstrcolor...
 define-type "sampleimagelod" (RIFF "SILD") (tuple (source = AnyId) (uv = AnyId) (lod = AnyId))

          
@@ 1737,7 1736,7 @@ fn generate-IL (module rootid)
         case draw (self)
             let pgoffset = (get self.func)
             let pg = (getgluint ctx.drive-ctx pgoffset)
-            let x y = (get self.x self.y)
+            let vp = (get self.viewport)
             let count instancecount = (get self.count self.instancecount)
             let bindings = self.bindings
 

          
@@ 1770,7 1769,7 @@ fn generate-IL (module rootid)
 
             assign-bindings ctx module body retargs bindings vacount
 
-            sc_expression_append body `(Viewport 0 0 (x as i32) (y as i32))
+            sc_expression_append body `(Viewport (unpack (ivec4 vp)))
 
             sc_expression_append body drawcmd
             sc_expression_append body `(UseProgram 0)

          
@@ 2257,10 2256,10 @@ fn lower-FIR (module rootid)
         let bcount = ((countof bindings) as u32)
         let dispatchptr =
             'alloc module TypeId.typeid_dispatch bcount
-        dispatchptr.func = func
         dispatchptr.x = sx
         dispatchptr.y = sy
         dispatchptr.z = sz
+        dispatchptr.func = func
         let entries = dispatchptr.bindings
         for i id in (enumerate bindings u32)
             entries @ i = id

          
M testing/tukdag.sc +8 -8
@@ 23,7 23,7 @@ inline gen-level1-test-geometry ()
         \ fconst comp utof fadd fmul sin fvec2 fvec4 udiv add uconst image
         \ outputs output uvec2 fvec draw shaderfn position vertexid
         \ rattr wattr block fsub urem store clearimage cos instanceid undef
-        \ primitiveid unpack-comp rbind wbind
+        \ primitiveid unpack-comp rbind wbind uvec4
 
     let inpss = (input SystemKey.ScreenSize)
     let inpit = (input SystemKey.Iteration)

          
@@ 42,6 42,11 @@ inline gen-level1-test-geometry ()
     outputs
         output SystemKey.Screen
             draw
+                PrimitiveType.TriangleStrip
+                uconst 4; uconst 10
+                uvec4
+                    uconst 0; uconst 0
+                    comp 0 inpss; comp 1 inpss
                 shaderfn
                     do
                         let vid = (vertexid)

          
@@ 74,12 79,6 @@ inline gen-level1-test-geometry ()
                                 fmul f b
                                 a
                             colorattr_frag
-                comp 0 inpss
-                comp 1 inpss
-                DepthTestType.True
-                PrimitiveType.TriangleStrip
-                uconst 4
-                uconst 10
                 rbind angle u_it
                 wbind
                     clearimage

          
@@ 133,10 132,11 @@ inline gen-level1-test ()
     outputs
         output SystemKey.Screen
             # indirect dispatch
-            dispatch func
+            dispatch
                 udiv (add (comp 0 inpss) (uconst 7)) (uconst 8)
                 udiv (add (comp 1 inpss) (uconst 7)) (uconst 8)
                 uconst 1
+                func
                 rbind (utof (comp 0 inpss)) ssx
                 rbind (utof (comp 1 inpss)) ssy
                 rbind z u_it