From 2517a1206ba77ddcf025b0ced8985112194ad8e5 Mon Sep 17 00:00:00 2001 From: Markus Fritsche Date: Mon, 4 May 2026 14:00:13 +0000 Subject: [PATCH] DEBUG: instrument surface CreateSurfaces2 + ExportSurfaceHandle for diagnosis MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Logs format_width/height + bytesperline + sizes from v4l2_get_format in CreateSurfaces2, and the full VADRMPRIMESurfaceDescriptor in ExportSurfaceHandle (fd, fourcc, width/height, num_objects/layers, obj.size + drm_format/modifier, plane offsets/pitches). Diagnostic for the surface-export bug surfaced by Phase 7 (mpv --hwdec=vaapi --vo=gpu shows solid blue, Firefox falls back to SW after frame 0 — both consumers GL-import the DMA-BUF, both fail to render correctly while vaapi-copy works). Phase 5 review (sonnet) suggested format_height might be 1080 (stream) vs 1088 (MB-aligned), miscomputing UV offset by 15360 bytes. Earlier ftrace shows kernel returns height=1088 — the hypothesis is likely false but verifying in-driver to confirm. Will compare with mpv --msg-level=vd=v --msg-level=vo=v output to identify the import-side discrepancy. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/surface.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/surface.c b/src/surface.c index 2a55b08..f2df393 100644 --- a/src/surface.c +++ b/src/surface.c @@ -146,6 +146,23 @@ VAStatus RequestCreateSurfaces2(VADriverContextP context, unsigned int format, destination_planes_count = video_format->planes_count; + /* + * DEBUG INSTRUMENTATION (surface-export diagnosis 2026-05-04): + * dump what v4l2_get_format returned. Sonnet's Phase 5 review + * hypothesis #4 was that format_height might be 1080 (stream- + * signaled) vs 1088 (MB-aligned), causing UV offset to land + * 15360 bytes early. Earlier ftrace shows hantro returns + * height=1088 — but verify in-driver to be sure. + */ + request_log("CreateSurfaces2: surf_width=%u surf_height=%u " + "fmt_width=%u fmt_height=%u bytesperline[0]=%u " + "sizes[0]=%u sizes[1]=%u planes_count=%u " + "v4l2_buffers_count=%u\n", + width, height, format_width, format_height, + destination_bytesperlines[0], + destination_sizes[0], destination_sizes[1], + destination_planes_count, video_format->v4l2_buffers_count); + rc = v4l2_create_buffers(driver_data->video_fd, capture_type, surfaces_count, &index_base); if (rc < 0) @@ -619,6 +636,33 @@ VAStatus RequestExportSurfaceHandle(VADriverContextP context, surface_object->destination_bytesperlines[i]; } + /* + * DEBUG INSTRUMENTATION (surface-export diagnosis 2026-05-04): + * dump the full descriptor so we can compare against what mpv + * reports importing via --msg-level=vd=v --msg-level=vo=v. + * Phase 5 review identified DMA-BUF surface export as the + * likely root cause of the solid-blue render in mpv vaapi mode. + */ + request_log("ExportSurfaceHandle: surf=%u fd[0]=%d fourcc=0x%x " + "w=%u h=%u num_objects=%u num_layers=%u " + "obj[0].size=%u drm_fmt=0x%x drm_mod=0x%llx num_planes=%u " + "p[0].off=%u pitch=%u p[1].off=%u pitch=%u\n", + surface_id, + export_fds_count > 0 ? export_fds[0] : -1, + surface_descriptor->fourcc, + surface_descriptor->width, + surface_descriptor->height, + surface_descriptor->num_objects, + surface_descriptor->num_layers, + surface_descriptor->objects[0].size, + surface_descriptor->layers[0].drm_format, + (unsigned long long)surface_descriptor->objects[0].drm_format_modifier, + surface_descriptor->layers[0].num_planes, + surface_descriptor->layers[0].offset[0], + surface_descriptor->layers[0].pitch[0], + planes_count > 1 ? surface_descriptor->layers[0].offset[1] : 0, + planes_count > 1 ? surface_descriptor->layers[0].pitch[1] : 0); + status = VA_STATUS_SUCCESS; goto complete;