aboutsummaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl
Commit message (Collapse)AuthorAgeFilesLines
* mesa: do not use bitfields for advanced-blend stateErik Faye-Lund2020-07-172-19/+17
| | | | | | | Signed-off-by: Elie Tournier <[email protected]> Reviewed-by: Gert Wollny <[email protected]> Reviewed-by: Dave Airlie <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5516>
* glsl: declare gl_Layer/gl_ViewportIndex/gl_ViewportMask as vs builtinsPierre-Eric Pelloux-Prayer2020-07-091-50/+55
| | | | | | | | | | | | | | | | | | | | | | | | Otherwise a VS doing the following: out gl_PerVertex { vec4 gl_Position; int gl_ViewportIndex; }; cannot be compiled because of the following error: "redeclaration of gl_PerVertex must be a subset of the built-in members of gl_PerVertex" v2: add GLSL_PRECISION_HIGH param to add_varying() for "gl_Layer" in generate_fs_special_vars. v3: add GLSL_PRECISION_HIGH param to add_varying() for "gl_Layer" in generate_varyings. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2946 Tested-by: John Galt <[email protected]> Reviewed-by: Marek Olšák <[email protected]> (v3) Reviewed-by: Ian Romanick <[email protected]> (v3) Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5167>
* glsl: only allow 32 bits atomic operations on imagesPierre-Eric Pelloux-Prayer2020-07-091-0/+44
| | | | | | | | | | | | | EXT_shader_image_load_store says: The format of the image unit must be in the "1x32" equivalence class otherwise the atomic operation is invalid. ARB_shader_image_load_store says: We will only support 32-bit atomic operations on images Fixes: fc0a2e5d017 ("glsl: add EXT_shader_image_load_store new image functions") Reviewed-by: Marek Olšák <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5688>
* glsl: don't expose imageAtomicIncWrap for signed imagePierre-Eric Pelloux-Prayer2020-07-091-15/+29
| | | | | | | | | The spec says that it's only allowed for unsigned ones. Same from imageAtomicDecWrap. Fixes: fc0a2e5d017 ("glsl: add EXT_shader_image_load_store new image functions") Reviewed-by: Marek Olšák <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5688>
* glsl: reject size1x8 for image variable with floating-point data typesPierre-Eric Pelloux-Prayer2020-07-091-5/+7
| | | | | | Fixes: 8d07d66180b ("glsl,nir: Switch the enum representing shader image formats to PIPE_FORMAT.") Reviewed-by: Marek Olšák <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5688>
* glsl: don't validate array types in ir_dereference_variableMarek Olšák2020-07-081-1/+4
| | | | | | | | Fixes: 8d62969cfe8 - glsl: validate more stuff Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3245 Reviewed-by: Alyssa Rosenzweig <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5813>
* glsl: lower mediump temporaries to 16 bits except structures (v2)Marek Olšák2020-07-073-2/+1022
| | | | | | | | | | | Without this, NIR contains non-lowerable 32-bit phis for mediump variables. Structures are not lowered yet. v2: add the LowerPrecisionTemporaries option Reviewed-by: Alyssa Rosenzweig <[email protected]> (v1) Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5746>
* glsl: Handle 16-bit types in loop analysisAlyssa Rosenzweig2020-07-071-0/+9
| | | | | | | | | | Fixes crash with mediump lowering in: dEQP-GLES2.functional.shaders.loops.do_while_constant_iterations.basic_mediump_float_fragment Signed-off-by: Alyssa Rosenzweig <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5746>
* glsl: add capability to lower mediump array typesMarek Olšák2020-07-071-29/+48
| | | | | | | | This is not needed for lowering expressions, because they always work with basic types, but it will be needed for lowering variables. Reviewed-by: Alyssa Rosenzweig <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5746>
* glsl: lower builtins to mediump that always return mediump or lowpMarek Olšák2020-07-072-2/+114
| | | | | Reviewed-by: Alyssa Rosenzweig <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5746>
* glsl: lower builtins to mediump that ignore precision of certain parametersMarek Olšák2020-07-072-0/+97
| | | | | Reviewed-by: Alyssa Rosenzweig <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5746>
* glsl: don't lower builtins to mediump that don't allow itMarek Olšák2020-07-073-15/+326
| | | | | Reviewed-by: Alyssa Rosenzweig <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5746>
* glsl: don't lower precision of textureSizeMarek Olšák2020-07-072-0/+19
| | | | | Reviewed-by: Alyssa Rosenzweig <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5746>
* glsl: flatten a tautological conditional in lower_precisionMarek Olšák2020-07-071-8/+5
| | | | | Reviewed-by: Alyssa Rosenzweig <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5746>
* glsl: cleanups in lower_precisionMarek Olšák2020-07-071-9/+8
| | | | | Reviewed-by: Alyssa Rosenzweig <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5746>
* glsl: remove the return type from lower_precisionMarek Olšák2020-07-072-10/+3
| | | | | | | It's unused. Reviewed-by: Alyssa Rosenzweig <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5746>
* glsl: convert reusable lower_precision util code into helper functionsMarek Olšák2020-07-071-27/+34
| | | | | Reviewed-by: Alyssa Rosenzweig <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5746>
* glsl: validate more stuffMarek Olšák2020-07-071-0/+66
| | | | | Reviewed-by: Alyssa Rosenzweig <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5746>
* glsl: run validate_ir_tree if GLSL_VALIDATE=1 regardless of the build configMarek Olšák2020-07-071-4/+5
| | | | | Reviewed-by: Alyssa Rosenzweig <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5746>
* glsl: fix evaluating float16 constant expression matricesMarek Olšák2020-07-071-0/+6
| | | | | Reviewed-by: Alyssa Rosenzweig <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5746>
* glsl: fix the type of ir_constant_data::u16Marek Olšák2020-07-071-1/+1
| | | | | Reviewed-by: Alyssa Rosenzweig <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5746>
* glsl: print constant initializersMarek Olšák2020-07-071-0/+10
| | | | | Reviewed-by: Alyssa Rosenzweig <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5746>
* glsl: print precision qualifiers in IR dumpsMarek Olšák2020-07-071-2/+3
| | | | | Reviewed-by: Alyssa Rosenzweig <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5746>
* glsl: make print_type non-static for debuggingMarek Olšák2020-07-072-11/+12
| | | | | Reviewed-by: Alyssa Rosenzweig <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5746>
* glsl: move fallthrough comment to where gcc can see itTimothy Arceri2020-07-021-1/+1
| | | | | Reviewed-by: Marek Olšák <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5705>
* glsl: fix constant packing for 64-bit big endian.Dave Airlie2020-07-012-10/+25
| | | | | | | | | In a piglit run on s390 a lot of double tests fail, explicitly packing/shifting things rather than using memcpy seems to help Cc: <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5679>
* glsl: remove stale FIXMETimothy Arceri2020-06-301-3/+0
| | | | | | | | This is no longer an issue, was likely fixed years ago. Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5657>
* glsl: define gl_LightSource members in ARB_vertex_program orderTimothy Arceri2020-06-302-4/+4
| | | | | | | | | | | | | | | | | | | | GLSL shares functionality with ARB_vertex_program but the GLSL spec defines the gl_LightSource builtin with a member order that is different from the packing expected in ARB_vertex_program. This difference introduces a need for specialist lowering code when handling builtin structs that is not required for normal uniform structs due to member location mismatches. Since gl_LightSource can't be redefined it shouldn't matter if we add the members in the order listed in the spec, just so long as we add them all. So here we rearrange the definition of the glsl builtin to reflex our internal layout and that of ARB_vertex_program. This required for the following patch. CC: <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5656>
* glsl,driconf: add allow_glsl_120_subset_in_110 for SPECviewperf13Marek Olšák2020-06-234-4/+9
| | | | | Reviewed-by: Pierre-Eric Pelloux-Prayer <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5459>
* nir/lower_images: handle dec and incKarol Herbst2020-06-181-0/+2
| | | | | | | Signed-off-by: Karol Herbst <[email protected]> Reviewed-by: Gert Wollny <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5480>
* nir/lower_images: fix for array of arraysKarol Herbst2020-06-181-2/+9
| | | | | | Signed-off-by: Karol Herbst <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5480>
* glsl_to_nir: fix vote_any/vote_allRob Clark2020-06-181-3/+4
| | | | | | Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5505>
* glsl_to_nir: fix shader_clockRob Clark2020-06-181-1/+0
| | | | | | Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5505>
* glsl_to_nir: fix is_helper_invocationRob Clark2020-06-181-1/+0
| | | | | | | Reported-by: Karol Herbst <[email protected]> Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5505>
* glsl: small optimisation fix for uniform array resizingTimothy Arceri2020-06-171-15/+10
| | | | | | | | | The fix in the previous patch removed an erronous attempt to skip resizing variable types in each stage. Now that has been removed iterating over each shader stage is no longer required here. Reviewed-by: Tapani Pälli <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5487>
* glsl: fix uniform array resizing in the nir linkerTimothy Arceri2020-06-171-44/+42
| | | | | | | | | | | | | | | | | | | | | | The initial support tried to match uniform variables from different shaders based on the variables pointer. This will obviously never work, instead here we use the variables name whcih also means we must disable this optimisation for spirv. Using the base variable name works because when collecting uniform references we never iterate past the first array dimension, and only support resizing 1D arrays (we also don't support resizing arrays inside structs). We also drop the resized bool as we can't skip processing the var just because is was resized in another shader, we must resize the var in all shaders. Fixes: a34cc97ca3e1 ("glsl: when NIR linker enable use it to resize uniform arrays") Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3130 Reviewed-by: Tapani Pälli <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5487>
* mesa/gles3: add support for GL_EXT_shader_group_voteDave Airlie2020-06-163-1/+22
| | | | | | | | This is the GLES equivalent to ARB_shader_group_vote. Passes: KHR-GLES31.core.shader_group_vote.* Reviewed-by: Marek Olšák <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5490>
* glsl: fix incorrect optimisation in opt_constant_variable()Timothy Arceri2020-06-121-0/+9
| | | | | | | | | | | | | | | When handling function inputs the optimisation pass incorrectly assumes the inputs are undefined. Here we simply change things to assume inputs have always been assigned a value. Any further optimisations will be taken care of once function inlining takes place. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2984 Fixes: 65122e9e8038 ("ir_constant_variable: New pass to mark constant-assigned variables constant.") Reviewed-by: Danylo Piliaiev <[email protected]> Reviewed-by: Pierre-Eric Pelloux-Prayer <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5413>
* nir: Properly preserve metadata in more casesJason Ekstrand2020-06-112-1/+18
| | | | | | Reviewed-by: Alyssa Rosenzweig <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5171>
* glsl: fix crash on glsl macro redefinitionAndrii Simiklit2020-06-101-0/+3
| | | | | | | | | | | | | | In case shader contains two equal macro defines, first one with trailing spaces and the second one without. `#define A 1 ` `#define A 1` The parser crashes Fixes: 0346ad37741b11d640c1c4970b275c1f0c7f9e75 ("glsl: ignore trailing whitespace when define redefined") Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Signed-off-by: Andrii Simiklit <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5312>
* glsl: inline functions with unsupported return type before converting to nirDanylo Piliaiev2020-06-081-0/+6
| | | | | | | | | | | | | glsl_to_nir doesn't expect non-vector/scalar return types in functions. Fixes: 7e60d5a501f311fa5e7bca5335adc6013dc1aeb9 Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3058 Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3060 Signed-off-by: Danylo Piliaiev <[email protected]> Tested-by: Witold Baryluk <[email protected]> Reviewed-by: Witold Baryluk <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5333>
* glsl: fix potential slow compile times for GLSLOptimizeConservativelyTimothy Arceri2020-06-071-1/+14
| | | | | | | | | | | | See code comment for full description of the change. Fixes: 0a5018c1a483 ("mesa: add gl_constants::GLSLOptimizeConservatively") Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3034 Tested-by: Witold Baryluk <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5346>
* glsl: when NIR linker enable use it to resize uniform arraysTimothy Arceri2020-06-032-13/+24
| | | | | | | | | | | | | | | | | | | | | | | Here we turn on uniform array resizing in the NIR linker and disable the GLSL IR resizing pass when the NIR linker is enabled. This will potentially make uniform arrays smaller due to NIR optimising away more uniform uses. Shader-db results (SKL): total instructions in shared programs: 14947192 -> 14944093 (-0.02%) instructions in affected programs: 138088 -> 134989 (-2.24%) helped: 822 HURT: 4 total cycles in shared programs: 324868402 -> 324794597 (-0.02%) cycles in affected programs: 3904170 -> 3830365 (-1.89%) helped: 2333 HURT: 1485 Reviewed-by: Kenneth Graunke <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4910>
* glsl: gather uniform dereference info before main linking loopTimothy Arceri2020-06-031-13/+24
| | | | | | | | | We want to gather information for all stages here before the main linking loop. In the following patch we will use to information to reduce the size of uniform arrays where possible. Reviewed-by: Kenneth Graunke <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4910>
* glsl: add update_array_sizes() helper to the NIR uniform linkerTimothy Arceri2020-06-031-0/+103
| | | | | | | | | This will be used to reduce the size of uniform arrays and replace the current glsl ir pass. Doing this in NIR allows us to better optimise the size of uniform arrays. Reviewed-by: Kenneth Graunke <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4910>
* glsl: add struct to gather more info about uniform array accessTimothy Arceri2020-06-031-8/+29
| | | | | | | | This will be used in the following patches to allow the linker to resize uniform arrays based on array dereferences. Reviewed-by: Kenneth Graunke <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4910>
* glsl: Don't replace lrp pattern with lrp if arguments are not floatsDanylo Piliaiev2020-06-031-1/+2
| | | | | | | | | | | | We don't have "lrp(int, int, int)" and validation of ir_triop_lrp fails down the road. Fixes: 8d37e991 Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3059 Signed-off-by: Danylo Piliaiev <[email protected]> Tested-by: Witold Baryluk <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5257>
* glsl/spirv: remove dead uniforms in spirv nir linkerTimothy Arceri2020-06-031-0/+8
| | | | | | Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4797>
* glsl: remove dead uniforms in the nir linkerTimothy Arceri2020-06-031-0/+8
| | | | | | | | | | | | | | | | | | | | This is now possible as we do uniform linking via a nir based linker. Shader-db results for IRIS (SKL): total instructions in shared programs: 14947192 -> 14946397 (<.01%) instructions in affected programs: 39498 -> 38703 (-2.01%) helped: 230 HURT: 18 total cycles in shared programs: 324868402 -> 324847058 (<.01%) cycles in affected programs: 706701 -> 685357 (-3.02%) helped: 599 HURT: 449 Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4797>
* glsl: add can_remove_uniform() helper to the NIR linkerTimothy Arceri2020-06-031-0/+32
| | | | | | | | | | | This helper reflects the rules we follow in the GLSL IR linker when deciding if we can remove a dead uniform. This check is required to avoid regressions when turning on NIR dead uniform clean up in the following patch. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4797>