mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-04-30 21:21:39 +02:00
frontends/va: Track surfaces in context
This will be needed to correctly cleanup fences. Reviewed-by: Sil Vilerino <sivileri@microsoft.com> Reviewed-by: Leo Liu <leo.liu@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25296>
This commit is contained in:
parent
8f513813b1
commit
d6b2a624a1
4 changed files with 37 additions and 5 deletions
|
|
@ -31,6 +31,7 @@
|
|||
#include "util/u_memory.h"
|
||||
#include "util/u_handle_table.h"
|
||||
#include "util/u_video.h"
|
||||
#include "util/set.h"
|
||||
#include "vl/vl_deint_filter.h"
|
||||
#include "vl/vl_winsys.h"
|
||||
|
||||
|
|
@ -366,6 +367,8 @@ vlVaCreateContext(VADriverContextP ctx, VAConfigID config_id, int picture_width,
|
|||
}
|
||||
}
|
||||
|
||||
context->surfaces = _mesa_set_create(NULL, _mesa_hash_pointer, _mesa_key_pointer_equal);
|
||||
|
||||
mtx_lock(&drv->mutex);
|
||||
*context_id = handle_table_add(drv->htab, context);
|
||||
mtx_unlock(&drv->mutex);
|
||||
|
|
@ -393,6 +396,13 @@ vlVaDestroyContext(VADriverContextP ctx, VAContextID context_id)
|
|||
return VA_STATUS_ERROR_INVALID_CONTEXT;
|
||||
}
|
||||
|
||||
set_foreach(context->surfaces, entry) {
|
||||
vlVaSurface *surf = (vlVaSurface *)entry->key;
|
||||
assert(surf->ctx == context);
|
||||
surf->ctx = NULL;
|
||||
}
|
||||
_mesa_set_destroy(context->surfaces, NULL);
|
||||
|
||||
if (context->decoder) {
|
||||
if (context->desc.base.entry_point == PIPE_VIDEO_ENTRYPOINT_ENCODE) {
|
||||
if (u_reduce_video_profile(context->decoder->profile) ==
|
||||
|
|
|
|||
|
|
@ -31,12 +31,28 @@
|
|||
#include "util/u_handle_table.h"
|
||||
#include "util/u_video.h"
|
||||
#include "util/u_memory.h"
|
||||
#include "util/set.h"
|
||||
|
||||
#include "util/vl_vlc.h"
|
||||
#include "vl/vl_winsys.h"
|
||||
|
||||
#include "va_private.h"
|
||||
|
||||
static void
|
||||
vlVaSetSurfaceContext(vlVaSurface *surf, vlVaContext *context)
|
||||
{
|
||||
if (surf->ctx == context)
|
||||
return;
|
||||
|
||||
if (surf->ctx) {
|
||||
assert(_mesa_set_search(surf->ctx->surfaces, surf));
|
||||
_mesa_set_remove_key(surf->ctx->surfaces, surf);
|
||||
}
|
||||
|
||||
surf->ctx = context;
|
||||
_mesa_set_add(surf->ctx->surfaces, surf);
|
||||
}
|
||||
|
||||
VAStatus
|
||||
vlVaBeginPicture(VADriverContextP ctx, VAContextID context_id, VASurfaceID render_target)
|
||||
{
|
||||
|
|
@ -69,7 +85,7 @@ vlVaBeginPicture(VADriverContextP ctx, VAContextID context_id, VASurfaceID rende
|
|||
return VA_STATUS_ERROR_INVALID_SURFACE;
|
||||
|
||||
context->target_id = render_target;
|
||||
surf->ctx = context_id;
|
||||
vlVaSetSurfaceContext(surf, context);
|
||||
context->target = surf->buffer;
|
||||
context->mjpeg.sampling_factor = 0;
|
||||
|
||||
|
|
@ -977,7 +993,7 @@ vlVaEndPicture(VADriverContextP ctx, VAContextID context_id)
|
|||
}
|
||||
|
||||
if (apply_av1_fg) {
|
||||
surf->ctx = context_id;
|
||||
vlVaSetSurfaceContext(surf, context);
|
||||
*out_target = surf->buffer;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@
|
|||
#include "util/u_sampler.h"
|
||||
#include "util/u_surface.h"
|
||||
#include "util/u_video.h"
|
||||
#include "util/set.h"
|
||||
|
||||
#include "vl/vl_compositor.h"
|
||||
#include "vl/vl_video_buffer.h"
|
||||
|
|
@ -85,6 +86,10 @@ vlVaDestroySurfaces(VADriverContextP ctx, VASurfaceID *surface_list, int num_sur
|
|||
surf->buffer->destroy(surf->buffer);
|
||||
if (surf->deint_buffer)
|
||||
surf->deint_buffer->destroy(surf->deint_buffer);
|
||||
if (surf->ctx) {
|
||||
assert(_mesa_set_search(surf->ctx->surfaces, surf));
|
||||
_mesa_set_remove_key(surf->ctx->surfaces, surf);
|
||||
}
|
||||
util_dynarray_fini(&surf->subpics);
|
||||
FREE(surf);
|
||||
handle_table_remove(drv->htab, surface_list[i]);
|
||||
|
|
@ -128,7 +133,7 @@ vlVaSyncSurface(VADriverContextP ctx, VASurfaceID render_target)
|
|||
return VA_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
context = handle_table_get(drv->htab, surf->ctx);
|
||||
context = surf->ctx;
|
||||
if (!context) {
|
||||
mtx_unlock(&drv->mutex);
|
||||
return VA_STATUS_ERROR_INVALID_CONTEXT;
|
||||
|
|
@ -227,7 +232,7 @@ vlVaQuerySurfaceStatus(VADriverContextP ctx, VASurfaceID render_target, VASurfac
|
|||
return VA_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
context = handle_table_get(drv->htab, surf->ctx);
|
||||
context = surf->ctx;
|
||||
if (!context) {
|
||||
mtx_unlock(&drv->mutex);
|
||||
return VA_STATUS_ERROR_INVALID_CONTEXT;
|
||||
|
|
|
|||
|
|
@ -372,6 +372,7 @@ typedef struct {
|
|||
bool needs_begin_frame;
|
||||
void *blit_cs;
|
||||
int packed_header_type;
|
||||
struct set *surfaces;
|
||||
} vlVaContext;
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -384,7 +385,7 @@ typedef struct {
|
|||
typedef struct {
|
||||
struct pipe_video_buffer templat, *buffer, *deint_buffer;
|
||||
struct util_dynarray subpics; /* vlVaSubpicture */
|
||||
VAContextID ctx;
|
||||
vlVaContext *ctx;
|
||||
vlVaBuffer *coded_buf;
|
||||
void *feedback;
|
||||
unsigned int frame_num_cnt;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue