Stream vertex poking
This commit is contained in:
+1
-1
@@ -49,7 +49,7 @@ dependencies:
|
|||||||
- QuickCheck
|
- QuickCheck
|
||||||
- extra
|
- extra
|
||||||
- primitive
|
- primitive
|
||||||
#- streaming
|
- streaming
|
||||||
|
|
||||||
library:
|
library:
|
||||||
source-dirs: src
|
source-dirs: src
|
||||||
|
|||||||
+1
-1
@@ -161,7 +161,7 @@ pokeBindFoldableLayer
|
|||||||
-> IO (IM.IntMap (PicShads Int))
|
-> IO (IM.IntMap (PicShads Int))
|
||||||
pokeBindFoldableLayer pdata m = do
|
pokeBindFoldableLayer pdata m = do
|
||||||
let shads = _pictureShaders pdata
|
let shads = _pictureShaders pdata
|
||||||
slist'' <- pokeLayVerxsFold (fmap (_vaoVBO . _vshaderVAO) shads) m
|
slist'' <- pokeLayVerxs (fmap (_vaoVBO . _vshaderVAO) shads) m
|
||||||
bindShaderLay shads slist''
|
bindShaderLay shads slist''
|
||||||
return slist''
|
return slist''
|
||||||
|
|
||||||
|
|||||||
+30
-32
@@ -6,7 +6,7 @@ module Shader.Poke
|
|||||||
, pokePoint3s
|
, pokePoint3s
|
||||||
, pokePoint33s
|
, pokePoint33s
|
||||||
, pokeVerxs
|
, pokeVerxs
|
||||||
, pokeLayVerxsFold
|
, pokeLayVerxs
|
||||||
, poke224s
|
, poke224s
|
||||||
) where
|
) where
|
||||||
import Shader.Data
|
import Shader.Data
|
||||||
@@ -24,23 +24,20 @@ import qualified Control.Foldl as F
|
|||||||
import qualified Data.IntMap.Strict as IM
|
import qualified Data.IntMap.Strict as IM
|
||||||
--import Control.Lens
|
--import Control.Lens
|
||||||
import qualified Data.Vector.Unboxed.Mutable as MV
|
import qualified Data.Vector.Unboxed.Mutable as MV
|
||||||
|
import qualified Streaming.Prelude as SP
|
||||||
import Control.Monad.Primitive
|
import Control.Monad.Primitive
|
||||||
|
|
||||||
pokeVerxs :: PicShads VBO -> [Verx] -> IO (PicShads Int)
|
pokeVerxs :: PicShads VBO -> [Verx] -> IO (PicShads Int)
|
||||||
pokeVerxs vbos vxs = do
|
pokeVerxs vbos vxs = do
|
||||||
count <- (MV.replicate 6 0 :: IO (MV.MVector (PrimState IO) Int))
|
count <- MV.replicate 6 0
|
||||||
F.foldM (F.FoldM
|
SP.mapM_ (\vx -> pokeVerx vbos count vx >> addCountVerx count vx) $ SP.each vxs
|
||||||
(\_ vx -> pokeVerx vbos count vx >> addCountVerx count vx)
|
vToPicShad count
|
||||||
(return ())
|
-- F.foldM (F.FoldM
|
||||||
(const (vToPicShad count))
|
-- (\_ vx -> pokeVerx vbos count vx >> addCountVerx count vx)
|
||||||
)
|
-- (return ())
|
||||||
vxs
|
-- (const (vToPicShad count))
|
||||||
|
-- )
|
||||||
pokeVerxs' :: PicShads VBO -> [Verx] -> IO (PicShads Int)
|
-- vxs
|
||||||
pokeVerxs' vbos = F.foldM $ F.FoldM
|
|
||||||
(\count vx -> pokeVerx vbos count vx >> addCountVerx count vx >> return count)
|
|
||||||
(MV.replicate 6 0)
|
|
||||||
vToPicShad
|
|
||||||
|
|
||||||
vToPicShad :: MV.MVector (PrimState IO) Int -> IO (PicShads Int)
|
vToPicShad :: MV.MVector (PrimState IO) Int -> IO (PicShads Int)
|
||||||
vToPicShad mv = mapM (MV.unsafeRead mv) $ PicShads 0 1 2 3 4 5
|
vToPicShad mv = mapM (MV.unsafeRead mv) $ PicShads 0 1 2 3 4 5
|
||||||
@@ -96,7 +93,7 @@ addCountVerx :: MV.MVector (PrimState IO) Int -> Verx -> IO ()
|
|||||||
{-# INLINE addCountVerx #-}
|
{-# INLINE addCountVerx #-}
|
||||||
addCountVerx vec vx = MV.unsafeModify vec (+1) (_unShadNum $ _vxShadNum vx)
|
addCountVerx vec vx = MV.unsafeModify vec (+1) (_unShadNum $ _vxShadNum vx)
|
||||||
|
|
||||||
pokeArrayOff :: Storable a => Ptr a -> Int -> [a] -> IO ()
|
pokeArrayOff :: Ptr Float -> Int -> [Float] -> IO ()
|
||||||
--{-# INLINE pokeArrayOff #-}
|
--{-# INLINE pokeArrayOff #-}
|
||||||
pokeArrayOff ptr i = pokeArray (plusPtr ptr (floatSize * i))
|
pokeArrayOff ptr i = pokeArray (plusPtr ptr (floatSize * i))
|
||||||
|
|
||||||
@@ -127,7 +124,8 @@ pokePoint3s ptr vals0 = go vals0 0
|
|||||||
where
|
where
|
||||||
off i = n*3 + i
|
off i = n*3 + i
|
||||||
|
|
||||||
comLayVerx :: PicShads VBO -> MV.MVector (PrimState IO) Int -> Verx -> IO (MV.MVector (PrimState IO) Int)
|
--comLayVerx :: PicShads VBO -> MV.MVector (PrimState IO) Int -> () -> Verx -> IO (MV.MVector (PrimState IO) Int)
|
||||||
|
comLayVerx :: PicShads VBO -> MV.MVector (PrimState IO) Int -> Verx -> IO ()
|
||||||
--{-# INLINE comLayVerx #-}
|
--{-# INLINE comLayVerx #-}
|
||||||
comLayVerx vbos counts vx = do
|
comLayVerx vbos counts vx = do
|
||||||
theOff <- MV.unsafeRead counts vecPos
|
theOff <- MV.unsafeRead counts vecPos
|
||||||
@@ -135,14 +133,14 @@ comLayVerx vbos counts vx = do
|
|||||||
poke34 thePtr thePos theCol
|
poke34 thePtr thePos theCol
|
||||||
pokeVerxType thePtr theType
|
pokeVerxType thePtr theType
|
||||||
MV.unsafeModify counts (+ 1) vecPos
|
MV.unsafeModify counts (+ 1) vecPos
|
||||||
return counts
|
|
||||||
where
|
where
|
||||||
vecPos = theLayer * 6 + _unShadNum (_vxShadNum vx)
|
sn = _unShadNum (_vxShadNum vx)
|
||||||
|
vecPos = theLayer * 6 + sn
|
||||||
theLayer = _vxLayer vx
|
theLayer = _vxLayer vx
|
||||||
theType = _vxType vx
|
theType = _vxType vx
|
||||||
thePos = _vxPos vx
|
thePos = _vxPos vx
|
||||||
theCol = _vxCol vx
|
theCol = _vxCol vx
|
||||||
basePtr = _vboPtr $ vboFromType vbos theType
|
basePtr = _vboPtr $ vboFromType vbos sn
|
||||||
layOff = theLayer * numSubElements
|
layOff = theLayer * numSubElements
|
||||||
theStride = pokeStride theType
|
theStride = pokeStride theType
|
||||||
|
|
||||||
@@ -157,22 +155,22 @@ pokeVerxType thePtr vt = case vt of
|
|||||||
>> pokeElemOff thePtr 9 z
|
>> pokeElemOff thePtr 9 z
|
||||||
_ -> return ()
|
_ -> return ()
|
||||||
|
|
||||||
vboFromType :: PicShads VBO -> VertexType -> VBO
|
vboFromType :: PicShads VBO -> Int -> VBO
|
||||||
{-# INLINE vboFromType #-}
|
{-# INLINE vboFromType #-}
|
||||||
vboFromType ps vt = case vt of
|
vboFromType ps sn = case sn of
|
||||||
PolyV -> _psPoly ps
|
0 -> _psPoly ps
|
||||||
PolyzV{} -> _psPolyz ps
|
1 -> _psPolyz ps
|
||||||
BezV{} -> _psBez ps
|
2 -> _psBez ps
|
||||||
TextV{} -> _psText ps
|
3 -> _psText ps
|
||||||
ArcV{} -> _psArc ps
|
4 -> _psArc ps
|
||||||
EllV -> _psEll ps
|
5 -> _psEll ps
|
||||||
|
|
||||||
|
|
||||||
pokeLayVerxsFold :: PicShads VBO -> [Verx] -> IO (IM.IntMap (PicShads Int))
|
pokeLayVerxs :: PicShads VBO -> [Verx] -> IO (IM.IntMap (PicShads Int))
|
||||||
pokeLayVerxsFold vbos = F.foldM $ F.FoldM
|
pokeLayVerxs vbos vxs = do
|
||||||
(comLayVerx vbos)
|
counts <- MV.replicate (6*6) 0
|
||||||
(MV.replicate (6*6) 0)
|
SP.mapM_ (comLayVerx vbos counts) $ SP.each vxs
|
||||||
vToLayPicShad
|
vToLayPicShad counts
|
||||||
|
|
||||||
vToLayPicShad :: MV.MVector RealWorld Int -> IO (IM.IntMap (PicShads Int))
|
vToLayPicShad :: MV.MVector RealWorld Int -> IO (IM.IntMap (PicShads Int))
|
||||||
vToLayPicShad mv = foldM f IM.empty [0..5]
|
vToLayPicShad mv = foldM f IM.empty [0..5]
|
||||||
|
|||||||
Reference in New Issue
Block a user