diff options
author | Péter Diviánszky <divipp@gmail.com> | 2016-02-29 19:50:40 +0100 |
---|---|---|
committer | Péter Diviánszky <divipp@gmail.com> | 2016-02-29 19:51:44 +0100 |
commit | a751f908b0779810f73b976541deab94c008085e (patch) | |
tree | ac0111854fc4a49bac39aeceb5ec450ec02b8576 /lc | |
parent | 976dddd4758849362a5433ce9095d7be15bf18b4 (diff) |
renames
Diffstat (limited to 'lc')
-rw-r--r-- | lc/Builtins.lc | 67 |
1 files changed, 38 insertions, 29 deletions
diff --git a/lc/Builtins.lc b/lc/Builtins.lc index 32c7e014..fb7c288f 100644 --- a/lc/Builtins.lc +++ b/lc/Builtins.lc | |||
@@ -214,6 +214,9 @@ map f (x:xs) = f x : map f xs | |||
214 | concatMap :: (a -> [b]) -> [a] -> [b] | 214 | concatMap :: (a -> [b]) -> [a] -> [b] |
215 | concatMap f x = concat (map f x) | 215 | concatMap f x = concat (map f x) |
216 | 216 | ||
217 | len [] = 0 | ||
218 | len (x:xs) = 1 `primAddInt` len xs | ||
219 | |||
217 | ------------------- | 220 | ------------------- |
218 | 221 | ||
219 | data Maybe a | 222 | data Maybe a |
@@ -256,7 +259,11 @@ type family ListElem a where ListElem [a] = a | |||
256 | 259 | ||
257 | fetchArrays :: forall a t t' . ({-AttributeTuple t, -} t ~ map ListElem t') => HList t' -> PrimitiveStream a (HList t) | 260 | fetchArrays :: forall a t t' . ({-AttributeTuple t, -} t ~ map ListElem t') => HList t' -> PrimitiveStream a (HList t) |
258 | 261 | ||
259 | fetch :: forall a t . {-(AttributeTuple t) => -} String -> t -> PrimitiveStream a t | 262 | fetch :: forall a t . {-(AttributeTuple t) => -} String -> HList t -> PrimitiveStream a (HList t) |
263 | |||
264 | Attribute :: String -> t | ||
265 | |||
266 | fetchStream :: forall p (t :: [Type]) . String -> forall (as :: [String]) -> len as ~ len t => PrimitiveStream p (HList t) | ||
260 | 267 | ||
261 | ------------------------------------------------------ | 268 | ------------------------------------------------------ |
262 | 269 | ||
@@ -286,14 +293,22 @@ mapFragments f = map (mapFragment f) | |||
286 | 293 | ||
287 | ------------------------------------------------------------------------- | 294 | ------------------------------------------------------------------------- |
288 | 295 | ||
289 | data ImageSemantics = Depth Type | Stencil Type | Color Type | 296 | data ImageKind |
297 | = Color Type | ||
298 | | Depth | ||
299 | | Stencil | ||
290 | 300 | ||
291 | data Image (n :: Nat) (t :: ImageSemantics) -- = Vector n [[t]] | 301 | imageType :: ImageKind -> Type |
302 | imageType (Color a) = a | ||
303 | imageType Depth = 'Float | ||
304 | imageType Stencil = 'Int | ||
305 | |||
306 | data Image (n :: Nat) (t :: ImageKind) -- = Vector n [[imageType t]] | ||
292 | 307 | ||
293 | ColorImage :: forall a d t color . (Num t, color ~ VecScalar d t) | 308 | ColorImage :: forall a d t color . (Num t, color ~ VecScalar d t) |
294 | => color -> Image a (Color color) | 309 | => color -> Image a (Color color) |
295 | DepthImage :: forall a . Float -> Image a (Depth Float) | 310 | DepthImage :: forall a . Float -> Image a Depth |
296 | StencilImage :: forall a . Int -> Image a (Stencil Int) | 311 | StencilImage :: forall a . Int -> Image a Stencil |
297 | 312 | ||
298 | emptyDepthImage = DepthImage @1 | 313 | emptyDepthImage = DepthImage @1 |
299 | emptyColorImage = ColorImage @1 | 314 | emptyColorImage = ColorImage @1 |
@@ -344,8 +359,8 @@ swizzvector v w | definedVec v = mapVec (swizzscalar v) w | |||
344 | ----------------------------------------------------------------------------- | 359 | ----------------------------------------------------------------------------- |
345 | 360 | ||
346 | data BlendingFactor | 361 | data BlendingFactor |
347 | = Zero' --- FIXME: modified | 362 | = ZeroBF |
348 | | One | 363 | | OneBF |
349 | | SrcColor | 364 | | SrcColor |
350 | | OneMinusSrcColor | 365 | | OneMinusSrcColor |
351 | | DstColor | 366 | | DstColor |
@@ -436,7 +451,6 @@ primTexture :: () -> Vec 2 Float -> Vec 4 Float | |||
436 | 451 | ||
437 | -- builtins | 452 | -- builtins |
438 | Uniform :: String -> t | 453 | Uniform :: String -> t |
439 | Attribute :: String -> t | ||
440 | 454 | ||
441 | data RasterContext a :: PrimitiveType -> Type where | 455 | data RasterContext a :: PrimitiveType -> Type where |
442 | TriangleCtx :: CullMode -> PolygonMode a -> PolygonOffset -> ProvokingVertex -> RasterContext a Triangle | 456 | TriangleCtx :: CullMode -> PolygonMode a -> PolygonOffset -> ProvokingVertex -> RasterContext a Triangle |
@@ -452,12 +466,11 @@ data Blending :: Type -> Type where | |||
452 | 466 | ||
453 | data StencilTests | 467 | data StencilTests |
454 | data StencilOps | 468 | data StencilOps |
455 | data Int32 | ||
456 | 469 | ||
457 | data FragmentOperation :: ImageSemantics -> Type where | 470 | data FragmentOperation :: ImageKind -> Type where |
458 | ColorOp :: Num c => Blending c -> VecScalar d Bool -> FragmentOperation (Color (VecScalar d c)) | 471 | ColorOp :: Num c => Blending c -> VecScalar d Bool -> FragmentOperation (Color (VecScalar d c)) |
459 | DepthOp :: ComparisonFunction -> Bool -> FragmentOperation (Depth Float) | 472 | DepthOp :: ComparisonFunction -> Bool -> FragmentOperation Depth |
460 | StencilOp :: StencilTests -> StencilOps -> StencilOps -> FragmentOperation (Stencil Int32) | 473 | StencilOp :: StencilTests -> StencilOps -> StencilOps -> FragmentOperation Stencil |
461 | 474 | ||
462 | data Interpolated t where | 475 | data Interpolated t where |
463 | Smooth, NoPerspective | 476 | Smooth, NoPerspective |
@@ -484,41 +497,37 @@ allSame (x: y: xs) = 'T2 (x ~ y) (allSame (y:xs)) | |||
484 | sameLayerCounts a = allSame (map 'ImageLC a) | 497 | sameLayerCounts a = allSame (map 'ImageLC a) |
485 | 498 | ||
486 | {- | 499 | {- |
487 | defaultFragOp :: forall (a :: ImageSemantics) -> FragmentOperation a | 500 | defaultFragOp :: forall (a :: ImageKind) -> FragmentOperation a |
488 | defaultFragOp (Color '(VecS Float 4)) = ColorOp NoBlending (V4 True True True True) | 501 | defaultFragOp (Color '(VecS Float 4)) = ColorOp NoBlending (V4 True True True True) |
489 | defaultFragOp (Depth 'Float) = DepthOp Less True | 502 | defaultFragOp Depth = DepthOp Less True |
490 | 503 | ||
491 | class DefaultFragOps a where defaultFragOps :: a | 504 | class DefaultFragOps a where defaultFragOps :: a |
492 | instance (DefaultFragOp a, DefaultFragOp b) => DefaultFragOps (FragmentOperation a, FragmentOperation b) where | 505 | instance (DefaultFragOp a, DefaultFragOp b) => DefaultFragOps (FragmentOperation a, FragmentOperation b) where |
493 | defaultFragOps = -- (undefined @(), undefined) | 506 | defaultFragOps = -- (undefined @(), undefined) |
494 | (defaultFragOp @a @_, defaultFragOp @b @_) | 507 | (defaultFragOp @a @_, defaultFragOp @b @_) |
495 | -} | 508 | -} |
496 | data FrameBuffer (n :: Nat) (t :: [ImageSemantics]) | 509 | data FrameBuffer (n :: Nat) (t :: [ImageKind]) |
497 | |||
498 | remSemantics :: ImageSemantics -> Type | ||
499 | remSemantics (Color a) = a | ||
500 | remSemantics (Depth a) = a | ||
501 | remSemantics (Stencil a) = a | ||
502 | 510 | ||
503 | remSemantics' :: [ImageSemantics] -> [Type] | 511 | imageType' :: [ImageKind] -> [Type] |
504 | remSemantics' (Depth _: x) = map remSemantics x | 512 | imageType' (Depth: x) = map imageType x |
505 | remSemantics' x = map remSemantics x | 513 | imageType' x = map imageType x |
506 | 514 | ||
507 | type family FragmentOperationSem a :: ImageSemantics where FragmentOperationSem (FragmentOperation x) = x | 515 | type family FragmentOperationKind a :: ImageKind where FragmentOperationKind (FragmentOperation x) = x |
508 | 516 | ||
509 | Accumulate :: forall (n :: Nat) (c :: [Type]) . (b ~ map FragmentOperationSem c) => HList c -> FragmentStream n (HList (remSemantics' b)) -> FrameBuffer n b -> FrameBuffer n b | 517 | Accumulate :: forall (n :: Nat) (c :: [Type]) . (b ~ map FragmentOperationKind c) => HList c -> FragmentStream n (HList (imageType' b)) -> FrameBuffer n b -> FrameBuffer n b |
510 | 518 | ||
511 | accumulateWith ctx x = (ctx, x) | 519 | accumulateWith ctx x = (ctx, x) |
512 | overlay cl (ctx, str) = Accumulate ctx str cl | 520 | overlay cl (ctx, str) = Accumulate ctx str cl |
513 | 521 | ||
514 | infixl 0 `overlay` | 522 | infixl 0 `overlay` |
515 | 523 | ||
516 | type family ImageSem a :: ImageSemantics where ImageSem (Image n t) = t | 524 | type family GetImageKind a :: ImageKind where GetImageKind (Image n t) = t |
517 | 525 | ||
518 | --class ValidFrameBuffer (a :: [ImageSemantics]) | 526 | --class ValidFrameBuffer (a :: [ImageKind]) |
519 | --instance ValidFrameBuffer a -- TODO | 527 | --instance ValidFrameBuffer a -- TODO |
520 | 528 | ||
521 | FrameBuffer :: forall (a :: [Type]) . (sameLayerCounts a) => HList a -> FrameBuffer (ImageLC (head a)) (map ImageSem a) | 529 | -- todo: rename to imageFrame |
530 | FrameBuffer :: forall (a :: [Type]) . (sameLayerCounts a) => HList a -> FrameBuffer (ImageLC (head a)) (map GetImageKind a) | ||
522 | 531 | ||
523 | imageFrame = FrameBuffer | 532 | imageFrame = FrameBuffer |
524 | 533 | ||
@@ -526,7 +535,7 @@ accumulate ctx fshader fstr fb = Accumulate ctx (mapFragments fshader fstr) fb | |||
526 | 535 | ||
527 | -- texture support | 536 | -- texture support |
528 | PrjImage :: FrameBuffer 1 '[a] -> Image 1 a | 537 | PrjImage :: FrameBuffer 1 '[a] -> Image 1 a |
529 | PrjImageColor :: FrameBuffer 1 '[ 'Depth Float, 'Color (Vec 4 Float)] -> Image 1 (Color (Vec 4 Float)) | 538 | PrjImageColor :: FrameBuffer 1 '[ 'Depth, 'Color (Vec 4 Float)] -> Image 1 (Color (Vec 4 Float)) |
530 | 539 | ||
531 | data Output where | 540 | data Output where |
532 | ScreenOut :: FrameBuffer a b -> Output | 541 | ScreenOut :: FrameBuffer a b -> Output |