Commit graph

53 commits

Author SHA1 Message Date
Kenneth Graunke
6c4a83ca3e Refresh autogenerated file builtin_function.cpp. 2010-11-03 13:39:41 -07:00
Kenneth Graunke
3f5fde5c45 Refresh autogenerated file builtin_function.cpp.
Since this is just generated by python, it's questionable whether this
should continue to live in the repository - Mesa already has other
things generated from python as part of the build process.
2010-10-21 11:46:08 -07:00
Kenneth Graunke
cc04347b8d glsl: Refresh autogenerated file builtin_function.cpp. 2010-10-21 00:14:38 -07:00
Kenneth Graunke
2bc704d543 glsl: Refresh autogenerated file builtin_function.cpp. 2010-10-14 15:59:47 -07:00
Kenneth Graunke
f9bd4c6c26 glsl: Refresh autogenerated file builtin_function.cpp. 2010-10-14 12:40:16 -07:00
Kristian Høgsberg
f9995b3075 Drop GLcontext typedef and use struct gl_context instead 2010-10-13 09:43:25 -04:00
Eric Anholt
b39e6f33b6 glsl: Rework assignments with write_masks to have LHS chan count match RHS.
It turns out that most people new to this IR are surprised when an
assignment to (say) 3 components on the LHS takes 4 components on the
RHS.  It also makes for quite strange IR output:

(assign (constant bool (1)) (x) (var_ref color) (swiz x (var_ref v) ))
(assign (constant bool (1)) (y) (var_ref color) (swiz yy (var_ref v) ))
(assign (constant bool (1)) (z) (var_ref color) (swiz zzz (var_ref v) ))

But even worse, even we get it wrong, as shown by this line of our
current step(float, vec4):

(assign (constant bool (1)) (w)
	(var_ref t)
	(expression float b2f (expression bool >=
		    (swiz w (var_ref x))(var_ref edge))))

where we try to assign a float to the writemasked-out x channel and
don't supply anything for the actual w channel we're writing.  Drivers
right now just get lucky since ir_to_mesa spams the float value across
all the source channels of a vec4.

