summaryrefslogtreecommitdiff
path: root/lc
diff options
context:
space:
mode:
authorPéter Diviánszky <divipp@gmail.com>2016-02-29 19:50:40 +0100
committerPéter Diviánszky <divipp@gmail.com>2016-02-29 19:51:44 +0100
commita751f908b0779810f73b976541deab94c008085e (patch)
treeac0111854fc4a49bac39aeceb5ec450ec02b8576 /lc
parent976dddd4758849362a5433ce9095d7be15bf18b4 (diff)
renames
Diffstat (limited to 'lc')
-rw-r--r--lc/Builtins.lc67
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
214concatMap :: (a -> [b]) -> [a] -> [b] 214concatMap :: (a -> [b]) -> [a] -> [b]
215concatMap f x = concat (map f x) 215concatMap f x = concat (map f x)
216 216
217len [] = 0
218len (x:xs) = 1 `primAddInt` len xs
219
217------------------- 220-------------------
218 221
219data Maybe a 222data Maybe a
@@ -256,7 +259,11 @@ type family ListElem a where ListElem [a] = a
256 259
257fetchArrays :: forall a t t' . ({-AttributeTuple t, -} t ~ map ListElem t') => HList t' -> PrimitiveStream a (HList t) 260fetchArrays :: forall a t t' . ({-AttributeTuple t, -} t ~ map ListElem t') => HList t' -> PrimitiveStream a (HList t)
258 261
259fetch :: forall a t . {-(AttributeTuple t) => -} String -> t -> PrimitiveStream a t 262fetch :: forall a t . {-(AttributeTuple t) => -} String -> HList t -> PrimitiveStream a (HList t)
263
264Attribute :: String -> t
265
266fetchStream :: 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
289data ImageSemantics = Depth Type | Stencil Type | Color Type 296data ImageKind
297 = Color Type
298 | Depth
299 | Stencil
290 300
291data Image (n :: Nat) (t :: ImageSemantics) -- = Vector n [[t]] 301imageType :: ImageKind -> Type
302imageType (Color a) = a
303imageType Depth = 'Float
304imageType Stencil = 'Int
305
306data Image (n :: Nat) (t :: ImageKind) -- = Vector n [[imageType t]]
292 307
293ColorImage :: forall a d t color . (Num t, color ~ VecScalar d t) 308ColorImage :: forall a d t color . (Num t, color ~ VecScalar d t)
294 => color -> Image a (Color color) 309 => color -> Image a (Color color)
295DepthImage :: forall a . Float -> Image a (Depth Float) 310DepthImage :: forall a . Float -> Image a Depth
296StencilImage :: forall a . Int -> Image a (Stencil Int) 311StencilImage :: forall a . Int -> Image a Stencil
297 312
298emptyDepthImage = DepthImage @1 313emptyDepthImage = DepthImage @1
299emptyColorImage = ColorImage @1 314emptyColorImage = ColorImage @1
@@ -344,8 +359,8 @@ swizzvector v w | definedVec v = mapVec (swizzscalar v) w
344----------------------------------------------------------------------------- 359-----------------------------------------------------------------------------
345 360
346data BlendingFactor 361data 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
438Uniform :: String -> t 453Uniform :: String -> t
439Attribute :: String -> t
440 454
441data RasterContext a :: PrimitiveType -> Type where 455data 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
453data StencilTests 467data StencilTests
454data StencilOps 468data StencilOps
455data Int32
456 469
457data FragmentOperation :: ImageSemantics -> Type where 470data 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
462data Interpolated t where 475data Interpolated t where
463 Smooth, NoPerspective 476 Smooth, NoPerspective
@@ -484,41 +497,37 @@ allSame (x: y: xs) = 'T2 (x ~ y) (allSame (y:xs))
484sameLayerCounts a = allSame (map 'ImageLC a) 497sameLayerCounts a = allSame (map 'ImageLC a)
485 498
486{- 499{-
487defaultFragOp :: forall (a :: ImageSemantics) -> FragmentOperation a 500defaultFragOp :: forall (a :: ImageKind) -> FragmentOperation a
488defaultFragOp (Color '(VecS Float 4)) = ColorOp NoBlending (V4 True True True True) 501defaultFragOp (Color '(VecS Float 4)) = ColorOp NoBlending (V4 True True True True)
489defaultFragOp (Depth 'Float) = DepthOp Less True 502defaultFragOp Depth = DepthOp Less True
490 503
491class DefaultFragOps a where defaultFragOps :: a 504class DefaultFragOps a where defaultFragOps :: a
492instance (DefaultFragOp a, DefaultFragOp b) => DefaultFragOps (FragmentOperation a, FragmentOperation b) where 505instance (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-}
496data FrameBuffer (n :: Nat) (t :: [ImageSemantics]) 509data FrameBuffer (n :: Nat) (t :: [ImageKind])
497
498remSemantics :: ImageSemantics -> Type
499remSemantics (Color a) = a
500remSemantics (Depth a) = a
501remSemantics (Stencil a) = a
502 510
503remSemantics' :: [ImageSemantics] -> [Type] 511imageType' :: [ImageKind] -> [Type]
504remSemantics' (Depth _: x) = map remSemantics x 512imageType' (Depth: x) = map imageType x
505remSemantics' x = map remSemantics x 513imageType' x = map imageType x
506 514
507type family FragmentOperationSem a :: ImageSemantics where FragmentOperationSem (FragmentOperation x) = x 515type family FragmentOperationKind a :: ImageKind where FragmentOperationKind (FragmentOperation x) = x
508 516
509Accumulate :: forall (n :: Nat) (c :: [Type]) . (b ~ map FragmentOperationSem c) => HList c -> FragmentStream n (HList (remSemantics' b)) -> FrameBuffer n b -> FrameBuffer n b 517Accumulate :: forall (n :: Nat) (c :: [Type]) . (b ~ map FragmentOperationKind c) => HList c -> FragmentStream n (HList (imageType' b)) -> FrameBuffer n b -> FrameBuffer n b
510 518
511accumulateWith ctx x = (ctx, x) 519accumulateWith ctx x = (ctx, x)
512overlay cl (ctx, str) = Accumulate ctx str cl 520overlay cl (ctx, str) = Accumulate ctx str cl
513 521
514infixl 0 `overlay` 522infixl 0 `overlay`
515 523
516type family ImageSem a :: ImageSemantics where ImageSem (Image n t) = t 524type 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
521FrameBuffer :: forall (a :: [Type]) . (sameLayerCounts a) => HList a -> FrameBuffer (ImageLC (head a)) (map ImageSem a) 529-- todo: rename to imageFrame
530FrameBuffer :: forall (a :: [Type]) . (sameLayerCounts a) => HList a -> FrameBuffer (ImageLC (head a)) (map GetImageKind a)
522 531
523imageFrame = FrameBuffer 532imageFrame = 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
528PrjImage :: FrameBuffer 1 '[a] -> Image 1 a 537PrjImage :: FrameBuffer 1 '[a] -> Image 1 a
529PrjImageColor :: FrameBuffer 1 '[ 'Depth Float, 'Color (Vec 4 Float)] -> Image 1 (Color (Vec 4 Float)) 538PrjImageColor :: FrameBuffer 1 '[ 'Depth, 'Color (Vec 4 Float)] -> Image 1 (Color (Vec 4 Float))
530 539
531data Output where 540data Output where
532 ScreenOut :: FrameBuffer a b -> Output 541 ScreenOut :: FrameBuffer a b -> Output