packages feed

fir-0.1.0.0: test/Tests/Atomics/FloatBitwise.hs

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

module Tests.Atomics.FloatBitwise where

-- fir
import FIR
import Math.Linear

------------------------------------------------
-- bitwise atomic operations are only supported on integers

type Defs =
  '[ "floats" ':-> StorageBuffer '[ DescriptorSet 0, Binding 0 ]
                    ( Struct '[ "arr" ':-> RuntimeArray Float ] )
   , "main"   ':-> EntryPoint '[ LocalSize 8 8 1 ] Compute
   ]

program :: Module Defs
program = Module $ entryPoint @"main" @Compute do
  ~( Vec3 x _ _ ) <- get @"gl_GlobalInvocationID"
  _ <- atomicAnd @( Name "floats" :.: Name "arr" :.: AnIndex Word32 ) x 1
  pure ( Lit () )