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

Frédéric Devernay frederic.devernay at inria.fr
Sat May 14 06:49:15 UTC 2016


Hi Brian,

I'm testing with shaders from Shadertoy.com, which may be pretty heavy (ray casting/marching and stuff).

This is used in an open source VFX/compositing software (Natron), so image resolution may be 4K and up.

Thanks for the tiled rendering tip, I'll do that.

We could even get rid of the glScissor stuff if OSMesaMakeCurrent had a "rowstride" parameter (pass the lower-left pixel address, tile width/height, and buffer rowstride).
This wouldn't penalize rendering speed, since the buffer is copied in the end anyway.

fred
--
Frédéric Devernay, Research Scientist, INRIA
frederic.devernay at inria.fr




> Le 13 mai 2016 à 22:55, Brian Paul <brianp at vmware.com> a écrit :
> 
> 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
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-users/attachments/20160514/8af4bd25/attachment.html>


More information about the mesa-users mailing list