Instead, the RHS will now have a number of components equal to the
number of components actually being written.  Hopefully this confuses
everyone less, and it also makes codegen for a scalar target simpler.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2010-09-22 13:09:51 -07:00
Kenneth Graunke
dbd2480507 glsl/builtins: Switch comparison functions to just return an expression. 2010-09-18 16:23:48 +02:00
Kenneth Graunke
52f9156e88 glsl/builtins: Fix equal and notEqual builtins.
Commit 309cd4115b incorrectly converted
these to all_equal and any_nequal, which is the wrong operation.
2010-09-18 16:23:48 +02:00
Ian Romanick
309cd4115b glsl2: Port equal() and notEqual() to ir_unop_all_equal and ir_unop_any_nequal 2010-09-13 17:53:32 -07:00
Ian Romanick
1f3c7d968c glsl2: Implement noise[1234] built-in functions using ir_unop_noise 2010-09-09 15:39:52 -07:00
Kenneth Graunke
6dcca5a308 glsl/builtins: normalize of a negative scalar should be -1.0. 2010-09-09 15:23:12 -07:00
Kenneth Graunke
7fc882643c glsl/builtins: Set the API in the fake context.
Otherwise it gets used uninitialized.
2010-09-08 17:38:42 -07:00
Ian Romanick
f69a6647fb glsl2: Clear out profile pointers in _mesa_glsl_release_functions
Otherwise builtin_profiles contains dangling pointers the next time
_mesa_read_profile is called.  I suspect this may fix bugzilla #29847,
but I was never able to reproduce it.
2010-09-08 17:16:49 -07:00
Kenneth Graunke
fc1daab2a2 glsl: Fix for scalar float built-in definitions.
These need abs, and we need more tests.
2010-09-08 15:38:09 -07:00
Eric Anholt
c3db43df04 glsl: regenerate builtins 2010-09-08 15:01:02 -07:00
Kenneth Graunke
4b2ffa0a42 glsl: Refresh automatically generated file builtin_function.cpp. 2010-09-08 12:09:42 -07:00
Ian Romanick
961f42c9bd glsl2: Make sure _mesa_glsl_parse_state constructor gets a context
Fix an major regression in dc754586.  Too bad that change was
obviously never tested.
2010-09-08 11:34:22 -07:00
Kenneth Graunke
116dc670e9 glsl: Add built-in function profiles for GLSL ES 1.00. 2010-09-07 17:30:38 -07:00
Kenneth Graunke
a878107d6c glsl: Regenerate autogenerated file builtin_function.cpp. 2010-09-04 02:19:37 -07:00
Kenneth Graunke
0181385f36 glsl: Add forgotten implementations of equal/notEqual on bvecs. 2010-09-01 11:50:23 -07:00
Brian Paul
16c733495d glsl2: fix bug in atan(y, x) function
When x==0, the result was wrong.  Fixes piglit glsl-fs-atan-1.shader_test
2010-08-31 19:15:07 -06:00
Eric Anholt
8b3d36d563 glsl: Clear the static values of builtin function profiles at release.
When releasing the builtin functions, we were just freeing the memory,
not telling the builtin function loader that we had freed its memory.
I wish I had done ARB_ES2_compatibility so we had regression testing
of this path.  Fixes segfault on changing video options in nexuiz.
2010-08-30 13:12:24 -07:00
Eric Anholt
681492cbe2 glsl: Regenerate for double destroy fix. 2010-08-27 15:25:06 -07:00
Kenneth Graunke
e9c7ceed27 glsl: Use a single shared namespace in the symbol table.
As of 1.20, variable names, function names, and structure type names all
share a single namespace, and should conflict with one another in the
same scope, or hide each other in nested scopes.

However, in 1.10, variables and functions can share the same name in the
same scope.  Structure types, however, conflict with/hide both.

Fixes piglit tests redeclaration-06.vert, redeclaration-11.vert,
redeclaration-19.vert, and struct-05.vert.
2010-08-26 09:19:48 -07:00
Chia-I Wu
bfd7c9ac22 glsl: Include main/core.h.
Make glsl include only main/core.h from core mesa.
2010-08-24 11:27:29 +08:00
Eric Anholt
b75645d8ad glsl: Rebuild builtins for any() change. 2010-08-23 13:06:02 -07:00
Eric Anholt
47003a8f65 glsl: Regenerate builtins with the new sorting. 2010-08-23 12:58:07 -07:00
Kenneth Graunke
cf37ba3430 glsl: Refresh autogenerated file builtin_function.cpp. 2010-08-18 13:20:58 -07:00
Kenneth Graunke
a57b1e579d glsl2: Regenerate builtin_function.cpp. 2010-08-17 23:50:40 -07:00
Kenneth Graunke
a433cd286c glsl2: Refresh autogenerated file builtin_function.cpp. 2010-08-16 15:18:44 -07:00
Kenneth Graunke
43ff8f1a4b glsl2: Rework builtin function generation.
Each language version/extension and target now has a "profile" containing
all of the available builtin function prototypes.  These are written in
GLSL, and come directly out of the GLSL spec (except for expanding genType).

A new builtins/ir/ folder contains the hand-written IR for each builtin,
regardless of what version includes it.  Only those definitions that have
prototypes in the profile will be included.

The autogenerated IR for texture builtins is no longer written to disk,
so there's no longer any confusion as to what's hand-written or
generated.

