diff options
Diffstat (limited to 'lc/Builtins.lc')
-rw-r--r-- | lc/Builtins.lc | 38 |
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) | |||
372 | fetch s a t = fetch_ @a s t | 372 | fetch s a t = fetch_ @a s t |
373 | fetchArrays a t = fetchArrays_ @a t | 373 | fetchArrays a t = fetchArrays_ @a t |
374 | 374 | ||
375 | data DepthHandler = NoDepth | DefinedDepth | ||
376 | {- todo: remove? | ||
377 | type 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 | -} | ||
391 | type family RemSemantics a where | 375 | type 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 |
406 | data Fragment :: Nat -> DepthHandler -> Type -> Type | 389 | data Fragment :: Nat -> Type -> Type |
407 | 390 | ||
408 | type FragmentStream n a t = Stream (Fragment n a t) | 391 | type FragmentStream n t = Stream (Fragment n t) |
409 | 392 | ||
410 | customizeDepth :: (a -> Float) -> Fragment n _ a -> Fragment n DefinedDepth a | 393 | customizeDepth :: (a -> Float) -> Fragment n a -> Fragment n a |
411 | 394 | ||
412 | customizeDepths f = mapStream (customizeDepth f) | 395 | customizeDepths f = mapStream (customizeDepth f) |
413 | {- todo: remove? | ||
414 | noDepth :: Fragment n _ a -> Fragment n NoDepth a | ||
415 | |||
416 | noDepths = mapStream noDepth | ||
417 | -} | ||
418 | 396 | ||
419 | rasterize_ :: (b ~ InterpolatedType y, a ~ JoinTupleType (Vec 4 Float) b) | 397 | rasterize_ :: (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 | ||
425 | filterFragment :: (a -> Bool) -> Fragment n _ a -> Bool | 403 | filterFragment :: (a -> Bool) -> Fragment n a -> Bool |
426 | 404 | ||
427 | filterFragments :: (a -> Bool) -> (FragmentStream n d a) -> (FragmentStream n d a) | 405 | filterFragments :: (a -> Bool) -> (FragmentStream n a) -> (FragmentStream n a) |
428 | filterFragments p = filterStream (filterFragment p) | 406 | filterFragments p = filterStream (filterFragment p) |
429 | 407 | ||
430 | mapFragment :: (a -> b) -> Fragment n d a -> Fragment n d b | 408 | mapFragment :: (a -> b) -> Fragment n a -> Fragment n b |
431 | 409 | ||
432 | mapFragments f = mapStream (mapFragment f) | 410 | mapFragments 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 | -} |
453 | data FrameBuffer (n :: Nat) b where | 431 | data 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 | ||
457 | accumulate ctx fshader fstr fb = Accumulate ctx (mapFragments fshader fstr) fb | 435 | accumulate ctx fshader fstr fb = Accumulate ctx (mapFragments fshader fstr) fb |