Attempt to stream SPics, not sure if this improves speed

This commit is contained in:
2022-07-04 20:34:47 +01:00
parent 1e32b05406
commit 6972256751
5 changed files with 64 additions and 22 deletions
+20 -1
View File
@@ -1,5 +1,6 @@
module Shader.Poke
( pokeVerxs
, pokeSPics
, pokeLayVerxs
, pokeArrayOff
-- , pokePoint33s
@@ -11,6 +12,7 @@ import Shader.Parameters
import Picture.Data
import Shape.Data
import Geometry.Data
import ShapePicture
import Graphics.Rendering.OpenGL hiding (color,scale,translate,rotate)
import Foreign
@@ -27,7 +29,7 @@ import Streaming
pokeVerxs
:: MV.MVector (PrimState IO) FullShader
-> UMV.MVector (PrimState IO) Int
-> Picture
-> Picture
-> IO ()
pokeVerxs vbos count = S.mapM_ (pokeVerx vbos count)
@@ -80,11 +82,28 @@ pokeW ptr i' ((V2 a b,V2 c d),V4 e f g h) = do
pokeElemOff ptr (i + 7) h
return $ i' + 1
pokeSPics
:: MV.MVector (PrimState IO) FullShader
-> UMV.MVector (PrimState IO) Int
-> Ptr Float -> Ptr GLushort -> Ptr GLushort
-> Stream (Of SPic) IO ()
-> IO (Int,Int,Int)
pokeSPics vbos counts ptr iptr ieptr =
S.foldM_ (\is (sh,pic) -> pokeLayVerxs vbos counts pic >> pokeShape' ptr iptr ieptr is sh)
(return (0,0,0)) return
pokeShape :: Ptr Float -> Ptr GLushort -> Ptr GLushort
-> Stream (Of ShapeObj) IO ()
-> IO (Int,Int,Int)
pokeShape ptr iptr ieptr = S.foldM_ (pokeShapeObj ptr iptr ieptr) (return (0,0,0)) return
pokeShape' :: Ptr Float -> Ptr GLushort -> Ptr GLushort
-> (Int,Int,Int)
-> Stream (Of ShapeObj) IO ()
-> IO (Int,Int,Int)
pokeShape' ptr iptr ieptr is = S.foldM_ (pokeShapeObj ptr iptr ieptr) (return is) return
pokeShapeObj
:: Ptr Float
-> Ptr GLushort