packages feed

fir-0.1.0.0: test/Tests/Layout/Products.hs

{-# LANGUAGE BlockArguments   #-}
{-# LANGUAGE DataKinds        #-}
{-# LANGUAGE PolyKinds        #-}
{-# LANGUAGE RebindableSyntax #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators    #-}

module Tests.Layout.Products where

-- fir
import FIR
import Math.Linear

------------------------------------------------
-- product optics over members of buffers with different layouts

type AB = Struct '[ "a" ':-> Array 2 Float, "b" ':-> Array 3 ( V 2 Float ) ]

type Defs =
  '[ "ubo"  ':-> Uniform '[ DescriptorSet 0, Binding 0 ]
                   ( Struct '[ "a" ':-> Array 2 Float, "b" ':-> Array 3 ( V 2 Float ), "v" ':-> V 4 Float ] )
   , "out"  ':-> StorageBuffer '[ DescriptorSet 0, Binding 1 ]
                   ( Struct '[ "a" ':-> Array 2 Float, "b" ':-> Array 3 ( V 2 Float ), "f" ':-> Float ] )
   , "main" ':-> EntryPoint '[ LocalSize 1 1 1 ] Compute
   ]

program :: Module Defs
program = Module do
  entryPoint @"main" @Compute do
    ab <- use @( Name "ubo" :.: Prod @_ @_ @_ @AB ( Name "a" :*: Name "b" :*: EndProd ) )
    assign @( Name "out" :.: Prod @_ @_ @_ @AB ( Name "a" :*: Name "b" :*: EndProd ) ) ab