From 9ca6fa064ed48ec6259844d10a483e38e27e17df Mon Sep 17 00:00:00 2001 From: LunaDL <91587464+EnzoDLofi@users.noreply.github.com> Date: Wed, 2 Dec 2026 05:04:53 -0400 Subject: [PATCH] fix(bionic): the WSI layer uses its normal bypass check, and zero-copy fallbacks log their reason (#3487) The Bionic launcher no longer forces the WSI layer's XWayland bypass; the layer runs its normal eligibility check, cached for 100 ms. The compositor logs, rate-limited, why a frame or layer candidate leaves the zero-copy path: no registered gralloc buffer, a failed direct present, or a rejected candidate draw. Tested on a 60 Hz Adreno handheld with the forced bypass on and off and with two driver versions: every run stayed on the zero-copy path at about 60 fps. --- app/src/main/cpp/waylandcomp/src/compositor.c | 222 +++++++++++++++++- .../cpp/waylandcomp/src/display_buffers.c | 120 ++++++++-- tools/bionic-runtime/tool/launch.sh | 3 +- tools/tests/test_vk_linear_dmabuf.py | 8 + 4 files changed, 327 insertions(+), 26 deletions(-) diff --git a/app/src/main/cpp/waylandcomp/src/compositor.c b/app/src/main/cpp/waylandcomp/src/compositor.c index 03f33894cb..685c8d0bc5 100644 --- a/app/src/main/cpp/waylandcomp/src/compositor.c +++ b/app/src/main/cpp/waylandcomp/src/compositor.c @@ -2272,6 +2272,69 @@ static void bind_output(struct wl_client *c, void *data, uint32_t ver, uint32_t struct draw_list { struct vkp_draw *d; int n, cap; }; +#define ZERO_COPY_FALLBACK_SIGNATURES 32u +enum zero_copy_fallback_reason { + ZERO_COPY_NO_SURFACE_BUFFER = 1, + ZERO_COPY_NO_GRALLOC_AHB = 2, + ZERO_COPY_AHB_PRESENT_FAILED = 3 +}; +struct zero_copy_fallback_signature { + uint32_t reason, format, stride, offset; + int width, height; + uint64_t modifier; +}; +static struct zero_copy_fallback_signature g_zero_copy_fallbacks[ZERO_COPY_FALLBACK_SIGNATURES]; +static uint32_t g_zero_copy_fallback_count; +static int g_zero_copy_fallback_limit_logged; + +static int zero_copy_fallback_should_log(const struct dmabuf_buffer *b, uint32_t reason) { + const struct zero_copy_fallback_signature key = { + .reason = reason, .format = b ? b->format : 0, + .stride = b && b->n_planes ? b->stride[0] : 0, + .offset = b && b->n_planes ? b->offset[0] : 0, + .width = b ? b->width : 0, .height = b ? b->height : 0, + .modifier = b ? b->modifier : 0}; + for (uint32_t i = 0; i < g_zero_copy_fallback_count; i++) { + const struct zero_copy_fallback_signature *seen = &g_zero_copy_fallbacks[i]; + if (seen->reason == key.reason && seen->format == key.format && seen->stride == key.stride && + seen->offset == key.offset && seen->width == key.width && seen->height == key.height && + seen->modifier == key.modifier) + return 0; + } + if (g_zero_copy_fallback_count >= ZERO_COPY_FALLBACK_SIGNATURES) { + if (!g_zero_copy_fallback_limit_logged) { + g_zero_copy_fallback_limit_logged = 1; + droiddeck_log("layer", "zero-copy: further fallback diagnostics suppressed after %u distinct buffer signatures", + ZERO_COPY_FALLBACK_SIGNATURES); + } + return 0; + } + g_zero_copy_fallbacks[g_zero_copy_fallback_count++] = key; + return 1; +} + +static void note_zero_copy_fallback(struct surface *s, const struct dmabuf_buffer *b, uint32_t reason, + int scene_w, int scene_h, int present_result) { + if (!zero_copy_fallback_should_log(b, reason)) return; + char name[160] = "unknown surface"; + if (s) describe(s, name, sizeof(name)); + if (reason == ZERO_COPY_NO_SURFACE_BUFFER) { + droiddeck_log("layer", "zero-copy: layer candidate %s has no associated Wayland surface buffer; using the layer-copy path", + name); + } else { + droiddeck_log("layer", "zero-copy: %s buffer %c%c%c%c %dx%d stride %u offset %u modifier 0x%llx %s; " + "scene %dx%d will use the layer-copy path (direct-present result %d)", + name, b->format & 0xff, (b->format >> 8) & 0xff, (b->format >> 16) & 0xff, + (b->format >> 24) & 0xff, b->width, b->height, + b->n_planes ? b->stride[0] : 0, b->n_planes ? b->offset[0] : 0, + (unsigned long long)b->modifier, + reason == ZERO_COPY_NO_GRALLOC_AHB + ? "has no registered gralloc AHardwareBuffer" + : "has a registered gralloc AHardwareBuffer but direct presentation failed", + scene_w, scene_h, present_result); + } +} + static int add_cursor(struct draw_list *dl, int scene_w); static struct vkp_image *surface_image(struct surface *s) { @@ -2391,17 +2454,53 @@ static int black_fill_below(const struct draw_list *dl, int n) { return 1; } +#define LAYER_CANDIDATE_DIAGNOSTICS 32u +static unsigned g_layer_candidate_diag_count; +static int g_layer_candidate_diag_limit; + +static void note_layer_candidate_skip(const struct vkp_draw *d, int index, int reason, + int scene_w, int scene_h) { + static int seen[LAYER_CANDIDATE_DIAGNOSTICS][8]; + const int key[8] = {index, reason, scene_w, scene_h, d->dx, d->dy, d->dw, d->dh}; + for (unsigned i = 0; i < g_layer_candidate_diag_count; i++) + if (!memcmp(seen[i], key, sizeof(key))) return; + if (g_layer_candidate_diag_count >= LAYER_CANDIDATE_DIAGNOSTICS) { + if (!g_layer_candidate_diag_limit++) droiddeck_log("layer", "zero-copy: further candidate-rejection details suppressed after %u signatures", + LAYER_CANDIDATE_DIAGNOSTICS); + return; + } + memcpy(seen[g_layer_candidate_diag_count++], key, sizeof(key)); + const char *why = reason == 1 ? "translucent draw" : + reason == 2 ? "image is not DMA-BUF" : + reason == 3 ? "source rectangle is outside/invalid" : + reason == 4 ? "draw rectangle is outside scene or invalid" : + "not fullscreen and no black backing below"; + droiddeck_log("layer", "zero-copy: candidate draw %d rejected: %s; scene %dx%d, dst %dx%d at %d,%d, src %.2f,%.2f %.2fx%.2f, image %dx%d", + index, why, scene_w, scene_h, d->dw, d->dh, d->dx, d->dy, + d->sx, d->sy, d->sw, d->sh, vkp_image_width(d->img), vkp_image_height(d->img)); +} + static int layer_candidate(const struct draw_list *dl, int scene_w, int scene_h) { for (int i = dl->n - 1; i >= 0 && i >= dl->n - 2; i--) { const struct vkp_draw *d = &dl->d[i]; - if (d->blend) continue; - if (!vkp_image_is_dmabuf(d->img)) continue; + if (d->blend) { note_layer_candidate_skip(d, i, 1, scene_w, scene_h); continue; } + if (!vkp_image_is_dmabuf(d->img)) { note_layer_candidate_skip(d, i, 2, scene_w, scene_h); continue; } if (d->sx < 0 || d->sy < 0 || d->sw < 1.0f || d->sh < 1.0f || d->sx + d->sw >= vkp_image_width(d->img) + 1.0f || - d->sy + d->sh >= vkp_image_height(d->img) + 1.0f) continue; + d->sy + d->sh >= vkp_image_height(d->img) + 1.0f) { + note_layer_candidate_skip(d, i, 3, scene_w, scene_h); + continue; + } if (d->dx == 0 && d->dy == 0 && d->dw == scene_w && d->dh == scene_h) return i; if (d->dx < 0 || d->dy < 0 || d->dw <= 0 || d->dh <= 0 || d->dx + d->dw > scene_w || - d->dy + d->dh > scene_h || !black_fill_below(dl, i)) continue; + d->dy + d->dh > scene_h) { + note_layer_candidate_skip(d, i, 4, scene_w, scene_h); + continue; + } + if (!black_fill_below(dl, i)) { + note_layer_candidate_skip(d, i, 5, scene_w, scene_h); + continue; + } return i; } return -1; @@ -2422,6 +2521,56 @@ static void note_copy_scene(const struct draw_list *dl, int scene_w, int scene_h vkp_image_is_dmabuf(t->img) ? "GPU" : "memory", t->blend ? ", translucent" : ""); } +static struct surface *surface_for_image(const struct vkp_image *img); + +static void note_layer_candidate_rejected(const struct draw_list *dl, int scene_w, int scene_h) { + static int seen[32][14]; + static unsigned seen_count; + static int limit_logged; + static time_t window_start; + struct timespec now_ts; + const struct vkp_draw *a = dl->n > 0 ? &dl->d[dl->n - 1] : NULL; + const struct vkp_draw *b = dl->n > 1 ? &dl->d[dl->n - 2] : NULL; + struct surface *sa = a ? surface_for_image(a->img) : NULL; + struct surface *sb = b ? surface_for_image(b->img) : NULL; + const int signature[14] = { + dl->n, scene_w, scene_h, + a ? a->dw : 0, a ? a->dh : 0, + a ? vkp_image_width(a->img) : 0, a ? vkp_image_height(a->img) : 0, + a ? vkp_image_is_dmabuf(a->img) : 0, a ? a->blend : 0, sa && sa->dmabuf_buf ? 1 : 0, + b ? b->dw : 0, b ? b->dh : 0, b ? vkp_image_is_dmabuf(b->img) : 0, sb && sb->dmabuf_buf ? 1 : 0 + }; + clock_gettime(CLOCK_MONOTONIC, &now_ts); + if (!window_start || now_ts.tv_sec - window_start >= 30) { + seen_count = 0; + limit_logged = 0; + window_start = now_ts.tv_sec; + } + for (unsigned i = 0; i < seen_count; i++) + if (!memcmp(signature, seen[i], sizeof(signature))) return; + if (seen_count >= 32) { + if (!limit_logged++) droiddeck_log("layer", "zero-copy: further fullscreen-candidate rejection details suppressed after 32 signatures in 30 seconds"); + return; + } + memcpy(seen[seen_count++], signature, sizeof(signature)); + char below[48]; + if (b) + snprintf(below, sizeof(below), "%s %dx%d", + vkp_image_is_dmabuf(b->img) ? "DMA-BUF" : "non-DMA-BUF", b->dw, b->dh); + else + snprintf(below, sizeof(below), "none"); + droiddeck_log("layer", "zero-copy: no eligible fullscreen DMA-BUF layer candidate: scene %dx%d, %d draws; " + "top draw %dx%d at %d,%d image %dx%d %s%s surface=%s dmabuf=%s; " + "draw below %s", + scene_w, scene_h, dl->n, a ? a->dw : 0, a ? a->dh : 0, a ? a->dx : 0, a ? a->dy : 0, + a ? vkp_image_width(a->img) : 0, a ? vkp_image_height(a->img) : 0, + a && vkp_image_is_dmabuf(a->img) ? "DMA-BUF" : "non-DMA-BUF", + a && a->blend ? " blended" : "", + sa ? "associated" : "unassociated", + sa && sa->dmabuf_buf ? "yes" : "no", + below); +} + static struct surface *surface_for_image(const struct vkp_image *img) { struct surface *s; wl_list_for_each(s, &g_surfaces, link) @@ -2430,16 +2579,56 @@ static struct surface *surface_for_image(const struct vkp_image *img) { } static struct surface *ahb_layer_only_candidate(int scene_w, int scene_h) { + static struct { + const struct surface *surface; + int reason, scene_w, scene_h, w, h, buf_w, buf_h, x, y, src_set, dst_set, children; + } seen[32]; + static unsigned seen_count; + static int limit_logged; struct surface *s; - int w, h; + int w = 0, h = 0, reason = 0; if (wl_list_empty(&g_toplevels)) return NULL; s = wl_container_of(g_toplevels.prev, s, toplevel_link); - if (!s->dmabuf_buf || s->dmabuf_buf->img || !ahb_swapchain_has_ahb(s->dmabuf_buf)) return NULL; - if ((g_desktop && !s->placed) || s->x != 0 || s->y != 0 || s->src_set || s->dst_set) return NULL; - if (!wl_list_empty(&s->children)) return NULL; - if (g_hide_shell && !strcmp(client_name(wl_resource_get_client(s->resource)), "explorer.exe")) return NULL; + if (!s->dmabuf_buf) reason = 1; + else if (s->dmabuf_buf->img) reason = 2; + else if (!ahb_swapchain_has_ahb(s->dmabuf_buf)) reason = 3; + else if ((g_desktop && !s->placed) || s->x != 0 || s->y != 0 || s->src_set || s->dst_set) reason = 4; + else if (!wl_list_empty(&s->children)) reason = 5; + else if (g_hide_shell && !strcmp(client_name(wl_resource_get_client(s->resource)), "explorer.exe")) reason = 6; surface_size(s, &w, &h); - if (w != scene_w || h != scene_h || s->buf_w != scene_w || s->buf_h != scene_h) return NULL; + if (!reason && (w != scene_w || h != scene_h || s->buf_w != scene_w || s->buf_h != scene_h)) reason = 7; + if (reason) { + int found = 0; + for (unsigned i = 0; i < seen_count; i++) { + if (seen[i].surface == s && seen[i].reason == reason && seen[i].scene_w == scene_w && + seen[i].scene_h == scene_h && seen[i].w == w && seen[i].h == h && + seen[i].buf_w == s->buf_w && seen[i].buf_h == s->buf_h && seen[i].x == s->x && + seen[i].y == s->y && seen[i].src_set == s->src_set && seen[i].dst_set == s->dst_set && + seen[i].children == !wl_list_empty(&s->children)) { found = 1; break; } + } + if (!found && seen_count < 32) { + seen[seen_count].surface = s; seen[seen_count].reason = reason; + seen[seen_count].scene_w = scene_w; seen[seen_count].scene_h = scene_h; + seen[seen_count].w = w; seen[seen_count].h = h; seen[seen_count].buf_w = s->buf_w; seen[seen_count].buf_h = s->buf_h; + seen[seen_count].x = s->x; seen[seen_count].y = s->y; seen[seen_count].src_set = s->src_set; + seen[seen_count].dst_set = s->dst_set; seen[seen_count].children = !wl_list_empty(&s->children); + seen_count++; + const char *why = reason == 1 ? "no DMA-BUF buffer" : + reason == 2 ? "buffer is already importable by Vulkan" : + reason == 3 ? "no registered gralloc AHardwareBuffer" : + reason == 4 ? "surface is positioned/cropped/scaled" : + reason == 5 ? "surface has child surfaces" : + reason == 6 ? "hidden shell surface" : "surface or buffer dimensions differ from scene"; + char name[160]; describe(s, name, sizeof(name)); + droiddeck_log("layer", "zero-copy: AHardwareBuffer-only candidate rejected: %s; %s, scene %dx%d, surface %dx%d at %d,%d, buffer %dx%d, crop=%d destination=%d children=%d", + why, name, scene_w, scene_h, w, h, s->x, s->y, s->buf_w, s->buf_h, + s->src_set, s->dst_set, !wl_list_empty(&s->children)); + } else if (!found && !limit_logged) { + limit_logged = 1; + droiddeck_log("layer", "zero-copy: further AHardwareBuffer-only candidate diagnostics suppressed after 32 signatures"); + } + return NULL; + } return s; } @@ -2882,7 +3071,10 @@ static void render_scene(void) { struct surface *ls = li >= 0 ? surface_for_image(dl.d[li].img) : NULL; const struct vkp_draw *ld = li >= 0 ? &dl.d[li] : NULL; if (li < 0) ls = layer_only; - if (g_zero_copy && li < 0 && !ls && !blocked && !cardboard) note_copy_scene(&dl, w, h, cursor_on); + if (g_zero_copy && li < 0 && !ls && !blocked && !cardboard) { + if (!cursor_on && !bfi) note_layer_candidate_rejected(&dl, w, h); + note_copy_scene(&dl, w, h, cursor_on); + } if (cardboard) ls = NULL; if (cursor_on) ls = NULL; if (bfi) ls = NULL; @@ -2910,6 +3102,14 @@ static void render_scene(void) { r = generated >= 0 ? 0 : -1; else if (generated >= 0 && !(fx_on && li >= 0) && ls && ls->dmabuf_buf && ahb_swapchain_has_ahb(ls->dmabuf_buf)) r = ahb_swapchain_present(ls->dmabuf_buf, ls, w, h, ld); + if (!fg_pass && generated >= 0 && !fx_on && !framegen && r != 0) { + if (!ls || !ls->dmabuf_buf) + note_zero_copy_fallback(ls, NULL, ZERO_COPY_NO_SURFACE_BUFFER, w, h, r); + else if (!ahb_swapchain_has_ahb(ls->dmabuf_buf)) + note_zero_copy_fallback(ls, ls->dmabuf_buf, ZERO_COPY_NO_GRALLOC_AHB, w, h, r); + else + note_zero_copy_fallback(ls, ls->dmabuf_buf, ZERO_COPY_AHB_PRESENT_FAILED, w, h, r); + } if (r == 0 && !fg_pass) g_zero_copy_shown = ls; else settle_unwaited(); if (!fg_pass && generated >= 0 && r != 0 && li >= 0) diff --git a/app/src/main/cpp/waylandcomp/src/display_buffers.c b/app/src/main/cpp/waylandcomp/src/display_buffers.c index 99f6993a56..f6ee1eb0d3 100644 --- a/app/src/main/cpp/waylandcomp/src/display_buffers.c +++ b/app/src/main/cpp/waylandcomp/src/display_buffers.c @@ -62,8 +62,40 @@ struct entry { static struct wl_list g_entries; static struct wl_event_loop *g_loop; static uint64_t g_next_id = 1; -static int g_refused_logged; static int g_ubwc_promised; + +#define DISPLAY_BUFFER_MISMATCH_SIGNATURES 64u +struct display_buffer_mismatch_signature { + uint32_t kind, format, stride, offset; + int width, height; + uint64_t modifier; +}; +static struct display_buffer_mismatch_signature g_mismatch_signatures[DISPLAY_BUFFER_MISMATCH_SIGNATURES]; +static uint32_t g_mismatch_signature_count; +static int g_mismatch_limit_logged; + +static int mismatch_should_log(const struct dmabuf_buffer *b, uint32_t kind) { + const struct display_buffer_mismatch_signature key = { + .kind = kind, .format = b->format, .stride = b->stride[0], .offset = b->offset[0], + .width = b->width, .height = b->height, .modifier = b->modifier}; + for (uint32_t i = 0; i < g_mismatch_signature_count; i++) { + const struct display_buffer_mismatch_signature *seen = &g_mismatch_signatures[i]; + if (seen->kind == key.kind && seen->format == key.format && seen->stride == key.stride && + seen->offset == key.offset && seen->width == key.width && seen->height == key.height && + seen->modifier == key.modifier) + return 0; + } + if (g_mismatch_signature_count >= DISPLAY_BUFFER_MISMATCH_SIGNATURES) { + if (!g_mismatch_limit_logged) { + g_mismatch_limit_logged = 1; + droiddeck_log("layer", "display buffers: further mismatch diagnostics suppressed after %u distinct buffer signatures", + DISPLAY_BUFFER_MISMATCH_SIGNATURES); + } + return 0; + } + g_mismatch_signatures[g_mismatch_signature_count++] = key; + return 1; +} static int g_ubwc_probed[2]; static uint32_t ahb_format_of(uint32_t drm, uint64_t modifier) { @@ -238,16 +270,51 @@ static void handle_alloc(struct peer *p, const struct display_buffers_request *q } else { if (ahb) AHardwareBuffer_release(ahb); fd = -1; - if (sized && wanted && (compressed || !g_refused_logged)) { - g_refused_logged = 1; - droiddeck_log(compressed ? "error" : "layer", "display buffers: no gralloc buffer matches pid %d's %ux%u " - "%c%c%c%c %s layout (stride %u bytes, pixels at %u, %llu bytes; gralloc's layout has pixels at " - "%llu, %llu bytes): %s", (int)p->pid, q->width, q->height, - q->format & 0xff, (q->format >> 8) & 0xff, (q->format >> 16) & 0xff, (q->format >> 24) & 0xff, - compressed ? "UBWC" : "linear", q->stride, q->offset, (unsigned long long)q->size, - (unsigned long long)(compressed ? ubwc_meta_size(q->width, q->height) : 0), - (unsigned long long)(compressed ? ubwc_size(q->width, q->height, q->stride) : q->size), - compressed ? "its compressed frames cannot be shown" : "its frames keep the copy path"); + static struct { + pid_t pid; + uint32_t width, height, format, stride, offset, reason; + uint64_t size, modifier; + } refused[32]; + static unsigned refused_count; + static int refused_limit_logged; + uint32_t reason = !sized ? 1u : !sane ? 2u : !wanted ? 3u : + !ahb_swapchain_advertised() ? 4u : + p->count >= DISPLAY_BUFFERS_MAX_PER_CLIENT ? 5u : 6u; + int seen = 0; + for (unsigned i = 0; i < refused_count; i++) { + if (refused[i].pid == p->pid && refused[i].width == q->width && refused[i].height == q->height && + refused[i].format == q->format && refused[i].stride == q->stride && refused[i].offset == q->offset && + refused[i].size == q->size && refused[i].modifier == q->modifier && refused[i].reason == reason) { + seen = 1; + break; + } + } + if (!seen && refused_count < 32) { + refused[refused_count].pid = p->pid; + refused[refused_count].width = q->width; + refused[refused_count].height = q->height; + refused[refused_count].format = q->format; + refused[refused_count].stride = q->stride; + refused[refused_count].offset = q->offset; + refused[refused_count].size = q->size; + refused[refused_count].modifier = q->modifier; + refused[refused_count].reason = reason; + refused_count++; + const char *why = reason == 1 ? "invalid dimensions, format, or stride" : + reason == 2 ? "size/offset/layout sanity check failed" : + reason == 3 ? "zero-copy or UBWC offering is disabled" : + reason == 4 ? "AHardwareBuffer swapchain is not advertised" : + reason == 5 ? "per-client allocation limit reached" : + "gralloc allocation/fd/size validation failed"; + droiddeck_log(compressed ? "error" : "layer", + "display buffers: allocation refused for pid %d: %s; request %ux%u %c%c%c%c %s stride=%u offset=%u size=%llu modifier=0x%llx (client has %d allocations)", + (int)p->pid, why, q->width, q->height, + q->format & 0xff, (q->format >> 8) & 0xff, (q->format >> 16) & 0xff, (q->format >> 24) & 0xff, + compressed ? "UBWC" : "linear", q->stride, q->offset, + (unsigned long long)q->size, (unsigned long long)q->modifier, p->count); + } else if (!seen && !refused_limit_logged) { + refused_limit_logged = 1; + droiddeck_log("layer", "display buffers: further allocation-refusal diagnostics suppressed after 32 signatures"); } } if (reply(p, &r, fd) != 0 && e) entry_free(e); @@ -299,9 +366,18 @@ static int on_listen(int fd, uint32_t mask, void *data) { } void display_buffers_match(struct wl_client *c, struct wl_resource *buffer, struct dmabuf_buffer *b) { + static int invalid_logged; struct stat st; struct entry *e; - if (!g_loop || wl_list_empty(&g_entries) || b->n_planes != 1 || b->offset[0] != 0 || fstat(b->fd[0], &st) != 0) return; + if (!g_loop || wl_list_empty(&g_entries)) return; + if (b->n_planes != 1 || b->offset[0] != 0 || fstat(b->fd[0], &st) != 0) { + if (!invalid_logged) { + invalid_logged = 1; + droiddeck_log("layer", "display buffers: cannot associate %s's DMA-BUF with gralloc (plane count %u; expected one plane at offset 0, or fstat failed)", + droiddeck_client_name(c), b->n_planes); + } + return; + } wl_list_for_each(e, &g_entries, link) { if (e->dev != st.st_dev || e->ino != st.st_ino) continue; AHardwareBuffer_Desc d; @@ -311,11 +387,27 @@ void display_buffers_match(struct wl_client *c, struct wl_resource *buffer, stru (uint32_t)b->height == e->height : (b->modifier == MOD_LINEAR || b->modifier == MOD_INVALID) && e->stride == b->stride[0]; - if (laid_out && e->format == ahb_format_of(b->format, e->modifier) && b->width > 0 && b->height > 0 && - (uint32_t)b->width <= d.width && (uint32_t)b->height <= d.height) + const uint32_t expected_format = ahb_format_of(b->format, e->modifier); + const int dimensions = b->width > 0 && b->height > 0 && + (uint32_t)b->width <= d.width && (uint32_t)b->height <= d.height; + if (laid_out && e->format == expected_format && dimensions) { ahb_swapchain_adopt(c, buffer, b, e->ahb, e->modifier); + } else if (mismatch_should_log(b, 2)) { + droiddeck_log("layer", "display buffers: gralloc DMA-BUF identity matched but layout was rejected for %s: %c%c%c%c %dx%d stride %u offset %u modifier 0x%llx; gralloc %ux%u stride %u format 0x%x, expected format 0x%x (layout %s, dimensions %s)", + droiddeck_client_name(c), b->format & 0xff, (b->format >> 8) & 0xff, + (b->format >> 16) & 0xff, (b->format >> 24) & 0xff, b->width, b->height, + b->stride[0], b->offset[0], (unsigned long long)b->modifier, + e->width, e->height, e->stride, e->format, expected_format, + laid_out ? "ok" : "mismatch", dimensions ? "ok" : "mismatch"); + } return; } + if (mismatch_should_log(b, 1)) { + droiddeck_log("layer", "display buffers: no registered gralloc allocation matches %s's DMA-BUF identity: %c%c%c%c %dx%d stride %u offset %u modifier 0x%llx; imported normally, copy path only", + droiddeck_client_name(c), b->format & 0xff, (b->format >> 8) & 0xff, + (b->format >> 16) & 0xff, (b->format >> 24) & 0xff, b->width, b->height, + b->stride[0], b->offset[0], (unsigned long long)b->modifier); + } } void display_buffers_init(struct wl_display *display) { diff --git a/tools/bionic-runtime/tool/launch.sh b/tools/bionic-runtime/tool/launch.sh index 8e52a857da..bb72dd09a8 100644 --- a/tools/bionic-runtime/tool/launch.sh +++ b/tools/bionic-runtime/tool/launch.sh @@ -86,7 +86,8 @@ RTD=$APP/.wayland-rt export VK_ICD_FILENAMES=$PACK/adapter/icd.json ADRENOTOOLS_DRIVER_PATH=$DRVDIR/ ADRENOTOOLS_HOOKS_PATH=$PACK/lib export ADRENOTOOLS_DRIVER_NAME=$(drvlib "$DRVDIR") export VK_ADD_IMPLICIT_LAYER_PATH=$PACK/layer ENABLE_GAMESCOPE_WSI=1 GAMESCOPE_WAYLAND_DISPLAY=${GAMESCOPE_WAYLAND_DISPLAY:-gamescope-0} -export XDG_RUNTIME_DIR=$RTD DROIDDECK_WSI_BYPASS_CHECK_MS=100 GAMESCOPE_WSI_FORCE_BYPASS=1 +export XDG_RUNTIME_DIR=$RTD DROIDDECK_WSI_BYPASS_CHECK_MS=100 GAMESCOPE_WSI_FORCE_BYPASS=0 +echo "WSI forced XWayland bypass disabled (GAMESCOPE_WSI_FORCE_BYPASS=$GAMESCOPE_WSI_FORCE_BYPASS)" [ -e "$RTD/droiddeck-gamescope-limiter" ] && export GAMESCOPE_LIMITER_FILE=$RTD/droiddeck-gamescope-limiter # Wine: DXVK/VKD3D over the builtins, X11 inside gamescope (winewayland would pick DroidDeck's compositor), diff --git a/tools/tests/test_vk_linear_dmabuf.py b/tools/tests/test_vk_linear_dmabuf.py index 4cbe70ddc4..61711f930a 100644 --- a/tools/tests/test_vk_linear_dmabuf.py +++ b/tools/tests/test_vk_linear_dmabuf.py @@ -15,6 +15,8 @@ SRC = TESTS.parents[1] / "app/src/main/cpp/waylandcomp/src" LAYER_HARNESS = r''' #include #include +#include +#include #include #include "vk_external_image_sync.h" #include "vk_linear_dmabuf.h" @@ -42,6 +44,11 @@ static const uint32_t g_qfam = 2; %(width)s %(height)s static int black_fill_below(const struct draw_list *dl, int n) { (void)dl; (void)n; return 0; } +#define LAYER_CANDIDATE_DIAGNOSTICS 32u +static unsigned g_layer_candidate_diag_count; +static int g_layer_candidate_diag_limit; +static void droiddeck_log(const char *tag, const char *fmt, ...) { (void)tag; (void)fmt; } +%(candidate_skip)s %(candidate)s static int candidate(struct vkp_image *img) { @@ -135,6 +142,7 @@ class VkLinearDmabufTest(unittest.TestCase): "is_dmabuf": function(vk, "vkp_image_is_dmabuf"), "width": function(vk, "vkp_image_width"), "height": function(vk, "vkp_image_height"), + "candidate_skip": function(comp, "note_layer_candidate_skip"), "candidate": function(comp, "layer_candidate"), } with tempfile.TemporaryDirectory(prefix="droiddeck-vk-linear-layer-") as tmp: