Some linting
This commit is contained in:
+14
-44
@@ -1,6 +1,5 @@
|
||||
{-# LANGUAGE TupleSections
|
||||
, BangPatterns
|
||||
#-}
|
||||
--{-# LANGUAGE TupleSections #-}
|
||||
{-# LANGUAGE BangPatterns #-}
|
||||
module Shader.Poke
|
||||
( pokeArrayOff
|
||||
, pokePoint3s
|
||||
@@ -30,7 +29,7 @@ import Control.Monad.Primitive
|
||||
pokeVerxs :: PicShads VBO -> [Verx] -> IO (PicShads Int)
|
||||
pokeVerxs vbos vxs = do
|
||||
count <- MV.replicate 6 0
|
||||
SP.mapM_ (\vx -> pokeVerx vbos count vx >> addCountVerx count vx) $ SP.each vxs
|
||||
SP.mapM_ (pokeVerx vbos count) $ SP.each vxs
|
||||
vToPicShad count
|
||||
-- F.foldM (F.FoldM
|
||||
-- (\_ vx -> pokeVerx vbos count vx >> addCountVerx count vx)
|
||||
@@ -40,6 +39,7 @@ pokeVerxs vbos vxs = do
|
||||
-- vxs
|
||||
|
||||
vToPicShad :: MV.MVector (PrimState IO) Int -> IO (PicShads Int)
|
||||
{-# INLINE vToPicShad #-}
|
||||
vToPicShad mv = mapM (MV.unsafeRead mv) $ PicShads 0 1 2 3 4 5
|
||||
|
||||
pokeVerx :: PicShads VBO -> MV.MVector (PrimState IO) Int -> Verx -> IO ()
|
||||
@@ -49,35 +49,9 @@ pokeVerx vbos offsets Verx{_vxPos=thePos,_vxCol=theCol,_vxExt=ext,_vxShadNum=the
|
||||
let thePtr = plusPtr (_vboPtr $ vboFromType vbos sn) (typeOff * pokeStride sn * floatSize)
|
||||
poke34 thePtr thePos theCol
|
||||
pokeArrayOff thePtr 7 ext
|
||||
MV.unsafeModify offsets (+1) sn
|
||||
where
|
||||
sn = _unShadNum theShadNum
|
||||
-- case _unShadNum theShadNum of
|
||||
-- 0 -> do
|
||||
-- typeOff <- MV.unsafeRead offsets 0
|
||||
-- poke34 (plusPtr (_vboPtr $ vboFromType vbos 0) (typeOff * 7 * floatSize)) thePos theCol
|
||||
-- 1 -> do
|
||||
-- typeOff <- MV.unsafeRead offsets 1
|
||||
-- let thePtr = plusPtr (_vboPtr $ _psPolyz vbos) (typeOff * 8 * floatSize)
|
||||
-- poke34 thePtr thePos theCol
|
||||
-- pokeArrayOff thePtr 7 ext
|
||||
-- 2 -> do
|
||||
-- typeOff <- MV.unsafeRead offsets 2
|
||||
-- let thePtr = plusPtr (_vboPtr $ _psBez vbos) (typeOff * 11 * floatSize)
|
||||
-- poke34 thePtr thePos theCol
|
||||
-- pokeArrayOff thePtr 7 ext
|
||||
-- 3 -> do
|
||||
-- typeOff <- MV.unsafeRead offsets 3
|
||||
-- let thePtr = plusPtr (_vboPtr $ _psText vbos) (typeOff * 9 * floatSize)
|
||||
-- poke34 thePtr thePos theCol
|
||||
-- pokeArrayOff thePtr 7 ext
|
||||
-- 4 -> do
|
||||
-- typeOff <- MV.unsafeRead offsets 4
|
||||
-- let thePtr = plusPtr (_vboPtr $ _psArc vbos) (typeOff * 10 * floatSize)
|
||||
-- poke34 thePtr thePos theCol
|
||||
-- pokeArrayOff thePtr 7 ext
|
||||
-- 5 -> do
|
||||
-- typeOff <- MV.unsafeRead offsets 5
|
||||
-- poke34 (plusPtr (_vboPtr $ _psEll vbos) (typeOff * 7 * floatSize)) thePos theCol
|
||||
|
||||
poke34 :: Ptr Float -> Point3 -> Point4 -> IO ()
|
||||
{-# INLINE poke34 #-}
|
||||
@@ -90,19 +64,15 @@ poke34 ptr (V3 a b c) (V4 d e f g) = do
|
||||
pokeElemOff ptr 5 f
|
||||
pokeElemOff ptr 6 g
|
||||
|
||||
addCountVerx :: MV.MVector (PrimState IO) Int -> Verx -> IO ()
|
||||
{-# INLINE addCountVerx #-}
|
||||
addCountVerx vec vx = MV.unsafeModify vec (+1) (_unShadNum $ _vxShadNum vx)
|
||||
|
||||
pokeArrayOff :: Ptr Float -> Int -> [Float] -> IO ()
|
||||
--{-# INLINE pokeArrayOff #-}
|
||||
{-# INLINE pokeArrayOff #-}
|
||||
pokeArrayOff ptr i = pokeArray (plusPtr ptr (floatSize * i))
|
||||
|
||||
pokePoint33s :: Ptr Float -> [(Point3,Point3)] -> IO Int
|
||||
pokePoint33s ptr vals0 = go vals0 0
|
||||
where
|
||||
go [] n = return n
|
||||
go ( !(!(V3 a b c),!(V3 d e f)):vals) !n = do
|
||||
go ( !(V3 a b c,V3 d e f):vals) !n = do
|
||||
pokeElemOff ptr (off 0) a
|
||||
pokeElemOff ptr (off 1) b
|
||||
pokeElemOff ptr (off 2) c
|
||||
@@ -117,7 +87,7 @@ pokePoint3s :: Ptr Float -> [Point3] -> IO Int
|
||||
pokePoint3s ptr vals0 = go vals0 0
|
||||
where
|
||||
go [] n = return n
|
||||
go ( !(V3 a b c):vals) !n = do
|
||||
go ( V3 a b c:vals) !n = do
|
||||
pokeElemOff ptr (off 0) a
|
||||
pokeElemOff ptr (off 1) b
|
||||
pokeElemOff ptr (off 2) c
|
||||
@@ -125,10 +95,9 @@ pokePoint3s ptr vals0 = go vals0 0
|
||||
where
|
||||
off i = n*3 + i
|
||||
|
||||
--comLayVerx :: PicShads VBO -> MV.MVector (PrimState IO) Int -> () -> Verx -> IO (MV.MVector (PrimState IO) Int)
|
||||
comLayVerx :: PicShads VBO -> MV.MVector (PrimState IO) Int -> Verx -> IO ()
|
||||
--{-# INLINE comLayVerx #-}
|
||||
comLayVerx vbos counts vx = do
|
||||
pokeLayVerx :: PicShads VBO -> MV.MVector (PrimState IO) Int -> Verx -> IO ()
|
||||
--{-# INLINE pokeLayVerx #-}
|
||||
pokeLayVerx vbos counts vx = do
|
||||
theOff <- MV.unsafeRead counts vecPos
|
||||
let thePtr = plusPtr basePtr ((theOff + layOff) * theStride * floatSize)
|
||||
poke34 thePtr thePos theCol
|
||||
@@ -159,10 +128,11 @@ vboFromType ps sn = case sn of
|
||||
pokeLayVerxs :: PicShads VBO -> [Verx] -> IO (IM.IntMap (PicShads Int))
|
||||
pokeLayVerxs vbos vxs = do
|
||||
counts <- MV.replicate (6*6) 0
|
||||
SP.mapM_ (comLayVerx vbos counts) $ SP.each vxs
|
||||
SP.mapM_ (pokeLayVerx vbos counts) $ SP.each vxs
|
||||
vToLayPicShad counts
|
||||
|
||||
vToLayPicShad :: MV.MVector RealWorld Int -> IO (IM.IntMap (PicShads Int))
|
||||
{-# INLINE vToLayPicShad #-}
|
||||
vToLayPicShad mv = foldM f IM.empty [0..5]
|
||||
where
|
||||
f m i = fmap (\ps -> IM.insert i ps m) (vToPicShad $ MV.unsafeSlice (i * 6) 6 mv)
|
||||
@@ -181,7 +151,7 @@ poke224s :: Ptr Float -> [((Point2,Point2),Point4)] -> IO Int
|
||||
poke224s ptr vals0 = go vals0 0
|
||||
where
|
||||
go [] n = return n
|
||||
go ((((V2 a b),(V2 c d)),(V4 e f g h)):vals) !n = do
|
||||
go (((V2 a b,V2 c d),V4 e f g h):vals) !n = do
|
||||
pokeElemOff ptr (off 0) a
|
||||
pokeElemOff ptr (off 1) b
|
||||
pokeElemOff ptr (off 2) c
|
||||
|
||||
Reference in New Issue
Block a user