Commit Graph

84 Commits

Author SHA1 Message Date
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
Eric Anholt
021222c6a8 ir_to_mesa: Add convenience function for opcodes with no src/dst reg.
Most of flow control is like this.
2010-07-13 12:24:39 -07:00
Eric Anholt
4d5da50b94 ir_to_mesa: Add support for variable array indexing of builtin varyings.
That is to say, gl_TexCoord[i] now works, fixing glsl-texcoord-array
on swrast.
2010-07-13 09:52:20 -07:00
Eric Anholt
f8a2b65bc9 ir_to_mesa: Add support for array dereferences on the LHS of assignments.
The big change is to delay address reg setup until the instruction
that needs the deref.  It was hard to use the deref chain support for
the LHS because it does the copy of the dereffed value to a temporary
(to avoid problems when two src regs are array derefs), so we wouldn't
haev a pointer to actual storage in the end.

Fixes glsl-vs-arrays on swrast.
2010-07-13 09:52:20 -07:00
Eric Anholt
4ca07882af ir_to_mesa: Rely on ir_mat_op_to_vec for matrix multiplication support. 2010-07-12 19:50:49 -07:00
Eric Anholt
3f08989267 ir_to_mesa: Emit OPCODE_MAD when we find an ADD of a MUL.
Bug #27914.
2010-07-12 19:50:49 -07:00
Eric Anholt
8258a6a2c3 ir_to_mesa: Add support for dereferencing matrices from arrays. 2010-07-12 16:07:02 -07:00
Ian Romanick
3fb878722e linker: Stub-out intrastage linker 2010-07-12 15:19:30 -07:00
Eric Anholt
7b48843ecd Revert "ir_to_mesa: Add support for adding/subtracting matrices."
This reverts commit b4d0c0e0ee.
Now that ir_mat_op_to_vec is landed, this change is no longer needed.
2010-07-12 13:26:49 -07:00
Eric Anholt
6d8a0a0aad glsl2: Add a new pass at the IR level to break down matrix ops to vector ops.
This will be used by the Mesa IR and likely most HW backends, as it
allows other optimizations to occur that might not otherwise.

Fixes glsl-vs-mat-sub-1, glsl-vs-mat-div-1.
2010-07-12 13:26:46 -07:00
Kenneth Graunke
dfd30ca6a9 glsl2: Remove generate_temporary and global temporary counter.
Most places in the code simply use a static name, which works because
names are never used to look up an ir_variable.  generate_temporary is
simply unnecessary (and looks like it would leak memory, and isn't
thread safe...)
2010-07-08 15:44:19 -07:00
Eric Anholt
ea2a03f0a5 ir_to_mesa: Fix the assertion on LHS array derefs to DWIM.
This allows array derefs of matrices now, which makes idr's GLSL demo
happy.
2010-07-07 17:59:50 -07:00
Eric Anholt
ffd24b0a68 ir_to_mesa: Add support for constant matrices (untested). 2010-07-07 17:49:05 -07:00
Eric Anholt
b4d0c0e0ee ir_to_mesa: Add support for adding/subtracting matrices.
This isn't really tested, but didn't break normal vector add/sub.
2010-07-07 17:27:06 -07:00
Eric Anholt
69676fc6a3 ir_to_mesa: Don't assert that we can't assign matrices. It should work now. 2010-07-07 17:27:04 -07:00
Eric Anholt
9968f1b23c ir_to_mesa: Only allocate a vector per column of a matrix. 2010-07-07 16:37:48 -07:00
Eric Anholt
7d8091f7cc ir_to_mesa: Add support for assignment of aggregates. 2010-07-07 16:37:48 -07:00
Eric Anholt
9b68b88e43 ir_to_mesa: Add support for matrix * matrix. 2010-07-07 16:37:48 -07:00
Eric Anholt
76101f7c04 ir_to_mesa: Add support for gl_TextureMatrix access.
Fixes glsl-vs-texturematrix-1, and glsl-vs-texturematrix-2 on swrast.
2010-07-07 11:51:36 -07:00
Eric Anholt
8bb15c1ed5 ir_to_mesa: Fill in some uninitialized fields that sometimes contained junk. 2010-07-07 11:39:21 -07:00
Eric Anholt
d674ebcee0 glsl2: Add a pass to simplify if statements returning from both sides.
This allows function inlining making the following tests work even
without function calls implemented:
glsl-fs-functions-2
glsl-fs-functions-3
glsl-vs-functions
glsl-vs-functions-2
glsl-vs-functions-3
glsl-vs-vec4-indexing-5

(Note that those tests were designed to trigger actual function calls,
and this defeats them.  However, those testcases ended up catching the
bug in the previous commit.)
2010-07-07 09:10:48 -07:00
Eric Anholt
a36334be02 glsl2: Add pass for supporting variable vector indexing in rvalues.
The Mesa IR needs this to support vector indexing correctly, and
hardware backends such as 915 would want this behavior as well.

