mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-02-15 13:10:31 +01:00
gallium/winsys/drm: Prepare for passing prime fds in winsys_handle
Signed-off-by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com> Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
This commit is contained in:
parent
343133167f
commit
d5a3a2d2fb
9 changed files with 38 additions and 4 deletions
|
|
@ -361,6 +361,11 @@ fd_screen_bo_from_handle(struct pipe_screen *pscreen,
|
|||
struct fd_screen *screen = fd_screen(pscreen);
|
||||
struct fd_bo *bo;
|
||||
|
||||
if (whandle->type != DRM_API_HANDLE_TYPE_SHARED) {
|
||||
DBG("Attempt to import unsupported handle type %d", whandle->type);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bo = fd_bo_from_name(screen->dev, whandle->handle);
|
||||
if (!bo) {
|
||||
DBG("ref name 0x%08x failed", whandle->handle);
|
||||
|
|
|
|||
|
|
@ -86,6 +86,12 @@ nouveau_screen_bo_from_handle(struct pipe_screen *pscreen,
|
|||
struct nouveau_bo *bo = 0;
|
||||
int ret;
|
||||
|
||||
if (whandle->type != DRM_API_HANDLE_TYPE_SHARED) {
|
||||
debug_printf("%s: attempt to import unsupported handle type %d\n",
|
||||
__FUNCTION__, whandle->type);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = nouveau_bo_name_ref(dev, whandle->handle, &bo);
|
||||
if (ret) {
|
||||
debug_printf("%s: ref name 0x%08x failed with %d\n",
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ struct pipe_resource;
|
|||
|
||||
#define DRM_API_HANDLE_TYPE_SHARED 0
|
||||
#define DRM_API_HANDLE_TYPE_KMS 1
|
||||
#define DRM_API_HANDLE_TYPE_FD 2
|
||||
|
||||
|
||||
/**
|
||||
* For use with pipe_screen::{texture_from_handle|texture_get_handle}.
|
||||
|
|
@ -17,9 +19,10 @@ struct pipe_resource;
|
|||
struct winsys_handle
|
||||
{
|
||||
/**
|
||||
* Unused for texture_from_handle, always
|
||||
* DRM_API_HANDLE_TYPE_SHARED. Input to texture_get_handle,
|
||||
* use TEXTURE_USAGE to select handle for kms or ipc.
|
||||
* Input for texture_from_handle, valid values are
|
||||
* DRM_API_HANDLE_TYPE_SHARED or DRM_API_HANDLE_TYPE_FD.
|
||||
* Input to texture_get_handle,
|
||||
* to select handle for kms, flink, or prime.
|
||||
*/
|
||||
unsigned type;
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -265,6 +265,7 @@ dri2_drawable_process_buffers(struct dri_context *ctx,
|
|||
|
||||
templ.format = format;
|
||||
templ.bind = bind;
|
||||
whandle.type = DRM_API_HANDLE_TYPE_SHARED;
|
||||
whandle.handle = buf->name;
|
||||
whandle.stride = buf->pitch;
|
||||
|
||||
|
|
@ -578,6 +579,7 @@ dri2_create_image_from_name(__DRIscreen *_screen,
|
|||
|
||||
memset(&whandle, 0, sizeof(whandle));
|
||||
whandle.handle = name;
|
||||
whandle.type = DRM_API_HANDLE_TYPE_SHARED;
|
||||
whandle.stride = pitch * util_format_get_blocksize(pf);
|
||||
|
||||
img->texture = screen->base.screen->resource_from_handle(screen->base.screen,
|
||||
|
|
|
|||
|
|
@ -427,6 +427,7 @@ drm_display_import_native_buffer(struct native_display *ndpy,
|
|||
|
||||
memset(&wsh, 0, sizeof(wsh));
|
||||
wsh.handle = nbuf->u.drm.name;
|
||||
wsh.type = DRM_API_HANDLE_TYPE_SHARED;
|
||||
wsh.stride = nbuf->u.drm.stride;
|
||||
|
||||
res = screen->resource_from_handle(screen, &nbuf->u.drm.templ, &wsh);
|
||||
|
|
|
|||
|
|
@ -173,6 +173,7 @@ dri2_surface_process_drawable_buffers(struct native_surface *nsurf,
|
|||
}
|
||||
|
||||
memset(&whandle, 0, sizeof(whandle));
|
||||
whandle.type = DRM_API_HANDLE_TYPE_SHARED;
|
||||
whandle.stride = xbuf->pitch;
|
||||
whandle.handle = xbuf->name;
|
||||
dri2surf->textures[natt] = dri2dpy->base.screen->resource_from_handle(
|
||||
|
|
|
|||
|
|
@ -95,9 +95,13 @@ i915_drm_buffer_from_handle(struct i915_winsys *iws,
|
|||
unsigned *stride)
|
||||
{
|
||||
struct i915_drm_winsys *idws = i915_drm_winsys(iws);
|
||||
struct i915_drm_buffer *buf = CALLOC_STRUCT(i915_drm_buffer);
|
||||
struct i915_drm_buffer *buf;
|
||||
uint32_t tile = 0, swizzle = 0;
|
||||
|
||||
if (whandle->type != DRM_API_HANDLE_TYPE_SHARED)
|
||||
return NULL;
|
||||
|
||||
buf = CALLOC_STRUCT(i915_drm_buffer);
|
||||
if (!buf)
|
||||
return NULL;
|
||||
|
||||
|
|
|
|||
|
|
@ -877,6 +877,9 @@ static struct pb_buffer *radeon_winsys_bo_from_handle(struct radeon_winsys *rws,
|
|||
|
||||
memset(&open_arg, 0, sizeof(open_arg));
|
||||
|
||||
if (whandle->type != DRM_API_HANDLE_TYPE_SHARED)
|
||||
return NULL;
|
||||
|
||||
/* We must maintain a list of pairs <handle, bo>, so that we always return
|
||||
* the same BO for one particular handle. If we didn't do that and created
|
||||
* more than one BO for the same handle and then relocated them in a CS,
|
||||
|
|
@ -991,6 +994,9 @@ static boolean radeon_winsys_bo_get_handle(struct pb_buffer *buffer,
|
|||
whandle->handle = bo->flink;
|
||||
} else if (whandle->type == DRM_API_HANDLE_TYPE_KMS) {
|
||||
whandle->handle = bo->handle;
|
||||
} else if (whandle->type == DRM_API_HANDLE_TYPE_FD) {
|
||||
/* TODO: Implement */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
whandle->stride = stride;
|
||||
|
|
|
|||
|
|
@ -163,6 +163,12 @@ vmw_drm_surface_from_handle(struct svga_winsys_screen *sws,
|
|||
int ret;
|
||||
int i;
|
||||
|
||||
if (whandle->type != DRM_API_HANDLE_TYPE_SHARED) {
|
||||
vmw_error("Attempt to import unknown handle type %d\n",
|
||||
whandle->type);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* The vmware device specific handle is the hardware SID.
|
||||
* FIXME: We probably want to move this to the ioctl implementations.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue