summaryrefslogtreecommitdiffstats
path: root/src/glsl/glsl_parser_extras.cpp
Commit message (Collapse)AuthorAgeFilesLines
* glsl: add support for GL_OES_EGL_image_externalChia-I Wu2011-11-031-0/+1
| | | | | | | | | | This extension introduces a new sampler type: samplerExternalOES. texture2D (and texture2DProj) can be used to do a texture look up in an external texture. Reviewed-by: Brian Paul <[email protected]> Acked-by: Jakob Bornecrantz <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add uniform_locations_assigned parameter to do_dead_code opt passIan Romanick2011-10-251-2/+21
| | | | | | | | | | | | | | | | | Setting this flag prevents declarations of uniforms from being removed from the IR. Since the IR is directly used by several API functions that query uniforms in shaders, uniform declarations cannot be removed after the locations have been set. However, it should still be safe to reorder the declarations (this is not tested). Signed-off-by: Ian Romanick <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=41980 Tested-by: Brian Paul <[email protected]> Reviewed-by: Bryan Cain <[email protected]> Cc: Vinson Lee <[email protected]> Cc: José Fonseca <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Yuanhan Liu <[email protected]>
* glsl: Defer initialization of built-in functions until they're needed.Kenneth Graunke2011-09-231-0/+2
| | | | | | | | | | | | | | | Very simple shaders don't actually use GLSL built-ins. For example: - gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; - gl_FragColor = vec4(0.0); Both of the shaders used by _mesa_meta_glsl_Clear() also qualify. By waiting to initialize the built-ins until the first time we need to look for a signature, we can avoid the overhead entirely in these cases. Makes piglit run roughly 18% faster (255 vs. 312 seconds). Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* glsl: Don't do structure splitting until link time.Eric Anholt2011-09-081-1/+1
| | | | | | | | | We were splitting on each side of an unlinked program, and the two sides lost track of which variables they referenced, resulting in assertion failure during validation. Fixes piglit link-struct-uniform-usage. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Implement the GL_ARB_conservative_depth extension.Kenneth Graunke2011-08-251-0/+1
| | | | | | | It's the same as GL_AMD_conservative_depth. The specs have slight differences in wording, but don't differ in content or behavior. Signed-off-by: Kenneth Graunke <[email protected]>
* glsl: Rewrote _mesa_glsl_process_extension to use table-driven logic.Paul Berry2011-06-281-109/+218
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of using a chain of manually maintained if/else blocks to handle "#extension" directives, we now consult a table that specifies, for each extension, the circumstances under which it is available, and what flags in _mesa_glsl_parse_state need to be set in order to activate it. This makes it easier to add new GLSL extensions in the future, and fixes the following bugs: - Previously, _mesa_glsl_process_extension would sometimes set the "_enable" and "_warn" flags for an extension before checking whether the extension was supported by the driver; as a result, specifying "enable" behavior for an unsupported extension would sometimes cause front-end support for that extension to be switched on in spite of the fact that back-end support was not available, leading to strange failures, such as those in https://bugs.freedesktop.org/show_bug.cgi?id=38015. - "#extension all: warn" and "#extension all: disable" had no effect. Notes: - All extensions are currently marked as unavailable in geometry shaders. This should not have any adverse effects since geometry shaders aren't supported yet. When we return to working on geometry shader support, we'll need to update the table for those extensions that are available in geometry shaders. - Previous to this commit, if a shader mentioned ARB_shader_texture_lod, extension ARB_texture_rectangle would be automatically turned on in order to ensure that the types sampler2DRect and sampler2DRectShadow would be defined. This was unnecessary, because (a) ARB_shader_texture_lod works perfectly well without those types provided that the builtin functions that reference them are not called, and (b) ARB_texture_rectangle is enabled by default in non-ES contexts anyway. I eliminated this unnecessary behavior in order to make the behavior of all extensions consistent. NOTE: This is a candidate for the 7.10 and 7.11 branches. Reviewed-by: Ian Romanick <[email protected]>
* AST dump: fixed printing of conditionals.Paul Berry2011-06-031-1/+1
| | | | | | | ast_expression::print() had an incorrect index into the subexpressions array, so (a ? b : c) was being incorrectly rendered as (a ? b : b). Signed-off-by: Brian Paul <[email protected]>
* glsl: Add compiler support for ARB_shader_texture_lod.Kenneth Graunke2011-05-091-0/+8
| | | | | Signed-off-by: Kenneth Graunke <[email protected]> Tested-by: Marek Olšák <[email protected]>
* mesa: implement AMD_shader_stencil_exportMarek Olšák2011-05-031-0/+10
| | | | | | | | It's just an alias of the ARB variant with some GLSL compiler changes. Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl/opt_cpe: Reenable opt_copy_propagation_elements.cpp pass.Eric Anholt2011-04-131-1/+1
|
* glsl: Make GL_ARB_shader_stencil_export enable block be similar to other blocksIan Romanick2011-04-111-7/+7
| | | | | Tested-by: Brian Paul <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Only let a shader enable GL_ARB_draw_instanced if the driver supports itIan Romanick2011-04-111-6/+5
| | | | | | | | Also make the GL_ARB_draw_instanced block follow the same pattern as the other blocks. Tested-by: Brian Paul <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Enable GL_OES_texture_3D extension for ES2.Kenneth Graunke2011-02-281-0/+5
|
* glsl: Disable the new copy propagation pass until it gets fixed.Eric Anholt2011-02-081-1/+1
| | | | It apparently regressed a bunch of ES2 cases.
* glsl: Add a new opt_copy_propagation variant that does it channel-wise.Eric Anholt2011-02-041-0/+1
| | | | | | | | | | This patch cleans up many of the extra copies in GLSL IR introduced by i965's scalarizing passes. It doesn't result in a statistically significant performance difference on nexuiz high settings (n=3) or my demo (n=10), due to brw_fs.cpp's register coalescing covering most of those extra moves anyway. However, it does make the debug of wine's GLSL shaders much more tractable, and reduces instruction count of glsl-fs-convolution-2 from 376 to 288.
* glsl: Fix memory error when creating the supported version string.Kenneth Graunke2011-02-011-1/+1
| | | | | | | | Passing ralloc_vasprintf_append a 0-byte allocation doesn't work. If passed a non-NULL argument, ralloc calls strlen to find the end of the string. Since there's no terminating '\0', it runs off the end. Fixes a crash introduced in 14880a510a1a288df0778395097d5a52806abfb0.
* glsl: Reject shader versions not supported by the implementationIan Romanick2011-01-311-0/+32
| | | | | | | | Previously we'd happily compile GLSL 1.30 shaders on any driver. We'd also happily compile GLSL 1.10 and 1.20 shaders in an ES2 context. This has been a long standing FINISHME in the compiler. NOTE: This is a candidate for the 7.9 and 7.10 branches
* Convert everything from the talloc API to the ralloc API.Kenneth Graunke2011-01-311-11/+9
|
* glsl: Enable AMD_conservative_depth in parserChad Versace2011-01-261-0/+7
| | | | | All the necessary compiler infrastructure for AMD_conservative_depth is in place, so it's safe to enable it in the parser.
* glsl: Skip the rest of loop unrolling if no loops were found.Eric Anholt2011-01-181-2/+4
| | | | | Shaves 1.6% (+/- 1.0%) off of ff_fragment_shader glean texCombine time (n=5).
* Merge branch 'draw-instanced'Brian Paul2011-01-151-0/+9
|\ | | | | | | | | | | | | | | Conflicts: src/gallium/auxiliary/draw/draw_llvm.c src/gallium/drivers/llvmpipe/lp_state_fs.c src/glsl/ir_set_program_inouts.cpp src/mesa/tnl/t_vb_program.c
| * glsl: add support for system values and GL_ARB_draw_instancedBrian Paul2010-12-081-0/+9
| |
* | glsl: Add an optimization pass to simplify discards.Kenneth Graunke2010-12-011-0/+1
|/ | | | NOTE: This is a candidate for the 7.9 branch.
* glsl: Combine many instruction lowering passes into one.Kenneth Graunke2010-11-191-1/+1
| | | | | | | This should save on the overhead of tree-walking and provide a convenient place to add more instruction lowering in the future. Signed-off-by: Ian Romanick <[email protected]>
* glsl: Remove useless ir_shader enumeration value.Kenneth Graunke2010-10-201-1/+0
|
* Drop GLcontext typedef and use struct gl_context insteadKristian Høgsberg2010-10-131-2/+2
|
* glsl: add support for shader stencil exportDave Airlie2010-10-131-0/+8
| | | | | This adds proper support for the GL_ARB_shader_stencil_export extension to the GLSL compiler. Thanks to Ian for pointing out where I need to add things.
* glsl: Add parser support for GL_ARB_explicit_attrib_location layoutsIan Romanick2010-10-081-0/+7
| | | | | Only layout(location=#) is supported. Setting the index requires GLSL 1.30 and GL_ARB_blend_func_extended.
* glsl: Wrap ast_type_qualifier contents in a struct in a unionIan Romanick2010-10-081-12/+12
| | | | This will ease adding non-bit fields in the near future.
* glsl: Properly handle nested structure types.Kenneth Graunke2010-09-181-0/+5
| | | | Fixes piglit test CorrectFull.frag.
* glsl2: Add pass to remove redundant jumpsIan Romanick2010-09-131-0/+2
|
* glsl: add continue/break/return unification/elimination pass (v2)Luca Barbieri2010-09-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Changes in v2: - Base class renamed to ir_control_flow_visitor - Tried to comply with coding style This is a new pass that supersedes ir_if_return and "lowers" jumps to if/else structures. Currently it causes no regressions on softpipe and nv40, but I'm not sure whether the piglit glsl tests are thorough enough, so consider this experimental. It can be asked to: 1. Pull jumps out of ifs where possible 2. Remove all "continue"s, replacing them with an "execute flag" 3. Replace all "break" with a single conditional one at the end of the loop 4. Replace all "return"s with a single return at the end of the function, for the main function and/or other functions This gives several great benefits: 1. All functions can be inlined after this pass 2. nv40 and other pre-DX10 chips without "continue" can be supported 3. nv30 and other pre-DX10 chips with no control flow at all are better supported Note that for full effect we should also teach the unroller to unroll loops with a fixed maximum number of iterations but with the canonical conditional "break" that this pass will insert if asked to. Continues are lowered by adding a per-loop "execute flag", initialized to TRUE, that when cleared inhibits all execution until the end of the loop. Breaks are lowered to continues, plus setting a "break flag" that is checked at the end of the loop, and trigger the unique "break". Returns are lowered to breaks/continues, plus adding a "return flag" that causes loops to break again out of their enclosing loops until all the loops are exited: then the "execute flag" logic will ignore everything until the end of the function. Note that "continue" and "return" can also be implemented by adding a dummy loop and using break. However, this is bad for hardware with limited nesting depth, and prevents further optimization, and thus is not currently performed.
* glsl: add several EmitNo* options, and MaxUnrollIterationsLuca Barbieri2010-09-081-2/+2
| | | | | | | | | This increases the chance that GLSL programs will actually work. Note that continues and returns are not yet lowered, so linking will just fail if not supported. Signed-off-by: Ian Romanick <[email protected]>
* glsl: Require a context in _mesa_glsl_parse_state.Chia-I Wu2010-09-081-56/+21
| | | | | Create a dummy context in the standalone compiler and pass it to _mesa_glsl_parse_state.
* glsl: Accept language version 100 and make it the default on ES2.Kenneth Graunke2010-09-071-0/+8
|
* glsl: Set default language version in mesa_glsl_parse_state constructor.Kenneth Graunke2010-09-071-0/+3
| | | | | | | | | | This should make it easier to change the default version based on the API (say, version 1.00 for OpenGL ES). Also, synchronize the symbol table's version with the parse state's version just before doing AST-to-HIR. This way, it will be set when it matters, but the main initialization code doesn't have to care about the symbol table.
* glsl2: Add module to perform simple loop unrollingIan Romanick2010-09-031-0/+1
|
* glsl2: Perform initial bits of loop analysis during compilationIan Romanick2010-09-031-0/+5
|
* glsl: Include main/core.h.Chia-I Wu2010-08-241-1/+1
| | | | Make glsl include only main/core.h from core mesa.
* glsl2: Free the shader compiler at dri screen destruction.Eric Anholt2010-08-181-0/+30
| | | | | | Hooray, we can valgrind again without adding suppressions. This also adds an interface for use by an implementation of glReleaseShaderCompiler().
* glsl2: Add a pass to strip out noop swizzles.Eric Anholt2010-08-131-0/+1
| | | | | | With the glsl2-965 branch, the optimization of glsl-algebraic-rcp-rcp regressed due to noop swizzles hiding information from ir_algebraic. This cleans up those noop swizzles for us.
* glsl2: Move the common optimization passes to a helper function.Eric Anholt2010-08-131-0/+35
| | | | | These are passes that we expect all codegen to be happy with. The other lowering passes for Mesa IR are moved to the Mesa IR generator.
* glsl2: Enable all supported extensions in stand-alone compilerIan Romanick2010-08-051-0/+5
|
* ast: Initialize location data in constructor of all ast_node objects.Carl Worth2010-07-301-1/+3
| | | | | | This prevents using uninitialized data in _msea_glsl_error in some cases, (including at least 6 piglit tests). Thanks to valgrind for pointing out the problem!
* glsl2: Parser support for GL_ARB_fragment_coord_conventionsIan Romanick2010-07-281-0/+7
|
* glsl2: Fix standalone compiler to not crash horribly.Kenneth Graunke2010-07-221-0/+23
| | | | | ir_to_mesa was updated for the _mesa_glsl_parse_state constructor changes, but main.cpp was not.
* glsl2: Add a constructor for _mesa_glsl_parse_stateIan Romanick2010-07-201-0/+41
| | | | Coming changes to the handling of built-in functions necessitate this.
* glsl2: Fix warning from always-false assert not being known to not return.Eric Anholt2010-07-181-0/+1
|
* glsl2: Conditionally allow optional extensions to be enabledIan Romanick2010-07-011-0/+6
| | | | | The only optional extension currently supported by the compiler is GL_EXT_texture_array.
* glsl2: Initialize ast_declarator_list::invariant in constructorIan Romanick2010-07-011-0/+1
|