f41db7e08a7c — Leonard Ritter a month ago
* renamed image types
2 files changed, 86 insertions(+), 81 deletions(-)

M lib/tukan/FIR.sc
M testing/tukdag.sc
M lib/tukan/FIR.sc +76 -71
@@ 207,23 207,6 @@ define-type "sample" (RIFF "SAMP") (tupl
 ################################################################################
 
 define-type "uniform"       (RIFF "UNIF") (tuple (type = AnyId) (location = u32))
-enum ImageFlags : u32
-    none = 0:u32
-    arrayed = 1:u32
-    multisampled = 2:u32
-    arrayed-multisampled = 3:u32
-struct ImageType plain
-    type : AnyId # vector type
-    dim : ImageDim
-    format : ImageFormat
-    flags : ImageFlags
-
-    let array? = (Accessor (inline (self key) ((self.flags & ImageFlags.arrayed) != 0)))
-    let ms? = (Accessor (inline (self key) ((self.flags & ImageFlags.multisampled) != 0)))
-define-type "image"         (RIFF "IMGT") ImageType
-    typecolor...
-define-type "sampler"       (RIFF "SMPT") ImageType
-    typecolor...
 define-type "wimage"        (RIFF "WIMG") (tuple (type = AnyId) (binding = u32))
     funccolor...
 define-type "load"          (RIFF "LOAD") (tuple (pointer = AnyId))

          
@@ 238,8 221,6 @@ define-type "computefn"     (RIFF "CMFN"
     funccolor...
 define-type "rbind"         (RIFF "RBND") (tuple (source = AnyId) (target = AnyId))
 define-type "wbind"         (RIFF "WBND") (tuple (source = AnyId) (target = AnyId))
-define-type "imagestorage"  (RIFF "IMST") (tuple (type = AnyId) (x = u32) (y = u32) (z = u32) (levels = u32) (samples = u32))
-    typecolor...
 define-type "undef"         (RIFF "UNDF") (tuple (type = AnyId))
     instrcolor...
 define-type "dispatch"      (RIFF "DISP") (tuple (x = AnyId) (y = AnyId) (z = AnyId) (func = AnyId) (bindings = (array AnyId)))

          
@@ 256,8 237,6 @@ define-type "mssbo"         (RIFF "MSBO"
     funccolor...
 define-type "store"         (RIFF "STOR") (tuple (value = AnyId) (pointer = AnyId))
     mutinstrcolor...
-define-type "bufferstorage" (RIFF "BFST") (tuple (size = u32))
-    funccolor...
 define-type "idispatch"     (RIFF "IDSP") (tuple (func = AnyId) (size = AnyId) (sources = AnyId) (sinks = AnyId))
     mutinstrcolor...
 define-type "clearimage"    (RIFF "CLRS")

          
@@ 301,29 280,10 @@ define-type "sampleimagelod" (RIFF "SILD
 # FIR Level 0
 ################################################################################
 
-enum ElementType : u32
-    U = ImageFormat.U
-    F = ImageFormat.F
-struct VectorType plain
-    element : ElementType
-    count : u32
-
-    @@ memo
-    inline __as (cls T)
-        static-if (T == ImageFormat)
-            inline (self)
-                'setcomponents
-                    'setformat ImageFormat.R32U (self.element as u32)
-                    self.count
-
-define-type "vectype"   (RIFF "VECT") VectorType
-    typecolor...
-define-type "mrv"       (RIFF "VART") (tuple (types = (array AnyId)))
-    typecolor...
-define-type "args"      (RIFF "ARGS") (tuple (args = (array AnyId)))
-    typecolor...
+define-type "vargs"     (RIFF "ARGS") (tuple (args = (array AnyId)))
+    funccolor...
 define-type "va"        (RIFF "VA  ") (tuple (index = u32) (args = AnyId))
-    typecolor...
+    funccolor...
 define-type "fvec2"     (RIFF "FVC2") (tuple (x = AnyId) (y = AnyId))
     instrcolor...
 define-type "fvec3"     (RIFF "FVC3") (tuple (x = AnyId) (y = AnyId) (z = AnyId))

          
@@ 422,6 382,51 @@ define-op1 "sqrt"   "SQRT"
 define-op1 "sin"    "FSIN"
 define-op1 "cos"    "FCOS"
 
+# FIR Types
+################################################################################
+
+enum ElementType : u32
+    U = ImageFormat.U
+    F = ImageFormat.F
+struct VectorType plain
+    element : ElementType
+    count : u32
+
+    @@ memo
+    inline __as (cls T)
+        static-if (T == ImageFormat)
+            inline (self)
+                'setcomponents
+                    'setformat ImageFormat.R32U (self.element as u32)
+                    self.count
+
+define-type "vectype"   (RIFF "VECT") VectorType
+    typecolor...
+define-type "vatype"    (RIFF "VA T") (tuple (types = (array AnyId)))
+    typecolor...
+
+enum ImageFlags : u32
+    none = 0:u32
+    arrayed = 1:u32
+    multisampled = 2:u32
+    arrayed-multisampled = 3:u32
+struct ImageType plain
+    type : AnyId # vector type
+    dim : ImageDim
+    format : ImageFormat
+    flags : ImageFlags
+
+    let array? = (Accessor (inline (self key) ((self.flags & ImageFlags.arrayed) != 0)))
+    let ms? = (Accessor (inline (self key) ((self.flags & ImageFlags.multisampled) != 0)))
+define-type "imagetype"     (RIFF "IMGT") ImageType
+    typecolor...
+define-type "samplertype"   (RIFF "SMPT") ImageType
+    typecolor...
+define-type "texturetype"   (RIFF "TEXT") (tuple (type = AnyId) (x = u32) (y = u32) (z = u32) (levels = u32) (samples = u32))
+    typecolor...
+define-type "buffertype"    (RIFF "BUFT") (tuple (size = u32))
+    typecolor...
+
 ################################################################################
 
 #

          
@@ 721,10 726,10 @@ struct FIRTyper
     fn imagetypeof (self module id)
         let tid = ('typeof self module id)
         dispatch ('handleof module tid)
-        case image (self) self
-        case imagestorage (self)
+        case imagetype (self) self
+        case texturetype (self)
             dispatch ('handleof module self.type)
-            case image (self) self
+            case imagetype (self) self
             default
                 error "image type expected"
         default

          
@@ 787,7 792,7 @@ struct FIRTyper
                 get (wbinds @ 0 @ 0)
             else
                 let mrv =
-                    'alloc module TypeId.typeid_mrv wcount
+                    'alloc module TypeId.typeid_vatype wcount
                 let args = mrv.types
                 for i entry in (enumerate wbinds u32)
                     args @ i = (get (entry @ 0))

          
@@ 837,11 842,11 @@ struct FIRTyper
             case TypeId.typeid_fvec4 (fvec 4)
 
             # types have no type
-            pass TypeId.typeid_image
-            pass TypeId.typeid_sampler
-            pass TypeId.typeid_mrv
+            pass TypeId.typeid_imagetype
+            pass TypeId.typeid_samplertype
+            pass TypeId.typeid_vatype
             pass TypeId.typeid_vectype
-            pass TypeId.typeid_imagestorage
+            pass TypeId.typeid_texturetype
             do NoId
 
             # first value is type

          
@@ 876,11 881,11 @@ struct FIRTyper
             if (handle.typeid == TypeId.typeid_vectype)
                 return tid
             dispatch handle
-            case imagestorage (self)
+            case texturetype (self)
                 repeat (copy self.type)
-            case image (self)
+            case imagetype (self)
                 repeat (copy self.type)
-            case sampler (self)
+            case samplertype (self)
                 repeat (copy self.type)
             default
                 return NoId

          
@@ 1272,7 1277,7 @@ fn generate-IL (module rootid)
 
         let dim format arrayed? ms? =
             dispatch ('handleof module rtype)
-            case image (self)
+            case imagetype (self)
                 from self let dim format array? ms?
             default
                 error "image type expected"

          
@@ 1367,7 1372,7 @@ fn generate-IL (module rootid)
                     if (loc < 0)
                         error "uniformattr has no binding"
                     dispatch ('handleof module self.type)
-                    case sampler (smpty)
+                    case samplertype (smpty)
                         from GL let BindTextureUnit Uniform1i IsTexture
                         let tu = (deref next_texture_unit)
                         next_texture_unit += 1

          
@@ 1629,14 1634,14 @@ fn generate-IL (module rootid)
             for i in (range vacount)
                 sc_call_append_argument call (get (indices @ i))
             call
-        case image (self)
+        case imagetype (self)
             let arrayed? = self.array?
             let multisampled? = self.ms?
             let T = (imageformat->type self.format)
             let dim = (imagedim->symbol self.dim)
             let format = (imageformat->symbol self.format)
             `[(sc_image_type T dim 0 arrayed? multisampled? 2 format unnamed)]
-        case sampler (self)
+        case samplertype (self)
             let arrayed? = self.array?
             let multisampled? = self.ms?
             let T = (imageformat->type self.format)

          
@@ 1646,10 1651,10 @@ fn generate-IL (module rootid)
                 (sc_image_type T dim 0 arrayed? multisampled? 1 'Unknown unnamed))]
         case rbind (self) `none
         case wbind (self) `none
-        case imagestorage (self) `none
+        case texturetype (self) `none
         case undef (self)
             dispatch ('handleof module self.type)
-            case imagestorage (self)
+            case texturetype (self)
                 gentexstorage module self ctx
             default
                 error "invalid type for undef"

          
@@ 2198,7 2203,7 @@ fn lower-FIR (module rootid)
                     .. "source must be float or integer, but has type "
                         'repr module ('typeof ctx.typer module source)
 
-    fn genimagestorage (ctx module rangeid source)
+    fn gentexturetype (ctx module rangeid source)
         let tid = ('typeof ctx.typer module source)
         let imgformat =
             dispatch ('handleof module tid)

          
@@ 2206,17 2211,17 @@ fn lower-FIR (module rootid)
                 self as ImageFormat
             default
                 error "source must be float or integer"
-        from (methodsof module.builder) let image imagestorage
+        from (methodsof module.builder) let imagetype texturetype
         let met = (range-metrics module rangeid)
         let cx cy cz = (unpack met.capacity)
-        let imgtype = (image tid ImageDim.2D imgformat ImageFlags.none)
-        _ (imagestorage imgtype cx cy cz 1 0) imgtype imgformat met
+        let imgtype = (imagetype tid ImageDim.2D imgformat ImageFlags.none)
+        _ (texturetype imgtype cx cy cz 1 0) imgtype imgformat met
 
     fn lower-expression (ctx module source)
         dispatch ('handleof module ('typeof ctx.typer module source))
-        case imagestorage (imgstor)
+        case texturetype (imgstor)
             dispatch ('handleof module imgstor.type)
-            case image (img)
+            case imagetype (img)
                 return (copy source) (copy img.format)
             default
                 error "image type expected"

          
@@ 2225,7 2230,7 @@ fn lower-FIR (module rootid)
         let stage = ('stageof ctx.typer module source)
         let rangeid = stage.generator
         let storagetype imgtype imgformat met =
-            genimagestorage ctx module rangeid source
+            gentexturetype ctx module rangeid source
         let sx sy sz = ('build-dispatchsize met module)
         let lx ly lz = (unpack met.localsize)
         let imports = ('imports stage)

          
@@ 2239,10 2244,10 @@ fn lower-FIR (module rootid)
             let ty = ('typeof ctx.typer module (copy srcid))
             let ty =
                 dispatch ('handleof module ty)
-                case imagestorage (self)
+                case texturetype (self)
                     dispatch ('handleof module self.type)
-                    case image (self)
-                        let sampler = ('alloc module TypeId.typeid_sampler)
+                    case imagetype (self)
+                        let sampler = ('alloc module TypeId.typeid_samplertype)
                         @sampler = self
                         'commit module
                     default (copy self.type)

          
@@ 2293,7 2298,7 @@ fn lower-FIR (module rootid)
             let stage = ('stageof ctx.typer module self.range)
             let rangeid = (copy stage.generator)
             let storagetype imgtype imgformat met =
-                genimagestorage ctx module rangeid self.value
+                gentexturetype ctx module rangeid self.value
             from (methodsof module.builder) let clearimage uconst undef
             let ox oy oz = (unpack met.size)
             let z = (uconst 0)

          
M testing/tukdag.sc +10 -10
@@ 19,8 19,8 @@ local module : FIR
 inline gen-level1-test-geometry ()
     let _uvec3 = uvec3
     from (methodsof module.builder) let input uniform uvec wimage dispatch
-        \ bindings computefn imagestorage imagewrite globalid load fdiv
-        \ fconst comp utof fadd fmul sin fvec2 fvec4 udiv add uconst image
+        \ bindings computefn texturetype imagewrite globalid load fdiv
+        \ fconst comp utof fadd fmul sin fvec2 fvec4 udiv add uconst imagetype
         \ outputs output uvec2 fvec draw shaderfn position vertexid
         \ rattr wattr block fsub urem store clearimage cos instanceid undef
         \ primitiveid unpack-comp rbind wbind uvec4

          
@@ 31,7 31,7 @@ inline gen-level1-test-geometry ()
     let ssx = (uniform (fvec 1) 0)
     let ssy = (uniform (fvec 1) 1)
     let u_it = (uniform (fvec 1) 2)
-    let imgtype = (image (fvec 4) ImageDim.2D ImageFormat.RGBA8UNORM ImageFlags.none)
+    let imgtype = (imagetype (fvec 4) ImageDim.2D ImageFormat.RGBA8UNORM ImageFlags.none)
     let img = (wimage imgtype 0)
     let z = (fadd (fmul (sin (fdiv (utof inpit) (fconst 60.0))) (fconst 0.5)) (fconst 0.5))
     let angle = (fdiv (utof inpit) (fconst 60.0))

          
@@ 87,14 87,14 @@ inline gen-level1-test-geometry ()
                         uconst 0; uconst 0; uconst 0
                         comp 0 inpss; comp 1 inpss; uconst 1
                         undef
-                            imagestorage imgtype 4096 4096 1 1 0
+                            texturetype imgtype 4096 4096 1 1 0
                     colorattr_frag
 
 inline gen-level1-test ()
     let _uvec3 = uvec3
     from (methodsof module.builder) let input uniform uvec wimage dispatch
-        \ bindings computefn imagestorage imagewrite globalid load fdiv
-        \ fconst comp utof fadd fmul sin fvec2 fvec4 udiv add uconst image
+        \ bindings computefn texturetype imagewrite globalid load fdiv
+        \ fconst comp utof fadd fmul sin fvec2 fvec4 udiv add uconst imagetype
         \ outputs output uvec2 fvec draw shaderfn position vertexid
         \ rattr wattr block fsub urem store clearimage cos instanceid undef
         \ primitiveid unpack-comp rbind wbind

          
@@ 105,7 105,7 @@ inline gen-level1-test ()
     let ssx = (uniform (fvec 1) 0)
     let ssy = (uniform (fvec 1) 1)
     let u_it = (uniform (fvec 1) 2)
-    let imgtype = (image (fvec 4) ImageDim.2D ImageFormat.RGBA8UNORM ImageFlags.none)
+    let imgtype = (imagetype (fvec 4) ImageDim.2D ImageFormat.RGBA8UNORM ImageFlags.none)
     let img = (wimage imgtype 0)
     let z = (fadd (fmul (sin (fdiv (utof inpit) (fconst 60.0))) (fconst 0.5)) (fconst 0.5))
     let angle = (fdiv (utof inpit) (fconst 60.0))

          
@@ 142,7 142,7 @@ inline gen-level1-test ()
                 rbind z u_it
                 wbind
                     undef
-                        imagestorage imgtype 4096 4096 1 1 0
+                        texturetype imgtype 4096 4096 1 1 0
                     img
 
 inline gen-level2-test-geometry ()

          
@@ 287,8 287,8 @@ inline graphviz ()
         'showdot module ('rootid module)
             module-dir .. "/tukdag"
 
-#let prog = (gen-level1-test-geometry)
-let prog = (gen-level1-test)
+let prog = (gen-level1-test-geometry)
+#let prog = (gen-level1-test)
 #let prog =
     do
         let prog = (gen-level2-test-geometry)