Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange visual error on Wayland (e.g. with Anno 2070, Dirt4 and others) #32

Closed
juliotux opened this issue Apr 4, 2019 · 47 comments
Closed

Comments

@juliotux
Copy link

juliotux commented Apr 4, 2019

Hello primus_vk developers. First of all, thanks for the great job!

primus_vk is running well on almost every game I tested, but present a very strange glitch on Anno 2070+DXVK. These glitches only appear using primus_vk, and are not present using nvidia-xrun or wined3d (OpenGL).

Here is a screenshot of the problem. It look like a compression or decoder problem.
Anno 2070

@felixdoerre
Copy link
Owner

Hi! Thanks for the feedback and it's good to also hear from games where everything just works fine :). It's strange how all displayed text is not affected by the visual distortion. Are the artifacts static or are they moving? Could you provide output of optirun env DISPLAY=:8 vulkaninfo and the tracing info that should be printed to standard out by the game?

Primus_vk does not compress not does it re-encode the image (so if these are compression artifacts they must come from somewhere else). The image is transmitted as a raw chunk of memory (of widthheight4 bytes) from the dedicated GPU to main memory.

@juliotux
Copy link
Author

juliotux commented Apr 7, 2019

Looking with more atention, it looks like the artifacts are from previous frames and, for some reason, they are kept in the screen. I had this problem with two games until now: native Dirt4 and Anno2070 with dxvk. I uploaded two videos to you have a good idea what's going on.

Dirt4
Anno2070

The vulkaninfo and the stdout of Dirt4 can be found in this gist

@juliotux
Copy link
Author

juliotux commented Apr 7, 2019

Important update about the problem: it only appear in Wayland session. With xorg session everything is fine. Also, in wayland everything show theses glitches. All demos from https://github.com/SaschaWillems/Vulkan show glitches in Wayland.

@felixdoerre
Copy link
Owner

felixdoerre commented Apr 10, 2019

primus_vk does not clear the buffer images between presentations. I created an experimental branch clears the images before handing them back to the application: https://github.com/felixdoerre/primus_vk/tree/test_clear_images Could you try if the artifacts are still present with this change? (I don't know how Wayland vs xorg could make a difference here, but who knows).

@juliotux
Copy link
Author

I tested again with this branch and the problem remains.

@felixdoerre
Copy link
Owner

I've got another test branch for you: https://github.com/felixdoerre/primus_vk/tree/overlay
The code now simply modifies the rendered image by forcefully painting a red square in the upper left corner. The question now is: are the artifacts above or below this red square?

@juliotux
Copy link
Author

The artifacts appear in the red square.

Screenshot

@Nikki1993
Copy link

just realized I am having the same issue with grimdawn

image

@felixdoerre
Copy link
Owner

@Nikki1993 are you also running the game in a Wayland session?

@Nikki1993
Copy link

yep, swaywm

@Nikki1993
Copy link

Nikki1993 commented Jun 16, 2019

here is mine
➜ optirun env DISPLAY=:8 vulkaninfo

using Lenovo X1E that has iGPU intel 630 and GTX 1050ti max q

ERROR: [Loader Message] Code 0 : /usr/lib32/libvulkan_intel.so: wrong ELF class: ELFCLASS32
==========
VULKANINFO
==========

Vulkan Instance Version: 1.1.107





INTEL-MESA: warning: ../mesa-19.0.6/src/intel/vulkan/anv_device.c:1252: FINISHME: Implement pop-free point clipping


Instance Extensions:
====================
Instance Extensions     count = 17
        VK_EXT_acquire_xlib_display         : extension revision  1
        VK_EXT_debug_report                 : extension revision  8
        VK_EXT_debug_utils                  : extension revision  1
        VK_EXT_direct_mode_display          : extension revision  1
        VK_EXT_display_surface_counter      : extension revision  1
        VK_KHR_device_group_creation        : extension revision  1
        VK_KHR_display                      : extension revision 23
        VK_KHR_external_fence_capabilities  : extension revision  1
        VK_KHR_external_memory_capabilities : extension revision  1
        VK_KHR_external_semaphore_capabilities: extension revision  1
        VK_KHR_get_display_properties2      : extension revision  1
        VK_KHR_get_physical_device_properties2: extension revision  1
        VK_KHR_get_surface_capabilities2    : extension revision  1
        VK_KHR_surface                      : extension revision 25
        VK_KHR_wayland_surface              : extension revision  6
        VK_KHR_xcb_surface                  : extension revision  6
        VK_KHR_xlib_surface                 : extension revision  6
