<div dir="ltr"><div><div><div>We already talked on IRC about putting vk_alloc.h in src/util.  Assuming that's done, the series is<br><br></div>Acked-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br><br></div>Please make sure you do a fairly complete (fedora config?) build test.  I don't want those MIN/MAX macros to cause problems.<br><br></div>--Jason<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Oct 16, 2016 at 7:07 PM, Dave Airlie <span dir="ltr"><<a href="mailto:airlied@gmail.com" target="_blank">airlied@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Dave Airlie <<a href="mailto:airlied@redhat.com">airlied@redhat.com</a>><br>
<br>
vulkan allocation allows for overriding the allocator used,<br>
add some macros for anv/radv to share for this.<br>
<br>
Signed-off-by: Dave Airlie <<a href="mailto:airlied@redhat.com">airlied@redhat.com</a>><br>
---<br>
 <a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a>                 |  5 ++-<br>
 src/Makefile.am              |  4 +++<br>
 src/vulkan/Makefile.am       | 26 +++++++++++++++<br>
 src/vulkan/Makefile.sources  |  2 ++<br>
 src/vulkan/common/vk_alloc.h | 75 ++++++++++++++++++++++++++++++<wbr>++++++++++++++<br>
 5 files changed, 111 insertions(+), 1 deletion(-)<br>
 create mode 100644 src/vulkan/Makefile.am<br>
 create mode 100644 src/vulkan/Makefile.sources<br>
 create mode 100644 src/vulkan/common/vk_alloc.h<br>
<br>
diff --git a/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a> b/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a><br>
index b414edd..37cc306 100644<br>
--- a/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a><br>
+++ b/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a><br>
@@ -2693,6 +2693,8 @@ VA_MINOR=`$PKG_CONFIG --modversion libva | $SED -n 's/.*\.\(.*\)\..*$/\1/p'`<br>
 AC_SUBST([VA_MAJOR], $VA_MAJOR)<br>
 AC_SUBST([VA_MINOR], $VA_MINOR)<br>
<br>
+AM_CONDITIONAL(HAVE_VULKAN_<wbr>COMMON, test "x$VULKAN_DRIVERS" != "x")<br>
+<br>
 AC_SUBST([XVMC_MAJOR], 1)<br>
 AC_SUBST([XVMC_MINOR], 0)<br>
<br>
@@ -2851,7 +2853,8 @@ AC_CONFIG_FILES([Makefile<br>
                src/mesa/drivers/x11/Makefile<br>
                src/mesa/main/tests/Makefile<br>
                src/util/Makefile<br>
-               src/util/tests/hash_table/<wbr>Makefile])<br>
+               src/util/tests/hash_table/<wbr>Makefile<br>
+               src/vulkan/Makefile])<br>
<br>
 AC_OUTPUT<br>
<br>
diff --git a/src/Makefile.am b/src/Makefile.am<br>
index 17c8798..10e0826 100644<br>
--- a/src/Makefile.am<br>
+++ b/src/Makefile.am<br>
@@ -74,6 +74,10 @@ endif<br>
 # include only conditionally ?<br>
 SUBDIRS += compiler<br>
<br>
+if HAVE_VULKAN_COMMON<br>
+SUBDIRS += vulkan<br>
+endif<br>
+<br>
 if HAVE_AMD_DRIVERS<br>
 SUBDIRS += amd<br>
 endif<br>
