[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mesa3d-dev
Subject:    Re: [Mesa-dev] [PATCHv3 11/16] mesa: add infrastructure for threaded shader compilation
From:       Chia-I Wu <olvaffe () gmail ! com>
Date:       2014-08-21 2:06:28
Message-ID: CAPaKu7QssYx-21SzfD-TrbffxWHYYaOfjukTRTt3jc=mi0OAdQ () mail ! gmail ! com
[Download RAW message or body]

On Thu, Aug 21, 2014 at 12:40 AM, Fredrik Höglund <fredrik@kde.org> wrote:
> On Wednesday 20 August 2014, Chia-I Wu wrote:
>> Add _mesa_enable_glsl_threadpool to enable the thread pool for a context, and
>> add ctx->Const.DeferCompileShader and ctx->Const.DeferLinkProgram to
>> fine-control what gets threaded.
>>
>> Setting DeferCompileShader to true will make _mesa_glsl_compile_shader be
>> executed in a worker thread.  The function is thread-safe so there is no
>> restriction on DeferCompileShader.
>>
>> Setting DeferLinkProgram to true will make _mesa_glsl_link_shader be executed
>> in a worker thread.  The function is thread-safe only when certain driver
>> functions (as documented in struct gl_constants) are thread-safe.  It is
>> drivers' responsibility to fix those driver functions before setting
>> DeferLinkProgram.
>>
>> When DeferLinkProgram is set, drivers are not supposed to inspect the context
>> in their LinkShader callbacks.  Instead, NotifyLinkShader is added.  Drivers
>> should inspect the context in NotifyLinkShader and save what they need for
>> LinkShader in gl_shader_program.
>>
>> As a final note, most applications will not benefit from threaded shader
>> compilation because they check GL_COMPILE_STATUS/GL_LINK_STATUS immediately,
>> giving the worker threads no time to do their jobs.  A possible improvement is
>> to split LinkShader into two parts: the first part links and error checks
>> while the second part optimizes and generates the machine code.  With the
>> split, we can always defer the second part to the thread pool.
>
> It looks like _mesa_create_shader_program() needs a bit of work since
> it also checks the compile status immediately after compiling the shader.
It is left out in this series because I have no real-world app to
measure the time difference.  I also want to keep this series simple.

To support it, it should be possible to have a deferred function that
combines deferred_compile_shader and deferred_link_program, and delete
the shader afterward.


>
> Fredrik
>



-- 
olv@LunarG.com
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic