Skip to content

Commit d0665ba

Browse files
Add 'mesa-vulkan-freedreno-24.0.0' and 'mesa-vulkan-freedreno-25.1.4'
1 parent 7217cbd commit d0665ba

14 files changed

+570
-0
lines changed

packages/index

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,12 @@ libffi
5555
zstd
5656
libarchive
5757
android-shmem
58+
mesa-vulkan-freedreno-24.0.0
5859
mesa-vulkan-freedreno-24.3.0
5960
mesa-vulkan-freedreno-25.0.0
6061
mesa-vulkan-freedreno-25.0.3
6162
mesa-vulkan-freedreno-25.1.0
63+
mesa-vulkan-freedreno-25.1.4
6264
mesa-vulkan-radeon
6365
mesa-vulkan-wrapper-rev8
6466
mesa-vulkan-wrapper-rev9
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
PKG_VER=24.0.0
2+
PKG_CATEGORY="VulkanDriver"
3+
PKG_PRETTY_NAME="Mesa Turnip Driver"
4+
PKG_OPTIONAL=1
5+
VK_DRIVER_LIB="libvulkan_freedreno.so"
6+
7+
BLACKLIST_ARCH=x86_64
8+
9+
SRC_URL=https://archive.mesa3d.org/mesa-$PKG_VER.tar.xz
10+
LDFLAGS="-L$PREFIX/lib -landroid-shmem"
11+
CPPFLAGS="-D__USE_GNU"
12+
MESON_ARGS="-Dgallium-drivers= -Dvulkan-drivers=freedreno -Dfreedreno-kmds=msm,kgsl -Dglvnd=false -Dplatforms=x11 -Dxmlconfig=enabled -Dllvm=disabled -Dopengl=false -Degl=disabled -Dzstd=enabled"
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
diff --git a/meson.build b/meson.build
2+
index 1c8667a8fce..1e9b4fd811d 100644
3+
--- a/meson.build
4+
+++ b/meson.build
5+
@@ -1361,7 +1361,7 @@ if not ['linux'].contains(host_machine.system())
6+
endif
7+
endif
8+
9+
-foreach h : ['xlocale.h', 'linux/futex.h', 'endian.h', 'dlfcn.h', 'sys/shm.h',
10+
+foreach h : ['linux/futex.h', 'endian.h', 'dlfcn.h', 'sys/shm.h',
11+
'cet.h', 'pthread_np.h', 'renderdoc_app.h', 'sys/inotify.h']
12+
if cc.check_header(h)
13+
pre_args += '-DHAVE_@0@'.format(h.to_upper().underscorify())
14+
@@ -1371,11 +1371,9 @@ endforeach
15+
functions_to_detect = {
16+
'strtof': '',
17+
'mkostemp': '',
18+
- 'memfd_create': '',
19+
'random_r': '',
20+
'flock': '',
21+
'strtok_r': '',
22+
- 'getrandom': '',
23+
'qsort_s': '',
24+
'posix_fallocate': '',
25+
'secure_getenv': '',
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
diff --git a/src/util/detect_os.h b/src/util/detect_os.h
2+
index 469b502bbd9..8a72b42aa08 100644
3+
--- a/src/util/detect_os.h
4+
+++ b/src/util/detect_os.h
5+
@@ -25,7 +25,7 @@
6+
* also be defined.
7+
*/
8+
#if defined(ANDROID)
9+
-#define DETECT_OS_ANDROID 1
10+
+#define DETECT_OS_ANDROID 0
11+
#endif
12+
13+
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
14+
diff --git a/include/vulkan/vk_android_native_buffer.h b/include/vulkan/vk_android_native_buffer.h
15+
index 746103bc1f4..9a76a321ffc 100644
16+
--- a/include/vulkan/vk_android_native_buffer.h
17+
+++ b/include/vulkan/vk_android_native_buffer.h
18+
@@ -18,7 +18,7 @@
19+
#define __VK_ANDROID_NATIVE_BUFFER_H__
20+
21+
/* MESA: A hack to avoid #ifdefs in driver code. */
22+
-#ifdef ANDROID
23+
+#if 0
24+
#include <cutils/native_handle.h>
25+
#include <vulkan/vulkan.h>
26+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
diff --git a/bin/install_megadrivers.py b/bin/install_megadrivers.py
2+
index 60ee4576c60..1e7108035cd 100644
3+
--- a/bin/install_megadrivers.py
4+
+++ b/bin/install_megadrivers.py
5+
@@ -24,7 +24,16 @@
6+
7+
import argparse
8+
import os
9+
+import shutil
10+
11+
+def link(src, dest):
12+
+ shutil.copyfile(src, dest)
13+
+
14+
+def unlink(src):
15+
+ os.remove(src)
16+
+
17+
+os.link = link
18+
+os.unlink = unlink
19+
20+
def main():
21+
parser = argparse.ArgumentParser()
Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
diff --git a/src/freedreno/vulkan/tu_device.cc b/src/freedreno/vulkan/tu_device.cc
2+
index f892fcedcb3..0a5c4dd7a49 100644
3+
--- a/src/freedreno/vulkan/tu_device.cc
4+
+++ b/src/freedreno/vulkan/tu_device.cc
5+
@@ -2624,6 +2624,14 @@ tu_AllocateMemory(VkDevice _device,
6+
uint64_t client_address = 0;
7+
BITMASK_ENUM(tu_bo_alloc_flags) alloc_flags = TU_BO_ALLOC_NO_FLAGS;
8+
9+
+ const VkExportMemoryAllocateInfo *export_info = vk_find_struct_const(
10+
+ pAllocateInfo->pNext, EXPORT_MEMORY_ALLOCATE_INFO);
11+
+ if (export_info && (export_info->handleTypes &
12+
+ (VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT |
13+
+ VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT))) {
14+
+ alloc_flags |= TU_BO_ALLOC_SHAREABLE;
15+
+ }
16+
+
17+
const VkMemoryOpaqueCaptureAddressAllocateInfo *replay_info =
18+
vk_find_struct_const(pAllocateInfo->pNext,
19+
MEMORY_OPAQUE_CAPTURE_ADDRESS_ALLOCATE_INFO);
20+
diff --git a/src/freedreno/vulkan/tu_knl.h b/src/freedreno/vulkan/tu_knl.h
21+
index 78cb442dc93..264000c5ea8 100644
22+
--- a/src/freedreno/vulkan/tu_knl.h
23+
+++ b/src/freedreno/vulkan/tu_knl.h
24+
@@ -21,6 +21,7 @@ enum tu_bo_alloc_flags
25+
TU_BO_ALLOC_ALLOW_DUMP = 1 << 0,
26+
TU_BO_ALLOC_GPU_READ_ONLY = 1 << 1,
27+
TU_BO_ALLOC_REPLAYABLE = 1 << 2,
28+
+ TU_BO_ALLOC_SHAREABLE = 1 << 3,
29+
};
30+
31+
/* Define tu_timeline_sync type based on drm syncobj for a point type
32+
@@ -53,6 +54,7 @@ struct tu_bo {
33+
uint32_t bo_list_idx;
34+
35+
bool implicit_sync : 1;
36+
+ int dmabuf_fd;
37+
};
38+
39+
struct tu_knl {
40+
diff --git a/src/freedreno/vulkan/tu_knl_kgsl.cc b/src/freedreno/vulkan/tu_knl_kgsl.cc
41+
index 0c2f16c496c..6a484d83a47 100644
42+
--- a/src/freedreno/vulkan/tu_knl_kgsl.cc
43+
+++ b/src/freedreno/vulkan/tu_knl_kgsl.cc
44+
@@ -11,6 +11,7 @@
45+
#include <stdint.h>
46+
#include <sys/ioctl.h>
47+
#include <sys/mman.h>
48+
+#include <linux/dma-heap.h>
49+
50+
#include "msm_kgsl.h"
51+
#include "vk_util.h"
52+
@@ -18,6 +19,7 @@
53+
#include "util/u_debug.h"
54+
#include "util/u_vector.h"
55+
#include "util/libsync.h"
56+
+#include "util/os_file.h"
57+
#include "util/timespec.h"
58+
59+
#include "tu_cmd_buffer.h"
60+
@@ -67,6 +69,57 @@ kgsl_submitqueue_close(struct tu_device *dev, uint32_t queue_id)
61+
safe_ioctl(dev->physical_device->local_fd, IOCTL_KGSL_DRAWCTXT_DESTROY, &req);
62+
}
63+
64+
+static int
65+
+dmabuf_alloc(uint64_t size)
66+
+{
67+
+ int ret;
68+
+ int dma_heap = open("/dev/dma_heap/system", O_RDONLY);
69+
+
70+
+ if (dma_heap < 0) {
71+
+ int ion_heap = open("/dev/ion", O_RDONLY);
72+
+
73+
+ if (ion_heap < 0)
74+
+ return -1;
75+
+
76+
+ struct ion_allocation_data {
77+
+ __u64 len;
78+
+ __u32 heap_id_mask;
79+
+ __u32 flags;
80+
+ __u32 fd;
81+
+ __u32 unused;
82+
+ } alloc_data = {
83+
+ .len = size,
84+
+ /* ION_HEAP_SYSTEM | ION_SYSTEM_HEAP_ID */
85+
+ .heap_id_mask = (1U << 0) | (1U << 25),
86+
+ .flags = 0, /* uncached */
87+
+ };
88+
+
89+
+ ret = safe_ioctl(ion_heap, _IOWR('I', 0, struct ion_allocation_data),
90+
+ &alloc_data);
91+
+
92+
+ close(ion_heap);
93+
+
94+
+ if (ret)
95+
+ return -1;
96+
+
97+
+ return alloc_data.fd;
98+
+ } else {
99+
+ struct dma_heap_allocation_data alloc_data = {
100+
+ .len = size,
101+
+ .fd_flags = O_RDWR | O_CLOEXEC,
102+
+ };
103+
+
104+
+ ret = safe_ioctl(dma_heap, DMA_HEAP_IOCTL_ALLOC, &alloc_data);
105+
+
106+
+ close(dma_heap);
107+
+
108+
+ if (ret)
109+
+ return -1;
110+
+
111+
+ return alloc_data.fd;
112+
+ }
113+
+}
114+
+
115+
static VkResult
116+
kgsl_bo_init(struct tu_device *dev,
117+
struct tu_bo **out_bo,
118+
@@ -78,6 +131,21 @@ kgsl_bo_init(struct tu_device *dev,
119+
{
120+
assert(client_iova == 0);
121+
122+
+ if (flags & TU_BO_ALLOC_SHAREABLE) {
123+
+ int fd = dmabuf_alloc(size);
124+
+
125+
+ if (fd < 0) {
126+
+ return vk_errorf(dev, VK_ERROR_OUT_OF_DEVICE_MEMORY,
127+
+ "DMABUF_ALLOC failed (%s)", strerror(errno));
128+
+ }
129+
+
130+
+ VkResult res = tu_bo_init_dmabuf(dev, out_bo, size, fd);
131+
+
132+
+ close(fd);
133+
+
134+
+ return res;
135+
+ }
136+
+
137+
struct kgsl_gpumem_alloc_id req = {
138+
.size = size,
139+
};
140+
@@ -113,6 +181,7 @@ kgsl_bo_init(struct tu_device *dev,
141+
.iova = req.gpuaddr,
142+
.name = tu_debug_bos_add(dev, req.mmapsize, name),
143+
.refcnt = 1,
144+
+ .dmabuf_fd = -1,
145+
};
146+
147+
*out_bo = bo;
148+
@@ -162,6 +231,7 @@ kgsl_bo_init_dmabuf(struct tu_device *dev,
149+
.iova = info_req.gpuaddr,
150+
.name = tu_debug_bos_add(dev, info_req.size, "dmabuf"),
151+
.refcnt = 1,
152+
+ .dmabuf_fd = os_dupfd_cloexec(fd),
153+
};
154+
155+
*out_bo = bo;
156+
@@ -172,9 +242,7 @@ kgsl_bo_init_dmabuf(struct tu_device *dev,
157+
static int
158+
kgsl_bo_export_dmabuf(struct tu_device *dev, struct tu_bo *bo)
159+
{
160+
- tu_stub();
161+
-
162+
- return -1;
163+
+ return os_dupfd_cloexec(bo->dmabuf_fd);
164+
}
165+
166+
static VkResult
167+
@@ -183,6 +251,15 @@ kgsl_bo_map(struct tu_device *dev, struct tu_bo *bo)
168+
if (bo->map)
169+
return VK_SUCCESS;
170+
171+
+ if (bo->dmabuf_fd != -1) {
172+
+ void *map = mmap(0, bo->size, PROT_READ | PROT_WRITE, MAP_SHARED, bo->dmabuf_fd, 0);
173+
+
174+
+ if (map != MAP_FAILED) {
175+
+ bo->map = map;
176+
+ return VK_SUCCESS;
177+
+ }
178+
+ }
179+
+
180+
uint64_t offset = bo->gem_handle << 12;
181+
void *map = mmap(0, bo->size, PROT_READ | PROT_WRITE, MAP_SHARED,
182+
dev->physical_device->local_fd, offset);
183+
@@ -210,6 +287,9 @@ kgsl_bo_finish(struct tu_device *dev, struct tu_bo *bo)
184+
if (bo->map)
185+
munmap(bo->map, bo->size);
186+
187+
+ if (bo->dmabuf_fd != -1)
188+
+ close(bo->dmabuf_fd);
189+
+
190+
struct kgsl_gpumem_free_id req = {
191+
.id = bo->gem_handle
192+
};
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
diff -uNr mesa-24.0.0/src/vulkan/wsi/wsi_common_display.c mesa-24.0.0-mod/src/vulkan/wsi/wsi_common_display.c
2+
--- mesa-24.0.0/src/vulkan/wsi/wsi_common_display.c 2024-01-31 20:29:42.000000000 -0300
3+
+++ mesa-24.0.0-mod/src/vulkan/wsi/wsi_common_display.c 2025-06-26 23:10:56.455202991 -0300
4+
@@ -175,6 +175,12 @@
5+
6+
static uint64_t fence_sequence;
7+
8+
+#ifdef __ANDROID__
9+
+static void thread_signal_handler (int signum) {
10+
+ pthread_exit (0);
11+
+}
12+
+#endif
13+
+
14+
ICD_DEFINE_NONDISP_HANDLE_CASTS(wsi_display_mode, VkDisplayModeKHR)
15+
ICD_DEFINE_NONDISP_HANDLE_CASTS(wsi_display_connector, VkDisplayKHR)
16+
17+
@@ -1339,8 +1345,9 @@
18+
.fd = wsi->fd,
19+
.events = POLLIN
20+
};
21+
-
22+
+#ifndef __ANDROID__
23+
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
24+
+#endif
25+
for (;;) {
26+
int ret = poll(&pollfd, 1, -1);
27+
if (ret > 0) {
28+
@@ -1370,7 +1377,11 @@
29+
{
30+
pthread_mutex_lock(&wsi->wait_mutex);
31+
if (wsi->wait_thread) {
32+
+#ifndef __ANDROID__
33+
pthread_cancel(wsi->wait_thread);
34+
+#else
35+
+ pthread_kill(wsi->wait_thread, SIGUSR2);
36+
+#endif
37+
pthread_join(wsi->wait_thread, NULL);
38+
wsi->wait_thread = 0;
39+
}
40+
@@ -2214,7 +2225,9 @@
41+
42+
int udev_fd = udev_monitor_get_fd(mon);
43+
44+
+#ifndef __ANDROID__
45+
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
46+
+#endif
47+
48+
for (;;) {
49+
nfds_t nfds = 1;
50+
@@ -2337,6 +2350,15 @@
51+
struct wsi_display *wsi =
52+
(struct wsi_display *) wsi_device->wsi[VK_ICD_WSI_PLATFORM_DISPLAY];
53+
54+
+#ifdef __ANDROID__
55+
+ struct sigaction actions;
56+
+ memset (&actions, 0, sizeof (actions));
57+
+ sigemptyset (&actions.sa_mask);
58+
+ actions.sa_flags = 0;
59+
+ actions.sa_handler = thread_signal_handler;
60+
+ sigaction (SIGUSR2, &actions, NULL);
61+
+#endif
62+
+
63+
if (wsi) {
64+
wsi_for_each_connector(connector, wsi) {
65+
wsi_for_each_display_mode(mode, connector) {
66+
@@ -2348,7 +2370,11 @@
67+
wsi_display_stop_wait_thread(wsi);
68+
69+
if (wsi->hotplug_thread) {
70+
+#ifndef __ANDROID__
71+
pthread_cancel(wsi->hotplug_thread);
72+
+#else
73+
+ pthread_kill(wsi->hotplug_thread, SIGUSR2);
74+
+#endif
75+
pthread_join(wsi->hotplug_thread, NULL);
76+
}
77+

packages/mesa-vulkan-freedreno-25.1.0/build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
PKG_VER=25.1.0
22
PKG_CATEGORY="VulkanDriver"
33
PKG_PRETTY_NAME="Mesa Turnip Driver"
4+
PKG_OPTIONAL=1
45
VK_DRIVER_LIB="libvulkan_freedreno.so"
56

67
BLACKLIST_ARCH=x86_64
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
PKG_VER=25.1.4
2+
PKG_CATEGORY="VulkanDriver"
3+
PKG_PRETTY_NAME="Mesa Turnip Driver"
4+
VK_DRIVER_LIB="libvulkan_freedreno.so"
5+
6+
BLACKLIST_ARCH=x86_64
7+
8+
SRC_URL=https://archive.mesa3d.org/mesa-$PKG_VER.tar.xz
9+
LDFLAGS="-L$PREFIX/lib -landroid-shmem"
10+
CPPFLAGS="-D__USE_GNU"
11+
MESON_ARGS="-Dgallium-drivers= -Dvulkan-drivers=freedreno -Dfreedreno-kmds=msm,kgsl -Dglvnd=disabled -Dplatforms=x11 -Dxmlconfig=enabled -Dllvm=disabled -Dopengl=false -Degl=disabled -Dzstd=enabled"

0 commit comments

Comments
 (0)