anv: move to using shared wsi code

This moves the shared code to a common subdirectory
and makes anv linked to that code instead of the copy
it was using.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
diff --git a/configure.ac b/configure.ac
index 8e779d4..7e63bfa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2631,6 +2631,8 @@
 AC_SUBST([VA_MAJOR], $VA_MAJOR)
 AC_SUBST([VA_MINOR], $VA_MINOR)
 
+AM_CONDITIONAL(HAVE_VULKAN_COMMON, test "x$VULKAN_DRIVERS" != "x")
+
 AC_SUBST([XVMC_MAJOR], 1)
 AC_SUBST([XVMC_MINOR], 0)
 
@@ -2789,7 +2791,8 @@
 		src/mesa/drivers/x11/Makefile
 		src/mesa/main/tests/Makefile
 		src/util/Makefile
-		src/util/tests/hash_table/Makefile])
+		src/util/tests/hash_table/Makefile
+		src/vulkan/wsi/Makefile])
 
 AC_OUTPUT
 
diff --git a/src/Makefile.am b/src/Makefile.am
index b63d135..1347120 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -115,6 +115,10 @@
 SUBDIRS += intel/tools
 endif
 
+if HAVE_VULKAN_COMMON
+SUBDIRS += vulkan/wsi
+endif
+
 ## Requires the i965 compiler (part of mesa) and wayland-drm
 if HAVE_INTEL_VULKAN
 SUBDIRS += intel/vulkan
diff --git a/src/intel/vulkan/Makefile.am b/src/intel/vulkan/Makefile.am
index 54a51be..5d2b3a5 100644
--- a/src/intel/vulkan/Makefile.am
+++ b/src/intel/vulkan/Makefile.am
@@ -49,6 +49,7 @@
 	-I$(top_srcdir)/include \
 	-I$(top_builddir)/src \
 	-I$(top_srcdir)/src \
+	-I$(top_srcdir)/src/vulkan/wsi \
 	-I$(top_builddir)/src/compiler \
 	-I$(top_srcdir)/src/compiler \
 	-I$(top_builddir)/src/compiler/nir \
@@ -116,6 +117,7 @@
 
 VULKAN_LIB_DEPS += \
 	libvulkan_common.la \
+	$(top_builddir)/src/vulkan/wsi/libvulkan_wsi.la \
 	$(top_builddir)/src/mesa/drivers/dri/i965/libi965_compiler.la \
 	$(top_builddir)/src/compiler/nir/libnir.la \
 	$(top_builddir)/src/util/libmesautil.la \
diff --git a/src/intel/vulkan/Makefile.sources b/src/intel/vulkan/Makefile.sources
index 62205d4..c51c146 100644
--- a/src/intel/vulkan/Makefile.sources
+++ b/src/intel/vulkan/Makefile.sources
@@ -42,19 +42,14 @@
 	anv_query.c \
 	anv_util.c \
 	anv_wsi.c \
-	wsi_common.h \
 	genX_pipeline_util.h \
 	vk_format_info.h
 
 VULKAN_WSI_WAYLAND_FILES := \
-	anv_wsi_wayland.c \
-	wsi_common_wayland.c \
-	wsi_common_wayland.h
+	anv_wsi_wayland.c
 
 VULKAN_WSI_X11_FILES := \
-	anv_wsi_x11.c \
-	wsi_common_x11.c \
-	wsi_common_x11.h
+	anv_wsi_x11.c
 
 VULKAN_GEM_FILES := \
 	anv_gem.c
