Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- hlsl :: QuasiQuoter
- comp :: QuasiQuoter
- frag :: QuasiQuoter
- geom :: QuasiQuoter
- tesc :: QuasiQuoter
- tese :: QuasiQuoter
- vert :: QuasiQuoter
- type ShadercError = String
- type ShadercWarning = String
- compileShaderQ :: String -> String -> Q Exp
- compileShader :: MonadIO m => Maybe Loc -> String -> String -> m ([ShadercWarning], Either [ShadercError] ByteString)
- processShadercMessages :: ByteString -> ([ShadercWarning], [ShadercError])
Documentation
hlsl :: QuasiQuoter Source #
hlsl
is a QuasiQuoter which produces HLSL source code with a #line
directive inserted so that error locations point to the correct location in
the Haskell source file. It also permits basic string interpolation.
- Interpolated variables are prefixed with
$
- They can optionally be surrounded with braces like
${foo}
- Interpolated variables are converted to strings with
show
- To escape a
$
use\$
It is intended to be used in concert with compileShaderQ
like so
myConstant = 3.141 -- Note that this will have to be in a different module myFragmentShader = $(compileShaderQ "frag" [hlsl| static const float myConstant = ${myConstant}; float main (){ return myConstant; } |])
An explicit example (interactive
is from doctest):
>>>
let foo = 450 :: Int in [hlsl|const float foo = $foo|]
"#line 31 \"<interactive>\"\nconst float foo = 450"
Note that line number will be thrown off if any of the interpolated variables contain newlines.
comp :: QuasiQuoter Source #
QuasiQuoter for creating a compute shader.
Equivalent to calling $(compileShaderQ "comp" [hlsl|...|])
without
interpolation support.
frag :: QuasiQuoter Source #
QuasiQuoter for creating a fragment shader.
Equivalent to calling $(compileShaderQ "frag" [hlsl|...|])
without
interpolation support.
geom :: QuasiQuoter Source #
QuasiQuoter for creating a geometry shader.
Equivalent to calling $(compileShaderQ "geom" [hlsl|...|])
without
interpolation support.
tesc :: QuasiQuoter Source #
QuasiQuoter for creating a tessellation control shader.
Equivalent to calling $(compileShaderQ "tesc" [hlsl|...|])
without
interpolation support.
tese :: QuasiQuoter Source #
QuasiQuoter for creating a tessellation evaluation shader.
Equivalent to calling $(compileShaderQ "tese" [hlsl|...|])
without
interpolation support.
vert :: QuasiQuoter Source #
QuasiQuoter for creating a vertex shader.
Equivalent to calling $(compileShaderQ "vert" [hlsl|...|])
without
interpolation support.
type ShadercError = String Source #
type ShadercWarning = String Source #
Compile a HLSL shader to SPIR-V using glslc (from the shaderc project)
Messages are converted to GHC warnings or errors depending on compilation success.
:: MonadIO m | |
=> Maybe Loc | Source location |
-> String | stage |
-> String | HLSL code |
-> m ([ShadercWarning], Either [ShadercError] ByteString) | Spir-V bytecode with warnings or errors |
Compile a HLSL shader to spir-v using glslc
processShadercMessages :: ByteString -> ([ShadercWarning], [ShadercError]) Source #