Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add trace for vaExportSurfaceHandle #724

Merged
merged 1 commit into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions va/va.c
Original file line number Diff line number Diff line change
Expand Up @@ -1558,6 +1558,8 @@ vaExportSurfaceHandle(VADisplay dpy, VASurfaceID surface_id,
vaStatus = ctx->vtable->vaExportSurfaceHandle(ctx, surface_id,
mem_type, flags,
descriptor);
VA_TRACE_LOG(va_TraceExportSurfaceHandle, dpy, surface_id, mem_type, flags, descriptor);

VA_TRACE_RET(dpy, vaStatus);
return vaStatus;
}
Expand Down
50 changes: 50 additions & 0 deletions va/va_trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -6316,3 +6316,53 @@ void va_TraceEventBuffers(
}
return;
}

void va_TraceExportSurfaceHandle(
VADisplay dpy,
VASurfaceID surfaceId,
uint32_t memType,
uint32_t flags,
void *descriptor)
{
int i;

DPY2TRACE_VIRCTX(dpy);

TRACE_FUNCNAME(idx);

va_TraceMsg(trace_ctx, "\tsurfaceId = 0x%08x\n", surfaceId);
va_TraceMsg(trace_ctx, "\tmemType = 0x%08x\n", memType);
va_TraceMsg(trace_ctx, "\tflags = 0x%08x\n", flags);

if (memType != VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2) {
return;
}

VADRMPRIMESurfaceDescriptor *desc = (VADRMPRIMESurfaceDescriptor *)descriptor;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As noted at

libva/va/va.h

Lines 4054 to 4055 in 984dfee

* with the handle details. The type of this structure depends on
* the value of mem_type.

You can't assume it's VADRMPRIMESurfaceDescriptor without checking memType.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in last version, see line 6337 above.


if (!desc) {
return;
}

va_TraceMsg(trace_ctx, "\tfourcc = %u\n", desc->fourcc);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will crash if descriptor is NULL. Parent function (vaExportSurfaceHandle) does not check that (and it should not). Add check here, please.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in last version, see line 6343 above.

va_TraceMsg(trace_ctx, "\twidth = %u\n", desc->width);
va_TraceMsg(trace_ctx, "\theight = %u\n", desc->height);

va_TraceMsg(trace_ctx, "\tnum_objects = %u\n", desc->num_objects);
for (i = 0; i < desc->num_objects; i++) {
va_TraceMsg(trace_ctx, "\tobject %d, fd = %d\n", i, desc->objects[i].fd);
va_TraceMsg(trace_ctx, "\tobject %d, size = %u\n", i, desc->objects[i].size);
va_TraceMsg(trace_ctx, "\tobject %d, modifier = 0x%llx\n", i, desc->objects[i].drm_format_modifier);
}

va_TraceMsg(trace_ctx, "\tnum_objects = %u\n", desc->num_layers);
for (i = 0; i < desc->num_layers; i++) {
va_TraceMsg(trace_ctx, "\tlayer %d, drm_format = %d\n", i, desc->layers[i].drm_format);
va_TraceMsg(trace_ctx, "\tlayer %d, size = %u\n", i, desc->layers[i].num_planes);
va_TraceMsg(trace_ctx, "\tlayer %d, object idx = [%d, %d, %d, %d]\n", i, desc->layers[i].object_index[0], desc->layers[i].object_index[1], desc->layers[i].object_index[2], desc->layers[i].object_index[3]);
va_TraceMsg(trace_ctx, "\tlayer %d, offset = [%d, %d, %d, %d]\n", i, desc->layers[i].offset[0], desc->layers[i].offset[1], desc->layers[i].offset[2], desc->layers[i].offset[3]);
va_TraceMsg(trace_ctx, "\tlayer %d, pitch = [%d, %d, %d, %d]\n", i, desc->layers[i].pitch[0], desc->layers[i].pitch[1], desc->layers[i].pitch[2], desc->layers[i].pitch[3]);
}

DPY2TRACE_VIRCTX_EXIT(pva_trace);
}
10 changes: 10 additions & 0 deletions va/va_trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,16 @@ void va_TraceEventBuffers(
int num_buffers,
VABufferID *buffers);

/** \brief va_TraceExportSurfaceHandle
* trace exported surface handle. */
DLL_HIDDEN
void va_TraceExportSurfaceHandle(
VADisplay dpy,
VASurfaceID surfaceId,
uint32_t memType,
uint32_t flags,
void *descriptor);

#ifdef __cplusplus
}
#endif
Expand Down