Safe Haskell | None |
---|---|
Language | Haskell98 |
Graphics.GPipe.Expr
Contents
Description
This module provides the DSL for shader operations in GPipe. The type
is an opaque type that represents a value of type S
x aa
in a shader stage x
, eg S F Float
means a
floating point value in a fragment stream.
- data S x a
- data V
- data F
- type VFloat = S V Float
- type VInt = S V Int
- type VWord = S V Word
- type VBool = S V Bool
- type FFloat = S F Float
- type FInt = S F Int
- type FWord = S F Word
- type FBool = S F Bool
- class Convert a where
- type ConvertFloat a
- type ConvertInt a
- type ConvertWord a
- class Integral' a where
- class Floating a => Real' a where
- class (IfB a, OrdB a, Floating a) => FloatingOrd a where
- dFdx :: FFloat -> FFloat
- dFdy :: FFloat -> FFloat
- fwidth :: FFloat -> FFloat
- while :: forall a x. ShaderType a x => (a -> S x Bool) -> (a -> a) -> a -> a
- ifThen :: forall a x. ShaderType a x => S x Bool -> (a -> a) -> a -> a
- ifThenElse :: forall a b x. (ShaderType a x, ShaderType b x) => S x Bool -> (a -> b) -> (a -> b) -> a -> b
- ifThenElse' :: forall a x. ShaderType a x => S x Bool -> a -> a -> a
- data ShaderBase a x
- class ShaderType a x where
- type ShaderBaseType a
Atomic shader type
Instances
Instances
FragmentInput VBool # | |
FragmentInput VWord # | |
FragmentInput VInt # | |
FragmentInput VFloat # | |
type FragmentFormat VBool # | |
type FragmentFormat VWord # | |
type FragmentFormat VInt # | |
type FragmentFormat VFloat # | |
Type classes where the Prelude ones are lacking
Provides a common way to convert numeric types to integer and floating point representations.
Methods
toFloat :: a -> ConvertFloat a #
Convert to a floating point number.
toInt :: a -> ConvertInt a #
Convert to an integral number, using truncation if necessary.
toWord :: a -> ConvertWord a #
Convert to an unsigned integral number, using truncation if necessary.
Instances
Integral' Int # | |
Integral' Int8 # | |
Integral' Int16 # | |
Integral' Int32 # | |
Integral' Word # | |
Integral' Word8 # | |
Integral' Word16 # | |
Integral' Word32 # | |
Integral' a => Integral' (V0 a) # | |
Integral' a => Integral' (V4 a) # | |
Integral' a => Integral' (V3 a) # | |
Integral' a => Integral' (V2 a) # | |
Integral' a => Integral' (V1 a) # | |
Integral' (S a Word) # | |
Integral' (S a Int) # | |
class Floating a => Real' a where #
This class provides the GPU functions either not found in Prelude's numerical classes, or that has wrong types.
Instances are also provided for normal Float
s and Double
s.
Methods
class (IfB a, OrdB a, Floating a) => FloatingOrd a where #
This class provides various order comparing functions
Methods
smoothstep :: a -> a -> a -> a #
Instances
Additional functions
The sum of the absolute derivative in x and y using local differencing of the rasterized value.
Shader control structures
while :: forall a x. ShaderType a x => (a -> S x Bool) -> (a -> a) -> a -> a #
while f g x
will iteratively transform x
with g
as long as f
generates true
.
ifThen :: forall a x. ShaderType a x => S x Bool -> (a -> a) -> a -> a #
ifThen c f x
will return f x
if c
evaluates to true
or x
otherwise.
In most cases functionally equivalent to ifThenElse'
but
usually generate smaller shader code since the last argument is not inlined into the two branches, which also would affect implicit derivates (e.g. dFdx
, dFdy
or sampling using SampleAuto
)
ifThenElse :: forall a b x. (ShaderType a x, ShaderType b x) => S x Bool -> (a -> b) -> (a -> b) -> a -> b #
ifThenElse c f g x
will return f x
if c
evaluates to true
or g x
otherwise.
In most cases functionally equivalent to ifThenElse'
but
usually generate smaller shader code since the last argument is not inlined into the two branches, which also would affect implicit derivates (e.g. dFdx
, dFdy
or sampling using SampleAuto
)
ifThenElse' :: forall a x. ShaderType a x => S x Bool -> a -> a -> a #
data ShaderBase a x #
An opaque type
class ShaderType a x where #
Constraint for types that may pass in and out of shader control structures. Define your own instances in terms of others and make sure to make toBase as lazy as possible.
Associated Types
type ShaderBaseType a #
A base type that this type can convert into. Use the ShaderBaseType
function on an existing instance of ShaderType
to define this in your instance.
Methods
toBase :: x -> a -> ShaderBase (ShaderBaseType a) x #
Convert this type to the shader base type. Make sure this is as lazy as possible (e.g. use tilde (~
) on each pattern match).
fromBase :: x -> ShaderBase (ShaderBaseType a) x -> a #
Convert back from the shader base type to this type.
Instances
ShaderType () x # | |
ShaderType a x => ShaderType (V0 a) x # | |
ShaderType a x => ShaderType (V4 a) x # | |
ShaderType a x => ShaderType (V3 a) x # | |
ShaderType a x => ShaderType (V2 a) x # | |
ShaderType a x => ShaderType (V1 a) x # | |
(ShaderType a x, ShaderType b x) => ShaderType (a, b) x # | |
ShaderType (S x Bool) x # | |
ShaderType (S x Word) x # | |
ShaderType (S x Int) x # | |
ShaderType (S x Float) x # | |
(ShaderType a x, ShaderType b x, ShaderType c x) => ShaderType (a, b, c) x # | |
(ShaderType a x, ShaderType b x, ShaderType c x, ShaderType d x) => ShaderType (a, b, c, d) x # | |
(ShaderType a x, ShaderType b x, ShaderType c x, ShaderType d x, ShaderType e x) => ShaderType (a, b, c, d, e) x # | |
(ShaderType a x, ShaderType b x, ShaderType c x, ShaderType d x, ShaderType e x, ShaderType f x) => ShaderType (a, b, c, d, e, f) x # | |
(ShaderType a x, ShaderType b x, ShaderType c x, ShaderType d x, ShaderType e x, ShaderType f x, ShaderType g x) => ShaderType (a, b, c, d, e, f, g) x # | |