<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sat, Nov 26, 2016 at 6:31 PM, Kenneth Graunke <span dir="ltr"><<a href="mailto:kenneth@whitecape.org" target="_blank">kenneth@whitecape.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Thursday, November 24, 2016 8:30:39 PM PST Emil Velikov wrote:<br>
> From: Emil Velikov <<a href="mailto:emil.velikov@collabora.com">emil.velikov@collabora.com</a>><br>
><br>
> Inspired by a similar commit for radv.<br>
><br>
> Rather than recomputing the timestamp on each make invocation, just<br>
> fetch it at runtime.<br>
><br>
> Thus we no longer get the constant rebuild of anv_device.c and the<br>
> follow-up libvulkan_intel.so link, when nothing has changed.<br>
><br>
> I.e. using make && make install is a little bit faster.<br>
><br>
> Signed-off-by: Emil Velikov <<a href="mailto:emil.velikov@collabora.com">emil.velikov@collabora.com</a>><br>
> ---<br>
> src/intel/vulkan/anv_device.c | 37 ++++++++++++++++++++++++++++++<wbr>+++----<br>
> 1 file changed, 33 insertions(+), 4 deletions(-)<br>
><br>
> diff --git a/src/intel/vulkan/anv_device.<wbr>c b/src/intel/vulkan/anv_device.<wbr>c<br>
> index 58c6b3f..4711501 100644<br>
> --- a/src/intel/vulkan/anv_device.<wbr>c<br>
> +++ b/src/intel/vulkan/anv_device.<wbr>c<br>
> @@ -21,15 +21,16 @@<br>
> * IN THE SOFTWARE.<br>
> */<br>
><br>
> +#include <dlfcn.h><br>
> #include <assert.h><br>
> #include <stdbool.h><br>
> #include <string.h><br>
> #include <sys/mman.h><br>
> +#include <sys/stat.h><br>
> #include <unistd.h><br>
> #include <fcntl.h><br>
><br>
> #include "anv_private.h"<br>
> -#include "anv_timestamp.h"<br>
> #include "util/strtod.h"<br>
> #include "util/debug.h"<br>
><br>
> @@ -53,11 +54,32 @@ compiler_perf_log(void *data, const char *fmt, ...)<br>
> va_end(args);<br>
> }<br>
><br>
> -static void<br>
> +static int<br>
<br>
</div></div>I'd prefer to have us return a bool on success - we don't tend to use<br>
the "0 means success" idiom much in Mesa.<br>
<span class=""><br>
> +anv_get_function_timestamp(<wbr>void *ptr, uint32_t* timestamp)<br>
> +{<br>
> + Dl_info info;<br>
> + struct stat st;<br>
> + if (!dladdr(ptr, &info) || !info.dli_fname)<br>
> + return -1;<br>
> +<br>
> + if (stat(info.dli_fname, &st))<br>
> + return -1;<br>
> +<br>
> + *timestamp = st.st_mtim.tv_sec;<br>
> + return 0;<br>
> +}<br>
> +<br>
> +static int<br>
<br>
</span>Ditto.<br>
<span class=""><br>
> anv_device_get_cache_uuid(void *uuid)<br>
> {<br>
> + uint32_t timestamp;<br>
> +<br>
> memset(uuid, 0, VK_UUID_SIZE);<br>
> - snprintf(uuid, VK_UUID_SIZE, "anv-%s", ANV_TIMESTAMP);<br>
> + if (anv_get_function_timestamp(<wbr>anv_device_get_cache_uuid, ×tamp))<br>
> + return -1;<br>
> +<br>
> + snprintf(uuid, VK_UUID_SIZE, "anv-%d", timestamp);<br>
> + return 0;<br>
> }<br>
><br>
> static VkResult<br>
> @@ -186,7 +208,14 @@ anv_physical_device_init(<wbr>struct anv_physical_device *device,<br>
> if (result != VK_SUCCESS)<br>
> goto fail;<br>
><br>
> - anv_device_get_cache_uuid(<wbr>device->uuid);<br>
> + if (anv_device_get_cache_uuid(<wbr>device->uuid)) {<br>
> + anv_finish_wsi(device);<br>
> + ralloc_free(device->compiler);<br>
> + result = vk_errorf(VK_ERROR_<wbr>INITIALIZATION_FAILED,<br>
> + "cannot generate UUID");<br>
> + goto fail;<br>
> + }<br>
> +<br>
<br>
</span>I don't see why this error case is special - all the others just have<br>
"goto fail". This stuff may need to get cleaned up, but shouldn't it<br>
happen for the other error paths too?<br>
<br>
I wrote these same patches today, not realizing you'd already done it,<br>
so with those comments addressed, consider it a series-wide:<br>
<br>
Reviewed-by: Kenneth Graunke <<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>><br>
<br>
But please wait for Jason - it sounds like he has some concerns and<br>
I'm not clear what those are.<br></blockquote><div><br></div><div>Nah. I'm fine with it. I'd just like to eventually come up with something more static. This seems to work fine.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">
> /* XXX: Actually detect bit6 swizzling */<br>
> isl_device_init(&device->isl_<wbr>dev, &device->info, swizzled);<br>
><br>
<br>
</div></div><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></blockquote></div><br></div></div>