summaryrefslogtreecommitdiffstats
path: root/src/glsl
Commit message (Collapse)AuthorAgeFilesLines
* 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]>
* glsl: Create builtin function profiles for GLSL 3.00 ES.Paul Berry2012-12-063-0/+834
| | | | | | | | | | | | | | | | Nearly all of the builtin functions in GLSL 3.00 ES are already implemented in Mesa; this patch enables them. A few functions are not implemented yet; those have been commented out, with a FIXME comment to act as a reminder of what still needs to be implemented. Here is the complete list: packSnorm2x16, unpackSnorm2x16, packUnorm2x16, unpackUnorm2x16, packHalf2x16, unpackHalf2x16. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Acked-by: Carl Worth <[email protected]>
* glsl: add determinant() functions.Paul Berry2012-12-061-0/+70
| | | | | | | | | | | | These functions are defined in GLSL 1.50 and GLES 3.00 ES. The formulas have been extracted from the existing implementation of inverse(). Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Acked-by: Carl Worth <[email protected]>
* glsl: Make builtin function profiles for GLSL ES use "es" in the filename.Paul Berry2012-12-064-1/+5
| | | | | | | Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Acked-by: Carl Worth <[email protected]>
* glsl: Add builtin variables for GLSL 3.00 ES.Paul Berry2012-12-061-42/+151
| | | | | | | | | | | | This patch also adds assertions so that when we add new GLSL versions, we'll notice that we need to update the builtin variables. [v2, idr]: s/Frab/Frag/ Noticed by Eric. Reviewed-by: Ian Romanick <[email protected]> [v1] Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Acked-by: Carl Worth <[email protected]>
* glsl: Populate built-in types correctly for GLSL 3.00 ES.Paul Berry2012-12-063-45/+103
| | | | | | | | | | | | | | | | | | | | | | | This patch implements all of the built-in types for GLSL 3.00 ES. This is almost exactly the same as the set of built-in types for GLSL 1.30, except ate 1D samplers are skipped, and samplerCubeShadow is added. This patch also addes an assertion so that when we add new GLSL versions, we'll notice that we need to update the types. In review, Eric noted: "This change looks correct. The overall interaction of profiles is getting ugly, though. I'm imagining a restructure of the symbol table population so that there's a big list of types, and each #version has a nice list of strings of type names copy and pasted out of its spec." Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Acked-by: Carl Worth <[email protected]>
* glsl: Make {Min,Max}ProgramTexelOffset available to compiler.Paul Berry2012-12-062-0/+6
| | | | | | | | | These constants need to be made available to shaders in GLSL 3.00 ES. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Acked-by: Carl Worth <[email protected]>
* glsl: Fix linker checks for GLSL ES 3.00.Paul Berry2012-12-061-7/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | This patch updates the following linker checks to do the right thing in GLSL 3.00 ES: - Failing to write to gl_Position is allowed in GLSL 1.40+ as well as GLSL 3.00 ES. - It is an error to write to both gl_ClipVertex and gl_ClipDistance in GLSL 1.30+. This does not apply to GLSL 3.00 ES. - GLSL 3.00 ES uses the same varying counting rules as GLSL 1.00 ES. - In GLSL 1.30 and GLSL 3.00 ES, "discard" terminates the shader. - In GLSL 1.00 ES and GLSL 3.00 ES, both a fragment and a vertex shader must be present. [v2, idr]: Fix minro typo in a comment. Noticed by Ken. [v3, idr]: s/IsEs(Shader|Prog)/IsES/ Suggested by Ken and Eric. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Acked-by: Carl Worth <[email protected]>
* glsl: Record in gl_shader_program whether the program uses GLSL ES.Paul Berry2012-12-061-0/+1
| | | | | | | | | | | | Previously we recorded just the GLSL version (or the max version, if GLSL 1.10 and GLSL 1.20 programs were linked together). [v2, idr]: s/IsEs(Shader|Prog)/IsES/ Suggested by Ken and Eric. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Acked-by: Carl Worth <[email protected]>
* glsl: Clean up shading language mixing check for GLSL 3.00 ES.Paul Berry2012-12-061-3/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | Previously, we prohibited mixing of shading language versions if min_version == 100 or max_version >= 130. This was technically correct (since desktop GLSL 1.30 and beyond prohibit mixing of shading language versions, as does GLSL 1.00 ES), but it was confusing. Also, we asserted that all shading language versions were between 1.00 and 1.40, which was unnecessary (since the parser already checks shading language versions) and doesn't work for GLSL 3.00 ES. This patch changes the code to explicitly check that (a) ES shaders aren't mixed with desktop shaders, (b) shaders aren't mixed between ES versions, and (c) shaders aren't mixed between desktop GLSL versions when at least one shader is GLSL 1.30 or greater. Also, it removes the unnecessary assertion. [v2, idr]: Slightly tweak the is_es_prog detection to occur outside the loop instead of doing something special on the first loop iteration. Suggested by Ken. [v3, idr]: s/IsEs(Shader|Prog)/IsES/ Suggested by Ken and Eric. Reviewed-by: Ian Romanick <[email protected]> [v1] Reviewed-by: Kenneth Graunke <[email protected]> Acked-by: Carl Worth <[email protected]>
* glsl: Record in gl_shader whether the shader uses GLSL ES.Paul Berry2012-12-061-0/+1
| | | | | | | | | | | | | | | | | | Previously we recorded just the GLSL version, with the knowledge that 100 means GLSL 1.00 ES. With the advent of GLSL 3.00 ES, this is going to get more complex, and eventually will probably become ambiguous (GLSL 4.00 already exists, and GLSL 4.00 ES is likely to be created some day). To reduce confusion, this patch simply records whether the shader is GLSL ES as an explicit boolean. [v2, idr]: s/IsEs(Shader|Prog)/IsES/ Suggested by Ken and Eric. Reviewed-by: Ian Romanick <[email protected]> [v1] Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Acked-by: Carl Worth <[email protected]>
* glsl/parser: Handle "#version 300 es" directive.Paul Berry2012-12-063-28/+86
| | | | | | | | | | | | | | | Note that GLSL 1.00 is selected using "#version 100", so "#version 100 es" is prohibited. v2: Check for GLES3 before allowing '#version 300 es' v3: Make sure a correct language_version is set in _mesa_glsl_parse_state::process_version_directive. Signed-off-by: Paul Berry <[email protected]> Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Acked-by: Carl Worth <[email protected]>
* glsl/parser: Extract version directive processing into a function.Paul Berry2012-12-063-42/+55
| | | | | | | | | | | | | | Version directive handling is going to have to be used within two parser rules, one for desktop-style version directives (e.g. "#version 130") and one for the new ES-style version directive (e.g. "#version 300 es"), so this patch moves it to a function that can be called from both rules. No functional change. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Acked-by: Carl Worth <[email protected]>
* glsl/preprocessor: Handle "#version 300 es" directive.Paul Berry2012-12-061-4/+17
| | | | | | Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Acked-by: Carl Worth <[email protected]>
* glsl/preprocessor: Extract version directive processing into a function.Paul Berry2012-12-061-19/+30
| | | | | | | | | | | | | | | | | | | | | Version directive handling is going to have to be used within two parser rules, one for desktop-style version directives (e.g. "#version 130") and one for the new ES-style version directive (e.g. "#version 300 es"), so this patch moves it to a function that can be called from both rules. No functional change. [mattst88] v2: Use intmax_t instead of int for version argument. Would otherwise write garbage after #version since PRIiMAX was reading 64-bits instead of 32. [idr] v3: A later commit fixes the caller of _glcpp_parser_handle_version_declaration to pass the correct number of parameters. Fix it in the patch that changes the interface instead. Reviewed-by: Kenneth Graunke <[email protected]> Acked-by: Carl Worth <[email protected]>
* glsl: Enable GLSL ES 3.00 features inherited from desktop GLSL.Paul Berry2012-12-065-17/+47
| | | | | | | | | | | | | | | | | | | | This patch turns on the following features for GLSL ES 3.00: - Array constructors, whole array assignment, and array comparisons. - Second and third operands of ?: may be arrays. - Use of "in" and "out" qualifiers on globals. - Bitwise and modulus operators. - Integral vertex shader inputs. - Range-checking of literal integers. - array.length method. - Function calls may be constant expressions. - Integral varyings must be qualified with "flat". - Interpolation and centroid qualifiers may not be applied to vertex shader inputs. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Acked-by: Carl Worth <[email protected]>
* glsl: parse GLSL ES 3.00 keywords correctly.Paul Berry2012-12-062-78/+114
| | | | | | | | | | | | | | | | | | | | | GLSL ES 3.00 adds the following keywords over GLSL 1.00: uint, uvec[2-4], matNxM, centroid, flat, smooth, various samplers, layout, switch, default, and case. Additionally, it reserves a large number of keywords, some of which were already reserved in versions of desktop GL that Mesa supports, some of which are new to Mesa. A few of the reserved keywords in GLSL ES 3.00 are keywords that are supported in all other versions of GLSL: attribute, varying, sampler1D, sampler1DShador, sampler2DRect, and sampler2DRectShadow. This patch updates the lexer to handle all of the new keywords correctly when the language being parsed is GLSL 3.00 ES. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Acked-by: Carl Worth <[email protected]>
* glsl: Rework lexer keyword handling in preparation for GLSL 3.00 ES.Paul Berry2012-12-061-132/+136
| | | | | | | | | | | | | | | | | | | | | | | | This patch expands the lexer KEYWORD macro to take two additional arguments: the GLSL ES versions in which the given keyword was first reserved, and supported, respectively. This will allow us to trivially add support for GLSL 3.00 ES keywords, even though the set of GLSL 3.00 ES keywords is neither a subset or a superset of the keywords corresponding to any desktop GLSL version. The new KEYWORD macro makes use of the _mesa_glsl_parse_state::is_version() function, so it accepts 0 as meaning "unsupported" (rather than 999, which we used previously). Note that a few keywords ("packed" and "row_major") are supported *either* when GLSL 1.40 is in use or when ARB_uniform_buffer_obj support is enabled. Previously, we handled these by cleverly taking advantage of the fact that the KEYWORD macro didn't parenthesize its arguments in the usual way. Now they are handled more straightforwardly, with a new macro, KEYWORD_WITH_ALT. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Acked-by: Carl Worth <[email protected]>