diff --git a/src/vulkan/Makefile.am b/src/vulkan/Makefile.am<br>
new file mode 100644<br>
index 0000000..abe8404<br>
--- /dev/null<br>
+++ b/src/vulkan/Makefile.am<br>
@@ -0,0 +1,26 @@<br>
+# Copyright © 2016 Red Hat.<br>
+#<br>
+# Permission is hereby granted, free of charge, to any person obtaining a<br>
+# copy of this software and associated documentation files (the "Software"),<br>
+# to deal in the Software without restriction, including without limitation<br>
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
+# and/or sell copies of the Software, and to permit persons to whom the<br>
+# Software is furnished to do so, subject to the following conditions:<br>
+#<br>
+# The above copyright notice and this permission notice (including the next<br>
+# paragraph) shall be included in all copies or substantial portions of the<br>
+# Software.<br>
+#<br>
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL<br>
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br>
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING<br>
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS<br>
+# IN THE SOFTWARE.<br>
+<br>
+include Makefile.sources<br>
+<br>
+noinst_LTLIBRARIES =<br>
+<br>
+EXTRA_DIST = $(COMMON_HEADER_FILES)<br>
diff --git a/src/vulkan/Makefile.sources b/src/vulkan/Makefile.sources<br>
new file mode 100644<br>
index 0000000..a73bf99<br>
--- /dev/null<br>
+++ b/src/vulkan/Makefile.sources<br>
@@ -0,0 +1,2 @@<br>
+COMMON_HEADER_FILES = \<br>
+       common/vk_alloc.h<br>
diff --git a/src/vulkan/common/vk_alloc.h b/src/vulkan/common/vk_alloc.h<br>
new file mode 100644<br>
index 0000000..a8e21ca<br>
--- /dev/null<br>
+++ b/src/vulkan/common/vk_alloc.h<br>
@@ -0,0 +1,75 @@<br>
+/*<br>
+ * Copyright © 2015 Intel Corporation<br>
+ *<br>
+ * Permission is hereby granted, free of charge, to any person obtaining a<br>
+ * copy of this software and associated documentation files (the "Software"),<br>
+ * to deal in the Software without restriction, including without limitation<br>
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
+ * and/or sell copies of the Software, and to permit persons to whom the<br>
+ * Software is furnished to do so, subject to the following conditions:<br>
+ *<br>
+ * The above copyright notice and this permission notice (including the next<br>
+ * paragraph) shall be included in all copies or substantial portions of the<br>
+ * Software.<br>
+ *<br>
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL<br>
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br>
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING<br>
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS<br>
+ * IN THE SOFTWARE.<br>
+ */<br>
+#ifndef VK_ALLOC_H<br>
+#define VK_ALLOC_H<br>
+<br>
+/* common allocation inlines for vulkan drivers */<br>
+<br>
+#include <vulkan/vulkan.h><br>
+<br>
+static inline void *<br>
+vk_alloc(const VkAllocationCallbacks *alloc,<br>
+         size_t size, size_t align,<br>
+         VkSystemAllocationScope scope)<br>
+{<br>
+   return alloc->pfnAllocation(alloc-><wbr>pUserData, size, align, scope);<br>
+}<br>
+<br>
+static inline void *<br>
+vk_realloc(const VkAllocationCallbacks *alloc,<br>
+           void *ptr, size_t size, size_t align,<br>
+           VkSystemAllocationScope scope)<br>
+{<br>
+   return alloc->pfnReallocation(alloc-><wbr>pUserData, ptr, size, align, scope);<br>
+}<br>
+<br>
+static inline void<br>
+vk_free(const VkAllocationCallbacks *alloc, void *data)<br>
+{<br>
+   alloc->pfnFree(alloc-><wbr>pUserData, data);<br>
+}<br>
+<br>
+static inline void *<br>
+vk_alloc2(const VkAllocationCallbacks *parent_alloc,<br>
+          const VkAllocationCallbacks *alloc,<br>
+          size_t size, size_t align,<br>
+          VkSystemAllocationScope scope)<br>
+{<br>
+   if (alloc)<br>
+      return vk_alloc(alloc, size, align, scope);<br>
+   else<br>
+      return vk_alloc(parent_alloc, size, align, scope);<br>
+}<br>
+<br>
+static inline void<br>
+vk_free2(const VkAllocationCallbacks *parent_alloc,<br>
+         const VkAllocationCallbacks *alloc,<br>
+         void *data)<br>
+{<br>
+   if (alloc)<br>
+      vk_free(alloc, data);<br>
+   else<br>
+      vk_free(parent_alloc, data);<br>
+}<br>
+<br>
+#endif<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.5.5<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>
</font></span></blockquote></div><br></div>