summaryrefslogtreecommitdiff
path: root/lc
diff options
context:
space:
mode:
authorPéter Diviánszky <divipp@gmail.com>2016-01-20 14:42:57 +0100
committerPéter Diviánszky <divipp@gmail.com>2016-01-20 14:43:15 +0100
commit12226ce92609806783805fc508bb83befe64d3ce (patch)
tree2a5e8bd19ed31bc009ffe7c136b1e514a241afc0 /lc
parent69597adb39d1e19ee07bc273ee85f681cbd8b559 (diff)
simpler Fragment type
Diffstat (limited to 'lc')
-rw-r--r--lc/Builtins.lc38
1 files changed, 8 insertions, 30 deletions
diff --git a/lc/Builtins.lc b/lc/Builtins.lc
index aa0af3ff..f05e501a 100644
--- a/lc/Builtins.lc
+++ b/lc/Builtins.lc
@@ -372,22 +372,6 @@ mapPrimitives f = mapStream (mapPrimitive f)
372fetch s a t = fetch_ @a s t 372fetch s a t = fetch_ @a s t
373fetchArrays a t = fetchArrays_ @a t 373fetchArrays a t = fetchArrays_ @a t
374 374
375data DepthHandler = NoDepth | DefinedDepth
376{- todo: remove?
377type family AddSemantics (d :: DepthHandler) a where
378 AddSemantics 'NoDepth () = ()
379 AddSemantics 'NoDepth (a, b) = (Color a, Color b)
380 AddSemantics 'NoDepth (a, b, c) = (Color a, Color b, Color c)
381 AddSemantics 'NoDepth (a, b, c, d) = (Color a, Color b, Color c, Color d)
382 AddSemantics 'NoDepth (a, b, c, d, e) = (Color a, Color b, Color c, Color d, Color e)
383 AddSemantics 'NoDepth a = Color a -- TODO
384 AddSemantics 'DefinedDepth () = ()
385 AddSemantics 'DefinedDepth (a, b) = (Depth Float, Color a, Color b)
386 AddSemantics 'DefinedDepth (a, b, c) = (Depth Float, Color a, Color b, Color c)
387 AddSemantics 'DefinedDepth (a, b, c, d) = (Depth Float, Color a, Color b, Color c, Color d)
388-- AddSemantics 'DefinedDepth (a, b, c, d, e) = (Depth Float, Color a, Color b, Color c, Color d, Color e)
389 AddSemantics 'DefinedDepth a = (Depth Float, Color a) -- TODO
390-}
391type family RemSemantics a where 375type family RemSemantics a where
392 RemSemantics () = () 376 RemSemantics () = ()
393 RemSemantics (Color a) = a 377 RemSemantics (Color a) = a
@@ -400,34 +384,28 @@ type family RemSemantics a where
400 RemSemantics (Depth Float, Color a, Color b) = (a, b) 384 RemSemantics (Depth Float, Color a, Color b) = (a, b)
401 RemSemantics (Depth Float, Color a, Color b, Color c) = (a, b, c) 385 RemSemantics (Depth Float, Color a, Color b, Color c) = (a, b, c)
402 RemSemantics (Depth Float, Color a, Color b, Color c, Color d) = (a, b, c, d) 386 RemSemantics (Depth Float, Color a, Color b, Color c, Color d) = (a, b, c, d)
403-- RemSemantics 'DefinedDepth (a, b, c, d, e) = (Depth Float, Color a, Color b, Color c, Color d, Color e)
404 387
405 -- Render Operations 388 -- Render Operations
406data Fragment :: Nat -> DepthHandler -> Type -> Type 389data Fragment :: Nat -> Type -> Type
407 390
408type FragmentStream n a t = Stream (Fragment n a t) 391type FragmentStream n t = Stream (Fragment n t)
409 392
410customizeDepth :: (a -> Float) -> Fragment n _ a -> Fragment n DefinedDepth a 393customizeDepth :: (a -> Float) -> Fragment n a -> Fragment n a
411 394
412customizeDepths f = mapStream (customizeDepth f) 395customizeDepths f = mapStream (customizeDepth f)
413{- todo: remove?
414noDepth :: Fragment n _ a -> Fragment n NoDepth a
415
416noDepths = mapStream noDepth
417-}
418 396
419rasterize_ :: (b ~ InterpolatedType y, a ~ JoinTupleType (Vec 4 Float) b) 397rasterize_ :: (b ~ InterpolatedType y, a ~ JoinTupleType (Vec 4 Float) b)
420 => (a -> Float) -- point size 398 => (a -> Float) -- point size
421 -> y -- tuple of Smooth & Flat 399 -> y -- tuple of Smooth & Flat
422 -> RasterContext x 400 -> RasterContext x
423 -> Primitive x a -> FragmentStream 1 DefinedDepth b 401 -> Primitive x a -> FragmentStream 1 b
424 402
425filterFragment :: (a -> Bool) -> Fragment n _ a -> Bool 403filterFragment :: (a -> Bool) -> Fragment n a -> Bool
426 404
427filterFragments :: (a -> Bool) -> (FragmentStream n d a) -> (FragmentStream n d a) 405filterFragments :: (a -> Bool) -> (FragmentStream n a) -> (FragmentStream n a)
428filterFragments p = filterStream (filterFragment p) 406filterFragments p = filterStream (filterFragment p)
429 407
430mapFragment :: (a -> b) -> Fragment n d a -> Fragment n d b 408mapFragment :: (a -> b) -> Fragment n a -> Fragment n b
431 409
432mapFragments f = mapStream (mapFragment f) 410mapFragments f = mapStream (mapFragment f)
433 411
@@ -451,7 +429,7 @@ instance (DefaultFragOp a, DefaultFragOp b) => DefaultFragOps (FragmentOperation
451 (defaultFragOp @a @_, defaultFragOp @b @_) 429 (defaultFragOp @a @_, defaultFragOp @b @_)
452-} 430-}
453data FrameBuffer (n :: Nat) b where 431data FrameBuffer (n :: Nat) b where
454 Accumulate :: FragOps' b -> (FragmentStream n d (RemSemantics b)) -> FrameBuffer n b -> FrameBuffer n b 432 Accumulate :: FragOps' b -> (FragmentStream n (RemSemantics b)) -> FrameBuffer n b -> FrameBuffer n b
455 FrameBuffer :: (ValidFrameBuffer b, SameLayerCounts a, FrameBuffer n b ~ TFFrameBuffer a) => a -> FrameBuffer n b 433 FrameBuffer :: (ValidFrameBuffer b, SameLayerCounts a, FrameBuffer n b ~ TFFrameBuffer a) => a -> FrameBuffer n b
456 434
457accumulate ctx fshader fstr fb = Accumulate ctx (mapFragments fshader fstr) fb 435accumulate ctx fshader fstr fb = Accumulate ctx (mapFragments fshader fstr) fb