aboutsummaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl/builtin_variables.cpp
Commit message (Collapse)AuthorAgeFilesLines
* mesa: include mtypes.h lessMarek Olšák2018-04-121-1/+1
| | | | | | | | | | - remove mtypes.h from most header files - add main/menums.h for often used definitions - remove main/core.h v2: fix radv build Reviewed-by: Brian Paul <[email protected]>
* glsl: Add support for the framebuffer fetch layout(noncoherent) qualifier.Francisco Jerez2018-02-241-0/+1
| | | | | | | | | | This allows the application to request framebuffer fetch coherency with per-fragment output granularity. Coherent framebuffer fetch outputs (which is the default if no qualifier is present for compatibility with older versions of the EXT_shader_framebuffer_fetch extension) will have ir_variable_data::memory_coherent set to true. Reviewed-by: Plamena Manolova <[email protected]>
* mesa: implement ARB_compatibilityMarek Olšák2018-02-231-1/+1
| | | | | Tested-by: Dieter Nützel <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* glsl: remove Lower{TCS,TES}PatchVerticesInIago Toral Quiroga2018-01-101-12/+1
| | | | | | | | | | | | Intel was the only user and now NIR can do the lowering. v2: do not try to handle it as a system value directly for the SPIR-V path. In GL we rather handle it as a uniform like we do for the GLSL path (Jason). v3: drop LowerTESPatchVerticesIn as well (Jason) Reviewed-by: Jason Ekstrand <[email protected]>
* glsl: Match order of gl_LightSourceParameters elements.Fabian Bieler2017-12-031-2/+2
| | | | | | | | | spotExponent and spotCosCutoff were swapped in the gl_builtin_uniform_element struct. Now the order matches across gl_builtin_uniform_element, glsl_struct_field and the spec. Reviewed-by: Brian Paul <[email protected]>
* glsl: fix derived cs variablesIlia Mirkin2017-10-231-90/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | There are two issues with the current implementation. First, it relies on the layout(local_size_*) happening in the same shader as the main function, and secondly it doesn't work for variable group sizes. In both cases, the simplest fix is to move the setup of these derived values to a later time, similar to how the gl_VertexID workarounds are done. There already exist system values defined for both of the derived values, so we use them unconditionally, and lower them after linking is performed. While we're at it, we move to using gl_LocalGroupSizeARB instead of gl_WorkGroupSize for variable group sizes. Also the dead code elimination avoidance can be removed, since there can be situations where gl_LocalGroupSizeARB is needed but has not been inserted for the shader with main function. As a result, the lowering code has to insert its own copies of the system values if needed. Reported-by: Stephane Chevigny <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=103393 Cc: [email protected] Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Samuel Pitoiset <[email protected]>
* glsl: update the extensions/functions that are enabled for 460Samuel Pitoiset2017-08-071-0/+5
| | | | | | | | Other ones are either unsupported or don't have any helper function checks. Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]>
* glsl: gl_Max{Vertex,Fragment}UniformComponents exist in all desktop GL versionsIago Toral Quiroga2017-06-191-7/+9
| | | | | | | | | | The current implementation assumed that these were replaced in GLSL >= 4.10 by gl_Max{Vertex,Fragment}UniformVectors, however this is not true: both built-ins should be produced from GLSL 4.10 onwards. This was raised by new CTS tests that are in development. Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: Fix gl_shader_stage enum unsigned comparisonRob Herring2017-06-081-0/+4
| | | | | | | | | | | Replace -1 with MESA_SHADER_NONE enum value to fix sign related warning: external/mesa3d/src/compiler/glsl/link_varyings.cpp:1415:25: warning: comparison of constant -1 with expression of type 'gl_shader_stage' is always true [-Wtautological-constant-out-of-range-compare] (consumer_stage != -1 && consumer_stage != MESA_SHADER_FRAGMENT))) { ~~~~~~~~~~~~~~ ^ ~~ Reviewed-by: Nicolai Hähnle <[email protected]> Signed-off-by: Rob Herring <[email protected]>
* glsl: store the image format in glsl_struct_fieldSamuel Pitoiset2017-05-081-0/+1
| | | | | | | | ARB_bindless_texture allows to declare image types inside structures, which means we need to keep track of the format. Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: rename image_* qualifiers to memory_*Samuel Pitoiset2017-05-041-5/+5
| | | | | | | | | It doesn't make sense to prefix them with 'image' because they are called "Memory Qualifiers" and they can be applied to members of storage buffer blocks. Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Andres Gomez <[email protected]>
* glsl: add gl_SubGroup*ARB builtinsNicolai Hähnle2017-04-051-0/+22
| | | | Reviewed-by: Marek Olšák <[email protected]>
* glsl: add has_shader_image_load_store()Samuel Pitoiset2017-02-271-2/+1
| | | | | | | | Preliminary work for ARB_bindless_texture which can interact with ARB_shader_image_load_store. Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Anuj Phogat <[email protected]>
* mesa: Add EXT_frag_depth bits and enable it on all driversAnuj Phogat2017-02-131-0/+3
| | | | | | | | | Passes the newly added piglit test for this extension on i965. V2: Fix comments by Ilia. Signed-off-by: Anuj Phogat <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]>
* glsl: Allow compatibility shaders with MESA_GL_VERSION_OVERRIDE=...Matt Turner2017-02-091-1/+1
| | | | | | | | | | | | | | | | | | Previously if you used MESA_GL_VERSION_OVERRIDE=3.3COMPAT, Mesa exposed an OpenGL 3.3 compatibility profile context (with various unimplemented features and bugs), but still refused to compile shaders with #version 330 compatibility This patch simply adds a small bit of plumbing to let that through. Of course the same caveats apply: compatibility profile is still not supported (and will not be supported), so there are no guarantees that anything will work. Tested-by: Dylan Baker <[email protected]> Reviewed-by: Anuj Phogat <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Move builtin_function related prototypes to a separate fileIan Romanick2017-01-201-0/+1
| | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Support gl_TessLevelInner/Outer[] as TES input variables.Kenneth Graunke2017-01-061-4/+11
| | | | | | | | | | Upcoming reworks in i965 are going to make it easy to handle this like any other input. Having it as a system value will just require additional code for no benefit. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: add matrix layout information to interface block typesIago Toral Quiroga2016-10-241-0/+1
| | | | | | | | | | | | | | | | | | | | | | So far we have been checking that interface block definitions had matching matrix layouts by comparing the definitions of their fields, however, this does not cover the case where the interface blocks are defined with mismatching matrix layouts but don't define any field with a matrix type. In this case Mesa will not fail to link because none of the fields will inherit the mismatching layout qualifier. This patch fixes the problem in the same way we fixed it for packing layout information: we add the the layout information to the interface type and then we check it matches during the uniform block linking process. v2: Fix unit tests so they pass the new parameter to glsl_type::get_interface_instance() Fixes: dEQP-GLES31.functional.shaders.linkage.uniform.block.layout_qualifier_mismatch_3 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98245 Reviewed-by: Nicolai Hähnle <[email protected]> (v1)
* glsl: add gl_LocalGroupSizeARB as a system valueSamuel Pitoiset2016-10-071-0/+6
| | | | | | | | v2: - only add it if the ext is enabled (Ilia) Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: add OES_viewport_array enables and use them to expose gl_ViewportIndexIlia Mirkin2016-09-221-3/+6
| | | | | Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Anuj Phogat <[email protected]>
* mesa: Implement ARB_shader_viewport_layer_array for i965Dylan Baker2016-09-201-2/+12
| | | | | | | | | | | | | This extension is a combination of AMD_vertex_shader_viewport_index and AMD_vertex_shader_layer, making it rather trivial to implement. For gallium I *think* this needs a new cap because of the addition of support in tessellation evaluation shaders, and since I don't have any hardware to test it on, I've left that for someone else to wire up. Signed-off-by: Dylan Baker <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: expose max atomic counter/buffer consts for tess in ES 3.2Ilia Mirkin2016-09-031-2/+2
| | | | | | | | Curiously OES/EXT_tessellation_shader leave these out, while ES 3.2 adds them in. Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: add gl_BoundingBox and associated varying slotsIlia Mirkin2016-08-301-0/+12
| | | | | Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Fix incorrect hard-coded location of the gl_SecondaryFragColorEXT ↵Francisco Jerez2016-08-301-7/+2
| | | | | | | | | | | | | | | | | | | built-in. gl_SecondaryFragColorEXT should have the same location as gl_FragColor for the secondary fragment color to be replicated to all fragment outputs. The incorrect location of gl_SecondaryFragColorEXT would cause the linker to mark both FRAG_RESULT_COLOR and FRAG_RESULT_DATA0 as being written to, which isn't allowed by the spec and would ultimately lead to an assertion failure in fs_visitor::emit_fb_writes() on my i965-fb-fetch branch. This should also fix the code below for multiple dual-source-blended render targets, which no driver currently supports but we have plans to enable eventually in the i965 driver (the comment saying that no hardware will ever support it seems rather hilarious). Reviewed-by: Ilia Mirkin <[email protected]>
* glsl: Allow gl_InvocationID and gl_Layer with GL_OES_geometry_shaderIan Romanick2016-08-261-2/+11
| | | | | | | | | | | | | | | Fixes dEQP-GLES31.functional.geometry_shading.layered.fragment_layer_2d_array dEQP-GLES31.functional.geometry_shading.layered.fragment_layer_2d_multisample_array dEQP-GLES31.functional.geometry_shading.layered.fragment_layer_3d dEQP-GLES31.functional.geometry_shading.layered.fragment_layer_cubemap v2: Don't enable gl_ViewportIndex in GLSL ES 3.20. Noticed by Ilia. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* mesa: Allow GL_EXT_geometry_shader and GL_EXT_geometry_point_sizeIan Romanick2016-08-261-1/+2
| | | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Define a gl_LastFragData built-in for older GLSL versions.Francisco Jerez2016-08-241-0/+10
| | | | | | | | | | | | | | | | | | | | | | | The EXT_shader_framebuffer_fetch extension defines alternative language for GLES2 shaders where user-defined fragment outputs are not allowed. Instead of using inout user-defined fragment outputs the shader is expected to read from the gl_LastFragData built-in array. In addition this allows using the same language on desktop GLSL versions prior to 4.2 that support the deprecated gl_FragData built-in in preparation for the MESA_shader_framebuffer_fetch desktop GL extension. Both legacy and user-defined inout outputs have a common representation at the GLSL IR level, so it shouldn't make any difference for optimization passes and back-ends whether the application is using gl_LastFragData or user-defined outputs, all they'll see is a variable dereference of a fragment output at a certain interface location with the fb_fetch_output bit set to one. v2: Don't define the built-in variable on GLSL versions for which gl_FragData exists but is deprecated. (Ken) Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Expose gl_PointSize if OES/EXT_tessellation_point_size is enabled.Kenneth Graunke2016-08-081-1/+5
| | | | | Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add a has_tessellation_shader() helper.Kenneth Graunke2016-08-071-4/+2
| | | | | | | | Similar to has_geometry_shader(), has_compute_shader(), and so on. This will make it easier to add more conditions here later. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* compiler: Rename INTERP_QUALIFIER_* to INTERP_MODE_*.Kenneth Graunke2016-07-171-10/+10
| | | | | | | | | | | | | | | | | Likewise, rename the enum type to glsl_interp_mode. Beyond the GLSL front-end, talking about "interpolation modes" seems more natural than "interpolation qualifiers" - in the IR, we're removed from how exactly the source language specifies how to interpolate an input. Also, SPIR-V calls these "decorations" rather than "qualifiers". Generated by: $ find . -regextype egrep -regex '.*\.(c|cpp|h)' -type f -exec sed -i \ -e 's/INTERP_QUALIFIER_/INTERP_MODE_/g' \ -e 's/glsl_interp_qualifier/glsl_interp_mode/g' {} \; Signed-off-by: Kenneth Graunke <[email protected]> Acked-by: Dave Airlie <[email protected]>
* glsl: pass symbols rather than shader to _mesa_get_main_function_signature()Timothy Arceri2016-06-301-1/+1
| | | | | | | This will allow us to split gl_shader into two different structs, one for shader objects and one for linked shaders. Reviewed-by: Iago Toral Quiroga <[email protected]>
* glsl: Optionally lower TCS gl_PatchVerticesIn to a uniform.Kenneth Graunke2016-06-151-1/+12
| | | | | | | | | i965 has no special hardware for this, so the best way to implement this is to pass it in via a uniform. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Alejandro Piñeiro <[email protected]> Cc: [email protected]
* glsl/builtin_variables: Populate MaxCombinedShaderStorageBlocks on GLSL 4.40Eduardo Lima Mitev2016-06-141-1/+1
| | | | | | | | | | | | | | | Built-in variable "MaxCombinedShaderStorageBlocks" was added to GLSL 4.40 revision 9. Section "1.2.1 Changes since revision 8 of GLSL version 4.40", page 3 of the PDF states: "Bug 11734: Add gl_MaxCombinedShaderOutputResources and mark gl_MaxCombinedImageUnitsAndFragmentOutputs as deprecated." Fixes: GL44-CTS.shader_image_load_store.basic-glsl-const Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Add glsl LowerCsDerivedVariables optionJordan Justen2016-06-011-11/+18
| | | | | | | | | | v2: * Move lower flag to context constants. (Ken) Cc: "12.0" <[email protected]> Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> (v1) Reviewed-by: Jason Ekstrand <[email protected]>
* glsl: define some GLES3 constants in GLSL 4.1Dave Airlie2016-06-011-1/+1
| | | | | | | | | | | | | | The GLSL 4.1 spec adds: gl_MaxVertexUniformVectors gl_MaxFragmentUniformVectors gl_MaxVaryingVectors This fixes: GL45-CTS.gtf31.GL3Tests.uniform_buffer_object.uniform_buffer_object_build_in_constants Reviewed-by: Ilia Mirkin <[email protected]> Cc: "12.0 11.2" <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl: add GL_EXT_clip_cull_distance define, add helpersIlia Mirkin2016-05-251-6/+4
| | | | | Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Tobias Klausmann <[email protected]>
* glsl: add EXT_clip_cull_distance support based on ARB_cull_distanceIlia Mirkin2016-05-231-4/+8
| | | | | Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Dave Airlie <[email protected]>
* glsl: Add arb_cull_distance support (v3)Tobias Klausmann2016-05-141-1/+10
| | | | | | | | | v2: make too large array a compile error v3: squash mesa/prog patch to avoid static compiler errors in bisect Signed-off-by: Tobias Klausmann <[email protected]> Signed-off-by: Dave Airlie <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: export accessor for builtin-uniform descriptorsRob Clark2016-05-111-9/+12
| | | | | | | We'll need this for a nir pass to lower builtin-uniform access. Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* glsl: add ARB_ES3_1_compatibility supportIlia Mirkin2016-04-031-7/+9
| | | | | | | | Oddly a bunch of the features it adds are actually from ESSL 3.20. But the spec is quite clear, oh well. Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Dave Airlie <[email protected]>
* glsl: add GL_OES_sample_variables supportIlia Mirkin2016-03-301-4/+11
| | | | | | Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Dave Airlie <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: add gl_MaxSamples, new in GL 4.5 / GL ES 3.2Ilia Mirkin2016-03-301-0/+3
| | | | | | Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Dave Airlie <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: add field to track if xfb_buffer is an explicit or implicit valueTimothy Arceri2016-03-311-0/+1
| | | | | | | | | Since any of the xfb_* qualifiers trigger the shader to be in transform feedback mode we need an extra field to track if the xfb_buffer on interface members was set explicitly since xfb_buffer will always have a default value. Reviewed-by: Dave Airlie <[email protected]>
* glsl: add xfb_* qualifiers to glsl_struct_fieldTimothy Arceri2016-03-311-0/+2
| | | | | | | | | | | | | These will be used to hold qualifier values for interface and struct members. Support is added to the struct/interface constructors to copy these fields upon creation. We also update record_compare() to ensure we don't reuse a glsl_type with the wrong xfb_* qualifier values. Reviewed-by: Dave Airlie <[email protected]>
* glsl: add transform feedback built-in constantsTimothy Arceri2016-03-311-0/+7
| | | | | | These are new built-ins added by ARB_enhanced_layouts. Reviewed-by: Dave Airlie <[email protected]>
* glsl: add offset to glsl interface typeTimothy Arceri2016-03-051-0/+1
| | | | | | | | | | | | | | | | In this patch we also copy the offset value from the ast and implement offset linking rules by adding it to the record_compare() function. From Section 4.4.5 (Uniform and Shader Storage Block Layout Qualifiers) of the GLSL 4.50 spec: "Two blocks linked together in the same program with the same block name must have the exact same set of members qualified with offset and their integral-constant-expression values must be the same, or a link-time error results." Reviewed-by: Edward O'Callaghan <[email protected]>
* mesa: make compute maximums reflect driver-provided valuesIlia Mirkin2016-02-131-5/+10
| | | | | | | | Looks like the various max's were never plumbed through. Signed-off-by: Ilia Mirkin <[email protected]> Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Marek Olšák <[email protected]>
* glsl: always initialize image_* fields, copy them on interface initIlia Mirkin2016-01-291-0/+5
| | | | | | | | | Interfaces can have image properties set in case they are buffer interfaces. Make sure not to lose this information. Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]> Reviewed-by: Marek Olšák <[email protected]>
* glsl: add GL_OES_geometry_point_size and conditionalize gl_PointSizeIlia Mirkin2016-01-261-1/+6
| | | | | | | | | | | For now this will be enabled in tandem with GL_OES_geometry_shader. Should a driver come along that wants to separate them out, another enable can be added. Also adds the missed GL_OES_geometry_shader define in glcpp. Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Marta Lofstedt <[email protected]>
* glsl: move to compiler/Emil Velikov2016-01-261-0/+1394
Signed-off-by: Emil Velikov <[email protected]> Acked-by: Matt Turner <[email protected]> Acked-by: Jose Fonseca <[email protected]>