Skip to main content
Topic: [SOLVED] How do I set a different mesa version for MuseScore? (Read 1349 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

[SOLVED] How do I set a different mesa version for MuseScore?

The current mesa version (21.1.2) does not work for me (mate-terminal and pluma keep freezing my entire box, except with the 5.4.y kernel. I replaced them with gnome-terminal and gedit; the success remains to be seen. gvim has been known to crash too. (The packaged gedit is out of date - the devel version got rid of tepl, which is unmaintained).

Switching desktop environments is not an option. The development version of mesa seems to work fine, *except* for MuseScore (corrupted cursor rendering).

I tried several mesa env variables, none worked. I tried installing a custom build in /opt/mesa (obviously I cannot run ldconfig on it, because that would make it system-wide. Edit: ran #ldconfig /opt/mesa, didn't work, restored prev condition). I also tried various LD_PRELOAD strings). So how do I get MuseScore to use /opt/mesa/lib? I'm not sure I can rebuild MuseScore (the string MESA does not occur in the source, and it uses cmake, which is not very flexible). Resetting MuseScore to default did not work.

Incidentally, the corruption disappears under load, e. g. if a compiler is running. And it doesn't show up on screenshots.

I could of course use the 5.4 kernel, but this won't solve anything in the long term. I need to fix this for current kernels.

<flame intensity=110%>And please don't tell me I have to use Ubuntu, with versioned libs. And if the kernel people don't get their shit together, I'll have to switch to FreeBSD when the 5.4 kernel reaches EOL.</flame>

Is there a way to simulate versioned libs? For instance, 'ldconfig /opt/mesa -C /etc/mycache.so.cache' and then running 'LD_PRELOAD /etc/mycache.so.cache mscore <my_score>'? Frankly, I'm reluctant to try this without knowing what it does. I'll post more info if needed.

Edit: Bisecting mesa according to https://wiki.archlinux.org/title/Bisecting_bugs_with_Git

After the first step (if I did it right), I got 23c4b59b46e403e21851ffc04ee0cfb0146df4c9 (HEAD, tag: 21.1-branchpoint), which works with MuseScore. To see if it works with the rest of the system will take a while.

Re: How do I set a different mesa version for MuseScore?

Reply #1
can you try musescore-dev/git? maybe can  this cursor bug be fixed in musesore, or? last version of musescore was released on 8.Feb, and lot of fixes landet in git repo, as i saw... maybe will be the easier way to fix musescore (if it was fixed in musescore)

Re: How do I set a different mesa version for MuseScore?

Reply #2
I already tried musescore-dev. It built but would not start. I'll keep trying.

Here is the result of the bisect, FWIW:
Code: [Select]
f62724ccacffb2a1508647e9004adf02f92f7833 is the first bad commit
commit f62724ccacffb2a1508647e9004adf02f92f7833
Author: Kenneth Graunke <[email protected]>
Date:   Thu May 20 02:02:51 2021 -0700

    iris: Pick a single mmap mode (WB/WC) at BO allocation time

    Previously, iris_bufmgr had the ability to maintain multiple
    simultaneous memory mappings for a BO, one in WB mode (with CPU caches),
    and another in WC (streaming) mode.  Depending on the flags passed to
    iris_bo_map(), we would select one mode or the other.

    The rules for deciding which to use were:

    - Systems with LLC always use WB mode because it's basically free
    - Non-LLC systems used...
      - WB maps for all BOs where snooping is enabled (which translates to
        when BO_ALLOC_COHERENT is set at allocation time)
      - WB maps for reads unless persistent, coherent, async, or raw.
      - WC maps for everything else.

    This patch simplifies the system by selecting a single mmap mode at
    BO allocation time, and always using that.  Each BO now has at most one
    map at a time, rather than up to two (or three before we deleted GTT
    map support in recent patches).

    In practical terms, this eliminates the capability to use WB maps for
    reads of non-snooped BOs on non-LLC systems.  Such reads would now be
    slow, uncached reads.  However, iris_transfer_map recently began using
    staging blits for such reads - so the GPU copies the data to a snooped
    buffer which will be mapped WB.  So, rather than incurring slow UC
    reads, we really just take the hit of a blit, and retain fast reads.

    The rest of the rules remain the same.

    There are a few reasons for this:

    1. TTM doesn't support mapping an object as both WB and WC.  The
       cacheability is treated as a property of the object, not the map.
       The kernel is moving to use TTM as part of adding discrete local
       memory support.  So it makes sense to centralize on that model.

    2. Mapping the same BO as both WB and WC is impossible to support on
       some CPUs.  It works on x86/x86_64, which was fine for integrated
       GPUs, but it may become an issue for discrete graphics paired with
       other CPUs (should that ever be a thing we need to support).

    3. It's overall much simpler.  We only have one bo->map field, and
       manage to drop a significant amount of boilerplate.

    One issue that arises is the interaction with the BO cache: BOs with
    WB maps and WC maps will be lumped together into the same cache.  This
    means that a cached BO may have the wrong mmap mode.  We check that,
    and if it doesn't match, we unmap it, waiting until iris_bo_map is
    called to restore one with the desired mode.  This may underutilize
    cache mappings slightly on non-LLC systems, but I don't expect it to
    have a large impact.

    Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4747
    Acked-by: Lionel Landwerlin <[email protected]>
    Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10941>

 src/gallium/drivers/iris/iris_bufmgr.c | 190 ++++++++-------------------------
 src/gallium/drivers/iris/iris_bufmgr.h |  13 ++-
 2 files changed, 56 insertions(+), 147 deletions(-)

The PKGBUILD used for bisecting:
Code: [Select]
# Maintainer: Laurent Carlier <[email protected]>
# Maintainer: Felix Yan <[email protected]>
# Maintainer: Jan de Groot <[email protected]>
# Contributor: Andreas Radke <[email protected]>

#pkgbase=mesa-git
pkgname=('mesa-custom')
#pkgname=('mesa')
pkgdesc="An open-source implementation of the OpenGL specification"
pkgver=21.2.0_devel.140410.f62724ccacf
pkgrel=1
arch=('x86_64')
makedepends=('python-mako' 'libxml2' 'libx11' 'xorgproto' 'libdrm' 'libxshmfence' 'libxxf86vm'
             'libxdamage' 'libva' 'wayland' 'wayland-protocols' 'zstd' 'elfutils'
             'libomxil-bellagio' 'libclc' 'libglvnd' 'libunwind' 'lm_sensors' 'libxrandr'
             'glslang' 'meson' 'gcc10' 'llvm') #'valgrind' 'vulkan-icd-loader' 'libvdpau' 'clang''llvm'
url="https://www.mesa3d.org/"
#_commit=3e59d54daad6a02ef314f8159d7e90b9849e605e #(tag: mesa-21.1.2, 21.1)

license=('custom')
#groups=(modified)
source=("mesa::git+https://gitlab.freedesktop.org/mesa/mesa.git#branch=main" #commit=$_commit"
        'LICENSE')
md5sums=('SKIP'
         '1eff81373cde4b3d7b0ea7590431c962')

validpgpkeys=('8703B6700E7EE06D7A39B8D6EDAE37B02CEB490D'  # Emil Velikov <[email protected]>
              '946D09B5E4C9845E63075FF1D961C596A7203456'  # Andres Gomez <[email protected]>
              'E3E8F480C52ADD73B278EE78E1ECBE07D7D70895'  # Juan Antonio Suárez Romero (Igalia, S.L.) <[email protected]>
              'A5CC9FEC93F2F837CB044912336909B6B25FADFA'  # Juan A. Suarez Romero <[email protected]>
              '71C4B75620BC75708B4BDB254C95FAAB3EB073EC'  # Dylan Baker <[email protected]>
              '57551DE15B968F6341C248F68D8E31AFC32428A6') # Eric Engestrom <[email protected]>

pkgver() {
    cd mesa
    read -r _ver <VERSION
    echo ${_ver/-/_}.$(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare() {
    # although removing build folder in build() function feels more natural,
    # that interferes with the spirit of makepkg --noextract
    cd mesa
    if [  -d build ]; then
        rm -rf build
    fi

    #patch --forward --strip=1 --input="${srcdir}/8543.patch"
}

build() {
  export CC=/usr/bin/gcc-10
  export CXX=/usr/bin/g++-10
  export CPP=/usr/bin/cpp-10
  meson mesa build -Dprefix=/usr \
    -D b_lto=true \
    -D b_ndebug=true \
    -D platforms=x11,wayland \
    -D dri-drivers=i915,i965 \
    -D gallium-drivers=iris,swrast \
    -D vulkan-drivers='' \
    -D swr-arches=avx,avx2 \
    -D dri3=disabled \
    -D egl=enabled \
    -D gbm=enabled \
    -D gles1=disabled \
    -D gles2=enabled \
    -D glvnd=true \
    -D glx=dri \
    -D libunwind=enabled \
    -D lmsensors=enabled \
    -D llvm=enabled \
    -D osmesa=true \
    -D shared-glapi=enabled \
    -D microsoft-clc=disabled \
    -D valgrind=disabled \
    -D datasources=''

  # Print config
  #meson configure build

  ninja -C build
  meson compile -C build
}

package_mesa-custom() {
  depends=('libdrm' 'wayland' 'libxxf86vm' 'libxdamage' 'libxshmfence' 'libelf'
           'libomxil-bellagio' 'libunwind' 'lm_sensors' 'libglvnd'
           'zstd' 'llvm-libs') #'vulkan-icd-loader'
  optdepends=('opengl-man-pages: for the OpenGL API man pages'
              'mesa-vdpau: for accelerated video playback'
              'libva-mesa-driver: for accelerated video playback')
  provides=('mesa' 'mesa-libgl' 'opengl-driver')
  conflicts=('mesa' 'mesa-libgl')
  replaces=('mesa-libgl')

  DESTDIR="${pkgdir}" meson install -C build
  # indirect rendering
  ln -s /usr/lib/libGLX_mesa.so.0 "${pkgdir}/usr/lib/libGLX_indirect.so.0"

  install -m644 -Dt "${pkgdir}/usr/share/licenses/${pkgname}" LICENSE
}
It shows the first bad commit (for MuseScore; it corrupts the cursor - the blue bar that runs across the score).
The musescore people probably know this already, but they aren't forthcoming with the bugfixes. As I said, to find out if the previous commit works for the rest of my system will take time (I could try bisecting mate-terminal and pluma, but that would take a very long time, since the error is not immediately apparent. And of course it would mean bisecting the kernel, and that error goes ***WAY*** back).

The last good commit is 22bfb5355f2e7f0c365b4e50f9f8a77a601b1ccf (refs/bisect/good-22bfb5355f2e7f0c365b4e50f9f8a77a601b1ccf)

Re: How do I set a different mesa version for MuseScore?

Reply #3
Solved with mesa-21.2.0_devel+141456+g6d0aceae4db built with i915 and i965 only (the gallium drivers don't work for me at all. The software rasterizers, including llvmpipe, are way too slow for fullscreen video. Maybe "prefer-iris" should be set to false in the default build to give users a choice), libva2.13.0-pre1, intel-media-driver-21.2.2+70+g2ceb77c1a and uninstalling libva-intel-driver.

The downside is that vlc3 does not seem to work properly with the iHD driver (the reason for keeping libva-intel-driver in the first place. "main filter error: option  does not exist" in the vlc log, though it does not seem to do any harm. More experimenting needed, including retrying iris). vlc-2.2.8 (which is still my preferred choice, and will still build with qt4 and ffmpeg-2.8.17 - and gcc11) works perfectly with iHD.

Whether this also fixes my freezing issues remains to be seen.

Re: [SOLVED] How do I set a different mesa version for MuseScore?

Reply #4
I have a similar problem: to be able to use the latest versions of FreeCAD.Appimage I have to do a
Code: [Select]
downgrade mesa
But I am forced to revert to the current version of mesa before shutting down the system, otherwise the graphics server will not restart on the next boot ...

Re: [SOLVED] How do I set a different mesa version for MuseScore?

Reply #5
I have a similar problem: to be able to use the latest versions of FreeCAD.Appimage I have to do a
Code: [Select]
downgrade mesa
But I am forced to revert to the current version of mesa before shutting down the system, otherwise the graphics server will not restart on the next boot ...
that is exactly the reason, why downgrade is not recommende!
 try mesa-git instead, maybe will be your problem fixed in git version.

Addition to musescore post

Reply #6
Why was the post locked? I wanted to mark it unsolved and add more info.

The problem is the iris driver - when I reinstalled the mesa devel package built with iris and prefer-iris=false (identical in every other respect) the musescore rendering issues returned after a reboot. Cannot really be fixed by setting MESA_LOADER_DRIVER_OVERRIDE='i965' in .bashrc because of vlc. But iris has better fullscreen video rendering, it's noticeably less choppy. So I created a custom launcher for musescore, and the driver is loaded, but musescore is still corrupted. And I set MESA_LOADER_DRIVER_OVERRIDE='iris' in the script that starts vlc, and the driver is loaded, but the video is still choppy.  And I had to reinstall the libva-intel-driver for vlc3, although it is ostensibly for Haswell and older GPUs (I'm on Skylake). I'm pretty sure this is a vlc3 coding bug - I get 'munmap_chunk(): invalid pointer' and 'glconv_vaapi_x11 gl error: vaInitialize: unknown libva error' in the vlc log. (Why the hell did they discontinue vlc2? It's the better program).

I'll have to figure out how to unload the i965 driver while vlc is running, and the iris driver while musescore is running. Can anybody help, please? I tried adriconf, but it only lists one driver, I can't choose between i965 and iris.

Edit:
Thanks for unlocking the post - all the problems, including tintin's, are related, they have to do with mesa. It would probably be better to change the title to "mesa problems" or something like that (I found out after posting that the switch from iris to i965 affected other programs too). Anyway, I just got another interface freeze and reinstalled the iris-free mesa package I built previously. So in principle, the topic is indeed solved - but the underlying mesa problem isn't, as it affects at least one other user (whom you shut down too).

 

Re: [SOLVED] How do I set a different mesa version for MuseScore?

Reply #7
i locked it because another user continued with his problem with mesa and freecad on this topic. this topic was  marked as solved, and in this case should be added nothing more...
if you have problems with vlc, and libva please open new topic,vlc have nothing to do with MuseScore and his problem with mesa.. same for freecad...
if you think, you found a bug, please report it in upstream.
please don't mix more problems to one topic, thank you for cooperation


Re: [SOLVED] How do I set a different mesa version for MuseScore?

Reply #9
that is exactly the reason, why downgrade is not recommende!
Oh yes  :)


Quote
try mesa-git instead, maybe will be your problem fixed in git version.
I tried mesa-git and the problem persists.
But that's okay, because I have a temporary solution.
If necessary I will open a new topic on this subject.

Thank you !