diff options
author | Péter Diviánszky <divipp@gmail.com> | 2016-01-20 14:37:52 +0100 |
---|---|---|
committer | Péter Diviánszky <divipp@gmail.com> | 2016-01-20 14:37:52 +0100 |
commit | 69597adb39d1e19ee07bc273ee85f681cbd8b559 (patch) | |
tree | 7d7a3eeba1dfe65a0fd9bf69a1356e1ad41990f8 /lc | |
parent | 19591f76e4a97bf3d0ea36ec7203367288ab38cb (diff) |
better type for rasterize primitive
Diffstat (limited to 'lc')
-rw-r--r-- | lc/Builtins.lc | 15 |
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 | |||
354 | data Stream a | 354 | data Stream a |
355 | 355 | ||
356 | mapStream :: (a -> b) -> Stream a -> Stream b | 356 | mapStream :: (a -> b) -> Stream a -> Stream b |
357 | concatMapStream :: (a -> Stream b) -> Stream a -> Stream b | ||
357 | filterStream :: (a -> Bool) -> Stream a -> Stream a | 358 | filterStream :: (a -> Bool) -> Stream a -> Stream a |
358 | 359 | ||
359 | data Primitive (a :: PrimitiveType) t | 360 | data Primitive (a :: PrimitiveType) t |
@@ -365,7 +366,7 @@ mapPrimitive :: (a -> b) -> Primitive p a -> Primitive p b | |||
365 | fetch_ :: forall a t . (AttributeTuple t) => String -> t -> PrimitiveStream a t | 366 | fetch_ :: forall a t . (AttributeTuple t) => String -> t -> PrimitiveStream a t |
366 | fetchArrays_ :: forall a t t' . (AttributeTuple t, t ~ FTRepr' t') => t' -> PrimitiveStream a t | 367 | fetchArrays_ :: forall a t t' . (AttributeTuple t, t ~ FTRepr' t') => t' -> PrimitiveStream a t |
367 | 368 | ||
368 | mapPrimitives :: (t' -> t) -> Stream (Primitive a t') -> PrimitiveStream a t | 369 | mapPrimitives :: (t' -> t) -> PrimitiveStream a t' -> PrimitiveStream a t |
369 | mapPrimitives f = mapStream (mapPrimitive f) | 370 | mapPrimitives f = mapStream (mapPrimitive f) |
370 | 371 | ||
371 | fetch s a t = fetch_ @a s t | 372 | fetch s a t = fetch_ @a s t |
@@ -404,6 +405,8 @@ type family RemSemantics a where | |||
404 | -- Render Operations | 405 | -- Render Operations |
405 | data Fragment :: Nat -> DepthHandler -> Type -> Type | 406 | data Fragment :: Nat -> DepthHandler -> Type -> Type |
406 | 407 | ||
408 | type FragmentStream n a t = Stream (Fragment n a t) | ||
409 | |||
407 | customizeDepth :: (a -> Float) -> Fragment n _ a -> Fragment n DefinedDepth a | 410 | customizeDepth :: (a -> Float) -> Fragment n _ a -> Fragment n DefinedDepth a |
408 | 411 | ||
409 | customizeDepths f = mapStream (customizeDepth f) | 412 | customizeDepths 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 | ||
422 | filterFragment :: (a -> Bool) -> Fragment n _ a -> Bool | 425 | filterFragment :: (a -> Bool) -> Fragment n _ a -> Bool |
423 | 426 | ||
424 | filterFragments :: (a -> Bool) -> Stream (Fragment n d a) -> Stream (Fragment n d a) | 427 | filterFragments :: (a -> Bool) -> (FragmentStream n d a) -> (FragmentStream n d a) |
425 | filterFragments p = filterStream (filterFragment p) | 428 | filterFragments p = filterStream (filterFragment p) |
426 | 429 | ||
427 | mapFragment :: (a -> b) -> Fragment n d a -> Fragment n d b | 430 | mapFragment :: (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 | -} |
450 | data FrameBuffer (n :: Nat) b where | 453 | data 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 | ||
454 | accumulate ctx fshader fstr fb = Accumulate ctx (mapFragments fshader fstr) fb | 457 | accumulate ctx fshader fstr fb = Accumulate ctx (mapFragments fshader fstr) fb |
@@ -580,8 +583,8 @@ data Sampler = Sampler Filter EdgeMode Texture | |||
580 | texture2D :: Sampler -> Vec 2 Float -> Vec 4 Float | 583 | texture2D :: Sampler -> Vec 2 Float -> Vec 4 Float |
581 | 584 | ||
582 | 585 | ||
583 | rasterizePrimitives ctx is = mapStream (rasterize_ (\_ -> 1) is ctx) | 586 | rasterizePrimitives ctx is = concatMapStream (rasterize_ (\_ -> 1) is ctx) |
584 | rasterizePrimitivesWithPointSize ctx ps is = mapStream (rasterize_ ps is ctx) | 587 | rasterizePrimitivesWithPointSize ctx ps is = concatMapStream (rasterize_ ps is ctx) |
585 | accumulateWith ctx x = (ctx, x) | 588 | accumulateWith ctx x = (ctx, x) |
586 | overlay cl (ctx, str) = Accumulate ctx str cl | 589 | overlay cl (ctx, str) = Accumulate ctx str cl |
587 | renderFrame = ScreenOut | 590 | renderFrame = ScreenOut |