aboutsummaryrefslogtreecommitdiffstats
path: root/src/glsl/lower_packed_varyings.cpp
Commit message (Collapse)AuthorAgeFilesLines
* glsl: Hide many classes local to individual .cpp files in anon namespaces.Eric Anholt2013-09-231-0/+4
| | | | | | | | This gives the compiler the chance to inline and not export class symbols even in the absence of LTO. Saves about 60kb on disk. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Pass _mesa_glsl_parse_state into matching_signature and such.Kenneth Graunke2013-09-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | During compilation, we'll use this to determine built-in availability. The plan is to have a single shader containing every built-in in every version of the language, but filter out the ones that aren't actually available to the shader being compiled. At link time, we don't actually need this filtering capability: we've already imported prototypes for every built-in that the shader actually calls, and they're flagged as is_builtin(). The linker doesn't import any additional prototypes, so it won't pull in any unavailable built-ins. When resolving prototypes to function definitions, the linker ensures the values of is_builtin() match, which means that a shader can't trick the linker into importing the body of an unavailable built-in by defining a suspiciously similar prototype. In other words, during linking, we can just pass in NULL. It will work out fine. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: Properly pack GS output varyingsPaul Berry2013-08-011-2/+57
| | | | | | | | | | | | | | In geometry shaders, outputs are consumed at the time of a call to EmitVertex() (as opposed to all other shader types, where outputs are consumed when the shader exits). Therefore, when packing geometry shader output varyings using lower_packed_varyings, we need to do the packing at the time of the EmitVertex() call. This patch accomplishes that by adding a new visitor class, lower_packed_varyings_gs_splicer, which is responsible for splicing the varying packing code into place wherever EmitVertex() is found. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Modify varying packing to use a temporary exec_list.Paul Berry2013-08-011-10/+18
| | | | | | | | | | | | | | This patch modifies lower_packed_varyings to store the packing code it generates in a temporary exec_list, and then splice that list into the shader's main() function when it's done. This paves the way for supporting geometry shader outputs, where we'll have to splice a clone of the packing code before every call to EmitVertex(). As a side benefit, varying packing code is now emitted in the same order for inputs and outputs; this should make debug output a little easier to read. Reviewed-by: Ian Romanick <[email protected]>
* glsl/linker: Properly pack GS input varyings.Paul Berry2013-08-011-28/+184
| | | | | | | | Since geometry shader inputs are arrays (where the array index indicates which vertex is being examined), varying packing needs to treat them differently. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Document lower_packed_varyings' "flat" requirement with an assert.Paul Berry2013-04-091-0/+8
| | | | | | | | | | | | | To minimize the variety of type conversions that lower_packed_varyings needs to perform, it assumes that integral varyings are always qualified as "flat". link_varyings.cpp takes care of ensuring that this is the case (even in the circumstances where GLSL doesn't require it). This patch documents the assumption with an assertion, for ease in future debugging. Reviewed-by: Jordan Justen <[email protected]>
* Replace gl_vert_result enum with gl_varying_slot.Paul Berry2013-03-151-1/+1
| | | | | | | | | | | This patch makes the following search-and-replace changes: gl_vert_result -> gl_varying_slot VERT_RESULT_* -> VARYING_SLOT_* Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Tested-by: Brian Paul <[email protected]>
* glsl: Update lower_packed_varyings to handle varying structs.Paul Berry2013-01-241-4/+18
| | | | | | | | | | | | | | | This patch adds code to lower_packed_varyings to handle varyings of type struct. Varying structs are currently packed in the most naive possible way (in declaration order, with no gaps), so there is a potential loss of runtime efficiency. In a later patch it would be nice to replace this with a "flattening" approach (wherein a varying struct is flattened to individual varyings corresponding to each of its structure elements), so that the linker can align each structure element independently. However, that would require a significantly more complex implementation. Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* glsl: Eliminate ambiguity between function ins/outs and shader ins/outsPaul Berry2013-01-241-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch replaces the three ir_variable_mode enums: - ir_var_in - ir_var_out - ir_var_inout with the following five: - ir_var_shader_in - ir_var_shader_out - ir_var_function_in - ir_var_function_out - ir_var_function_inout This eliminates a frustrating ambiguity: it used to be impossible to tell whether an ir_var_{in,out} variable was a shader in/out or a function in/out without seeing where the variable was declared in the IR. This complicated some optimization and lowering passes, and would have become a problem for implementing varying structs. In the lisp-style serialization of GLSL IR to strings performed by ir_print_visitor.cpp and ir_reader.cpp, I've retained the names "in", "out", and "inout" for function parameters, to avoid introducing code churn to the src/glsl/builtins/ir/ directory. Note: a couple of comments in the code seemed to indicate that we were planning for a possible future in which geometry shaders could have shader-scope inout variables. Our GLSL grammar rejects shader-scope inout variables, and I've been unable to find any evidence in the GLSL standards documents (or extensions) that this will ever be allowed, so I've eliminated these comments. Reviewed-by: Carl Worth <[email protected]> Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* glsl: Pack flat "varyings" of mixed types together.Paul Berry2013-01-081-8/+87
| | | | | | | | | | | | | | | | | | | | | This patch enhances the varying packing code so that flat varyings of uint, int, and float types can be packed together. We accomplish this in lower_packed_varyings.cpp by making the type of all flat varyings ivec4, and then using information-preserving type conversions (e.g. ir_unop_bitcast_f2i) to convert all other types to ints. The varying_matches::compute_packing_class() function is updated to reflect the fact that varying packing no longer needs to segregate varyings of different base types. Fixes piglit test varying-packing-mixed-types. Reviewed-by: Kenneth Graunke <[email protected]> v2: Split lower_packed_varyings_visitor::bitwise_assign into pack/unpack variants.
* glsl: Add a lowering pass for packing varyings.Paul Berry2012-12-141-0/+364
This lowering pass generates GLSL code that manually packs varyings into vec4 slots, for the benefit of back-ends that don't support packed varyings natively. No functional change--the lowering pass is not yet used. Reviewed-by: Eric Anholt <[email protected]> v2: Don't use ir_hierarchical_visitor--just loop over instructions directly. Also, make the names of the packed varyings include the names of the original varyings that were packed into them.