Copyright | (c) 2023 IC Rainbow (c) 2014-2019 Edward Kmett |
---|---|
License | BSD-2-Clause OR Apache-2.0 |
Maintainer | IC Rainbow <[email protected]> |
Stability | experimental |
Portability | non-portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Graphics.Gl.Block
Description
OpenGL std140 and std430 support
Synopsis
- class Block b where
- type PackedSize b :: Nat
- alignment140 :: proxy b -> Int
- sizeOf140 :: proxy b -> Int
- isStruct :: proxy b -> Bool
- read140 :: MonadIO m => Ptr a -> Diff a b -> m b
- write140 :: MonadIO m => Ptr a -> Diff a b -> b -> m ()
- alignment430 :: proxy b -> Int
- sizeOf430 :: proxy b -> Int
- read430 :: MonadIO m => Ptr a -> Diff a b -> m b
- write430 :: MonadIO m => Ptr a -> Diff a b -> b -> m ()
- sizeOfPacked :: proxy b -> Int
- readPacked :: MonadIO m => Ptr a -> Diff a b -> m b
- writePacked :: MonadIO m => Ptr a -> Diff a b -> b -> m ()
- class GBlock f where
- type GPackedSize f :: Nat
- galignment140 :: p f -> Int
- galignment430 :: p f -> Int
- gsizeOf140 :: p f -> Int
- gsizeOf430 :: p f -> Int
- gsizeOfPacked :: p f -> Int
- gread140 :: Ptr a -> Int -> IO (f b)
- gread430 :: Ptr a -> Int -> IO (f b)
- greadPacked :: Ptr a -> Int -> IO (f b)
- gwrite140 :: Ptr a -> Int -> f b -> IO ()
- gwrite430 :: Ptr a -> Int -> f b -> IO ()
- gwritePacked :: Ptr a -> Int -> f b -> IO ()
- newtype Packed a = Packed {
- getPacked :: a
- newtype Std140 a = Std140 {
- getStd140 :: a
- newtype Std430 a = Std430 {
- getStd430 :: a
- roundUp :: Int -> Int -> Int
Documentation
This describes how to load and store primitives through a uniform/shader storage blocks according to OpenGL Std140 and Std430.
There are lots of fiddly little constants around, beware.
Minimal complete definition
Nothing
Methods
alignment140 :: proxy b -> Int Source #
sizeOf140 :: proxy b -> Int Source #
isStruct :: proxy b -> Bool Source #
Structures get smashed up to a minimum of a vec4 alignment in 140 mode
read140 :: MonadIO m => Ptr a -> Diff a b -> m b Source #
write140 :: MonadIO m => Ptr a -> Diff a b -> b -> m () Source #
default write140 :: (MonadIO m, Generic b, GBlock (Rep b)) => Ptr a -> Diff a b -> b -> m () Source #
alignment430 :: proxy b -> Int Source #
sizeOf430 :: proxy b -> Int Source #
read430 :: MonadIO m => Ptr a -> Diff a b -> m b Source #
write430 :: MonadIO m => Ptr a -> Diff a b -> b -> m () Source #
default write430 :: (MonadIO m, Generic b, GBlock (Rep b)) => Ptr a -> Diff a b -> b -> m () Source #
sizeOfPacked :: proxy b -> Int Source #
default sizeOfPacked :: KnownNat (PackedSize b) => proxy b -> Int Source #
readPacked :: MonadIO m => Ptr a -> Diff a b -> m b Source #
writePacked :: MonadIO m => Ptr a -> Diff a b -> b -> m () Source #
Instances
Automatically derive Std140 and Std430 alignment using GHC Generics
Associated Types
type GPackedSize f :: Nat Source #
Methods
galignment140 :: p f -> Int Source #
galignment430 :: p f -> Int Source #
gsizeOf140 :: p f -> Int Source #
gsizeOf430 :: p f -> Int Source #
gsizeOfPacked :: p f -> Int Source #
gread140 :: Ptr a -> Int -> IO (f b) Source #
gread430 :: Ptr a -> Int -> IO (f b) Source #
greadPacked :: Ptr a -> Int -> IO (f b) Source #
gwrite140 :: Ptr a -> Int -> f b -> IO () Source #
Instances
GBlock (U1 :: k -> Type) Source # | |
Defined in Graphics.Gl.Block Associated Types type GPackedSize U1 :: Nat Source # Methods galignment140 :: p U1 -> Int Source # galignment430 :: p U1 -> Int Source # gsizeOf140 :: p U1 -> Int Source # gsizeOf430 :: p U1 -> Int Source # gsizeOfPacked :: p U1 -> Int Source # gread140 :: forall a (b :: k0). Ptr a -> Int -> IO (U1 b) Source # gread430 :: forall a (b :: k0). Ptr a -> Int -> IO (U1 b) Source # greadPacked :: forall a (b :: k0). Ptr a -> Int -> IO (U1 b) Source # gwrite140 :: forall a (b :: k0). Ptr a -> Int -> U1 b -> IO () Source # gwrite430 :: forall a (b :: k0). Ptr a -> Int -> U1 b -> IO () Source # gwritePacked :: forall a (b :: k0). Ptr a -> Int -> U1 b -> IO () Source # | |
(GBlock f, GBlock g) => GBlock (f :*: g :: k -> Type) Source # | |
Defined in Graphics.Gl.Block Associated Types type GPackedSize (f :*: g) :: Nat Source # Methods galignment140 :: p (f :*: g) -> Int Source # galignment430 :: p (f :*: g) -> Int Source # gsizeOf140 :: p (f :*: g) -> Int Source # gsizeOf430 :: p (f :*: g) -> Int Source # gsizeOfPacked :: p (f :*: g) -> Int Source # gread140 :: forall a (b :: k0). Ptr a -> Int -> IO ((f :*: g) b) Source # gread430 :: forall a (b :: k0). Ptr a -> Int -> IO ((f :*: g) b) Source # greadPacked :: forall a (b :: k0). Ptr a -> Int -> IO ((f :*: g) b) Source # gwrite140 :: forall a (b :: k0). Ptr a -> Int -> (f :*: g) b -> IO () Source # gwrite430 :: forall a (b :: k0). Ptr a -> Int -> (f :*: g) b -> IO () Source # gwritePacked :: forall a (b :: k0). Ptr a -> Int -> (f :*: g) b -> IO () Source # | |
Block c => GBlock (K1 i c :: k -> Type) Source # | |
Defined in Graphics.Gl.Block Associated Types type GPackedSize (K1 i c) :: Nat Source # Methods galignment140 :: p (K1 i c) -> Int Source # galignment430 :: p (K1 i c) -> Int Source # gsizeOf140 :: p (K1 i c) -> Int Source # gsizeOf430 :: p (K1 i c) -> Int Source # gsizeOfPacked :: p (K1 i c) -> Int Source # gread140 :: forall a (b :: k0). Ptr a -> Int -> IO (K1 i c b) Source # gread430 :: forall a (b :: k0). Ptr a -> Int -> IO (K1 i c b) Source # greadPacked :: forall a (b :: k0). Ptr a -> Int -> IO (K1 i c b) Source # gwrite140 :: forall a (b :: k0). Ptr a -> Int -> K1 i c b -> IO () Source # gwrite430 :: forall a (b :: k0). Ptr a -> Int -> K1 i c b -> IO () Source # gwritePacked :: forall a (b :: k0). Ptr a -> Int -> K1 i c b -> IO () Source # | |
GBlock f => GBlock (M1 C c f :: k -> Type) Source # | |
Defined in Graphics.Gl.Block Methods galignment140 :: p (M1 C c f) -> Int Source # galignment430 :: p (M1 C c f) -> Int Source # gsizeOf140 :: p (M1 C c f) -> Int Source # gsizeOf430 :: p (M1 C c f) -> Int Source # gsizeOfPacked :: p (M1 C c f) -> Int Source # gread140 :: forall a (b :: k0). Ptr a -> Int -> IO (M1 C c f b) Source # gread430 :: forall a (b :: k0). Ptr a -> Int -> IO (M1 C c f b) Source # greadPacked :: forall a (b :: k0). Ptr a -> Int -> IO (M1 C c f b) Source # gwrite140 :: forall a (b :: k0). Ptr a -> Int -> M1 C c f b -> IO () Source # gwrite430 :: forall a (b :: k0). Ptr a -> Int -> M1 C c f b -> IO () Source # gwritePacked :: forall a (b :: k0). Ptr a -> Int -> M1 C c f b -> IO () Source # | |
GBlock f => GBlock (M1 D c f :: k -> Type) Source # | |
Defined in Graphics.Gl.Block Methods galignment140 :: p (M1 D c f) -> Int Source # galignment430 :: p (M1 D c f) -> Int Source # gsizeOf140 :: p (M1 D c f) -> Int Source # gsizeOf430 :: p (M1 D c f) -> Int Source # gsizeOfPacked :: p (M1 D c f) -> Int Source # gread140 :: forall a (b :: k0). Ptr a -> Int -> IO (M1 D c f b) Source # gread430 :: forall a (b :: k0). Ptr a -> Int -> IO (M1 D c f b) Source # greadPacked :: forall a (b :: k0). Ptr a -> Int -> IO (M1 D c f b) Source # gwrite140 :: forall a (b :: k0). Ptr a -> Int -> M1 D c f b -> IO () Source # gwrite430 :: forall a (b :: k0). Ptr a -> Int -> M1 D c f b -> IO () Source # gwritePacked :: forall a (b :: k0). Ptr a -> Int -> M1 D c f b -> IO () Source # | |
GBlock f => GBlock (M1 S c f :: k -> Type) Source # | |
Defined in Graphics.Gl.Block Methods galignment140 :: p (M1 S c f) -> Int Source # galignment430 :: p (M1 S c f) -> Int Source # gsizeOf140 :: p (M1 S c f) -> Int Source # gsizeOf430 :: p (M1 S c f) -> Int Source # gsizeOfPacked :: p (M1 S c f) -> Int Source # gread140 :: forall a (b :: k0). Ptr a -> Int -> IO (M1 S c f b) Source # gread430 :: forall a (b :: k0). Ptr a -> Int -> IO (M1 S c f b) Source # greadPacked :: forall a (b :: k0). Ptr a -> Int -> IO (M1 S c f b) Source # gwrite140 :: forall a (b :: k0). Ptr a -> Int -> M1 S c f b -> IO () Source # gwrite430 :: forall a (b :: k0). Ptr a -> Int -> M1 S c f b -> IO () Source # gwritePacked :: forall a (b :: k0). Ptr a -> Int -> M1 S c f b -> IO () Source # |
Instances
Foldable Packed Source # | |
Defined in Graphics.Gl.Block Methods fold :: Monoid m => Packed m -> m # foldMap :: Monoid m => (a -> m) -> Packed a -> m # foldMap' :: Monoid m => (a -> m) -> Packed a -> m # foldr :: (a -> b -> b) -> b -> Packed a -> b # foldr' :: (a -> b -> b) -> b -> Packed a -> b # foldl :: (b -> a -> b) -> b -> Packed a -> b # foldl' :: (b -> a -> b) -> b -> Packed a -> b # foldr1 :: (a -> a -> a) -> Packed a -> a # foldl1 :: (a -> a -> a) -> Packed a -> a # elem :: Eq a => a -> Packed a -> Bool # maximum :: Ord a => Packed a -> a # minimum :: Ord a => Packed a -> a # | |
Traversable Packed Source # | |
Functor Packed Source # | |
Data a => Data (Packed a) Source # | |
Defined in Graphics.Gl.Block Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Packed a -> c (Packed a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Packed a) # toConstr :: Packed a -> Constr # dataTypeOf :: Packed a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Packed a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Packed a)) # gmapT :: (forall b. Data b => b -> b) -> Packed a -> Packed a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Packed a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Packed a -> r # gmapQ :: (forall d. Data d => d -> u) -> Packed a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Packed a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Packed a -> m (Packed a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Packed a -> m (Packed a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Packed a -> m (Packed a) # | |
Block a => Storable (Packed a) Source # | |
Defined in Graphics.Gl.Block | |
Generic (Packed a) Source # | |
Read a => Read (Packed a) Source # | |
Show a => Show (Packed a) Source # | |
Eq a => Eq (Packed a) Source # | |
Ord a => Ord (Packed a) Source # | |
Defined in Graphics.Gl.Block | |
type Rep (Packed a) Source # | |
Defined in Graphics.Gl.Block |
Instances
Foldable Std140 Source # | |
Defined in Graphics.Gl.Block Methods fold :: Monoid m => Std140 m -> m # foldMap :: Monoid m => (a -> m) -> Std140 a -> m # foldMap' :: Monoid m => (a -> m) -> Std140 a -> m # foldr :: (a -> b -> b) -> b -> Std140 a -> b # foldr' :: (a -> b -> b) -> b -> Std140 a -> b # foldl :: (b -> a -> b) -> b -> Std140 a -> b # foldl' :: (b -> a -> b) -> b -> Std140 a -> b # foldr1 :: (a -> a -> a) -> Std140 a -> a # foldl1 :: (a -> a -> a) -> Std140 a -> a # elem :: Eq a => a -> Std140 a -> Bool # maximum :: Ord a => Std140 a -> a # minimum :: Ord a => Std140 a -> a # | |
Traversable Std140 Source # | |
Functor Std140 Source # | |
Data a => Data (Std140 a) Source # | |
Defined in Graphics.Gl.Block Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Std140 a -> c (Std140 a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Std140 a) # toConstr :: Std140 a -> Constr # dataTypeOf :: Std140 a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Std140 a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Std140 a)) # gmapT :: (forall b. Data b => b -> b) -> Std140 a -> Std140 a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Std140 a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Std140 a -> r # gmapQ :: (forall d. Data d => d -> u) -> Std140 a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Std140 a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Std140 a -> m (Std140 a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Std140 a -> m (Std140 a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Std140 a -> m (Std140 a) # | |
Block a => Storable (Std140 a) Source # | |
Defined in Graphics.Gl.Block | |
Generic (Std140 a) Source # | |
Read a => Read (Std140 a) Source # | |
Show a => Show (Std140 a) Source # | |
Eq a => Eq (Std140 a) Source # | |
Ord a => Ord (Std140 a) Source # | |
Defined in Graphics.Gl.Block | |
type Rep (Std140 a) Source # | |
Defined in Graphics.Gl.Block |
Instances
Foldable Std430 Source # | |
Defined in Graphics.Gl.Block Methods fold :: Monoid m => Std430 m -> m # foldMap :: Monoid m => (a -> m) -> Std430 a -> m # foldMap' :: Monoid m => (a -> m) -> Std430 a -> m # foldr :: (a -> b -> b) -> b -> Std430 a -> b # foldr' :: (a -> b -> b) -> b -> Std430 a -> b # foldl :: (b -> a -> b) -> b -> Std430 a -> b # foldl' :: (b -> a -> b) -> b -> Std430 a -> b # foldr1 :: (a -> a -> a) -> Std430 a -> a # foldl1 :: (a -> a -> a) -> Std430 a -> a # elem :: Eq a => a -> Std430 a -> Bool # maximum :: Ord a => Std430 a -> a # minimum :: Ord a => Std430 a -> a # | |
Traversable Std430 Source # | |
Functor Std430 Source # | |
Data a => Data (Std430 a) Source # | |
Defined in Graphics.Gl.Block Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Std430 a -> c (Std430 a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Std430 a) # toConstr :: Std430 a -> Constr # dataTypeOf :: Std430 a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Std430 a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Std430 a)) # gmapT :: (forall b. Data b => b -> b) -> Std430 a -> Std430 a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Std430 a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Std430 a -> r # gmapQ :: (forall d. Data d => d -> u) -> Std430 a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Std430 a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Std430 a -> m (Std430 a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Std430 a -> m (Std430 a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Std430 a -> m (Std430 a) # | |
Block a => Storable (Std430 a) Source # | |
Defined in Graphics.Gl.Block | |
Generic (Std430 a) Source # | |
Read a => Read (Std430 a) Source # | |
Show a => Show (Std430 a) Source # | |
Eq a => Eq (Std430 a) Source # | |
Ord a => Ord (Std430 a) Source # | |
Defined in Graphics.Gl.Block | |
type Rep (Std430 a) Source # | |
Defined in Graphics.Gl.Block |