diff options
author | Péter Diviánszky <divipp@gmail.com> | 2016-01-27 11:57:34 +0100 |
---|---|---|
committer | Péter Diviánszky <divipp@gmail.com> | 2016-01-27 12:15:43 +0100 |
commit | c0a3b1a4a71af08398d561698765206a54114593 (patch) | |
tree | f6bbb983f15f0a0225fe5f4d05305db8c0995878 /lc | |
parent | 1dd30849d7cd226275b758a9520661b37a8fabb3 (diff) |
less wired-in reductions in the compiler
Diffstat (limited to 'lc')
-rw-r--r-- | lc/Builtins.lc | 43 |
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 | {- | |
342 | type family FragOps a where | 342 | type 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 | -} | |
349 | type family FragOps' a where | 349 | type 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 | 416 | data Image :: Nat -> Type -> Type where |
417 | type 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 | |
422 | type family SameLayerCounts a | 422 | -- todo: eliminate |
423 | data PreFrameBuffer (n :: Nat) b | ||
424 | |||
425 | type 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 | |||
430 | type 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 | ||
424 | class DefaultFragOp a where defaultFragOp :: FragmentOperation a | 435 | class DefaultFragOp a where defaultFragOp :: FragmentOperation a |
425 | instance DefaultFragOp (Color (VecS Float 4)) where defaultFragOp = ColorOp NoBlending (V4 True True True True) | 436 | instance 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 | -} |
433 | data FrameBuffer (n :: Nat) b where | 444 | data 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 | ||
437 | accumulate ctx fshader fstr fb = Accumulate ctx (mapFragments fshader fstr) fb | 448 | accumulate ctx fshader fstr fb = Accumulate ctx (mapFragments fshader fstr) fb |
438 | 449 | ||
439 | accumulationContext x = x | 450 | accumulationContext x = x |
440 | 451 | ||
441 | data Image :: Nat -> Type -> Type where | 452 | -- texture support |
442 | ColorImage :: forall a d t color . (Num t, color ~ VecScalar d t) | 453 | PrjImage :: FrameBuffer 1 a -> Image 1 a |
443 | => color -> Image a (Color color) | 454 | PrjImageColor :: 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 | ||
451 | data Output where | 456 | data Output where |
452 | ScreenOut :: FrameBuffer a b -> Output | 457 | ScreenOut :: FrameBuffer a b -> Output |