Introduce drm_free_fb
This function takes care of calling drmModeRmFB. In the future it'll also take care of releasing the client buffer when using direct scan-out.
This commit is contained in:
parent
0ee8d451e4
commit
2062141c49
2 changed files with 19 additions and 2 deletions
20
src/drm.cpp
20
src/drm.cpp
|
@ -190,6 +190,8 @@ static int get_plane_id(struct drm_t *drm)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static void drm_free_fb( struct drm_t *drm, struct fb *fb );
|
||||
|
||||
static void page_flip_handler(int fd, unsigned int frame,
|
||||
unsigned int sec, unsigned int usec, void *data)
|
||||
{
|
||||
|
@ -224,7 +226,7 @@ static void page_flip_handler(int fd, unsigned int frame,
|
|||
{
|
||||
printf("deferred free %u\n", previous_fbid);
|
||||
}
|
||||
drmModeRmFB( g_DRM.fd, previous_fbid );
|
||||
drm_free_fb( &g_DRM, &g_DRM.map_fbid_inflightflips[ previous_fbid ] );
|
||||
|
||||
g_DRM.fbid_free_queue.erase( g_DRM.fbid_free_queue.begin() + i );
|
||||
break;
|
||||
|
@ -649,12 +651,26 @@ uint32_t drm_fbid_from_dmabuf( struct drm_t *drm, struct wlr_dmabuf_attributes *
|
|||
}
|
||||
assert( drm->map_fbid_inflightflips[ fb_id ].held == false );
|
||||
|
||||
drm->map_fbid_inflightflips[ fb_id ].id = fb_id;
|
||||
drm->map_fbid_inflightflips[ fb_id ].held = true;
|
||||
drm->map_fbid_inflightflips[ fb_id ].n_refs = 0;
|
||||
|
||||
return fb_id;
|
||||
}
|
||||
|
||||
static void drm_free_fb( struct drm_t *drm, struct fb *fb )
|
||||
{
|
||||
assert( !fb->held );
|
||||
assert( fb->n_refs == 0 );
|
||||
|
||||
if ( drmModeRmFB( drm->fd, fb->id ) != 0 )
|
||||
{
|
||||
perror( "drmModeRmFB failed" );
|
||||
}
|
||||
|
||||
fb = {};
|
||||
}
|
||||
|
||||
void drm_drop_fbid( struct drm_t *drm, uint32_t fbid )
|
||||
{
|
||||
assert( drm->map_fbid_inflightflips[ fbid ].held == true );
|
||||
|
@ -667,7 +683,7 @@ void drm_drop_fbid( struct drm_t *drm, uint32_t fbid )
|
|||
{
|
||||
printf("free fbid %u\n", fbid);
|
||||
}
|
||||
drmModeRmFB( drm->fd, fbid );
|
||||
drm_free_fb( drm, &drm->map_fbid_inflightflips[ fbid ] );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -38,6 +38,7 @@ struct connector {
|
|||
};
|
||||
|
||||
struct fb {
|
||||
uint32_t id;
|
||||
/* A FB is held if it's being used by steamcompmgr */
|
||||
bool held;
|
||||
/* Number of page-flips using the FB */
|
||||
|
|
Loading…
Reference in a new issue