[Mesa-users] asynchronous / interruptible OSMesa render using glFenceSync: is it possible?

Brian Paul brianp at vmware.com
Fri May 13 20:55:45 UTC 2016


On 05/10/2016 05:13 AM, Frédéric Devernay wrote:
> Hi,
>
> I am using OSMesa to render large shaders, and would like to be able to
> interrupt the OSMesa render before it is finished, e.g. when there is
> user interaction.
>
> The OpenGL way to do this is to use glFenceSync/glClientWaitSync but
> glFenceSync blocks until llvmpipe is flushed and glClientWaitSync always
> returns GL_ALREADY_SIGNALED on OSMesa, without executing anything.
>
> Besides, many commands in OSMesa are blocking and cause an immediate
> render, such as glUseProgram(0) or glPopAttrib().

The amount of work that's done when a state-change command is hit 
depends on the driver.  With llvmpipe we try to queue up as much 
rendering as possible, effectively building a command list per screen 
tile.  Some state-change commands trigger rendering while others don't.

With softpipe/swrast, almost any state change after a drawing command 
will cause the queued drawing command(s) to be executed.


> Is there any way to do what I want to achieve, i.e. pipe all my commands
> and then wait for the render to finish with a timeout?

We don't have a way to do that now.  Are your images pretty large? 
Maybe one approach would to render the scene in tiled chunks.  For 
example, divide the window into an NxM grid of tiles, then render the 
scene into each tile with glScissor.  After rendering each tile, check 
if there's user input and abort drawing the grid if needed.

Ideally the tile size should be a multiple of llvmpipe's tile size which 
is 64x64.  llvmpipe employs multiple threads to process tiles in 
parallel so your tiles should probably be 128x128 for 4 cores, 256x128 
for 8 cores, etc.

Or maybe your rendering and UI code could be in separate threads.

-Brian



More information about the mesa-users mailing list