aboutsummaryrefslogtreecommitdiffstats
path: root/src/glsl/glsl_parser_extras.cpp
Commit message (Collapse)AuthorAgeFilesLines
* glsl: Add extension infrastructure for ARB_viewport_arrayIan Romanick2014-01-201-0/+1
| | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* mesa: replace ctx->Const.{Vertex,Fragment,Geomtery}Program with an array.Paul Berry2014-01-091-14/+14
| | | | | | | | | | | | | | | | | | | | 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: Remove _mesa_progshader_enum_to_string(), which is no longer used.Paul Berry2014-01-081-29/+0
| | | | | Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* glsl: Change _mesa_glsl_parse_state ctor to use gl_shader_stage enum.Paul Berry2014-01-081-7/+5
| | | | | | | | 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-081-2/+2
| | | | | | | | | | | | | | | | | | | | | 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: Clean up nomenclature for pipeline stages.Paul Berry2014-01-081-11/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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]>
* mesa: enable AMD_shader_trinary_minmaxMaxence Le Doré2014-01-061-1/+1
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Add extension tracking for AMD_shader_trinary_minmaxMaxence Le Doré2014-01-061-0/+1
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* Rename overloads of _mesa_glsl_shader_target_name().Paul Berry2013-12-301-9/+8
| | | | | | | | | | | | Previously, _mesa_glsl_shader_target_name() had an overload for GLenum and an overload for the gl_shader_type enum, each of which behaved differently. However, since GLenum is a synonym for unsigned int, and unsigned ints are often used in place of gl_shader_type (e.g. in loop indices), there was a big risk of calling the wrong overload by mistake. This patch gives the two overloads different names so that it's always clear which one we mean to call. Reviewed-by: Brian Paul <[email protected]>
* glsl: Replace _mesa_glsl_parser_targets enum with gl_shader_type.Paul Berry2013-12-171-7/+7
| | | | | | These enums were redundant. Reviewed-by: Brian Paul <[email protected]>
* glsl: Add frontend support for `sample` auxiliary storage qualifierChris Forbes2013-12-071-0/+2
| | | | | Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Francisco Jerez <[email protected]>
* glsl: Simplify the built-in function linking code.Kenneth Graunke2013-12-011-5/+3
| | | | | | | | | | | | | | | | | | Previously, we stored an array of up to 16 additional shaders to link, as well as a count of how many each shader actually needed. Since the built-in functions rewrite, all the built-ins are stored in a single shader. So all we need is a boolean indicating whether a shader needs to link against built-ins or not. During linking, we can avoid creating the temporary array if none of the shaders being linked need built-ins. Otherwise, it's simply a copy of the array that has one additional element. This is much simpler. This patch saves approximately 128 bytes of memory per gl_shader object. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Initialize _mesa_glsl_parse_state::atomic_counter_offsets before using it.Francisco Jerez2013-11-261-0/+2
| | | | | | Cc: Ian Romanick <[email protected]> Cc: "10.0" <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: cleanup, remove duplicate assignmentTapani Pälli2013-11-171-1/+0
| | | | | Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* mesa: Add infrastructure for GL_ARB_sample_shadingAnuj Phogat2013-11-011-0/+1
| | | | | | | | | | | This patch implements the common support code required for the GL_ARB_sample_shading extension. V2: Move GL_ARB_sample_shading to ARB extension list. Signed-off-by: Anuj Phogat <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Ken Graunke <[email protected]>
* glsl: Add a CSE pass.Eric Anholt2013-11-011-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | This only operates on constant/uniform values for now, because otherwise I'd have to deal with killing my available CSE entries when assignments happen, and getting even this working in the tree ir was painful enough. As is, it has the following effect in shader-db: total instructions in shared programs: 1524077 -> 1521964 (-0.14%) instructions in affected programs: 50629 -> 48516 (-4.17%) GAINED: 0 LOST: 0 And, for tropics, that accounts for most of the effect, the FPS improvement is 11.67% +/- 0.72% (n=3). v2: Use read_only field of the variable, manually check the lod_info union members, use get_num_operands(), rename cse_operands_visitor to is_cse_candidate_visitor, move all is-a-candidate logic to that function, and call it before checking for CSE on a given rvalue, more comments, use private keyword. Reviewed-by: Paul Berry <[email protected]>
* glsl: Add built-in functions and constants required for ↵Francisco Jerez2013-10-291-0/+6
| | | | | | | | ARB_shader_atomic_counters. v2: Represent atomics as GLSL intrinsics. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add extension enables for ARB_shader_atomic_counters.Francisco Jerez2013-10-291-0/+1
| | | | | Reviewed-by: Paul Berry <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add new GLSL 1.50 constants.Paul Berry2013-10-151-0/+10
| | | | | | | | | | | | | | | | | | | | | This patch populates the following built-in GLSL 1.50 variables based on constants stored in ctx->Const: - gl_MaxVertexOutputComponents - gl_MaxGeometryInputComponents - gl_MaxGeometryOutputComponents - gl_MaxFragmentInputComponents - gl_MaxGeometryTextureImageUnits - gl_MaxGeometryOutputVertices - gl_MaxGeometryTotalOutputComponents - gl_MaxGeometryUniformComponents - gl_MaxGeometryVaryingComponents On i965/gen7, fixes all Piglit tests in "spec/glsl-1.50/built-in constants/*" except for gl_MaxCombinedTextureImageUnits and gl_MaxGeometryUniformComponents. Reviewed-by: Matt Turner <[email protected]>
* glsl: Remove glsl_parser_state MaxVaryingFloats fieldIan Romanick2013-10-071-1/+0
| | | | | | | | | | Pull the data directly from the context like the other varying related limits. The parser state shadow copies were added back when the parser state didn't have a pointer to the context. There's no reason to do it now days. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: add plumbing for GL_ARB_texture_query_levelsChris Forbes2013-10-051-0/+1
| | | | | Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: add texture gather changesMaxence Le Dore2013-10-031-0/+1
| | | | | | | | | | V2 [Chris Forbes]: - Add new pattern, fixup parameter reading. V3: Rebase onto new builtins machinery Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Switch ast_node to the non-zeroing allocator.Francisco Jerez2013-10-011-1/+2
| | | | | | | | | | | | | | | | | | All member variables of ast_node are already being initialized from its constructor, but some of its derived classes were leaving members uninitialized -- Fix them. Using rzalloc makes it more likely that we will start relying on the allocator to zero out all memory if the class is ever extended with new member variables. That's bad because it ties objects to some specific allocation scheme, and gives unpredictable results when an object is created with a different allocator -- Stack allocation, array allocation, or aggregation inside a different object are some of the useful possibilities that come to my mind. v2: Use NULL initialization instead of default construction for pointers. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Initialize all member variables of _mesa_glsl_parse_state on construction.Francisco Jerez2013-10-011-2/+14
| | | | | | | | | | | | | | | The _mesa_glsl_parse_state object relies on the memory allocator zeroing out its contents before it's initialized, which is quite an unusual practice in the C++ world because it ties objects to some specific allocation scheme, and gives unpredictable results when an object is created with a different allocator -- Stack allocation, array allocation, or aggregation inside a different object are some of the useful possibilities that come to my mind. Initialize all fields from the constructor and stop using the zeroing allocator. Reviewed-by: Paul Berry <[email protected]> Reviewed-by: Chad Versace <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Create and use a has_uniform_buffer_objects() helper.Kenneth Graunke2013-09-261-4/+0
| | | | | | | | | | | This is better than overriding the extension enable based on the language version; it's robust against shaders that do: #version 140 #extension GL_ARB_uniform_buffer_object : disable Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Create and use a has_explicit_attrib_location() helper.Kenneth Graunke2013-09-261-4/+0
| | | | | | | | | | | | | | | | | | | Explicit attribute locations are supported with GLSL 3.30, GLSL ES 3.00, or "#extension GL_ARB_explicit_attrib_location: enable". Using a helper function makes it easy to check for this. This enables support in GLSL 3.30, which was previously missing. Previously, we overrode the extension enable flag for ES 3.00. This is not robust against a shader such as: #version 330 #extension GL_ARB_explicit_attrib_location : disable Disabling extensions should not remove core language functionality. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* mesa: Rename MESA_shader_integer_mix to EXT_shader_integer_mixIan Romanick2013-09-131-1/+1
| | | | | | | | | | | | | | Everyone at the Khronos meeting was as surprised that GLSL didn't already support this as we were. Several vendors said they'd ship it, but there didn't seem to be enough interest to put in the effort to make it ARB or KHR. v2: Fix a couple typos and rename the spec file to EXT_shader_integer_mix.spec. Suggested by Roland. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Roland Scheidegger <[email protected]>
* glsl: Implement MESA_shader_integer_mix extension.Matt Turner2013-09-091-0/+1
| | | | | | | Because why doesn't GLSL allow you to do this already? Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Switch to the new built-in function module.Kenneth Graunke2013-09-091-1/+1
| | | | | | | | All built-ins are now handled by the new code; the old system is dead. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: Remove ubo_qualifiers_allowed variable.Matt Turner2013-08-211-1/+0
| | | | | | | No longer used. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Anuj Phogat <[email protected]>
* glsl: Rename ubo_qualifiers_valid to ubo_qualifiers_allowed.Matt Turner2013-08-211-1/+1
| | | | | | | | | The variable means that UBO qualifiers are allowed in a particular context (e.g., not allowed in a struct field declaration), rather than a particular set of UBO qualifiers are valid. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Anuj Phogat <[email protected]>
* glsl: Disallow embedded structure definitionsIan Romanick2013-08-191-0/+1
| | | | | | | | | | Continue to allow them in GLSL 1.10 because the spec allows it. Generate an error in all other versions because the specs specifically disallow it. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Cc: "9.2" <[email protected]>
* glsl: Export the compiler's GS layout qualifiers to the gl_shader.Eric Anholt2013-08-011-0/+31
| | | | | | | | | | | | | | | | Next step is to validate them at link time. v2 (Paul Berry <[email protected]>): Don't attempt to export the layout qualifiers in the event of a compile error, since some of them are set up by ast_to_hir(), and ast_to_hir() isn't guaranteed to have run in the event of a compile error. Reviewed-by: Kenneth Graunke <[email protected]> v3 (Paul Berry <[email protected]>): Use PRIM_UNKNOWN to represent "not set in this shader". Reviewed-by: Ian Romanick <[email protected]>
* glsl: Parse the GLSL 1.50 GS layout qualifiers.Eric Anholt2013-08-011-0/+4
| | | | | | | | | | | | | | | Limited semantic checking (compatibility between declarations, checking that they're in the right shader target, etc.) is done. v2: Remove stray debug printfs. v3 (Paul Berry <[email protected]>): Process input layout qualifiers at ast_to_hir time rather than at parse time, since certain error conditions depend on the relative ordering between input layout qualifiers, declarations, and calls to .length(). Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* mesa,glsl,st/dri: add a new driconf option force_glsl_version for UnigineMarek Olšák2013-07-301-1/+2
| | | | | | | | See documentation in mtypes.h. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Remove shader stage checking for extension handling.Kenneth Graunke2013-07-291-61/+28
| | | | | | | | | | | | | | | | | Certain extensions only add functionality to particular shader stages. (For example, ARB_draw_instanced only adds variables to the vertex shader stage.) Previously, we only allowed such extensions to be enabled in the shader stages where they're useful. However, I've never found any text which mandates that behavior; in my opinion, you should be able to turn on extensions in any shader stage, even if they have no effect. Fixes Piglit tests glslparsertest/glsl2/draw_buffers-05.vert and ARB_draw_instanced/preprocessor/feature-macro-enabled.frag. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=29185 Signed-off-by: Kenneth Graunke <[email protected]>
* glsl: Be consistent about '\n', '.', and capitalization in errors/warnings.Paul Berry2013-07-271-8/+8
| | | | | | | | | | | | The majority of calls to _mesa_glsl_error(), _mesa_glsl_warning(), and _mesa_glsl_parse_state::check_version() use a message that begins with a lower case letter and ends without a period. This patch makes all messages follow that convention. Also, error/warning messages shouldn't end in '\n', since _mesa_glsl_msg() automatically adds '\n' at the end of the message. Reviewed-by: Matt Turner <[email protected]>
* glsl: Initialize ast_function member variables.Vinson Lee2013-07-211-1/+2
| | | | | | Fixes "Uninitialized pointer field" defect reported by Coverity. Signed-off-by: Vinson Lee <[email protected]>
* glsl: Initialize ast_jump_statement::opt_return_value.Vinson Lee2013-07-161-0/+1
| | | | | | | | | opt_return_value was not initialized if mode != ast_return. Fixes "Uninitialized pointer field" defect reported by Coverity. Signed-off-by: Vinson Lee <[email protected]> Reviewed-by: Chad Versace <[email protected]>
* glsl: Add support for C-style initializers.Matt Turner2013-07-111-0/+188
| | | | | | | | | Required by GL_ARB_shading_language_420pack. Parts based on work done by Todd Previte and Ken Graunke, implementing basic support for C-style initializers of arrays. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add infrastructure for aggregate initializers.Matt Turner2013-07-111-0/+13
| | | | Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add an is_declaration field to ast_struct_specifier.Matt Turner2013-07-111-0/+1
| | | | | | | | | | | | | | | | | | Will be used in a later commit to differentiate between a structure type declaration and a variable declaration of a struct type. I.e., the difference between struct S { float x; }; (is_declaration = true) and S s; (is_declaration = false) Also note that is_declaration = true for struct S { float x; } s; Reviewed-by: Ian Romanick <[email protected]>
* glsl: Change type of is_array to bool.Matt Turner2013-07-111-1/+1
| | | | Reviewed-by: Ian Romanick <[email protected]>
* mesa: Move the common _mesa_glsl_compile_shader() code to glsl/.Eric Anholt2013-06-211-0/+83
| | | | | | | | | | | This code had no relation to ir_to_mesa.cpp, since it was also used by intel and state_tracker, and most of it was duplicated with the standalone compiler (which has periodically drifted from the Mesa copy). v2: Split from the ir_to_mesa to shaderapi.c changes. Acked-by: Paul Berry <[email protected]> (v1) Reviewed-by: Kenneth Graunke <[email protected]>
* mesa: Use shared code for converting shader targets to short strings.Eric Anholt2013-06-211-0/+35
| | | | | | | | We were duplicating this code all over the place, and they all would need updating for the next set of shader targets. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* mesa: Add infrastructure for ARB_shading_language_420pack.Todd Previte2013-06-141-0/+1
| | | | | | | | v2 [mattst88] - Split infrastructure into separate patch. - Add preprocessor #define. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Parse "#version 150 core" directives.Kenneth Graunke2013-06-101-0/+13
| | | | | | | | | | Previously we only supported "#version 150". This patch recognizes "compatibility" to give the user a more descriptive error message. Fixes Piglit's version-150-core-profile test. Reviewed-by: Matt Turner <[email protected]> Signed-off-by: Kenneth Graunke <[email protected]>
* glsl: add AMD_vertex_shader_layer supportJordan Justen2013-05-131-0/+1
| | | | | | | | This GLSL extension requires that AMD_vertex_shader_layer be enabled by the driver. Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add lowering pass for ir_triop_vector_insertIan Romanick2013-05-131-0/+1
| | | | | | | | | | | | | | | | | | This will eventually replace do_vec_index_to_cond_assign. This lowering pass is called in all the places where do_vec_index_to_cond_assign or do_vec_index_to_swizzle is called. v2: Use WRITEMASK_* instead of integer literals. Use a more concise method of generating broadcast_index. Both suggested by Eric. v3: Use a series of scalar compares instead of a single vector compare. Suggested by Eric and Ken. It still uses 'if (cond) v.x = y;' instead of conditional assignments because ir_builder doesn't do conditional assignments, and I'd rather keep the code simple. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Add a pass to flip matrix/vector multiplies to use dot products.Kenneth Graunke2013-05-121-0/+4
| | | | | | | | | | | | | | | | | | | | | | This pass flips (matrix * vector) operations to (vector * matrixTranspose) for certain built-in matrices (currently gl_ModelViewProjectionMatrix and gl_TextureMatrix). This is equivalent, but results in dot products rather than multiplies and adds. On some hardware, this is more efficient. This pass is conditionalized on ctx->mvp_with_dp4, the flag drivers set to indicate they prefer dot products. Improves performance in Lightsmark by 1.01131% +/- 0.162069% (n = 10) on a Haswell GT2 system. Passes Piglit on Ivybridge. v2: Use struct gl_shader_compiler_options instead of plumbing through another boolean flag for this purpose. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Eric Anholt <[email protected]>