Bug 111259

Summary: Presentation regression while rendering on X11 surface
Product: Mesa Reporter: jaelpark
Component: Drivers/Vulkan/CommonAssignee: mesa-dev
Status: RESOLVED NOTOURBUG QA Contact:
Severity: normal    
Priority: medium CC: airlied, chadversary, jason
Version: git   
Hardware: All   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:

Description jaelpark 2019-07-30 10:39:44 UTC
While rendering to an x11 surface, the frames appear in wrong order, making the graphics look corrupted. This probably depends on how the swap chain was created, since vkcube for example works fine.

I bisected the problem to this commit:
6f880f128f9862a047a5ba543c2843e14517b1e6
vulkan/wsi: update swapchain status on vkQueuePresent

Reproduced on:
OpenGL renderer string: Mesa DRI Intel(R) HD Graphics 630 (Kaby Lake GT2)
Comment 1 Lionel Landwerlin 2019-07-30 10:46:08 UTC
What application are you using to reproduce this problem?
Comment 2 jaelpark 2019-07-30 12:13:31 UTC
I was looking if there would be some minimal test case to demonstrate this, but couldn't find one so far. One case where this gets reproduced is the desktop compositor I've been working on. The build instructions and setup is here:
https://jaelpark.github.io/chamferwm-docs/setup.html#building-with-meson

After building, change the terminal emulator in line 504 of config/config.py to your preference, and once running, launch the terminal with Alt+Enter. Typing something will reveal how the frames come disordered and lagging. Using a recent version of mesa before this particular commit will result in expected behavior.
Comment 3 Lionel Landwerlin 2019-07-30 12:27:52 UTC
(In reply to jaelpark from comment #2)
> I was looking if there would be some minimal test case to demonstrate this,
> but couldn't find one so far. One case where this gets reproduced is the
> desktop compositor I've been working on. The build instructions and setup is
> here:
> https://jaelpark.github.io/chamferwm-docs/setup.html#building-with-meson
> 
> After building, change the terminal emulator in line 504 of config/config.py
> to your preference, and once running, launch the terminal with Alt+Enter.
> Typing something will reveal how the frames come disordered and lagging.
> Using a recent version of mesa before this particular commit will result in
> expected behavior.

I think I can spot the bug in your compositor :

compositor.cpp:984 : currentFrame = (currentFrame+1)%swapChainImageCount;

That's incorrect, the image indice returned by acquireNextImage() might not increment.
Comment 4 Lionel Landwerlin 2019-07-30 12:28:58 UTC
I would recommend using a list in which you push indices returned by acquireNextImage() and when you need a new currentFrame, you pull from that list.
Comment 5 jaelpark 2019-07-30 12:53:54 UTC
Okay, thanks a lot. I'll try fix this later and see how it goes.
Comment 6 Lionel Landwerlin 2019-07-30 13:14:42 UTC
Thanks, feel free to open if you still have the issue.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.