diff --git a/src/drm.c b/src/drm.c index f24fe91..70ace5b 100644 --- a/src/drm.c +++ b/src/drm.c @@ -456,3 +456,14 @@ int drm_atomic_commit(struct drm_t *drm, uint32_t fb_id, uint32_t flags) return ret; } + +uint32_t drm_fbid_from_dmabuf( struct drm_t *drm, struct wlr_dmabuf_attributes *dma_buf ) +{ + uint32_t ret = 0; + uint32_t handles[4] = { 0 }; + drmPrimeFDToHandle( drm->fd, dma_buf->fd[0], &handles[0] ); + + drmModeAddFB2( drm->fd, dma_buf->width, dma_buf->height, dma_buf->format, handles, dma_buf->stride, dma_buf->offset, &ret, 0 ); + + return ret; +} diff --git a/src/drm.h b/src/drm.h index 04a4f59..92f9f2e 100644 --- a/src/drm.h +++ b/src/drm.h @@ -5,6 +5,8 @@ #include #include +#include + struct plane { drmModePlane *plane; drmModeObjectProperties *props; @@ -49,6 +51,7 @@ extern struct drm_t g_DRM; int init_drm(struct drm_t *drm, const char *device, const char *mode_str, unsigned int vrefresh); int drm_atomic_commit(struct drm_t *drm, uint32_t fb_id, uint32_t flags); +uint32_t drm_fbid_from_dmabuf( struct drm_t *drm, struct wlr_dmabuf_attributes *dma_buf ); #ifndef C_SIDE } diff --git a/src/steamcompmgr.c b/src/steamcompmgr.c index 5f6cfa0..ff2a872 100644 --- a/src/steamcompmgr.c +++ b/src/steamcompmgr.c @@ -61,6 +61,7 @@ #include "main.hpp" #include "wlserver.h" +#include "drm.h" #define WAFFLE_API_VERSION 0x0106 #include @@ -105,6 +106,7 @@ typedef struct _win { struct wlr_surface *wlrsurface; Bool dmabuf_attribs_valid; struct wlr_dmabuf_attributes dmabuf_attribs; + uint32_t fb_id; } win; static win *list; @@ -377,6 +379,8 @@ ensure_win_resources (Display *dpy, win *w) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + + w->fb_id = drm_fbid_from_dmabuf( &g_DRM, &w->dmabuf_attribs ); } }