Fixes glsl-vs-vec4-indexing-2.
2010-07-06 18:49:24 -07:00
Eric Anholt
2d1789e667 ir_to_mesa: Add support for conditional moves.
Nothing generates conditional moves yet.
2010-07-06 18:49:24 -07:00
Eric Anholt
a0b3b93029 ir_to_mesa: Use the compiler-assigned locations for builtin attrs/varyings.
The previous table didn't distinguish gl_Color for the VS and FS, so
we would use the FS's attribute index for the VS and read undefined.
This partially fixes glsl-routing to match its behavior on master.
2010-07-06 14:05:51 -07:00
Kenneth Graunke
e2a358348b ir_to_mesa: Fix uninitalized value. 2010-07-02 18:03:58 -07:00
Eric Anholt
b0ac07e3de ir_to_mesa: Fix up implementation of ir_unop_exp.
OPCODE_EXP is not to ir_unop_exp what OPCODE_EX2 is to ir_unop_exp2.
It's the weird VP approximation helper opcode.  Just implement it with
OPCODE_POW instead.

Fixes glsl-fs-exp.
2010-07-02 17:06:32 -07:00
Eric Anholt
8f25d198e5 ir_to_mesa: Add support for scalar * mat, vec * mat.
This is not tested by piglit currently.
2010-07-02 17:06:08 -07:00
Eric Anholt
b61f4241f3 ir_to_mesa: Add support for shadow comparison to texture instructions.
piglit lacks tests for this currently.
2010-07-02 17:06:06 -07:00
Eric Anholt
d3983ca032 ir_to_mesa: Move projection handling out of ir_tex so txb and txl get it.
Fixes:
glsl-fs-texture2dproj-bias
glsl-fs-texture2dproj-bias-2
2010-07-02 17:06:05 -07:00
Eric Anholt
de75dfac4e ir_to_mesa: Add support for projected non-shadow/bias/lod texturing.
Fixes:
glsl-fs-texture2dproj
glsl-fs-texture2dproj-2
2010-07-02 14:50:02 -07:00
Eric Anholt
cab95c228b ir_to_mesa: Fix sparse swizzling of src regs when a writemask is present.
Fixes glsl-fs-texture2d-masked.
2010-07-02 14:08:20 -07:00
Eric Anholt
28faa12dc2 ir_to_mesa: Don't forget to run the Mesa IR optimization passes.
With how we generate assignments, the trivial copy propagation in it
is really important, and some drivers will really want the register
allocation, too.
2010-07-02 11:38:02 -07:00
Eric Anholt
9a0e421983 glsl2: Add a pass to break ir_binop_div to _mul and _rcp.
This results in constant folding of a constant divisor.
2010-07-02 11:27:06 -07:00
Ian Romanick
667f4e1940 glsl2: Conditionally allow optional extensions to be enabled
The only optional extension currently supported by the compiler is
GL_EXT_texture_array.
2010-07-01 20:40:08 -07:00
Ian Romanick
06143ea094 glsl2: Conditionally define preprocessor tokens for optional extensions
The only optional extension currently supported by the compiler is
GL_EXT_texture_array.
2010-07-01 20:40:08 -07:00
Ian Romanick
127308b4be glsl2: Add gl_MaxTextureCoords 2010-07-01 13:30:50 -07:00
Eric Anholt
411fb36b7c ir_to_mesa: Fill in remaining ops, remove default case for expression types.
We should now have support for all the expression types we need for
GLSL 1.20.
2010-07-01 11:24:38 -07:00
Eric Anholt
8761fcc2bf ir_to_mesa: Add support for ir_unop_rcp.
This isn't used at the moment, but will be soon.
2010-07-01 11:23:02 -07:00
Eric Anholt
8a1f186cc5 glsl2: Add a pass to convert mod(a, b) to b * fract(a/b).
This is used by the Mesa IR backend to implement mod, fixing glsl-fs-mod.
2010-07-01 11:07:23 -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
5e4dd061d1 ir_to_mesa: Add support for discard instructions.
Fixes glsl-fs-discard-01.
2010-06-30 17:31:06 -07:00
Eric Anholt
3acd92a91f ir_to_mesa: Add support for ir_unop_sign.
Fixes glsl-fs-sign, glsl-vs-sign.
2010-06-30 17:29:12 -07:00
Eric Anholt
d6ebe9b16b ir_to_mesa: Add missing no-op type conversions.
Fixes glsl-fs-step.
2010-06-30 16:23:32 -07:00
Eric Anholt
e64a4aaacb ir_to_mesa: Note which of our expr ops are unsupported 1.30 features. 2010-06-30 16:18:06 -07:00
Eric Anholt
285ff93819 ir_to_mesa: Initialize the (we never use it) abs field of Mesa src regs. 2010-06-30 15:49:04 -07:00
Eric Anholt
ea6b34cce4 ir_to_mesa: Send the negate field on to Mesa IR.
Fixes glsl-fs-neg.
2010-06-30 15:47:11 -07:00
Eric Anholt
698b844443 ir_to_mesa: When generating a swizzle, respect the reg's current swizzle.
Fixes depth-tex-modes-glsl.
2010-06-30 15:30:00 -07:00
Kenneth Graunke
16efab1c4d glsl2: Define new ir_discard instruction. 2010-06-30 14:54:58 -07:00
Eric Anholt
88c20c46b8 ir_to_mesa: Support gl_FragDepth.
Fixes glsl-bug-22603.
2010-06-30 14:55:45 -07:00
Eric Anholt
c64da87611 ir_to_mesa: Fix the indexing of attributes in the program's Attributes.
This fixes GetAttribLocation returning VERT_ATTRIB_GENERIC1 instead of 1,
caught by glsl-dlist-getattriblocation.
2010-06-30 14:44:14 -07:00