diff --git a/src/vulkan/wsi/Makefile.am b/src/vulkan/wsi/Makefile.am
new file mode 100644
index 0000000..50a7401
--- /dev/null
+++ b/src/vulkan/wsi/Makefile.am
@@ -0,0 +1,49 @@
+
+include Makefile.sources
+
+vulkan_includedir = $(includedir)/vulkan
+
+noinst_LTLIBRARIES = libvulkan_wsi.la
+
+AM_CPPFLAGS = \
+	$(DEFINES) \
+	-I$(top_srcdir)/include \
+	-I$(top_builddir)/src \
+	-I$(top_srcdir)/src/gallium/auxiliary \
+	-I$(top_srcdir)/src/gallium/include
+
+AM_CFLAGS = \
+	$(VISIBILITY_CFLAGS)
+
+VULKAN_LIB_DEPS =
+
+VULKAN_WSI_SOURCES = \
+	$(VULKAN_WSI_FILES)
+
+if HAVE_PLATFORM_X11
+AM_CPPFLAGS += \
+	$(XCB_DRI3_CFLAGS) \
+	-DVK_USE_PLATFORM_XCB_KHR \
+	-DVK_USE_PLATFORM_XLIB_KHR
+
+VULKAN_WSI_SOURCES += $(VULKAN_WSI_X11_FILES)
+
+# FIXME: Use pkg-config for X11-xcb ldflags.
+VULKAN_LIB_DEPS += $(XCB_DRI3_LIBS) -lX11-xcb
+endif
+
+if HAVE_PLATFORM_WAYLAND
+AM_CPPFLAGS += \
+	-I$(top_builddir)/src/egl/wayland/wayland-drm \
+	-I$(top_srcdir)/src/egl/wayland/wayland-drm \
+	$(WAYLAND_CFLAGS) \
+	-DVK_USE_PLATFORM_WAYLAND_KHR
+
+VULKAN_WSI_SOURCES += $(VULKAN_WSI_WAYLAND_FILES)
+
+VULKAN_LIB_DEPS += \
+	$(top_builddir)/src/egl/wayland/wayland-drm/libwayland-drm.la \
+	$(WAYLAND_LIBS)
+endif
+
+libvulkan_wsi_la_SOURCES = $(VULKAN_WSI_SOURCES)
diff --git a/src/vulkan/wsi/Makefile.sources b/src/vulkan/wsi/Makefile.sources
new file mode 100644
index 0000000..3139e6d
--- /dev/null
+++ b/src/vulkan/wsi/Makefile.sources
@@ -0,0 +1,11 @@
+
+VULKAN_WSI_FILES := \
+	wsi_common.h
+
+VULKAN_WSI_WAYLAND_FILES := \
+	wsi_common_wayland.c \
+	wsi_common_wayland.h
+
+VULKAN_WSI_X11_FILES := \
+	wsi_common_x11.c \
+	wsi_common_x11.h
\ No newline at end of file
diff --git a/src/intel/vulkan/wsi_common.h b/src/vulkan/wsi/wsi_common.h
similarity index 100%
rename from src/intel/vulkan/wsi_common.h
rename to src/vulkan/wsi/wsi_common.h
diff --git a/src/intel/vulkan/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c
similarity index 99%
rename from src/intel/vulkan/wsi_common_wayland.c
rename to src/vulkan/wsi/wsi_common_wayland.c
index fc6775a..32a0a51 100644
--- a/src/intel/vulkan/wsi_common_wayland.c
+++ b/src/vulkan/wsi/wsi_common_wayland.c
@@ -24,6 +24,7 @@
 #include <wayland-client.h>
 #include <wayland-drm-client-protocol.h>
 
+#include <assert.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <unistd.h>
@@ -31,7 +32,7 @@
 #include <string.h>
 
 #include "wsi_common_wayland.h"
-#include "vk_format_info.h"
+
 #include <util/hash_table.h>
 #include <util/u_vector.h>
 
diff --git a/src/intel/vulkan/wsi_common_wayland.h b/src/vulkan/wsi/wsi_common_wayland.h
similarity index 100%
rename from src/intel/vulkan/wsi_common_wayland.h
rename to src/vulkan/wsi/wsi_common_wayland.h
diff --git a/src/intel/vulkan/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_x11.c
similarity index 99%
rename from src/intel/vulkan/wsi_common_x11.c
rename to src/vulkan/wsi/wsi_common_x11.c
index 02b6eb6..b5832c6 100644
--- a/src/intel/vulkan/wsi_common_x11.c
+++ b/src/vulkan/wsi/wsi_common_x11.c
@@ -27,12 +27,15 @@
 #include <xcb/dri3.h>
 #include <xcb/present.h>
 
-#include "util/hash_table.h"
+#include "util/macros.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <errno.h>
 #include <string.h>
+
+#include "util/hash_table.h"
+
 #include "wsi_common.h"
 #include "wsi_common_x11.h"
 
diff --git a/src/intel/vulkan/wsi_common_x11.h b/src/vulkan/wsi/wsi_common_x11.h
similarity index 100%
rename from src/intel/vulkan/wsi_common_x11.h
rename to src/vulkan/wsi/wsi_common_x11.h