aboutsummaryrefslogtreecommitdiffstats
path: root/src/glsl
Commit message (Collapse)AuthorAgeFilesLines
* scons: Add glsl/glcpp to the include path.Vinson Lee2012-06-231-2/+2
| | | | | | | | | | Fixes this build failure on Solaris. Compiling build/sunos-debug/glsl/glcpp/glcpp-lex.c ... "src/glsl/glcpp/glcpp-lex.l", line 30: cannot find include file: "glcpp-parse.h" Signed-off-by: Vinson Lee <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* glx/tests: Fix signed/unsigned comparison warnings.Paul Berry2012-06-201-1/+1
|
* glsl: Use ir_unop_f2u to convert floats to uints.Paul Berry2012-06-151-2/+1
| | | | | | | Fixes piglit tests spec/glsl-1.30/execution/{vs,fs}-float-uint-conversion on i965. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Add support for ir_unop_f2u to constant folding.Paul Berry2012-06-151-0/+6
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Add unary operation ir_unop_f2u.Paul Berry2012-06-153-0/+7
| | | | | | | | | | | | | | | Previously, we performed conversions from float->uint by a two step process: float->int->uint. However, on platforms that use saturating conversions (e.g. i965), this didn't work, because if the source value was larger than the maximum representable int (0x7fffffff), then converting it to an int would clamp it to 0x7fffffff. This patch just adds the new opcode; further patches will adapt optimization passes and back-ends to use it, and then finally the ast_to_hir logic will be modified to emit the new opcode. Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Fix pi/2 constant in acos built-in functionIan Romanick2012-06-131-4/+4
| | | | | | | | | | | | In single precision, 1.5707963 becomes 1.5707962513 which is too small. However, 1.5707964 becomes 1.5707963705 which is just right. The value 1.5707964 is already used in asin.ir. NOTE: This is a candidate for stable release branches. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Olivier Galibert <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: Transform dot product by a basis vector into a swizzleMatt Turner2012-06-122-3/+24
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Add is_basis functionMatt Turner2012-06-122-4/+70
| | | | | | | Determines whether it's a basis vector, i.e., a vector with one element equal to 1 and all other elements equal to 0. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Check for zero vectors in ir_binop_dotMatt Turner2012-06-121-0/+7
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* scons: Fix scons build.José Fonseca2012-06-111-0/+2
|
* glsl: Put a bunch of optimization visitors under anonymous namespaces.Eric Anholt2012-06-1115-0/+57
| | | | | | | | | | | | | | | | | Because these classes are used entirely from their own source files and not from separate DSOs, the linker gets to produce massively less code. This cuts about 13k of text in the libdricore case. In the non-libdricore case, the additional linkage information allows the compiler to inline some code, so libglsl.a size actually increases by about 300 bytes. For a dricore build, improves shader_runner runtime on glsl-fs-copy-propagation-texcoords-1 by 0.21% +/- 0.03% (n=353574, outliers removed). No statistically significant difference with n=322 on glslparsertest on a yofrankie shader intended to test compiler performance. Reviewed-by: Kenneth Graunke <[email protected]>
* automake: Merge the dricore libglsl build into libdricore.Eric Anholt2012-06-111-32/+3
| | | | | | | | | | | | | Now we have just one library of "all of Mesa core" instead of both libdricore and libglsl that drivers link against. I did this change in a sort of nonrecursive make fashion: the generated files are still produced in the non-automake build, like the rest of dricore, but the GLSL files are stuffed into libdricore without building a convenience library in src/glsl (even though we could now). This would make a bit more sense if glsl was just another dir under src/mesa, because right now I had to contort the prefix variable name to look another ../ level up.
* automake: Add a prefix variable for libglsl sources.Eric Anholt2012-06-113-86/+88
| | | | | See e86c40a84d241b954594f5ae7df9b9c3fc797a4e for reasoning. In the process I did s/:=/=/ to shut up automake about nonportable make syntax.
* glsl: Clean up warnings about deleting classes without virtual destructors.Eric Anholt2012-06-081-0/+10
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: fix deref_hash memory leak in constant_expression_valueMarcin Slusarz2012-06-081-2/+5
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* glcpp: .gitignore cleanupAndreas Boll2012-06-081-3/+0
| | | | | | *.o, *.lo and *~ are already in toplevel .gitignore Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Bitwise conversion operator support in ir_constant_expression.Olivier Galibert2012-06-071-0/+47
| | | | | | | | | A "test_out = floatBitsToUint(-1.0);" fired through the GLSL compiler gives a correct "(assign (x) (var_ref test_out) (constant uint (3212836864)))" Signed-off-by: Olivier Galibert <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Bitwise conversion operator support in ir_validate.Olivier Galibert2012-06-071-0/+16
| | | | | Signed-off-by: Olivier Galibert <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Bitwise conversion operator support in ir_expression.Olivier Galibert2012-06-071-0/+4
| | | | | Signed-off-by: Olivier Galibert <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: New unary opcodes for ARB_shader_bit_encoding support.Olivier Galibert2012-06-077-11/+125
| | | | | | | The opcodes are bitcast_f2u, bitcast_f2i, bitcast_i2f and bitcast_u2f. Signed-off-by: Olivier Galibert <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Scaffolding for ARB_shader_bit_encoding.Olivier Galibert2012-06-075-0/+8
| | | | | | | | That adds support for activating the extension. It doesn't actually *do* anything yet, of course. Signed-off-by: Olivier Galibert <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Hook up loop_variable_state destructor to plug a memory leak.Kenneth Graunke2012-06-071-0/+17
| | | | | | | | | | | | | While ~loop_state() is already freeing the loop_variable_state objects via ralloc_free(this->mem_ctx), the ~loop_variable_state() destructor was never getting called, so the hash table inside loop_variable_state was never getting destroyed. Fixes a memory leak in any shader with loops. NOTE: This is a candidate for stable release branches. Signed-off-by: Kenneth Graunke <[email protected]>
* glsl/builtins: Fix textureGrad() for Array samplers.Kenneth Graunke2012-06-051-3/+3
| | | | | | | | | | | | We were incorrectly assuming that the coordinate's dimensionality is equal to the gradient's dimensionality. For array types, the coordinate has one more component. Fixes 12 subcases of oglconform's glsl-bif-tex-grad test. NOTE: This is a candidate for stable release branches. Signed-off-by: Kenneth Graunke <[email protected]>
* Fix .gitignore for ralloc-testPaul Berry2012-06-041-1/+1
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Remove spurious printf messagesIan Romanick2012-06-011-3/+0
| | | | | | | | These look like debug messages from the switch-statement development. NOTE: This is a candidate for the 8.0 release branch. Signed-off-by: Ian Romanick <[email protected]>
* glsl/tests: Plumb $(PYTHON2) and $(PYTHON_FLAGS) into optimization-test.Kenneth Graunke2012-05-302-2/+6
| | | | | | | | | | | | | | | | | | Some distributions (like Arch Linux) make /usr/bin/python Python 3, rather than Python 2. Since compare_ir uses /usr/bin/env python, such systems will fail to run optimization-test, causing 'make check' to always fail. Automake's TESTS_ENVIRONMENT variable provides a mechanism to run programs or set environment variables in the test environment. Ideally, I think we would want to use AM_TESTS_ENVIRONMENT, since TESTS_ENVIRONMENT is supposed to be user-overridable. However, it isn't supported using the default/serial test runner. Fixes 'make check' on Arch Linux and Gentoo. Signed-off-by: Kenneth Graunke <[email protected]> Acked-by: Matt Turner <[email protected]>
* ralloc: Add some basic unit tests.Kenneth Graunke2012-05-303-0/+44
| | | | | | | | | I started writing unit tests for a new piece of code, and discovered they all failed due to a bug in ralloc. Clearly it needs a test suite. v2: Rename to 'ralloc-test' and fix copyright date. (idr review) Signed-off-by: Kenneth Graunke <[email protected]>
* ralloc: Fix ralloc_parent() of memory allocated out of the NULL context.Kenneth Graunke2012-05-301-1/+1
| | | | | | | | | | | | If an object is allocated out of the NULL context, info->parent will be NULL. Using the PTR_FROM_HEADER macro would be incorrect: it would say that ralloc_parent(ralloc_context(NULL)) == sizeof(ralloc_header). Fixes the new "null_parent" unit test. NOTE: This is a candidate for the 7.9, 7.10, 7.11, and 8.0 branches. Signed-off-by: Kenneth Graunke <[email protected]>
* 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]>