vaallocator: Allow non-linear modifiers for dummy mem_maps

A client may map dmabufs without the intention to either read or write
to the memory. One example is clients wanting to use the
`gst_video_frame_map()` helper function.

Thus, in order to make buffers from `GstVaDmabufAllocator` conveniently
usable, ignore the modifier check if the client specified neither
`GST_MAP_READ` nor `GST_MAP_WRITE`.

Also skip the `va_sync_surface()` call in that case, as it's likely only
needed for CPU reads/writes.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5965>
This commit is contained in:
Robert Mader 2024-01-23 15:34:15 +01:00 committed by GStreamer Marge Bot
parent c84285d44d
commit 9ee58825cc

View file

@ -391,15 +391,17 @@ gst_va_dmabuf_mem_map (GstMemory * gmem, gsize maxsize, GstMapFlags flags)
GstVaDmabufAllocator *self = GST_VA_DMABUF_ALLOCATOR (gmem->allocator);
VASurfaceID surface = gst_va_memory_get_surface (gmem);
if (self->info.drm_modifier != DRM_FORMAT_MOD_LINEAR) {
GST_ERROR_OBJECT (self, "Failed to map the dmabuf because the modifier "
"is: %#" G_GINT64_MODIFIER "x, which is not linear.",
self->info.drm_modifier);
return NULL;
}
if (flags & GST_MAP_READWRITE) {
if (self->info.drm_modifier != DRM_FORMAT_MOD_LINEAR) {
GST_ERROR_OBJECT (self, "Failed to map the dmabuf because the modifier "
"is: %#" G_GINT64_MODIFIER "x, which is not linear.",
self->info.drm_modifier);
return NULL;
}
if (!va_sync_surface (self->display, surface))
return NULL;
if (!va_sync_surface (self->display, surface))
return NULL;
}
return self->parent_map (gmem, maxsize, flags);
}