[Mesa-dev] [PATCH 2/2] glsl: don't recompile a shader on fallback unless needed

Timothy Arceri tarceri at itsqueeze.com
Sun Mar 12 01:51:52 UTC 2017



On 10/03/17 22:53, Marek Olšák wrote:
> For the series:
>
> Acked-by: Marek Olšák <marek.olsak at amd.com>
>

Thanks :)

> Does this fix the crash when GLSL gets a cache hit and st/mesa gets a
> cache miss?

There is no crash that I'm aware of. If you mean does the fallback path 
stop such a crash happening then yes.

>
> Marek
>
>
> On Thu, Mar 9, 2017 at 1:42 PM, Timothy Arceri <tarceri at itsqueeze.com> wrote:
>> On 09/03/17 22:58, Timothy Arceri wrote:
>>>
>>> Because we optimistically skip compiling shaders if we have seen them
>>> before we may need to compile them later at link time if they haven't
>>> yet been use in a specific combination to create a program.
>>>
>>> Rather than always recompiling we take advantage of the
>>> gl_compile_status enum introduced in the previous patch to only
>>> compile when we have previously skipped compilation.
>>>
>>> This should help with regressions in app start-up times on cold cache
>>> runs, compared with no cache.
>>
>>
>> Here are the stats:
>>
>> Deus Ex: Mankind Divided start-up times:
>>
>> cache disabled:               ~3m15s
>> cold cache master:            ~4m23s
>> cold cache with this patch:   ~3m33s
>>
>>
>>> ---
>>>  src/compiler/glsl/glsl_parser_extras.cpp | 7 +++++++
>>>  1 file changed, 7 insertions(+)
>>>
>>> diff --git a/src/compiler/glsl/glsl_parser_extras.cpp
>>> b/src/compiler/glsl/glsl_parser_extras.cpp
>>> index 59114a7..776636c 100644
>>> --- a/src/compiler/glsl/glsl_parser_extras.cpp
>>> +++ b/src/compiler/glsl/glsl_parser_extras.cpp
>>> @@ -1945,20 +1945,27 @@ _mesa_glsl_compile_shader(struct gl_context *ctx,
>>> struct gl_shader *shader,
>>>           if (ctx->_Shader->Flags & GLSL_CACHE_INFO) {
>>>              fprintf(stderr, "deferring compile of shader: %s\n",
>>>                      _mesa_sha1_format(buf, shader->sha1));
>>>           }
>>>           shader->CompileStatus = compile_skipped;
>>>
>>>           free((void *)shader->FallbackSource);
>>>           shader->FallbackSource = NULL;
>>>           return;
>>>        }
>>> +   } else {
>>> +      /* We should only ever end up here if a re-compile has been forced
>>> by a
>>> +       * shader cache miss. In which case we can skip the compile if its
>>> +       * already be done by a previous fallback or the initial compile
>>> call.
>>> +       */
>>> +      if (shader->CompileStatus == compile_success)
>>> +         return;
>>>     }
>>>
>>>     if (!state->error) {
>>>       _mesa_glsl_lexer_ctor(state, source);
>>>       _mesa_glsl_parse(state);
>>>       _mesa_glsl_lexer_dtor(state);
>>>       do_late_parsing_checks(state);
>>>     }
>>>
>>>     if (dump_ast) {
>>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list