vulkan-utils-0.5.3: Utils for the vulkan package
Safe HaskellNone
LanguageHaskell2010

Vulkan.Utils.ShaderQQ.HLSL.Shaderc

Synopsis

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 Nothing "frag" Nothing [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 57 \"<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 Nothing "comp" Nothing [hlsl|...|]) without interpolation support.

frag :: QuasiQuoter Source #

QuasiQuoter for creating a fragment shader.

Equivalent to calling $(compileShaderQ Nothing "frag" Nothing [hlsl|...|]) without interpolation support.

geom :: QuasiQuoter Source #

QuasiQuoter for creating a geometry shader.

Equivalent to calling $(compileShaderQ Nothing "geom" Nothing [hlsl|...|]) without interpolation support.

tesc :: QuasiQuoter Source #

QuasiQuoter for creating a tessellation control shader.

Equivalent to calling $(compileShaderQ Nothing "tesc" Nothing [hlsl|...|]) without interpolation support.

tese :: QuasiQuoter Source #

QuasiQuoter for creating a tessellation evaluation shader.

Equivalent to calling $(compileShaderQ Nothing "tese" Nothing [hlsl|...|]) without interpolation support.

vert :: QuasiQuoter Source #

QuasiQuoter for creating a vertex shader.

Equivalent to calling $(compileShaderQ Nothing "vert" Nothing [hlsl|...|]) without interpolation support.

rgen :: QuasiQuoter Source #

QuasiQuoter for creating a ray generation shader.

Equivalent to calling $(compileShaderQ (Just "spv1.4") "rgen" Nothing [hlsl|...|]) without interpolation support.

rint :: QuasiQuoter Source #

QuasiQuoter for creating an intersection shader.

Equivalent to calling $(compileShaderQ (Just "spv1.4") "rint" Nothing [hlsl|...|]) without interpolation support.

rahit :: QuasiQuoter Source #

QuasiQuoter for creating an any-hit shader.

Equivalent to calling $(compileShaderQ (Just "spv1.4") "rahit" Nothing [hlsl|...|]) without interpolation support.

rchit :: QuasiQuoter Source #

QuasiQuoter for creating a closest hit shader.

Equivalent to calling $(compileShaderQ (Just "spv1.4") "rchit" Nothing [hlsl|...|]) without interpolation support.

rmiss :: QuasiQuoter Source #

QuasiQuoter for creating a miss shader.

Equivalent to calling $(compileShaderQ (Just "spv1.4") "rmiss" Nothing [hlsl|...|]) without interpolation support.

rcall :: QuasiQuoter Source #

QuasiQuoter for creating a callable shader.

Equivalent to calling $(compileShaderQ (Just "spv1.4") "rcall" Nothing [hlsl|...|]) without interpolation support.

task :: QuasiQuoter Source #

QuasiQuoter for creating a task shader.

Equivalent to calling $(compileShaderQ Nothing "task" Nothing [hlsl|...|]) without interpolation support.

mesh :: QuasiQuoter Source #

QuasiQuoter for creating a mesh shader.

Equivalent to calling $(compileShaderQ Nothing "mesh" Nothing [hlsl|...|]) without interpolation support.

compileShaderQ Source #

Arguments

:: Maybe String

Argument to pass to `--target-env`

-> String

stage

-> Maybe String

Argument to pass to `-fentry-point=` to specify entry-point function name

-> String

hlsl shader code

-> Q Exp

Spir-V bytecode

Compile a HLSL shader to spir-v using glslc.

Messages are converted to GHC warnings or errors depending on compilation success.

compileShader Source #

Arguments

:: MonadIO m 
=> Maybe Loc

Source location

-> Maybe String

Argument to pass to `--target-env`

-> String

stage

-> Maybe String

Argument to pass to `-fentry-point=` to specify entry-point function name

-> String

hlsl shader code

-> m ([ShadercWarning], Either [ShadercError] ByteString)

Spir-V bytecode with warnings or errors

Compile a HLSL shader to spir-v using glslc.