aboutsummaryrefslogtreecommitdiffstats
path: root/src/glsl/glsl_parser_extras.h
Commit message (Collapse)AuthorAgeFilesLines
* glsl: Create a _mesa_shader_stage_to_abbrev() function.Kenneth Graunke2015-02-191-0/+3
| | | | | | | | | | | | | This is similar to _mesa_shader_stage_to_string(), but returns "VS" instead of "vertex". v2: Use unreachable() and add MESA_SHADER_COMPUTE (requested by Ian). Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]> Reviewed-by: Anuj Phogat <[email protected]>
* glsl: Add double builtin type generationDave Airlie2015-02-191-0/+5
| | | | | | | Signed-off-by: Dave Airlie <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]>
* glsl: add ARB_gpu_shader_fp64 to the glsl extensions. (v2)Dave Airlie2015-02-191-0/+2
| | | | | | | | | | | | | v2: add define bit (Tapani Pälli) Patch makes following Piglit tests pass: arb_gpu_shader_fp64/preprocessor/define.vert arb_gpu_shader_fp64/preprocessor/define.frag Reviewed-by: Ian Romanick <[email protected]> Signed-off-by: Dave Airlie <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]>
* mesa: Add ARB_shader_precision infrastructureMicah Fedke2015-01-191-0/+2
| | | | | Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Chris Forbes <[email protected]>
* mesa/glsl/glapi: enable GL_EXT_draw_buffers extensionTapani Pälli2015-01-141-0/+2
| | | | | | | | | | | | | | | | Patch enables ES2 extension that utilizes existing ES3 functionality. Changes make all the subtests to run and pass in WebGL conformance test 'webgl-draw-buffers' when running Chrome on OpenGL ES, also Piglit test 'draw_buffers_gles2' passes. v2: remove unused boolean (Ilia Mirkin) v3: proper error checking for invalid values (Chad Versace) v4: run error check explicitly for ES2 and ES3 (Kenneth Graunke) Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Chad Versace <[email protected]>
* glsl: Add gl_MaxViewports to available builtin constantsMaxence Le Doré2014-12-151-0/+3
| | | | | | | | It seems to have been forgotten during viewports array implementation time. Cc: "10.4 10.3" <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* main, glsl: Bump max known desktop glsl version to 4.50Jordan Justen2014-12-011-1/+1
| | | | | Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: implement switch flow control using a loopTapani Pälli2014-10-201-1/+3
| | | | | | | | | | | | | | | | | | | | | | | Patch removes old variable based logic for handling a break inside switch. Switch is put inside a loop so that existing infrastructure for loop flow control can be used for the switch, now also dead code elimination works properly. Possible 'continue' call inside a switch needs now special handling which is taken care of by detecting continue, breaking out and calling continue for the outside loop. v2: remove one unnecessary ir_expression (Curro) Fixes following Piglit tests: fs-exec-after-break.shader_test fs-conditional-break.shader_test No Piglit or es3conform regressions. Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Francisco Jerez <[email protected]>
* glsl: add ARB_derivative control supportIlia Mirkin2014-08-141-0/+2
| | | | | | | Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Chris Forbes <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: add a mechanism to allow #extension directives in the middle of shadersMarek Olšák2014-07-181-0/+2
| | | | | | | | | | | This is needed to make Unigine Heaven 4.0 and Unigine Valley 1.0 work with sample shading. Also, if this is disabled, the error message at least makes sense now. Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: handle a switch where default is in the middle of casesTapani Pälli2014-07-171-0/+3
| | | | | | | | | | | | | | | | | | | | | This fixes following tests in es3conform: shaders.switch.default_not_last_dynamic_vertex shaders.switch.default_not_last_dynamic_fragment and makes following tests in Piglit pass: glsl-1.30/execution/switch/fs-default-notlast-fallthrough glsl-1.30/execution/switch/fs-default_notlast No Piglit regressions. v2: take away unnecessary ir_if, just use conditional assignment v3: use foreach_in_list instead of foreach_list Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Roland Scheidegger <[email protected]> (v2) Reviewed-by: Ian Romanick <[email protected]> (v3)
* glsl: add support for AMD_vertex_shader_viewport_indexIlia Mirkin2014-07-021-0/+2
| | | | | | | Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Chris Forbes <[email protected]> Tested-by: Tobias Droste <[email protected]>
* glsl: Add parsing support for multi-stream output in geometry shaders.Samuel Iglesias Gonsalvez2014-06-301-0/+18
| | | | | | | | This implements parsing requirements for multi-stream support in geometry shaders as defined in ARB_gpu_shader5. Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Silence many unused parameter warningsIan Romanick2014-06-231-1/+1
| | | | | | | | In file included from ../../src/glsl/builtin_functions.cpp:61:0: ../../src/glsl/glsl_parser_extras.h:154:9: warning: unused parameter 'var' [-Wunused-parameter] Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
* glsl: Add extension plumbing for ARB_fragment_layer_viewportChris Forbes2014-06-221-0/+2
| | | | | Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: parser changes for GL_ARB_explicit_uniform_locationTapani Pälli2014-06-161-0/+15
| | | | | | | | | | | | Patch adds a preprocessor define for the extension and stores explicit location data for uniforms during AST->HIR conversion. It also sets layout token to be available when having the extension in place. v2: change parser check to require GLSL 330 or enabling GL_ARB_explicit_attrib_location (Ian) v3: fix the check and comment in AST->HIR (Petri) Signed-off-by: Tapani Pälli <[email protected]>
* glsl: add enable bit for ARB_explicit_uniform_locationTapani Pälli2014-06-161-0/+2
| | | | | Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Correct more typosChris Forbes2014-06-151-1/+1
| | | | Signed-off-by: Chris Forbes <[email protected]>
* mesa: Enable GL_EXT_separate_shader_objects for OpenGL ESIan Romanick2014-05-021-3/+5
| | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* glsl: Sort the list of extensionsIan Romanick2014-05-021-42/+53
| | | | | | | | ARB, OES, then everything else. If there's ever a KHR shading language extension, it should go between ARB and OES. Signed-off-by: Ian Romanick <[email protected]> Acked-by: Eric Anholt <[email protected]>
* glsl: Link error if fs defines conflicting qualifiers for gl_FragCoordAnuj Phogat2014-05-011-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GLSL 1.50 spec says: "If gl_FragCoord is redeclared in any fragment shader in a program, it must be redeclared in all the fragment shaders in that program that have a static use gl_FragCoord. All redeclarations of gl_FragCoord in all fragment shaders in a single program must have the same set of qualifiers." This patch causes the shader link to fail if we have multiple fragment shaders with conflicting layout qualifiers for gl_FragCoord. V2: Restructure the code and add conditions to correctly handle the following case: fragment shader 1: layout(origin_upper_left) in vec4 gl_FragCoord; void main() { foo(); gl_FragColor = gl_FragData; } fragment shader 2: layout(pixel_center_integer) in vec4 gl_FragCoord; void foo() { } V3: Allow linking in the following case: fragment shader 1: void main() { foo(); gl_FragColor = gl_FragCoord; } fragment shader 2: in vec4 gl_FragCoord; void foo() { ... } Signed-off-by: Anuj Phogat <[email protected]> Cc: <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Compile error if fs defines conflicting qualifiers for gl_FragCoordAnuj Phogat2014-05-011-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GLSL 1.50 spec says: "If gl_FragCoord is redeclared in any fragment shader in a program, it must be redeclared in all the fragment shaders in that program that have a static use gl_FragCoord. All redeclarations of gl_FragCoord in all fragment shaders in a single program must have the same set of qualifiers." This patch makes the glsl compiler to generate an error if we have a fragment shader defined with conflicting layout qualifier declarations for gl_FragCoord. For example: layout(origin_upper_left, pixel_center_integer) in vec4 gl_FragCoord; layout(pixel_center_integer) in vec4 gl_FragCoord; void main() { } V2: Some code refactoring for better readability. Add compiler error conditions for redeclarations like: layout(origin_upper_left) in vec4 gl_FragCoord; layout(origin_upper_left, pixel_center_integer) in vec4 gl_FragCoord; and in vec4 gl_FragCoord; layout(origin_upper_left, pixel_center_integer) in vec4 gl_FragCoord; V3: Simplify function is_conflicting_fragcoord_redeclaration() V4: Check for null pointer before doing strcmp(var->name, "gl_FragCoord"). Signed-off-by: Anuj Phogat <[email protected]> Cc: <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* 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]>