All scripts are now in python instead of perl.
2010-08-13 19:09:36 -07:00
Ian Romanick
261bbc011d glsl2: Use Elements from main/compiler.h instead of open-coding 2010-08-12 15:05:39 -07:00
Kenneth Graunke
8aa7dbacaf glsl2: Refresh autogenerated file builtin_function.cpp. 2010-08-09 12:45:25 -07:00
Eric Anholt
eb7e120f0f glsl2: Fix expression type in builtin tan().
Fixes glsl-fs-tan-1.
2010-08-02 12:33:18 -07:00
Eric Anholt
3fa1b85196 glsl2: Fix the implementation of atan(y, x).
So many problems here.  One is that we can't do the quadrant handling
for all the channels at the same time, so we call the float(y, x)
version multiple times.  I'd also left out the x == 0 handling.  Also,
the quadrant handling was broken for y == 0, so there was a funny
discontinuity on the +x side if you plugged in obvious values to test.

I generated the atan(float y, float x) code from a short segment of
GLSL and pasted it in by hand.  It would be nice to automate that
somehow.

Fixes:
glsl-fs-atan-1
glsl-fs-atan-2
2010-07-30 15:19:00 -07:00
Kenneth Graunke
56af4e56e3 glsl2: Fix outerProduct builtin.
The type signatures were completely backwards.
2010-07-28 15:46:29 -07:00
Kenneth Graunke
0a71527dab glsl2: Refresh autogenerated file builtin_function.cpp. 2010-07-22 16:54:20 -07:00
Eric Anholt
e65dfa89ee glsl2: Fix the type of (1.0 - arg2) for mix(gen, gen, float).
Previously, we'd constant-fold up a value of vec4(1.0 - arg2, 0, 0, 0).

Fixes:
glsl1-mix(vec4) function
2010-07-22 14:25:26 -07:00
Ian Romanick
d5be2acae3 linker: Link built-in functions instead of including them in every shader
This is an invasive set of changes.  Each user shader tracks a set of other
shaders that contain built-in functions.  During compilation, function
prototypes are imported from these shaders.  During linking, the
shaders are linked with these built-in-function shaders just like with
any other shader.
2010-07-21 15:52:58 -07:00
Eric Anholt
1245babe0c glsl2: Fix asin() implementation.
I'd flipped around the order of two operations in paren-balancing
adventures, and left out the multiply by sign(x) required for negative x.

Fixes:
glsl1-acos(vec4) function
glsl1-asin(vec4) function
glsl1-atan(vec4) function
2010-07-20 12:24:01 -07:00
Eric Anholt
117d154b4d glsl2: notEqual() produces a boolean value, not the base type of the args.
Fixes:
glsl1-vector relational (bvec2 ==,!=)
glsl1-vector relational (vec4 !=)
2010-07-20 12:01:40 -07:00
Ian Romanick
b64e979971 glsl2: Use Elements macro 2010-07-19 14:50:43 -07:00
Eric Anholt
82d4b9593b glsl2: Fix the expression type for atan's pi * sign(y).
Fixes CorrectFunction.vert.
2010-07-19 10:47:12 -07:00
Eric Anholt
9be7f63813 glsl2: Make cross() be an expression operation.
ARB_fp, ARB_vp, Mesa IR, and the 965 vertex shader all have
instructions for cross.  Shaves 12 Mesa instructions off of a
66-instruction shader I have.
2010-07-18 18:12:12 -07:00
Kenneth Graunke
53120805a8 Refresh autogenerated file builtin_function.cpp. 2010-07-14 16:49:24 -07:00
Eric Anholt
0b74bbb3dc glsl: Fix the setup of refract()'s output for vec3/vec4 and k < 0.0.
caught by valgrind.
2010-07-07 14:55:33 -07:00
Kenneth Graunke
83035574db Refresh autogenerated file builtin_function.cpp. 2010-07-02 18:20:19 -07:00
Eric Anholt
d925c91730 glsl2: Add ir_unop_fract as an expression type.
Most backends will prefer seeing this to seeing (a - floor(a)), so
represent it explicitly.
2010-07-01 11:07:22 -07:00
Eric Anholt
f5b3b2a01a glsl2: Don't break sign() down by vector components. 2010-06-30 17:29:12 -07:00