summaryrefslogtreecommitdiff
path: root/lc
diff options
context:
space:
mode:
authorPéter Diviánszky <divipp@gmail.com>2016-01-20 14:37:52 +0100
committerPéter Diviánszky <divipp@gmail.com>2016-01-20 14:37:52 +0100
commit69597adb39d1e19ee07bc273ee85f681cbd8b559 (patch)
tree7d7a3eeba1dfe65a0fd9bf69a1356e1ad41990f8 /lc
parent19591f76e4a97bf3d0ea36ec7203367288ab38cb (diff)
better type for rasterize primitive
Diffstat (limited to 'lc')
-rw-r--r--lc/Builtins.lc15
1 files changed, 9 insertions, 6 deletions
diff --git a/lc/Builtins.lc b/lc/Builtins.lc
index 9a8a2221..aa0af3ff 100644
--- a/lc/Builtins.lc
+++ b/lc/Builtins.lc
@@ -354,6 +354,7 @@ type family FragOps' a where
354data Stream a 354data Stream a
355 355
356mapStream :: (a -> b) -> Stream a -> Stream b 356mapStream :: (a -> b) -> Stream a -> Stream b
357concatMapStream :: (a -> Stream b) -> Stream a -> Stream b
357filterStream :: (a -> Bool) -> Stream a -> Stream a 358filterStream :: (a -> Bool) -> Stream a -> Stream a
358 359
359data Primitive (a :: PrimitiveType) t 360data Primitive (a :: PrimitiveType) t
@@ -365,7 +366,7 @@ mapPrimitive :: (a -> b) -> Primitive p a -> Primitive p b
365fetch_ :: forall a t . (AttributeTuple t) => String -> t -> PrimitiveStream a t 366fetch_ :: forall a t . (AttributeTuple t) => String -> t -> PrimitiveStream a t
366fetchArrays_ :: forall a t t' . (AttributeTuple t, t ~ FTRepr' t') => t' -> PrimitiveStream a t 367fetchArrays_ :: forall a t t' . (AttributeTuple t, t ~ FTRepr' t') => t' -> PrimitiveStream a t
367 368
368mapPrimitives :: (t' -> t) -> Stream (Primitive a t') -> PrimitiveStream a t 369mapPrimitives :: (t' -> t) -> PrimitiveStream a t' -> PrimitiveStream a t
369mapPrimitives f = mapStream (mapPrimitive f) 370mapPrimitives f = mapStream (mapPrimitive f)
370 371
371fetch s a t = fetch_ @a s t 372fetch s a t = fetch_ @a s t
@@ -404,6 +405,8 @@ type family RemSemantics a where
404 -- Render Operations 405 -- Render Operations
405data Fragment :: Nat -> DepthHandler -> Type -> Type 406data Fragment :: Nat -> DepthHandler -> Type -> Type
406 407
408type FragmentStream n a t = Stream (Fragment n a t)
409
407customizeDepth :: (a -> Float) -> Fragment n _ a -> Fragment n DefinedDepth a 410customizeDepth :: (a -> Float) -> Fragment n _ a -> Fragment n DefinedDepth a
408 411
409customizeDepths f = mapStream (customizeDepth f) 412customizeDepths f = mapStream (customizeDepth f)
@@ -417,11 +420,11 @@ rasterize_ :: (b ~ InterpolatedType y, a ~ JoinTupleType (Vec 4 Float) b)
417 => (a -> Float) -- point size 420 => (a -> Float) -- point size
418 -> y -- tuple of Smooth & Flat 421 -> y -- tuple of Smooth & Flat
419 -> RasterContext x 422 -> RasterContext x
420 -> Primitive x a -> Fragment 1 DefinedDepth b 423 -> Primitive x a -> FragmentStream 1 DefinedDepth b
421 424
422filterFragment :: (a -> Bool) -> Fragment n _ a -> Bool 425filterFragment :: (a -> Bool) -> Fragment n _ a -> Bool
423 426
424filterFragments :: (a -> Bool) -> Stream (Fragment n d a) -> Stream (Fragment n d a) 427filterFragments :: (a -> Bool) -> (FragmentStream n d a) -> (FragmentStream n d a)
425filterFragments p = filterStream (filterFragment p) 428filterFragments p = filterStream (filterFragment p)
426 429
427mapFragment :: (a -> b) -> Fragment n d a -> Fragment n d b 430mapFragment :: (a -> b) -> Fragment n d a -> Fragment n d b
@@ -448,7 +451,7 @@ instance (DefaultFragOp a, DefaultFragOp b) => DefaultFragOps (FragmentOperation
448 (defaultFragOp @a @_, defaultFragOp @b @_) 451 (defaultFragOp @a @_, defaultFragOp @b @_)
449-} 452-}
450data FrameBuffer (n :: Nat) b where 453data FrameBuffer (n :: Nat) b where
451 Accumulate :: FragOps' b -> Stream (Fragment n d (RemSemantics b)) -> FrameBuffer n b -> FrameBuffer n b 454 Accumulate :: FragOps' b -> (FragmentStream n d (RemSemantics b)) -> FrameBuffer n b -> FrameBuffer n b
452 FrameBuffer :: (ValidFrameBuffer b, SameLayerCounts a, FrameBuffer n b ~ TFFrameBuffer a) => a -> FrameBuffer n b 455 FrameBuffer :: (ValidFrameBuffer b, SameLayerCounts a, FrameBuffer n b ~ TFFrameBuffer a) => a -> FrameBuffer n b
453 456
454accumulate ctx fshader fstr fb = Accumulate ctx (mapFragments fshader fstr) fb 457accumulate ctx fshader fstr fb = Accumulate ctx (mapFragments fshader fstr) fb
@@ -580,8 +583,8 @@ data Sampler = Sampler Filter EdgeMode Texture
580texture2D :: Sampler -> Vec 2 Float -> Vec 4 Float 583texture2D :: Sampler -> Vec 2 Float -> Vec 4 Float
581 584
582 585
583rasterizePrimitives ctx is = mapStream (rasterize_ (\_ -> 1) is ctx) 586rasterizePrimitives ctx is = concatMapStream (rasterize_ (\_ -> 1) is ctx)
584rasterizePrimitivesWithPointSize ctx ps is = mapStream (rasterize_ ps is ctx) 587rasterizePrimitivesWithPointSize ctx ps is = concatMapStream (rasterize_ ps is ctx)
585accumulateWith ctx x = (ctx, x) 588accumulateWith ctx x = (ctx, x)
586overlay cl (ctx, str) = Accumulate ctx str cl 589overlay cl (ctx, str) = Accumulate ctx str cl
587renderFrame = ScreenOut 590renderFrame = ScreenOut