aboutsummaryrefslogtreecommitdiffstats
path: root/src/glsl
Commit message (Collapse)AuthorAgeFilesLines
* glsl: Add parsing for GLSL uniform blocks.Eric Anholt2012-07-094-2/+164
| | | | | | | | This doesn't do anything with the uniform block declarations yet, so usage of those uniforms finds them to be undeclared. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Don't hide the type of struct_declaration_list.Eric Anholt2012-07-093-5/+9
| | | | | | | | I've been trying to derive from this for UBO support, and the slightly obfuscated types were putting me over the edge. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glcpp: Add built-in #define for GL_ARB_uniform_buffer_object.Kenneth Graunke2012-07-091-0/+3
| | | | | Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* glsl: Parser handles "#extension GL_ARB_uniform_buffer_object"Vincent Lejeune2012-07-092-0/+3
| | | | | Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Reduce a bit of extra code in the merging of layout qualifiers.Eric Anholt2012-07-091-7/+2
| | | | | Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Take advantage of the layout qualifier flags union to clean up parsing.Eric Anholt2012-07-091-21/+7
| | | | | | | | | The got_one variable was set iff one of the bits in flags.i was set. v2: Fix incorrect dropping of the ARB_conservative_depth warning. Reviewed-by: Kenneth Graunke <[email protected]> (v1) Reviewed-by: Ian Romanick <[email protected]>
* glsl: fix unop/binop errors in commentsBrian Paul2012-07-031-2/+2
|
* glsl: Remove unused ir_loop_jump::loop pointer.Kenneth Graunke2012-07-021-4/+0
| | | | | | | | | | | | | | | | | Commit 0c005bd7 intended to make ir_loop_jump::mode public, but also accidentally added a new pointer to the enclosing loop. Furthermore, it tried to initialize the new field by adding "this->loop = loop;" to the constructor, but since there is no loop parameter, this only initialized the field to itself---so it will likely be a garbage pointer. A lot of code, such as lower_jumps, allocates new loop jumps without setting this field appropriately, so any uses would probably just crash. Thankfully, there were none, so we can just delete the field. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=51574 Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* glsl: be more careful about counting varying vars in the linkerBrian Paul2012-06-271-1/+27
| | | | | | | | | | | | | Previously, we were counting gl_FrontFacing, gl_FragCoord and gl_PointCoord against the limit of varying variables. This prevented some valid shaders from linking. The other potential solution to this is to have the driver advertise more varying vars or set the GLSLSkipStrictMaxVaryingLimitCheck flag. But the above-mentioned variables aren't conventional varying attributes so it doesn't seem right to count them. Reviewed-by: Eric Anholt <[email protected]>
* glsl: glcpp: Extend testing of #line directivesCarl Worth2012-06-262-0/+12
| | | | | | | | The most recent commit adds support for comments and macro expansion on #line directives. Add testing to verify the new features. Signed-off-by: Carl Worth <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: glcpp: Move handling of #line directives from lexer to parser.Carl Worth2012-06-264-40/+55
| | | | | | | | | | | | | | | | | | | The GLSL specification requires that #line directives be interpreted after macro expansion. Our existing implementation of #line macros in the lexer prevents conformance on this point. Moving the handling of #line from the lexer to the parser gives us the macro expansion we need. An additional benefit is that the preprocessor also now supports comments on the same line as #line directives. Finally, the preprocessor now emits the (fully-macro-expanded) #line directives into the output. This allows the full GLSL compiler to also see and interpret these directives so it can also generate correct line numbers in error messages. Signed-off-by: Carl Worth <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: glcpp: Rename and document _glcpp_parser_expand_ifCarl Worth2012-06-261-5/+20
| | | | | | | | | This function is currently used only in the expansion of #if lines, but we will soon be using it more generally (for the expansion of (_glcpp_parser_expand_and_lex_from) and some more documentation. Signed-off-by: Carl Worth <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Consistently use length-based ralloc string functions for info_log.Carl Worth2012-06-261-14/+24
| | | | | | | | | | | | | | | | | | | | | Commit b823b99ec0f13af257dcd885f436a4d294c6222a switched from using functions such as ralloc_asprintf and ralloc_strcat to ralloc_asprintf_rewrite_tail. This change maintains the string's length as a aparamter that is updated by the ralloc functions (rather than recomputing it with strlen over and over). However, the change failed to updated two locations (glcpp_error and glcpp_warning), with the result that the string's length wasn't updated by these calls. Then, subsequent calls to other ralloc_asprintf_rewrite_tail would overwrite the text appended by glcpp_error. This commit fixes the two missing updates, and restores line numbers to the output of glcpp error messages, (as noticed by a glcpp unit test case that has been failing since the above-mentioned commit). Signed-off-by: Carl Worth <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: glcpp: Allow "#if undefined-macro' to evaluate to false.Carl Worth2012-06-265-3/+20
| | | | | | | | | | | | | | | | | A strict reading of the GLSL specification would have this be an error, but we've received reports from users who expect the preprocessor to interepret undefined macros as 0. This is the standard behavior of the rpeprocessor for C, and according to these user reports is also the behavior of other OpenGL implementations. So here's one of those cases where we can make our users happier by ignoring the specification. And it's hard to imagine users who really, really want to see an error for this case. The two affected tests cases are updated to reflect the new behavior. Signed-off-by: Carl Worth <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: fix comment typoBrian Paul2012-06-261-1/+1
|
* glsl: Add IsCentroid bitfield to gl_fragment_program.Paul Berry2012-06-251-1/+5
| | | | | | | | | This bitfield tells the back-ends which of a fragment shader's inputs require centroid interpolation. It is only set for GLSL fragment shaders, since assembly fragment shaders don't support centroid interpolation. Reviewed-by: Eric Anholt <[email protected]>
* 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]>