On Tue, Apr 22, 2014 at 12:22:12PM -0700, Sarah Sharp wrote: > On Fri, Apr 18, 2014 at 06:21:31PM -0700, Jamey Sharp wrote: > > I'm no expert on OML_sync_control, but in a funny coincidence I've > > been reading that spec and Xorg's DRI2 implementation of it pretty > > carefully recently. (I blame keithp.) > > > > In test_eglGetSyncValuesCHROMIUM_msc_and_sbc_test, I think what the > > spec allows and requires might be a little different than what's > > tested, although I'm not sure. > > > > - I don't see that MSC has to change at all even after two > > eglSwapBuffers calls, if SwapBuffers doesn't sync to vertical retrace. > > I looked at the EGL 1.5 spec with Chad, and if you look at the > definition of eglSwapInterval, you'll see that the "minimum number of > video frame periods per buffer swap" is set to 1 by default. I think > one frame period is the time between vertical retraces, but the spec > isn't clear on that.
The spec is sadly ambiguous on that. It's also ambiguous on whether eglSwapBuffers blocks or immediately returns false if too many outstanding swaps are pending. I think it's safe to assume that it blocks. because that's what all EGL implementations do that I've used: X11, Android, Wayland, and (vacuously) GBM. (More below on why this it's vacuously true that GBM implements the blocking behavior). As for eglSwapBuffers being synchronized to vertical retraces, again it is on all platforms I've used. > > I think you can test this by setting the DRI config option > > vblank_mode=0 when you run your Piglit test. (I've read that you can > > set that as an environment variable but I can't find code in Mesa that > > would do that, so maybe you have to use drirc.) > > I asked Chad about this, and his argument was if you're setting random > environment variables, the test suite is not guaranteed to work. Jamey, Mesa does respect the environment var vblank_mode=0. You likely failed to find the code in Mesa because it lives in magic XML spaghetti. Like Sarah said. If you set env vars that provide nonconformant behavior, then your conformance testsuite may fail. > > - I'm not sure how you can ensure any SwapBuffers calls completed > > without using any of GLX_OML_sync_control, GLX_INTEL_swap_event, or > > implementation-specific knowledge. It isn't obvious to me that > > eglSwapBuffers can be relied on to throttle the client, even on a > > specific implementation like Xorg/DRI2. (Again, perhaps with > > vblank_mode=0; I'd expect turning off vsync to also turn off > > throttling.) Per the de facto standard behavior discussed above (that eglSwapBuffers blocks if swap_interval >= 1 and there exists outstanding swaps), if two calls to eglSwapBuffers have returned then at least one swap has completed. > It's apparently up to the driver to enforce the throttling of > eglSwapBuffers. Chad and I discussed explicitly setting > EGL_MIN_SWAP_INTERVAL and EGL_MAX_SWAP_INTERVAL to 1 in the EGL config. > The driver is supposed to throw an error if it can't accommodate that > swap interval, and that's a bug if it doesn't. I suggested adding a > piglit log warning if the test fails, something to the effect of: > > "MSC and SBC test failed, does the driver throttle eglSwapBuffers?" > > That way if the test fails, people will at least know what part of the > driver to look at. I've been playing with that idea. I even wrote a test app: https://github.com/chadversary/waffle/blob/wfl-swapinterval/src/utils/wfl-swapinterval.c I played with that test app on X11, Wayland, and GBM to discover exactly how the swap interval behaves on each platform. Wayland was the weirdest. I think the test should do this: Create the EGLConfig as it currently does. That is, do not specify EGL_[MIN|MAX]_SWAP_INTERVAL. Then immediately query eglGetConfigAttrib(EGL_MIN_SWAP_INTERVAL) and eglGetConfigAttrib(EGL_MAX_SWAP_INTERVAL). If the max swap interval is 0, then eglSwapBuffers will not block. So report PIGLIT_RESULT_SKIP. Else, the EGL spec ensures that the surface's swap interval is EGL_MIN_SWAP_INTERVAL. Calculate the expected MSC and SBC from that. For bonus points, let the desired swap_interval be an input parameter to the test. The test will skip if and only if requested_swap_interval is outside of [EGL_MIN_SWAP_INTERVAL, EGL_MAX_SWAP_INTERVAL]. The test sets the surface's swap interval with eglSwapInterval(requested_swap_interval), calculates expected values of of MSC and SBC, and tests for them. Why is GBM a special case? Because EGLConfigs on GBM have EGL_MIN_SWAP_INTERVAL == EGL_MAX_SWAP_INTERVAL == 0. So eglSwapBuffers never throttles. _______________________________________________ Piglit mailing list Piglit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/piglit