fir-0.1.0.0: test/Tests/Layout/DescriptorArray.hs
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RebindableSyntax #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}
module Tests.Layout.DescriptorArray where
-- fir
import FIR
import Math.Linear
------------------------------------------------
-- arrays of uniform buffers
type S = Struct '[ "m" ':-> M 4 4 Float, "v" ':-> V 3 Float, "xs" ':-> Array 3 Float ]
type Defs =
'[ "ubos" ':-> Uniform '[ DescriptorSet 0, Binding 0 ] ( Array 4 S )
, "out" ':-> StorageBuffer '[ DescriptorSet 0, Binding 1 ]
( Struct '[ "f" ':-> Float, "s" ':-> S ] )
, "main" ':-> EntryPoint '[ LocalSize 1 1 1 ] Compute
]
program :: Module Defs
program = Module do
entryPoint @"main" @Compute do
i <- use @( Name "gl_LocalInvocationIndex" )
x <- use @( Name "ubos" :.: AnIndex Word32 :.: Name "xs" :.: Index 1 ) i
s <- use @( Name "ubos" :.: Index 2 )
whole <- get @"ubos"
assign @( Name "out" :.: Name "f" ) ( x + view @( Index 3 :.: Name "xs" :.: Index 0 ) whole )
assign @( Name "out" :.: Name "s" ) s