diff --git a/tools/ubuntu/README.md b/tools/ubuntu/README.md index ba7256ccf7..751ce585c0 100644 --- a/tools/ubuntu/README.md +++ b/tools/ubuntu/README.md @@ -7,10 +7,10 @@ Steam on the desktop). The app installs it into `files/linuxfs` and runs it unde - `build-debs.sh` (run in an `ubuntu:26.04` container on an arm64 runner) rebuilds two Ubuntu source packages: Mesa with `-Dfreedreno-kmds=msm,kgsl`, so Turnip and freedreno reach Android's `/dev/kgsl-3d0`, and KWin with `patches/kwin` (nested desktop scale, an explicit render node, - scroll source/discrete forwarding). Both get a `+droiddeck` version. `patches/mesa` adds KGSL - UBWC 5/6 (backported from upstream Mesa) and the KGSL device numbers for WSI (from - [Droid-Deck/Drivers](https://github.com/Droid-Deck/Drivers)). It also carries Icenowy Zheng's upstream - Zink fix that keeps the Imagination depth/stencil swizzle off colour views (Mesa d55418dae7). + scroll source/discrete forwarding). Both get a `+droiddeck` version. `patches/mesa` adds the KGSL + device numbers for WSI (from [Droid-Deck/Drivers](https://github.com/Droid-Deck/Drivers)). + KGSL UBWC 5/6 and Icenowy Zheng's Zink fix that keeps the Imagination depth/stencil swizzle off + colour views (Mesa d55418dae7) are in Ubuntu's Mesa 26.2 and no longer patched. Zink also reclaims the memory a client freed once it has been idle for a second: otherwise only its next allocation does, and Steam's UI behind a game held 250 MiB more of unswappable GPU memory. - The runtime's built-in Vulkan driver is DroidDeck's DD-Turnip Linux build (`DD_TURNIP_URL` and diff --git a/tools/ubuntu/patches/mesa/0002-turnip-kgsl-accept-ubwc-5-and-6.patch b/tools/ubuntu/patches/mesa/0002-turnip-kgsl-accept-ubwc-5-and-6.patch deleted file mode 100644 index 1bdc8be424..0000000000 --- a/tools/ubuntu/patches/mesa/0002-turnip-kgsl-accept-ubwc-5-and-6.patch +++ /dev/null @@ -1,30 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: maxjivi05 -Date: Wed, 28 Oct 2026 13:30:00 -0400 -Subject: [PATCH] turnip/kgsl: accept UBWC 5 and 6 - -Backport of upstream Mesa's KGSL_UBWC_5_0/6_0 handling so Adreno 8xx -(UBWC 6) is found by the KGSL backend. ---- ---- a/src/freedreno/vulkan/msm_kgsl.h 2026-10-28 13:27:57.698671357 -0400 -+++ b/src/freedreno/vulkan/msm_kgsl.h 2026-10-28 13:27:57.700490261 -0400 -@@ -247,6 +247,8 @@ - #define KGSL_UBWC_2_0 2 - #define KGSL_UBWC_3_0 3 - #define KGSL_UBWC_4_0 4 -+#define KGSL_UBWC_5_0 5 -+#define KGSL_UBWC_6_0 6 - - /* - * Reset status values for context ---- a/src/freedreno/vulkan/tu_knl_kgsl.cc 2026-10-28 13:27:57.697821704 -0400 -+++ b/src/freedreno/vulkan/tu_knl_kgsl.cc 2026-10-28 13:27:57.710313562 -0400 -@@ -1884,6 +1884,8 @@ - device->ubwc_config.macrotile_mode = FDL_MACROTILE_4_CHANNEL; - break; - case KGSL_UBWC_4_0: -+ case KGSL_UBWC_5_0: -+ case KGSL_UBWC_6_0: - device->ubwc_config.bank_swizzle_levels = 0x6; - device->ubwc_config.macrotile_mode = FDL_MACROTILE_8_CHANNEL; - break; diff --git a/tools/ubuntu/patches/mesa/0003-turnip-kgsl-report-device-numbers-for-wsi.patch b/tools/ubuntu/patches/mesa/0003-turnip-kgsl-report-device-numbers-for-wsi.patch index 5d09c46d80..91a080d483 100644 --- a/tools/ubuntu/patches/mesa/0003-turnip-kgsl-report-device-numbers-for-wsi.patch +++ b/tools/ubuntu/patches/mesa/0003-turnip-kgsl-report-device-numbers-for-wsi.patch @@ -8,9 +8,11 @@ nested compositor such as gamescope can advertise dma-buf feedback and Vulkan swapchains work without the software WSI. Ported from Droid-Deck/Drivers (patches/scripts/linux_kgsl_wsi.py). --- ---- a/src/freedreno/vulkan/tu_device.cc 2026-10-28 14:41:54.161481991 -0400 -+++ b/src/freedreno/vulkan/tu_device.cc 2026-10-28 14:41:54.174757117 -0400 -@@ -312,7 +312,7 @@ +diff --git a/src/freedreno/vulkan/tu_device.cc b/src/freedreno/vulkan/tu_device.cc +index e8ef940..78ea4fc 100644 +--- a/src/freedreno/vulkan/tu_device.cc ++++ b/src/freedreno/vulkan/tu_device.cc +@@ -353,7 +353,7 @@ get_device_extensions(const struct tu_physical_device *device, .EXT_mutable_descriptor_type = true, .EXT_nested_command_buffer = true, .EXT_non_seamless_cube_map = true, @@ -18,19 +20,21 @@ Droid-Deck/Drivers (patches/scripts/linux_kgsl_wsi.py). + .EXT_physical_device_drm = !is_kgsl(device->instance) || device->has_local, .EXT_pipeline_creation_cache_control = true, .EXT_pipeline_creation_feedback = true, - .EXT_primitive_topology_list_restart = true, ---- a/src/freedreno/vulkan/tu_knl_kgsl.cc 2026-10-28 14:41:54.159481934 -0400 -+++ b/src/freedreno/vulkan/tu_knl_kgsl.cc 2026-10-28 14:41:54.174233883 -0400 -@@ -11,6 +11,8 @@ + #ifdef TU_USE_WSI_PLATFORM +diff --git a/src/freedreno/vulkan/tu_knl_kgsl.cc b/src/freedreno/vulkan/tu_knl_kgsl.cc +index 9cb95ec..a7a2ee0 100644 +--- a/src/freedreno/vulkan/tu_knl_kgsl.cc ++++ b/src/freedreno/vulkan/tu_knl_kgsl.cc +@@ -10,6 +10,8 @@ #include #include #include +#include +#include - #include #define __user -@@ -1907,6 +1909,13 @@ + #include "ion/ion.h" +@@ -1943,6 +1945,13 @@ tu_knl_kgsl_load(struct tu_instance *instance, int fd) instance->knl = &kgsl_knl_funcs; diff --git a/tools/ubuntu/patches/mesa/0005-zink-check-zs-aspect-before-creating-zs-view.patch b/tools/ubuntu/patches/mesa/0005-zink-check-zs-aspect-before-creating-zs-view.patch deleted file mode 100644 index 3a2aa0bd96..0000000000 --- a/tools/ubuntu/patches/mesa/0005-zink-check-zs-aspect-before-creating-zs-view.patch +++ /dev/null @@ -1,41 +0,0 @@ -From d55418dae753c8daacf66ab81a7481094808576a Mon Sep 17 00:00:00 2001 -From: Icenowy Zheng -Date: Sun, 31 May 2026 21:56:32 +0800 -Subject: [PATCH] zink: check Z/S aspect before creating Z/S image view - -When moving the code of creating image views to the init_sampler_view() -function, the check for Z/S aspect bits was forgotten to be added -(because it was a big if gating a lot of code originally). - -When the driver doesn't have needs_zs_shader_swizzle set, this is not -problematic, because the condition for creating Z/S view is to have only -Z aspect; however the needs_zs_shader_swizzle case now fails because Z/S -views are now created for color images. - -Fix the issue by re-adding the Z/S aspect check before checking -needs_zs_shader_swizzle flag. - -Fixes: cafa22142bf1 ("zink: create views for samplers lazily") -Signed-off-by: Icenowy Zheng -Part-of: ---- - src/gallium/drivers/zink/zink_context.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c -index e264e57b2703..41bc1b6932a7 100644 ---- a/src/gallium/drivers/zink/zink_context.c -+++ b/src/gallium/drivers/zink/zink_context.c -@@ -1173,7 +1173,8 @@ init_sampler_view(struct zink_context *ctx, struct zink_sampler_view *sv) - - bool red_depth_sampler_view = false; - if (sv->ivci.subresourceRange.aspectMask == VK_IMAGE_ASPECT_DEPTH_BIT || -- screen->driver_compiler_workarounds.needs_zs_shader_swizzle) { -+ ((sv->ivci.subresourceRange.aspectMask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) && -+ screen->driver_compiler_workarounds.needs_zs_shader_swizzle)) { - VkComponentSwizzle *swizzle = (VkComponentSwizzle*)&sv->ivci.components; - for (unsigned i = 0; i < 4; i++) { - if (swizzle[i] == VK_COMPONENT_SWIZZLE_ONE || --- -GitLab - diff --git a/tools/ubuntu/patches/mesa/0006-zink-reclaim-freed-memory-while-the-client-is-idle.patch b/tools/ubuntu/patches/mesa/0006-zink-reclaim-freed-memory-while-the-client-is-idle.patch index a2081913f2..34b23bd68d 100644 --- a/tools/ubuntu/patches/mesa/0006-zink-reclaim-freed-memory-while-the-client-is-idle.patch +++ b/tools/ubuntu/patches/mesa/0006-zink-reclaim-freed-memory-while-the-client-is-idle.patch @@ -7,55 +7,8 @@ fullscreen game after scrolling its library, and released it the moment the overlay drew a frame. A thread now reclaims once a second after a second without allocations. ---- a/src/util/pb_slab.h -+++ b/src/util/pb_slab.h -@@ -145,6 +145,9 @@ - unsigned - pb_slabs_reclaim(struct pb_slabs *slabs); - -+unsigned -+pb_slabs_reclaim_all(struct pb_slabs *slabs); -+ - bool - pb_slabs_init(struct pb_slabs *slabs, - unsigned min_order, unsigned max_order, ---- a/src/util/pb_slab.c -+++ b/src/util/pb_slab.c -@@ -231,6 +231,19 @@ - return num_reclaims; - } - -+/* Like pb_slabs_reclaim, but skips entries that are still in use instead of -+ * stopping at the first ones, so entries freed behind them are reclaimed too. -+ */ -+unsigned -+pb_slabs_reclaim_all(struct pb_slabs *slabs) -+{ -+ unsigned num_reclaims; -+ simple_mtx_lock(&slabs->mutex); -+ num_reclaims = pb_slabs_reclaim_all_locked(slabs); -+ simple_mtx_unlock(&slabs->mutex); -+ return num_reclaims; -+} -+ - /* Initialize the slabs manager. - * - * The minimum and maximum size of slab entries are 2^min_order and ---- a/src/gallium/drivers/zink/zink_types.h -+++ b/src/gallium/drivers/zink/zink_types.h -@@ -1427,6 +1427,12 @@ - struct pb_slabs bo_slabs[NUM_SLAB_ALLOCATORS]; - unsigned min_alloc_size; - uint32_t next_bo_unique_id; -+ uint32_t alloc_serial; -+ thrd_t reclaim_thread; -+ mtx_t reclaim_lock; -+ cnd_t reclaim_cond; -+ bool reclaim_stop; -+ bool reclaim_running; - } pb; - uint8_t heap_map[ZINK_HEAP_MAX][VK_MAX_MEMORY_TYPES]; // mapping from zink heaps to memory type indices - uint8_t heap_count[ZINK_HEAP_MAX]; // number of memory types per zink heap +diff --git a/src/gallium/drivers/zink/zink_bo.c b/src/gallium/drivers/zink/zink_bo.c +index 0e98a20..a0d0ceb 100644 --- a/src/gallium/drivers/zink/zink_bo.c +++ b/src/gallium/drivers/zink/zink_bo.c @@ -34,6 +34,7 @@ @@ -66,7 +19,7 @@ without allocations. #ifdef HAVE_LIBDRM #define ZINK_USE_DMABUF -@@ -577,6 +578,7 @@ +@@ -537,6 +538,7 @@ struct pb_buffer_lean * zink_bo_create(struct zink_screen *screen, uint64_t size, unsigned alignment, enum zink_heap heap, enum zink_alloc_flag flags, unsigned mem_type_idx, const void *pNext) { struct zink_bo *bo; @@ -74,7 +27,7 @@ without allocations. /* pull in sparse flag */ flags |= zink_alloc_flags_from_heap(heap); -@@ -1390,6 +1392,40 @@ +@@ -1350,6 +1352,39 @@ bo_slab_alloc_normal(void *priv, unsigned mem_type_idx, unsigned entry_size, uns return bo_slab_alloc(priv, mem_type_idx, entry_size, group_index, false); } @@ -100,8 +53,7 @@ without allocations. + + uint32_t serial = p_atomic_read(&screen->pb.alloc_serial); + if (serial == seen) { -+ for (unsigned i = 0; i < NUM_SLAB_ALLOCATORS; i++) -+ pb_slabs_reclaim_all(&screen->pb.bo_slabs[i]); ++ pb_slabs_reclaim_all(&screen->pb.bo_slabs); + pb_cache_release_all_buffers(&screen->pb.bo_cache); + } + seen = serial; @@ -115,10 +67,10 @@ without allocations. bool zink_bo_init(struct zink_screen *screen) { -@@ -1425,12 +1461,25 @@ - min_slab_order = max_order + 1; +@@ -1371,12 +1406,25 @@ zink_bo_init(struct zink_screen *screen) + (void*)bo_slab_free)) { + return false; } - screen->pb.min_alloc_size = 1 << screen->pb.bo_slabs[0].min_order; + + mtx_init(&screen->pb.reclaim_lock, mtx_plain); + cnd_init(&screen->pb.reclaim_cond); @@ -138,6 +90,61 @@ without allocations. + thrd_join(screen->pb.reclaim_thread, NULL); + screen->pb.reclaim_running = false; + } - for (unsigned i = 0; i < NUM_SLAB_ALLOCATORS; i++) { - if (screen->pb.bo_slabs[i].groups) - pb_slabs_deinit(&screen->pb.bo_slabs[i]); + if (screen->pb.bo_slabs.groups) + pb_slabs_deinit(&screen->pb.bo_slabs); + pb_cache_deinit(&screen->pb.bo_cache); +diff --git a/src/gallium/drivers/zink/zink_types.h b/src/gallium/drivers/zink/zink_types.h +index 9c461cf..f31cc42 100644 +--- a/src/gallium/drivers/zink/zink_types.h ++++ b/src/gallium/drivers/zink/zink_types.h +@@ -1443,6 +1443,12 @@ struct zink_screen { + struct pb_cache bo_cache; + struct pb_slabs bo_slabs; + uint32_t next_bo_unique_id; ++ uint32_t alloc_serial; ++ thrd_t reclaim_thread; ++ mtx_t reclaim_lock; ++ cnd_t reclaim_cond; ++ bool reclaim_stop; ++ bool reclaim_running; + } pb; + uint8_t heap_map[ZINK_HEAP_MAX][VK_MAX_MEMORY_TYPES]; // mapping from zink heaps to memory type indices + uint8_t heap_count[ZINK_HEAP_MAX]; // number of memory types per zink heap +diff --git a/src/util/pb_slab.c b/src/util/pb_slab.c +index 24f4d34..bf27e88 100644 +--- a/src/util/pb_slab.c ++++ b/src/util/pb_slab.c +@@ -231,6 +231,19 @@ pb_slabs_reclaim(struct pb_slabs *slabs) + return num_reclaims; + } + ++/* Like pb_slabs_reclaim, but skips entries that are still in use instead of ++ * stopping at the first ones, so entries freed behind them are reclaimed too. ++ */ ++unsigned ++pb_slabs_reclaim_all(struct pb_slabs *slabs) ++{ ++ unsigned num_reclaims; ++ simple_mtx_lock(&slabs->mutex); ++ num_reclaims = pb_slabs_reclaim_all_locked(slabs); ++ simple_mtx_unlock(&slabs->mutex); ++ return num_reclaims; ++} ++ + /* Initialize the slabs manager. + * + * The minimum and maximum size of slab entries are 2^min_order and +diff --git a/src/util/pb_slab.h b/src/util/pb_slab.h +index 7ef7c5d..663dcc7 100644 +--- a/src/util/pb_slab.h ++++ b/src/util/pb_slab.h +@@ -145,6 +145,9 @@ pb_slab_free(struct pb_slabs* slabs, struct pb_slab_entry *entry); + unsigned + pb_slabs_reclaim(struct pb_slabs *slabs); + ++unsigned ++pb_slabs_reclaim_all(struct pb_slabs *slabs); ++ + bool + pb_slabs_init(struct pb_slabs *slabs, + unsigned min_order, unsigned max_order,