summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKosyrev Serge <_deepfire@feelingofgreen.ru>2018-09-15 16:24:52 +0300
committerKosyrev Serge <_deepfire@feelingofgreen.ru>2018-09-17 19:43:18 +0300
commitfa9acbf78f91a639c0e76c1757564a6446445f39 (patch)
treea06489fbe3d1357800157c7b516f2ec3cfb95506
parent5e522de525affb137b46eb7b5896a2f3b4d4f0d9 (diff)
CoreToIr: add some top-level type signatures
-rw-r--r--src/LambdaCube/Compiler/CoreToIR.hs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/LambdaCube/Compiler/CoreToIR.hs b/src/LambdaCube/Compiler/CoreToIR.hs
index 8972d6b9..6646d345 100644
--- a/src/LambdaCube/Compiler/CoreToIR.hs
+++ b/src/LambdaCube/Compiler/CoreToIR.hs
@@ -21,6 +21,7 @@ import Data.List
21import qualified Data.Map as Map 21import qualified Data.Map as Map
22import qualified Data.Set as Set 22import qualified Data.Set as Set
23import qualified Data.Vector as Vector 23import qualified Data.Vector as Vector
24import GHC.Stack
24import Control.Arrow hiding ((<+>)) 25import Control.Arrow hiding ((<+>))
25import Control.Monad.Writer 26import Control.Monad.Writer
26import Control.Monad.State 27import Control.Monad.State
@@ -77,6 +78,11 @@ addLEq l x = modL l $ \sv -> maybe (let i = length sv in i `seq` (i, Map.insert
77 78
78--------------------------------------------------------- 79---------------------------------------------------------
79 80
81addTarget
82 :: Backend
83 -> ExpTV
84 -> [IR.TargetItem]
85 -> CG ([IR.Command], [IR.Command])
80addTarget backend a tl = do 86addTarget backend a tl = do
81 rt <- addL targetLens $ IR.RenderTarget $ Vector.fromList tl 87 rt <- addL targetLens $ IR.RenderTarget $ Vector.fromList tl
82 second (IR.SetRenderTarget rt:) <$> getCommands backend a 88 second (IR.SetRenderTarget rt:) <$> getCommands backend a
@@ -201,6 +207,7 @@ type SamplerBinding = (IR.UniformName,IR.ImageRef)
201frameBufferType (A2 "FrameBuffer" _ ty) = ty 207frameBufferType (A2 "FrameBuffer" _ ty) = ty
202frameBufferType x = error $ "illegal target type: " ++ ppShow x 208frameBufferType x = error $ "illegal target type: " ++ ppShow x
203 209
210getSemantics :: ExpTV -> [IR.ImageSemantic]
204getSemantics = compSemantics . frameBufferType . tyOf 211getSemantics = compSemantics . frameBufferType . tyOf
205 212
206getFragFilter (A2 "map" (EtaPrim2 "filterFragment" p) x) = (Just p, x) 213getFragFilter (A2 "map" (EtaPrim2 "filterFragment" p) x) = (Just p, x)
@@ -428,6 +435,7 @@ compFetchPrimitive x = case x of
428 A0 "TriangleAdjacency" -> IR.TrianglesAdjacency 435 A0 "TriangleAdjacency" -> IR.TrianglesAdjacency
429 x -> error $ "compFetchPrimitive " ++ ppShow x 436 x -> error $ "compFetchPrimitive " ++ ppShow x
430 437
438compValue :: HasCallStack => ExpTV -> IR.Value
431compValue x = case x of 439compValue x = case x of
432 EFloat a -> IR.VFloat $ realToFrac a 440 EFloat a -> IR.VFloat $ realToFrac a
433 EInt a -> IR.VInt $ fromIntegral a 441 EInt a -> IR.VInt $ fromIntegral a
@@ -495,6 +503,14 @@ compPV x = case x of
495 503
496--------------------------------------------------------------- GLSL generation 504--------------------------------------------------------------- GLSL generation
497 505
506genGLSLs
507 :: Backend
508 -> Maybe ExpTV
509 -> ExpTV
510 -> (Maybe ExpTV, ExpTV)
511 -> (Maybe ExpTV, ExpTV)
512 -> Maybe ExpTV
513 -> ([[Char]], Uniforms, Doc, Doc)
498genGLSLs backend 514genGLSLs backend
499 rp -- program point size 515 rp -- program point size
500 (ETuple ints) -- interpolations 516 (ETuple ints) -- interpolations