summaryrefslogtreecommitdiffstats
path: root/src/glsl
Commit message (Collapse)AuthorAgeFilesLines
* glsl/tests: Add .gitignore for uniform initialization unit test.Paul Berry2012-05-231-0/+1
| | | | Reviewed-by: Ian Romanick <[email protected]>
* glsl/constant propagation: kill whole var if LHS involves array indexing.Paul Berry2012-05-231-1/+20
| | | | | | | | | | | | | | | | | | | | | | | | When considering which components of a variable were killed by an assignment, constant propagation would previously just use the write mask of the assignment. This worked if the LHS of the assignment was simple, e.g.: v.xy = ...; // (assign (xy) (var_ref v) ...) But it did the wrong thing if the LHS of the assignment involved an array indexing operator, since in this case the write mask is always (x): v[i] = ...; // (assign (x) (deref_array (var_ref v) (var_ref i)) ...) In general, we can't predict which vector component will be selected by array indexing, so the only safe thing to do in this case is to kill the entire variable. Fixes piglit tests {fs,vs}-vector-indexing-kills-all-channels.shader_test. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* glsl/tests: Add test for uniform initialization by the linkerIan Romanick2012-05-235-1/+1186
| | | | | | | | v2: Put unit tests in src/glsl/tests rather than tests/glsl. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Acked-by: Kenneth Graunke <[email protected]>
* glsl: Propagate sampler uniform initializers to gl_shader_program::SamplerUnitsIan Romanick2012-05-231-0/+9
| | | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Initialize samplers to 0, propagate sampler values to the gl_programIan Romanick2012-05-231-3/+10
| | | | | | | | | | | | | The spec requires that samplers be initialized to 0. Since this differs from the 1-to-1 mapping of samplers to texture units assumed by ARB assembly shaders (and the gl_program structure), be sure to propagate this date from the gl_shader_program to the gl_program. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> CC: Vadim Girlin <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=49088
* glsl: Set initial values for uniforms in the linkerIan Romanick2012-05-234-0/+178
| | | | | | | | | | | | | | v2: Fix handling of arrays-of-structure. Thanks to Eric Anholt for pointing this out. v3: Minor comment change based on feedback from Ken. Fixes piglit glsl-1.20/execution/uniform-initializer/fs-structure-array and glsl-1.20/execution/uniform-initializer/vs-structure-array. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Drop the extra NULL specifiction on ir_assignment constructors.Eric Anholt2012-05-171-21/+14
| | | | | | | | It's an implied argument, and I don't think being explicit about it helps. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Fix assertion failure on handling switch on uint expressions.Eric Anholt2012-05-171-1/+1
| | | | | | | Fixes piglit glsl-1.30/execution/switch/fs-uint. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Reject non-scalar switch expressions.Eric Anholt2012-05-171-4/+2
| | | | | | | | | | The comment quotes spec saying that only scalar integers are allowed, but we only checked for integer. Fixes piglit switch-expression-const-ivec2.vert Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Let the constructor figure out the types of switch-related expressions.Eric Anholt2012-05-171-4/+1
| | | | | | | I noticed this while unindenting the code. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Fix indentation of switch code.Eric Anholt2012-05-171-282/+263
| | | | | | | I managed to completely trash it in 22d81f15. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Improve the local dead code optimization to eliminate unused channels.Eric Anholt2012-05-171-23/+126
| | | | | | | | | | | | | | | Total instructions: 261582 -> 261316 135/2147 programs affected (6.3%) 36752 -> 36486 instructions in affected programs (0.7% reduction) This excludes a tropics shader that now gets 16-wide mode and throws off the numbers. 5 shaders are hurt: two extra MOVs in 4 tropics shaders it looks like because we don't split register names according to independent webs, and one gstreamer shader where it looks like try_rewrite_rhs_to_dst() is falling on its face. This should also help avoid a regression in VSes from idr's ARB programs to GLSL work.
* glsl: Fix lower_discard_flow prototype mismatch.José Fonseca2012-05-151-1/+1
| | | | Should fix MSVC link failure.
* glsl: Implement the GLSL 1.30+ discard control flow rule in GLSL IR.Eric Anholt2012-05-144-0/+157
| | | | | | | Previously, I tried implementing this in the i965 driver, but did so in a way that violated the intent of the spec, and broke Tropics. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Remove the opt_discard_simplification pass.Eric Anholt2012-05-144-209/+0
| | | | | | | This conflicts with the GLSL 1.30+ rules for derivatives after a discard has occurred. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Change built-in constant expression evaluation to run the IR.Olivier Galibert2012-05-082-380/+156
| | | | | | | | This removes code duplication with ir_expression::constant_expression_value and builtins/ir/*. Signed-off-by: Olivier Galibert <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Add an origin pointer in the function signature object.Olivier Galibert2012-05-083-0/+5
| | | | | | | | This points to the object with the function body, allowing us to map from a built-in prototype to the actual body with IR code to execute. Signed-off-by: Olivier Galibert <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Add methods to copy parts of one ir_constant into another.Olivier Galibert2012-05-082-0/+114
| | | | | | | | | | | | | | | - copy_masked_offset copies part of a constant into another, assign-like. - copy_offset copies a constant into (a subset of) another, funcall-return like. These methods are to be used to trace through assignments and function calls when computing a constant expression. Signed-off-by: Olivier Galibert <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]> [v1]
* glsl: Add a constant_referenced method to ir_dereference*Olivier Galibert2012-05-082-0/+128
| | | | | | | | | | The method is used to get a reference to an ir_constant * within the context of evaluating an assignment when calculating a constant_expression_value. Signed-off-by: Olivier Galibert <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]> [v1]
* glsl: Add a variable context to constant_expression_value().Olivier Galibert2012-05-083-31/+44
| | | | | | Signed-off-by: Olivier Galibert <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]> [v1]
* glsl: Extend ir_constant::zero to handle more types.Olivier Galibert2012-05-081-1/+16
| | | | | | Signed-off-by: Olivier Galibert <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]> [v1]
* glsl: Fix broken constant expression handling for <, <=, >, and >=.Kenneth Graunke2012-05-081-9/+9
| | | | | | | | | | | | | We were looping over all the vector components, but only dealing with the first one. This was masked by the fact that constant expression handling on built-ins went through custom code for the lessThan() /function/ rather than the ir_binop_less expression operator. NOTE: This is a candidate for all release branches. Reviewed-by: Ian Romanick <[email protected]> Signed-off-by: Olivier Galibert <[email protected]> Signed-off-by: Kenneth Graunke <[email protected]>
* glsl: Fix regression in function out-parameter lvalue detection.Eric Anholt2012-05-041-14/+14
| | | | | | | | | | When doing the var->assigned change in f2475ca424f7e001be50f64dafa5700f6603d684, I overzealously indented the second block of code into the "if (var)" test. Revert these blocks to the way they were before, just taking advantage of "var" to avoid re-calling variable_referenced(). Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=49066
* glsl: Don't consider unused FS out variables as being statically assigned.Eric Anholt2012-05-041-3/+3
| | | | | | | | I only considered var->assigned for FragColor and FragData, but ignored when it was false for out vars. Fixes piglit write-gl_FragColor-and-not-user-output.frag Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=49068
* glsl: Always copy the index when cloning a variable.Eric Anholt2012-05-041-6/+1
| | | | | | | | The index is also used for GL_ARB_blend_func_extended. Cloning in i965 was dropping a non-ARB_explicit_attrib_location index. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Dave Airlie <[email protected]>
* glsl: report errors via GL_ARB_debug_outputDylan Noblesmith2012-05-023-0/+21
| | | | Reviewed-by: Brian Paul <[email protected]>
* glsl: add gl_context memberDylan Noblesmith2012-05-022-2/+4
| | | | Reviewed-by: Brian Paul <[email protected]>
* glsl: consolidate error/warning codeDylan Noblesmith2012-05-021-14/+23
| | | | | | | | And lay the groundwork for GL_ARB_debug_output. v2: Add descriptive comments. Reviewed-by: Brian Paul <[email protected]>
* glsl: Remove some completed tasks from the old "TODO" file.Kenneth Graunke2012-05-011-13/+1
|
* glsl: Initialize member variable in ir_copy_propagation_elements_visitor.Vinson Lee2012-04-301-0/+1
| | | | | | | Fix uninitialized scalar field defect reported by Coverity. Signed-off-by: Vinson Lee <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* glsl: Remove unused member predicate from ir_dead_functions_visitor.Vinson Lee2012-04-281-2/+0
| | | | | | | Fix uninitialized pointer field defect reported by Coverity. Signed-off-by: Vinson Lee <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Remove unused member mem_ctx from ir_dead_functions_visitor.Vinson Lee2012-04-261-1/+0
| | | | | | | Fix uninitialized pointer field defect reported by Coverity. Signed-off-by: Vinson Lee <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Add implementation of inverse() for mat2/3/4.Eric Anholt2012-04-243-1/+111
| | | | | | | | | | | | This is taken from the ogl-math project, with Inverse renamed to adj (since it's not actually the inverse), transposed, and our types plugged in. There are potential CSE opportunities in this code (particularly for hardware with RCP but not DIV), but we should be doing CSE anyway, so don't hand-optimize. Fixes piglit inverse tests. Acked-by: Kenneth Graunke <[email protected]>
* glsl: Add support for generating builtin code from GLSL instead of IR.Eric Anholt2012-04-241-4/+16
| | | | | | | | This takes advantage of the builtin compiler to generate IR into a string, the same way we read GLSL for function prototypes for our profiles. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Make ir_reader parse the "temporary" variable qualifier.Eric Anholt2012-04-241-0/+2
| | | | | | | This lets ir_reader eat the output of builtin_compiler on actual function definitions. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Add doxygen explaining what main.cpp is for.Eric Anholt2012-04-241-0/+9
| | | | | | | I keep getting lost in the Makefile trying to figure out what to edit to work on builtin_compiler or glsl_compiler. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Properly throw compile-time errors for conflicting FS output writes.Eric Anholt2012-04-191-0/+66
| | | | | | | | | | | We were checking for these at link time previously, which is not as early as mandated, and would actually fail to detect conflicting writes if dead code removal removed some writes. Fixes failures in piglit glsl-*/compiler/fragment-outputs/write-gl_Frag* Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Track in each ir_variable whether it was ever assigned.Eric Anholt2012-04-193-13/+33
| | | | | | | This will be used for some compile-and-link-time error checking, where currently we've been doing error checking only at link time. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Convert the tests directory to automake.Eric Anholt2012-04-192-0/+3
| | | | | | | | | | | This runs optimization-test and produces the usual automake test output, which may be interesting to automated build systems. This doesn't convert the tests to be individually exposed to the automake runner, because automake doesn't like wildcards (due to being nonportable in make, not that we care). Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Fix up some comments in structure splitting, based on array-split work.Eric Anholt2012-04-191-3/+8
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Don't allow array splitting on function arguments.Eric Anholt2012-04-191-1/+17
| | | | | | | | | | | This is the reason the declaration member existed in the reference visitor, but I didn't copy the code from structure splitting that avoided setting it. This wasn't currently a problem, because we don't allow splitting of in/out variables. But that would be nice to change some day. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Rename the "whole_array_access" member in array splitting.Eric Anholt2012-04-191-11/+15
| | | | | | | This was carried over from structure splitting, without thinking about whether the name still made sense in this context. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Fix up a comment explaining what a visitor class does.Eric Anholt2012-04-191-1/+4
| | | | | | | Ken noted that some of the "actual work" was happening in the caller of this class. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Use the column_types() helper method.Eric Anholt2012-04-191-2/+1
| | | | | | Ken noted this in a review of this patch that I pushed early. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Remove unused mem_ctx field from ir_array_splitting_visitor.Kenneth Graunke2012-04-181-1/+0
| | | | | | | | Vinson reported that we failed to initialize this, which would lead to all kinds of crashes if we actually used it. Since we don't use it, we may as well just delete the broken code. Signed-off-by: Kenneth Graunke <[email protected]>
* glsl/builtins: Rework profiles to use the new '.glsl' common suffix.Kenneth Graunke2012-04-1720-4807/+1902
| | | | | | | | | | | | | | | | | | | | Deletes a lot of pointless duplication, as well as some run-time effort. Conveniently, GLSL 1.40 no longer needs a .vert variant, since it doesn't define any built-ins specific to the vertex shader stage. ARB_texture_rectangle and OES_EGL_image_external also only need a single profile, since the .vert and .frag variants were identical. I didn't bother with EXT_texture_array and OES_texture_3D because they're so tiny that the savings would be miniscule. Cuts the generated builtin_function.cpp from 1.7MB to 1.0MB (41%). Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Acked-by: Ian Romanick <[email protected]>
* glsl/builtins: Support stage-agnostic built-in profiles.Kenneth Graunke2012-04-171-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The built-in subsystem uses "profiles," or GLSL shaders containing prototypes for all built-ins supported within a particular language version (or extension) and shader stage. Since profiles were stage-specific, we had to cut and paste almost all the prototypes between (e.g.) 110.vert and 110.frag. Naturally, this led to sundry cut and paste bugs, where someone fixed an issue in .frag but neglected to update .vert, or vice-versa. Geometry shaders would have only made this worse. This patch introduces support for a new '.glsl' profile suffix which contains prototypes common to all shader stages. The existing '.frag' and '.vert' profiles need only contain the few stage-specific built-ins. Not only does this remove duplication, it makes built-in setup slightly faster: we don't need to re-read the common prototypes and function bodies for both the vertex and fragment shader stage. Internally, this was trivial. We already create a list of gl_shader objects to search through for built-ins: one for the core language version/stage, and additional shaders for any extensions in use. This patch simply adds another shader to the list: core/common, core/stage, and extensions. The next patch will update the profiles to remove the duplication. It's separated out purely to make review easier. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Acked-by: Ian Romanick <[email protected]>
* glsl: Make the standalone compiler accept '.glsl' files.Kenneth Graunke2012-04-171-1/+1
| | | | | | | | | | These ought to be treated as 'any stage', but for now, they're just treated as vertex shaders. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Acked-by: Ian Romanick <[email protected]>
* glsl/builtins: Use ivec for texel offsets in textureProjGradOffset.Kenneth Graunke2012-04-173-4/+4
| | | | | | | | | | | | | | | | | The GLSL 1.30 -> 4.10 specs all erroneously say "vec2" for a few overloads of textureProjGradOffset, while most overloads and all other texturing functions use ivec types. The GLSL 4.20 specification corrects these to "ivec2", but doesn't mention this as being a conscious change in behavior. Nor does the ARB_shading_language_420pack extension. So presumably it was a typo. At any rate, our builtin functions all use ivec already, so the fact that these prototypes use plain vecs will only lead to applications dying in a fire when trying to use them. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* Revert "glsl: Refuse to link GLSL 1.40+ shaders that would use fixed function."Eric Anholt2012-04-161-14/+0
| | | | | | | | | | | | | | | | | | | | | This reverts commit 4ec449a6ed1d2cea3bf83d6518b3b352ce5daceb. I meant to not push this one. Review found that a link error is not mandated: it should link, but you get undefined rendering if you rely on a missing stage. page 42/55 section 2.11 "Vertex Shaders": "If the program object has no vertex shader, or no program object is currently in use, the results of vertex shader execution are undefined." (and similar for page 160/173 section 3.9 "Fragment Shaders" for FS, and page 45/58 section 2.11.2 "Program Objects" for program being 0) It turns out the commit was broken anyway, because it was missing a "goto done", so linkstatus got smashed back to true later and the error just showed up as a warning in the infolog.