Continue transfer to mutable vectors
This commit is contained in:
+14
-19
@@ -31,14 +31,22 @@ import qualified Data.Vector.Mutable as MV
|
||||
import qualified Data.Vector.Fusion.Stream.Monadic as VS
|
||||
import Control.Monad.Primitive
|
||||
|
||||
pokeVerxs
|
||||
:: PicShads VBO
|
||||
--pokeVerxs
|
||||
-- :: PicShads VBO
|
||||
-- -> UMV.MVector (PrimState IO) Int
|
||||
-- -> [Verx]
|
||||
-- -> IO ()
|
||||
--pokeVerxs vbos count vxs = do
|
||||
-- s <- picShadToMV vbos
|
||||
-- VS.mapM_ (pokeVerx s count) $ VS.fromList vxs
|
||||
|
||||
pokeVerxs
|
||||
:: MV.MVector (PrimState IO) VShader
|
||||
-> UMV.MVector (PrimState IO) Int
|
||||
-> [Verx]
|
||||
-> IO ()
|
||||
pokeVerxs vbos count vxs = do
|
||||
s <- picShadToMV vbos
|
||||
VS.mapM_ (pokeVerx' s count) $ VS.fromList vxs
|
||||
VS.mapM_ (pokeVerx vbos count) $ VS.fromList vxs
|
||||
|
||||
vToPicShad :: UMV.MVector (PrimState IO) Int -> IO (PicShads Int)
|
||||
{-# INLINE vToPicShad #-}
|
||||
@@ -71,23 +79,10 @@ picShadToMV (PicShads a b c d e f) = do
|
||||
MV.write theVec 5 f
|
||||
return theVec
|
||||
|
||||
|
||||
|
||||
pokeVerx :: PicShads VBO -> UMV.MVector (PrimState IO) Int -> Verx -> IO ()
|
||||
--{-# INLINE pokeVerx #-}
|
||||
pokeVerx :: MV.MVector (PrimState IO) VShader -> UMV.MVector (PrimState IO) Int -> Verx -> IO ()
|
||||
pokeVerx vbos offsets Verx{_vxPos=thePos,_vxCol=theCol,_vxExt=ext,_vxShadNum=theShadNum} = do
|
||||
typeOff <- UMV.unsafeRead offsets sn
|
||||
let thePtr = plusPtr (_vboPtr $ vboFromType vbos sn) (typeOff * pokeStride sn * floatSize)
|
||||
poke34 thePtr thePos theCol
|
||||
pokeArrayOff thePtr 7 ext
|
||||
UMV.unsafeModify offsets (+1) sn
|
||||
where
|
||||
sn = _unShadNum theShadNum
|
||||
|
||||
pokeVerx' :: MV.MVector (PrimState IO) VBO -> UMV.MVector (PrimState IO) Int -> Verx -> IO ()
|
||||
pokeVerx' vbos offsets Verx{_vxPos=thePos,_vxCol=theCol,_vxExt=ext,_vxShadNum=theShadNum} = do
|
||||
typeOff <- UMV.unsafeRead offsets sn
|
||||
theShad <- MV.read vbos sn
|
||||
theShad <- fmap (_vaoVBO . _vshaderVAO) $ MV.read vbos sn
|
||||
let thePtr = plusPtr (_vboPtr theShad) (typeOff * pokeStride sn * floatSize)
|
||||
poke34 thePtr thePos theCol
|
||||
pokeArrayOff thePtr 7 ext
|
||||
|
||||
Reference in New Issue
Block a user