Use vector streams instead of streaming library
This commit is contained in:
+6
-4
@@ -23,13 +23,14 @@ import Control.Monad
|
|||||||
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 qualified Data.Vector.Fusion.Stream.Monadic as VS
|
||||||
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
|
count <- MV.replicate 6 0
|
||||||
SP.mapM_ (pokeVerx vbos count) $ SP.each vxs
|
--SP.mapM_ (pokeVerx vbos count) $ SP.each vxs
|
||||||
|
VS.mapM_ (pokeVerx vbos count) $ VS.fromList vxs
|
||||||
vToPicShad count
|
vToPicShad count
|
||||||
-- F.foldM (F.FoldM
|
-- F.foldM (F.FoldM
|
||||||
-- (\_ vx -> pokeVerx vbos count vx >> addCountVerx count vx)
|
-- (\_ vx -> pokeVerx vbos count vx >> addCountVerx count vx)
|
||||||
@@ -44,7 +45,7 @@ vToPicShad mv = mapM (MV.unsafeRead mv) $ PicShads 0 1 2 3 4 5
|
|||||||
|
|
||||||
pokeVerx :: PicShads VBO -> MV.MVector (PrimState IO) Int -> Verx -> IO ()
|
pokeVerx :: PicShads VBO -> MV.MVector (PrimState IO) Int -> Verx -> IO ()
|
||||||
--{-# INLINE pokeVerx #-}
|
--{-# INLINE pokeVerx #-}
|
||||||
pokeVerx vbos offsets Verx{_vxPos=thePos,_vxCol=theCol,_vxExt=ext,_vxShadNum=theShadNum} = do
|
pokeVerx vbos offsets !Verx{_vxPos=thePos,_vxCol=theCol,_vxExt=ext,_vxShadNum=theShadNum} = do
|
||||||
typeOff <- MV.unsafeRead offsets sn
|
typeOff <- MV.unsafeRead offsets sn
|
||||||
let thePtr = plusPtr (_vboPtr $ vboFromType vbos sn) (typeOff * pokeStride sn * floatSize)
|
let thePtr = plusPtr (_vboPtr $ vboFromType vbos sn) (typeOff * pokeStride sn * floatSize)
|
||||||
poke34 thePtr thePos theCol
|
poke34 thePtr thePos theCol
|
||||||
@@ -128,7 +129,8 @@ vboFromType ps sn = case sn of
|
|||||||
pokeLayVerxs :: PicShads VBO -> [Verx] -> IO (IM.IntMap (PicShads Int))
|
pokeLayVerxs :: PicShads VBO -> [Verx] -> IO (IM.IntMap (PicShads Int))
|
||||||
pokeLayVerxs vbos vxs = do
|
pokeLayVerxs vbos vxs = do
|
||||||
counts <- MV.replicate (6*6) 0
|
counts <- MV.replicate (6*6) 0
|
||||||
SP.mapM_ (pokeLayVerx vbos counts) $ SP.each vxs
|
--SP.mapM_ (pokeLayVerx vbos counts) $ SP.each vxs
|
||||||
|
VS.mapM_ (pokeLayVerx vbos counts) $ VS.fromList vxs
|
||||||
vToLayPicShad counts
|
vToLayPicShad counts
|
||||||
|
|
||||||
vToLayPicShad :: MV.MVector RealWorld Int -> IO (IM.IntMap (PicShads Int))
|
vToLayPicShad :: MV.MVector RealWorld Int -> IO (IM.IntMap (PicShads Int))
|
||||||
|
|||||||
Reference in New Issue
Block a user