[Mesa-dev] Proper implemtation of glFinish

Bob Gleitsmann rjgleits at bellsouth.net
Sat Jan 1 13:35:18 PST 2011

Hello everyone,

When trying the demo program copytex for the first time recently, I noticed 
pathological behavior: after running for a long time it asserted out and 
locked up X. Investigation showed this to be due to the glFinish function 
acting like glFlush and not waiting as it is supposed to for completion of 
whatever commands had been issued. I took up the task of remedying this. There 
are, as usual, a variety of different ways of doing so. Influenced by the 
current gallium code, I planned a separate call to the kernel to wait for the 
fence created by the pushbuf flush ioctl to complete. After completing the 
implementation in this way, it occurred to me that it would be more economical 
to modify the pushbuf flush ioctl call with a flag to indicate whether it should 
wait for completion or not. This would require modifying the FIRE_RING inline 
which appears in numerous places. Perhaps my original plan is adequate. 
The code changes required for the original plan involve mesa, drm, and the 
kernel. This forum seems like the best starting point to solicit feedback, 
since the whole thing is motivated by mesa. The Xorg nouveau driver does not 
seem to need anything of this nature. I have tested on my current hardware, 
x86-64 dual opteron and 7300 GT card. 

The assert out noted in the beginning was due to timeout in the 
__nouveau_fence_wait function in the kernel. Unfortunately, it does not exit 
gracefully. The patches that I came up with eliminate the timeout in the case 
of copytex, but this is clearly a flaw that someday should have a more complete 
Please let me know if I should send the kernel and drm patches to another 
forum (like dri-devel). For now I will post them here. 

Best Wishes,


More information about the mesa-dev mailing list