aboutsummaryrefslogtreecommitdiffstats
path: root/src/glsl/glsl_parser_extras.h
Commit message (Collapse)AuthorAgeFilesLines
* glsl: remove UBO fields from _mesa_glsl_parse_stateChia-I Wu2014-04-011-4/+0
| | | | | | | They are not needed since 514f8c7ec7cc1ab18be93cebb5b9bf970b1955a9. Signed-off-by: Chia-I Wu <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl/sso: Add parser and AST-to-HIR support for separate shader object layoutsIan Romanick2014-02-211-0/+17
| | | | | | | | | | | | GL_ARB_separate_shader_objects adds the ability to specify location layouts for interstage inputs and outputs. In addition, this extension makes 'in' and 'out' generally available for shader inputs and outputs. This mimics the behavior of GL_ARB_explicit_attrib_location. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* mesa/sso: Add extension tracking for ARB_separate_shader_objectsIan Romanick2014-02-211-0/+7
| | | | | | | This adds the necessary bits for both the API and the GLSL compiler. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* glsl: convert GS input primitive to use ast_type_qualifierJordan Justen2014-02-201-5/+2
| | | | | | | | | | | | | | | | | | | | | | | | We introduce a new merge_in_qualifier ast_type_qualifier which allows specialized handling of merging input layout qualifiers. By merging layout qualifiers into state->in_qualifier, we allow multiple input qualifiers. For example, the primitive type can be specified specified separately from the invocations count (ARB_gpu_shader5). state->gs_input_prim_type is moved into state->in_qualifier->prim_type state->gs_input_prim_type_specified is still processed separately so we can determine when the input primitive is specified. This is important since certain scenerios are not supported until after the primitive type has been specified in the shader code. v4: * Merge with compute shader input layout qualifiers Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Anuj Phogat <[email protected]>
* glsl: Add built-in constants for ARB_shader_image_load_store.Francisco Jerez2014-02-121-0/+9
| | | | | | v2: Add them on GLSL version 4.20 too. Reviewed-by: Paul Berry <[email protected]>
* glsl/parser: Handle the early_fragment_tests input layout qualifier.Francisco Jerez2014-02-121-0/+2
| | | | | | v2: Only allow the early_fragment_tests qualifier in fragment shaders. Reviewed-by: Paul Berry <[email protected]>
* glsl: Add ARB_shader_image_load_store extension enables.Francisco Jerez2014-02-121-0/+2
| | | | Reviewed-by: Paul Berry <[email protected]>
* glsl/cs: Handle compute shader local_size_{x,y,z} declaration.Paul Berry2014-02-051-0/+15
| | | | Reviewed-by: Jordan Justen <[email protected]>
* mesa/cs: Implement MAX_COMPUTE_WORK_GROUP_COUNT constant.Paul Berry2014-02-051-0/+1
| | | | | | | | v2: Document that the 3-element array MaxComputeWorkGroupCount is indexed by dimension. Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* mesa/cs: Implement MAX_COMPUTE_WORK_GROUP_SIZE constant.Paul Berry2014-02-051-0/+3
| | | | | | | | v2: Document that the 3-element array MaxComputeWorkGroupSize is indexed by dimension. Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* mesa/cs: Add extension enable flags for ARB_compute_shader.Paul Berry2014-02-051-0/+2
| | | | Reviewed-by: Matt Turner <[email protected]>
* glsl: Add ARB_arrays_of_arrays support to yacc definition and astTimothy Arceri2014-01-231-0/+2
| | | | | | | Adds array specifier object to hold array information Signed-off-by: Timothy Arceri <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: Add extension infrastructure for ARB_viewport_arrayIan Romanick2014-01-201-0/+2
| | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* mesa: Remove _mesa_progshader_enum_to_string(), which is no longer used.Paul Berry2014-01-081-3/+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-1/+1
| | | | | | | | Reviewed-by: Kenneth Graunke <[email protected]> v2: Also rename "target" param to "stage". Reviewed-by: Brian Paul <[email protected]>
* glsl: make _mesa_shader_stage_to_string() available to non-C++ code.Paul Berry2014-01-081-8/+7
| | | | | | | | 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-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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]>
* glsl: Add extension tracking for AMD_shader_trinary_minmaxMaxence Le Doré2014-01-061-0/+2
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* Rename overloads of _mesa_glsl_shader_target_name().Paul Berry2013-12-301-3/+4
| | | | | | | | | | | | 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-8/+2
| | | | | | These enums were redundant. Reviewed-by: Brian Paul <[email protected]>
* glsl: Simplify the built-in function linking code.Kenneth Graunke2013-12-011-3/+1
| | | | | | | | | | | | | | | | | | 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: Implement parser support for atomic counters.Francisco Jerez2013-11-071-0/+3
| | | | | | | | | | | | | | | | v2: Mark atomic counters as read-only variables. Move offset overlap code to the linker. Use the contains_atomic() convenience method. v3: Use pointer to integer instead of non-const reference. Add comment so we remember to add a spec quotation from the next GLSL release once the issue of atomic counter aggregation within structures is clarified. v4 (idr): Don't use std::map because it's overkill. Add an assertion that ctx->Const.MaxAtomicBufferBindings <= MAX_COMBINED_ATOMIC_BUFFERS. Signed-off-by: Francisco Jerez <[email protected]> Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Paul Berry <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* mesa: Add infrastructure for GL_ARB_sample_shadingAnuj Phogat2013-11-011-0/+2
| | | | | | | | | | | 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: Move layout(location) checks to AST-to-HIR conversionIan Romanick2013-10-301-3/+20
| | | | | | | | | | | | | This will simplify the addition of layout(location) qualifiers for separate shader objects. This was validated with new piglit tests arb_explicit_attrib_location/1.30/compiler/not-enabled-01.vert and arb_explicit_attrib_location/1.30/compiler/not-enabled-02.vert. v2: Refactor error checking to check_explicit_attrib_location_allowed and eliminate the gotos. Suggested by Paul. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: Add built-in functions and constants required for ↵Francisco Jerez2013-10-291-0/+7
| | | | | | | | 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/+2
| | | | | 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/+2
| | | | | Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: add texture gather changesMaxence Le Dore2013-10-031-0/+2
| | | | | | | | | | 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: Initialize all member variables of _mesa_glsl_parse_state on construction.Francisco Jerez2013-10-011-1/+1
| | | | | | | | | | | | | | | 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-0/+5
| | | | | | | | | | | 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-0/+5
| | | | | | | | | | | | | | | | | | | 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]>
* glsl: Use the new DECLARE_R[Z]ALLOC_CXX_OPERATORS in a bunch of places.Kenneth Graunke2013-09-211-16/+1
| | | | | | | | | This eliminates a lot of boilerplate and should be 100% equivalent. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Chad Versace <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* mesa: Rename MESA_shader_integer_mix to EXT_shader_integer_mixIan Romanick2013-09-131-2/+2
| | | | | | | | | | | | | | 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/+2
| | | | | | | Because why doesn't GLSL allow you to do this already? Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Mark _mesa_glsl_parse_state::is_version() as const.Kenneth Graunke2013-09-091-1/+1
| | | | | | | | | This promises the method won't modify the contents of the object. This allows us to call it even with a const pointer to the state. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: Disallow embedded structure definitionsIan Romanick2013-08-191-0/+7
| | | | | | | | | | 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: Implement rules for geometry shader input sizes.Paul Berry2013-08-011-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Section 4.3.8.1 (Input Layout Qualifiers) of the GLSL 1.50 spec contains some tricky rules for how the sizes of geometry shader input arrays are related to the input layout specification. In essence, those rules boil down to the following: - If an input array declaration does not specify a size, and it follows an input layout declaration, it is sized according to the input layout. - If an input layout declaration follows an input array declaration that didn't specify a size, the input array declaration is given a size at the time the input layout declaration appears. - All input layout declarations and input array sizes must ultimately match. Inconsistencies are reported as soon as they are detected, at compile time if the inconsistency is within one compilation unit, otherwise at link time. - At least one compilation unit must contain an input layout declaration. (Note: the geom_array_resize_visitor class was contributed by Bryan Cain <[email protected]>.) Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Parse the GLSL 1.50 GS layout qualifiers.Eric Anholt2013-08-011-0/+18
| | | | | | | | | | | | | | | 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]>
* glsl: Change the lexer's namespace.Kenneth Graunke2013-07-311-2/+2
| | | | | | | | | | | | Bison 3.0 removes the YYLEX_PARAM macro. In preparation for handling this using %lex-param, the parser needs a wrapper function for the actual Flex lex() function. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=67354 Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]> Tested-by: Laurent Carlier <[email protected]> Cc: "9.2" [email protected]
* mesa: Use shared code for converting shader targets to short strings.Eric Anholt2013-06-211-0/+3
| | | | | | | | 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/+2
| | | | | | | | v2 [mattst88] - Split infrastructure into separate patch. - Add preprocessor #define. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: add AMD_vertex_shader_layer supportJordan Justen2013-05-131-0/+2
| | | | | | | | 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]>
* mesa: Add infrastructure for ARB_gpu_shader5.Matt Turner2013-05-061-0/+2
| | | | Reviewed-by: Chris Forbes <[email protected]>
* glsl: Implement ARB_texture_query_lodDave Airlie2013-03-291-0/+2
| | | | | | | | | | | | | | | | | | | v2 [mattst88]: - Rebase. - #define GL_ARB_texture_query_lod to 1. - Remove comma after ir_lod in ir.h for MSVC. - Handled ir_lod in ir_hv_accept.cpp, ir_rvalue_visitor.cpp, opt_tree_grafting.cpp. - Rename textureQueryLOD to textureQueryLod, see https://www.khronos.org/bugzilla/show_bug.cgi?id=821 - Fix ir_reader of (lod ...). v3 [mattst88]: - Rename textureQueryLod to textureQueryLOD, pending resolution of Khronos 821. - Add ir_lod case to ir_to_mesa.cpp. Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: add support for ARB_texture_multisampleChris Forbes2013-03-021-0/+2
| | | | | | | | | | | | | | | | | | V2: - emit `sample` parameter properly for multisample texelFetch() - fix spurious whitespace change - introduce a new opcode ir_txf_ms rather than overloading the existing ir_txf further. This makes doing the right thing in the driver somewhat simpler. V3: - fix weird whitespace V4: - don't forget to include the new opcode in tex_opcode_strs[] (thanks Kenneth for spotting this) Signed-off-by: Chris Forbes <[email protected]> [V2] Reviewed-by: Eric Anholt <[email protected]> [V2] Reviewed-by: Paul Berry <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Fix unsupported version error for GLSL ES 3.00, future proof for 3.30.Paul Berry2013-02-121-0/+6
| | | | | | | | | | | | | | | | | | | | | | When the user specifies an unsupported GLSL version, _mesa_glsl_parse_state::process_version_directive() nicely gives them an error message telling them which GLSL versions are supported. Previous to this patch, the logic for determining whether a given language version was supported was independent from the logic to generate this error message string; as a result, we had a bug where GLSL 3.00 would never be listed in the error message as an available language version, even if it was really available. To make matters worse, the code for generating the error message string assumed that desktop GL versions were always separated by 0.10, an assumption that will be wrong as soon as we support GLSL 3.30. This patch fixes both problems by adding a table of supported GLSL versions to _mesa_glsl_parse_state; this table is used both to generate the error message and to check whether a given version is supported. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add infrastructure for ARB_shading_language_packingMatt Turner2013-01-251-0/+2
| | | | | Reviewed-by: Chad Versace <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glcpp: Accept pointer to GL context rather than just the API versionCarl Worth2013-01-111-1/+1
| | | | | | | | | As the preprocessor becomes more sophisticated and gains more optional behavior, it's easiest to just pass the GL context pointer to it so that it can examine any fields there that it needs to (such as API version, or the state of any driconf options, etc.). Reviewed-by: Kenneth Graunke <[email protected]>