diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2019-05-27 07:20:32 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2019-05-27 07:20:32 +0000 |
commit | 47b2bb30c5643e0920b6a89f2416944777dfe27b (patch) | |
tree | 335d2e37daaf7ea33c312f542c0b375b40537a1a /lib/mesa/src/intel | |
parent | 02aebe809c282e963b12e439a0227f0715eb5987 (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/mesa/src/intel')
-rw-r--r-- | lib/mesa/src/intel/Makefile.in | 14 | ||||
-rw-r--r-- | lib/mesa/src/intel/Makefile.vulkan.am | 15 | ||||
-rw-r--r-- | lib/mesa/src/intel/vulkan/anv_allocator.c | 20 | ||||
-rw-r--r-- | lib/mesa/src/intel/vulkan/anv_device.c | 17 | ||||
-rw-r--r-- | lib/mesa/src/intel/vulkan/anv_private.h | 10 | ||||
-rw-r--r-- | lib/mesa/src/intel/vulkan/anv_queue.c | 2 |
6 files changed, 78 insertions, 0 deletions
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" |