summaryrefslogtreecommitdiffstats
path: root/src/glsl
Commit message (Collapse)AuthorAgeFilesLines
* glcpp: Make sure GL_AMD_shader_trinary_minmax is definedIan Romanick2014-01-271-3/+2
| | | | | | | | | | | The define was only available if gl_extensions::AMD_shader_trinary_minmax was set, but no driver set it. Since the extension is advertised by default, remove that field too. Signed-off-by: Ian Romanick <[email protected]> Cc: Maxence Le Doré <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Simplify built-in generator functions for min3/max3/mid3.Kenneth Graunke2014-01-241-77/+60
| | | | | | | | | The type of all three parameters are identical, so we don't need to specify it three times. The predicate is always identical too, so we don't need to make it a parameter, either. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Fix chained assignments of vector channels.Kenneth Graunke2014-01-241-1/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Simple shaders such as: void splat(vec2 v, float f) { v[0] = v[1] = f; } failed to compile with the following error: error: value of type vec2 cannot be assigned to variable of type float First, we would process v[1] = f, and transform: LHS: (expression float vector_extract (var_ref v) (constant int (1))) RHS: (var_ref f) into: LHS: (var_ref v) RHS: (expression vec2 vector_insert (var_ref v) (constant int (1)) (var_ref f)) Note that the LHS type is now vec2, not a float. This is surprising, but not the real problem. After emitting assignments, this ultimately becomes: (declare (temporary) vec2 assignment_tmp) (assign (xy) (var_ref assignment_tmp) (expression vec2 vector_insert (var_ref v) (constant int (1)) (var_ref f))) (assign (xy) (var_ref v) (var_ref assignment_tmp)) We would then return (var_ref assignment_tmp) as the rvalue, which has the wrong type---it should be float, but is instead a vec2. To fix this, we simply return (vector_extract (var_ref assignment_temp) <the appropriate channel>) to pull out the desired float value. Fixes Piglit's chained-assignment-with-vector-constant-index.vert and chained-assignment-with-vector-dynamic-index.vert tests. Cc: [email protected] Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=74026 Reported-by: Dan Ginsburg <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]> Signed-off-by: Kenneth Graunke <[email protected]>
* glsl: Rename "expr" to "lhs_expr" in vector_extract munging code.Kenneth Graunke2014-01-241-6/+6
| | | | | | | | | | | When processing assignments, we have both an LHS and RHS. At a glance, "lhs_expr" clearly refers to the LHS, while a generic name like "expr" is ambiguous. Cc: [email protected] Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]> Signed-off-by: Kenneth Graunke <[email protected]>
* glcpp: Define GL_EXT_shader_integer_mix in both GL and ES.Matt Turner2014-01-231-3/+5
| | | | | Cc: [email protected] Reviewed-by: Ian Romanick <[email protected]>
* glcpp: Remove unused gl_api bits.Matt Turner2014-01-232-2/+0
| | | | Reviewed-by: Ian Romanick <[email protected]>
* glcpp: Set extension defines after resolving the GLSL version.Matt Turner2014-01-233-143/+172
| | | | | | | | | | | | | | | | | | | | | | Instead of defining preprocessor macros in glcpp_parser_create based on the GL API, wait until the shader version has been resolved. Doing this allows us to correctly set (and not set) preprocessor macros for extensions allowed by the API but not the shader, as in the case of ARB_ES3_compatibility. The shader version has been resolved when the preprocessor encounters the first preprocessor token, since the GLSL spec says "The #version directive must occur in a shader before anything else, except for comments and white space." Specifically, if a #version token is found the version is known explicitly, and if any other preprocessor token is found then the GLSL version is implicitly 1.10. Cc: [email protected] Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=71630 Reviewed-by: Ian Romanick <[email protected]>
* glsl: Disable ARB_texture_rectangle in shader version 100.Anuj Phogat2014-01-231-0/+4
| | | | | | | | | | | | | OpenGL with ARB_ES2_compatibility allows shaders that specify #version 100. This fixes the Khronos OpenGL test(Texture_Rectangle_Samplers_frag.test) failure. Cc: [email protected] Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Signed-off-by: Anuj Phogat <[email protected]>
* glsl: Mark GLSL 4.40 as a known version.Matt Turner2014-01-231-1/+1
| | | | Reviewed-by: Ian Romanick <[email protected]>
* glsl: silence a couple warnings in find_active_atomic_counters()Brian Paul2014-01-231-1/+2
| | | | | | | Silence unitialized variable 'id' warning. Silence unused 'found' warning. Only seen in release builds. Reviewed-by: Marek Olšák <[email protected]>
* glsl: remove remaining is_array variablesTimothy Arceri2014-01-235-59/+35
| | | | | | | | | Previously the reason we needed is_array was because we used array_size == NULL to represent both non-arrays and unsized arrays. Now that we use a non-NULL array_specifier to represent an unsized array, is_array is redundant. Signed-off-by: Timothy Arceri <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: create type name for arrays of arraysTimothy Arceri2014-01-231-2/+14
| | | | | | | | We need to insert outermost dimensions in the correct spot otherwise the dimension order will be backwards Signed-off-by: Timothy Arceri <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: Allow arrays of arrays as input to vertex shaderTimothy Arceri2014-01-231-2/+3
| | | | | Signed-off-by: Timothy Arceri <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: only call mark_max_array if we are assigning anTimothy Arceri2014-01-231-2/+4
| | | | | | | | | | array This change does not help fix or prevent any bugs it just seems reasonable to do Signed-off-by: Timothy Arceri <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: Add ARB_arrays_of_arrays support to yacc definition and astTimothy Arceri2014-01-237-173/+235
| | | | | | | Adds array specifier object to hold array information Signed-off-by: Timothy Arceri <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* mesa: Add ARB_arrays_of_arraysTimothy Arceri2014-01-231-0/+3
| | | | | Signed-off-by: Timothy Arceri <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: Simplify aggregate type inference to prepare for ARB_arrays_of_arrays.Paul Berry2014-01-225-148/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Most of the time it is not necessary to perform type inference to compile GLSL; the type of every expression can be inferred from the contents of the expression itself (and previous type declarations). The exception is aggregate initializers: their type is determined by the LHS of the variable being assigned to. For example, in the statement: mat2 foo = { { 1, 2 }, { 3, 4 } }; the type of { 1, 2 } is only known to be vec2 (as opposed to, say, ivec2, uvec2, int[2], or a struct) because of the fact that the result is being assigned to a mat2. Previous to this patch, we handled this situation by doing some type inference during parsing: when parsing a declaration like the one above, we would call _mesa_set_aggregate_type(), which would infer the type of each aggregate initializer and store it in the corresponding ast_aggregate_initializer::constructor_type field. Since this happened at parse time, we couldn't do the type inference using glsl_type objects; we had to use ast_type_specifiers, which are much more awkward to work with. Things are about to get more complicated when we add support for ARB_arrays_of_arrays. This patch simplifies things by postponing the call to _mesa_set_aggregate_type() until ast-to-hir time, when we have access to glsl_type objects. As a side benefit, we only need to have one call to _mesa_set_aggregate_type() now, instead of six. Reviewed-by: Matt Turner <[email protected]>
* glsl/linker: Refactor in preparation for adding more shader stages.Paul Berry2014-01-211-75/+41
| | | | | | | | | | | | | Rather than maintain separately named arrays and counts for vertex, geometry, and fragment shaders, just maintain these as arrays indexed by the gl_shader_type enum. v2: When there is neither a vertex nor a geometry shader, set prog->LastClipDistanceArraySize = 0, and clarify that the values is not used. Reviewed-by: Chris Forbes <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* glsl: Optimize open-coded lrp into lrp.Jordan Justen2014-01-211-0/+52
| | | | | | | | | | total instructions in shared programs: 1498191 -> 1487051 (-0.74%) instructions in affected programs: 669388 -> 658248 (-1.66%) GAINED: 1 LOST: 0 Reviewed-by: Matt Turner <[email protected]> Signed-off-by: Jordan Justen <[email protected]>
* glsl: Vectorize multiple scalar assignmentsMatt Turner2014-01-214-0/+325
| | | | | | | | | | Reduces vertex shader instruction counts in DOTA2 by 6.42%, L4D2 by 4.61%, and CS:GO by 5.71%. total instructions in shared programs: 1500153 -> 1498191 (-0.13%) instructions in affected programs: 59919 -> 57957 (-3.27%) Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add parameter to .equals() to ignore an IR type.Matt Turner2014-01-212-36/+38
| | | | | | | Only implemented for ir_swizzles currently, but perhaps will be useful for other IR types in the future. Reviewed-by: Ian Romanick <[email protected]>
* mesa: rename PreferDP4 to OptimizeForAOS.Matt Turner2014-01-211-1/+1
| | | | | | | | | This flag was really just a proxy for determining whether the backend was vector (AOS) or scalar (SOA). It will be used to apply a future optimization only for vector backends. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Match unnamed record types across stages.Grigori Goronzy2014-01-211-0/+4
| | | | | | | | | | | | | | Unnamed record types are assigned to separate types per stage, e.g. if uniform struct { ... } a; is defined in both vertex and fragment shader, two separate types will result with different names. When linking the shader, this results in a type conflict. However, there is no reason why this should not be allowed according to GLSL specifications. Compare and match record types when linking shader stages to avoid this conflict. Reviewed-by: Matt Turner <[email protected]>
* glsl: Extract function for record comparisons.Grigori Goronzy2014-01-212-30/+44
| | | | Reviewed-by: Matt Turner <[email protected]>
* glsl: Add gl_ViewportIndex built-in variableCourtney Goeltzenleuchter2014-01-201-0/+2
| | | | | | | | v2 (idr): Fix copy-and-paste bug... s/LAYER/VIEWPORT/ Signed-off-by: Courtney Goeltzenleuchter <[email protected]> Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Add extension infrastructure for ARB_viewport_arrayIan Romanick2014-01-204-0/+7
| | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Remove exec_list iterators now that nothing uses them.Kenneth Graunke2014-01-132-88/+0
| | | | | | Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Replace iterators in ir_reader.cpp with ad-hoc list walking.Kenneth Graunke2014-01-131-8/+10
| | | | | | | | | These can't use foreach_list since they want to skip over the first few list elements. Just doing the ad-hoc list walking isn't too bad. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Use a new foreach_two_lists macro for walking two lists at once.Kenneth Graunke2014-01-1311-78/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When handling function calls, we often want to walk through the list of formal parameters and list of actual parameters at the same time. (Both are guaranteed to be the same length.) Previously, we used a pattern of: exec_list_iterator 1st_iter = <1st list>.iterator(); foreach_iter(exec_list_iterator, 2nd_iter, <2nd list>) { ... 1st_iter.next(); } This was awkward, since you had to manually iterate through one of the two lists. This patch introduces a foreach_two_lists macro which safely walks through two lists at the same time, so you can simply do: foreach_two_lists(1st_node, <1st list>, 2nd_node, <2nd list>) { ... } v2: Rename macro from foreach_list2 to foreach_two_lists, as suggested by Ian Romanick. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Statically cast parameter exec_node to ir_variable.Kenneth Graunke2014-01-131-1/+1
| | | | | | | | | Formal function parameters are always ir_variable objects, not an arbitrary ir_instruction. So there's no need to dynamically cast here. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Cast ir_call parameters to ir_rvalue, not ir_instruction.Kenneth Graunke2014-01-134-6/+6
| | | | | | | | | | A function call's parameters are always rvalues. ir_rvalue may not always be a subclass of ir_instruction in the future, so we should use the right one. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Convert piles of foreach_iter to foreach_list_safe.Kenneth Graunke2014-01-1312-36/+36
| | | | | | | | | In these cases, we edit the list (or at least might be), so we use the foreach_list_safe variant. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Convert piles of foreach_iter to the newer foreach_list macro.Kenneth Graunke2014-01-1323-120/+113
| | | | | | | | | | | | | foreach_iter and exec_list_iterators have been deprecated for some time now; we just hadn't ever bothered to convert code to the newer foreach_list and foreach_list_safe macros. In these cases, we aren't editing the list, so we can use foreach_list rather than foreach_list_safe. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Index into ctx->Const.Program[] rather than using ad-hoc code.Paul Berry2014-01-094-87/+17
| | | | | Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* mesa: replace ctx->Const.{Vertex,Fragment,Geomtery}Program with an array.Paul Berry2014-01-098-109/+109
| | | | | | | | | | | | | | | | | | | | These are replaced with ctx->Const.Program[MESA_SHADER_{VERTEX,FRAGMENT,GEOMETRY}]. In patches to follow, this will allow us to replace a lot of ad-hoc logic with a variable index into the array. With the exception of the changes to mtypes.h, this patch was generated entirely by the command: find src -type f '(' -iname '*.c' -o -iname '*.cpp' -o -iname '*.py' \ -o -iname '*.y' ')' -print0 | xargs -0 sed -i \ -e 's/Const\.VertexProgram/Const.Program[MESA_SHADER_VERTEX]/g' \ -e 's/Const\.GeometryProgram/Const.Program[MESA_SHADER_GEOMETRY]/g' \ -e 's/Const\.FragmentProgram/Const.Program[MESA_SHADER_FRAGMENT]/g' Suggested-by: Brian Paul <[email protected]> Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* mesa: Namespace qualify fma to override ambiguity with fma from math.hThomas Sondergaard2014-01-081-1/+1
| | | | | | | MSVC 2013 version of math.h includes an fma() function. Cc: "10.0" <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* mesa: Fix compile error with MSVC 2013Thomas Sondergaard2014-01-081-1/+1
| | | | | | | | | This fixes the following compile error: src\glsl\ir_constant_expression.cpp(1405) : error C2666: 'copysign' : 3 overloads have similar conversions Cc: "10.0" <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* mesa: Remove _mesa_progshader_enum_to_string(), which is no longer used.Paul Berry2014-01-082-32/+0
| | | | | Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* glsl: Make more use of gl_shader_stage enum in ir_set_program_inouts.cpp.Paul Berry2014-01-082-15/+16
| | | | | Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* glsl: Make more use of gl_shader_stage enum in lower_clip_distance.cpp.Paul Berry2014-01-081-8/+8
| | | | | Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* glsl: Make more use of gl_shader_stage enum in link_varyings.cpp.Paul Berry2014-01-081-24/+24
| | | | | | | | Reviewed-by: Kenneth Graunke <[email protected]> v2: Also rename "shaderType" param of is_varying_var() to "stage". Reviewed-by: Brian Paul <[email protected]>
* glsl: Change _mesa_glsl_parse_state ctor to use gl_shader_stage enum.Paul Berry2014-01-085-11/+9
| | | | | | | | Reviewed-by: Kenneth Graunke <[email protected]> v2: Also rename "target" param to "stage". Reviewed-by: Brian Paul <[email protected]>
* mesa: Use gl_shader::Stage instead of gl_shader::Type where possible.Paul Berry2014-01-086-25/+25
| | | | | | | | | | | | | | | | | | | | | This reduces confusion since gl_shader::Type is sometimes GL_SHADER_PROGRAM_MESA but is more frequently GL_SHADER_{VERTEX,GEOMETRY,FRAGMENT}. It also has the advantage that when switching on gl_shader::Stage, the compiler will alert if one of the possible enum types is unhandled. Finally, many functions in src/glsl (especially those dealing with linking) already use gl_shader_stage to represent pipeline stages; using gl_shader::Stage in those functions avoids the need for a conversion. Note: in the process I changed _mesa_write_shader_to_file() so that if it encounters an unexpected shader stage, it will use a file suffix of "????" rather than "geom". Reviewed-by: Brian Paul <[email protected]> v2: Split from patch "mesa: Store gl_shader_stage enum in gl_shader objects." Reviewed-by: Kenneth Graunke <[email protected]>
* mesa: Store gl_shader_stage enum in gl_shader objects.Paul Berry2014-01-084-0/+4
| | | | | Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: make _mesa_shader_stage_to_string() available to non-C++ code.Paul Berry2014-01-081-8/+7
| | | | | | | | Reviewed-by: Brian Paul <[email protected]> v2: Split from patch "mesa: Store gl_shader_stage enum in gl_shader objects." Reviewed-by: Kenneth Graunke <[email protected]>
* mesa: Clean up nomenclature for pipeline stages.Paul Berry2014-01-0817-148/+148
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, we had an enum called gl_shader_type which represented pipeline stages in the order they occur in the pipeline (i.e. MESA_SHADER_VERTEX=0, MESA_SHADER_GEOMETRY=1, etc), and several inconsistently named functions for converting between it and other representations: - _mesa_shader_type_to_string: gl_shader_type -> string - _mesa_shader_type_to_index: GLenum (GL_*_SHADER) -> gl_shader_type - _mesa_program_target_to_index: GLenum (GL_*_PROGRAM) -> gl_shader_type - _mesa_shader_enum_to_string: GLenum (GL_*_{SHADER,PROGRAM}) -> string This patch tries to clean things up so that we use more consistent terminology: the enum is now called gl_shader_stage (to emphasize that it is in the order of pipeline stages), and the conversion functions are: - _mesa_shader_stage_to_string: gl_shader_stage -> string - _mesa_shader_enum_to_shader_stage: GLenum (GL_*_SHADER) -> gl_shader_stage - _mesa_program_enum_to_shader_stage: GLenum (GL_*_PROGRAM) -> gl_shader_stage - _mesa_progshader_enum_to_string: GLenum (GL_*_{SHADER,PROGRAM}) -> string In addition, MESA_SHADER_TYPES has been renamed to MESA_SHADER_STAGES, for consistency with the new name for the enum. Reviewed-by: Kenneth Graunke <[email protected]> v2: Also rename the "target" field of _mesa_glsl_parse_state and the "target" parameter of _mesa_shader_stage_to_string to "stage". Reviewed-by: Brian Paul <[email protected]>
* glsl: Optimize pow(2, x) --> exp2(x).Kenneth Graunke2014-01-071-0/+11
| | | | | | | | | | | | | | | | | On Haswell, POW takes 24 cycles, while EXP2 only takes 14. Plus, using POW requires putting 2.0 in a register, while EXP2 doesn't. I believe that EXP2 will be faster than POW on basically all GPUs, so it makes sense to optimize it. Looking at the savage2 subset of shader-db: total instructions in shared programs: 113225 -> 113179 (-0.04%) instructions in affected programs: 2139 -> 2093 (-2.15%) instances of 'math pow': 795 -> 749 (-6.14%) instances of 'math exp': 389 -> 435 (11.8%) Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Refactor is_zero/one/negative_one into an is_value() method.Kenneth Graunke2014-01-072-68/+23
| | | | | | | | | | | | | | | This patch creates a new generic is_value() method, which checks if an ir_constant has a particular value. (For vectors, it must have the single value repeated across all components.) It then rewrites the is_zero/is_one/is_negative_one methods to use this generic helper. All three were basically identical except for the value they checked for. The other difference is that is_negative_one rejects boolean types. The new is_value function maintains this behavior, only allowing boolean types when checking for 0 or 1. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Optimize pow(1.0, X) --> 1.0.Kenneth Graunke2014-01-071-0/+6
| | | | | | | Surprisingly, this helps one vertex shader in 3DMMES. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: rename min(), max() functions to fix MSVC buildBrian Paul2014-01-063-7/+7
| | | | | | | | Evidently, there's some other definition of "min" and "max" that causes MSVC to choke on these function names. Renaming to min2() and max2() fixes things. Reviewed-by: Kenneth Graunke <[email protected]>