Kenneth Graunke [Fri, 25 Jun 2010 20:36:14 +0000 (13:36 -0700)]
glsl2: Create new talloc contexts the "right" way.
Kenneth Graunke [Fri, 25 Jun 2010 20:14:37 +0000 (13:14 -0700)]
glsl2: Use _mesa_glsl_parse_state as the talloc parent, not glsl_shader.
_mesa_glsl_parse_state should be the parent for all temporary allocation
done while compiling a shader. glsl_shader should only be used as the
parent for the shader's final IR---the _result_ of compilation.
Since many IR instructions may be added or discarded during optimization
passes, IR should not ever be allocated to glsl_shader directly.
Done via sed -i s/talloc_parent(state)/state/g and s/talloc_parent(st)/st/g.
This also removes a ton of talloc_parent calls, which may help performance.
Kenneth Graunke [Fri, 25 Jun 2010 21:10:01 +0000 (14:10 -0700)]
glsl2: Steal the live IR and free the rest of the junk.
Ian Romanick [Wed, 30 Jun 2010 00:58:43 +0000 (17:58 -0700)]
linker: Don't dynamically allocate slots for linked shaders
The can be at most one shader per stage. There are currently only two
stages. There is zero reason to dynamically size this array.
Eric Anholt [Wed, 30 Jun 2010 01:23:05 +0000 (18:23 -0700)]
ir_to_mesa: Tell Mesa about our choices for vertex attribute locations.
Ian Romanick [Wed, 30 Jun 2010 01:58:20 +0000 (18:58 -0700)]
linker: Don't automatically allocate VERT_ATTRIB_GENERIC0
Eric Anholt [Wed, 30 Jun 2010 18:49:17 +0000 (11:49 -0700)]
glsl2: Use Mesa's gl_shader_program instead of our own struct glsl_program.
This avoids more allocation and shuffling of data around.
Eric Anholt [Wed, 30 Jun 2010 18:51:54 +0000 (11:51 -0700)]
glsl2: Make function names and variable names be children of the node.
This avoids losing their memory when the parser state is freed.
Eric Anholt [Wed, 30 Jun 2010 18:05:43 +0000 (11:05 -0700)]
glsl2: Move our data from a glsl_shader* on the side to the main gl_shader *.
This saves recompiling at link time. gl_shader->ir is made a pointer
so that we don't have to bring exec_list into mtypes.h.
Eric Anholt [Tue, 29 Jun 2010 23:39:38 +0000 (16:39 -0700)]
ir_to_mesa: Add support for ir_unop_abs.
Eric Anholt [Tue, 29 Jun 2010 23:36:42 +0000 (16:36 -0700)]
ir_to_mesa: Add support for dFdx, dFdy.
Eric Anholt [Tue, 29 Jun 2010 21:16:11 +0000 (14:16 -0700)]
ir_to_mesa: Start adding support for texture instructions.
Fixes:
glsl-fs-bug25902
glsl-fs-sampler-numbering
glsl-lod-bias
Kenneth Graunke [Tue, 29 Jun 2010 22:59:27 +0000 (15:59 -0700)]
glsl2: Keep the same number of components in implicit conversions.
Fixes piglit test glsl-implicit-conversion-01.
Ian Romanick [Tue, 29 Jun 2010 22:29:56 +0000 (15:29 -0700)]
glsl2: Make gl_MaxDrawBuffers available in the vertex shader
Ian Romanick [Tue, 29 Jun 2010 22:19:11 +0000 (15:19 -0700)]
glsl2: Make gl_MaxDrawBuffers available in the fragment shader
Ian Romanick [Tue, 29 Jun 2010 22:10:09 +0000 (15:10 -0700)]
glsl2: Make gl_FragData be available in GLSL 1.10 too
Ian Romanick [Tue, 29 Jun 2010 21:21:05 +0000 (14:21 -0700)]
glsl2: Pass MaxDrawBuffers from core Mesa into the GLSL compiler
Ian Romanick [Mon, 28 Jun 2010 20:17:18 +0000 (13:17 -0700)]
glsl_type: Add _mesa_glsl_release_types to release all type related storage
Ian Romanick [Mon, 28 Jun 2010 19:19:52 +0000 (12:19 -0700)]
glsl_type: All glsl_type objects live in their own talloc context
Ian Romanick [Mon, 28 Jun 2010 18:57:38 +0000 (11:57 -0700)]
glsl_type: Record type constructors are private
Ian Romanick [Mon, 28 Jun 2010 18:54:57 +0000 (11:54 -0700)]
glsl_type: Add get_record_instance method
Ian Romanick [Mon, 28 Jun 2010 18:09:40 +0000 (11:09 -0700)]
glsl_type: Vector, matrix, and sampler type constructors are private
Ian Romanick [Mon, 28 Jun 2010 18:01:57 +0000 (11:01 -0700)]
glsl_type: Make all static objects be class private
Ian Romanick [Mon, 28 Jun 2010 20:22:55 +0000 (13:22 -0700)]
glsl2: Use talloc_strdup when generating constructor temporary names
Ian Romanick [Sat, 26 Jun 2010 00:58:16 +0000 (17:58 -0700)]
glsl_type: Remove vector and matrix constructor generators
All scalar, vector, and matrix constructors are generated in-line
during AST-to-HIR translation. There is no longer any need to
generate function versions of the constructors.
Ian Romanick [Sat, 26 Jun 2010 00:36:17 +0000 (17:36 -0700)]
glsl2: Don't flatten constructor parameters to scalars
Now that all scalar, vector, and matrix constructors are emitted
in-line, the parameters to these constructors should not be flattened
to a pile of scalars. Instead, the functions that emit the in-line
constructor bodies can directly write the parameters to the correct
locations in the objects being constructed.
Ian Romanick [Fri, 25 Jun 2010 23:10:43 +0000 (16:10 -0700)]
glsl2: Always emit matrix constructors inline
Ian Romanick [Wed, 23 Jun 2010 22:19:40 +0000 (15:19 -0700)]
glsl2: Always emit vector constructors inline
Ian Romanick [Fri, 25 Jun 2010 22:25:27 +0000 (15:25 -0700)]
ir_swizzle: Add new constructor, refactor constructors
Adds a new constructor that takes an array of component values. Refactors
the meat of the two constructors to an init_mask method.
Kenneth Graunke [Tue, 29 Jun 2010 17:02:01 +0000 (10:02 -0700)]
glsl2: Update TODO.
Kenneth Graunke [Tue, 29 Jun 2010 16:59:40 +0000 (09:59 -0700)]
glsl2: Check for non-void functions that don't have a return statement.
This doesn't do any control flow analysis to ensure that the return
statements are actually reached.
Fixes piglit tests function5.frag and function-07.vert.
Kenneth Graunke [Tue, 29 Jun 2010 07:48:10 +0000 (00:48 -0700)]
glsl2: Reject return types with qualifiers.
Fixes piglit test return-qualifier.frag.
Kenneth Graunke [Tue, 29 Jun 2010 07:47:44 +0000 (00:47 -0700)]
glsl2: Add a method for querying if an AST type has any qualifiers.
Kenneth Graunke [Tue, 29 Jun 2010 06:38:04 +0000 (23:38 -0700)]
glsl2: Check that returned expressions match the function return type.
From my reading of the specification, implicit conversions are not
allowed. ATI seems to agree, though nVidia allows it without warning.
Ian Romanick [Tue, 29 Jun 2010 17:02:36 +0000 (10:02 -0700)]
glsl2: Invoke preprocessor before calling the compiler proper
Eric Anholt [Mon, 28 Jun 2010 22:02:51 +0000 (15:02 -0700)]
ir_to_mesa: Actually initialize the undef register for scalar_op1.
Fixes glsl-sin, glsl-cos on 965, where we rely on unused src arguments
in the VS having a file of PROGRAM_UNDEFINED.
Eric Anholt [Mon, 28 Jun 2010 21:47:43 +0000 (14:47 -0700)]
ir_to_mesa: Support user-defined varyings using the linker's locations.
Fixes glsl-reload-source.
Eric Anholt [Mon, 28 Jun 2010 20:45:43 +0000 (13:45 -0700)]
ir_to_mesa: Actually add the header file for the interface.
Eric Anholt [Mon, 28 Jun 2010 20:01:49 +0000 (13:01 -0700)]
ir_to_mesa: Fix binop_sqrt for multi-channel and negative source channels.
Fixes glsl-fs-sqrt-branch.
Eric Anholt [Mon, 28 Jun 2010 19:48:47 +0000 (12:48 -0700)]
ir_to_mesa: Fix indexes of temps used in expressions.
It looks like I managed to horribly mangle this in some rebase of the
branch. Fixes:
glsl-fs-fragcoord
glsl-fs-mix
Eric Anholt [Mon, 28 Jun 2010 19:35:54 +0000 (12:35 -0700)]
ir_to_mesa: Notify the driver when we generate new Mesa programs for GLSL.
Fixes glsl-fs-if-*.
Eric Anholt [Mon, 28 Jun 2010 19:26:19 +0000 (12:26 -0700)]
ir_to_mesa: Add support for the pow expression.
Fixes glsl-algebraic-pow-two.
Eric Anholt [Mon, 28 Jun 2010 19:16:03 +0000 (12:16 -0700)]
ir_to_mesa: Fix EmitCondCodes for boolean vars as condition.
Fixes glsl-vs-if-bool.
Eric Anholt [Mon, 28 Jun 2010 18:59:13 +0000 (11:59 -0700)]
ir_to_mesa: Respect EmitCondCodes for IF statements.
Fixes glsl-vs-if-* for the 965 driver.
Eric Anholt [Mon, 28 Jun 2010 18:44:30 +0000 (11:44 -0700)]
ir_to_mesa: Traverse the "else" instrs after "else", instead of "then" again.
Eric Anholt [Tue, 29 Jun 2010 02:56:53 +0000 (19:56 -0700)]
ir_to_mesa: Fix matrix * scalar multiplication.
We're accessing in terms of columns, so we need to do MUL/MAD/MAD/MAD
instead of DP4s.
Fixes:
glsl-fs-exp2
glsl-fs-log2
glsl-fs-mix-constant
glsl-fs-sqrt-zero
glsl-vs-sqrt-zero
Eric Anholt [Mon, 28 Jun 2010 04:07:21 +0000 (21:07 -0700)]
ir_to_mesa: Check the right element for matrix * scalar multiplication.
Eric Anholt [Mon, 28 Jun 2010 03:36:41 +0000 (20:36 -0700)]
glsl2: Add support for some builtin matrices.
Eric Anholt [Mon, 28 Jun 2010 03:43:09 +0000 (20:43 -0700)]
ir_to_mesa: Fix copy and wasted InputsRead/OutputsWritten setup.
Kenneth Graunke [Fri, 25 Jun 2010 20:44:09 +0000 (13:44 -0700)]
Use a more sensible context in copy propagation.
Kenneth Graunke [Fri, 25 Jun 2010 20:36:14 +0000 (13:36 -0700)]
Use more sensible contexts in ir_dead_code_local.
Ian Romanick [Fri, 25 Jun 2010 22:27:47 +0000 (15:27 -0700)]
glsl2: Add option to stand-alone GLSL compiler to dump IR before optimizations
Ian Romanick [Fri, 25 Jun 2010 23:19:45 +0000 (16:19 -0700)]
glsl2: Use i2b and f2b IR opcodes for casting int or float to bool
Eric Anholt [Sat, 26 Jun 2010 00:50:25 +0000 (17:50 -0700)]
glsl2: Add support for non-float constants in Mesa IR.
Fixes glsl-vs-vec4-indexing-4.
Eric Anholt [Sat, 26 Jun 2010 00:23:31 +0000 (17:23 -0700)]
glsl2: Take out the spamming of debug flags I'd added.
Eric Anholt [Sat, 26 Jun 2010 00:20:46 +0000 (17:20 -0700)]
glsl2: Don't clear swizzles for Mesa IR constants after fetching them.
Missed this while hacking in constants support. Fixes:
glsl-algebraic-mul-*
glsl-algebraic-rcp-*
glsl-vs-swizzle-swizzle-lhs
glsl-vs-vec4-indexing-6
Kenneth Graunke [Fri, 25 Jun 2010 20:10:37 +0000 (13:10 -0700)]
ir_reader: Free memory for S-Expressions earlier.
There's no point in keeping it around once we've read the IR.
Also, remove an unnecessary talloc_parent call.
Eric Anholt [Fri, 25 Jun 2010 21:35:48 +0000 (14:35 -0700)]
glsl2: Start trying to hook up uniforms.
This should be resolved with linker.cpp's location assignment, as
currently we drop that location assignment on the ground. However,
this gets basic programs using uniforms working for now.
Eric Anholt [Fri, 25 Jun 2010 21:27:07 +0000 (14:27 -0700)]
glsl2: Associate the GLenum for the type with builtin GLSL types.
Eric Anholt [Fri, 25 Jun 2010 20:38:38 +0000 (13:38 -0700)]
glsl2: Use the parser state as the talloc context for dead code elimination.
This cuts runtime by around 20% from talloc_parent() lookups.
Eric Anholt [Fri, 25 Jun 2010 20:00:38 +0000 (13:00 -0700)]
glsl2: Emit OPCODE_END at the end of the Mesa program.
The 965 driver can now run a glsl2-generated shader!
Eric Anholt [Fri, 25 Jun 2010 19:59:10 +0000 (12:59 -0700)]
glsl2: Hook up constant parameters in ir_to_mesa.
Eric Anholt [Fri, 25 Jun 2010 19:52:01 +0000 (12:52 -0700)]
glsl2: Set InputsRead and OutputsWritten on the generated programs.
Eric Anholt [Fri, 25 Jun 2010 19:37:21 +0000 (12:37 -0700)]
glsl2: Start integrating ir_to_mesa.cpp into shader_api.h
The compiler is now called by the driver, and generates program
instructions. Parameter lists are still not set up, so the driver
chokes on it shortly thereafter.
Eric Anholt [Fri, 25 Jun 2010 19:23:38 +0000 (12:23 -0700)]
glsl2: Use Mesa types instead of duping them into our program.h.
Eric Anholt [Fri, 25 Jun 2010 19:23:20 +0000 (12:23 -0700)]
glsl2: Fix dependencies. (at least partially)
Eric Anholt [Mon, 21 Jun 2010 18:29:15 +0000 (11:29 -0700)]
glsl2: Replace the GLSL compiler with the glsl2 project.
Eric Anholt [Fri, 25 Jun 2010 00:08:53 +0000 (17:08 -0700)]
glsl2: Wrap includes of C interfaces with extern "C".
Eric Anholt [Thu, 24 Jun 2010 23:34:43 +0000 (16:34 -0700)]
glsl2: Remove files that had been imported for standalone.
Eric Anholt [Thu, 24 Jun 2010 22:52:07 +0000 (15:52 -0700)]
glsl2: Stop .gitignoring the old standalone build system.
Eric Anholt [Thu, 24 Jun 2010 22:49:18 +0000 (15:49 -0700)]
glsl2: Move the Mesa IR codegen into mesa/shader/
Eric Anholt [Thu, 24 Jun 2010 22:47:38 +0000 (15:47 -0700)]
Merge branch 'glsl2-head' into glsl2
This brings in the standalone GLSL compiler that we are planning on
replacing the existing Mesa GLSL compiler. It currently targets GLSL
1.20 and the Mesa IR.
Eric Anholt [Thu, 24 Jun 2010 22:41:40 +0000 (15:41 -0700)]
glsl2: Add a README file for the new compiler.
Eric Anholt [Thu, 24 Jun 2010 22:32:15 +0000 (15:32 -0700)]
glsl2: Move the compiler to the subdirectory it will live in in Mesa.
Eric Anholt [Thu, 24 Jun 2010 22:21:51 +0000 (15:21 -0700)]
Merge branch 'mesa'
This brings in the ir_to_mesa.cpp code I've been developing to codegen
to the Mesa IR. It does not actually generate a complete Mesa
fragment/vertex program yet.
Eric Anholt [Thu, 24 Jun 2010 22:18:39 +0000 (15:18 -0700)]
Move the talloc_parent lookup down in a few hot paths.
talloc_parent is still 80% of our runtime, but likely talloc_parent
lookups will be reduced as we improve the handling of memory
ownership.
Eric Anholt [Thu, 24 Jun 2010 22:13:03 +0000 (15:13 -0700)]
Merge remote branch 'cworth/master'
Conflicts:
ast_to_hir.cpp
ir.cpp
This brings in the talloc-based memory management work, so that the
compiler (almost) no longer leaks memory.
Eric Anholt [Thu, 3 Jun 2010 23:37:17 +0000 (16:37 -0700)]
ir_to_mesa: Handle a limited subset of matrix multiplication.
glsl-mvp.vert now generates believable code, and mesa mode fails only
5 tests that master doesn't. I must have left out some asserts...
Eric Anholt [Thu, 3 Jun 2010 23:31:14 +0000 (16:31 -0700)]
ir_to_mesa: Handle constant matrices.
There's not much to it since we're not actually storing constant data yet.
Eric Anholt [Thu, 3 Jun 2010 18:18:51 +0000 (11:18 -0700)]
ir_to_mesa: Fix copy-and-wasted second argument to compare expresssion ops.
Fixes CorrectParse2.vert assertion due to uninitialized values.
Eric Anholt [Thu, 3 Jun 2010 17:13:18 +0000 (10:13 -0700)]
ir_to_mesa: Don't allocate temps for swizzles.
We do them in place by actually, you know, swizzling.
Eric Anholt [Thu, 3 Jun 2010 16:39:54 +0000 (09:39 -0700)]
ir_to_mesa: Set up storage for uniform vars.
Eric Anholt [Thu, 3 Jun 2010 16:31:46 +0000 (09:31 -0700)]
ir_to_mesa: Move the classes into the file now that we don't have the burg.
At 1kloc, it doesn't look like I'll want to split the ir_to_mesa file
up even once it's feature-complete. Move definitions closer to usage,
and prevent rebuilding the world when changing the definitions.
Eric Anholt [Thu, 3 Jun 2010 16:29:29 +0000 (09:29 -0700)]
ir_to_mesa: Remove old monoburg structure.
Eric Anholt [Thu, 3 Jun 2010 16:17:54 +0000 (09:17 -0700)]
ir_to_mesa: Restrict dst writemasks like we did in the monoburg setup.
Eric Anholt [Thu, 3 Jun 2010 16:04:57 +0000 (09:04 -0700)]
ir_to_mesa: Fix copy-and-wasted DIV instruction sequence.
Eric Anholt [Thu, 3 Jun 2010 00:43:43 +0000 (17:43 -0700)]
ir_to_mesa: Remove the BURG code.
The promise of the BURG was to recognize multi-instruction sequences
and emit reduced sequences for them. It would have worked well for
recognizing MUL+ADD -> MAD and possibly even MIN(MAX(val, 0), 1) ->
MOV_SAT with some grammar changes. However, that potential benefit in
making those optimizations easy is outweighed by the fragility of
monoburg, the amount of (incorrect, as I wrote it) code for using it,
and the burden it was going to cause for handling operations on
aggregate types.
Eric Anholt [Tue, 1 Jun 2010 23:32:46 +0000 (16:32 -0700)]
ir_to_mesa: Fix mapping of FS texcoord inputs and color output.
Eric Anholt [Tue, 1 Jun 2010 23:23:57 +0000 (16:23 -0700)]
ir_to_mesa: Try to fix up the dereference handling for the visitor rework.
One of the gstreamer shaders I play with now compiles, but input
mappings are wrong.
Eric Anholt [Wed, 19 May 2010 23:10:37 +0000 (16:10 -0700)]
ir_to_mesa: Implement min and max expressions.
fixes glsl-orangebook-ch06-bump.frag.
Eric Anholt [Wed, 19 May 2010 23:06:37 +0000 (16:06 -0700)]
ir_to_mesa: Don't assert over assignments with a constant-true condition.
Eric Anholt [Wed, 19 May 2010 23:02:00 +0000 (16:02 -0700)]
ir_to_mesa: Add support for trunc/ceil/floor.
Eric Anholt [Wed, 19 May 2010 22:54:28 +0000 (15:54 -0700)]
ir_to_mesa: Implement neg expression.
Eric Anholt [Wed, 19 May 2010 22:50:02 +0000 (15:50 -0700)]
ir_to_mesa: Add sin/cos.
Eric Anholt [Wed, 12 May 2010 17:16:11 +0000 (10:16 -0700)]
ir_to_mesa: Start trying to support struct storage.
Eric Anholt [Tue, 11 May 2010 23:20:21 +0000 (16:20 -0700)]
ir_to_mesa: Fix up array indexing.
The grammar for array_reference_vec4_vec4 was set up wrong, so we
weren't generating instructions if necessary for the array index.
Eric Anholt [Tue, 11 May 2010 07:00:35 +0000 (00:00 -0700)]
ir_to_mesa: Remove stale comment about monoburg.
Eric Anholt [Mon, 10 May 2010 17:06:36 +0000 (10:06 -0700)]
ir_to_mesa: Add support for variable indexing of temporary arrays.
Fixes loop-01.vert, loop-02.vert.
Eric Anholt [Tue, 11 May 2010 01:15:33 +0000 (18:15 -0700)]
ir_to_mesa: Clean up some handling of builtins and arrays.
Constant-index dereferences of arrays should work now. One test is
regressed, but it should have been failing before this commit, too.
Eric Anholt [Fri, 7 May 2010 19:59:08 +0000 (12:59 -0700)]
ir_to_mesa: Add support for loops.
Fixes CorrectParse1 and the glsl2 loop tests that don't use arrays.