Commit graph

36 commits

Author SHA1 Message Date
Eric Anholt
cc4ddc3a1e glsl: Fix gl_NormalMatrix swizzle setup to match i965's invariants.
A driver trying to set up builtin uniforms is faced with a problem:
How do I walk the ir_variable structure (representing an array of
structs, or array of matrices, or struct, or whatever), and set up
driver structures so that dereference of that uniform gets the
corresponding ParameterValues[] entry.  The rule in general is that
each corresponding vector-sized field of an array of structs is one
builtin uniform state slot.  i965 relied on another invariant: each
state slot has a number of unique channel swizzles corresponding to
the number of elements in the field's vector, to avoid needing to walk
the glsl_type in parallel to get at vector_elements.

All of the builtin uniforms followed this behavior, except for
gl_NormalMatrix.  That's a mat3 (so 3 vec3s), but it was swizzled as 3
vec4s.

Fixes piglit glsl-fs-normalmatrix.
Reviewed-by: Paul Berry <stereotype441@gmail.com>
2011-10-24 13:43:02 -07:00
Eric Anholt
2ecfa88548 glsl: Add gl_MaxVaryingComponents in GLSL 1.30.
This is the new name for gl_MaxVaryingFloats now that non-float
varyings exist.  Fixes piglit
glsl-1.30/execution/maximums/gl_MaxVaryingFloats

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2011-10-24 13:43:02 -07:00
Eric Anholt
f868cb0963 glsl: Add gl_CurrentAttrib{Vert,Frag}MESA internal builtin uniforms.
These will be used by the FF VS/FS to represent the current attributes
when they don't have an active vertex array.
2011-10-18 10:54:32 -07:00
Paul Berry
3d7c5a4f6f mesa: set up gl_vert_result and gl_frag_attrib values for gl_ClipDistance.
This patch assigns enumerated values for gl_ClipDistance in the
gl_vert_result and gl_frag_attrib enums, so that driver back-ends can
assign gl_ClipDistance to the appropriate hardware registers.  It also
adjusts the functions _mesa_vert_result_to_frag_attrib() and
_mesa_frag_attrib_to_vert_result() (which translate between the two
enums) to correctly translate the new enumerated values.

Reviewed-by: Eric Anholt <eric@anholt.net>
Tested-by: Brian Paul <brianp@vmware.com>
2011-09-23 13:30:03 -07:00
Paul Berry
36c4b1a3da glsl: Add constant gl_MaxClipDistances.
Fixes piglit tests {vs,fs}-clip-distance-sizeable-to-max.shader_test.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2011-09-08 09:37:12 -07:00
Paul Berry
af243b55ac glsl: Make gl_ClipDistance[] implicitly sized.
From the GLSL 1.30 spec, section 7.1 (Vertex Shader Special Variables):

  The gl_ClipDistance array is predeclared as unsized and must be
  sized by the shader either redeclaring it with a size or indexing it
  only with integral constant expressions.

Fixes piglit tests clip-distance-implicit-length.vert,
clip-distance-implicit-nonconst-access.vert, and
{vs,fs}-clip-distance-explicitly-sized.shader_test.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2011-09-08 09:36:13 -07:00
Marek Olšák
5ba2e7adf0 mesa: implement AMD_shader_stencil_export
It's just an alias of the ARB variant with some GLSL compiler changes.

Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2011-05-03 12:03:22 +02:00
Ian Romanick
89d81ab16c glsl: Calcluate Mesa state slots in front-end instead of back-end
This should be the last bit of infrastructure changes before
generating GLSL IR for assembly shaders.

This commit leaves some odd code formatting in ir_to_mesa and brw_fs.
This was done to minimize whitespace changes / reindentation in some
loops.  The following commit will restore formatting sanity.

Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Chad Versace <chad.versace@intel.com>
2011-03-29 13:21:08 -07:00
Ian Romanick
92e412e788 glsl: Move _mesa_builtin_uniform_desc from uniforms.c to ir_variable.cpp
This array is going to be used in the main compiler soon.  Leaving
them uniforms.c caused problems for building the stand-alone compiler.

Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Chad Versace <chad.versace@intel.com>
2011-03-29 13:21:08 -07:00
Ian Romanick
dfdff940b6 glsl: Make add_variable, add_uniform, et. al. have similar signatures
While making some other changes in this area I was finding it annoying
each of these functions took mostly the same set of parameters in
differing orders.
2011-03-25 11:28:08 -07:00
Kenneth Graunke
819d57fce9 glsl: Introduce a new "const_in" variable mode.
This annotation is for an "in" function parameter for which it is only legal
to pass constant expressions.  The only known example of this, currently,
is the textureOffset functions.

