mirror of https://github.com/mpv-player/mpv
vdpau: allocate surfaces by age
Whether this helps is probably questionable and depends on the GPU. But the vaapi code does it too.
This commit is contained in:
parent
ef9b399020
commit
33a8e2a9ad
|
@ -179,6 +179,7 @@ static struct mp_image *create_ref(struct mp_vdpau_ctx *ctx, int index)
|
|||
struct surface_entry *e = &ctx->video_surfaces[index];
|
||||
assert(!e->in_use);
|
||||
e->in_use = true;
|
||||
e->age = ctx->age_counter++;
|
||||
struct surface_ref *ref = talloc_ptrtype(NULL, ref);
|
||||
*ref = (struct surface_ref){ctx, index};
|
||||
struct mp_image *res =
|
||||
|
@ -237,11 +238,18 @@ static struct mp_image *mp_vdpau_get_surface(struct mp_vdpau_ctx *ctx,
|
|||
assert(e->chroma == chroma);
|
||||
assert(e->rgb_format == rgb_format);
|
||||
assert(e->rgb == rgb);
|
||||
if (surface_index >= 0) {
|
||||
struct surface_entry *other = &ctx->video_surfaces[surface_index];
|
||||
if (other->age < e->age)
|
||||
continue;
|
||||
}
|
||||
surface_index = n;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
if (surface_index >= 0)
|
||||
goto done;
|
||||
|
||||
// Allocate new surface
|
||||
for (int n = 0; n < MAX_VIDEO_SURFACES; n++) {
|
||||
struct surface_entry *e = &ctx->video_surfaces[n];
|
||||
|
|
|
@ -56,6 +56,7 @@ struct mp_vdpau_ctx {
|
|||
|
||||
// Surface pool
|
||||
pthread_mutex_t pool_lock;
|
||||
int64_t age_counter;
|
||||
struct surface_entry {
|
||||
VdpVideoSurface surface;
|
||||
VdpOutputSurface osurface;
|
||||
|
@ -65,6 +66,7 @@ struct mp_vdpau_ctx {
|
|||
VdpChromaType chroma;
|
||||
bool rgb;
|
||||
bool in_use;
|
||||
int64_t age;
|
||||
} video_surfaces[MAX_VIDEO_SURFACES];
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue