[Mesa-dev] [PATCH 20/21] mesa: add support for threaded glCompileShader

Chia-I Wu olvaffe at gmail.com
Tue May 6 21:35:19 PDT 2014


On Mon, May 5, 2014 at 5:37 AM, Chia-I Wu <olvaffe at gmail.com> wrote:
> On Sat, May 3, 2014 at 1:59 AM, Ian Romanick <idr at freedesktop.org> wrote:
>> On 04/22/2014 01:58 AM, Chia-I Wu wrote:
>>> From: Chia-I Wu <olv at lunarg.com>
>>>
>>> Threaded glCompileShader can be enabled for a context by calling
>>> _mesa_enable_glsl_threadpool.  It will initialize the singleton GLSL thread
>>> pool and defer glCompileShader calls to the thread pool.
>>>
>>> For applications to benefit from threaded glCompileShader, they have to
>>> compile shaders in this fashion
>>>
>>>  for (i = 0; i < num_shaders; i++)
>>>    glCompileShader(shaders[i]);
>>>  for (i = 0; i < num_shaders; i++)
>>>    glGetShaderiv(shaders[i], GL_COMPILE_STATUS, &val);
>>
>> I think when you try this series on some real applications, you will be
>> disappointed.  Eric had a pretty similar branch
>> (http://cgit.freedesktop.org/~anholt/mesa/log/?h=compiler-threads), but
>> it saw no benefit on any applications... because everybody does
>>
>>     for (i = 0; i < num_shaders; i++) {
>>         glCompileShader(shaders[i]);
>>         glGetShaderiv(shaders[i], GL_COMPILE_STATUS, &val);
>>     }
>>
>> or
>>
>>     for (i = 0; i < num_shaders; i++) {
>>         glCompileShader(shaders[i]);
>>         glAttachShader(prog, shaders[i]);
>>     }
>>
>>     glLinkProgram(prog);
> Yeah, I am aware of the situation with real-world applications.  Only
> applications that are modified to not immediately check compilation results
> will get the speed up in compile times.  That is why this feature needs to be
> enabled through drirc.  We, at LunarG, are working with major game engines
> vendors to ensure this performance benefit is realized.
>
>> I'm also curious about your test case... did you link the shaders?  As
>> far as I'm aware, the bulk of time spent in the compiler happens during
>> linking (final optimizations and register allocation).  Eric's data
>> (http://lists.freedesktop.org/archives/mesa-dev/2014-April/057494.html)
>> says we spend more than 2x time in linking than in compiling.
> No, I did not.  In my other experiment with Unigine Tropics, the
> distribution of time was more like
>
> glCompileShader: 50%
> glLinkProgram FE: 25%
> glLinkProgram BE: 25%
I've rerun the test (source attached).  The numbers from compiling and
linking Unigine Tropics shaders are

  _mesa_CompileShader: 54.8%
  link_shaders: 17.1%
  brw_link_shaders: 27.9%

The numbers from running on another set of shaders (took about 100 seconds) are

  _mesa_CompileShader: 50.4%
  link_shaders: 5.6%
  brw_link_shaders: 43.8%


-- 
olv at LunarG.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: a.c
Type: text/x-csrc
Size: 3575 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20140507/30741d0c/attachment.c>


More information about the mesa-dev mailing list