This should never be used for globals.
2011-01-31 11:10:59 -08:00
Brian Paul
652901e95b Merge branch 'draw-instanced'
Conflicts:
	src/gallium/auxiliary/draw/draw_llvm.c
	src/gallium/drivers/llvmpipe/lp_state_fs.c
	src/glsl/ir_set_program_inouts.cpp
	src/mesa/tnl/t_vb_program.c
2011-01-15 10:24:08 -07:00
Brian Paul
7ce186358e glsl: add support for system values and GL_ARB_draw_instanced 2010-12-08 18:25:38 -07:00
Eric Anholt
001eee52d4 glsl: Make the symbol table's add_variable just use the variable's name. 2010-11-29 17:08:27 -08:00
Kenneth Graunke
a75da2c0e8 glsl: Remove useless ir_shader enumeration value. 2010-10-20 15:07:47 -07:00
Dave Airlie
d9671863ea glsl: add support for shader stencil export
This adds proper support for the GL_ARB_shader_stencil_export extension
to the GLSL compiler. Thanks to Ian for pointing out where I need to add things.
2010-10-13 09:30:05 +10:00
Ian Romanick
68a4fc9d5a glsl: Add linker support for explicit attribute locations 2010-10-08 14:21:23 -07:00
Eric Anholt
b5bb215629 glsl: Add definition of gl_TextureMatrix inverse/transpose builtins.
Fixes glsl2/builtin-texturematrix.
Bug #30196.
2010-09-21 10:09:46 -07:00
Kenneth Graunke
b4fe4d52b6 glsl: Add built-in variables for GLSL ES 1.00. 2010-09-07 17:30:38 -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
Ian Romanick
261bbc011d glsl2: Use Elements from main/compiler.h instead of open-coding 2010-08-12 15:05:39 -07:00
Kenneth Graunke
dbff7b541e glsl2: Use gl_DepthRange's proper name.
It was being incorrectly added as gl_DepthRangeParameters, which is the
type name, not the variable name.
2010-08-09 11:42:37 -07:00
Eric Anholt
046bef2357 glsl2: Remove the shader_in/shader_out tracking separate from var->mode.
I introduced this for ir_dead_code to distinguish function parameter
outvals from varying outputs.  Only, since ast_to_hir's
current_function is unset when setting up function parameters (they're
needed for making the function signature in the first place), all
function parameter outvals were marked as shader outputs anyway.  This
meant that an inlined function's cloned outval was marked as a shader
output and couldn't be dead-code eliminated.  Instead, since
ir_dead_code doesn't even look at function parameters, just use
var->mode.

The longest Mesa IR coming out of ir_to_mesa for Yo Frankie drops from
725 instructions to 636.
2010-08-04 20:52:33 -07:00
Eric Anholt
85b5dba593 glsl2: Add the remaining builtin uniforms. 2010-07-28 12:34:08 -07:00
Eric Anholt
73df636e04 glsl2: Size builtin arrays according to the context constants.
Cleans up some of the FINISHMEs in this file.
2010-07-28 11:16:19 -07:00
Ian Romanick
f38d15b80d glsl2: glsl_type has its own talloc context, don't pass one in 2010-07-20 17:48:25 -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
Eric Anholt
f8946699ec glsl2: Add definitions of the builtin constants present in GLSL 1.10.
Fixes:
glsl1-built-in constants
2010-07-20 14:03:35 -07:00
Eric Anholt
152b55e74d glsl2: Add support for gl_PointCoord in 1.20.
Fixes glsl-fs-pointcoord on swrast (remains broken on 965, like master)
2010-07-07 19:45:22 -07:00
Ian Romanick
127308b4be glsl2: Add gl_MaxTextureCoords 2010-07-01 13:30:50 -07:00
Ian Romanick
cd00d5b88c glsl2: Default delcaration of gl_TexCoord is unsized 2010-07-01 13:17:54 -07:00
Ian Romanick
22971e922a glsl2: Make gl_MaxDrawBuffers available in the vertex shader 2010-06-29 15:32:19 -07:00
Ian Romanick
e2f84f04e5 glsl2: Make gl_MaxDrawBuffers available in the fragment shader 2010-06-29 15:32:15 -07:00
Ian Romanick
9c4b1f2bad glsl2: Make gl_FragData be available in GLSL 1.10 too 2010-06-29 15:19:42 -07:00
Ian Romanick
5e18b051c0 glsl2: Pass MaxDrawBuffers from core Mesa into the GLSL compiler 2010-06-29 15:19:38 -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 ir_variable.cpp (Browse further)