diff options
author | Kosyrev Serge <_deepfire@feelingofgreen.ru> | 2018-09-15 16:24:52 +0300 |
---|---|---|
committer | Kosyrev Serge <_deepfire@feelingofgreen.ru> | 2018-09-17 19:43:18 +0300 |
commit | fa9acbf78f91a639c0e76c1757564a6446445f39 (patch) | |
tree | a06489fbe3d1357800157c7b516f2ec3cfb95506 | |
parent | 5e522de525affb137b46eb7b5896a2f3b4d4f0d9 (diff) |
CoreToIr: add some top-level type signatures
-rw-r--r-- | src/LambdaCube/Compiler/CoreToIR.hs | 16 |
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 | |||
21 | import qualified Data.Map as Map | 21 | import qualified Data.Map as Map |
22 | import qualified Data.Set as Set | 22 | import qualified Data.Set as Set |
23 | import qualified Data.Vector as Vector | 23 | import qualified Data.Vector as Vector |
24 | import GHC.Stack | ||
24 | import Control.Arrow hiding ((<+>)) | 25 | import Control.Arrow hiding ((<+>)) |
25 | import Control.Monad.Writer | 26 | import Control.Monad.Writer |
26 | import Control.Monad.State | 27 | import 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 | ||
81 | addTarget | ||
82 | :: Backend | ||
83 | -> ExpTV | ||
84 | -> [IR.TargetItem] | ||
85 | -> CG ([IR.Command], [IR.Command]) | ||
80 | addTarget backend a tl = do | 86 | addTarget 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) | |||
201 | frameBufferType (A2 "FrameBuffer" _ ty) = ty | 207 | frameBufferType (A2 "FrameBuffer" _ ty) = ty |
202 | frameBufferType x = error $ "illegal target type: " ++ ppShow x | 208 | frameBufferType x = error $ "illegal target type: " ++ ppShow x |
203 | 209 | ||
210 | getSemantics :: ExpTV -> [IR.ImageSemantic] | ||
204 | getSemantics = compSemantics . frameBufferType . tyOf | 211 | getSemantics = compSemantics . frameBufferType . tyOf |
205 | 212 | ||
206 | getFragFilter (A2 "map" (EtaPrim2 "filterFragment" p) x) = (Just p, x) | 213 | getFragFilter (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 | ||
438 | compValue :: HasCallStack => ExpTV -> IR.Value | ||
431 | compValue x = case x of | 439 | compValue 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 | ||
506 | genGLSLs | ||
507 | :: Backend | ||
508 | -> Maybe ExpTV | ||
509 | -> ExpTV | ||
510 | -> (Maybe ExpTV, ExpTV) | ||
511 | -> (Maybe ExpTV, ExpTV) | ||
512 | -> Maybe ExpTV | ||
513 | -> ([[Char]], Uniforms, Doc, Doc) | ||
498 | genGLSLs backend | 514 | genGLSLs backend |
499 | rp -- program point size | 515 | rp -- program point size |
500 | (ETuple ints) -- interpolations | 516 | (ETuple ints) -- interpolations |