summaryrefslogtreecommitdiffstats
path: root/src/glsl
Commit message (Collapse)AuthorAgeFilesLines
* glsl/ir_factory: Add helper method for making an ir_constantChad Versace2013-01-241-0/+24
| | | | | | | | Add method ir_factory::constant. This little method constructs an ir_constant using the factory's mem_ctx. Reviewed-by: Ian Romanick <[email protected]> Signed-off-by: Chad Versace <[email protected]>
* glsl/ir_builder: Add more helpers for constructing expressionsChad Versace2013-01-242-0/+156
| | | | | | | | | | | | | | | | | Add the following functions, each of which construct the similarly named ir expression: div, round_even, clamp equal, less, greater, lequal, gequal logic_not, logic_and, logic_or bit_not, bit_or, bit_and, lshift, rshift f2i, i2f, f2u, u2f, i2u, u2i Reviewed-by: Ian Romanick <[email protected]> Signed-off-by: Chad Versace <[email protected]>
* glsl/ir_factory: Initialize members to NULL in constructorChad Versace2013-01-241-0/+7
| | | | | | | This eliminates unexpected behavior due to unitialized values. Reviewed-by: Ian Romanick <[email protected]> Signed-off-by: Chad Versace <[email protected]>
* glsl: Evaluate constant GLSL ES 3.00 pack/unpack expressions (v3)Chad Versace2013-01-241-0/+189
| | | | | | | | | | | | | | | | | | That is, evaluate constant expressions of the following functions: packSnorm2x16 unpackSnorm2x16 packUnorm2x16 unpackUnorm2x16 packHalf2x16 unpackHalf2x16 v2: Reuse _mesa_pack_float_to_half and its inverse to evaluate pack/unpackHalf2x16. [for idr] v3: Whitespace fixes. [for mattst88] Don't cast neg floats directly to uint16; use an intermediate cast to int16. [for paul] Reviewed-by: Ian Romanick <[email protected]> (v2) Reviewed-by: Paul Berry <[email protected]> Reviewed-by: Matt Tuner <[email protected]> Signed-off-by: Chad Versace <[email protected]>
* mesa,glsl: Move round_to_even() from glsl to mesa/main (v2)Chad Versace2013-01-243-20/+4
| | | | | | | | | | | | | Move round_to_even's definition to mesa/main so that _mesa_float_to_half() can use it in order to eliminate rounding bias. In additon to moving the fuction definition, prefix its name with "_mesa", just as all other functions in mesa/main are prefixed. v2: Fix Android build. Reviewed-by: Ian Romanick <[email protected]> Signed-off-by: Chad Versace <[email protected]>
* glsl/standalone_scaffolding: Add stub for _mesa_warning()Chad Versace2013-01-242-0/+21
| | | | | | | | | | | | | A subsequent patch will add mesa/main/imports.c as a dependency to the compiler, which in turn requires that _mesa_warning() be defined. The real definition of _mesa_warning() is in mesa/main/errors.c, but to pull that file into the standalone scaffolding would require transitively pulling in the dispatch tables. Reviewed-by: Ian Romanick <[email protected]> Acked-by: Paul Berry <[email protected]> Signed-off-by: Chad Versace <[email protected]>
* glsl: Extend ir_expression_operation for GLSL 3.00 pack/unpack functions (v2)Chad Versace2013-01-243-0/+84
| | | | | | | | | | | | | | | | | For each function {pack,unpack}{Snorm,Unorm,Half}2x16, add a corresponding opcode to enum ir_expression_operation. Validate the new opcodes in ir_validate.cpp. Also, add opcodes for scalarized variants of the Half2x16 functions. (The code generator for the i965 fragment shader requires that all vector operations be scalarized. A lowering pass, to be added later, will scalarize the Half2x16 functions). v2: Fix assertion message in ir_to_mesa [for idr]. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Matt Tuner <[email protected]> Signed-off-by: Chad Versace <[email protected]>
* glsl: Add IR lisp for GLSL ES 3.00 pack/unpack functionsChad Versace2013-01-247-7/+43
| | | | | | | | | | | | | | For each of the following functions, add a declaration to builtins/profiles/300es.glsl and create new file builtins/ir/${funcname}.ir: packSnorm2x16 unpackSnorm2x16 packUnorm2x16 unpackUnorm2x16 packHalf2x16 unpackHalf2x16 Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Matt Tuner <[email protected]> Signed-off-by: Chad Versace <[email protected]>
* glsl: Fix typo in commentChad Versace2013-01-241-1/+1
| | | | | | | | | s/num_operands()/get_num_operands()/ Discovered because Eclipse failed to resolve the false reference. Reviewed-by: Ian Romanick <[email protected]> Signed-off-by: Chad Versace <[email protected]>
* glsl: Allow varying structs in GLSL ES 3.00 and GLSL 1.50.Paul Berry2013-01-241-4/+4
| | | | | | | | | | | | | | | | | | | | Previously I thought that varying structs had been added to GLSL ES 3.00 by mistake, because chapter 11 of the GLSL ES 3.00 spec ("Counting of Inputs and Outputs") failed to mention how structs should be handled. Khronos has clarified (https://cvs.khronos.org/bugzilla/show_bug.cgi?id=9828) that varying structs are indeed required, and that chapter 11 will be modified to indicate that the minimal reference packing algorithm flattens varying structs to their individual components. Mesa doesn't flatten varying structs to their individual components, but this is ok, since it packs varyings of all kinds with no wasted space at all (except where this is impossible due to differing interpolation modes), so it will outperform the minimal reference packing algorithm in all but the most pathological cases. Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* glsl: Disable transform feedback of varying structs.Paul Berry2013-01-241-1/+10
| | | | | | | | | | | | | | | | | | | | | | It is not clear from the GLSL ES 3.00 spec how transform feedback is supposed to apply to varying structs: - There is no specification for how the structure is to be packed when it is recorded into the transform feedback buffer. - There is no reasonable value for GetTransformFeedbackVarying to return as the "type" of the variable. We currently have a Khronos bug requesting clarification on how this feature is supposed to work (https://cvs.khronos.org/bugzilla/show_bug.cgi?id=9856). This patch just disables transform feedback of varying structs for now; we can implement the proper behaviour once we find out from Khronos what it is. Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Eric Anholt <[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: Generalize compute_packing_order for varying structs.Paul Berry2013-01-241-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch paves the way for allowing varying structs by generalizing varying_matches::compute_packing_order to handle any type of varying. Previously, we packed in the order (vec4, vec2, float, vec3), with matrices being packed according to the size of their columns. Now, we pack everything according to its number of components mod 4, in the order (0, 2, 1, 3). There is no behavioural change for vectors. Matrices are now packed slightly differently: - mat2x2 gets assigned PACKING_ORDER_VEC4 instead of PACKING_ORDER_VEC2. This is slightly better, because it guarantees that the matrix occupies a single varying slot. - mat2x3 gets assigned PACKING_ORDER_VEC2 instead of PACKING_ORDER_VEC3. This is kind of a wash. Previously, mat2x3 had a 25% chance of having neither of its columns double parked, a 50% chance of having exactly one of its columns double parked, and a 25% chance of having both of its columns double parked. Now it always has exactly one of its columns double parked. - mat3x3 gets assigned PACKING_ORDER_SCALAR instead of PACKING_ORDER_VEC3. This doesn't affect much, since in both cases there is no guarantee of how the matrix will be aligned. - mat4x2 gets assigned PACKING_ORDER_VEC4 instead of PACKING_ORDER_VEC2. This is slightly better for the same reason as in mat2x2. - mat4x3 gets assigned PACKING_ORDER_VEC4 instead of PACKING_ORDER_VEC3. This is slightly better for the same reason as in mat2x2. Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* glsl: Disable structure splitting for shader ins/outs.Paul Berry2013-01-241-1/+2
| | | | | | | | | | | | Previously, it didn't matter whether structure splitting tried to split shader ins/outs, because structs were prohibited from being used for shader ins/outs. However, GLSL 3.00 ES supports varying structs. In order for varying structs to work, we need to make sure that structure splitting doesn't get applied to them, because if it does, then the linker won't be able to match up varyings properly. 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-2424-163/+179
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: Clean up case statement in builtin_variables.cpp's add_variable.Paul Berry2013-01-241-2/+4
| | | | | | | | | | | The case statement purported to handle the addition of ir_var_const_in and ir_var_inout builtin variables. But no such variables exist. This patch removes the unnecessary cases, and adds a comment explaining why they're not needed. Reviewed-by: Carl Worth <[email protected]> Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* glsl/build: Build libglcpp and libglslcore in builtin_compilerMatt Turner2013-01-222-45/+34
| | | | | | And reuse them if not cross compiling. Tested-by: Andreas Boll <[email protected]>
* glsl/Makefile.sources: Correct BUILTIN_COMPILER_CXX_FILESMatt Turner2013-01-223-5/+4
| | | | | | | | | | | | | | | Squashed with two reverts: Revert "android: Update for builtin_stubs.cpp move" This reverts commit c0def90ede1e939173041b8785303de90f8fdc6c. Revert "scons: Update for builtin_stubs.cpp" This reverts commit 8ac4b82699ad0a59ae6ae6d3415702eaa5d4fe3b. Tested-by: Andreas Boll <[email protected]> Tested-on-Android-by: Chad Versace <[email protected]>
* builtin_compiler/build: Use generated parser filesMatt Turner2013-01-221-15/+4
| | | | | | ... instead of generating them again. Tested-by: Andreas Boll <[email protected]>
* glsl/build: Build tests via the glsl MakefileMatt Turner2013-01-223-39/+44
| | | | Tested-by: Andreas Boll <[email protected]>
* glsl/build: Build glcpp via the glsl MakefileMatt Turner2013-01-225-87/+90
| | | | | | Removing the subdirectory recursion provides a small speed up. Tested-by: Andreas Boll <[email protected]>
* glsl/build: Don't build builtin_compiler separately if not cross compilingMatt Turner2013-01-222-2/+28
| | | | | | | Reduces the number of times that src/glsl/ is compiled when not cross compiling. Tested-by: Andreas Boll <[email protected]>
* glsl/build: Don't build glsl_compilerMatt Turner2013-01-221-9/+0
| | | | | | Use glslparsertest from piglit instead. Tested-by: Andreas Boll <[email protected]>
* 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]>