packages feed

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

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

module Tests.Layout.PushConstant where

-- fir
import FIR
import Math.Linear

------------------------------------------------
-- copying push constants to a storage buffer

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

type Defs =
  '[ "pc"   ':-> PushConstant '[]
                   ( Struct '[ "m" ':-> M 4 4 Float, "arr" ':-> A ] )
   , "out"  ':-> StorageBuffer '[ DescriptorSet 0, Binding 1 ]
                   ( Struct '[ "arr" ':-> A, "m" ':-> M 4 4 Float ] )
   , "main" ':-> EntryPoint '[ LocalSize 1 1 1 ] Compute
   ]

program :: Module Defs
program = Module do
  entryPoint @"main" @Compute do
    assign @( Name "out" :.: Name "arr" ) =<< use @( Name "pc" :.: Name "arr" )
    assign @( Name "out" :.: Name "m"   ) =<< use @( Name "pc" :.: Name "m"   )