Work towards using mutable vectors for storing parameters

This commit is contained in:
jgk
2021-08-11 19:28:50 +02:00
parent 4bbe5d0cf1
commit b77683bafd
4 changed files with 78 additions and 28 deletions
+16 -2
View File
@@ -11,9 +11,13 @@ module Shader
import Shader.Data
import Shader.Parameters
import Shader.ExtraPrimitive
import Shader.Poke
--import Layers
--import MatrixHelper
import qualified Data.Vector.Unboxed.Mutable as UMV
import qualified Data.Vector.Mutable as MV
import Control.Monad.Primitive
import Foreign
import Control.Monad
import Graphics.Rendering.OpenGL hiding (Point,translate,scale,imageHeight)
@@ -53,8 +57,18 @@ bindShaderLay shads = mapM_ (uncurry f) . IM.toList
where
f lay counts = sequence_ $ bindArrayBuffersLayer lay <$> counts <*> (_vaoVBO . _vshaderVAO <$> shads)
bindShader :: PicShads VShader -> PicShads Int -> IO ()
bindShader shads counts = sequence_ $ bindArrayBuffers <$> counts <*> (_vaoVBO . _vshaderVAO <$> shads)
--bindShader :: PicShads VShader -> PicShads Int -> IO ()
----bindShader shads counts = sequence_ $ bindArrayBuffers <$> counts <*> (_vaoVBO . _vshaderVAO <$> shads)
--bindShader shads count = do
-- s <- picShadToMV shads
-- c <- picShadToUMV count
-- bindShader' s c
bindShader :: MV.MVector (PrimState IO) VShader -> UMV.MVector (PrimState IO) Int -> IO ()
bindShader shads counts = MV.imapM_ f shads
where
f i shad = UMV.read counts i >>= flip bindArrayBuffers (_vaoVBO . _vshaderVAO $ shad)
bindShaderBuffers :: [FullShader] -> [Int] -> IO ()
bindShaderBuffers = zipWithM_ f