aboutsummaryrefslogtreecommitdiffstats
path: root/src/compiler
Commit message (Collapse)AuthorAgeFilesLines
* nir/print: show variable precisionRob Clark2020-03-101-0/+10
| | | | | Signed-off-by: Rob Clark <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4071>
* glsl/opt_minmax: Add support for float16Neil Roberts2020-03-091-0/+19
| | | | | | | | Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Alyssa Rosenzweig <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3929> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3929>
* glsl/lower_instructions: Handle fp16 for FDIV_TO_MUL_RCPKristian H. Kristensen2020-03-091-4/+5
| | | | Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3929>
* glsl/lower_instructions: Handle fp16 for MOD_TO_FLOORHyunjun Ko2020-03-091-1/+1
| | | | Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3929>
* glsl/lower_instructions: Use float16 constants when appropriateNeil Roberts2020-03-091-5/+31
| | | | | | | | | | | | | When lowering instructions that involve floating-point constants, pick the appropriate type for the constant so that it will also work with float16 parameters. v2: Use float16_t constructor instead of helper function. Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Alyssa Rosenzweig <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3929>
* glsl/validate: Allow float16 in the expression treeNeil Roberts2020-03-091-27/+18
| | | | | | | | | v2. [Hyunjun Ko ([email protected])] squashed 3 commits into one commit. Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Alyssa Rosenzweig <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3929>
* glsl: Add type queries for fp16+float and fp16+float+doubleKristian H. Kristensen2020-03-091-0/+16
| | | | | | | Following the is_integer_32_64() convention, add is_float_16_32() and float_16_32_64() for these commonly tested combinations. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3929>
* glsl: Handle fp16 unary operations when lowering matrix operationsHyunjun Ko2020-03-091-0/+3
| | | | | | | Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Alyssa Rosenzweig <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3929>
* glsl: Add ir_unop_f2fmpNeil Roberts2020-03-094-0/+8
| | | | | | | | | | | | This is the same as ir_unop_f2f16 except that it comes with a promise that it is safe to optimise it out if the result is immediately converted back to float32 again. Normally this would be a lossy operation but it is safe to do if the conversion was generated as part of the precision lowering pass. Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3929>
* glsl: Add b2f16 and f162b conversion operationsNeil Roberts2020-03-094-0/+17
| | | | | | Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Alyssa Rosenzweig <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3929>
* glsl: Add IR conversion ops for 16-bit float typesNeil Roberts2020-03-094-0/+22
| | | | | | | | | Adds ir_unop_f162f and ir_unop_f2f16. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Alyssa Rosenzweig <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3929>
* glsl: Expand fp16 to float before constant expression evaluationKristian H. Kristensen2020-03-091-0/+26
| | | | | | | | | | | This way the generated constant folding code doesn't need to understand fp16. All operations have to be expanded to full float for evaulation on the CPU, so we might as well do it up front. As far as GLSL is concerned, fp16 isn't a separate type from float, so everything we're supposed to support for float we need to do for fp16. Reviewed-by: Ian Romanick <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3929>
* glsl: Implement constant propagation for fp16Kristian H. Kristensen2020-03-091-0/+3
| | | | | | | Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Alyssa Rosenzweig <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3929>
* glsl: Add fp16 case for ir_triop_lrp optimizationKristian H. Kristensen2020-03-091-0/+3
| | | | | | | Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Alyssa Rosenzweig <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3929>
* glsl: Add support for float16 types in the IR treeNeil Roberts2020-03-095-12/+86
| | | | | | | Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Alyssa Rosenzweig <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3929>
* glsl: Add ir_constant constructor for fp16Kristian H. Kristensen2020-03-092-0/+15
| | | | | Reviewed-by: Ian Romanick <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3929>
* nir: add pass to lower discard() to demote()Daniel Schürmann2020-03-094-0/+73
| | | | | | | | | This pass is intended to work around game bugs, only! It also lowers nir_intrinsic_load_helper_invocation to nir_intrinsic_is_helper_invocation for consistency. Reviewed-by: Marek Olšák <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4047>
* nir: gather info whether a shader uses demote_to_helperDaniel Schürmann2020-03-092-0/+4
| | | | | Reviewed-by: Marek Olšák <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4047>
* nir: fix compilation warning on glsl_get_internal_ifc_packingTapani Pälli2020-03-092-2/+2
| | | | | | | | | | Removes following warning: warning: 'const' type qualifier on return type has no effect Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Lionel Landwerlin <[email protected]> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4111> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4111>
* glsl: add subroutine support to nir linkerTimothy Arceri2020-03-061-1/+99
| | | | | | Reviewed-by: Alejandro Piñeiro <[email protected]> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4050> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4050>
* glsl: dont try to assign uniform storage for uniform blocksTimothy Arceri2020-03-061-2/+4
| | | | | | | Fixes a crash in some shaders. Reviewed-by: Alejandro Piñeiro <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4050>
* glsl: add support for builtins to the nir uniform linkerTimothy Arceri2020-03-061-2/+11
| | | | | Reviewed-by: Alejandro Piñeiro <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4050>
* glsl: set ShaderStorageBlocksWriteAccess in the nir linkerTimothy Arceri2020-03-061-6/+32
| | | | | Reviewed-by: Alejandro Piñeiro <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4050>
* glsl: nir linker fix setting of ssbo top level arrayTimothy Arceri2020-03-061-6/+19
| | | | | | | | This helps correcly set it for each top level member and correctly handle unsized arrays. Reviewed-by: Alejandro Piñeiro <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4050>
* glsl: find the base offset for block members from unnamed blocksTimothy Arceri2020-03-061-1/+95
| | | | | | | | | | These block member have been split into individual vars so we need to set the correct offsets for each member in the new glsl nir linker. We also take this opportunity to set the correct location for the variable. Reviewed-by: Alejandro Piñeiro <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4050>
* glsl: correctly set explicit offsets for struct membersTimothy Arceri2020-03-061-3/+11
| | | | | | | This correctly sets offsets set in glsl when using the nir linker. Reviewed-by: Alejandro Piñeiro <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4050>
* glsl: add std140 and std430 layouts to nir uniform linkerTimothy Arceri2020-03-061-4/+29
| | | | | | | | | The current ARB_gl_spirv linking only supports explicit layouts so we need to update it to support std140 and std430 layouts before we can use the linker for glsl. Reviewed-by: Alejandro Piñeiro <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4050>
* nir: add glsl_get_std430_size() helperTimothy Arceri2020-03-062-0/+7
| | | | | | | This will be used by the nir glsl linker for linking uniforms. Reviewed-by: Alejandro Piñeiro <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4050>
* nir: add glsl_get_std430_base_alignment() helperTimothy Arceri2020-03-062-0/+8
| | | | | | | This will be used by the nir glsl linker for linking uniforms. Reviewed-by: Alejandro Piñeiro <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4050>
* nir: add glsl_get_std140_size() helperTimothy Arceri2020-03-062-0/+7
| | | | | | | This will be used by the nir glsl linker for linking uniforms. Reviewed-by: Alejandro Piñeiro <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4050>
* nir: add glsl_get_std140_base_alignment() helperTimothy Arceri2020-03-062-0/+8
| | | | | | | This will be used by the nir glsl linker for linking uniforms. Reviewed-by: Alejandro Piñeiro <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4050>
* nir: add glsl_get_internal_ifc_packing() helperTimothy Arceri2020-03-062-0/+11
| | | | | | | This will be used by the nir glsl linker for linking uniforms. Reviewed-by: Alejandro Piñeiro <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4050>
* glsl: correctly find block index when linking glsl with nir linkerTimothy Arceri2020-03-061-4/+30
| | | | | | | | The existing code for spirv expects all vars to have explicit bindings set which is not true for glsl. Reviewed-by: Alejandro Piñeiro <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4050>
* glsl: add name support to nir uniform linkerTimothy Arceri2020-03-061-42/+248
| | | | | | | | Name support is optional for spirv support but is required for glsl support. Reviewed-by: Alejandro Piñeiro <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4050>
* glsl: move get_next_index() earlier in nir link uniformsTimothy Arceri2020-03-061-34/+34
| | | | | | | | We will use get_next_index() in more of the helper functions in the following patches. Reviewed-by: Alejandro Piñeiro <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4050>
* glsl: move add_parameter() earlier in nir link uniformsTimothy Arceri2020-03-061-54/+54
| | | | | | | | We will use add_parameter() in more of the helper functions in the following patches. Reviewed-by: Alejandro Piñeiro <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4050>
* glsl: move nir link uniforms struct defs earlierTimothy Arceri2020-03-061-47/+47
| | | | | | | | We will need to use the state in more of the helper functions in the following patches. Reviewed-by: Alejandro Piñeiro <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4050>
* nir/linker: remove reference to just SPIR-V linkingAlejandro Piñeiro2020-03-065-26/+19
| | | | | | | | | | | | | | Several files had a initial comment about the purpose of such files, including a reference that the NIR linker was implemented with just ARB_gl_spirv in mind. Since the nice job Timothy is doing to use the NIR linker on GLSL, that is not true anymore, so let's remove that reference and also tweak some other comments. Acked-by: Timothy Arceri <[email protected]> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4081> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4081>
* nir/lower_input_attachments: remove bogus assert in try_lower_input_texop()Samuel Pitoiset2020-03-061-1/+0
| | | | | | | | | | | It can be a sampler too. Fixes: 84b08971fbd ("nir/lower_input_attachments: lower nir_texop_fragment_{mask}_fetch") Closes: https://gitlab.freedesktop.org/mesa/mesa/issues/2558 Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Bas Nieuwenhuizen <[email protected]> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4043> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4043>
* Revert "spirv: Use a simpler and more correct implementaiton of tanh()"Kristian H. Kristensen2020-03-051-14/+13
| | | | | | | | | | This reverts commit da1c49171d0df185545cfbbd600e287f7c6160fa. The reduced formula has precision problems on fp16 around 0. Bring back the old formula, but make sure to keep the clamping. Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4054> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4054>
* Revert "glsl: Use a simpler formula for tanh"Kristian H. Kristensen2020-03-051-10/+8
| | | | | | | | | This reverts commit 9807f502eb7a023be619a14119388b2a43271b0e. The simplified formula doesn't pass the tanh dEQP tests when we lower to fp16 math. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4054>
* nir: Flush to zero with OOB low exponents in ldexpJason Ekstrand2020-03-041-14/+41
| | | | | Reviewed-by: Arcady Goldmints-Orlov <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl/linker: add xfb workaround for modified built-in variablesLouis-Francis Ratté-Boulianne2020-03-031-6/+17
| | | | | | | | | | | | | | | | | | | | | Some lowering passes modify the value of built-in variables in order for drivers to work properly. However, modifying such values will also break transform feedback as the captured value won't match what's expected. For example, on some hardware, the vertex shaders are expected to output gl_Position in screen space. However, the transform feedback captured value is still supposed to be the world-space coordinates (see nir_lower_viewport_transform). To fix that, we create a new variable that contains the pre-transformation value and use it for transform feedback instead of the built-in one. Signed-off-by: Louis-Francis Ratté-Boulianne <[email protected]> Reviewed-by: Alyssa Rosenzweig <[email protected]> Acked-by: Daniel Stone <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2433>
* glsl/linker: handle array/struct members for DisableXfbPackingLouis-Francis Ratté-Boulianne2020-03-036-0/+283
| | | | | | | | | | | | | | | | | | When varying packing is disabled for transform feedback and a xfb declaration points to an array element or structure member, the element/member should be aligned to the start of a slot as well. If that's not the case, a new varying is created and the element/member value is copied. There might a way to further optimize the number of slots allocated or the number of copies necessary if the performance cost is problematic. For example, in cases where simply padding the top level variable might correctly align all the captured values. Signed-off-by: Louis-Francis Ratté-Boulianne <[email protected]> Reviewed-by: Alyssa Rosenzweig <[email protected]> Acked-by: Daniel Stone <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2433>
* glsl/linker: add DisableTransformFeedbackPacking workaroundLouis-Francis Ratté-Boulianne2020-03-034-19/+106
| | | | | | | | | | | | | | | | | Some drivers (e.g. Panfrost) don't support packing of varyings when used for transform feedback. This new constant ensures that any varying used for xfb is aligned at the start of a slot and won't be packed with other varyings. Scenarios where transform feedback declarations are related to an array element or a struct member will be handled in a subsequent patch. Signed-off-by: Louis-Francis Ratté-Boulianne <[email protected]> Signed-off-by: Tomeu Vizoso <[email protected]> (Fix order of arguments to varying_matches()) Reviewed-by: Alyssa Rosenzweig <[email protected]> Acked-by: Daniel Stone <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2433>
* spirv: fix memory_barrier_tcs_patch emissionRhys Perry2020-03-031-1/+2
| | | | | | | | | | | Shouldn't affect any driver, since all currently implement memory_barrier_tcs_patch as a no-op. It also looks like optimizations are fine Signed-off-by: Rhys Perry <[email protected]> Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4003> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4003>
* spirv: improve creation of memory_barrierRhys Perry2020-03-031-3/+8
| | | | | | | | It shouldn't check for atomic counters or return in case we also need to create a TCS output barrier. Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4003>
* glsl: add some error checks to the nir uniform linkerTimothy Arceri2020-02-281-0/+16
| | | | | | | | These are optional for spirv but it shouldnt hurt to enable them. Reviewed-by: Alejandro Piñeiro <[email protected]> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3992> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3992>
* glsl: fix sampler index calculation in nir linkerTimothy Arceri2020-02-281-13/+19
| | | | | | | | | Here we reset the counter to 0 for each shader stage not each program. We also make add a flag to stop iterating over indices that have already been processed. Reviewed-by: Alejandro Piñeiro <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3992>
* glsl: reset next_image_index count for each shader stageTimothy Arceri2020-02-281-1/+2
| | | | | | | | This fixes the image index calculation in the nir linker. We need to reset the counter to 0 for each shader stage not each program. Reviewed-by: Alejandro Piñeiro <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3992>