context_drm_egl: remove custom fencing

537006965e introduced this while
implementing n-buffering. The changes are all good, but the suspect part
is the implementation of wait_fence/new_fence to specifically bypass
what is done generically in context.c for all other opengl backends. The
commit message says that the reason for this is because "the places we
create and wait for the fences needs to be somewhat different for best
performance". It's certainly plausible that it may have been true then,
but I see no evidence it's true now. Driver code is way different these
days under the hood, and the general vo drm code has been rewritten a
lot since then. The generic fencing in context.c works fine and shows no
difference compared to this custom implementation. Delete it and
simplify.
This commit is contained in:
Dudemanguy committed 2025-02-25 21:53:05 +00:00
1 parent 8ed2c98655
commit 6e60667ece
1 file changed
+3 -36
+3 -36
View File
@@ -70,9 +70,6 @@ struct priv {
struct egl egl;
struct gbm gbm;
GLsync *vsync_fences;
unsigned int num_vsync_fences;
uint32_t gbm_format;
uint64_t *gbm_modifiers;
unsigned int num_gbm_modifiers;
@@ -366,32 +363,9 @@ static void swapchain_step(struct ra_ctx *ctx)
dequeue_bo(ctx);
}
static void new_fence(struct ra_ctx *ctx)
static void drm_egl_swap_buffers(struct ra_ctx *ctx)
{
struct priv *p = ctx->priv;
if (p->gl.FenceSync) {
GLsync fence = p->gl.FenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
if (fence)
MP_TARRAY_APPEND(p, p->vsync_fences, p->num_vsync_fences, fence);
}
}
static void wait_fence(struct ra_ctx *ctx)
{
struct priv *p = ctx->priv;
while (p->num_vsync_fences && (p->num_vsync_fences >= p->gbm.num_bos)) {
p->gl.ClientWaitSync(p->vsync_fences[0], GL_SYNC_FLUSH_COMMANDS_BIT, 1e9);
p->gl.DeleteSync(p->vsync_fences[0]);
MP_TARRAY_REMOVE_AT(p->vsync_fences, p->num_vsync_fences, 0);
}
}
static void drm_egl_swap_buffers(struct ra_swapchain *sw)
{
struct ra_ctx *ctx = sw->ctx;
struct priv *p = ctx->priv;
struct vo_drm_state *drm = ctx->vo->drm;
if (!drm->atomic_context->request) {
@@ -402,8 +376,6 @@ static void drm_egl_swap_buffers(struct ra_swapchain *sw)
if (!drm->active)
return;
wait_fence(ctx);
eglSwapBuffers(p->egl.display, p->egl.surface);
struct gbm_bo *new_bo = gbm_surface_lock_front_buffer(p->gbm.surface);
@@ -412,7 +384,6 @@ static void drm_egl_swap_buffers(struct ra_swapchain *sw)
return;
}
enqueue_bo(ctx, new_bo);
new_fence(ctx);
while (drm->redraw || p->gbm.num_bos > ctx->vo->opts->swapchain_depth ||
!gbm_surface_has_free_buffers(p->gbm.surface)) {
@@ -432,10 +403,6 @@ static void drm_egl_swap_buffers(struct ra_swapchain *sw)
drm->redraw = false;
}
static const struct ra_swapchain_fns drm_egl_swapchain = {
.swap_buffers = drm_egl_swap_buffers,
};
static void drm_egl_uninit(struct ra_ctx *ctx)
{
struct priv *p = ctx->priv;
@@ -662,8 +629,8 @@ static bool drm_egl_init(struct ra_ctx *ctx)
}
struct ra_ctx_params params = {
.external_swapchain = &drm_egl_swapchain,
.get_vsync = &drm_egl_get_vsync,
.get_vsync = drm_egl_get_vsync,
.swap_buffers = drm_egl_swap_buffers,
};
if (!ra_gl_ctx_init(ctx, &p->gl, params))
goto err;