<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Feb 7, 2017 at 3:43 PM, Timothy Arceri <span dir="ltr"><<a href="mailto:tarceri@itsqueeze.com" target="_blank">tarceri@itsqueeze.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail-HOEnZb"><div class="gmail-h5">On Wed, 8 Feb 2017 08:29:29 +1100<br>
Timothy Arceri <<a href="mailto:tarceri@itsqueeze.com">tarceri@itsqueeze.com</a>> wrote:<br>
<br>
> On Tue, 7 Feb 2017 11:40:12 -0600<br>
> Aaron Watry <<a href="mailto:awatry@gmail.com">awatry@gmail.com</a>> wrote:<br>
><br>
> > On Mon, Feb 6, 2017 at 9:42 PM, Timothy Arceri<br>
> > <<a href="mailto:tarceri@itsqueeze.com">tarceri@itsqueeze.com</a>> wrote:<br>
> ><br>
> > > In order to avoid costly fallback recompiles when cache items are<br>
> > > created with an old version of Mesa or for a different gpu on the<br>
> > > same system we want to create directories that look like this:<br>
> > ><br>
> > > ./{MESA_VERSION_STRING}/{GPU_<wbr>ID}<br>
> > ><br>
> > > For llvm based drivers we will probably want an additional<br>
> > > {LLVM_VERSION} folder although it looks like there is currently<br>
> > > no support for querying this at runtime.<br>
> > > ---<br>
> > >  src/compiler/glsl/tests/cache_<wbr>test.c | 20 ++++++++++----------<br>
> > >  src/util/disk_cache.c                | 29<br>
> > > +++++++++++++++++++++++++---- src/util/disk_cache.h<br>
> > > |  4 ++-- 3 files changed, 37 insertions(+), 16 deletions(-)<br>
> > ><br>
> > > diff --git a/src/compiler/glsl/tests/<wbr>cache_test.c<br>
> > > b/src/compiler/glsl/tests/<wbr>cache_test.c<br>
> > > index 8547141..ba56441 100644<br>
> > > --- a/src/compiler/glsl/tests/<wbr>cache_test.c<br>
> > > +++ b/src/compiler/glsl/tests/<wbr>cache_test.c<br>
> > > @@ -126,7 +126,7 @@ test_disk_cache_create(void)<br>
> > >      * MESA_GLSL_CACHE_DISABLE set, that disk_cache_create returns<br>
> > > NULL. */<br>
> > >     setenv("MESA_GLSL_CACHE_<wbr>DISABLE", "1", 1);<br>
> > > -   cache = disk_cache_create();<br>
> > > +   cache = disk_cache_create("test", "make_check");<br>
> > >     expect_null(cache, "disk_cache_create with<br>
> > > MESA_GLSL_CACHE_DISABLE set");<br>
> > ><br>
> > >     unsetenv("MESA_GLSL_CACHE_<wbr>DISABLE");<br>
> > > @@ -137,19 +137,19 @@ test_disk_cache_create(void)<br>
> > >     unsetenv("MESA_GLSL_CACHE_DIR"<wbr>);<br>
> > >     unsetenv("XDG_CACHE_HOME");<br>
> > ><br>
> > > -   cache = disk_cache_create();<br>
> > > +   cache = disk_cache_create("test", "make_check");<br>
> > >     expect_non_null(cache, "disk_cache_create with no environment<br>
> > > variables");<br>
> > ><br>
> > >     disk_cache_destroy(cache);<br>
> > ><br>
> > >     /* Test with XDG_CACHE_HOME set */<br>
> > >     setenv("XDG_CACHE_HOME", CACHE_TEST_TMP "/xdg-cache-home", 1);<br>
> > > -   cache = disk_cache_create();<br>
> > > +   cache = disk_cache_create("test", "make_check");<br>
> > >     expect_null(cache, "disk_cache_create with XDG_CACHE_HOME set<br>
> > > with" "a non-existing parent directory");<br>
> > ><br>
> > >     mkdir(CACHE_TEST_TMP, 0755);<br>
> > > -   cache = disk_cache_create();<br>
> > > +   cache = disk_cache_create("test", "make_check");<br>
> > >     expect_non_null(cache, "disk_cache_create with XDG_CACHE_HOME<br>
> > > set");<br>
> > ><br>
> > >     disk_cache_destroy(cache);<br>
> > > @@ -159,12 +159,12 @@ test_disk_cache_create(void)<br>
> > >     expect_equal(err, 0, "Removing " CACHE_TEST_TMP);<br>
> > ><br>
> > >     setenv("MESA_GLSL_CACHE_DIR", CACHE_TEST_TMP<br>
> > > "/mesa-glsl-cache-dir", 1);<br>
> > > -   cache = disk_cache_create();<br>
> > > +   cache = disk_cache_create("test", "make_check");<br>
> > >     expect_null(cache, "disk_cache_create with MESA_GLSL_CACHE_DIR<br>
> > > set with"<br>
> > >                 "a non-existing parent directory");<br>
> > ><br>
> > >     mkdir(CACHE_TEST_TMP, 0755);<br>
> > > -   cache = disk_cache_create();<br>
> > > +   cache = disk_cache_create("test", "make_check");<br>
> > >     expect_non_null(cache, "disk_cache_create with<br>
> > > MESA_GLSL_CACHE_DIR set");<br>
> > ><br>
> > >     disk_cache_destroy(cache);<br>
> > > @@ -203,7 +203,7 @@ test_put_and_get(void)<br>
> > >     uint8_t one_KB_key[20], one_MB_key[20];<br>
> > >     int count;<br>
> > ><br>
> > > -   cache = disk_cache_create();<br>
> > > +   cache = disk_cache_create("test", "make_check");<br>
> > ><br>
> > >     _mesa_sha1_compute(blob, sizeof(blob), blob_key);<br>
> > ><br>
> > > @@ -235,7 +235,7 @@ test_put_and_get(void)<br>
> > >     disk_cache_destroy(cache);<br>
> > ><br>
> > >     setenv("MESA_GLSL_CACHE_MAX_<wbr>SIZE", "1K", 1);<br>
> > > -   cache = disk_cache_create();<br>
> > > +   cache = disk_cache_create("test", "make_check");<br>
> > ><br>
> > >     one_KB = calloc(1, 1024);<br>
> > ><br>
> > > @@ -287,7 +287,7 @@ test_put_and_get(void)<br>
> > >     disk_cache_destroy(cache);<br>
> > ><br>
> > >     setenv("MESA_GLSL_CACHE_MAX_<wbr>SIZE", "1M", 1);<br>
> > > -   cache = disk_cache_create();<br>
> > > +   cache = disk_cache_create("test", "make_check");<br>
> > ><br>
> > >     disk_cache_put(cache, blob_key, blob, sizeof(blob));<br>
> > >     disk_cache_put(cache, string_key, string, sizeof(string));<br>
> > > @@ -343,7 +343,7 @@ test_put_key_and_get_key(void)<br>
> > >                          { 0,  1, 42, 43, 44, 45, 46, 47, 48, 49,<br>
> > >                           50, 55, 52, 53, 54, 55, 56, 57, 58, 59};<br>
> > ><br>
> > > -   cache = disk_cache_create();<br>
> > > +   cache = disk_cache_create("test", "make_check");<br>
> > ><br>
> > >     /* First test that disk_cache_has_key returns false before<br>
> > > disk_cache_put_key */<br>
> > >     result = disk_cache_has_key(cache, key_a);<br>
> > > diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c<br>
> > > index 382ac6c..df511e4 100644<br>
> > > --- a/src/util/disk_cache.c<br>
> > > +++ b/src/util/disk_cache.c<br>
> > > @@ -115,7 +115,7 @@ mkdir_if_needed(char *path)<br>
> > >   *      <path>/<name> cannot be created as a directory<br>
> > >   */<br>
> > >  static char *<br>
> > > -concatenate_and_mkdir(void *ctx, char *path, char *name)<br>
> > > +concatenate_and_mkdir(void *ctx, char *path, const char *name)<br>
> > >  {<br>
> > >     char *new_path;<br>
> > >     struct stat sb;<br>
> > > @@ -131,8 +131,27 @@ concatenate_and_mkdir(void *ctx, char *path,<br>
> > > char *name)<br>
> > >        return NULL;<br>
> > >  }<br>
> > ><br>
> > > +static char *<br>
> > > +create_mesa_cache_dir(void *mem_ctx, char *path, const char<br>
> > > *mesa_version,<br>
> > > +                      const char *gpu_name)<br>
> > > +{<br>
> > > +   char *new_path = concatenate_and_mkdir(mem_ctx, path, "mesa");<br>
> > > +   if (new_path == NULL)<br>
> > > +      return NULL;<br>
> > > +<br>
> > > +   new_path = concatenate_and_mkdir(mem_ctx, new_path,<br>
> > > mesa_version);<br>
> > > +   if (new_path == NULL)<br>
> > > +      return NULL;<br>
> > > +<br>
> > > +   new_path = concatenate_and_mkdir(mem_ctx, new_path, gpu_name);<br>
> > > +   if (new_path == NULL)<br>
> > > +      return NULL;<br>
> > > +<br>
> > > +   return new_path;<br>
> > > +}<br>
> > > +<br>
> > >  struct disk_cache *<br>
> > > -disk_cache_create(void)<br>
> > > +disk_cache_create(const char *gpu_name, const char *mesa_version)<br>
> > ><br>
> ><br>
> > You forgot to update cache_test.c, so make check now fails:<br>
> ><br>
> > DIR/src/mesa/src/compiler/<wbr>glsl/tests/cache_test.c: In function<br>
> > ‘test_put_key_and_get_key’:<br>
> > DIR/src/mesa/src/compiler/<wbr>glsl/tests/cache_test.c:346:<wbr>12: error: too<br>
> > few arguments to function ‘disk_cache_create’<br>
> >     cache = disk_cache_create();<br>
> >             ^<br>
> > In file included from<br>
> > DIR/src/mesa/src/compiler/<wbr>glsl/tests/cache_test.c:36:0:<br>
> > DIR/src/mesa/src/util/disk_<wbr>cache.h:72:1: note: declared here<br>
> >  disk_cache_create(const char *driver_directory, const char<br>
> > *mesa_version); ^<br>
> > Makefile:2362: recipe for target<br>
> > 'glsl/tests/glsl_tests_cache_<wbr>test-cache_test.o' failed<br>
> ><br>
> ><br>
><br>
> Actually I fixed that before sending out, although I've done<br>
> something silly. I did git send-email to write the cover letter<br>
> then remembered to run make check afterwards and fixed the tests,<br>
> however that would have sent the original patch.<br>
><br>
> I'll send a v2 thanks.<br>
<br>
</div></div>Actually no I did send the right patch.<br>
<br>
It looks like you are running an old branch from my repo rather than<br>
this patch. Your error message doesn't match the function declaration<br>
here, and the test is updated above.<br>
<div class="gmail-HOEnZb"><div class="gmail-h5"><br></div></div></blockquote><div><div>Yeah, you're right...  I just skimmed this patch, and it's 
probably fine... I had pulled the shader-cache-radeonsi3 branch, which 
was the latest one on your github repo... which was evidently out of 
date and failed to compile.  I should've read the exact patch more closely before hitting send.<br><br></div>--Aaron<br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail-HOEnZb"><div class="gmail-h5">
><br>
><br>
> ><br>
> ><br>
> > >  {<br>
> > >     void *local;<br>
> > >     struct disk_cache *cache = NULL;<br>
> > > @@ -180,7 +199,8 @@ disk_cache_create(void)<br>
> > >           if (mkdir_if_needed(xdg_cache_<wbr>home) == -1)<br>
> > >              goto fail;<br>
> > ><br>
> > > -         path = concatenate_and_mkdir(local, xdg_cache_home,<br>
> > > "mesa");<br>
> > > +         path = create_mesa_cache_dir(local, xdg_cache_home,<br>
> > > mesa_version,<br>
> > > +                                      gpu_name);<br>
> > >           if (path == NULL)<br>
> > >              goto fail;<br>
> > >        }<br>
> > > @@ -216,7 +236,8 @@ disk_cache_create(void)<br>
> > >        if (path == NULL)<br>
> > >           goto fail;<br>
> > ><br>
> > > -      path = concatenate_and_mkdir(local, path, "mesa");<br>
> > > +      path = create_mesa_cache_dir(local, path, mesa_version,<br>
> > > +                                   gpu_name);<br>
> > >        if (path == NULL)<br>
> > >           goto fail;<br>
> > >     }<br>
> > > diff --git a/src/util/disk_cache.h b/src/util/disk_cache.h<br>
> > > index 1f2bf3d..e429db5 100644<br>
> > > --- a/src/util/disk_cache.h<br>
> > > +++ b/src/util/disk_cache.h<br>
> > > @@ -69,7 +69,7 @@ struct disk_cache;<br>
> > >   * assistance in computing SHA-1 signatures.<br>
> > >   */<br>
> > >  struct disk_cache *<br>
> > > -disk_cache_create(void);<br>
> > > +disk_cache_create(const char *gpu_name, const char<br>
> > > *mesa_version);<br>
> > ><br>
> > >  /**<br>
> > >   * Destroy a cache object, (freeing all associated resources).<br>
> > > @@ -140,7 +140,7 @@ disk_cache_has_key(struct disk_cache *cache,<br>
> > > cache_key key);<br>
> > >  #else<br>
> > ><br>
> > >  static inline struct disk_cache *<br>
> > > -disk_cache_create(void)<br>
> > > +disk_cache_create(const char *gpu_name, const char *mesa_version)<br>
> > >  {<br>
> > >     return NULL;<br>
> > >  }<br>
> > > --<br>
> > > 2.9.3<br>
> > ><br>
> > > ______________________________<wbr>_________________<br>
> > > mesa-dev mailing list<br>
> > > <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
> > > <a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
> > ><br>
><br>
> ______________________________<wbr>_________________<br>
> mesa-dev mailing list<br>
> <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
> <a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
<br>
</div></div></blockquote></div><br></div></div>