summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2019-05-27 07:20:32 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2019-05-27 07:20:32 +0000
commit47b2bb30c5643e0920b6a89f2416944777dfe27b (patch)
tree335d2e37daaf7ea33c312f542c0b375b40537a1a /lib
parent02aebe809c282e963b12e439a0227f0715eb5987 (diff)
Build Mesa intel and radeon vulkan drivers and amd64 and i386
The intel driver can be used with inteldrm on ivy bridge or newer. The radeon driver only works with amdgpu not radeondrm. As we can't use python in xenocara add phony targets to create the same output as python scripts which create json files for the loader. This is just the ICDs, to use vulkan the loader and additional ports are required. ok mpi@ on an earlier version. Changed to call shm_unlink() directly after shm_mkstemp() as suggested by kettenis@
Diffstat (limited to 'lib')
-rw-r--r--lib/mesa/Makefile.bsd-wrapper5
-rw-r--r--lib/mesa/src/amd/vulkan/Makefile.am14
-rw-r--r--lib/mesa/src/amd/vulkan/Makefile.in13
-rw-r--r--lib/mesa/src/amd/vulkan/radv_device.c4
-rw-r--r--lib/mesa/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c3
-rw-r--r--lib/mesa/src/intel/Makefile.in14
-rw-r--r--lib/mesa/src/intel/Makefile.vulkan.am15
-rw-r--r--lib/mesa/src/intel/vulkan/anv_allocator.c20
-rw-r--r--lib/mesa/src/intel/vulkan/anv_device.c17
-rw-r--r--lib/mesa/src/intel/vulkan/anv_private.h10
-rw-r--r--lib/mesa/src/intel/vulkan/anv_queue.c2
-rw-r--r--lib/mesa/src/util/futex.h20
12 files changed, 136 insertions, 1 deletions
diff --git a/lib/mesa/Makefile.bsd-wrapper b/lib/mesa/Makefile.bsd-wrapper
index a9f40c58f..2801def26 100644
--- a/lib/mesa/Makefile.bsd-wrapper
+++ b/lib/mesa/Makefile.bsd-wrapper
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile.bsd-wrapper,v 1.26 2019/05/23 05:33:19 jsg Exp $
+# $OpenBSD: Makefile.bsd-wrapper,v 1.27 2019/05/27 07:20:30 jsg Exp $
.include <bsd.own.mk>
.include <bsd.xconf.mk>
@@ -8,11 +8,13 @@ SHARED_LIBS= EGL 1.1 gbm 0.4 glapi 0.2 GL 17.1 GLESv1_CM 2.0 GLESv2 2.0 \
DRI_DRIVERS= swrast
GALLIUM_DRIVERS= swrast
+VULKAN_DRIVERS= no
WITH_LLVM= --disable-llvm
.if ${MACHINE} == i386 || ${MACHINE} == amd64
DRI_DRIVERS=swrast,radeon,r200,i915,i965
GALLIUM_DRIVERS=swrast,r300,r600,radeonsi
+VULKAN_DRIVERS= intel,radeon
WITH_LLVM= --enable-llvm
.endif
@@ -24,6 +26,7 @@ GALLIUM_DRIVERS=swrast,r300,r600
CONFIGURE_ARGS= --with-dri-drivers=${DRI_DRIVERS} \
--with-gallium-drivers=${GALLIUM_DRIVERS} \
+ --with-vulkan-drivers=${VULKAN_DRIVERS} \
--disable-silent-rules \
${WITH_LLVM} \
--disable-glx-tls \
diff --git a/lib/mesa/src/amd/vulkan/Makefile.am b/lib/mesa/src/amd/vulkan/Makefile.am
index 14b222d40..1e10f9ffb 100644
--- a/lib/mesa/src/amd/vulkan/Makefile.am
+++ b/lib/mesa/src/amd/vulkan/Makefile.am
@@ -199,6 +199,20 @@ dev_icd.json : radv_extensions.py radv_icd.py
radeon_icd.@host_cpu@.json : radv_extensions.py radv_icd.py
$(AM_V_GEN)$(PYTHON) $(srcdir)/radv_icd.py \
--lib-path="${libdir}" --out $@
+else
+radeon_icd.@host_cpu@.json :
+ @echo -e "{" > $@
+ @echo -e " \"ICD\": {" >> $@
+ @echo -e " \"api_version\": \"1.1.70\"," >> $@
+ @echo -e " \"library_path\": \"${libdir}/libvulkan_radeon.so\"" >> $@
+ @echo -e " }," >> $@
+ @echo -e " \"file_format_version\": \"1.0.0\"" >> $@
+ @echo -ne "}" >> $@
+
+.PHONY: radeon_icd.@host_cpu@.json
+
+dev_icd.json : radeon_icd.@host_cpu@.json
+ cp radeon_icd.@host_cpu@.json $@
endif
include $(top_srcdir)/install-lib-links.mk
diff --git a/lib/mesa/src/amd/vulkan/Makefile.in b/lib/mesa/src/amd/vulkan/Makefile.in
index f2d99f42f..e13095598 100644
--- a/lib/mesa/src/amd/vulkan/Makefile.in
+++ b/lib/mesa/src/amd/vulkan/Makefile.in
@@ -1286,6 +1286,19 @@ uninstall-am: uninstall-icdconfDATA uninstall-libLTLIBRARIES
@REGEN_SOURCES_TRUE@radeon_icd.@host_cpu@.json : radv_extensions.py radv_icd.py
@REGEN_SOURCES_TRUE@ $(AM_V_GEN)$(PYTHON) $(srcdir)/radv_icd.py \
@REGEN_SOURCES_TRUE@ --lib-path="${libdir}" --out $@
+@REGEN_SOURCES_FALSE@radeon_icd.@host_cpu@.json :
+@REGEN_SOURCES_FALSE@ @echo -e "{" > $@
+@REGEN_SOURCES_FALSE@ @echo -e " \"ICD\": {" >> $@
+@REGEN_SOURCES_FALSE@ @echo -e " \"api_version\": \"1.1.70\"," >> $@
+@REGEN_SOURCES_FALSE@ @echo -e " \"library_path\": \"${libdir}/libvulkan_radeon.so\"" >> $@
+@REGEN_SOURCES_FALSE@ @echo -e " }," >> $@
+@REGEN_SOURCES_FALSE@ @echo -e " \"file_format_version\": \"1.0.0\"" >> $@
+@REGEN_SOURCES_FALSE@ @echo -ne "}" >> $@
+
+@REGEN_SOURCES_FALSE@.PHONY: radeon_icd.@host_cpu@.json
+
+@REGEN_SOURCES_FALSE@dev_icd.json : radeon_icd.@host_cpu@.json
+@REGEN_SOURCES_FALSE@ cp radeon_icd.@host_cpu@.json $@
@BUILD_SHARED_TRUE@@HAVE_COMPAT_SYMLINKS_TRUE@all-local : .install-mesa-links
diff --git a/lib/mesa/src/amd/vulkan/radv_device.c b/lib/mesa/src/amd/vulkan/radv_device.c
index 334c8bd45..a81cb456a 100644
--- a/lib/mesa/src/amd/vulkan/radv_device.c
+++ b/lib/mesa/src/amd/vulkan/radv_device.c
@@ -49,6 +49,10 @@
#include "util/debug.h"
#include "util/mesa-sha1.h"
+#ifndef CLOCK_MONOTONIC_RAW
+#define CLOCK_MONOTONIC_RAW CLOCK_MONOTONIC
+#endif
+
static int
radv_device_get_cache_uuid(enum radeon_family family, void *uuid)
{
diff --git a/lib/mesa/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c b/lib/mesa/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c
index 49a86a72c..0c779806e 100644
--- a/lib/mesa/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c
+++ b/lib/mesa/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c
@@ -35,6 +35,9 @@
#include "radv_amdgpu_bo.h"
#include "sid.h"
+#ifndef ETIME
+#define ETIME ETIMEDOUT
+#endif
enum {
VIRTUAL_BUFFER_HASH_TABLE_SIZE = 1024
diff --git a/lib/mesa/src/intel/Makefile.in b/lib/mesa/src/intel/Makefile.in
index 519562b0c..0b540ff77 100644
--- a/lib/mesa/src/intel/Makefile.in
+++ b/lib/mesa/src/intel/Makefile.in
@@ -5057,6 +5057,20 @@ isl_tiled_memcpy_sse41.c: $(ISL_TILED_MEMCPY_DEP_FILES)
@REGEN_SOURCES_TRUE@ $(MKDIR_GEN)
@REGEN_SOURCES_TRUE@ $(AM_V_GEN)$(PYTHON) $(srcdir)/vulkan/anv_icd.py \
@REGEN_SOURCES_TRUE@ --lib-path="${libdir}" --out $@
+@REGEN_SOURCES_FALSE@vulkan/intel_icd.@host_cpu@.json :
+@REGEN_SOURCES_FALSE@ $(MKDIR_GEN)
+@REGEN_SOURCES_FALSE@ @echo -e "{" > $@
+@REGEN_SOURCES_FALSE@ @echo -e " \"ICD\": {" >> $@
+@REGEN_SOURCES_FALSE@ @echo -e " \"api_version\": \"1.1.96\"," >> $@
+@REGEN_SOURCES_FALSE@ @echo -e " \"library_path\": \"${libdir}/libvulkan_intel.so\"" >> $@
+@REGEN_SOURCES_FALSE@ @echo -e " }," >> $@
+@REGEN_SOURCES_FALSE@ @echo -e " \"file_format_version\": \"1.0.0\"" >> $@
+@REGEN_SOURCES_FALSE@ @echo -ne "}" >> $@
+
+@REGEN_SOURCES_FALSE@.PHONY: vulkan/intel_icd.@host_cpu@.json
+
+@REGEN_SOURCES_FALSE@vulkan/dev_icd.json : vulkan/intel_icd.@host_cpu@.json
+@REGEN_SOURCES_FALSE@ cp vulkan/intel_icd.@host_cpu@.json $@
@BUILD_SHARED_TRUE@@HAVE_COMPAT_SYMLINKS_TRUE@@HAVE_INTEL_VULKAN_TRUE@all-local : .install-mesa-links
diff --git a/lib/mesa/src/intel/Makefile.vulkan.am b/lib/mesa/src/intel/Makefile.vulkan.am
index c7b36ef4b..5a1e1f55d 100644
--- a/lib/mesa/src/intel/Makefile.vulkan.am
+++ b/lib/mesa/src/intel/Makefile.vulkan.am
@@ -75,6 +75,21 @@ vulkan/intel_icd.@host_cpu@.json : vulkan/anv_extensions.py vulkan/anv_icd.py
$(MKDIR_GEN)
$(AM_V_GEN)$(PYTHON) $(srcdir)/vulkan/anv_icd.py \
--lib-path="${libdir}" --out $@
+else
+vulkan/intel_icd.@host_cpu@.json :
+ $(MKDIR_GEN)
+ @echo -e "{" > $@
+ @echo -e " \"ICD\": {" >> $@
+ @echo -e " \"api_version\": \"1.1.96\"," >> $@
+ @echo -e " \"library_path\": \"${libdir}/libvulkan_intel.so\"" >> $@
+ @echo -e " }," >> $@
+ @echo -e " \"file_format_version\": \"1.0.0\"" >> $@
+ @echo -ne "}" >> $@
+
+.PHONY: vulkan/intel_icd.@host_cpu@.json
+
+vulkan/dev_icd.json : vulkan/intel_icd.@host_cpu@.json
+ cp vulkan/intel_icd.@host_cpu@.json $@
endif
if HAVE_INTEL_VULKAN
diff --git a/lib/mesa/src/intel/vulkan/anv_allocator.c b/lib/mesa/src/intel/vulkan/anv_allocator.c
index e9cc57649..2dd9f8804 100644
--- a/lib/mesa/src/intel/vulkan/anv_allocator.c
+++ b/lib/mesa/src/intel/vulkan/anv_allocator.c
@@ -25,9 +25,21 @@
#include <unistd.h>
#include <limits.h>
#include <assert.h>
+#ifdef __linux__
#include <linux/memfd.h>
+#else
+#include <fcntl.h>
+#endif
#include <sys/mman.h>
+#ifndef MAP_POPULATE
+#define MAP_POPULATE 0
+#endif
+
+#ifndef MFD_CLOEXEC
+#define MFD_CLOEXEC O_CLOEXEC
+#endif
+
#include "anv_private.h"
#include "util/hash_table.h"
@@ -115,7 +127,15 @@ struct anv_mmap_cleanup {
static inline int
memfd_create(const char *name, unsigned int flags)
{
+#ifdef __linux__
return syscall(SYS_memfd_create, name, flags);
+#else
+ char template[] = "/tmp/mesa-XXXXXXXXXX";
+ int fd = shm_mkstemp(template);
+ if (fd != -1)
+ shm_unlink(template);
+ return fd;
+#endif
}
#endif
diff --git a/lib/mesa/src/intel/vulkan/anv_device.c b/lib/mesa/src/intel/vulkan/anv_device.c
index 99b512a03..0768b1aa2 100644
--- a/lib/mesa/src/intel/vulkan/anv_device.c
+++ b/lib/mesa/src/intel/vulkan/anv_device.c
@@ -25,7 +25,12 @@
#include <stdbool.h>
#include <string.h>
#include <sys/mman.h>
+#ifdef __linux__
#include <sys/sysinfo.h>
+#else
+#include <sys/types.h>
+#include <sys/sysctl.h>
+#endif
#include <unistd.h>
#include <fcntl.h>
#include <xf86drm.h>
@@ -64,10 +69,22 @@ static uint64_t
anv_compute_heap_size(int fd, uint64_t gtt_size)
{
/* Query the total ram from the system */
+#ifdef __linux__
struct sysinfo info;
sysinfo(&info);
uint64_t total_ram = (uint64_t)info.totalram * (uint64_t)info.mem_unit;
+#else
+ int mib[2];
+ uint64_t total_ram;
+ size_t size;
+
+ mib[0] = CTL_HW;
+ mib[1] = HW_PHYSMEM64;
+ size = sizeof(total_ram);
+ if (sysctl(mib, 2, &total_ram, &size, NULL, 0) == -1)
+ return vk_error(VK_ERROR_INITIALIZATION_FAILED);
+#endif
/* We don't want to burn too much ram with the GPU. If the user has 4GiB
* or less, we use at most half. If they have more than 4GiB, we use 3/4.
diff --git a/lib/mesa/src/intel/vulkan/anv_private.h b/lib/mesa/src/intel/vulkan/anv_private.h
index 9979b832a..c0d27df0b 100644
--- a/lib/mesa/src/intel/vulkan/anv_private.h
+++ b/lib/mesa/src/intel/vulkan/anv_private.h
@@ -32,6 +32,16 @@
#include <stdint.h>
#include <i915_drm.h>
+#include <errno.h>
+#ifndef ETIME
+#define ETIME ETIMEDOUT
+#endif
+
+#include <time.h>
+#ifndef CLOCK_MONOTONIC_RAW
+#define CLOCK_MONOTONIC_RAW CLOCK_MONOTONIC
+#endif
+
#ifdef HAVE_VALGRIND
#include <valgrind.h>
#include <memcheck.h>
diff --git a/lib/mesa/src/intel/vulkan/anv_queue.c b/lib/mesa/src/intel/vulkan/anv_queue.c
index 55465c5eb..7e6ae109a 100644
--- a/lib/mesa/src/intel/vulkan/anv_queue.c
+++ b/lib/mesa/src/intel/vulkan/anv_queue.c
@@ -27,7 +27,9 @@
#include <fcntl.h>
#include <unistd.h>
+#ifdef __linux__
#include <sys/eventfd.h>
+#endif
#include "anv_private.h"
#include "vk_util.h"
diff --git a/lib/mesa/src/util/futex.h b/lib/mesa/src/util/futex.h
index 440289306..2ac0eb170 100644
--- a/lib/mesa/src/util/futex.h
+++ b/lib/mesa/src/util/futex.h
@@ -53,4 +53,24 @@ static inline int futex_wait(uint32_t *addr, int32_t value, const struct timespe
#endif
+#ifdef __OpenBSD__
+
+#include <sys/time.h>
+#include <sys/futex.h>
+
+static inline int futex_wake(uint32_t *addr, int count)
+{
+ return futex(addr, FUTEX_WAKE, count, NULL, NULL);
+}
+
+static inline int futex_wait(uint32_t *addr, int32_t value, const struct timespec *timeout)
+{
+ struct timespec tsrel, tsnow;
+ clock_gettime(CLOCK_MONOTONIC, &tsnow);
+ timespecsub(timeout, &tsrel, &tsrel);
+ return futex(addr, FUTEX_WAIT, value, &tsrel, NULL);
+}
+
+#endif
+
#endif /* UTIL_FUTEX_H */