Slang internal include file defining constructors and operators
authorMichal Krol <mjkrol@gmail.org>
Wed, 24 Mar 2004 15:02:37 +0000 (15:02 +0000)
committerMichal Krol <mjkrol@gmail.org>
Wed, 24 Mar 2004 15:02:37 +0000 (15:02 +0000)
for built-in data types.

src/mesa/shader/slang_core.gc [new file with mode: 0755]

diff --git a/src/mesa/shader/slang_core.gc b/src/mesa/shader/slang_core.gc
new file mode 100755 (executable)
index 0000000..d8b795f
--- /dev/null
@@ -0,0 +1,1654 @@
+\r
+// \r
+// This file defines nearly all constructors and operators for built-in data types, using\r
+// extended language syntax. In general, compiler treats constructors and operators as\r
+// ordinary functions with some exceptions. For example, the language does not allow\r
+// functions to be called in constant expressions - here the exception is made to allow it.\r
+// \r
+// Each implementation provides its own version of this file. Each implementation can define\r
+// the required set of operators and constructors in its own fashion.\r
+// \r
+// The extended language syntax is only present when compiling this file. It is implicitly\r
+// included at the very beginning of the compiled shader, so no built-in functions can be\r
+// used.\r
+// \r
+// To communicate with the implementation, a special extended "__asm" keyword is used, followed\r
+// by an instruction name (any valid identifier), a destination variable identifier and a\r
+// a list of zero or more source variable identifiers. A variable identifier is a variable name\r
+// declared earlier in the code (as a function parameter, local or global variable).\r
+// An instruction name designates an instruction that must be exported by the implementation.\r
+// Each instruction receives data from destination and source variable identifiers and returns\r
+// data in the destination variable identifier.\r
+// \r
+// It is up to the implementation how to define a particular operator or constructor. If it is\r
+// expected to being used rarely, it can be defined in terms of other operators and constructors,\r
+// for example:\r
+// \r
+// ivec2 operator + (const ivec2 x, const ivec2 y) {\r
+//    return ivec2 (x[0] + y[0], x[1] + y[1]);\r
+// }\r
+// \r
+// If a particular operator or constructor is expected to be used very often or is an atomic\r
+// operation (that is, an operation that cannot be expressed in terms of other operations or\r
+// would create a dependency cycle) it must be defined using one or more __asm constructs.\r
+// \r
+// Each implementation must define constructors for all scalar types (bool, float, int).\r
+// There are 9 scalar-to-scalar constructors (including identity constructors). However,\r
+// since the language introduces special constructors (like matrix constructor with a single\r
+// scalar value), implementations must also implement these cases.\r
+// The compiler provides the following algorithm when resolving a constructor:\r
+// - try to find a constructor with a prototype matching ours,\r
+// - if no constructor is found and this is a scalar-to-scalar constructor, raise an error,\r
+// - if a constructor is found, execute it and return,\r
+// - count the size of the constructor parameter list - if it is less than the size of\r
+//   our constructor's type, raise an error,\r
+// - for each parameter in the list do a recursive constructor matching for appropriate\r
+//   scalar fields in the constructed variable,\r
+// \r
+// Each implementation must also define a set of operators that deal with built-in data types.\r
+// There are four kinds of operators:\r
+// 1) Operators that are implemented only by the compiler: "()" (function call), "," (sequence)\r
+//    and "?:" (selection).\r
+// 2) Operators that are implemented by the compiler by expressing it in terms of other operators:\r
+//    - "." (field selection) - translated to subscript access,\r
+//    - "&&" (logical and) - translated to "<left_expr> ? <right_expr> : false",\r
+//    - "||" (logical or) - translated to "<left_expr> ? true : <right_expr>",\r
+// 3) Operators that can be defined by the implementation and if the required prototype is not\r
+//    found, standard behaviour is used:\r
+//    - "==", "!=", "=" (equality, assignment) - compare or assign matching fields one-by-one;\r
+//      note that at least operators for scalar data types must be defined by the implementation\r
+//      to get it work,\r
+// 4) All other operators not mentioned above. If no required prototype is found, an error is\r
+//    raised. An implementation must follow the language specification to provide all valid\r
+//    operator prototypes.\r
+// \r
+\r
+// \r
+// TODO:\r
+//   - do something with [] operator: leave it in compiler or move it here,\r
+//   - emulate bools and ints with floats (this should simplify target implementation),\r
+//   - are vec*mat and mat*vec definitions correct? is the list complete?\r
+// \r
+\r
+// \r
+// From Shader Spec, ver. 1.051\r
+// \r
+\r
+// \r
+// 5.4.1 Conversion and Scalar Constructors\r
+// \r
+\r
+// \r
+// When constructors are used to convert a float to an int, the fractional part of the\r
+// floating-point value is dropped.\r
+// \r
+\r
+int constructor (const float _f) {\r
+    int _i;\r
+    __asm float_to_int _i, _f;\r
+    return _i;\r
+}\r
+\r
+// \r
+// When a constructor is used to convert an int or a float to bool, 0 and 0.0 are converted to\r
+// false, and nonzero values are converted to true.\r
+// \r
+\r
+bool constructor (const int _i) {\r
+    return _i != 0;\r
+}\r
+\r
+bool constructor (const float _f) {\r
+    return _f != 0.0;\r
+}\r
+\r
+// \r
+// When a constructor is used to convert a bool to an int or float, false is converted to 0 or\r
+// 0.0, and true is converted to 1 or 1.0.\r
+// \r
+\r
+int constructor (const bool _b) {\r
+    return _b ? 1 : 0;\r
+}\r
+\r
+float constructor (const bool _b) {\r
+    return _b ? 1.0 : 0.0;\r
+}\r
+\r
+// \r
+// Int to float constructor.\r
+// \r
+\r
+float constructor (const int _i) {\r
+    float _f;\r
+    __asm int_to_float _f, _i;\r
+    return _f;\r
+}\r
+\r
+// \r
+// Identity constructors, like float(float) are also legal, but of little use.\r
+// \r
+\r
+bool constructor (const bool _b) {\r
+    return _b;\r
+}\r
+\r
+int constructor (const int _i) {\r
+    return _i;\r
+}\r
+\r
+float constructor (const float _f) {\r
+    return _f;\r
+}\r
+\r
+// \r
+// Scalar constructors with non-scalar parameters can be used to take the first element from\r
+// a non-scalar. For example, the constructor float(vec3) will select the first component of the\r
+// vec3 parameter.\r
+// \r
+\r
+// [These scalar conversions will be handled internally by the compiler.]\r
+\r
+// \r
+// 5.4.2 Vector and Matrix Constructors\r
+// \r
+// Constructors can be used to create vectors or matrices from a set of scalars, vectors,\r
+// or matrices. This includes the ability to shorten vectors or matrices.\r
+// \r
+\r
+// \r
+// If there is a single scalar parameter to a vector constructor, it is used to initialize all\r
+// components of the constructed vector to that scalar\92s value.\r
+// \r
+// If the basic type (bool, int, or float) of a parameter to a constructor does not match the basic\r
+// type of the object being constructed, the scalar construction rules (above) are used to convert\r
+// the parameters.\r
+// \r
+\r
+vec2 constructor (const float _f) {\r
+    return vec2 (_f, _f);\r
+}\r
+\r
+vec2 constructor (const int _i) {\r
+    return vec2 (_i, _i);\r
+}\r
+\r
+vec2 constructor (const bool _b) {\r
+    return vec2 (_b, _b);\r
+}\r
+\r
+vec3 constructor (const float _f) {\r
+    return vec3 (_f, _f, _f);\r
+}\r
+\r
+vec3 constructor (const int _i) {\r
+    return vec3 (_i, _i, _i);\r
+}\r
+\r
+vec3 constructor (const bool _b) {\r
+    return vec3 (_b, _b, _b);\r
+}\r
+\r
+vec4 constructor (const float _f) {\r
+    return vec4 (_f, _f, _f, _f);\r
+}\r
+\r
+vec4 constructor (const int _i) {\r
+    return vec4 (_i, _i, _i, _i);\r
+}\r
+\r
+vec4 constructor (const bool _b) {\r
+    return vec4 (_b, _b, _b, _b);\r
+}\r
+\r
+ivec2 constructor (const int _i) {\r
+    return ivec2 (_i, _i);\r
+}\r
+\r
+ivec2 constructor (const float _f) {\r
+    return ivec2 (_f, _f);\r
+}\r
+\r
+ivec2 constructor (const bool _b) {\r
+    return ivec2 (_b, _b);\r
+}\r
+\r
+ivec3 constructor (const int _i) {\r
+    return ivec3 (_i, _i, _i);\r
+}\r
+\r
+ivec3 constructor (const float _f) {\r
+    return ivec3 (_f, _f, _f);\r
+}\r
+\r
+ivec3 constructor (const bool _b) {\r
+    return ivec3 (_b, _b, _b);\r
+}\r
+\r
+ivec4 constructor (const int _i) {\r
+    return ivec4 (_i, _i, _i, _i);\r
+}\r
+\r
+ivec4 constructor (const float _f) {\r
+    return ivec4 (_f, _f, _f, _f);\r
+}\r
+\r
+ivec4 constructor (const bool _b) {\r
+    return ivec4 (_b, _b, _b, _b);\r
+}\r
+\r
+bvec2 constructor (const bool _b) {\r
+    return bvec2 (_b, _b);\r
+}\r
+\r
+bvec2 constructor (const float _f) {\r
+    return bvec2 (_f, _f);\r
+}\r
+\r
+bvec2 constructor (const int _i) {\r
+    return bvec2 (_i, _i);\r
+}\r
+\r
+bvec3 constructor (const bool _b) {\r
+    return bvec3 (_b, _b, _b);\r
+}\r
+\r
+bvec3 constructor (const float _f) {\r
+    return bvec3 (_f, _f, _f);\r
+}\r
+\r
+bvec3 constructor (const int _i) {\r
+    return bvec3 (_i, _i, _i);\r
+}\r
+\r
+bvec4 constructor (const bool _b) {\r
+    return bvec4 (_b, _b, _b, _b);\r
+}\r
+\r
+bvec4 constructor (const float _f) {\r
+    return bvec4 (_f, _f, _f, _f);\r
+}\r
+\r
+bvec4 constructor (const int _i) {\r
+    return bvec4 (_i, _i, _i, _i);\r
+}\r
+\r
+// \r
+// If there is a single scalar parameter to a matrix constructor, it is used to initialize all the\r
+// components on the matrix\92s diagonal, with the remaining components initialized to 0.0.\r
+// (...) Matrices will be constructed in column major order.\r
+// \r
+// If the basic type (bool, int, or float) of a parameter to a constructor does not match the basic\r
+// type of the object being constructed, the scalar construction rules (above) are used to convert\r
+// the parameters.\r
+// \r
+\r
+mat2 constructor (const float _f) {\r
+    return mat2 (\r
+        _f, .0,\r
+        .0, _f\r
+    );\r
+}\r
+\r
+mat2 constructor (const int _i) {\r
+    return mat2 (\r
+        _i, .0,\r
+        .0, _i\r
+    );\r
+}\r
+\r
+mat2 constructor (const bool _b) {\r
+    return mat2 (\r
+        _b, .0,\r
+        .0, _b\r
+    );\r
+}\r
+\r
+mat3 constructor (const float _f) {\r
+    return mat3 (\r
+        _f, .0, .0,\r
+        .0, _f, .0,\r
+        .0, .0, _f\r
+    );\r
+}\r
+\r
+mat3 constructor (const int _i) {\r
+    return mat3 (\r
+        _i, .0, .0,\r
+        .0, _i, .0,\r
+        .0, .0, _i\r
+    );\r
+}\r
+\r
+mat3 constructor (const bool _b) {\r
+    return mat3 (\r
+        _b, .0, .0,\r
+        .0, _b, .0,\r
+        .0, .0, _b\r
+    );\r
+}\r
+\r
+mat4 constructor (const float _f) {\r
+    return mat4 (\r
+        _f, .0, .0, .0,\r
+        .0, _f, .0, .0,\r
+        .0, .0, _f, .0,\r
+        .0, .0, .0, _f\r
+    );\r
+}\r
+\r
+mat4 constructor (const int _i) {\r
+    return mat4 (\r
+        _i, .0, .0, .0,\r
+        .0, _i, .0, .0,\r
+        .0, .0, _i, .0,\r
+        .0, .0, .0, _i\r
+    );\r
+}\r
+\r
+mat4 constructor (const bool _b) {\r
+    return mat4 (\r
+        _b, .0, .0, .0,\r
+        .0, _b, .0, .0,\r
+        .0, .0, _b, .0,\r
+        .0, .0, .0, _b\r
+    );\r
+}\r
+\r
+// \r
+// 5.8 Assignments\r
+// \r
+// Assignments of values to variable names are done with the assignment operator ( = ), like\r
+// \r
+//   lvalue = expression\r
+// \r
+// The assignment operator stores the value of expression into lvalue. It will compile only if\r
+// expression and lvalue have the same type. All desired type-conversions must be specified\r
+// explicitly via a constructor. Lvalues must be writable. Variables that are built-in types,\r
+// entire structures, structure fields, l-values with the field selector ( . ) applied to select\r
+// components or swizzles without repeated fields, and l-values dereferenced with the array\r
+// subscript operator ( [ ] ) are all possible l-values. Other binary or unary expressions,\r
+// non-dereferenced arrays, function names, swizzles with repeated fields, and constants cannot\r
+// be l-values.\r
+// \r
+// Expressions on the left of an assignment are evaluated before expressions on the right of the\r
+// assignment.\r
+// \r
+\r
+void operator = (inout float a, const float b) {\r
+       __asm float_copy a, b;\r
+}\r
+\r
+void operator = (inout int a, const int b) {\r
+       __asm int_copy a, b;\r
+}\r
+\r
+void operator = (inout bool a, const bool b) {\r
+       __asm bool_copy a, b;\r
+}\r
+\r
+void operator = (inout vec2 v, const vec2 u) {\r
+       v.x = u.x, v.y = u.y;\r
+}\r
+\r
+void operator = (inout vec3 v, const vec3 u) {\r
+       v.x = u.x, v.y = u.y, v.z = u.z;\r
+}\r
+\r
+void operator = (inout vec4 v, const vec4 u) {\r
+       v.x = u.x, v.y = u.y, v.z = u.z, v.w = u.w;\r
+}\r
+\r
+void operator = (inout ivec2 v, const ivec2 u) {\r
+       v.x = u.x, v.y = u.y;\r
+}\r
+\r
+void operator = (inout ivec3 v, const ivec3 u) {\r
+       v.x = u.x, v.y = u.y, v.z = u.z;\r
+}\r
+\r
+void operator = (inout ivec4 v, const ivec4 u) {\r
+       v.x = u.x, v.y = u.y, v.z = u.z, v.w = u.w;\r
+}\r
+\r
+void operator = (inout bvec2 v, const bvec2 u) {\r
+       v.x = u.x, v.y = u.y;\r
+}\r
+\r
+void operator = (inout bvec3 v, const bvec3 u) {\r
+       v.x = u.x, v.y = u.y, v.z = u.z;\r
+}\r
+\r
+void operator = (inout bvec4 v, const bvec4 u) {\r
+       v.x = u.x, v.y = u.y, v.z = u.z, v.w = u.w;\r
+}\r
+\r
+void operator = (inout mat2 m, const mat2 n) {\r
+       m[0] = n[0], m[1] = n[1];\r
+}\r
+\r
+void operator = (inout mat3 m, const mat3 n) {\r
+       m[0] = n[0], m[1] = n[1], m[2] = n[2];\r
+}\r
+\r
+void operator = (inout mat4 m, const mat4 n) {\r
+       m[0] = n[0], m[1] = n[1], m[2] = n[2], m[3] = n[3];\r
+}\r
+\r
+// \r
+// \95 The arithmetic assignments add into (+=), subtract from (-=), multiply into (*=), and divide\r
+//   into (/=). The variable and expression must be the same floating-point or integer type, ...\r
+// \r
+\r
+void operator += (inout float a, const float b) {\r
+    __asm float_add a, b;\r
+}\r
+\r
+void operator -= (inout float a, const float b) {\r
+    a += -b;\r
+}\r
+\r
+void operator *= (inout float a, const float b) {\r
+    __asm float_multiply a, b;\r
+}\r
+\r
+void operator /= (inout float a, const float b) {\r
+    __asm float_divide a, b;\r
+}\r
+\r
+void operator += (inout int x, const int y) {\r
+    __asm int_add x, y;\r
+}\r
+\r
+void operator -= (inout int x, const int y) {\r
+    x += -y;\r
+}\r
+\r
+void operator *= (inout int x, const int y) {\r
+    __asm int_multiply x, y;\r
+}\r
+\r
+void operator /= (inout int x, const int y) {\r
+    __asm int_divide x, y;\r
+}\r
+\r
+void operator += (inout vec2 v, const vec2 u) {\r
+    v.x += u.x, v.y += u.y;\r
+}\r
+\r
+void operator -= (inout vec2 v, const vec2 u) {\r
+    v.x -= u.x, v.y -= u.y;\r
+}\r
+\r
+void operator *= (inout vec2 v, const vec2 u) {\r
+    v.x *= u.x, v.y *= u.y;\r
+}\r
+\r
+void operator /= (inout vec2 v, const vec2 u) {\r
+    v.x /= u.x, v.y /= u.y;\r
+}\r
+\r
+void operator += (inout vec3 v, const vec3 u) {\r
+    v.x += u.x, v.y += u.y, v.z += u.z;\r
+}\r
+\r
+void operator -= (inout vec3 v, const vec3 u) {\r
+    v.x -= u.x, v.y -= u.y, v.z -= u.z;\r
+}\r
+\r
+void operator *= (inout vec3 v, const vec3 u) {\r
+    v.x *= u.x, v.y *= u.y, v.z *= u.z;\r
+}\r
+\r
+void operator /= (inout vec3 v, const vec3 u) {\r
+    v.x /= u.x, v.y /= u.y, v.z /= u.z;\r
+}\r
+\r
+void operator += (inout vec4 v, const vec4 u) {\r
+    v.x += u.x, v.y += u.y, v.z += u.z, v.w += u.w;\r
+}\r
+\r
+void operator -= (inout vec4 v, const vec4 u) {\r
+    v.x -= u.x, v.y -= u.y, v.z -= u.z, v.w -= u.w;\r
+}\r
+\r
+void operator *= (inout vec4 v, const vec4 u) {\r
+    v.x *= u.x, v.y *= u.y, v.z *= u.z, v.w *= u.w;\r
+}\r
+\r
+void operator /= (inout vec4 v, const vec4 u) {\r
+    v.x /= u.x, v.y /= u.y, v.z /= u.z, v.w /= u.w;\r
+}\r
+\r
+void operator += (inout ivec2 v, const ivec2 u) {\r
+    v.x += u.x, v.y += u.y;\r
+}\r
+\r
+void operator -= (inout ivec2 v, const ivec2 u) {\r
+    v.x -= u.x, v.y -= u.y;\r
+}\r
+\r
+void operator *= (inout ivec2 v, const ivec2 u) {\r
+    v.x *= u.x, v.y *= u.y;\r
+}\r
+\r
+void operator /= (inout ivec2 v, const ivec2 u) {\r
+    v.x /= u.x, v.y /= u.y;\r
+}\r
+\r
+void operator += (inout ivec3 v, const ivec3 u) {\r
+    v.x += u.x, v.y += u.y, v.z += u.z;\r
+}\r
+\r
+void operator -= (inout ivec3 v, const ivec3 u) {\r
+    v.x -= u.x, v.y -= u.y, v.z -= u.z;\r
+}\r
+\r
+void operator *= (inout ivec3 v, const ivec3 u) {\r
+    v.x *= u.x, v.y *= u.y, v.z *= u.z;\r
+}\r
+\r
+void operator /= (inout ivec3 v, const ivec3 u) {\r
+    v.x /= u.x, v.y /= u.y, v.z /= u.z;\r
+}\r
+\r
+void operator += (inout ivec4 v, const ivec4 u) {\r
+    v.x += u.x, v.y += u.y, v.z += u.z, v.w += u.w;\r
+}\r
+\r
+void operator -= (inout ivec4 v, const ivec4 u) {\r
+    v.x -= u.x, v.y -= u.y, v.z -= u.z, v.w -= u.w;\r
+}\r
+\r
+void operator *= (inout ivec4 v, const ivec4 u) {\r
+    v.x *= u.x, v.y *= u.y, v.z *= u.z, v.w *= u.w;\r
+}\r
+\r
+void operator /= (inout ivec4 v, const ivec4 u) {\r
+    v.x /= u.x, v.y /= u.y, v.z /= u.z, v.w /= u.w;\r
+}\r
+\r
+void operator += (inout mat2 m, const mat2 n) {\r
+    m[0] += n[0], m[1] += n[1];\r
+}\r
+\r
+void operator -= (inout mat2 v, const mat2 n) {\r
+    m[0] -= n[0], m[1] -= n[1];\r
+}\r
+\r
+void operator *= (inout mat2 m, const mat2 n) {\r
+    m = m * n;\r
+}\r
+\r
+void operator /= (inout mat2 m, const mat2 n) {\r
+    m[0] /= n[0], m[1] /= n[1];\r
+}\r
+\r
+void operator += (inout mat3 m, const mat3 n) {\r
+    m[0] += n[0], m[1] += n[1], m[2] += n[2];\r
+}\r
+\r
+void operator -= (inout mat3 m, const mat3 n) {\r
+    m[0] -= n[0], m[1] -= n[1], m[2] -= n[2];\r
+}\r
+\r
+void operator *= (inout mat3 m, const mat3 n) {\r
+    m = m * n;\r
+}\r
+\r
+void operator /= (inout mat3 m, const mat3 n) {\r
+    m[0] /= n[0], m[1] /= n[1], m[2] /= n[2];\r
+}\r
+\r
+void operator += (inout mat4 m, const mat4 n) {\r
+    m[0] += n[0], m[1] += n[1], m[2] += n[2], m[3] += n[3];\r
+}\r
+\r
+void operator -= (inout mat4 m, const mat4 n) {\r
+    m[0] -= n[0], m[1] -= n[1], m[2] -= n[2], m[3] -= n[3];\r
+}\r
+\r
+void operator *= (inout mat4 m, const mat4 n) {\r
+    m = m * n;\r
+}\r
+\r
+void operator /= (inout mat4 m, const mat4 n) {\r
+    m[0] /= n[0], m[1] /= n[1], m[2] /= n[2], m[3] /= n[3];\r
+}\r
+\r
+// \r
+//   ... or if the expression is a float, then the variable can be floating-point, a vector, or\r
+//   a matrix, ...\r
+// \r
+\r
+void operator += (inout vec2 v, const float a) {\r
+    v.x += a, v.y += a;\r
+}\r
+\r
+void operator -= (inout vec2 v, const float a) {\r
+    v.x -= a, v.y -= a;\r
+}\r
+\r
+void operator *= (inout vec2 v, const float a) {\r
+    v.x *= a, v.y *= a;\r
+}\r
+\r
+void operator /= (inout vec2 v, const float a) {\r
+    v.x /= a, v.y /= a;\r
+}\r
+\r
+void operator += (inout vec3 v, const float a) {\r
+    v.x += a, v.y += a, v.z += a;\r
+}\r
+\r
+void operator -= (inout vec3 v, const float a) {\r
+    v.x -= a, v.y -= a, v.z -= a;\r
+}\r
+\r
+void operator *= (inout vec3 v, const float a) {\r
+    v.x *= a, v.y *= a, v.z *= a;\r
+}\r
+\r
+void operator /= (inout vec3 v, const float a) {\r
+    v.x /= a, v.y /= a, v.z /= a;\r
+}\r
+\r
+void operator += (inout vec4 v, const float a) {\r
+    v.x += a, v.y += a, v.z += a, v.w += a;\r
+}\r
+\r
+void operator -= (inout vec4 v, const float a) {\r
+    v.x -= a, v.y -= a, v.z -= a, v.w -= a;\r
+}\r
+\r
+void operator *= (inout vec4 v, const float a) {\r
+    v.x *= a, v.y *= a, v.z *= a, v.w *= a;\r
+}\r
+\r
+void operator /= (inout vec4 v, const float a) {\r
+    v.x /= a, v.y /= a, v.z /= a, v.w /= a;\r
+}\r
+\r
+void operator += (inout mat2 m, const float a) {\r
+    m[0] += a, m[1] += a;\r
+}\r
+\r
+void operator -= (inout mat2 m, const float a) {\r
+    m[0] -= a, m[1] -= a;\r
+}\r
+\r
+void operator *= (inout mat2 m, const float a) {\r
+    m[0] *= a, m[1] *= a;\r
+}\r
+\r
+void operator /= (inout mat2 m, const float a) {\r
+    m[0] /= a, m[1] /= a;\r
+}\r
+\r
+void operator += (inout mat3 m, const float a) {\r
+    m[0] += a, m[1] += a, m[2] += a;\r
+}\r
+\r
+void operator -= (inout mat3 m, const float a) {\r
+    m[0] -= a, m[1] -= a, m[2] -= a;\r
+}\r
+\r
+void operator *= (inout mat3 m, const float a) {\r
+    m[0] *= a, m[1] *= a, m[2] *= a;\r
+}\r
+\r
+void operator /= (inout mat3 m, const float a) {\r
+    m[0] /= a, m[1] /= a, m[2] /= a;\r
+}\r
+\r
+void operator += (inout mat4 m, const float a) {\r
+    m[0] += a, m[1] += a, m[2] += a, m[3] += a;\r
+}\r
+\r
+void operator -= (inout mat4 m, const float a) {\r
+    m[0] -= a, m[1] -= a, m[2] -= a, m[3] -= a;\r
+}\r
+\r
+void operator *= (inout mat4 m, const float a) {\r
+    m[0] *= a, m[1] *= a, m[2] *= a, m[3] *= a;\r
+}\r
+\r
+void operator /= (inout mat4 m, const float a) {\r
+    m[0] /= a, m[1] /= a, m[2] /= a, m[3] /= a;\r
+}\r
+\r
+// \r
+//   ... or if the operation is multiply into (*=), then the variable can be a vector and the\r
+//   expression can be a matrix of matching size.\r
+// \r
+\r
+void operator *= (inout vec2 v, const mat2 m) {\r
+    v = v * m;\r
+}\r
+\r
+void operator *= (inout vec3 v, const mat3 m) {\r
+    v = v * m;\r
+}\r
+\r
+void operator *= (inout vec4 v, const mat4 m) {\r
+    v = v * m;\r
+}\r
+\r
+// \r
+// 5.9 Expressions\r
+// \r
+// Expressions in the shading language include the following:\r
+// \r
+\r
+// \r
+// \95 The arithmetic binary operators add (+), subtract (-), multiply (*), and divide (/), that\r
+//   operate on integer and floating-point typed expressions (including vectors and matrices).\r
+//   The two operands must be the same type, ...\r
+// \r
+\r
+float operator + (const float a, const float b) {\r
+    float c = a;\r
+    return c += b;\r
+}\r
+\r
+float operator - (const float a, const float b) {\r
+    return a + -b;\r
+}\r
+\r
+float operator * (const float a, const float b) {\r
+    float c = a;\r
+    return c *= b;\r
+}\r
+\r
+float operator / (const float a, const float b) {\r
+    float c = a;\r
+    return c /= b;\r
+}\r
+\r
+int operator + (const int a, const int b) {\r
+    int c = a;\r
+    return c += b;\r
+}\r
+\r
+int operator - (const int x, const int y) {\r
+    return x + -y;\r
+}\r
+\r
+int operator * (const int x, const int y) {\r
+    int z = x;\r
+    return z *= y;\r
+}\r
+\r
+int operator / (const int x, const int y) {\r
+    int z = x;\r
+    return z /= y;\r
+}\r
+\r
+vec2 operator + (const vec2 v, const vec2 u) {\r
+    return vec2 (v.x + u.x, v.y + u.y);\r
+}\r
+\r
+vec2 operator - (const vec2 v, const vec2 u) {\r
+    return vec2 (v.x - u.x, v.y - u.y);\r
+}\r
+\r
+vec3 operator + (const vec3 v, const vec3 u) {\r
+    return vec3 (v.x + u.x, v.y + u.y, v.z + u.z);\r
+}\r
+\r
+vec3 operator - (const vec3 v, const vec3 u) {\r
+    return vec3 (v.x - u.x, v.y - u.y, v.z - u.z);\r
+}\r
+\r
+vec4 operator + (const vec4 v, const vec4 u) {\r
+    return vec4 (v.x + u.x, v.y + u.y, v.z + u.z, v.w + u.w);\r
+}\r
+\r
+vec4 operator - (const vec4 v, const vec4 u) {\r
+    return vec4 (v.x - u.x, v.y - u.y, v.z - u.z, v.w - u.w);\r
+}\r
+\r
+ivec2 operator + (const ivec2 v, const ivec2 u) {\r
+    return ivec2 (v.x + u.x, v.y + u.y);\r
+}\r
+\r
+ivec2 operator - (const ivec2 v, const ivec2 u) {\r
+    return ivec2 (v.x - u.x, v.y - u.y);\r
+}\r
+\r
+ivec3 operator + (const ivec3 v, const ivec3 u) {\r
+    return ivec3 (v.x + u.x, v.y + u.y, v.z + u.z);\r
+}\r
+\r
+ivec3 operator - (const ivec3 v, const ivec3 u) {\r
+    return ivec3 (v.x - u.x, v.y - u.y, v.z - u.z);\r
+}\r
+\r
+ivec4 operator + (const ivec4 v, const ivec4 u) {\r
+    return ivec4 (v.x + u.x, v.y + u.y, v.z + u.z, v.w + u.w);\r
+}\r
+\r
+ivec4 operator - (const ivec4 v, const ivec4 u) {\r
+    return ivec4 (v.x - u.x, v.y - u.y, v.z - u.z, v.w - u.w);\r
+}\r
+\r
+mat2 operator + (const mat2 m, const mat2 n) {\r
+    return mat2 (m[0] + n[0], m[1] + n[1]);\r
+}\r
+\r
+mat2 operator - (const mat2 m, const mat2 n) {\r
+    return mat2 (m[0] - n[0], m[1] - n[1]);\r
+}\r
+\r
+mat3 operator + (const mat3 m, const mat3 n) {\r
+    return mat3 (m[0] + n[0], m[1] + n[1], m[2] + n[2]);\r
+}\r
+\r
+mat3 operator - (const mat3 m, const mat3 n) {\r
+    return mat3 (m[0] - n[0], m[1] - n[1], m[2] - n[2]);\r
+}\r
+\r
+mat4 operator + (const mat4 m, const mat4 n) {\r
+    return mat4 (m[0] + n[0], m[1] + n[1], m[2] + n[2], m[3] + n[3]);\r
+}\r
+\r
+mat4 operator - (const mat4 m, const mat4 n) {\r
+    return mat4 (m[0] - n[0], m[1] - n[1], m[2] - n[2], m[3] - n[3]);\r
+}\r
+\r
+// \r
+//   ... or one must be a scalar float and the other a vector or matrix, ...\r
+// \r
+\r
+vec2 operator + (const float a, const vec2 u) {\r
+    return vec2 (a + u.x, a + u.y);\r
+}\r
+\r
+vec2 operator + (const vec2 v, const float b) {\r
+    return vec2 (v.x + b, v.y + b);\r
+}\r
+\r
+vec2 operator - (const float a, const vec2 u) {\r
+    return vec2 (a - u.x, a - u.y);\r
+}\r
+\r
+vec2 operator - (const vec2 v, const float b) {\r
+    return vec2 (v.x - b, v.y - b);\r
+}\r
+\r
+vec2 operator * (const float a, const vec2 u) {\r
+    return vec2 (a * u.x, a * u.y);\r
+}\r
+\r
+vec2 operator * (const vec2 v, const float b) {\r
+    return vec2 (v.x * b, v.y * b);\r
+}\r
+\r
+vec2 operator / (const float a, const vec2 u) {\r
+    return vec2 (a / u.x, a / u.y);\r
+}\r
+\r
+vec2 operator / (const vec2 v, const float b) {\r
+    return vec2 (v.x / b, v.y / b);\r
+}\r
+\r
+vec3 operator + (const float a, const vec3 u) {\r
+    return vec3 (a + u.x, a + u.y, a + u.z);\r
+}\r
+\r
+vec3 operator + (const vec3 v, const float b) {\r
+    return vec3 (v.x + b, v.y + b, v.z + b);\r
+}\r
+\r
+vec3 operator - (const float a, const vec3 u) {\r
+    return vec3 (a - u.x, a - u.y, a - u.z);\r
+}\r
+\r
+vec3 operator - (const vec3 v, const float b) {\r
+    return vec3 (v.x - b, v.y - b, v.z - b);\r
+}\r
+\r
+vec3 operator * (const float a, const vec3 u) {\r
+    return vec3 (a * u.x, a * u.y, a * u.z);\r
+}\r
+\r
+vec3 operator * (const vec3 v, const float b) {\r
+    return vec3 (v.x * b, v.y * b, v.z * b);\r
+}\r
+\r
+vec3 operator / (const float a, const vec3 u) {\r
+    return vec3 (a / u.x, a / u.y, a / u.z);\r
+}\r
+\r
+vec3 operator / (const vec3 v, const float b) {\r
+    return vec3 (v.x / b, v.y / b, v.z / b);\r
+}\r
+\r
+vec4 operator + (const float a, const vec4 u) {\r
+    return vec4 (a + u.x, a + u.y, a + u.z, a + u.w);\r
+}\r
+\r
+vec4 operator + (const vec4 v, const float b) {\r
+    return vec4 (v.x + b, v.y + b, v.z + b, v.w + b);\r
+}\r
+\r
+vec4 operator - (const float a, const vec4 u) {\r
+    return vec4 (a - u.x, a - u.y, a - u.z, a - u.w);\r
+}\r
+\r
+vec4 operator - (const vec4 v, const float b) {\r
+    return vec4 (v.x - b, v.y - b, v.z - b, v.w - b);\r
+}\r
+\r
+vec4 operator * (const float a, const vec4 u) {\r
+    return vec4 (a * u.x, a * u.y, a * u.z, a * u.w);\r
+}\r
+\r
+vec4 operator * (const vec4 v, const float b) {\r
+    return vec4 (v.x * b, v.y * b, v.z * b, v.w * b);\r
+}\r
+\r
+vec4 operator / (const float a, const vec4 u) {\r
+    return vec4 (a / u.x, a / u.y, a / u.z, a / u.w);\r
+}\r
+\r
+vec4 operator / (const vec4 v, const float b) {\r
+    return vec4 (v.x / b, v.y / b, v.z / b, v.w / b);\r
+}\r
+\r
+mat2 operator + (const float a, const mat2 n) {\r
+    return mat2 (a + n[0], a + n[1]);\r
+}\r
+\r
+mat2 operator + (const mat2 m, const float b) {\r
+    return mat2 (m[0] + b, m[1] + b);\r
+}\r
+\r
+mat2 operator - (const float a, const mat2 n) {\r
+    return mat2 (a - n[0], a - n[1]);\r
+}\r
+\r
+mat2 operator - (const mat2 m, const float b) {\r
+    return mat2 (m[0] - b, m[1] - b);\r
+}\r
+\r
+mat2 operator * (const float a, const mat2 n) {\r
+    return mat2 (a * n[0], a * n[1]);\r
+}\r
+\r
+mat2 operator * (const mat2 m, const float b) {\r
+    return mat2 (m[0] * b, m[1] * b);\r
+}\r
+\r
+mat2 operator / (const float a, const mat2 n) {\r
+    return mat2 (a / n[0], a / n[1]);\r
+}\r
+\r
+mat2 operator / (const mat2 m, const float b) {\r
+    return mat2 (m[0] / b, m[1] / b);\r
+}\r
+\r
+mat3 operator + (const float a, const mat3 n) {\r
+    return mat3 (a + n[0], a + n[1], a + n[2]);\r
+}\r
+\r
+mat3 operator + (const mat3 m, const float b) {\r
+    return mat3 (m[0] + b, m[1] + b, m[2] + b);\r
+}\r
+\r
+mat3 operator - (const float a, const mat3 n) {\r
+    return mat3 (a - n[0], a - n[1], a - n[2]);\r
+}\r
+\r
+mat3 operator - (const mat3 m, const float b) {\r
+    return mat3 (m[0] - b, m[1] - b, m[2] - b);\r
+}\r
+\r
+mat3 operator * (const float a, const mat3 n) {\r
+    return mat3 (a * n[0], a * n[1], a * n[2]);\r
+}\r
+\r
+mat3 operator * (const mat3 m, const float b) {\r
+    return mat3 (m[0] * b, m[1] * b, m[2] * b);\r
+}\r
+\r
+mat3 operator / (const float a, const mat3 n) {\r
+    return mat3 (a / n[0], a / n[1], a / n[2]);\r
+}\r
+\r
+mat3 operator / (const mat3 m, const float b) {\r
+    return mat3 (m[0] / b, m[1] / b, m[2] / b);\r
+}\r
+\r
+mat4 operator + (const float a, const mat4 n) {\r
+    return mat4 (a + n[0], a + n[1], a + n[2], a + n[3]);\r
+}\r
+\r
+mat4 operator + (const mat4 m, const float b) {\r
+    return mat4 (m[0] + b, m[1] + b, m[2] + b, m[3] + b);\r
+}\r
+\r
+mat4 operator - (const float a, const mat4 n) {\r
+    return mat4 (a - n[0], a - n[1], a - n[2], a - n[3]);\r
+}\r
+\r
+mat4 operator - (const mat4 m, const float b) {\r
+    return mat4 (m[0] - b, m[1] - b, m[2] - b, m[3] - b);\r
+}\r
+\r
+mat4 operator * (const float a, const mat4 n) {\r
+    return mat4 (a * n[0], a * n[1], a * n[2], a * n[3]);\r
+}\r
+\r
+mat4 operator * (const mat4 m, const float b) {\r
+    return mat4 (m[0] * b, m[1] * b, m[2] * b, m[3] * b);\r
+}\r
+\r
+mat4 operator / (const float a, const mat4 n) {\r
+    return mat4 (a / n[0], a / n[1], a / n[2], a / n[3]);\r
+}\r
+\r
+mat4 operator / (const mat4 m, const float b) {\r
+    return mat4 (m[0] / b, m[1] / b, m[2] / b, m[3] / b);\r
+}\r
+\r
+// \r
+//   ... or for multiply (*) one can be a vector and the other a matrix with the same dimensional\r
+//   size of the vector.\r
+// \r
+// [When:]\r
+// \95 the left argument is a floating-point vector and the right is a matrix with a compatible\r
+//   dimension in which case the * operator will do a row vector matrix multiplication.\r
+// \95 the left argument is a matrix and the right is a floating-point vector with a compatible\r
+//   dimension in which case the * operator will do a column vector matrix multiplication.\r
+// \r
+\r
+vec2 operator * (const mat2 m, const vec2 v) {\r
+    return vec2 (\r
+        v.x * m[0].x + v.y * m[1].x,\r
+        v.x * m[0].y + v.y * m[1].y\r
+    );\r
+}\r
+\r
+vec2 operator * (const vec2 v, const mat2 m) {\r
+    return vec2 (\r
+        v.x * m[0].x + v.y * m[0].y,\r
+        v.x * m[1].x + v.y * m[1].y\r
+    );\r
+}\r
+\r
+vec3 operator * (const mat3 m, const vec3 v) {\r
+    return vec3 (\r
+        v.x * m[0].x + v.y * m[1].x + v.z * m[2].x,\r
+        v.x * m[0].y + v.y * m[1].y + v.z * m[2].y,\r
+        v.x * m[0].z + v.y * m[1].z + v.z * m[2].z\r
+    );\r
+}\r
+\r
+vec3 operator * (const vec3 v, const mat3 m) {\r
+    return vec3 (\r
+        v.x * m[0].x + v.y * m[0].y + v.z * m[0].z,\r
+        v.x * m[1].x + v.y * m[1].y + v.z * m[1].z,\r
+        v.x * m[2].x + v.y * m[2].y + v.z * m[2].z\r
+    );\r
+}\r
+\r
+vec4 operator * (const mat4 m, const vec4 v) {\r
+    return vec4 (\r
+        v.x * m[0].x + v.y * m[1].x + v.z * m[2].x + v.w * m[3].x,\r
+        v.x * m[0].y + v.y * m[1].y + v.z * m[2].y + v.w * m[3].y,\r
+        v.x * m[0].z + v.y * m[1].z + v.z * m[2].z + v.w * m[3].z,\r
+        v.x * m[0].w + v.y * m[1].w + v.z * m[2].w + v.w * m[3].w\r
+    );\r
+}\r
+\r
+vec4 operator * (const vec4 v, const mat4 m) {\r
+    return vec4 (\r
+        v.x * m[0].x + v.y * m[0].y + v.z * m[0].z + v.w * m[0].w,\r
+        v.x * m[1].x + v.y * m[1].y + v.z * m[1].z + v.w * m[1].w,\r
+        v.x * m[2].x + v.y * m[2].y + v.z * m[2].z + v.w * m[2].w,\r
+        v.x * m[3].x + v.y * m[3].y + v.z * m[3].z + v.w * m[3].w\r
+    );\r
+}\r
+\r
+// \r
+//   Multiply (*) applied to two vectors yields a component-wise multiply.\r
+// \r
+\r
+vec2 operator * (const vec2 v, const vec2 u) {\r
+    return vec2 (v.x * u.x, v.y * u.y);\r
+}\r
+\r
+vec3 operator * (const vec3 v, const vec3 u) {\r
+    return vec3 (v.x * u.x, v.y * u.y, v.z * u.z);\r
+}\r
+\r
+vec4 operator * (const vec4 v, const vec4 u) {\r
+    return vec4 (v.x * u.x, v.y * u.y, v.z * u.z, v.w * u.w);\r
+}\r
+\r
+ivec2 operator * (const ivec2 v, const ivec2 u) {\r
+    return ivec2 (v.x * u.x, v.y * u.y);\r
+}\r
+\r
+ivec3 operator * (const ivec3 v, const ivec3 u) {\r
+    return ivec3 (v.x * u.x, v.y * u.y, v.z * u.z);\r
+}\r
+\r
+ivec4 operator * (const ivec4 v, const ivec4 u) {\r
+    return ivec4 (v.x * u.x, v.y * u.y, v.z * u.z, v.w * u.w);\r
+}\r
+\r
+// \r
+//   Dividing by zero does not cause an exception but does result in an unspecified value.\r
+// \r
+\r
+vec2 operator / (const vec2 v, const vec2 u) {\r
+    return vec2 (v.x / u.x, v.y / u.y);\r
+}\r
+\r
+vec3 operator / (const vec3 v, const vec3 u) {\r
+    return vec3 (v.x / u.x, v.y / u.y, v.z / u.z);\r
+}\r
+\r
+vec4 operator / (const vec4 v, const vec4 u) {\r
+    return vec4 (v.x / u.x, v.y / u.y, v.z / u.z, v.w / u.w);\r
+}\r
+\r
+ivec2 operator / (const ivec2 v, const ivec2 u) {\r
+    return ivec2 (v.x / u.x, v.y / u.y);\r
+}\r
+\r
+ivec3 operator / (const ivec3 v, const ivec3 u) {\r
+    return ivec3 (v.x / u.x, v.y / u.y, v.z / u.z);\r
+}\r
+\r
+ivec4 operator / (const ivec4 v, const ivec4 u) {\r
+    return ivec4 (v.x / u.x, v.y / u.y, v.z / u.z, v.w / u.w);\r
+}\r
+\r
+mat2 operator / (const mat2 m, const mat2 n) {\r
+    return mat2 (m[0] / n[0], m[1] / n[1]);\r
+}\r
+\r
+mat3 operator / (const mat3 m, const mat3 n) {\r
+    return mat3 (m[0] / n[0], m[1] / n[1], m[2] / n[2]);\r
+}\r
+\r
+mat4 operator / (const mat4 m, const mat4 n) {\r
+    return mat4 (m[0] / n[0], m[1] / n[1], m[2] / n[2], m[3] / n[3]);\r
+}\r
+\r
+// \r
+//   Multiply (*) applied to two matrices yields a linear algebraic matrix multiply, not\r
+//   a component-wise multiply.\r
+// \r
+\r
+mat2 operator * (const mat2 m, const mat2 n) {\r
+    return mat2 (m * n[0], m * n[1]);\r
+}\r
+\r
+mat3 operator * (const mat3 m, const mat3 n) {\r
+    return mat3 (m * n[0], m * n[1], m * n[2]);\r
+}\r
+\r
+mat4 operator * (const mat4 m, const mat4 n) {\r
+    return mat4 (m * n[0], m * n[1], m * n[2], m * n[3]);\r
+}\r
+\r
+// \r
+// \95 The arithmetic unary operators negate (-), post- and pre-increment and decrement (-- and\r
+//   ++) that operate on integer or floating-point values (including vectors and matrices). These\r
+//   result with the same type they operated on. For post- and pre-increment and decrement, the\r
+//   expression must be one that could be assigned to (an l-value). Pre-increment and predecrement\r
+//   add or subtract 1 or 1.0 to the contents of the expression they operate on, and the\r
+//   value of the pre-increment or pre-decrement expression is the resulting value of that\r
+//   modification. Post-increment and post-decrement expressions add or subtract 1 or 1.0 to\r
+//   the contents of the expression they operate on, but the resulting expression has the\r
+//   expression\92s value before the post-increment or post-decrement was executed.\r
+// \r
+// [NOTE: postfix increment and decrement operators take additional dummy int parameter to\r
+//        distinguish their prototypes from prefix ones.]\r
+// \r
+\r
+float operator - (const float a) {\r
+    float c = a;\r
+    __asm float_negate c;\r
+    return c;\r
+}\r
+\r
+int operator - (const int a) {\r
+    int c = a;\r
+    __asm int_negate c;\r
+    return c;\r
+}\r
+\r
+vec2 operator - (const vec2 v) {\r
+    return vec2 (-v.x, -v.y);\r
+}\r
+\r
+vec3 operator - (const vec3 v) {\r
+    return vec3 (-v.x, -v.y, -v.z);\r
+}\r
+\r
+vec4 operator - (const vec4 v) {\r
+    return vec4 (-v.x, -v.y, -v.z, -v.w);\r
+}\r
+\r
+ivec2 operator - (const ivec2 v) {\r
+    return ivec2 (-v.x, -v.y);\r
+}\r
+\r
+ivec3 operator - (const ivec3 v) {\r
+    return ivec3 (-v.x, -v.y, -v.z);\r
+}\r
+\r
+ivec4 operator - (const ivec4 v) {\r
+    return ivec4 (-v.x, -v.y, -v.z, -v.w);\r
+}\r
+\r
+mat2 operator - (const mat2 m) {\r
+    return mat2 (-m[0], -m[1]);\r
+}\r
+\r
+mat3 operator - (const mat3 m) {\r
+    return mat3 (-m[0], -m[1], -m[2]);\r
+}\r
+\r
+mat4 operator - (const mat4 m) {\r
+    return mat4 (-m[0], -m[1], -m[2], -m[3]);\r
+}\r
+\r
+void operator -- (inout float a) {\r
+    a -= 1.0;\r
+}\r
+\r
+void operator -- (inout int a) {\r
+    a -= 1;\r
+}\r
+\r
+void operator -- (inout vec2 v) {\r
+    --v.x, --v.y;\r
+}\r
+\r
+void operator -- (inout vec3 v) {\r
+    --v.x, --v.y, --v.z;\r
+}\r
+\r
+void operator -- (inout vec4 v) {\r
+    --v.x, --v.y, --v.z, --v.w;\r
+}\r
+\r
+void operator -- (inout ivec2 v) {\r
+    --v.x, --v.y;\r
+}\r
+\r
+void operator -- (inout ivec3 v) {\r
+    --v.x, --v.y, --v.z;\r
+}\r
+\r
+void operator -- (inout ivec4 v) {\r
+    --v.x, --v.y, --v.z, --v.w;\r
+}\r
+\r
+void operator -- (inout mat2 m) {\r
+    --m[0], --m[1];\r
+}\r
+\r
+void operator -- (inout mat3 m) {\r
+    --m[0], --m[1], --m[2];\r
+}\r
+\r
+void operator -- (inout mat4 m) {\r
+    --m[0], --m[1], --m[2], --m[3];\r
+}\r
+\r
+void operator ++ (inout float a) {\r
+    a += 1.0;\r
+}\r
+\r
+void operator ++ (inout int a) {\r
+    a += 1;\r
+}\r
+\r
+void operator ++ (inout vec2 v) {\r
+    ++v.x, ++v.y;\r
+}\r
+\r
+void operator ++ (inout vec3 v) {\r
+    ++v.x, ++v.y, ++v.z;\r
+}\r
+\r
+void operator ++ (inout vec4 v) {\r
+    ++v.x, ++v.y, ++v.z, ++v.w;\r
+}\r
+\r
+void operator ++ (inout ivec2 v) {\r
+    ++v.x, ++v.y;\r
+}\r
+\r
+void operator ++ (inout ivec3 v) {\r
+    ++v.x, ++v.y, ++v.z;\r
+}\r
+\r
+void operator ++ (inout ivec4 v) {\r
+    ++v.x, ++v.y, ++v.z, ++v.w;\r
+}\r
+\r
+void operator ++ (inout mat2 m) {\r
+    ++m[0], ++m[1];\r
+}\r
+\r
+void operator ++ (inout mat3 m) {\r
+    ++m[0], ++m[1], ++m[2];\r
+}\r
+\r
+void operator ++ (inout mat4 m) {\r
+    ++m[0], ++m[1], ++m[2], ++m[3];\r
+}\r
+\r
+float operator -- (inout float a, const int) {\r
+    const float c = a;\r
+    --a;\r
+    return c;\r
+}\r
+\r
+int operator -- (inout int a, const int) {\r
+    const int c = a;\r
+    --a;\r
+    return c;\r
+}\r
+\r
+vec2 operator -- (inout vec2 v, const int) {\r
+    return vec2 (v.x--, v.y--);\r
+}\r
+\r
+vec3 operator -- (inout vec3 v, const int) {\r
+    return vec3 (v.x--, v.y--, v.z--);\r
+}\r
+\r
+vec4 operator -- (inout vec4 v, const int) {\r
+    return vec4 (v.x--, v.y--, v.z--, v.w--);\r
+}\r
+\r
+ivec2 operator -- (inout ivec2 v, const int) {\r
+    return ivec2 (v.x--, v.y--);\r
+}\r
+\r
+ivec3 operator -- (inout ivec3 v, const int) {\r
+    return ivec3 (v.x--, v.y--, v.z--);\r
+}\r
+\r
+ivec4 operator -- (inout ivec4 v, const int) {\r
+    return ivec4 (v.x--, v.y--, v.z--, v.w--);\r
+}\r
+\r
+mat2 operator -- (inout mat2 m, const int) {\r
+    return mat2 (m[0]--, m[1]--);\r
+}\r
+\r
+mat3 operator -- (inout mat3 m, const int) {\r
+    return mat3 (m[0]--, m[1]--, m[2]--);\r
+}\r
+\r
+mat4 operator -- (inout mat4 m, const int) {\r
+    return mat4 (m[0]--, m[1]--, m[2]--, m[3]--);\r
+}\r
+\r
+float operator ++ (inout float a, const int) {\r
+    const float c = a;\r
+    ++a;\r
+    return c;\r
+}\r
+\r
+int operator ++ (inout int a, const int) {\r
+    const int c = a;\r
+    ++a;\r
+    return c;\r
+}\r
+\r
+vec2 operator ++ (inout vec2 v, const int) {\r
+    return vec2 (v.x++, v.y++);\r
+}\r
+\r
+vec3 operator ++ (inout vec3 v, const int) {\r
+    return vec3 (v.x++, v.y++, v.z++);\r
+}\r
+\r
+vec4 operator ++ (inout vec4 v, const int) {\r
+    return vec4 (v.x++, v.y++, v.z++, v.w++);\r
+}\r
+\r
+ivec2 operator ++ (inout ivec2 v, const int) {\r
+    return ivec2 (v.x++, v.y++);\r
+}\r
+\r
+ivec3 operator ++ (inout ivec3 v, const int) {\r
+    return ivec3 (v.x++, v.y++, v.z++);\r
+}\r
+\r
+ivec4 operator ++ (inout ivec4 v, const int) {\r
+    return ivec4 (v.x++, v.y++, v.z++, v.w++);\r
+}\r
+\r
+mat2 operator ++ (inout mat2 m, const int) {\r
+    return mat2 (m[0]++, m[1]++);\r
+}\r
+\r
+mat3 operator ++ (inout mat3 m, const int) {\r
+    return mat3 (m[0]++, m[1]++, m[2]++);\r
+}\r
+\r
+mat4 operator ++ (inout mat4 m, const int) {\r
+    return mat4 (m[0]++, m[1]++, m[2]++, m[3]++);\r
+}\r
+\r
+// \r
+// \95 The relational operators greater than (>), less than (<), greater than or equal (>=), and less\r
+//   than or equal (<=) operate only on scalar integer and scalar floating-point expressions. The\r
+//   result is scalar Boolean. The operands\92 types must match. To do component-wise\r
+//   comparisons on vectors, use the built-in functions lessThan, lessThanEqual,\r
+//   greaterThan, and greaterThanEqual.\r
+// \r
+\r
+bool operator < (const float a, const float b) {\r
+    bool c;\r
+    __asm float_less c, a, b;\r
+    return c;\r
+}\r
+\r
+bool operator < (const int a, const int b) {\r
+    bool c;\r
+    __asm int_less c, a, b;\r
+    return c;\r
+}\r
+\r
+bool operator > (const float a, const float b) {\r
+    return b < a;\r
+}\r
+\r
+bool operator > (const int a, const int b) {\r
+    return b < a;\r
+}\r
+\r
+bool operator >= (const float a, const float b) {\r
+    return a > b || a == b;\r
+}\r
+\r
+bool operator >= (const int a, const int b) {\r
+    return a > b || a == b;\r
+}\r
+\r
+bool operator <= (const float a, const float b) {\r
+    return a < b || a == b;\r
+}\r
+\r
+bool operator <= (const int a, const int b) {\r
+    return a < b || a == b;\r
+}\r
+\r
+// \r
+// \95 The equality operators equal (==), and not equal (!=) operate on all types except arrays.\r
+//   They result in a scalar Boolean. For vectors, matrices, and structures, all components of the\r
+//   operands must be equal for the operands to be considered equal. To get component-wise\r
+//   equality results for vectors, use the built-in functions equal and notEqual.\r
+// \r
+\r
+bool operator == (const float a, const float b) {\r
+       bool c;\r
+       __asm float_equal c, a, b;\r
+       return c;\r
+}\r
+\r
+bool operator == (const int a, const int b) {\r
+       bool c;\r
+       __asm int_equal c, a, b;\r
+       return c;\r
+}\r
+\r
+bool operator == (const bool a, const bool b) {\r
+       bool c;\r
+       __asm bool_equal c, a, b;\r
+       return c;\r
+}\r
+\r
+bool operator == (const vec2 v, const vec2 u) {\r
+       return v.x == u.x && v.y == u.y;\r
+}\r
+\r
+bool operator == (const vec3 v, const vec3 u) {\r
+       return v.x == u.x && v.y == u.y && v.z == u.z;\r
+}\r
+\r
+bool operator == (const vec4 v, const vec4 u) {\r
+       return v.x == u.x && v.y == u.y && v.z == u.z && v.w == u.w;\r
+}\r
+\r
+bool operator == (const ivec2 v, const ivec2 u) {\r
+       return v.x == u.x && v.y == u.y;\r
+}\r
+\r
+bool operator == (const ivec3 v, const ivec3 u) {\r
+       return v.x == u.x && v.y == u.y && v.z == u.z;\r
+}\r
+\r
+bool operator == (const ivec4 v, const ivec4 u) {\r
+       return v.x == u.x && v.y == u.y && v.z == u.z && v.w == u.w;\r
+}\r
+\r
+bool operator == (const bvec2 v, const bvec2 u) {\r
+       return v.x == u.x && v.y == u.y;\r
+}\r
+\r
+bool operator == (const bvec3 v, const bvec3 u) {\r
+       return v.x == u.x && v.y == u.y && v.z == u.z;\r
+}\r
+\r
+bool operator == (const bvec4 v, const bvec4 u) {\r
+       return v.x == u.x && v.y == u.y && v.z == u.z && v.w == u.w;\r
+}\r
+\r
+bool operator == (const mat2 m, const mat2 n) {\r
+       return m[0] == n[0] && m[1] == n[1];\r
+}\r
+\r
+bool operator == (const mat3 m, const mat3 n) {\r
+       return m[0] == n[0] && m[1] == n[1] && m[2] == n[2];\r
+}\r
+\r
+bool operator == (const mat4 m, const mat4 n) {\r
+       return m[0] == n[0] && m[1] == n[1] && m[2] == n[2] && m[3] == n[3];\r
+}\r
+\r
+bool operator != (const float a, const float b) {\r
+       return !(a == b);\r
+}\r
+\r
+bool operator != (const int a, const int b) {\r
+       return !(a == b);\r
+}\r
+\r
+bool operator != (const bool a, const bool b) {\r
+       return !(a == b);\r
+}\r
+\r
+bool operator != (const vec2 v, const vec2 u) {\r
+       return v.x != u.x || v.y != u.y;\r
+}\r
+\r
+bool operator != (const vec3 v, const vec3 u) {\r
+       return v.x != u.x || v.y != u.y || v.z != u.z;\r
+}\r
+\r
+bool operator != (const vec4 v, const vec4 u) {\r
+       return v.x != u.x || v.y != u.y || v.z != u.z || v.w != u.w;\r
+}\r
+\r
+bool operator != (const ivec2 v, const ivec2 u) {\r
+       return v.x != u.x || v.y != u.y;\r
+}\r
+\r
+bool operator != (const ivec3 v, const ivec3 u) {\r
+       return v.x != u.x || v.y != u.y || v.z != u.z;\r
+}\r
+\r
+bool operator != (const ivec4 v, const ivec4 u) {\r
+       return v.x != u.x || v.y != u.y || v.z != u.z || v.w != u.w;\r
+}\r
+\r
+bool operator != (const bvec2 v, const bvec2 u) {\r
+       return v.x != u.x || v.y != u.y;\r
+}\r
+\r
+bool operator != (const bvec3 v, const bvec3 u) {\r
+       return v.x != u.x || v.y != u.y || v.z != u.z;\r
+}\r
+\r
+bool operator != (const bvec4 v, const bvec4 u) {\r
+       return v.x != u.x || v.y != u.y || v.z != u.z || v.w != u.w;\r
+}\r
+\r
+bool operator != (const mat2 m, const mat2 n) {\r
+       return m[0] != n[0] || m[1] != n[1];\r
+}\r
+\r
+bool operator != (const mat3 m, const mat3 n) {\r
+       return m[0] != n[0] || m[1] != n[1] || m[2] != n[2];\r
+}\r
+\r
+bool operator != (const mat4 m, const mat4 n) {\r
+       return m[0] != n[0] || m[1] != n[1] || m[2] != n[2] || m[3] != n[3];\r
+}\r
+\r
+// \r
+// \95 The logical binary operators and (&&), or ( | | ), and exclusive or (^^). They operate only\r
+//   on two Boolean expressions and result in a Boolean expression. And (&&) will only\r
+//   evaluate the right hand operand if the left hand operand evaluated to true. Or ( | | ) will\r
+//   only evaluate the right hand operand if the left hand operand evaluated to false. Exclusive or\r
+//   (^^) will always evaluate both operands.\r
+// \r
+\r
+bool operator ^^ (const bool a, const bool b) {\r
+    return a != b;\r
+}\r
+\r
+// \r
+// [These operators are handled internally by the compiler:]\r
+// \r
+// bool operator && (bool a, bool b) {\r
+//     return a ? b : false;\r
+// }\r
+// bool operator || (bool a, bool b) {\r
+//     return a ? true : b;\r
+// }\r
+// \r
+\r
+// \r
+// \95 The logical unary operator not (!). It operates only on a Boolean expression and results in a\r
+//   Boolean expression. To operate on a vector, use the built-in function not.\r
+// \r
+\r
+bool operator ! (const bool a) {\r
+    return a == false;\r
+}\r
+\r