egl: add virgl_renderer_get_fd_for_texture2()

virgl_renderer_resource_get_info() doesn't return the underlying image
stride. eglExportDMABUFImageMESA() does. This fixes imports failing
due to a stride mismatch under certain resolutions. (note that qemu
uses its own export methods, perhaps because Gerd noticed the problem
with virgl egl export functions)

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
macos/master
Marc-André Lureau 7 years ago committed by Dave Airlie
parent 3bb6a9a909
commit 6cf9b5ece6
  1. 1
      src/virgl_egl.h
  2. 23
      src/virgl_egl_context.c
  3. 9
      src/virglrenderer.c
  4. 1
      src/virglrenderer.h

@ -37,5 +37,6 @@ virgl_renderer_gl_context virgl_egl_get_current_context(struct virgl_egl *ve);
int virgl_egl_get_fourcc_for_texture(struct virgl_egl *ve, uint32_t tex_id, uint32_t format, int *fourcc);
int virgl_egl_get_fd_for_texture(struct virgl_egl *ve, uint32_t tex_id, int *fd);
int virgl_egl_get_fd_for_texture2(struct virgl_egl *ve, uint32_t tex_id, int *fd, int *stride, int *offset);
uint32_t virgl_egl_get_gbm_format(uint32_t format);
#endif

@ -315,6 +315,29 @@ int virgl_egl_get_fourcc_for_texture(struct virgl_egl *ve, uint32_t tex_id, uint
return ret;
}
int virgl_egl_get_fd_for_texture2(struct virgl_egl *ve, uint32_t tex_id, int *fd,
int *stride, int *offset)
{
int ret = EINVAL;
EGLImageKHR image = eglCreateImageKHR(ve->egl_display, eglGetCurrentContext(),
EGL_GL_TEXTURE_2D_KHR,
(EGLClientBuffer)(unsigned long)tex_id, NULL);
if (!image)
return EINVAL;
if (!ve->have_mesa_dma_buf_img_export)
goto out_destroy;
if (!eglExportDMABUFImageMESA(ve->egl_display, image, fd,
stride, offset))
goto out_destroy;
ret = 0;
out_destroy:
eglDestroyImageKHR(ve->egl_display, image);
return ret;
}
int virgl_egl_get_fd_for_texture(struct virgl_egl *ve, uint32_t tex_id, int *fd)
{
EGLImageKHR image;

@ -337,6 +337,15 @@ int virgl_renderer_get_fd_for_texture(uint32_t tex_id, int *fd)
#endif
}
int virgl_renderer_get_fd_for_texture2(uint32_t tex_id, int *fd, int *stride, int *offset)
{
#ifdef HAVE_EPOXY_EGL_H
return virgl_egl_get_fd_for_texture2(egl_info, tex_id, fd, stride, offset);
#else
return -1;
#endif
}
void virgl_renderer_reset(void)
{
vrend_renderer_reset();

@ -73,6 +73,7 @@ VIRGL_EXPORT void virgl_renderer_get_rect(int resource_id, struct iovec *iov, un
uint32_t offset, int x, int y, int width, int height);
VIRGL_EXPORT int virgl_renderer_get_fd_for_texture(uint32_t tex_id, int *fd);
VIRGL_EXPORT int virgl_renderer_get_fd_for_texture2(uint32_t tex_id, int *fd, int *stride, int *offset);
/* virgl bind flags - these are compatible with mesa 10.5 gallium.
but are fixed, no other should be passed to virgl either. */

Loading…
Cancel
Save