Bug 110706 - glFinish does not wait for VBlank
Summary: glFinish does not wait for VBlank
Status: RESOLVED NOTABUG
Alias: None
Product: Mesa
Classification: Unclassified
Component: Drivers/DRI/i965 (show other bugs)
Version: 19.0
Hardware: x86-64 (AMD64) Linux (All)
: medium major
Assignee: Intel 3D Bugs Mailing List
QA Contact: Intel 3D Bugs Mailing List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-05-18 21:09 UTC by acc12345acc
Modified: 2019-05-25 07:31 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
triangle test (4.79 KB, text/x-c++src)
2019-05-18 21:09 UTC, acc12345acc
Details

Description acc12345acc 2019-05-18 21:09:13 UTC
Created attachment 144297 [details]
triangle test

I have attached a test program (compile with `g++ -o triangle triangle.cpp -lGL -lGLEW -lglfw`).

The triangle must rotate for 0.5 seconds, then stop for 0.5 seconds and continue rotating for 0.5 seconds, then stop for 0.5 seconds and so on. If this is the case, then it means glFinish is working correctly and waiting for VBlank. (indicated by "PASSED" after 5 seconds)

However, under Intel, the triangle does not continue rotating after stopping, but rather it skips, which means glFinish is not waiting and Mesa is catching up. (indicated by "FAILED")

Setting LIBGL_DRI3_DISABLE=1 works around the problem, but it isn't a solution.

glxinfo | grep OpenGL:

```
OpenGL vendor string: Intel Open Source Technology Center
OpenGL renderer string: Mesa DRI Intel(R) Ivybridge Mobile 
OpenGL core profile version string: 4.2 (Core Profile) Mesa 19.0.4
OpenGL core profile shading language version string: 4.20
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 3.0 Mesa 19.0.4
OpenGL shading language version string: 1.30
OpenGL context flags: (none)
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.0 Mesa 19.0.4
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.00
OpenGL ES profile extensions:
```
uname -a:
```
Linux work 5.0.7-arch1-1-ARCH #1 SMP PREEMPT Mon Apr 8 10:37:08 UTC 2019 x86_64 GNU/Linux
```

/etc/os-release:
```
NAME="Arch Linux"
PRETTY_NAME="Arch Linux"
ID=arch
BUILD_ID=rolling
ANSI_COLOR="0;36"
HOME_URL="https://www.archlinux.org/"
DOCUMENTATION_URL="https://wiki.archlinux.org/"
SUPPORT_URL="https://bbs.archlinux.org/"
BUG_REPORT_URL="https://bugs.archlinux.org/"
```

lscpu model name: Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz
DRI version: 3
Comment 1 Kenneth Graunke 2019-05-19 00:39:00 UTC
glFinish has nothing to do with monitor vblanks.  According to the GL 4.5 spec:

"The command

 void Finish( void );

 forces all previously issued GL commands to complete. Finish does not return
 until all effects from such commands on GL client and server state and the
 framebuffer are fully realized."

In practice, this means that:

1) We've queued all GPU commands for your drawing.
2) We sent those rendering commands to the GPU.
3) We waited until those commands completed, so your rendering (to the back buffer) is done.

It guarantees nothing about the presentation of those results in your windowing system.  You'd need to use GLX or EGL functionality for that, or work with your windowing system.

Your demo appears to call SwapBuffers, then Finish.  SwapBuffers will cause a flush.  Finish will likely wait until that rendering is complete.  But nothing syncs with vblank.
Comment 2 acc12345acc 2019-05-21 01:51:05 UTC
...but nothing syncs with VBlank? If you test using DRI2, or in AMD/NVIDIA, or even under Windows, it does.

Otherwise, how else am I going to block until VBlank? SGI_video_sync and OML_sync_control are broken as they may block permanently (#110697) and INTEL_swap_event does not help.


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.