Rendering optimisations (mainly inlining)
This commit is contained in:
@@ -37,6 +37,8 @@ module Shader.Data
|
||||
-- TODO make lenses for VBO object
|
||||
-- , textureObject
|
||||
) where
|
||||
--import Geometry.Data
|
||||
|
||||
import Graphics.Rendering.OpenGL
|
||||
import Foreign
|
||||
import Control.Lens
|
||||
@@ -139,6 +141,14 @@ data FullShader = FullShader
|
||||
{- | Datatype containing the reference to a texture object. -}
|
||||
newtype ShaderTexture = ShaderTexture
|
||||
{ _textureObject :: TextureObject }
|
||||
--data PicVerxs = PicVerxs
|
||||
-- { _pvPoly :: (Point3,Point4)
|
||||
-- , _pvPolyz :: (Point3,Point4,Float)
|
||||
-- , _pvBez :: (Point3,Point4,Point4)
|
||||
-- , _pvText :: (Point3,Point4,Point2)
|
||||
-- , _pvArc :: (Point3,Point3,Point3)
|
||||
-- , _pvEll :: (Point3,Point4)
|
||||
-- }
|
||||
|
||||
data EPrimitiveMode
|
||||
= EPoints
|
||||
|
||||
+31
-10
@@ -7,6 +7,8 @@ module Shader.Poke
|
||||
, pokePoint33s
|
||||
, pokeVerxs
|
||||
, pokeLayVerxs
|
||||
, pokeLayVerxsPart
|
||||
, pokeLayVerxsPartM
|
||||
, pokeLayVerxsM
|
||||
, poke224s
|
||||
) where
|
||||
@@ -22,7 +24,7 @@ import Foreign
|
||||
import Control.Monad
|
||||
--import qualified Control.Foldl as F
|
||||
--import qualified Data.IntMap.Strict as IM
|
||||
import Control.Lens
|
||||
--import Control.Lens
|
||||
|
||||
pokeVerxs :: PicShads VBO -> [Verx] -> IO (PicShads Int)
|
||||
pokeVerxs vbos vxs0 = go vxs0 (pure 0)
|
||||
@@ -32,7 +34,7 @@ pokeVerxs vbos vxs0 = go vxs0 (pure 0)
|
||||
|
||||
-- this is very brittle, but want to optimise speed if possible here
|
||||
pokeVerx :: PicShads VBO -> PicShads Int -> Verx -> IO ()
|
||||
--{-# INLINE pokeVerx #-}
|
||||
{-# INLINE pokeVerx #-}
|
||||
pokeVerx vbos offsets Verx{_vxPos=thePos,_vxCol=theCol,_vxType=theType} = case theType of
|
||||
PolyV -> poke34 (plusPtr (_vboPtr $ _psPoly vbos) (_psPoly offsets * 7 * floatSize)) thePos theCol
|
||||
PolyzV x -> poke34 thePtr thePos theCol
|
||||
@@ -124,6 +126,17 @@ pokeLayVerxsM !vbos = foldM f (pure $ pure 0)
|
||||
where
|
||||
f counts vx = pokeLayVerx vbos counts vx >> return (addLayCountVerx counts vx)
|
||||
|
||||
pokeLayVerxsPartM :: PicShads VBO -> [Verx] -> Layers (PicShads Int) -> IO (Layers (PicShads Int))
|
||||
pokeLayVerxsPartM !vbos vxs0 count0 = foldM f count0 vxs0
|
||||
where
|
||||
f counts vx = pokeLayVerx vbos counts vx >> return (addLayCountVerx counts vx)
|
||||
|
||||
pokeLayVerxsPart :: PicShads VBO -> [Verx] -> Layers (PicShads Int) -> IO (Layers (PicShads Int))
|
||||
pokeLayVerxsPart !vbos vxs0 count0 = go vxs0 count0
|
||||
where
|
||||
go [] count = return count
|
||||
go (!vx:vxs) !count = pokeLayVerx vbos count vx >> (go vxs $! addLayCountVerx count vx)
|
||||
|
||||
pokeLayVerxs :: PicShads VBO -> [Verx] -> IO (Layers (PicShads Int))
|
||||
pokeLayVerxs !vbos vxs0 = go vxs0 (pure (pure 0))
|
||||
where
|
||||
@@ -132,7 +145,7 @@ pokeLayVerxs !vbos vxs0 = go vxs0 (pure (pure 0))
|
||||
|
||||
-- this is very brittle, but want to optimise speed if possible here
|
||||
pokeLayVerx :: PicShads VBO -> Layers (PicShads Int) -> Verx -> IO ()
|
||||
--{-# INLINE pokeLayVerx #-}
|
||||
{-# INLINE pokeLayVerx #-}
|
||||
pokeLayVerx vbos imoffsets Verx{_vxPos=thePos,_vxCol=theCol,_vxType=theType, _vxLayer = theLay} = case theType of
|
||||
PolyV -> poke34 (plusPtr (_vboPtr $ _psPoly vbos) ((_psPoly offsets + layOff) * 7 * floatSize)) thePos theCol
|
||||
PolyzV x -> poke34 thePtr thePos theCol
|
||||
@@ -164,13 +177,21 @@ pokeLayVerx vbos imoffsets Verx{_vxPos=thePos,_vxCol=theCol,_vxType=theType, _vx
|
||||
|
||||
addLayCountVerx :: Layers (PicShads Int) -> Verx -> Layers (PicShads Int)
|
||||
--{-# INLINE addLayCountVerx #-}
|
||||
addLayCountVerx !m !vx = case _vxLayer vx of
|
||||
0 -> m & lay0 %~ f
|
||||
1 -> m & lay1 %~ f
|
||||
2 -> m & lay2 %~ f
|
||||
3 -> m & lay3 %~ f
|
||||
4 -> m & lay4 %~ f
|
||||
5 -> m & lay5 %~ f
|
||||
addLayCountVerx !m@Layers
|
||||
{ _lay0 = a0
|
||||
, _lay1 = a1
|
||||
, _lay2 = a2
|
||||
, _lay3 = a3
|
||||
, _lay4 = a4
|
||||
, _lay5 = a5
|
||||
}
|
||||
!vx = case _vxLayer vx of
|
||||
0 -> m { _lay0 = f a0 }
|
||||
1 -> m { _lay1 = f a1 }
|
||||
2 -> m { _lay2 = f a2 }
|
||||
3 -> m { _lay3 = f a3 }
|
||||
4 -> m { _lay4 = f a4 }
|
||||
5 -> m { _lay5 = f a5 }
|
||||
_ -> undefined
|
||||
where
|
||||
f = flip addCountVerx vx
|
||||
|
||||
Reference in New Issue
Block a user