summaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl
Commit message (Collapse)AuthorAgeFilesLines
* glsl/standalone: set MaxTransformFeedbackBuffersAlejandro Piñeiro2018-01-051-0/+3
| | | | | | | | Using 4, as it is the default value on mesa. See mesa/main/config.h and the following commit that introduced the value: 15ac66e331abdab12e882d80a6b4f647bc905298 Reviewed-by: Ian Romanick <[email protected]>
* glsl/standalone: set MaxVertexStreamsAlejandro Piñeiro2018-01-051-0/+3
| | | | | | | ARB_transform_feedback3 sets a minimum of 1, ARB_gpu_shader5 a minimum of 4. It shouldn't matter too much, so choosing the later. Reviewed-by: Ian Romanick <[email protected]>
* glsl/standalone: set MaxUniformBufferBindingsAlejandro Piñeiro2018-01-051-0/+3
| | | | | | | | Used to handle how many ubo you can define on the context. Minimimum defined as 36 on ARB_uniform_buffer_object spec, up to 84 on OpenGL 4.6 (12 per stage at each moment). Reviewed-by: Ian Romanick <[email protected]>
* glsl/standalone: point which arguments are mandatoryAlejandro Piñeiro2018-01-051-1/+4
| | | | | | | Every now and then I execute the standalone compiler, get the non-version error, and need to remember what I'm doing wrong Reviewed-by: Ian Romanick <[email protected]>
* glsl: disable vec3 packing/splitting in tfb separate modeBrian Paul2017-12-201-1/+13
| | | | | | | | | | | | | | | | This fixes a varying packing issue when using transform feedback in GL_SEPARATE_ATTRIBS mode. By time we get to linking, we already know that the number of feedback attributes is under the GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS limit so packing isn't as critical. In fact, packing/splitting vec3 attributes can cause trouble because splitting effectively creates another TFB output which can exceed device limits. So, disable vec3 packing when it's not needed to avoid that issue. Fixes the Piglit ext_transform_feedback-separate test on VMware driver. Reviewed-by: Timothy Arceri <[email protected]>
* glsl: simply packing class comparisonBrian Paul2017-12-201-2/+3
| | | | | | | Handle comparing the packing class using the same method as we do for var->data.is_xfb_only Reviewed-by: Timothy Arceri <[email protected]>
* glsl: document varying_matches::assign_locations() params and return valueBrian Paul2017-12-201-2/+7
| | | | | | And change *components to components[] as a reminder that it's an array. Reviewed-by: Timothy Arceri <[email protected]>
* glsl: remove some continue statementsBrian Paul2017-12-201-13/+11
| | | | | | | In some cases, I think loop code is easier to read without continue statements. Reviewed-by: Timothy Arceri <[email protected]>
* glsl: use bitwise operators in varying_matches::compute_packing_class()Brian Paul2017-12-201-5/+10
| | | | | | | | | | The mix of bitwise operators with * and + to compute the packing_class values was a little weird. Just use bitwise ops instead. v2: add assertion to make sure interpolation bits fit without collision, per Timothy. Basically, rewrite function to be simpler. Reviewed-by: Timothy Arceri <[email protected]>
* glsl: simplify loop in varying_matches::assign_locations()Brian Paul2017-12-201-5/+5
| | | | | | The use of break/continue was kind of weird/confusing. Reviewed-by: Timothy Arceri <[email protected]>
* glsl: minor simplification in assign_varying_locations()Brian Paul2017-12-201-5/+3
| | | | Reviewed-by: Timothy Arceri <[email protected]>
* glsl: make varying_matches::is_varying_packing_safe() constBrian Paul2017-12-201-2/+2
| | | | Reviewed-by: Timothy Arceri <[email protected]>
* glsl: trivial comment fixes in lower_packed_varyings.cppBrian Paul2017-12-201-1/+1
| | | | Reviewed by: Timothy Arceri <[email protected]>
* glsl: trivial whitespace fixes in link_varyings.cppBrian Paul2017-12-131-2/+2
|
* main, glsl: Add UniformDataDefaults which stores uniform defaultsJordan Justen2017-12-083-2/+19
| | | | | | | | | | | | | | | | | | | The ARB_get_program_binary extension requires that uniform values in a program be restored to their initial value just after linking. This patch saves off the initial values just after linking. When the program is restored by glProgramBinary, we can use this to copy the initial value of uniforms into UniformDataSlots. V2 (Timothy Arceri): - Store UniformDataDefaults only when serializing GLSL as this is what we want for both disk cache and ARB_get_program_binary. This saves us having to come back later and reset the Uniforms on program binary restores. Signed-off-by: Timothy Arceri <[email protected]> Signed-off-by: Jordan Justen <[email protected]> (v1) Reviewed-by: Tapani Pälli <[email protected]>
* glsl: Split out shader program serializationJordan Justen2017-12-084-1181/+1294
| | | | | | | | This will allow us to use the program serialization to implement ARB_get_program_binary. Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: get correct member type when processing xfb ifc arraysTimothy Arceri2017-12-071-2/+4
| | | | | | | | | This fixes a crash in: KHR-GL45.enhanced_layouts.xfb_block_stride Fixes: 0822517936d4 "glsl: add helper to process xfb qualifiers during linking" Reviewed-by: Kenneth Graunke <[email protected]>
* nir: Handle fp16 rounding modes at nir_type_conversion_opJose Maria Casanova Crespo2017-12-061-1/+2
| | | | | | | | | | | | | | | | | nir_type_conversion enables new operations to handle rounding modes to convert to fp16 values. Two new opcodes are enabled nir_op_f2f16_rtne and nir_op_f2f16_rtz. The undefined behaviour doesn't has any effect and uses the original nir_op_f2f16 operation. v2: Indentation fixed (Jason Ekstrand) v3: Use explicit case for undefined rounding and assert if rounding mode is used for non 16-bit float conversions (Jason Ekstrand) Reviewed-by: Jason Ekstrand <[email protected]>
* glsl: Add 16-bit typesEduardo Lima Mitev2017-12-065-4/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adds new INT16, UINT16 and FLOAT16 base types. The corresponding GL types for half floats were reused from the AMD_gpu_shader_half_float extension. The int16 and uint16 types come from NV_gpu_shader_5 extension. This adds the builtins and the lexer support. To avoid a bunch of warnings due to cases not handled in switch, the new types have been added to a few places using same behavior as their 32-bit counterparts, except for a few trivial cases where they are already handled properly. Subsequent patches in this set will provide correct 16-bit implementations when needed. v2: * Use FLOAT16 instead of HALF_FLOAT as name of the base type. * Removed float16_t from builtin types. * Don't copy 16-bit types as if they were 32-bit values in copy_constant_to_storage(). * Use get_scalar_type() instead of adding a new custom switch statement. (Jason Ekstrand) v3: Use GL_FLOAT16_NV instead of GL_HALF_FLOAT for consistency (Ilia Mirkin) v4: Add missing 16-bit base types support in glsl_to_nir (Eduardo Lima). v5: Fix coding style (Topi Poholainen). Signed-off-by: Jose Maria Casanova Crespo <[email protected]> Signed-off-by: Eduardo Lima <[email protected]> Signed-off-by: Alejandro Piñeiro <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: don't run intrastage array validation when the interface type is not ↵Samuel Iglesias Gonsálvez2017-12-041-1/+1
| | | | | | | | | | | | | | | | | an array We validate that the interface block array type's definition matches. However, previously, the function could be called if an non-array interface block has different type definitions -for example, when the precision qualifier differs in a GLSL ES shader, we would create two different types-, and it would return invalid as both definitions are non-arrays. We fix this by specifying that at least one definition should be an array to call the validation. Signed-off-by: Samuel Iglesias Gonsálvez <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl/es: precision qualifier doesn't need to match in UBOsSamuel Iglesias Gonsálvez2017-12-041-1/+1
| | | | | | | | | They might mismatch due to the two shaders using different GLSL versions, and that's ok in desktop GL. In ES, precision qualifiers don't need to match. Signed-off-by: Samuel Iglesias Gonsálvez <[email protected]> Reviewed-by: Nicolai Hähnle <[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]>
* mesa: add AllowGLSLCrossStageInterpolationMismatch workaroundTapani Pälli2017-11-301-18/+33
| | | | | | | | | | | | | This fixes issues seen with certain versions of Unreal Engine 4 editor and games built with that using GLSL 4.30. v2: add driinfo_gallium change (Emil Velikov) Signed-off-by: Tapani Pälli <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97852 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=103801 Acked-by: Andres Gomez <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* mesa: rework _mesa_add_parameter() to only add a single paramTimothy Arceri2017-11-291-2/+2
| | | | | | | | | This is more inline with what the functions name suggests it should do, and makes the code much easier to follow. This will also make adding uniform packing support much simpler. Reviewed-by: Nicolai Hähnle <[email protected]>
* st/glsl_to_tgsi: make use of driver_cache_blob with the disk cacheTimothy Arceri2017-11-281-1/+1
| | | | | | | | | | | | driver_cache_blob was introduced with the i965 disk cache, it allows us to simplify the cache a little and possibly offers some minor speed improvements since we load the GLSL metadata and TGSI from disk in one pass. Using driver_cache_blob should also make it straight forward to implement binary support for ARB_get_program_binary in gallium. Reviewed-by: Marek Olšák <[email protected]>
* glsl: Fix typo nagivation -> navigationGwan-gyeong Mun2017-11-281-1/+1
| | | | | | Signed-off-by: Mun Gwan-gyeong <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: Catch subscripted calls to undeclared subroutinesGeorge Barrett2017-11-201-2/+7
| | | | | | | | | | generate_array_index fails to check whether the target of a subroutine call exists in the AST, potentially passing around null ir_rvalue pointers eventuating in abort/segfault. Fixes: fd01840c0bd3 ("glsl: add AoA support to subroutines") Reviewed-by: Timothy Arceri <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=100438
* glsl/linker: use without_array() to retrieve typeIago Toral Quiroga2017-11-131-3/+4
| | | | | | | | This is what we do in the condition too, so it makes sense. v2: Only compute without_array() once (Ilia). Reviewed-by: Ilia Mirkin <[email protected]>
* nir: add streams to nir dataTimothy Arceri2017-11-121-0/+1
| | | | | | This will be used by gallium drivers. Reviewed-by: Marek Olšák <[email protected]>
* glsl: Make #pragma STDGL invariant(all) only modify outputs.Kenneth Graunke2017-11-081-24/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | According to the GLSL ES 3.20, GLSL 4.50, and GLSL 1.20 specs: "To force all output variables to be invariant, use the pragma #pragma STDGL invariant(all) before all declarations in a shader." Notably, this is only supposed to affect output variables. Furthermore, "Only variables output from a shader can be candidates for invariance." It looks like this has been wrong since we first supported the pragma in 2011 (commit 86b4398cd158024f6be9fa830554a11c2a7ebe0c). Fixes dEQP-GLES2.functional.shaders.preprocessor.pragmas.pragma_fragment. v2: Now that all cases are identical (other than compute shaders, which have no output variables anyway), we can drop the switch statement entirely. We also don't need the current_function == NULL check; this was a hold over from when we had a single var_mode_out for both function parameters and shader varyings, in the bad old days. Reviewed-by: Iago Toral Quiroga <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]>
* glsl: Transform fb buffers are only active if a variable uses themNeil Roberts2017-11-091-9/+15
| | | | | | | | | | | | | | | The GL spec will soon be revised to clarify that a buffer binding for a transform feedback buffer is only required if a variable is actually defined to use the buffer binding point. Previously a declaration for the default transform buffer would make it require a binding even if nothing was declared to use the default buffer. Affects: KHR-GL44/45.enhanced_layouts.xfb_stride_of_empty_list KHR-GL44/45.enhanced_layouts.xfb_stride_of_empty_list_and_api Reviewed-by: Nicolai Hähnle <[email protected]> Cc: [email protected]
* glsl: Minor cleanups after previous commitIan Romanick2017-11-081-18/+11
| | | | | | | | | | | | I think it's more clear to only call emit_access once. The only difference between the two calls is the value of size_mul used for the offset parameter... but you really have to look at it to be sure. The s/is_64bit/is_double/ change is because there are no int64_t or uint64_t matrix types. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Thomas Helland <[email protected]>
* glsl: Use more link_calculate_matrix_stride in lower_buffer_accessIan Romanick2017-11-081-20/+2
| | | | | | | | I was going to squash this with the previous commit, but there's a lot of churn in that commit. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Thomas Helland <[email protected]>
* glsl: Use link_calculate_matrix_stride in lower_buffer_access and friendsIan Romanick2017-11-084-70/+42
| | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Thomas Helland <[email protected]>
* glsl: Refactor matrix stride calculation into a utility functionIan Romanick2017-11-082-11/+50
| | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Thomas Helland <[email protected]>
* glsl/linker: Optimize swizzles again after linkingIan Romanick2017-11-081-0/+10
| | | | | | | | | | | | | | Without this, the SPIR-V generator has to deal with a bunch of junk like: (swiz z (swiz xxx (swiz x (var_ref packed:binormal.z,light_dir)))) It seems better to cull that stuff out than to add code to deal with it. The problem is the way swizzles to and from scalars have to be handled in SPIR-V. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Thomas Helland <[email protected]>
* glsl: Combine nop-swizzle optimization with swizzle-swizzle optimizationIan Romanick2017-11-086-116/+51
| | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: <[email protected]>
* glsl: Make the swizzle-swizzle optimization greedyIan Romanick2017-11-081-30/+29
| | | | | | | | If there is a long sequence of swizzled swizzles, compact all of them down to a single swizzle. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: <[email protected]>
* glsl: Remove program_resource_visitor::visit_field(const glsl_struct_field *)Ian Romanick2017-11-082-18/+0
| | | | | | | I could not find any remaining users. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: Silence unused parameter warningIan Romanick2017-11-081-1/+1
| | | | | | | | | | | | | | glsl/lower_shared_reference.cpp: In member function ‘virtual void {anonymous}::lower_shared_reference_visitor::insert_buffer_access(void*, ir_dereference*, const glsl_type*, ir_rvalue*, unsigned int, int)’: glsl/lower_shared_reference.cpp:244:58: warning: unused parameter ‘channel’ [-Wunused-parameter] int channel) ^~~~~~~ Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: use the correct parent when allocating program data membersTimothy Arceri2017-11-094-8/+8
| | | | | | Cc: "17.2 17.3" <[email protected]> Reviewed-by: Tapani Pälli <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: drop cache_fallbackTimothy Arceri2017-11-093-60/+42
| | | | | | | | | | This turned out to be a dead end, it is much easier and less error prone to just cache the IR used by the drivers backend e.g. TGSI or NIR. Cc: "17.2 17.3" <[email protected]> Reviewed-by: Tapani Pälli <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* meson: Add threads dependencies to glsl_compiler executableDylan Baker2017-11-081-1/+1
| | | | | | | | Fixes compiling the optional standalone glsl compiler. Reported-by: DrNick (on irc) Signed-off-by: Dylan Baker <[email protected]> Reviewed-and-Tested-by: Eric Engestrom <[email protected]>
* glsl: Fix typo fragement -> fragmentAndreas Boll2017-11-081-1/+1
| | | | | | | | | | Fixes: 94d669b0d2f ("glsl: enforce fragment shader input restrictions in GLSL ES 3.10") Signed-off-by: Andreas Boll <[email protected]> Reviewed-by: Eric Engestrom <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* glsl: add varying resources for arrays of complex typesJuan A. Suarez Romero2017-11-081-4/+59
| | | | | | | | | | | | | This patch is mostly a patch done by Ilia Mirkin. It fixes KHR-GL45.enhanced_layouts.varying_structure_locations. v2: fix locations for TCS/TES/GS inputs and outputs (Ilia) CC: Ilia Mirkin <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=103098 Reviewed-by: Nicolai Hähnle <[email protected]> Signed-off-by: Juan A. Suarez Romero <[email protected]>
* nir: Make ballot intrinsics variable-sizeJason Ekstrand2017-11-071-0/+1
| | | | | | | | This way they can return either a uvec4 or a uint64_t. At the moment, this is a no-op since we still always return a uint64_t. Reviewed-by: Lionel Landwerlin <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]>
* glsl: Allow precision mismatch on dead data with GLSL ES 1.00Tomasz Figa2017-11-061-4/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 259fc505454ea6a67aeacf6cdebf1398d9947759 added linker error for mismatching uniform precision, as required by GLES 3.0 specification and conformance test-suite. Several Android applications, including Forge of Empires, have shaders which violate this rule, on a dead varying that will be eliminated. The problem affects a big number of applications using Cocos2D engine and other GLES implementations accept this, this poses a serious application compatibility issue. Starting from GLSL ES 3.0, declarations with conflicting precision qualifiers are explicitly prohibited. However GLSL ES 1.00 does not clearly specify the behavior, except that "Uniforms are defined to behave as if they are using the same storage in the vertex and fragment processors and may be implemented this way. If uniforms are used in both the vertex and fragment shaders, developers should be warned if the precisions are different. Conversion of precision should never be implicit." The word "used" is not clear in this context and might refer to 1) declared (same as GLES 3.x) 2) referred after post-processing, or 3) linked after all optimizations are done. Looking at existing applications, 2) or 3) seems to be widely adopted. To avoid compatibility issues, turn the error into a warning if GLSL ES version is lower than 3.0 and the data is dead in at least one of the shaders. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97532 Signed-off-by: Tomasz Figa <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: fix interpolateAtXxx(some_vec[idx], ...) with dynamic idxNicolai Hähnle2017-11-031-1/+30
| | | | | | | | | | | | | The dynamic index of a vector (not array!) is lowered to a sequence of conditional assignments. However, the interpolate_at_* expressions require that the interpolant is an l-value of a shader input. So instead of doing conditional assignments of parts of the shader input and then interpolating that (which is nonsensical), we interpolate the entire shader input and then do conditional assignments of the interpolated result. Reviewed-by: Timothy Arceri <[email protected]>
* glsl: allow any l-value of an input variable as interpolant in interpolateAt*Nicolai Hähnle2017-11-032-5/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | The intended rule has been clarified in GLSL 4.60, Section 8.13.2 (Interpolation Functions): "For all of the interpolation functions, interpolant must be an l-value from an in declaration; this can include a variable, a block or structure member, an array element, or some combination of these. Component selection operators (e.g., .xy) may be used when specifying interpolant." For members of interface blocks, var->data.must_be_shader_input must be determined on-the-fly after lowering interface blocks, since we don't want to disable varying packing for an entire block just because one input in it is used in interpolateAt*. v2: keep setting must_be_shader_input in ast_function (Ian) v3: follow the relaxed rule of GLSL 4.60 v4: only apply the relaxed rules to desktop GL (the ES WG decided that the relaxed rules may apply in a future version but not retroactively; see also dEQP-GLES31.functional.shaders.multisample_interpolation.interpolate_at_centroid.negative.*) Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101378 Reviewed-by: Ian Romanick <[email protected]> (v1) Reviewed-by: Timothy Arceri <[email protected]>
* glsl/shader_cache: Save fs (BlendSupport) metadataJordan Justen2017-10-311-0/+6
| | | | | | | | | | | | | | | | | | Fixes many GL 4.5 CTS blend tests, such as: * GL45-CTS.blend_equation_advanced.extension_directive_enable * GL45-CTS.blend_equation_advanced.extension_directive_warn * GL45-CTS.blend_equation_advanced.blend_all.GL_MULTIPLY_KHR_all_qualifier * GL45-CTS.blend_equation_advanced.blend_specific.GL_COLORBURN_KHR v2: * Directly save the BlendSupport field to avoid potentially including a pointer in the future in the structure is updated. (tarceri) Cc: Timothy Arceri <[email protected]> Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>