packages feed

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

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

module Tests.Layout.Copy where

-- fir
import FIR
import Math.Linear

------------------------------------------------
-- copying a structure from a uniform buffer to a storage buffer,
-- which use different layouts

type S =
  Struct
    '[ "a" ':-> Array 3 Float
     , "b" ':-> V 3 Float
     , "c" ':-> Array 2 ( Struct '[ "x" ':-> Float, "y" ':-> V 2 Float ] )
     , "m" ':-> M 4 4 Float
     ]

type Defs =
  '[ "ubo"  ':-> Uniform '[ DescriptorSet 0, Binding 0 ]
                   ( Struct '[ "s" ':-> S ] )
   , "out"  ':-> StorageBuffer '[ DescriptorSet 0, Binding 1 ]
                   ( Struct '[ "s" ':-> S, "t" ':-> S ] )
   , "main" ':-> EntryPoint '[ LocalSize 1 1 1 ] Compute
   ]

program :: Module Defs
program = Module do
  entryPoint @"main" @Compute do
    assign @( Name "out" :.: Name "s" ) =<< use @( Name "ubo" :.: Name "s" )
    assign @( Name "out" :.: Name "t" ) =<< use @( Name "out" :.: Name "s" )