Parasol
The Parasol language is an aggressively
minimalist pure-functional shading language. The intention is to provide
a language with simple and predictable semantics that can then be
compiled to all possible versions of GLSL, eliminating all of the versioning
concerns previously expressed. On versions of GLSL that do not provide certain
functions, the compiler silently provides emulations
. Essentially, the programmer provides a
Parasol program and a range of GLSL versions
upon which the program is expected to run. The compiler produces GLSL for
all of the possible versions and will raise errors if a valid program really cannot
be produced for a particular GLSL version
.
The Parasol language is
both pure-functional and total. That
is, programs do not have side effects and are guaranteed to
terminate. The language statically rejects recursive and mutually
recursive terms, and does not provide looping constructs or
arrays.
The Parasol language categorically
rejects operator and function overloading
; the programmer always knows exactly which function
is being applied on sight. This eliminates the correctness issues
caused by pervasive overloading.
The language provides a simple non-hierarchical module and package
system for controlling the namespace. Parasol
programs can be developed as sets of re-usable libraries without
any fear of name collisions. The language works from the assumption
that, although shader programs are likely to be short and linear,
there are also likely to be a large number of them, with significant
amounts of duplicated code. The Parasol
module system allows code to be imported and re-used safely, with full
type checking and without requiring a complicated and error-prone
preprocessor.
The jparasol compiler is a strictly
offline compiler developed in Java. The compiler takes
Parasol
programs as input, and produces GLSL programs (and additional metadata)
as output. The produced GLSL can then be loaded as normal in any OpenGL program
and has no dependencies on Parasol,
the jparasol compiler, or anything else.
The additional metadata produced as output describes various properties
of the program. This means that programmers are not required to
parse Parasol
programs to, for example, determine all of the declared inputs,
parameters, and outputs. The metadata is an optional component;
programmers are not required to use it in order to make use of
compiled GLSL programs.
Limitations
The language considers portability and correctness
to be more important than exposing the latest flashy
features of GLSL. The language therefore exposes
features roughly analogous
to version 1.40 of
GLSL in an attempt to provide the subset of OpenGL and
GLSL that will work on as many implementations as possible.
The language does not support geometry shaders
or tesselation shaders. The language does not support
double-precision floating point. These features will
likely be introduced as time moves on and older versions
of OpenGL disappear into history.
As described, the language is currently total,
meaning that all programs are guaranteed to terminate. This
is both a desirable property (because non-terminating shader
programs are extremely bad news on some OpenGL implementations), and
a severe limitation (because programs that require loops cannot
be expressed in Parasol
at all). In practice, this has not turned out to be much of
a problem
. The shading programs found in most
game engines tend to be linear in nature and do
not require iterating over arrays of values.