summaryrefslogtreecommitdiff
path: root/lc
diff options
context:
space:
mode:
authorPéter Diviánszky <divipp@gmail.com>2016-01-27 11:57:34 +0100
committerPéter Diviánszky <divipp@gmail.com>2016-01-27 12:15:43 +0100
commitc0a3b1a4a71af08398d561698765206a54114593 (patch)
treef6bbb983f15f0a0225fe5f4d05305db8c0995878 /lc
parent1dd30849d7cd226275b758a9520661b37a8fabb3 (diff)
less wired-in reductions in the compiler
Diffstat (limited to 'lc')
-rw-r--r--lc/Builtins.lc43
1 files changed, 24 insertions, 19 deletions
diff --git a/lc/Builtins.lc b/lc/Builtins.lc
index 27490d18..06713cec 100644
--- a/lc/Builtins.lc
+++ b/lc/Builtins.lc
@@ -338,14 +338,14 @@ data FragmentOperation :: Type -> Type where
338 -> FragmentOperation (Color color) 338 -> FragmentOperation (Color color)
339 DepthOp :: ComparisonFunction -> Bool -> FragmentOperation (Depth Float) 339 DepthOp :: ComparisonFunction -> Bool -> FragmentOperation (Depth Float)
340 StencilOp :: StencilTests -> StencilOps -> StencilOps -> FragmentOperation (Stencil Int32) 340 StencilOp :: StencilTests -> StencilOps -> StencilOps -> FragmentOperation (Stencil Int32)
341 341{-
342type family FragOps a where 342type family FragOps a where
343 FragOps (FragmentOperation t) = t 343 FragOps (FragmentOperation t) = t
344 FragOps (FragmentOperation t1, FragmentOperation t2) = (t1, t2) 344 FragOps (FragmentOperation t1, FragmentOperation t2) = (t1, t2)
345 FragOps (FragmentOperation t1, FragmentOperation t2, FragmentOperation t3) = (t1, t2, t3) 345 FragOps (FragmentOperation t1, FragmentOperation t2, FragmentOperation t3) = (t1, t2, t3)
346 FragOps (FragmentOperation t1, FragmentOperation t2, FragmentOperation t3, FragmentOperation t4) = (t1, t2, t3, t4) 346 FragOps (FragmentOperation t1, FragmentOperation t2, FragmentOperation t3, FragmentOperation t4) = (t1, t2, t3, t4)
347 FragOps (FragmentOperation t1, FragmentOperation t2, FragmentOperation t3, FragmentOperation t4, FragmentOperation t5) = (t1, t2, t3, t4, t5) 347 FragOps (FragmentOperation t1, FragmentOperation t2, FragmentOperation t3, FragmentOperation t4, FragmentOperation t5) = (t1, t2, t3, t4, t5)
348 348-}
349type family FragOps' a where 349type family FragOps' a where
350 FragOps' (t1, t2) = (FragmentOperation t1, FragmentOperation t2) 350 FragOps' (t1, t2) = (FragmentOperation t1, FragmentOperation t2)
351 FragOps' (t1, t2, t3) = (FragmentOperation t1, FragmentOperation t2, FragmentOperation t3) 351 FragOps' (t1, t2, t3) = (FragmentOperation t1, FragmentOperation t2, FragmentOperation t3)
@@ -413,13 +413,24 @@ mapFragments f = mapStream (mapFragment f)
413 413
414--data ShadedFragment :: Nat -> Type -> Type 414--data ShadedFragment :: Nat -> Type -> Type
415 415
416-- todo: mutually defined with FrameBuffer and Image 416data Image :: Nat -> Type -> Type where
417type family TFFrameBuffer a {-where 417 ColorImage :: forall a d t color . (Num t, color ~ VecScalar d t)
418 TFFrameBuffer (Image n t) = FrameBuffer n t 418 => color -> Image a (Color color)
419 TFFrameBuffer (Image n1 t1, Image n2 t2) {- TODO | n1 == n2 -} = FrameBuffer n1 (t1, t2) 419 DepthImage :: forall a . Float -> Image a (Depth Float)
420 TFFrameBuffer (Image n1 t1, Image n2 t2, Image n2 t3) {- TODO | n1 == n2 && n2 == n3 -} = FrameBuffer n1 (t1, t2, t3) 420 StencilImage :: forall a . Int -> Image a (Stencil Int)
421-} 421
422type family SameLayerCounts a 422-- todo: eliminate
423data PreFrameBuffer (n :: Nat) b
424
425type family TFFrameBuffer a where
426 TFFrameBuffer (Image n1 t1) = PreFrameBuffer n1 t1
427 TFFrameBuffer (Image n1 t1, Image n2 t2) = PreFrameBuffer n1 (t1, t2)
428 TFFrameBuffer (Image n1 t1, Image n2 t2, Image n3 t3) = PreFrameBuffer n1 (t1, t2, t3)
429
430type family SameLayerCounts a where
431 SameLayerCounts (Image n1 t1) = Unit
432 SameLayerCounts (Image n1 t1, Image n2 t2) = EqCT Nat n1 n2
433 SameLayerCounts (Image n1 t1, Image n2 t2, Image n3 t3) = T2 (EqCT Nat n1 n2) (EqCT Nat n1 n3)
423 434
424class DefaultFragOp a where defaultFragOp :: FragmentOperation a 435class DefaultFragOp a where defaultFragOp :: FragmentOperation a
425instance DefaultFragOp (Color (VecS Float 4)) where defaultFragOp = ColorOp NoBlending (V4 True True True True) 436instance DefaultFragOp (Color (VecS Float 4)) where defaultFragOp = ColorOp NoBlending (V4 True True True True)
@@ -432,21 +443,15 @@ instance (DefaultFragOp a, DefaultFragOp b) => DefaultFragOps (FragmentOperation
432-} 443-}
433data FrameBuffer (n :: Nat) b where 444data FrameBuffer (n :: Nat) b where
434 Accumulate :: FragOps' b -> (FragmentStream n (RemSemantics b)) -> FrameBuffer n b -> FrameBuffer n b 445 Accumulate :: FragOps' b -> (FragmentStream n (RemSemantics b)) -> FrameBuffer n b -> FrameBuffer n b
435 FrameBuffer :: (ValidFrameBuffer b, SameLayerCounts a, FrameBuffer n b ~ TFFrameBuffer a) => a -> FrameBuffer n b 446 FrameBuffer :: (ValidFrameBuffer b, SameLayerCounts a, PreFrameBuffer n b ~ TFFrameBuffer a) => a -> FrameBuffer n b
436 447
437accumulate ctx fshader fstr fb = Accumulate ctx (mapFragments fshader fstr) fb 448accumulate ctx fshader fstr fb = Accumulate ctx (mapFragments fshader fstr) fb
438 449
439accumulationContext x = x 450accumulationContext x = x
440 451
441data Image :: Nat -> Type -> Type where 452-- texture support
442 ColorImage :: forall a d t color . (Num t, color ~ VecScalar d t) 453PrjImage :: FrameBuffer 1 a -> Image 1 a
443 => color -> Image a (Color color) 454PrjImageColor :: FrameBuffer 1 (Depth Float, Color (Vec 4 Float)) -> Image 1 (Color (Vec 4 Float))
444 DepthImage :: forall a . Float -> Image a (Depth Float)
445 StencilImage :: forall a . Int -> Image a (Stencil Int)
446
447 -- texture support
448 PrjImage :: FrameBuffer 1 a -> Image 1 a
449 PrjImageColor :: FrameBuffer 1 (Depth Float, Color (Vec 4 Float)) -> Image 1 (Color (Vec 4 Float))
450 455
451data Output where 456data Output where
452 ScreenOut :: FrameBuffer a b -> Output 457 ScreenOut :: FrameBuffer a b -> Output