vaallocator: remove runtime mapping selection

The original idea was to select the type of mapping (either using derive images
or downloading the image) in runtime, under the assumption that both methods
shared the same memory layout (offsets and strides), because a single
GstVideoMeta is assigned by the buffer pool at allocation time. Nonetheless, in
recent hardware this assumption is invalid, raising memory access errors.

This patch removes completely the mapping type selection at runtime, using the
method selected when the allocator is configured, synced with the bufferpool
allocation.

This problem was fixed originally for iHD driver only. But now it makes sense to
remove all of it.

Original-patch-by: Mengkejiergeli Ba <mengkejiergeli.ba@intel.com>
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6204>
This commit is contained in:
Víctor Manuel Jáquez Leal 2023-11-30 14:47:06 +01:00
parent e376d06845
commit 6a42ed20ec

View file

@ -1196,7 +1196,7 @@ _clean_mem (GstVaMemory * mem)
mem->image.image_id = VA_INVALID_ID;
mem->image.buf = VA_INVALID_ID;
mem->is_derived = TRUE;
mem->is_derived = FALSE;
mem->is_dirty = FALSE;
mem->prev_mapflags = 0;
mem->mapped_data = NULL;
@ -1337,10 +1337,8 @@ static gpointer
_va_map_unlocked (GstVaMemory * mem, GstMapFlags flags)
{
GstAllocator *allocator = GST_MEMORY_CAST (mem)->allocator;
GstVideoInfo *info;
GstVaAllocator *va_allocator;
GstVaDisplay *display;
gboolean use_derived;
g_return_val_if_fail (mem->surface != VA_INVALID_ID, NULL);
g_return_val_if_fail (GST_IS_VA_ALLOCATOR (allocator), NULL);
@ -1366,32 +1364,12 @@ _va_map_unlocked (GstVaMemory * mem, GstMapFlags flags)
goto success;
}
if (va_allocator->feat_use_derived == GST_VA_FEATURE_ENABLED) {
use_derived = TRUE;
} else if (va_allocator->feat_use_derived == GST_VA_FEATURE_DISABLED) {
use_derived = FALSE;
} else {
switch (gst_va_display_get_implementation (display)) {
case GST_VA_IMPLEMENTATION_INTEL_I965:
/* YUV derived images are tiled, so writing them is also
* problematic */
use_derived = va_allocator->use_derived && !((flags & GST_MAP_READ)
|| ((flags & GST_MAP_WRITE)
&& GST_VIDEO_INFO_IS_YUV (&va_allocator->info)));
break;
default:
use_derived = va_allocator->use_derived;
break;
}
}
mem->is_derived = va_allocator->use_derived;
info = &va_allocator->info;
if (!va_ensure_image (display, mem->surface, info, &mem->image, use_derived))
if (!va_ensure_image (display, mem->surface, &va_allocator->info, &mem->image,
va_allocator->use_derived))
return NULL;
mem->is_derived = use_derived;
if (!mem->is_derived) {
if (!va_get_image (display, mem->surface, &mem->image))
goto fail;