packages feed

fir-0.1.0.0: test/Tests/Control/RayQueryVariable.hs

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

module Tests.Control.RayQueryVariable where

-- fir
import FIR
import Math.Linear

------------------------------------------------
-- program

-- Initialising a ray query declares a variable holding the ray query object,
-- which must be declared in a valid location (module scope for a Private variable,
-- first block of the function for a Function variable).

type Defs =
  '[ "accel" ':-> UniformConstant '[ DescriptorSet 0, Binding 0 ] AccelerationStructure
   , "main"  ':-> EntryPoint '[ LocalSize 1 1 1 ] Compute
   ]

program :: Module Defs
program = Module do

  entryPoint @"main" @Compute do
    accel <- get @"accel"
    locally do
      initialize @"query" accel
        ( RayInfo
          { rayFlags     = 0
          , rayOrigin    = Vec3 0 0 0
          , rayDirection = Vec3 0 0 1
          , rayTMin      = 0
          , rayTMax      = 100
          , cullMask     = 0xff
          }
        )
      terminate @"query"