From: Eric Anholt Date: Wed, 19 May 2010 21:01:33 +0000 (-0700) Subject: builtins: Add support for reflect(). X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5b9ac87941a11c72a220ba14c25cf0f8bc5acffa;p=mesa.git builtins: Add support for reflect(). Fixes glsl-orangebook-ch06.frag parsing. --- diff --git a/builtin_function.cpp b/builtin_function.cpp index 4203502e45b..5bb0007e6da 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -1329,6 +1329,67 @@ static const char *builtins_110_radians = { "))\n" }; +static const char *builtins_110_reflect = { + "((function reflect\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float i)\n" + " (declare (in) float n))\n" + " ((return (expression float -\n" + " (var_ref i)\n" + " (expression float *\n" + " (constant float (2.0))\n" + " (expression float *\n" + " (expression float dot\n" + " (var_ref n)\n" + " (var_ref i))\n" + " (var_ref n)))))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 i)\n" + " (declare (in) vec2 n))\n" + " ((return (expression vec2 -\n" + " (var_ref i)\n" + " (expression vec2 *\n" + " (constant float (2.0))\n" + " (expression vec2 *\n" + " (expression float dot\n" + " (var_ref n)\n" + " (var_ref i))\n" + " (var_ref n)))))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 i)\n" + " (declare (in) vec3 n))\n" + " ((return (expression vec3 -\n" + " (var_ref i)\n" + " (expression vec3 *\n" + " (constant float (2.0))\n" + " (expression vec3 *\n" + " (expression float dot\n" + " (var_ref n)\n" + " (var_ref i))\n" + " (var_ref n)))))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 i)\n" + " (declare (in) vec4 n))\n" + " ((return (expression vec4 -\n" + " (var_ref i)\n" + " (expression vec4 *\n" + " (constant float (2.0))\n" + " (expression vec4 *\n" + " (expression float dot\n" + " (var_ref n)\n" + " (var_ref i))\n" + " (var_ref n)))))))\n" + "\n" + "))\n" +}; + static const char *builtins_110_sign = { "((function sign\n" " (signature float\n" @@ -1770,6 +1831,7 @@ static const char *functions_for_110 [] = { builtins_110_notEqual, builtins_110_pow, builtins_110_radians, + builtins_110_reflect, builtins_110_sign, builtins_110_sin, builtins_110_smoothstep, diff --git a/builtins/110/reflect b/builtins/110/reflect new file mode 100644 index 00000000000..8238fdc93fd --- /dev/null +++ b/builtins/110/reflect @@ -0,0 +1,58 @@ +((function reflect + (signature float + (parameters + (declare (in) float i) + (declare (in) float n)) + ((return (expression float - + (var_ref i) + (expression float * + (constant float (2.0)) + (expression float * + (expression float dot + (var_ref n) + (var_ref i)) + (var_ref n))))))) + + (signature vec2 + (parameters + (declare (in) vec2 i) + (declare (in) vec2 n)) + ((return (expression vec2 - + (var_ref i) + (expression vec2 * + (constant float (2.0)) + (expression vec2 * + (expression float dot + (var_ref n) + (var_ref i)) + (var_ref n))))))) + + (signature vec3 + (parameters + (declare (in) vec3 i) + (declare (in) vec3 n)) + ((return (expression vec3 - + (var_ref i) + (expression vec3 * + (constant float (2.0)) + (expression vec3 * + (expression float dot + (var_ref n) + (var_ref i)) + (var_ref n))))))) + + (signature vec4 + (parameters + (declare (in) vec4 i) + (declare (in) vec4 n)) + ((return (expression vec4 - + (var_ref i) + (expression vec4 * + (constant float (2.0)) + (expression vec4 * + (expression float dot + (var_ref n) + (var_ref i)) + (var_ref n))))))) + +))