dri3: Fix dri3_wait_for_sbc to wait for completion of requested SBC
dri3: Fix dri3_wait_for_sbc to wait for completion of requested SBC

Eric figured out that glXWaitForSbcOML wanted to block until the requested
SBC had been completed, which means to wait until the
PresentCompleteNotify event for that SBC had been received.

This replaces the simple sleep(1) loop (which was bogus) with a loop that
just checks to see if we've seen the specified SBC value come back in a
PresentCompleteNotify event yet.

The change is a bit larger than that as I've broken out a piece of common
code to wait for and process a single Present event for the target
drawable.

Signed-off-by: Keith Packard <fd7f967895e9f35e58ec8a62a847a54d7fa7275f@keithp.com>
Reviewed-by: Eric Anholt <96f164ad4d9b2b0dacf8ebee2bb1eeb3aa69adf1@anholt.net>

zeux/glsl-optimizer,mcanthony/glsl-optimizer,jbarczak/glsl-optimizer,mapbox/glsl-optimizer,dellis1972/glsl-optimizer,tokyovigilante/glsl-optimizer,tokyovigilante/glsl-optimizer,benaadams/glsl-optimizer,metora/MesaGLSLCompiler,zeux/glsl-optimizer,jbarczak/glsl-optimizer,zz85/glsl-optimizer,wolf96/glsl-optimizer,zz85/glsl-optimizer,metora/MesaGLSLCompiler,wolf96/glsl-optimizer,bkaradzic/glsl-optimizer,zeux/glsl-optimizer,mcanthony/glsl-optimizer,tokyovigilante/glsl-optimizer,benaadams/glsl-optimizer,mapbox/glsl-optimizer,bkaradzic/glsl-optimizer,zz85/glsl-optimizer,wolf96/glsl-optimizer,benaadams/glsl-optimizer,djreep81/glsl-optimizer,bkaradzic/glsl-optimizer,djreep81/glsl-optimizer,mapbox/glsl-optimizer,mapbox/glsl-optimizer,wolf96/glsl-optimizer,zz85/glsl-optimizer,zz85/glsl-optimizer,djreep81/glsl-optimizer,jbarczak/glsl-optimizer,mapbox/glsl-optimizer,dellis1972/glsl-optimizer,djreep81/glsl-optimizer,jbarczak/glsl-optimizer,benaadams/glsl-optimizer,djreep81/glsl-optimizer,tokyovigilante/glsl-optimizer,dellis1972/glsl-optimizer,benaadams/glsl-optimizer,mcanthony/glsl-optimizer,dellis1972/glsl-optimizer,benaadams/glsl-optimizer,jbarczak/glsl-optimizer,mcanthony/glsl-optimizer,bkaradzic/glsl-optimizer,zeux/glsl-optimizer,metora/MesaGLSLCompiler,zeux/glsl-optimizer,tokyovigilante/glsl-optimizer,mcanthony/glsl-optimizer,dellis1972/glsl-optimizer,wolf96/glsl-optimizer,bkaradzic/glsl-optimizer,zz85/glsl-optimizer