Commit Graph

380 Commits

Author SHA1 Message Date
Eric Anholt a6c7606ab6 glsl2: Unmark unwritten varyings as varying.
This fixes an assertion failure in ir_to_mesa, and the varying won't
take up varying space.
2010-07-28 14:04:54 -07:00
Eric Anholt 59c45e9e6c glsl2: Actually use the linked dead code eliminator.
I managed to revert the change from unlinked at some point while
cleaning up the changes.  glsl-fs-raytrace-bug27060 drops from 389
instructions to 370.
2010-07-27 14:34:53 -07:00
Eric Anholt bf6ad0ab3d glsl2: Use ir_dead_code's linked version after linking.
glsl-fs-raytrace-bug27060 goes from 485 Mesa IR instructions to 389
before Mesa IR optimization.
2010-07-27 11:49:27 -07:00
Eric Anholt afe125e0a1 Merge remote branch 'origin/master' into glsl2
This pulls in multiple i965 driver fixes which will help ensure better
testing coverage during development, and also gets past the conflicts
of the src/mesa/shader -> src/mesa/program move.

Conflicts:
	src/mesa/Makefile
	src/mesa/main/shaderapi.c
	src/mesa/main/shaderobj.h
2010-07-26 17:53:27 -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
Ian Romanick a7ba9a7919 linker: Do post-link lowering and optimization
The lowering code should probably be moved elsewhere.
2010-07-20 17:48:24 -07:00
Ian Romanick 7e2aa91507 glsl2: Add and use new variable mode ir_var_temporary
This is quite a large patch because breaking it into smaller pieces
would result in the tree being intermitently broken.  The big changes
are:

    * Add the ir_var_temporary variable mode

    * Change the ir_variable constructor to take the mode as a
      parameter and correctly specify the mode for all ir_varables.

    * Change the linker to not cross validate ir_var_temporary
      variables.

    * Change the linker to pull all ir_var_temporary variables from
      global scope into 'main'.
2010-07-20 17:48:24 -07:00
Ian Romanick cd6764ed6e linker: Remove the FINISHME comment for intrastage linking 2010-07-19 14:50:43 -07:00
Ian Romanick 1a03a644d2 linker: Remove redundant check for 'main' in shaders
This is now handled in link_intrastage_shaders.
2010-07-19 14:50:43 -07:00
Ian Romanick 25f51d3b9b linker: Track and validate GLSL versions used in shaders 2010-07-19 14:50:43 -07:00
Ian Romanick de415b7f4b linker: Add comment about bug in initializer handling 2010-07-19 14:50:43 -07:00
Ian Romanick 8fe8a814b0 linker: First bits of intrastage, intershader function linking
This handles the easy case of linking a function in a different
compilation unit that doesn't call any functions or reference any
global variables.
2010-07-19 14:50:43 -07:00
Ian Romanick 3880d07f4b linker: Remove some unnecessary includes 2010-07-19 14:50:43 -07:00
Ian Romanick 303c99f12f linker: Use foreach_list_safe in move_non_declarations
The node being processed may be removed from the list and put in a
different list.  Not using the safe version caused list processing to
change streams after moving a node.
2010-07-19 12:36:32 -07:00
Ian Romanick 9303e358cb linker: Move global instructions from the linked shader first
For the shader containing 'main', use the linked shader (i.e., the
clone of the original shader that contained main) as the source for
global instructions to move into main.
2010-07-19 12:36:32 -07:00
Eric Anholt c10a68522c glsl2: When linking makes a variable not a varying output, make it ir_var_auto.
This almost fixes glsl-unused-varying, except that the used varying
gets assigned to the first varying slot (position).
2010-07-13 11:07:16 -07:00
Ian Romanick 4e6a3e0d2d glsl2: Remove unnecessary casts of clone return values 2010-07-13 09:22:35 -07:00
Ian Romanick 31a97868fc linker: Merge global-scope instructions into main
Find instructions in all shaders that are not contained in a function
(i.e., initializers for global variables).  "Move" these instructions
to the top of the main function in the linked shader.  As a
side-effect, many global variables will also be copied into the linked
shader.
2010-07-12 19:12:28 -07:00
Ian Romanick 15ce87e9f2 linker: Detect the shader that contains "main" during intrastage linking 2010-07-12 18:51:55 -07:00
Ian Romanick 13f782c4ae linker: Implement first bits of intrastage linking
This currently involves an ugly hack so that every link doesn't result
in all the built-in functions showing up as multiply defined.  As soon
as the built-in functions are stored in a separate compilation unit,
ir_function_signature::is_built_in can be removed.
2010-07-12 18:51:55 -07:00
Ian Romanick e2e5d0def4 linker: Refactor cross_validate_uniforms into cross_validate_globals
The later, more generic function will be used in the intra-stage linker.
2010-07-12 18:51:55 -07:00
Ian Romanick 3fb878722e linker: Stub-out intrastage linker 2010-07-12 15:19:30 -07:00
Ian Romanick 35c89204e5 linker: Use bit-0 instead of VERT_BIT_GENERIC0
Uses of the bits for allocation are offset by 16, and
VERT_BIT_GENERIC0 already has the 16 offset.  As a result, it was
preventing the wrong thing from being allocated.
2010-07-07 16:28:39 -07:00
Eric Anholt 97eba76b8c glsl2: Allow a fragment shader to not write a color.
I can't find any text justifying this check, and it caused a
reasonable-looking shader in glsl-bug-22603 (which writes only
gl_FragDepth) to fail.
2010-06-30 14:51:50 -07:00
Ian Romanick ef5f194831 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.
2010-06-30 12:20:44 -07:00
Ian Romanick 982e3798d8 linker: Don't automatically allocate VERT_ATTRIB_GENERIC0 2010-06-30 12:02:11 -07:00
Eric Anholt 849e18153c glsl2: Use Mesa's gl_shader_program instead of our own struct glsl_program.
This avoids more allocation and shuffling of data around.
2010-06-30 12:01:42 -07:00
Eric Anholt 16b68b1952 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.
2010-06-30 11:30:26 -07:00
Eric Anholt 3d6012303c glsl2: Wrap includes of C interfaces with extern "C". 2010-06-24 17:23:19 -07:00
Eric Anholt 2928588267 glsl2: Move the compiler to the subdirectory it will live in in Mesa. 2010-06-24 15:36:00 -07:00
Renamed from linker.cpp (Browse further)