[Mesa-dev] [PATCH] glsl, st/shader_cache: check the whole sha1 for zero

Edward O'Callaghan funfunctor at folklore1984.net
Mon Mar 27 02:48:47 UTC 2017


Reviewed-by: Edward O'Callaghan <funfunctor at folklore1984.net>

On 03/27/2017 11:42 AM, Timothy Arceri wrote:
> 
> 
> On 27/03/17 10:18, Grazvydas Ignotas wrote:
>> On Sun, Mar 26, 2017 at 11:45 PM, Timothy Arceri
>> <tarceri at itsqueeze.com> wrote:
>>>
>>>
>>> On 27/03/17 03:30, Grazvydas Ignotas wrote:
>>>>
>>>> The checks were only looking at the first byte, while the intention
>>>> seems to be to check if the whole sha1 is zero. This prevented all
>>>> shaders with first byte zero in their sha1 from being saved.
>>>>
>>>> This shaves around a second from Deus Ex load time on a hot cache.
>>>>
>>>> Signed-off-by: Grazvydas Ignotas <notasas at gmail.com>
>>>> ---
>>>>  src/compiler/glsl/shader_cache.cpp       | 3 ++-
>>>>  src/mesa/state_tracker/st_shader_cache.c | 3 ++-
>>>>  2 files changed, 4 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/src/compiler/glsl/shader_cache.cpp
>>>> b/src/compiler/glsl/shader_cache.cpp
>>>> index 274bb8c..ea1bc01 100644
>>>> --- a/src/compiler/glsl/shader_cache.cpp
>>>> +++ b/src/compiler/glsl/shader_cache.cpp
>>>> @@ -1219,11 +1219,12 @@ shader_cache_write_program_metadata(struct
>>>> gl_context *ctx,
>>>>      * generate a source from.
>>>>      *
>>>>      * TODO: In future we should use another method to generate a
>>>> key for
>>>> ff
>>>>      * programs.
>>>>      */
>>>> -   if (*prog->data->sha1 == 0)
>>>> +   static const char zero[sizeof(prog->data->sha1)] = {0};
>>>
>>>
>>> I don't think this will compile on Windows.
>>
>> Why do you think so? From my experience msvc (forced to use it at
>> work) is fine with sizeof(array) and zero initializers, and other code
>> in src/compiler/glsl/ has used both already.
> 
> I was worried about zero[sizeof(prog->data->sha1)] as msvc seem very
> picky about that type of thing but if you say it works then that's fine.
> 
>>
>> GraÅžvydas
>>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170327/00fc6c36/attachment.sig>


More information about the mesa-dev mailing list