summaryrefslogtreecommitdiffstats
path: root/src/glsl
Commit message (Collapse)AuthorAgeFilesLines
* glsl/build: Build glsl_test only on make checkMatt Turner2013-01-201-1/+2
| | | | Reviewed-by: Andreas Boll <[email protected]>
* glsl/build: Remove dead LIBRARY_* variablesMatt Turner2013-01-202-4/+0
| | | | Reviewed-by: Andreas Boll <[email protected]>
* glsl: Eliminate link_update_uniform_buffer_variables return valueIan Romanick2013-01-181-5/+2
| | | | | | | It always returns true, so there's no point in having a return value. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Remove unused loc parameter from generate_callIan Romanick2013-01-181-2/+2
| | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* mesa: Remove unused field gl_uniform_buffer_variable::BufferIan Romanick2013-01-181-1/+0
| | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* linker: Use helper variable shIan Romanick2013-01-181-2/+2
| | | | | | | This looks like a copy-and-paste left over. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Remove stale commentIan Romanick2013-01-181-4/+0
| | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Track UBO block names in the symbol table.Kenneth Graunke2013-01-183-3/+18
| | | | | | | | | | | | | | | | | | | | The GLSL 1.40 spec says: "Uniform block names and variable names declared within uniform blocks are scoped at the program level." Track the block name in the symbol table and emit errors when conflicts exist. Fixes es3conform's uniform_buffer_object_block_name_conflict test, and fixes the piglit block-name-clashes-with-{variable,function,struct}.vert tests. NOTE: This is a candidate for the 9.0 branch. v2: Fix bad constructor initialization. Noticed by Topi Pohjolainen. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Reject row_major and column_major on non-matrix typesIan Romanick2013-01-181-6/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | About both row_major and column_major layout qualifiers, the GLSL spec says: "It only affects the layout of matrices." However, the OpenGL ES 3.0 conformance tests have taken this to mean it is an error use it elsewhere. This seems logical given that 'layout(row_major) vec4 foo' is probably not what the programmer meant. The only catch is dealing with structures that contain matrices. Layout qualifiers cannot be applied directly to fields of structures, so the only way to affect the layout of the fields is to apply a qualifier to the structure declaration itself. There is ongoing debate about this within Khronos, and it seems to be settling in favor of allowing the qualifiers on structures. I light of this, I have chosen to allow the qualifiers on structures but emit a warning since the usage may not be portable. Fixes gles3conform test uniform_buffer_object_layouts_not_for_matrix_type and causes no regressions. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* tests: AM_CPPFLAGS must include $(top_srcdir) instead of $(top_builddir).Johannes Obermayr2013-01-131-4/+5
| | | | Reviewed-by: Andreas Boll <[email protected]>
* Remove hacks for static MakefilesMatt Turner2013-01-131-7/+0
| | | | | | | | | | | v2: Andreas Boll <[email protected]> - don't remove compatibility with scripts for the old build system v3: Andreas Boll <[email protected]> - remove more obsolete hacks v4: Andreas Boll <[email protected]> - add a previously removed TOP variable to fix vgapi build
* glcpp: Add tests for line continuationCarl Worth2013-01-114-0/+46
| | | | | | | | | First we test that line continuations are honored within a comment, (as recently changed in glcpp), then we test that line continuations can be disabled via an option within the context. This is tested via the new support for a test-specific command-line option passed to glcpp. Reviewed-by: Kenneth Graunke <[email protected]>
* glcpp: Rewrite line-continuation support to act globally.Carl Worth2013-01-111-66/+49
| | | | | | | | | | | | | | | | | | | Previously, we were only supporting line-continuation backslash characters within lines of pre-processor directives, (as per the specification). With OpenGL 4.2 and GLES3, line continuations are now supported anywhere within a shader. While changing this, also fix a bug where the preprocessor was ignoring line continuation characters when a line ended in multiple backslash characters. The new code is also more efficient than the old. Previously, we would perform a ralloc copy at each newline. We now perform copies only at each occurrence of a line-continuation. This commit fixes the line-continuation.vert test in piglit. Reviewed-by: Kenneth Graunke <[email protected]>
* glcpp: Add --disable-line-continuations argument to standalone glcppCarl Worth2013-01-111-2/+44
| | | | | | | This will allow testing of disabled line-continuation on a case-by-case basis, (with the option communicated to the preprocessor via the GL context). Reviewed-by: Kenneth Graunke <[email protected]>
* glcpp: Allow test-specific arguments for standalone glcpp testsCarl Worth2013-01-111-2/+9
| | | | | | | | This will allow the test exercising disabled line continuations to arrange for the --disable-line-continuations argument to be passed to the standalone glcpp. Reviewed-by: Kenneth Graunke <[email protected]>
* glcpp: Honor the GL context's DisableGLSLLineContinuations optionCarl Worth2013-01-111-1/+3
| | | | | | And simply don't call into the function that removes line continuations. Reviewed-by: Kenneth Graunke <[email protected]>
* glcpp: Accept pointer to GL context rather than just the API versionCarl Worth2013-01-116-7/+20
| | | | | | | | | As the preprocessor becomes more sophisticated and gains more optional behavior, it's easiest to just pass the GL context pointer to it so that it can examine any fields there that it needs to (such as API version, or the state of any driconf options, etc.). Reviewed-by: Kenneth Graunke <[email protected]>
* glcpp: Reject token pasting operator in GLESMatt Turner2013-01-111-0/+2
| | | | | | | | | The GLSL ES 3.0 spec (Section 12.17) says: "GLSL ES 1.00 removed token pasting and other functionality." NOTE: This is a candidate for the stable branches. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Carl Worth <[email protected]>
* glcpp: Make undefined macros illegal in #if and #elif for GLES3Carl Worth2013-01-111-0/+2
| | | | | | | | | | | | Simply emitting a nicely-formatted error message if any undefined macro is encountered in a parser context expecting an expression. With this commit, the following piglit test now passes: spec/glsl-es-3.00/compiler/undefined-macro.vert Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glcpp: Add a flag to the parser state to indicate GLES.Carl Worth2013-01-112-11/+16
| | | | | | | | | | | | This can be triggered either by creation of a GLES context (with api == API_OPENGLES2) or else by a #version directive with version value 100 or with a string of "es" following the version value. There's no behavioral change with this commit—just preparation for ES-specific behavior in the preprocessor in the future. Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glcpp: Add back tests/*.out to .gitignoreAndreas Boll2013-01-111-0/+1
| | | | Accidentally removed in ac2793cf3e1e004942c386dfa45f3b5507223f50
* Clean up .gitignore filesMatt Turner2013-01-104-5/+0
|
* Remove unused glsl Makefile.templateMatt Turner2013-01-101-50/+0
|
* glsl: Don't add structure fields to the symbol tableIan Romanick2013-01-081-1/+0
| | | | | | | | | | | | | | | | | I erroneously added this back in January 2011 in commit 88421589. Looking at the commit message, I have no idea why I added it. It only added non-array structure fields to the symbol table, so array structure fields are treated correctly. Fixes piglit tests structure-and-field-have-same-name.vert and structure-and-field-have-same-name-nested.vert. It should also fix WebGL conformance tests shader-with-non-reserved-words. NOTE: This is a candidate for the stable release branches. Signed-off-by: Ian Romanick <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=57622 Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Pack flat "varyings" of mixed types together.Paul Berry2013-01-082-14/+101
| | | | | | | | | | | | | | | | | | | | | 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: Prohibit structs and bools from being used as "varyings".Paul Berry2013-01-081-21/+71
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The GLSL 1.30 spec only allows vertex shader outputs and fragment shader inputs ("varyings" in pre-GLSL-1.30 parlance) to be of type int, uint, float, or vectors, matrices, or arrays thereof. Bools, bvec's, and structs are prohibited. (Integral varyings were prohibited prior to GLSL 1.30). Previously, Mesa only performed this check on variables declared with the "varying" keyword, and it always performed the check according to the pre-GLSL-1.30 rules. As a result, bools and structs were allowed to slip through, provided they were declared using the new in/out syntax. This patch modifies the error check so that it occurs after "varying" is converted to "in/out", and corrects it to properly account for GLSL version. Fixes piglit tests: in-bool-prohibited.frag in-bvec2-prohibited.frag in-bvec3-prohibited.frag in-bvec4-prohibited.frag in-struct-prohibited.frag out-bool-prohibited.vert out-bvec2-prohibited.vert out-bvec3-prohibited.vert out-bvec4-prohibited.vert out-struct-prohibited.vert Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Plumb through is_parameter to apply_type_qualifier_to_variable()Paul Berry2013-01-081-3/+4
| | | | | | | | | | This patch adds logic to allow the ast_to_hir function apply_type_qualifier_to_variable() to tell whether it is acting on a variable declaration or a function parameter. This will allow it to correctly interpret the meaning of "out" and "in" keywords (which have different meanings in those two contexts). Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Separate varying linking code to its own file.Paul Berry2013-01-085-1124/+1240
| | | | | | | | linker.cpp is getting pretty big, and we're about to add even more varying packing code, so split out the linker code that concerns varyings to its own file. Reviewed-by: Kenneth Graunke <[email protected]>
* mesa: Add ALIGN() macro to main/macros.h.Paul Berry2013-01-081-2/+0
| | | | | | | | | Previously this macro existed in 3 separate places, some inside the intel driver and some outside of it. It makes more sense to have it in main/macros.h Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Fix loop bounds detection.Paul Berry2013-01-081-4/+4
| | | | | | | | | | | | | When analyzing a loop where the loop condition is expressed in the non-standard order (e.g. "4 > i" instead of "i < 4"), we were reversing the condition incorrectly, leading to a loop bound that was off by 1. Fixes piglit tests {vs,fs}-loop-bounds-unrolled.shader_test. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* glcpp: Typo fix.Adam Jackson2013-01-021-1/+1
| | | | | | Note: this is a candidate for the 9.0 stable branch. Signed-off-by: Adam Jackson <[email protected]>
* glcpp: Fix visibility CFLAGS in automakeAdam Jackson2013-01-021-0/+1
| | | | | | Note: this is a candidate for the 9.0 stable branch. Signed-off-by: Adam Jackson <[email protected]>
* glsl: Add a note about a surprising feature of gl_uniform_storage->type.Eric Anholt2012-12-281-0/+4
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Fix gl_context vs. ralloc context in check_version again, again.Kenneth Graunke2012-12-171-2/+2
| | | | | | Dave found some, but there were more. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=58039
* glsl_parser_extras.cpp: fixup gl vs mem contexts again.Dave Airlie2012-12-161-4/+4
| | | | | | | | | This should fix: https://bugs.freedesktop.org/show_bug.cgi?id=58039 Tested-by: Darxus on bug 58039 Reviewed-by: Kenneth Graunke <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl: avoid using gl context as a memory contextDave Airlie2012-12-151-4/+5
| | | | | | | | Not sure what was going on here, but running piglit with debug builds might be a good plan :-) Reviewed-by: Kenneth Graunke <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl/linker: Pack between varyings.Paul Berry2012-12-141-15/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch implements varying packing between varyings. Previously, each varying occupied components 0 through N-1 of its assigned varying slot, so there was no way to pack two varyings into the same slot. For example, if the varyings were a float, a vec2, a vec3, and another vec2, they would be stored as follows: <----slot1----> <----slot2----> <----slot3----> <----slot4----> slots * * * * * * * * * * * * * * * * flt x x x <vec2-> x x <--vec3---> x <vec2-> x x varyings (Each * represents a varying component, and the "x"s represent wasted space). This change packs the varyings together to eliminate wasted space between varyings, like so: <----slot1----> <----slot2----> <----slot3----> <----slot4----> slots * * * * * * * * * * * * * * * * <vec2-> <vec2-> flt <--vec3---> x x x x x x x x varyings Note that we take advantage of the sort order introduced in previous patches (vec4's first, then vec2's, then scalars, then vec3's) to minimize how often a varying is "double parked" (split across varying slots). Reviewed-by: Eric Anholt <[email protected]> v2: Skip varying packing if ctx->Const.DisableVaryingPacking is true.
* glsl/linker: Pack within compound varyings.Paul Berry2012-12-141-37/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch implements varying packing within varyings that are composed of multiple vectors of size less than 4 (e.g. arrays of vec2's, or matrices with height less than 4). Previously, such varyings used up a full 4-wide varying slot for each constituent vector, meaning that some of the components of each varying slot went unused. For example, a mat4x3 would be stored as follows: <----slot1----> <----slot2----> <----slot3----> <----slot4----> slots * * * * * * * * * * * * * * * * <-column1-> x <-column2-> x <-column3-> x <-column4-> x matrix (Each * represents a varying component, and the "x"s represent wasted space). In addition to wasting precious varying components, this layout complicated transform feedback, since the constituents of the varying are expected to be output to the transform feedback buffer contiguously (e.g. without gaps between the columns, in the case of a matrix). This change packs the constituents of each varying together so that all wasted space is at the end. For the mat4x3 example, this looks like so: <----slot1----> <----slot2----> <----slot3----> <----slot4----> slots * * * * * * * * * * * * * * * * <-column1-> <-column2-> <-column3-> <-column4-> x x x x matrix Note that matrix columns 2 and 3 now cross a boundary between varying slots (a characteristic I call "double parking" of a varying). We don't bother trying to eliminate the wasted space at the end of the varying, since the patch that follows will take care of that. Since compiler back-ends don't (yet) support this packed layout, the lower_packed_varyings function is used to rewrite the shader into a form where each varying occupies a full varying slot. Later, if we add native back-end support for varying packing, we can make this lowering pass optional. Reviewed-by: Eric Anholt <[email protected]> v2: Skip varying packing if ctx->Const.DisableVaryingPacking is true.
* glsl: Add a lowering pass for packing varyings.Paul Berry2012-12-143-0/+368
| | | | | | | | | | | | | | 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.
* glsl/linker: Sort varyings by packing class, then vector size.Paul Berry2012-12-141-0/+104
| | | | | | | | | | | | | | | | | | | | | | | | | | | This patch paves the way for varying packing by adding a sorting step before varying assignment, which sorts the varyings into an order that increases the likelihood of being able to find an efficient packing. First, varyings are sorted into "packing classes" by considering attributes that can't be mixed during varying packing--at the moment this includes base type (float/int/uint/bool) and interpolation mode (smooth/noperspective/flat/centroid), though later we will hopefully be able to relax some of these restrictions. The number of packing classes places an upper limit on the amount of space that must be wasted by varying packing, since in theory a shader might nave 4n+1 components worth of varyings in each of m packing classes, resulting in 3m components worth of wasted space. Then, within each packing class, varyings are sorted by vector size, with vec4's coming first, then vec2's, then scalars, and then finally vec3's. The motivation for this order is that it ensures that the only vectors that might be "double parked" (with part of the vector in one varying slot and the remainder in another) are vec3's. Note that the varyings aren't actually packed yet, merely placed in an order that will facilitate packing. Reviewed-by: Eric Anholt <[email protected]>
* glsl/linker: Subdivide the first phase of varying assignment.Paul Berry2012-12-141-44/+163
| | | | | | | | | | | | | | | | | This patch further subdivides the loop that assigns varying locations into two phases: one phase to match up the varyings between shader stages, and one phase to assign them varying locations. In between the two phases the matched varyings are stored in a new data structure called varying_matches. This will free us to be able to assign varying locations in any order, which will pave the way for packing varyings. Note that the new varying_matches::assign_locations() function returns the number of varying slots that were used; this return value will be used in a future patch. Reviewed-by: Eric Anholt <[email protected]>
* glsl/linker: Defer recording transform feedback locations.Paul Berry2012-12-141-55/+48
| | | | | | | | | | | | | | | | | This patch subdivides the loop that assigns varying locations into two phases: one phase to match up varyings between shader stages (and assign them varying locations), and a second phase to record the varying assignments for use by transform feedback. This paves the way for varying packing, which will require us to further subdivide the first phase. In addition, it lets us avoid a clumsy O(n^2) algorithm, since we can now record the locations of all transform feedback varyings in a single pass through the tfeedback_decls array, rather than have to iterate through the array after assigning each varying. Reviewed-by: Eric Anholt <[email protected]>
* glsl: Create a field to store fractional varying locations.Paul Berry2012-12-143-2/+14
| | | | | | | | | | | | | | | Currently, the location of each varying is recorded in ir_variable as a multiple of the size of a vec4. In order to pack varyings, we need to be able to record, e.g. that a vec2 is stored in the second half of a varying slot rather than the first half. This patch introduces a field ir_variable::location_frac, which represents the offset within a vec4 where a varying's value is stored. Varyings that are not subject to packing will always have a location_frac value of zero. Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl/linker: Make separate ir_variable field to mean "unmatched".Paul Berry2012-12-142-4/+23
| | | | | | | | | | | | | | | | | Previously, the linker used a value of -1 in ir_variable::location to denote a generic input or output of the shader that had not yet been matched up to a variable in another pipeline stage. This patch introduces a new ir_variable field, is_unmatched_generic_inout, for that purpose. In future patches, this will allow us to separate the process of matching varyings between shader stages from the processes of assigning locations to those varying. That will in turn pave the way for packing varyings. Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl/linker: Always invalidate shader ins/outs, even in corner cases.Paul Berry2012-12-141-12/+31
| | | | | | | | | | | | | | | | | | Previously, link_invalidate_variable_locations() was only called during assign_attribute_or_color_locations() and assign_varying_locations(). This meant that in the corner case when there was only a vertex shader, and varyings were being captured by transform feedback, link_invalidate_variable_locations() wasn't being called for the varyings. This patch migrates the calls to link_invalidate_variable_locations() to link_shaders(), so that they will be called in all circumstances. In addition, it modifies the call semantics so that link_invalidate_variable_locations() need only be called once per shader stage (rather than once for inputs and once for outputs). Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl/lower_clip_distance: Update symbol table.Paul Berry2012-12-143-5/+10
| | | | | | | | | | | | | This patch modifies the clip distance lowering pass so that the new symbol it generates (glClipDistanceMESA) is added to the shader's symbol table. This will allow a later patch to modify the linker so that it finds transform feedback varyings using the symbol table rather than having to iterate through all the declarations in the shader. Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* mesa: Use the new hash table for the variable refcount visitor.Eric Anholt2012-12-076-22/+43
| | | | | | | Reviewed-by: Jordan Justen <[email protected]> [[email protected]: open_hash_table => hash_table] Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* program/hash_table.c: rename to program/prog_hash_table.cJordan Justen2012-12-074-6/+6
| | | | | | | | Removes a collision of the object file name for main/hash_table and program/hash_table. Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add missing semicolon in the grammarKenneth Graunke2012-12-061-0/+1
| | | | | | | | | This may not be strictly necessary, but every other rule in the grammar ends with a semicolon. It also appears that this was supposed to be commited with the original patch that changed this rule, but the wrong version of the patch was accidentally pushed. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Allow layout qualifiers in GLSL 3.00 ESIan Romanick2012-12-063-1/+7
| | | | | | | | | | Note that while 'packed' is a reserved word in GLSL ES, row_major is not. This means that we have to use the string-based matching for that. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Acked-by: Carl Worth <[email protected]>