Layers: count = 6
=======
VK_LAYER_LUNARG_standard_validation (LunarG Standard Validation Layer) Vulkan version 1.0.108, layer version 1
        Layer Extensions        count = 0
        Devices         count = 3
                GPU id       : 0 (GeForce GTX 1050 Ti with Max-Q Design)
                Layer-Device Extensions count = 0
                GPU id       : 1 (GeForce GTX 1050 Ti with Max-Q Design)
                Layer-Device Extensions count = 0
                GPU id       : 2 (Intel(R) UHD Graphics 630 (Coffeelake 3x8 GT2))
                Layer-Device Extensions count = 0

VK_LAYER_PRIMUS_PrimusVK (Primus-vk - https://github.com/felixdoerre/primus_vk) Vulkan version 1.1.0, layer version 1
        Layer Extensions        count = 0
        Devices         count = 3
                GPU id       : 0 (GeForce GTX 1050 Ti with Max-Q Design)
                Layer-Device Extensions count = 0
                GPU id       : 1 (GeForce GTX 1050 Ti with Max-Q Design)
                Layer-Device Extensions count = 0
                GPU id       : 2 (Intel(R) UHD Graphics 630 (Coffeelake 3x8 GT2))
                Layer-Device Extensions count = 0

VK_LAYER_VALVE_steam_fossilize_32 (Steam Pipeline Caching Layer) Vulkan version 1.1.73, layer version 1
        Layer Extensions        count = 0
        Devices         count = 3
                GPU id       : 0 (GeForce GTX 1050 Ti with Max-Q Design)
                Layer-Device Extensions count = 0
                GPU id       : 1 (GeForce GTX 1050 Ti with Max-Q Design)
                Layer-Device Extensions count = 0
                GPU id       : 2 (Intel(R) UHD Graphics 630 (Coffeelake 3x8 GT2))
                Layer-Device Extensions count = 0

VK_LAYER_VALVE_steam_fossilize_64 (Steam Pipeline Caching Layer) Vulkan version 1.1.73, layer version 1
        Layer Extensions        count = 0
        Devices         count = 3
                GPU id       : 0 (GeForce GTX 1050 Ti with Max-Q Design)
                Layer-Device Extensions count = 0
                GPU id       : 1 (GeForce GTX 1050 Ti with Max-Q Design)
                Layer-Device Extensions count = 0
                GPU id       : 2 (Intel(R) UHD Graphics 630 (Coffeelake 3x8 GT2))
                Layer-Device Extensions count = 0

VK_LAYER_VALVE_steam_overlay_32 (Steam Overlay Layer) Vulkan version 1.1.73, layer version 1
        Layer Extensions        count = 0
        Devices         count = 3
                GPU id       : 0 (GeForce GTX 1050 Ti with Max-Q Design)
                Layer-Device Extensions count = 0
                GPU id       : 1 (GeForce GTX 1050 Ti with Max-Q Design)
                Layer-Device Extensions count = 0
                GPU id       : 2 (Intel(R) UHD Graphics 630 (Coffeelake 3x8 GT2))
                Layer-Device Extensions count = 0

VK_LAYER_VALVE_steam_overlay_64 (Steam Overlay Layer) Vulkan version 1.1.73, layer version 1
        Layer Extensions        count = 0
        Devices         count = 3
                GPU id       : 0 (GeForce GTX 1050 Ti with Max-Q Design)
                Layer-Device Extensions count = 0
                GPU id       : 1 (GeForce GTX 1050 Ti with Max-Q Design)
                Layer-Device Extensions count = 0
                GPU id       : 2 (Intel(R) UHD Graphics 630 (Coffeelake 3x8 GT2))
                Layer-Device Extensions count = 0

Presentable Surfaces:
=====================
GPU id       : 0 (GeForce GTX 1050 Ti with Max-Q Design)
Surface type : VK_KHR_wayland_surface

@Nikki1993
Copy link

also not sure if related but I am getting extremely low fps (< 30) vs running wined3d which fluctuates between 40 - 70 fps

@felixdoerre
Copy link
Owner

felixdoerre commented Jun 16, 2019

do you experience the same issue when using the intel drivers to render (i.e. running the game without ENABLE_PRIMUS_LAYER / optirun)?

@Nikki1993
Copy link

Nikki1993 commented Jun 17, 2019

@felixdoerre nope, no artifacts

image

of course, the game is barely running at 40 fps, but surprisingly higher than primus vk with dxvk, at least if steam fps overlay to be believed

@Nikki1993
Copy link

Nikki1993 commented Jun 17, 2019

also, no artifacts when doing pvkrun vkcube however performance feels lower than Intel but that could be related to my laptop not plugged into power which throttles card hard.

image

@felixdoerre
Copy link
Owner

Could you test https://github.com/felixdoerre/primus_vk/tree/test_membarrier for me and check if the problem persists?

@Nikki1993
Copy link

trying to do local build following readme, cloned repo and added few dev packages for vulkan (running arch), followed arch specific mods to be done and now trying to compile with make and hit with this

primus_vk on  test_membarrier [!] 
➜ make libprimus_vk.so libnv_vulkan_wrapper.so
g++ -std=gnu++11 -g3 -I/usr/include/vulkan -shared -fPIC primus_vk.cpp -o libprimus_vk.so
In file included from primus_vk.cpp:3:
/usr/include/vulkan/vk_layer_dispatch_table.h:392:5: error: ‘PFN_vkGetDeviceGroupSurfacePresentModes2EXT’ does not name a type; did you mean ‘PFN_vkGetDeviceGroupSurfacePresentModesKHR’?
     PFN_vkGetDeviceGroupSurfacePresentModes2EXT GetDeviceGroupSurfacePresentModes2EXT;
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     PFN_vkGetDeviceGroupSurfacePresentModesKHR
make: *** [Makefile:17: libprimus_vk.so] Error 1

@Nikki1993
Copy link

Nikki1993 commented Jun 17, 2019

are these the correct changes?
image
image

EDIT:

apparently, need to downgrade packages to build, https://aur.archlinux.org/packages/primus-vk-git/ I will see to it tomorrow and try to get the build running

@felixdoerre
Copy link
Owner

Yes, those changes are correct. The build error looks like a version mismatch between your /usr/include/vulkan/vk_layer_dispatch_table.h and your vulkan_core.h. I think the dispatch_table is newer than vulkan_core.h, which is missing this line: https://github.com/KhronosGroup/Vulkan-Headers/blob/7dbd74f04430f3a811a8fbd3c94f2684e38d9152/include/vulkan/vulkan_core.h#L5255, which seems to have been inserted here: KhronosGroup/Vulkan-Headers@71be0a4#diff-0ff049f722e55de41ee15b2c91ef380fR7325 in vulkan 1.1.105.

Thanks for trying this out!

@Nikki1993
Copy link

Nikki1993 commented Jun 18, 2019

ok, I managed to downgrade the package by running

sudo pacman -U https://archive.archlinux.org/packages/v/vulkan-headers/vulkan-headers-1%3A1.1.107%2B130%2B171949d-1-any.pkg.tar.xz

at which point all compiled well, I am not entirely sure I correctly cloned via PKGBUILD (mainly because I've never compiled stuff before on arch, I confess total noob here) so if you could tell me have I done the correct changes, I used primus_vk_git from AUR and modified the build

I only edited primus_vk.git#branch=test_membarrier to add the branch

_pkgname=primus-vk
pkgname=$_pkgname-git
pkgver=r86.804e2a9
pkgrel=1
pkgdesc="Primus-Vk Nvidia Vulkan offloading for Bumblebee"
arch=('i686' 'x86_64')
url="https://github.com/felixdoerre/primus_vk"
license=('BSD')
depends=('nvidia-utils' 'bumblebee' 'vulkan-icd-loader' 'primus')
makedepends=('vulkan-validation-layers' 'git')
source=(git+https://github.com/felixdoerre/primus_vk.git#branch=test_membarrier
        'primus_vk_wrapper.json'
       'pvkrun.in.sh')
md5sums=('SKIP'
         'e8bec20f7aa74956f4944c7ed237a770'
         'fb5ae09d41c4590de7f0ecf1ca6c3673')

pkgver() {
  cd "${_pkgname/-/_}"
  printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}


build() {
  cd "${_pkgname/-/_}"

  CXXFLAGS+=' -DNV_DRIVER_PATH=\"/usr/lib/libGLX_nvidia.so.0\"'
  make CXXFLAGS="$CXXFLAGS"
}

package() {
  cd "${_pkgname/-/_}"

  install -D libnv_vulkan_wrapper.so "$pkgdir"/usr/lib/libnv_vulkan_wrapper.so
	install -D libprimus_vk.so "$pkgdir"/usr/lib/libprimus_vk.so
	install -Dm644 primus_vk.json "$pkgdir"/usr/share/vulkan/implicit_layer.d/primus_vk.json
  install -Dm644 "$srcdir"/primus_vk_wrapper.json "$pkgdir"/usr/share/vulkan/icd.d/primus_vk_wrapper.json
  install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/"$pkgname"/LICENSE
  install -Dm755 "$srcdir"/pvkrun.in.sh "$pkgdir"/usr/bin/pvkrun
}

# vim:set ts=2 sw=2 et:

Installed with makepkg -si, ran the primusrun with LAYER and nada, same artifacts

@felixdoerre
Copy link
Owner

Dang! Anyway, thank you very much for testing!

@Nikki1993
Copy link

well if you have more stuff to test just lemme know :)

@felixdoerre
Copy link
Owner

I've just pushed a few more commits resolving some vulkan validation errors. Maybe those help? Could you test them?

@Nikki1993
Copy link

@felixdoerre to the same branch I presume?

@felixdoerre
Copy link
Owner

yes

@Nikki1993
Copy link

still a miss, artifacts like I am on an acid trip.

@juliotux
Copy link
Author

Tested again, with the new branch, new commits, and the artifacts are still present. Should we start to consider this as a Wayland bug?

@felixdoerre
Copy link
Owner

yes it could be, but we don't really know what happens here yet.

@janisstreib
Copy link
Collaborator

janisstreib commented Aug 31, 2019

I can reproduce this in gnome+wayland in "The Talos Principle" - not in sway+wayland though. This may be a gnome+wayland related issue.
I'll try it in plasma+wayland soon.

@felixdoerre felixdoerre changed the title Strange visual error on Anno 2070 Strange visual error on Wayland (e.g. with Anno 2070, Dirt4 and others) Aug 31, 2019
@greyltc
Copy link

greyltc commented Sep 1, 2019

It sure does look like some sort of compression artifact to me.
I bet we can blame something in gnome's compositing layer(s) for this: mutter/clutter

Interesting that sway doesn't show this bug. I wonder about Cinnamon then, since it uses Muffin, a fork of Mutter. (ridiculous names all around!)

@greyltc
Copy link

greyltc commented Sep 7, 2019

A great way to reproduce this for testing so that you don't need some specific commercial game is, as @juliotux said, run the demos from https://github.com/SaschaWillems/Vulkan

That project has three build options for "window system integration": XCB, Wayland and DirectToDisplay. I've tried building with all three of those options. The first two run with the artifacts described by this bug report and the last one doesn't run with the following error

$ ENABLE_PRIMUS_LAYER=1 VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/nv_vulkan_wrapper.json:/usr/share/vulkan/icd.d/intel_icd.x86_64.json optirun ./bin/bloom 
PrimusVK: Getting devices
PrimusVK: Searching for display GPU:
PrimusVK: 0x559661684310: 
PrimusVK: Got integrated gpu!
PrimusVK: Device: Intel(R) HD Graphics 530 (Skylake GT2)
PrimusVK:   Type: 1
PrimusVK: Searching for render GPU:
PrimusVK: 0x559661684310.
PrimusVK: 0x559661684340.
PrimusVK: Got discrete gpu!
PrimusVK: Device: GeForce GTX 960M
PrimusVK:   Type: 2
PrimusVK: in function: creating device
PrimusVK: Extension: 3
PrimusVK: Extension: 48
PrimusVK: Extension: 48
PrimusVK: spawning secondary device creation: 0x55966156ed98
PrimusVK: After reset:0
PrimusVK: fetching dispatch for 0x559661686020
PrimusVK: Device creation thread running
PrimusVK: CreateDevice done
PrimusVK: phys[1]: 0x5596616831a0
Can't find a display and a display mode!PrimusVK: render queues: 1

PrimusVK:  flags: 7
PrimusVK: in function: creating device
PrimusVK: Extension: 3
PrimusVK: Extension: 48
PrimusVK: Extension: 48

@greyltc
Copy link

greyltc commented Sep 8, 2019

I've done some more testing here. Cinnamon desktop doesn't show any issues. So I think even more so now that this is a Mutter compatibility problem.

@Nikki1993
Copy link

You mentioned sway does not have issues, but it does (at least it did at the time I reported it) since I was/still am using it and it exhibits artifacts when launching the game.

@felixdoerre
Copy link
Owner

I believe, I found the cause for gnome: https://gitlab.gnome.org/GNOME/mutter/merge_requests/687
I was able to reproduce the issue for gnome 3.30.1 and after finding that merge request, I tried 3.33.92 in which the error was gone. The fix should be in gnome >= 3.33.4. Could you please retry with that more recent gnome?

@greyltc
Copy link

greyltc commented Sep 12, 2019

I've used the method described in #24 to launch the Vulkan demos (compiled with cmake -DUSE_WAYLAND_WSI=ON) in Sway with xwayland disable to guarantee there's no funny GNOME or X stuff in the pipeline at all. I still get the artifacts.

So, to me, this is pretty strong evidence this is not GNOME or mutter related! So then in response to the above comment, I'm very surprised that a mutter patch solved it!

screenshot

@greyltc
Copy link

greyltc commented Sep 13, 2019

@felixdoerre I'll test out gnome >= 3.33.4 as soon as it hits the Arch testing repo (which I expect should be very soon)

@greyltc
Copy link

greyltc commented Sep 14, 2019

I don't see any change here with gnome 3.34.0
Screenshot from 2019-09-14 11-03-18

@felixdoerre
Copy link
Owner

@greyltc Thank's for testing. Interesting... I just re-tested 3.33.92, and yes, it's still broken. Maybe when I tested it previously, there was just something broken and gnome fallbacked to x11 and I didn't notice.

@felixdoerre
Copy link
Owner

Could you try if the issue persists with e3c4f6c ?

@artumino
Copy link

I did a bit of testing with e3c4f6c
Cleared the shader cache and tested WoW(DXVK) and TheSims4(D9VK)
The artifacts are gone from the games but they appeared on the Battle.net client.
Still a better trade-off for now...

@felixdoerre
Copy link
Owner

strange... the Battle.net client shows not artifacts on gnome-wayland when I try it.

@artumino
Copy link

Strange indeed, I'm also on gnome-wayland and the client looks like this
image

It could very well be something on my end, the in-game graphics are fixed though.

@felixdoerre
Copy link
Owner

did you also recompile/reinstall your 32-bit primus-vk?

@artumino
Copy link

Yeah, that's it. I forgot to also rebuild primus-vk 32-bit.
Everything is working as expected now

@hedgepigdaniel
Copy link

Can confirm, the problem is fixed on the latest master :)

@greyltc
Copy link

greyltc commented Sep 23, 2019

🎉 Confirmed here too, the latest master fixes this up on my end! Thanks!

@felixdoerre
Copy link
Owner

So, I think we can close this issue, as there are only positive test results with the fix. If someone still observes artifacts with the fix, we'll open a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants