summaryrefslogtreecommitdiffstats
path: root/src/glsl/builtins
diff options
context:
space:
mode:
Diffstat (limited to 'src/glsl/builtins')
-rw-r--r--src/glsl/builtins/ir/modf41
-rw-r--r--src/glsl/builtins/ir/round21
-rw-r--r--src/glsl/builtins/ir/roundEven21
-rw-r--r--src/glsl/builtins/ir/trunc21
-rw-r--r--src/glsl/builtins/profiles/130.frag20
-rw-r--r--src/glsl/builtins/profiles/130.vert20
-rwxr-xr-xsrc/glsl/builtins/tools/generate_builtins.py20
7 files changed, 160 insertions, 4 deletions
diff --git a/src/glsl/builtins/ir/modf b/src/glsl/builtins/ir/modf
new file mode 100644
index 00000000000..2b935a91a7c
--- /dev/null
+++ b/src/glsl/builtins/ir/modf
@@ -0,0 +1,41 @@
+((function modf
+ (signature float
+ (parameters
+ (declare (in) float x)
+ (declare (out) float i))
+ ((declare () float t)
+ (assign (constant bool (1)) (x) (var_ref t)
+ (expression float trunc (var_ref x)))
+ (assign (constant bool (1)) (x) (var_ref i) (var_ref t))
+ (return (expression float - (var_ref x) (var_ref t)))))
+
+ (signature vec2
+ (parameters
+ (declare (in) vec2 x)
+ (declare (out) vec2 i))
+ ((declare () vec2 t)
+ (assign (constant bool (1)) (xy) (var_ref t)
+ (expression vec2 trunc (var_ref x)))
+ (assign (constant bool (1)) (xy) (var_ref i) (var_ref t))
+ (return (expression vec2 - (var_ref x) (var_ref t)))))
+
+ (signature vec3
+ (parameters
+ (declare (in) vec3 x)
+ (declare (out) vec3 i))
+ ((declare () vec3 t)
+ (assign (constant bool (1)) (xyz) (var_ref t)
+ (expression vec3 trunc (var_ref x)))
+ (assign (constant bool (1)) (xyz) (var_ref i) (var_ref t))
+ (return (expression vec3 - (var_ref x) (var_ref t)))))
+
+ (signature vec4
+ (parameters
+ (declare (in) vec4 x)
+ (declare (out) vec4 i))
+ ((declare () vec4 t)
+ (assign (constant bool (1)) (xyzw) (var_ref t)
+ (expression vec4 trunc (var_ref x)))
+ (assign (constant bool (1)) (xyzw) (var_ref i) (var_ref t))
+ (return (expression vec4 - (var_ref x) (var_ref t)))))
+))
diff --git a/src/glsl/builtins/ir/round b/src/glsl/builtins/ir/round
new file mode 100644
index 00000000000..d0d425bd656
--- /dev/null
+++ b/src/glsl/builtins/ir/round
@@ -0,0 +1,21 @@
+((function round
+ (signature float
+ (parameters
+ (declare (in) float arg0))
+ ((return (expression float round_even (var_ref arg0)))))
+
+ (signature vec2
+ (parameters
+ (declare (in) vec2 arg0))
+ ((return (expression vec2 round_even (var_ref arg0)))))
+
+ (signature vec3
+ (parameters
+ (declare (in) vec3 arg0))
+ ((return (expression vec3 round_even (var_ref arg0)))))
+
+ (signature vec4
+ (parameters
+ (declare (in) vec4 arg0))
+ ((return (expression vec4 round_even (var_ref arg0)))))
+))
diff --git a/src/glsl/builtins/ir/roundEven b/src/glsl/builtins/ir/roundEven
new file mode 100644
index 00000000000..a9c99b6f44c
--- /dev/null
+++ b/src/glsl/builtins/ir/roundEven
@@ -0,0 +1,21 @@
+((function roundEven
+ (signature float
+ (parameters
+ (declare (in) float arg0))
+ ((return (expression float round_even (var_ref arg0)))))
+
+ (signature vec2
+ (parameters
+ (declare (in) vec2 arg0))
+ ((return (expression vec2 round_even (var_ref arg0)))))
+
+ (signature vec3
+ (parameters
+ (declare (in) vec3 arg0))
+ ((return (expression vec3 round_even (var_ref arg0)))))
+
+ (signature vec4
+ (parameters
+ (declare (in) vec4 arg0))
+ ((return (expression vec4 round_even (var_ref arg0)))))
+))
diff --git a/src/glsl/builtins/ir/trunc b/src/glsl/builtins/ir/trunc
new file mode 100644
index 00000000000..d320a2a7722
--- /dev/null
+++ b/src/glsl/builtins/ir/trunc
@@ -0,0 +1,21 @@
+((function trunc
+ (signature float
+ (parameters
+ (declare (in) float arg0))
+ ((return (expression float trunc (var_ref arg0)))))
+
+ (signature vec2
+ (parameters
+ (declare (in) vec2 arg0))
+ ((return (expression vec2 trunc (var_ref arg0)))))
+
+ (signature vec3
+ (parameters
+ (declare (in) vec3 arg0))
+ ((return (expression vec3 trunc (var_ref arg0)))))
+
+ (signature vec4
+ (parameters
+ (declare (in) vec4 arg0))
+ ((return (expression vec4 trunc (var_ref arg0)))))
+))
diff --git a/src/glsl/builtins/profiles/130.frag b/src/glsl/builtins/profiles/130.frag
index aa7a6adb1d7..0d860eb9ed4 100644
--- a/src/glsl/builtins/profiles/130.frag
+++ b/src/glsl/builtins/profiles/130.frag
@@ -143,6 +143,21 @@ vec2 floor(vec2 x);
vec3 floor(vec3 x);
vec4 floor(vec4 x);
+float trunc(float x);
+vec2 trunc(vec2 x);
+vec3 trunc(vec3 x);
+vec4 trunc(vec4 x);
+
+float round(float x);
+vec2 round(vec2 x);
+vec3 round(vec3 x);
+vec4 round(vec4 x);
+
+float roundEven(float x);
+vec2 roundEven(vec2 x);
+vec3 roundEven(vec3 x);
+vec4 roundEven(vec4 x);
+
float ceil(float x);
vec2 ceil(vec2 x);
vec3 ceil(vec3 x);
@@ -162,6 +177,11 @@ vec2 mod(vec2 x, vec2 y);
vec3 mod(vec3 x, vec3 y);
vec4 mod(vec4 x, vec4 y);
+float modf(float x, out float i);
+vec2 modf(vec2 x, out vec2 i);
+vec3 modf(vec3 x, out vec3 i);
+vec4 modf(vec4 x, out vec4 i);
+
float min(float x, float y);
vec2 min(vec2 x, vec2 y);
vec3 min(vec3 x, vec3 y);
diff --git a/src/glsl/builtins/profiles/130.vert b/src/glsl/builtins/profiles/130.vert
index d0152b03748..2fd44dce8c7 100644
--- a/src/glsl/builtins/profiles/130.vert
+++ b/src/glsl/builtins/profiles/130.vert
@@ -143,6 +143,21 @@ vec2 floor(vec2 x);
vec3 floor(vec3 x);
vec4 floor(vec4 x);
+float trunc(float x);
+vec2 trunc(vec2 x);
+vec3 trunc(vec3 x);
+vec4 trunc(vec4 x);
+
+float round(float x);
+vec2 round(vec2 x);
+vec3 round(vec3 x);
+vec4 round(vec4 x);
+
+float roundEven(float x);
+vec2 roundEven(vec2 x);
+vec3 roundEven(vec3 x);
+vec4 roundEven(vec4 x);
+
float ceil(float x);
vec2 ceil(vec2 x);
vec3 ceil(vec3 x);
@@ -162,6 +177,11 @@ vec2 mod(vec2 x, vec2 y);
vec3 mod(vec3 x, vec3 y);
vec4 mod(vec4 x, vec4 y);
+float modf(float x, out float i);
+vec2 modf(vec2 x, out vec2 i);
+vec3 modf(vec3 x, out vec3 i);
+vec4 modf(vec4 x, out vec4 i);
+
float min(float x, float y);
vec2 min(vec2 x, vec2 y);
vec3 min(vec3 x, vec3 y);
diff --git a/src/glsl/builtins/tools/generate_builtins.py b/src/glsl/builtins/tools/generate_builtins.py
index 691a318c1cb..9bde17157af 100755
--- a/src/glsl/builtins/tools/generate_builtins.py
+++ b/src/glsl/builtins/tools/generate_builtins.py
@@ -25,13 +25,25 @@ def get_builtin_definitions():
return fs
def stringify(s):
+ # Work around MSVC's 65535 byte limit by outputting an array of characters
+ # rather than actual string literals.
+ if len(s) >= 65535:
+ #t = "/* Warning: length " + repr(len(s)) + " too large */\n"
+ t = ""
+ for c in re.sub('\s\s+', ' ', s):
+ if c == '\n':
+ t += '\n'
+ else:
+ t += "'" + c + "',"
+ return '{' + t[:-1] + '}'
+
t = s.replace('\\', '\\\\').replace('"', '\\"').replace('\n', '\\n"\n "')
return ' "' + t + '"\n'
def write_function_definitions():
fs = get_builtin_definitions()
for k, v in sorted(fs.iteritems()):
- print 'static const char *builtin_' + k + ' ='
+ print 'static const char builtin_' + k + '[] ='
print stringify(v), ';'
def run_compiler(args):
@@ -64,7 +76,7 @@ def write_profile(filename, profile):
# clutter the diff output.
proto_ir = re.sub(r'@0x[0-9a-f]+', '', proto_ir);
- print 'static const char *prototypes_for_' + profile + ' ='
+ print 'static const char prototypes_for_' + profile + '[] ='
print stringify(proto_ir), ';'
# Print a table of all the functions (not signatures) referenced.
@@ -123,12 +135,12 @@ if __name__ == "__main__":
#include "ast.h"
extern "C" struct gl_shader *
-_mesa_new_shader(GLcontext *ctx, GLuint name, GLenum type);
+_mesa_new_shader(struct gl_context *ctx, GLuint name, GLenum type);
gl_shader *
read_builtins(GLenum target, const char *protos, const char **functions, unsigned count)
{
- GLcontext fakeCtx;
+ struct gl_context fakeCtx;
fakeCtx.API = API_OPENGL;
gl_shader *sh = _mesa_new_shader(NULL, 0, target);
struct _mesa_glsl_parse_state *st =