Continue mutability changes
This commit is contained in:
+3
-2
@@ -166,8 +166,9 @@ pokeBindFoldableLayer
|
||||
pokeBindFoldableLayer pdata m = do
|
||||
let shads = _pictureShaders pdata
|
||||
shadV <- picShadToMV shads
|
||||
slist'' <- pokeLayVerxs shadV m
|
||||
bindShaderLay shads slist''
|
||||
counts <- UMV.replicate (6*6) 0
|
||||
slist'' <- pokeLayVerxs shadV counts m
|
||||
bindShaderLayers shadV counts
|
||||
return slist''
|
||||
|
||||
renderFoldable
|
||||
|
||||
+20
-4
@@ -1,5 +1,5 @@
|
||||
module Shader
|
||||
( bindShaderLay
|
||||
( bindShaderLayers
|
||||
, bindShaderBuffers
|
||||
, bindShader
|
||||
, drawShader
|
||||
@@ -53,10 +53,26 @@ bindArrayBuffersLayer lay numVs theVBO = do
|
||||
where
|
||||
stride = sum $ _vboAttribSizes theVBO
|
||||
|
||||
bindShaderLay :: PicShads VShader -> IM.IntMap (PicShads Int) -> IO ()
|
||||
bindShaderLay shads = mapM_ (uncurry f) . IM.toList
|
||||
bindShaderLayers :: MV.MVector (PrimState IO) VShader -> UMV.MVector (PrimState IO) Int -> IO ()
|
||||
bindShaderLayers shads counts = MV.imapM_ f shads
|
||||
where
|
||||
f lay counts = sequence_ $ bindArrayBuffersLayer lay <$> counts <*> (_vaoVBO . _vshaderVAO <$> shads)
|
||||
f i shad = do
|
||||
let theVBO = _vaoVBO $ _vshaderVAO shad
|
||||
stride = sum $ _vboAttribSizes theVBO
|
||||
bindBuffer ArrayBuffer $= (Just . _vbo $ theVBO)
|
||||
mapM_ (g stride theVBO) [0..5]
|
||||
where
|
||||
g stride theVBO lay = do
|
||||
numVs <- UMV.unsafeRead counts $ lay * 6 + i
|
||||
bufferSubData
|
||||
ArrayBuffer
|
||||
WriteToBuffer
|
||||
(fromIntegral $ floatSize * stride * numSubElements * lay)
|
||||
(fromIntegral $ floatSize * numVs * stride)
|
||||
(_vboPtr theVBO `plusPtr` (floatSize * stride * numSubElements * lay))
|
||||
|
||||
|
||||
--lay counts = sequence_ $ bindArrayBuffersLayer lay <$> counts <*> (_vaoVBO . _vshaderVAO <$> shads)
|
||||
|
||||
bindShader :: MV.MVector (PrimState IO) VShader -> UMV.MVector (PrimState IO) Int -> IO ()
|
||||
bindShader shads counts = MV.imapM_ f shads
|
||||
|
||||
+4
-3
@@ -137,9 +137,10 @@ vboFromType ps sn = case sn of
|
||||
_ -> undefined
|
||||
|
||||
|
||||
pokeLayVerxs :: MV.MVector (PrimState IO) VShader -> [Verx] -> IO (IM.IntMap (PicShads Int))
|
||||
pokeLayVerxs vbos vxs = do
|
||||
counts <- UMV.replicate (6*6) 0
|
||||
pokeLayVerxs :: MV.MVector (PrimState IO) VShader
|
||||
-> UMV.MVector (PrimState IO) Int
|
||||
-> [Verx] -> IO (IM.IntMap (PicShads Int))
|
||||
pokeLayVerxs vbos counts vxs = do
|
||||
VS.mapM_ (pokeLayVerx vbos counts) $ VS.fromList vxs
|
||||
vToLayPicShad counts
|
||||
|
||||
|
||||
Reference in New Issue
Block a user