mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-02-21 07:50:35 +01:00
read-only mirror of https://gitlab.freedesktop.org/mesa/mesa
NIR has a fsin instruction that takes an argument in radians. Midgard instead has an fsinpi argument that takes an argument in multiples of pi. So, we had a NIR pass that would change fsin(x) to fsin(x / pi) and then map fsin to fsinpi in the backend. But that's invalid! In NIR, the opcode fsin is well-defined. fsin(x) means something very different than fsin(x / pi). They won't usually be equal. The transform fsin(x) -> fsin(x / pi) is fundamentally unsound. It did work before, by accident. Most NIR passes don't care about the semantics of ALU instructions. fsin(x) and fsin(x / pi) are both well-defined but fundamentally different NIR shaders. So while rewriting is wrong -- the NIR we get out is not equivalent to the NIR we put in, and the Midgard ops we generate are not equivalent to the NIR -- but if we don't run any passes that care about the definition of fsin the two wrongs will cancel out to make a right. However, some NIR passes do care about the definitions of ALU instructions, instead of treating them as named black boxes. In particular, constant folding (nir_opt_constant_fold) evaluates ALU instructions when their inputs are constants, according to the definition in nir_opcodes.py. So our little charade will only work if we don't call nir_opt_constant_fold, or if all the fsin instructions have non-constant inputs. At the beginning of this series, that is the case. With the later scalarization change, that's no longer the case, and the unsoundness translates to real failing tests rather than a quibble of NIR's semantics. To mitigate, we define a new NIR opcode with the semantics we want and translate fsin(x) = fsin_mdg(x / pi), where that equivalence does hold mathematically. So the new translation is sound and doesn't rely on lucky pass ordering. This matches the approach already used for AMD and AGX, which have fsin_amd and fsin_agx opcodes respectively. Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com> Reviewed-by: Italo Nicola <italonicola@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19350> |
||
|---|---|---|
| .github/workflows | ||
| .gitlab/issue_templates | ||
| .gitlab-ci | ||
| android | ||
| bin | ||
| build-support | ||
| docs | ||
| include | ||
| src | ||
| subprojects | ||
| .dir-locals.el | ||
| .editorconfig | ||
| .gitattributes | ||
| .gitignore | ||
| .gitlab-ci.yml | ||
| .graphqlrc.yml | ||
| .mailmap | ||
| CODEOWNERS | ||
| meson.build | ||
| meson_options.txt | ||
| README.rst | ||
| VERSION | ||
`Mesa <https://mesa3d.org>`_ - The 3D Graphics Library ====================================================== Source ------ This repository lives at https://gitlab.freedesktop.org/mesa/mesa. Other repositories are likely forks, and code found there is not supported. Build & install --------------- You can find more information in our documentation (`docs/install.rst <https://mesa3d.org/install.html>`_), but the recommended way is to use Meson (`docs/meson.rst <https://mesa3d.org/meson.html>`_): .. code-block:: sh $ mkdir build $ cd build $ meson .. $ sudo ninja install Support ------- Many Mesa devs hang on IRC; if you're not sure which channel is appropriate, you should ask your question on `OFTC's #dri-devel <irc://irc.oftc.net/dri-devel>`_, someone will redirect you if necessary. Remember that not everyone is in the same timezone as you, so it might take a while before someone qualified sees your question. To figure out who you're talking to, or which nick to ping for your question, check out `Who's Who on IRC <https://dri.freedesktop.org/wiki/WhosWho/>`_. The next best option is to ask your question in an email to the mailing lists: `mesa-dev\@lists.freedesktop.org <https://lists.freedesktop.org/mailman/listinfo/mesa-dev>`_ Bug reports ----------- If you think something isn't working properly, please file a bug report (`docs/bugs.rst <https://mesa3d.org/bugs.html>`_). Contributing ------------ Contributions are welcome, and step-by-step instructions can be found in our documentation (`docs/submittingpatches.rst <https://mesa3d.org/submittingpatches.html>`_). Note that Mesa uses gitlab for patches submission, review and discussions.