summaryrefslogtreecommitdiff
path: root/graphics
diff options
context:
space:
mode:
Diffstat (limited to 'graphics')
-rw-r--r--graphics/MesaLib/patches/patch-src_drm-shim_drm__shim.c28
-rw-r--r--graphics/MesaLib/patches/patch-src_gallium_drivers_freedreno_freedreno__screen.c30
-rw-r--r--graphics/MesaLib/patches/patch-src_gallium_drivers_freedreno_freedreno__util.h31
-rw-r--r--graphics/MesaLib/patches/patch-src_gallium_frontends_clover_util_range.hpp40
-rw-r--r--graphics/MesaLib/patches/patch-src_gallium_frontends_osmesa_osmesa.c29
-rw-r--r--graphics/MesaLib/patches/patch-src_glx_dri__common.c41
-rw-r--r--graphics/MesaLib/patches/patch-src_mesa_main_context.c28
-rw-r--r--graphics/MesaLib/patches/patch-src_mesa_main_formats.c28
-rw-r--r--graphics/MesaLib/patches/patch-src_util_disk__cache__os.c18
-rw-r--r--graphics/MesaLib/patches/patch-src_util_libsync.h16
-rw-r--r--graphics/MesaLib/patches/patch-src_util_u__printf.h14
-rw-r--r--graphics/MesaLib/patches/patch-src_util_u__process.c34
12 files changed, 337 insertions, 0 deletions
diff --git a/graphics/MesaLib/patches/patch-src_drm-shim_drm__shim.c b/graphics/MesaLib/patches/patch-src_drm-shim_drm__shim.c
new file mode 100644
index 00000000000..644374be8fd
--- /dev/null
+++ b/graphics/MesaLib/patches/patch-src_drm-shim_drm__shim.c
@@ -0,0 +1,28 @@
+$NetBSD: patch-src_drm-shim_drm__shim.c,v 1.1 2022/03/13 15:52:50 tnn Exp $
+
+atexit() is not a good idea in shared libraries.
+
+--- src/drm-shim/drm_shim.c.orig 2021-07-14 20:04:46.724922400 +0000
++++ src/drm-shim/drm_shim.c
+@@ -162,7 +162,11 @@ drm_shim_override_file(const char *conte
+ override->contents = strdup(contents);
+ }
+
++#if defined(HAVE_NOATEXIT)
++static void __attribute__((__destructor__))
++#else
+ static void
++#endif
+ destroy_shim(void)
+ {
+ _mesa_set_destroy(opendir_set, NULL);
+@@ -227,7 +231,9 @@ init_shim(void)
+
+ drm_shim_device_init();
+
++#if !defined(HAVE_NOATEXIT)
+ atexit(destroy_shim);
++#endif
+ }
+
+ /* Override libdrm's reading of various sysfs files for device enumeration. */
diff --git a/graphics/MesaLib/patches/patch-src_gallium_drivers_freedreno_freedreno__screen.c b/graphics/MesaLib/patches/patch-src_gallium_drivers_freedreno_freedreno__screen.c
new file mode 100644
index 00000000000..ad6e6c56751
--- /dev/null
+++ b/graphics/MesaLib/patches/patch-src_gallium_drivers_freedreno_freedreno__screen.c
@@ -0,0 +1,30 @@
+$NetBSD: patch-src_gallium_drivers_freedreno_freedreno__screen.c,v 1.1 2022/03/13 15:52:50 tnn Exp $
+
+sysinfo(2) is for Linux only
+
+--- src/gallium/drivers/freedreno/freedreno_screen.c.orig 2021-12-01 19:04:14.000000000 +0000
++++ src/gallium/drivers/freedreno/freedreno_screen.c
+@@ -43,7 +43,9 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include "drm-uapi/drm_fourcc.h"
++#if !defined(__NetBSD__)
+ #include <sys/sysinfo.h>
++#endif
+
+ #include "freedreno_fence.h"
+ #include "freedreno_perfetto.h"
+@@ -1020,9 +1022,13 @@ fd_screen_create(struct fd_device *dev,
+ driParseConfigFiles(config->options, config->options_info, 0, "msm",
+ NULL, fd_dev_name(screen->dev_id), NULL, 0, NULL, 0);
+
++#if defined(__NetBSD__)
++ screen->ram_size = 512 * 1024 * 1024; /* XXX should use sysctl hw.physmem64 here */
++#else
+ struct sysinfo si;
+ sysinfo(&si);
+ screen->ram_size = si.totalram;
++#endif
+
+ DBG("Pipe Info:");
+ DBG(" GPU-id: %s", fd_dev_name(screen->dev_id));
diff --git a/graphics/MesaLib/patches/patch-src_gallium_drivers_freedreno_freedreno__util.h b/graphics/MesaLib/patches/patch-src_gallium_drivers_freedreno_freedreno__util.h
new file mode 100644
index 00000000000..11283117baa
--- /dev/null
+++ b/graphics/MesaLib/patches/patch-src_gallium_drivers_freedreno_freedreno__util.h
@@ -0,0 +1,31 @@
+$NetBSD: patch-src_gallium_drivers_freedreno_freedreno__util.h,v 1.1 2022/03/13 15:52:50 tnn Exp $
+
+gettid() is linux-specific
+
+--- src/gallium/drivers/freedreno/freedreno_util.h.orig 2022-01-12 21:32:28.000000000 +0000
++++ src/gallium/drivers/freedreno/freedreno_util.h
+@@ -108,6 +108,7 @@ extern bool fd_binning_enabled;
+ #include <sys/types.h>
+ #include <sys/syscall.h>
+
++#if defined(__linux__)
+ #define DBG(fmt, ...) \
+ do { \
+ if (FD_DBG(MSGS)) \
+@@ -115,6 +116,16 @@ extern bool fd_binning_enabled;
+ __FUNCTION__, __LINE__, \
+ ##__VA_ARGS__); \
+ } while (0)
++#else
++#define DBG(fmt, ...) \
++ do { \
++ if (FD_DBG(MSGS)) \
++ mesa_logi("%s:%d: " fmt, \
++ __FUNCTION__, __LINE__, \
++ ##__VA_ARGS__); \
++ } while (0)
++#endif
++
+
+ #define perf_debug_message(debug, type, ...) \
+ do { \
diff --git a/graphics/MesaLib/patches/patch-src_gallium_frontends_clover_util_range.hpp b/graphics/MesaLib/patches/patch-src_gallium_frontends_clover_util_range.hpp
new file mode 100644
index 00000000000..fe383391a3d
--- /dev/null
+++ b/graphics/MesaLib/patches/patch-src_gallium_frontends_clover_util_range.hpp
@@ -0,0 +1,40 @@
+$NetBSD: patch-src_gallium_frontends_clover_util_range.hpp,v 1.1 2022/03/13 15:52:50 tnn Exp $
+
+From FreeBSD ports for mesa 17.1.10:
+
+From b95533b981af9a6687b41418e7cc2a5652fc2bdb Mon Sep 17 00:00:00 2001
+Date: Fri, 7 Mar 2014 15:16:08 +0100
+Subject: [PATCH 3/3] Work around for clang 3.4 which fails to build Clover
+
+See:
+ https://bugs.freedesktop.org/show_bug.cgi?id=74098#c3
+
+--- src/gallium/frontends/clover/util/range.hpp.orig 2021-07-14 20:04:53.703990500 +0000
++++ src/gallium/frontends/clover/util/range.hpp
+@@ -362,6 +362,14 @@ namespace clover {
+ return { i, i + n };
+ }
+
++#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
++ namespace detail {
++ template<typename T>
++ using fixup_function_type =
++ typename std::conditional<std::is_function<T>::value, T &, T>::type;
++ }
++#endif
++
+ ///
+ /// Create a range by transforming the contents of a number of
+ /// source ranges \a rs element-wise using a provided functor \a f.
+@@ -369,7 +377,11 @@ namespace clover {
+ /// \sa adaptor_range.
+ ///
+ template<typename F, typename... Rs>
++#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
++ adaptor_range<detail::fixup_function_type<F>, Rs...>
++#else
+ adaptor_range<F, Rs...>
++#endif
+ map(F &&f, Rs &&... rs) {
+ return { std::forward<F>(f), std::forward<Rs>(rs)... };
+ }
diff --git a/graphics/MesaLib/patches/patch-src_gallium_frontends_osmesa_osmesa.c b/graphics/MesaLib/patches/patch-src_gallium_frontends_osmesa_osmesa.c
new file mode 100644
index 00000000000..7d0b65940df
--- /dev/null
+++ b/graphics/MesaLib/patches/patch-src_gallium_frontends_osmesa_osmesa.c
@@ -0,0 +1,29 @@
+$NetBSD: patch-src_gallium_frontends_osmesa_osmesa.c,v 1.1 2022/03/13 15:52:50 tnn Exp $
+
+atexit() is not a good idea in shared libraries.
+
+--- src/gallium/frontends/osmesa/osmesa.c.orig 2021-07-14 20:04:55.420007000 +0000
++++ src/gallium/frontends/osmesa/osmesa.c
+@@ -134,7 +134,11 @@ osmesa_st_get_param(struct st_manager *s
+ static struct st_manager *stmgr = NULL;
+ static struct st_api *stapi = NULL;
+
++#if defined(HAVE_NOATEXIT)
++static void __attribute__((__destructor__))
++#else
+ static void
++#endif
+ destroy_st_manager(void)
+ {
+ if (stmgr) {
+@@ -151,8 +155,10 @@ destroy_st_manager(void)
+ static void
+ create_st_manager(void)
+ {
++#if !defined(HAVE_NOATEXIT)
+ if (atexit(destroy_st_manager) != 0)
+ return;
++#endif
+
+ stmgr = CALLOC_STRUCT(st_manager);
+ if (stmgr) {
diff --git a/graphics/MesaLib/patches/patch-src_glx_dri__common.c b/graphics/MesaLib/patches/patch-src_glx_dri__common.c
new file mode 100644
index 00000000000..5367f1c52b5
--- /dev/null
+++ b/graphics/MesaLib/patches/patch-src_glx_dri__common.c
@@ -0,0 +1,41 @@
+$NetBSD: patch-src_glx_dri__common.c,v 1.1 2022/03/13 15:52:50 tnn Exp $
+
+atexit() is not a good idea in shared libraries.
+
+FreeBSD reported atexit bug for 10.6:
+https://bugs.freedesktop.org/show_bug.cgi?id=91869
+
+--- src/glx/dri_common.c.orig 2021-07-14 20:04:55.743010300 +0000
++++ src/glx/dri_common.c
+@@ -690,9 +690,19 @@ static struct driver_config_entry *drive
+ /* Called as an atexit function. Otherwise, this would have to be called with
+ * driver_config_mutex locked.
+ */
++#if defined(HAVE_NOATEXIT)
++static Bool e_next_ever_null = False;
++
++static void __attribute__((__destructor__))
++#else
+ static void
++#endif
+ clear_driver_config_cache()
+ {
++#if defined(HAVE_NOATEXIT)
++ if (!e_next_ever_null)
++ return;
++#endif
+ while (driver_config_cache) {
+ struct driver_config_entry *e = driver_config_cache;
+ driver_config_cache = e->next;
+@@ -777,7 +787,11 @@ glXGetDriverConfig(const char *driverNam
+ driver_config_cache = e;
+
+ if (!e->next)
++#if defined(HAVE_NOATEXIT)
++ e_next_ever_null = True;
++#else
+ atexit(clear_driver_config_cache);
++#endif
+
+ out:
+ pthread_mutex_unlock(&driver_config_mutex);
diff --git a/graphics/MesaLib/patches/patch-src_mesa_main_context.c b/graphics/MesaLib/patches/patch-src_mesa_main_context.c
new file mode 100644
index 00000000000..e4d0698301f
--- /dev/null
+++ b/graphics/MesaLib/patches/patch-src_mesa_main_context.c
@@ -0,0 +1,28 @@
+$NetBSD: patch-src_mesa_main_context.c,v 1.6 2022/03/13 15:52:50 tnn Exp $
+
+atexit() is not a good idea in shared libraries.
+
+--- src/mesa/main/context.c.orig 2021-07-14 20:04:58.296035000 +0000
++++ src/mesa/main/context.c
+@@ -324,7 +324,11 @@ _mesa_destroy_visual( struct gl_config *
+ * Calls all the various one-time-fini functions in Mesa
+ */
+
++#if defined(HAVE_NOATEXIT)
++static void __attribute__((__destructor__))
++#else
+ static void
++#endif
+ one_time_fini(void)
+ {
+ glsl_type_singleton_decref();
+@@ -357,7 +361,9 @@ one_time_init(void)
+ _mesa_ubyte_to_float_color_tab[i] = (float) i / 255.0F;
+ }
+
++#if !defined(HAVE_NOATEXIT)
+ atexit(one_time_fini);
++#endif
+
+ #if defined(DEBUG)
+ if (MESA_VERBOSE != 0) {
diff --git a/graphics/MesaLib/patches/patch-src_mesa_main_formats.c b/graphics/MesaLib/patches/patch-src_mesa_main_formats.c
new file mode 100644
index 00000000000..d96293f76ab
--- /dev/null
+++ b/graphics/MesaLib/patches/patch-src_mesa_main_formats.c
@@ -0,0 +1,28 @@
+$NetBSD: patch-src_mesa_main_formats.c,v 1.1 2022/03/13 15:52:50 tnn Exp $
+
+atexit() is not a good idea in shared libraries.
+
+--- src/mesa/main/formats.c.orig 2021-07-14 20:04:58.323035200 +0000
++++ src/mesa/main/formats.c
+@@ -451,7 +451,11 @@ _mesa_format_to_array_format(mesa_format
+ static struct hash_table *format_array_format_table;
+ static once_flag format_array_format_table_exists = ONCE_FLAG_INIT;
+
++#if defined(HAVE_NOATEXIT)
++static void __attribute__((__destructor__))
++#else
+ static void
++#endif
+ format_array_format_table_destroy(void)
+ {
+ _mesa_hash_table_destroy(format_array_format_table, NULL);
+@@ -496,7 +500,9 @@ format_array_format_table_init(void)
+ (void *)(intptr_t)f);
+ }
+
++#if !defined(HAVE_NOATEXIT)
+ atexit(format_array_format_table_destroy);
++#endif
+ }
+
+ mesa_format
diff --git a/graphics/MesaLib/patches/patch-src_util_disk__cache__os.c b/graphics/MesaLib/patches/patch-src_util_disk__cache__os.c
new file mode 100644
index 00000000000..2a9df5a4bbe
--- /dev/null
+++ b/graphics/MesaLib/patches/patch-src_util_disk__cache__os.c
@@ -0,0 +1,18 @@
+$NetBSD: patch-src_util_disk__cache__os.c,v 1.1 2022/03/13 15:52:50 tnn Exp $
+
+--- src/util/disk_cache_os.c.orig 2021-12-29 21:05:19.000000000 +0000
++++ src/util/disk_cache_os.c
+@@ -167,9 +167,13 @@ choose_lru_file_matching(const char *dir
+ /* First count the number of files in the directory */
+ unsigned total_file_count = 0;
+ while ((dir_ent = readdir(dir)) != NULL) {
++#if defined(DT_REG)
+ if (dir_ent->d_type == DT_REG) { /* If the entry is a regular file */
+ total_file_count++;
+ }
++#else
++ total_file_count++;
++#endif
+ }
+
+ /* Reset to the start of the directory */
diff --git a/graphics/MesaLib/patches/patch-src_util_libsync.h b/graphics/MesaLib/patches/patch-src_util_libsync.h
new file mode 100644
index 00000000000..deffa444fe3
--- /dev/null
+++ b/graphics/MesaLib/patches/patch-src_util_libsync.h
@@ -0,0 +1,16 @@
+$NetBSD: patch-src_util_libsync.h,v 1.1 2022/03/13 15:52:50 tnn Exp $
+
+sys/ioccom.h for _IOWR
+
+--- src/util/libsync.h.orig 2022-01-12 21:32:28.000000000 +0000
++++ src/util/libsync.h
+@@ -34,6 +34,9 @@
+ #include <stdint.h>
+ #include <string.h>
+ #include <sys/ioctl.h>
++#ifdef __sun__
++#include <sys/ioccom.h>
++#endif
+ #include <sys/poll.h>
+ #include <unistd.h>
+
diff --git a/graphics/MesaLib/patches/patch-src_util_u__printf.h b/graphics/MesaLib/patches/patch-src_util_u__printf.h
new file mode 100644
index 00000000000..7cf31123476
--- /dev/null
+++ b/graphics/MesaLib/patches/patch-src_util_u__printf.h
@@ -0,0 +1,14 @@
+$NetBSD: patch-src_util_u__printf.h,v 1.1 2022/03/13 15:52:50 tnn Exp $
+
+include cstdarg for va_list
+
+--- src/util/u_printf.h.orig 2021-12-01 19:04:14.000000000 +0000
++++ src/util/u_printf.h
+@@ -25,6 +25,7 @@
+ #ifdef __cplusplus
+
+ #include <string>
++#include <cstdarg>
+
+ /* find next valid printf specifier in a C++ std::string */
+ size_t util_printf_next_spec_pos(const std::string &s, size_t pos);
diff --git a/graphics/MesaLib/patches/patch-src_util_u__process.c b/graphics/MesaLib/patches/patch-src_util_u__process.c
new file mode 100644
index 00000000000..0c088bcb388
--- /dev/null
+++ b/graphics/MesaLib/patches/patch-src_util_u__process.c
@@ -0,0 +1,34 @@
+$NetBSD: patch-src_util_u__process.c,v 1.1 2022/03/13 15:52:50 tnn Exp $
+
+atexit() is not a good idea in shared libraries.
+
+--- src/util/u_process.c.orig 2021-07-14 20:04:59.260044300 +0000
++++ src/util/u_process.c
+@@ -48,9 +48,15 @@
+
+ static char *path = NULL;
+
+-static void __freeProgramPath()
++#if defined(HAVE_NOATEXIT)
++static void __attribute__((__destructor__))
++#else
++static void
++#endif
++__freeProgramPath()
+ {
+- free(path);
++ if (path)
++ free(path);
+ path = NULL;
+ }
+
+@@ -68,7 +74,9 @@ __getProgramName()
+ */
+ if (!path) {
+ path = realpath("/proc/self/exe", NULL);
++#if !defined(HAVE_NOATEXIT)
+ atexit(__freeProgramPath);
++#endif
+ }
+
+ if (path && strncmp(path, program_invocation_name, strlen(path)) == 0) {