[Mesa-dev] [PATCH 2/3] gallium: add a pipe_context parameter to resource_get_handle
Marek Olšák
maraeo at gmail.com
Mon Aug 22 14:06:20 UTC 2016
From: Marek Olšák <marek.olsak at amd.com>
radeonsi needs to do some operations (DCC decompression) for OpenGL-OpenCL
interop and this is the only way to make it coherent with the current
context. It can optionally be set to NULL.
---
src/gallium/auxiliary/util/u_transfer.c | 1 +
src/gallium/auxiliary/util/u_transfer.h | 1 +
src/gallium/auxiliary/vl/vl_winsys_dri3.c | 2 +-
src/gallium/drivers/ddebug/dd_screen.c | 4 +++-
src/gallium/drivers/ilo/ilo_resource.c | 1 +
src/gallium/drivers/llvmpipe/lp_texture.c | 1 +
src/gallium/drivers/noop/noop_pipe.c | 1 +
src/gallium/drivers/r300/r300_texture.c | 1 +
src/gallium/drivers/r300/r300_texture.h | 1 +
src/gallium/drivers/radeon/r600_texture.c | 1 +
src/gallium/drivers/rbug/rbug_screen.c | 5 ++++-
src/gallium/drivers/softpipe/sp_texture.c | 1 +
src/gallium/drivers/trace/tr_screen.c | 5 ++++-
src/gallium/include/pipe/p_screen.h | 7 +++++++
src/gallium/state_trackers/dri/dri2.c | 13 +++++++------
src/gallium/state_trackers/nine/swapchain9.c | 3 ++-
src/gallium/state_trackers/va/buffer.c | 3 ++-
src/gallium/state_trackers/vdpau/output.c | 3 ++-
src/gallium/state_trackers/vdpau/surface.c | 3 ++-
src/gallium/state_trackers/xa/xa_tracker.c | 3 ++-
src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c | 2 +-
21 files changed, 46 insertions(+), 16 deletions(-)
diff --git a/src/gallium/auxiliary/util/u_transfer.c b/src/gallium/auxiliary/util/u_transfer.c
index 82cf68d..ba4b9dc 100644
--- a/src/gallium/auxiliary/util/u_transfer.c
+++ b/src/gallium/auxiliary/util/u_transfer.c
@@ -104,20 +104,21 @@ void u_default_transfer_unmap( struct pipe_context *pipe,
}
static inline struct u_resource *
u_resource( struct pipe_resource *res )
{
return (struct u_resource *)res;
}
boolean u_resource_get_handle_vtbl(struct pipe_screen *screen,
+ struct pipe_context *ctx,
struct pipe_resource *resource,
struct winsys_handle *handle,
unsigned usage)
{
struct u_resource *ur = u_resource(resource);
return ur->vtbl->resource_get_handle(screen, resource, handle);
}
void u_resource_destroy_vtbl(struct pipe_screen *screen,
struct pipe_resource *resource)
diff --git a/src/gallium/auxiliary/util/u_transfer.h b/src/gallium/auxiliary/util/u_transfer.h
index 7f680bc..ab787ab 100644
--- a/src/gallium/auxiliary/util/u_transfer.h
+++ b/src/gallium/auxiliary/util/u_transfer.h
@@ -66,20 +66,21 @@ struct u_resource_vtbl {
};
struct u_resource {
struct pipe_resource b;
const struct u_resource_vtbl *vtbl;
};
boolean u_resource_get_handle_vtbl(struct pipe_screen *screen,
+ struct pipe_context *ctx,
struct pipe_resource *resource,
struct winsys_handle *handle,
unsigned usage);
void u_resource_destroy_vtbl(struct pipe_screen *screen,
struct pipe_resource *resource);
void *u_transfer_map_vtbl(struct pipe_context *context,
struct pipe_resource *resource,
unsigned level,
diff --git a/src/gallium/auxiliary/vl/vl_winsys_dri3.c b/src/gallium/auxiliary/vl/vl_winsys_dri3.c
index 61d6205..3d596a6 100644
--- a/src/gallium/auxiliary/vl/vl_winsys_dri3.c
+++ b/src/gallium/auxiliary/vl/vl_winsys_dri3.c
@@ -236,21 +236,21 @@ dri3_alloc_back_buffer(struct vl_dri3_screen *scrn)
templ.depth0 = 1;
templ.array_size = 1;
buffer->texture = scrn->base.pscreen->resource_create(scrn->base.pscreen,
&templ);
if (!buffer->texture)
goto unmap_shm;
memset(&whandle, 0, sizeof(whandle));
whandle.type= DRM_API_HANDLE_TYPE_FD;
usage = PIPE_HANDLE_USAGE_EXPLICIT_FLUSH | PIPE_HANDLE_USAGE_READ;
- scrn->base.pscreen->resource_get_handle(scrn->base.pscreen,
+ scrn->base.pscreen->resource_get_handle(scrn->base.pscreen, NULL,
buffer->texture, &whandle,
usage);
buffer_fd = whandle.handle;
buffer->pitch = whandle.stride;
xcb_dri3_pixmap_from_buffer(scrn->conn,
(pixmap = xcb_generate_id(scrn->conn)),
scrn->drawable,
0,
scrn->width, scrn->height, buffer->pitch,
scrn->depth, 32,
diff --git a/src/gallium/drivers/ddebug/dd_screen.c b/src/gallium/drivers/ddebug/dd_screen.c
index 3deba0a..4050e39 100644
--- a/src/gallium/drivers/ddebug/dd_screen.c
+++ b/src/gallium/drivers/ddebug/dd_screen.c
@@ -230,27 +230,29 @@ static void
dd_screen_resource_destroy(struct pipe_screen *_screen,
struct pipe_resource *res)
{
struct pipe_screen *screen = dd_screen(_screen)->screen;
screen->resource_destroy(screen, res);
}
static boolean
dd_screen_resource_get_handle(struct pipe_screen *_screen,
+ struct pipe_context *_pipe,
struct pipe_resource *resource,
struct winsys_handle *handle,
unsigned usage)
{
struct pipe_screen *screen = dd_screen(_screen)->screen;
+ struct pipe_context *pipe = dd_context(_pipe)->pipe;
- return screen->resource_get_handle(screen, resource, handle, usage);
+ return screen->resource_get_handle(screen, pipe, resource, handle, usage);
}
/********************************************************************
* fence
*/
static void
dd_screen_fence_reference(struct pipe_screen *_screen,
struct pipe_fence_handle **pdst,
diff --git a/src/gallium/drivers/ilo/ilo_resource.c b/src/gallium/drivers/ilo/ilo_resource.c
index 0afbfc6..7961288 100644
--- a/src/gallium/drivers/ilo/ilo_resource.c
+++ b/src/gallium/drivers/ilo/ilo_resource.c
@@ -718,20 +718,21 @@ ilo_resource_from_handle(struct pipe_screen *screen,
unsigned usage)
{
if (templ->target == PIPE_BUFFER)
return NULL;
else
return tex_create(screen, templ, handle);
}
static boolean
ilo_resource_get_handle(struct pipe_screen *screen,
+ struct pipe_context *ctx,
struct pipe_resource *res,
struct winsys_handle *handle,
unsigned usage)
{
if (res->target == PIPE_BUFFER)
return false;
else
return tex_get_handle(ilo_texture(res), handle);
}
diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c
index 0d4c4ef..733253b 100644
--- a/src/gallium/drivers/llvmpipe/lp_texture.c
+++ b/src/gallium/drivers/llvmpipe/lp_texture.c
@@ -478,20 +478,21 @@ llvmpipe_resource_from_handle(struct pipe_screen *screen,
no_dt:
FREE(lpr);
no_lpr:
return NULL;
}
static boolean
llvmpipe_resource_get_handle(struct pipe_screen *screen,
+ struct pipe_context *ctx,
struct pipe_resource *pt,
struct winsys_handle *whandle,
unsigned usage)
{
struct sw_winsys *winsys = llvmpipe_screen(screen)->winsys;
struct llvmpipe_resource *lpr = llvmpipe_resource(pt);
assert(lpr->dt);
if (!lpr->dt)
return FALSE;
diff --git a/src/gallium/drivers/noop/noop_pipe.c b/src/gallium/drivers/noop/noop_pipe.c
index cf20681..4eb6051 100644
--- a/src/gallium/drivers/noop/noop_pipe.c
+++ b/src/gallium/drivers/noop/noop_pipe.c
@@ -128,20 +128,21 @@ static struct pipe_resource *noop_resource_from_handle(struct pipe_screen *scree
struct pipe_resource *result;
struct pipe_resource *noop_resource;
result = oscreen->resource_from_handle(oscreen, templ, handle, usage);
noop_resource = noop_resource_create(screen, result);
pipe_resource_reference(&result, NULL);
return noop_resource;
}
static boolean noop_resource_get_handle(struct pipe_screen *screen,
+ struct pipe_context *ctx,
struct pipe_resource *resource,
struct winsys_handle *handle,
unsigned usage)
{
return FALSE;
}
static void noop_resource_destroy(struct pipe_screen *screen,
struct pipe_resource *resource)
{
diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c
index 2fc93c2..5f459e4 100644
--- a/src/gallium/drivers/r300/r300_texture.c
+++ b/src/gallium/drivers/r300/r300_texture.c
@@ -1029,20 +1029,21 @@ static void r300_texture_destroy(struct pipe_screen *screen,
if (texture == rscreen->cmask_resource) {
rscreen->cmask_resource = NULL;
}
pipe_mutex_unlock(rscreen->cmask_mutex);
}
pb_reference(&tex->buf, NULL);
FREE(tex);
}
boolean r300_resource_get_handle(struct pipe_screen* screen,
+ struct pipe_context *ctx,
struct pipe_resource *texture,
struct winsys_handle *whandle,
unsigned usage)
{
struct radeon_winsys *rws = r300_screen(screen)->rws;
struct r300_resource* tex = (struct r300_resource*)texture;
if (!tex) {
return FALSE;
}
diff --git a/src/gallium/drivers/r300/r300_texture.h b/src/gallium/drivers/r300/r300_texture.h
index 4c33942..3341671 100644
--- a/src/gallium/drivers/r300/r300_texture.h
+++ b/src/gallium/drivers/r300/r300_texture.h
@@ -55,20 +55,21 @@ boolean r300_is_sampler_format_supported(enum pipe_format format);
void r300_texture_setup_format_state(struct r300_screen *screen,
struct r300_resource *tex,
enum pipe_format format,
unsigned level,
unsigned width0_override,
unsigned height0_override,
struct r300_texture_format_state *out);
boolean r300_resource_get_handle(struct pipe_screen* screen,
+ struct pipe_context *ctx,
struct pipe_resource *texture,
struct winsys_handle *whandle,
unsigned usage);
struct pipe_resource*
r300_texture_from_handle(struct pipe_screen* screen,
const struct pipe_resource* base,
struct winsys_handle *whandle,
unsigned usage);
diff --git a/src/gallium/drivers/radeon/r600_texture.c b/src/gallium/drivers/radeon/r600_texture.c
index 8c7bfa3..9629fbb 100644
--- a/src/gallium/drivers/radeon/r600_texture.c
+++ b/src/gallium/drivers/radeon/r600_texture.c
@@ -504,20 +504,21 @@ static void r600_degrade_tile_mode_to_linear(struct r600_common_context *rctx,
assert(!rtex->dcc_offset);
assert(!rtex->is_depth);
r600_texture_reference(&new_tex, NULL);
r600_dirty_all_framebuffer_states(rctx->screen);
p_atomic_inc(&rctx->screen->dirty_tex_descriptor_counter);
}
static boolean r600_texture_get_handle(struct pipe_screen* screen,
+ struct pipe_context *ctx,
struct pipe_resource *resource,
struct winsys_handle *whandle,
unsigned usage)
{
struct r600_common_screen *rscreen = (struct r600_common_screen*)screen;
struct r600_common_context *aux_context =
(struct r600_common_context*)rscreen->aux_context;
struct r600_resource *res = (struct r600_resource*)resource;
struct r600_texture *rtex = (struct r600_texture*)resource;
struct radeon_bo_metadata metadata;
diff --git a/src/gallium/drivers/rbug/rbug_screen.c b/src/gallium/drivers/rbug/rbug_screen.c
index 8d21669..3742c10 100644
--- a/src/gallium/drivers/rbug/rbug_screen.c
+++ b/src/gallium/drivers/rbug/rbug_screen.c
@@ -169,30 +169,33 @@ rbug_screen_resource_from_handle(struct pipe_screen *_screen,
result = screen->resource_from_handle(screen, templ, handle, usage);
result = rbug_resource_create(rbug_screen(_screen), result);
return result;
}
static boolean
rbug_screen_resource_get_handle(struct pipe_screen *_screen,
+ struct pipe_context *_pipe,
struct pipe_resource *_resource,
struct winsys_handle *handle,
unsigned usage)
{
struct rbug_screen *rb_screen = rbug_screen(_screen);
+ struct rbug_context *rb_pipe = rbug_context(_pipe);
struct rbug_resource *rb_resource = rbug_resource(_resource);
struct pipe_screen *screen = rb_screen->screen;
struct pipe_resource *resource = rb_resource->resource;
- return screen->resource_get_handle(screen, resource, handle, usage);
+ return screen->resource_get_handle(screen, rb_pipe ? rb_pipe->pipe : NULL,
+ resource, handle, usage);
}
static void
rbug_screen_resource_destroy(struct pipe_screen *screen,
struct pipe_resource *_resource)
{
rbug_resource_destroy(rbug_resource(_resource));
}
diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c
index 9c64397..8dca158 100644
--- a/src/gallium/drivers/softpipe/sp_texture.c
+++ b/src/gallium/drivers/softpipe/sp_texture.c
@@ -244,20 +244,21 @@ softpipe_resource_from_handle(struct pipe_screen *screen,
return &spr->base;
fail:
FREE(spr);
return NULL;
}
static boolean
softpipe_resource_get_handle(struct pipe_screen *screen,
+ struct pipe_context *ctx,
struct pipe_resource *pt,
struct winsys_handle *whandle,
unsigned usage)
{
struct sw_winsys *winsys = softpipe_screen(screen)->winsys;
struct softpipe_resource *spr = softpipe_resource(pt);
assert(spr->dt);
if (!spr->dt)
return FALSE;
diff --git a/src/gallium/drivers/trace/tr_screen.c b/src/gallium/drivers/trace/tr_screen.c
index 67241ca..493725c 100644
--- a/src/gallium/drivers/trace/tr_screen.c
+++ b/src/gallium/drivers/trace/tr_screen.c
@@ -326,32 +326,35 @@ trace_screen_resource_from_handle(struct pipe_screen *_screen,
result = screen->resource_from_handle(screen, templ, handle, usage);
result = trace_resource_create(trace_screen(_screen), result);
return result;
}
static boolean
trace_screen_resource_get_handle(struct pipe_screen *_screen,
+ struct pipe_context *_pipe,
struct pipe_resource *_resource,
struct winsys_handle *handle,
unsigned usage)
{
struct trace_screen *tr_screen = trace_screen(_screen);
+ struct trace_context *tr_pipe = _pipe ? trace_context(_pipe) : NULL;
struct trace_resource *tr_resource = trace_resource(_resource);
struct pipe_screen *screen = tr_screen->screen;
struct pipe_resource *resource = tr_resource->resource;
/* TODO trace call */
- return screen->resource_get_handle(screen, resource, handle, usage);
+ return screen->resource_get_handle(screen, tr_pipe ? tr_pipe->pipe : NULL,
+ resource, handle, usage);
}
static void
trace_screen_resource_destroy(struct pipe_screen *_screen,
struct pipe_resource *_resource)
{
struct trace_screen *tr_scr = trace_screen(_screen);
struct trace_resource *tr_res = trace_resource(_resource);
diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h
index dd40e07..255647e 100644
--- a/src/gallium/include/pipe/p_screen.h
+++ b/src/gallium/include/pipe/p_screen.h
@@ -199,27 +199,34 @@ struct pipe_screen {
*/
struct pipe_resource * (*resource_from_user_memory)(struct pipe_screen *,
const struct pipe_resource *t,
void *user_memory);
/**
* Get a winsys_handle from a texture. Some platforms/winsys requires
* that the texture is created with a special usage flag like
* DISPLAYTARGET or PRIMARY.
*
+ * The context parameter can optionally be used to flush the resource and
+ * the context to make sure the resource is coherent with whatever user
+ * will use it. Some drivers may also use the context to convert
+ * the resource into a format compatible for sharing. The use case is
+ * OpenGL-OpenCL interop. The context parameter is allowed to be NULL.
+ *
* NOTE: in the case of DRM_API_HANDLE_TYPE_FD handles, the caller
* takes ownership of the FD. (This is consistent with
* EGL_MESA_image_dma_buf_export)
*
* \param usage A combination of PIPE_HANDLE_USAGE_* flags.
*/
boolean (*resource_get_handle)(struct pipe_screen *,
+ struct pipe_context *context,
struct pipe_resource *tex,
struct winsys_handle *handle,
unsigned usage);
void (*resource_destroy)(struct pipe_screen *,
struct pipe_resource *pt);
/**
diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c
index 9803b0e..f391c77 100644
--- a/src/gallium/state_trackers/dri/dri2.c
+++ b/src/gallium/state_trackers/dri/dri2.c
@@ -397,21 +397,21 @@ dri2_allocate_buffer(__DRIscreen *sPriv,
FREE(buffer);
return NULL;
}
memset(&whandle, 0, sizeof(whandle));
if (screen->can_share_buffer)
whandle.type = DRM_API_HANDLE_TYPE_SHARED;
else
whandle.type = DRM_API_HANDLE_TYPE_KMS;
- screen->base.screen->resource_get_handle(screen->base.screen,
+ screen->base.screen->resource_get_handle(screen->base.screen, NULL,
buffer->resource, &whandle,
PIPE_HANDLE_USAGE_EXPLICIT_FLUSH | PIPE_HANDLE_USAGE_READ);
buffer->base.attachment = attachment;
buffer->base.name = whandle.handle;
buffer->base.cpp = util_format_get_blocksize(pf);
buffer->base.pitch = whandle.stride;
return &buffer->base;
}
@@ -956,39 +956,39 @@ dri2_query_image(__DRIimage *image, int attrib, int *value)
usage = PIPE_HANDLE_USAGE_EXPLICIT_FLUSH | PIPE_HANDLE_USAGE_READ;
else
usage = PIPE_HANDLE_USAGE_READ_WRITE;
memset(&whandle, 0, sizeof(whandle));
switch (attrib) {
case __DRI_IMAGE_ATTRIB_STRIDE:
whandle.type = DRM_API_HANDLE_TYPE_KMS;
image->texture->screen->resource_get_handle(image->texture->screen,
- image->texture, &whandle, usage);
+ NULL, image->texture, &whandle, usage);
*value = whandle.stride;
return GL_TRUE;
case __DRI_IMAGE_ATTRIB_HANDLE:
whandle.type = DRM_API_HANDLE_TYPE_KMS;
image->texture->screen->resource_get_handle(image->texture->screen,
- image->texture, &whandle, usage);
+ NULL, image->texture, &whandle, usage);
*value = whandle.handle;
return GL_TRUE;
case __DRI_IMAGE_ATTRIB_NAME:
whandle.type = DRM_API_HANDLE_TYPE_SHARED;
image->texture->screen->resource_get_handle(image->texture->screen,
- image->texture, &whandle, usage);
+ NULL, image->texture, &whandle, usage);
*value = whandle.handle;
return GL_TRUE;
case __DRI_IMAGE_ATTRIB_FD:
whandle.type= DRM_API_HANDLE_TYPE_FD;
image->texture->screen->resource_get_handle(image->texture->screen,
- image->texture, &whandle, usage);
+ NULL, image->texture, &whandle, usage);
*value = whandle.handle;
return GL_TRUE;
case __DRI_IMAGE_ATTRIB_FORMAT:
*value = image->dri_format;
return GL_TRUE;
case __DRI_IMAGE_ATTRIB_WIDTH:
*value = image->texture->width0;
return GL_TRUE;
case __DRI_IMAGE_ATTRIB_HEIGHT:
*value = image->texture->height0;
@@ -1713,21 +1713,22 @@ dri2_interop_export_object(__DRIcontext *_ctx,
case MESA_GLINTEROP_ACCESS_WRITE_ONLY:
usage = PIPE_HANDLE_USAGE_WRITE;
break;
default:
usage = 0;
}
memset(&whandle, 0, sizeof(whandle));
whandle.type = DRM_API_HANDLE_TYPE_FD;
- success = screen->resource_get_handle(screen, res, &whandle, usage);
+ success = screen->resource_get_handle(screen, st->pipe, res, &whandle,
+ usage);
mtx_unlock(&ctx->Shared->Mutex);
if (!success)
return MESA_GLINTEROP_OUT_OF_HOST_MEMORY;
out->dmabuf_fd = whandle.handle;
out->out_driver_data_written = 0;
if (res->target == PIPE_BUFFER)
out->buf_offset += whandle.offset;
diff --git a/src/gallium/state_trackers/nine/swapchain9.c b/src/gallium/state_trackers/nine/swapchain9.c
index 08ee482..bc1c4b1 100644
--- a/src/gallium/state_trackers/nine/swapchain9.c
+++ b/src/gallium/state_trackers/nine/swapchain9.c
@@ -81,21 +81,22 @@ D3DWindowBuffer_create(struct NineSwapChain9 *This,
struct pipe_resource *resource,
int depth,
int for_frontbuffer_reading)
{
D3DWindowBuffer *ret;
struct winsys_handle whandle;
int stride, dmaBufFd;
memset(&whandle, 0, sizeof(whandle));
whandle.type = DRM_API_HANDLE_TYPE_FD;
- This->screen->resource_get_handle(This->screen, resource, &whandle,
+ This->screen->resource_get_handle(This->screen, This->pipe, resource,
+ &whandle,
for_frontbuffer_reading ?
PIPE_HANDLE_USAGE_WRITE :
PIPE_HANDLE_USAGE_EXPLICIT_FLUSH |
PIPE_HANDLE_USAGE_READ);
stride = whandle.stride;
dmaBufFd = whandle.handle;
ID3DPresent_NewD3DWindowBufferFromDmaBuf(This->present,
dmaBufFd,
resource->width0,
resource->height0,
diff --git a/src/gallium/state_trackers/va/buffer.c b/src/gallium/state_trackers/va/buffer.c
index dfcebbe..3c9b9d1 100644
--- a/src/gallium/state_trackers/va/buffer.c
+++ b/src/gallium/state_trackers/va/buffer.c
@@ -295,21 +295,22 @@ vlVaAcquireBufferHandle(VADriverContextP ctx, VABufferID buf_id,
case VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME: {
struct winsys_handle whandle;
pipe_mutex_lock(drv->mutex);
drv->pipe->flush(drv->pipe, NULL, 0);
pipe_mutex_unlock(drv->mutex);
memset(&whandle, 0, sizeof(whandle));
whandle.type = DRM_API_HANDLE_TYPE_FD;
- if (!screen->resource_get_handle(screen, buf->derived_surface.resource,
+ if (!screen->resource_get_handle(screen, drv->pipe,
+ buf->derived_surface.resource,
&whandle, PIPE_HANDLE_USAGE_READ_WRITE))
return VA_STATUS_ERROR_INVALID_BUFFER;
buf_info->handle = (intptr_t)whandle.handle;
break;
}
default:
return VA_STATUS_ERROR_UNSUPPORTED_MEMORY_TYPE;
}
diff --git a/src/gallium/state_trackers/vdpau/output.c b/src/gallium/state_trackers/vdpau/output.c
index 0b4f081..85751ea 100644
--- a/src/gallium/state_trackers/vdpau/output.c
+++ b/src/gallium/state_trackers/vdpau/output.c
@@ -789,21 +789,22 @@ VdpStatus vlVdpOutputSurfaceDMABuf(VdpVideoSurface surface,
pipe_mutex_lock(vlsurface->device->mutex);
vlVdpResolveDelayedRendering(vlsurface->device, NULL, NULL);
vlsurface->device->context->flush(vlsurface->device->context, NULL, 0);
pipe_mutex_unlock(vlsurface->device->mutex);
memset(&whandle, 0, sizeof(struct winsys_handle));
whandle.type = DRM_API_HANDLE_TYPE_FD;
pscreen = vlsurface->surface->texture->screen;
- if (!pscreen->resource_get_handle(pscreen, vlsurface->surface->texture, &whandle,
+ if (!pscreen->resource_get_handle(pscreen, vlsurface->device->context,
+ vlsurface->surface->texture, &whandle,
PIPE_HANDLE_USAGE_READ_WRITE))
return VDP_STATUS_NO_IMPLEMENTATION;
result->handle = whandle.handle;
result->width = vlsurface->surface->width;
result->height = vlsurface->surface->height;
result->offset = whandle.offset;
result->stride = whandle.stride;
result->format = PipeToFormatRGBA(vlsurface->surface->format);
diff --git a/src/gallium/state_trackers/vdpau/surface.c b/src/gallium/state_trackers/vdpau/surface.c
index 177483e..69afce0 100644
--- a/src/gallium/state_trackers/vdpau/surface.c
+++ b/src/gallium/state_trackers/vdpau/surface.c
@@ -463,21 +463,22 @@ VdpStatus vlVdpVideoSurfaceDMABuf(VdpVideoSurface surface,
pipe_mutex_unlock(p_surf->device->mutex);
if (!surf)
return VDP_STATUS_RESOURCES;
memset(&whandle, 0, sizeof(struct winsys_handle));
whandle.type = DRM_API_HANDLE_TYPE_FD;
whandle.layer = surf->u.tex.first_layer;
pscreen = surf->texture->screen;
- if (!pscreen->resource_get_handle(pscreen, surf->texture, &whandle,
+ if (!pscreen->resource_get_handle(pscreen, p_surf->device->context,
+ surf->texture, &whandle,
PIPE_HANDLE_USAGE_READ_WRITE))
return VDP_STATUS_NO_IMPLEMENTATION;
result->handle = whandle.handle;
result->width = surf->width;
result->height = surf->height;
result->offset = whandle.offset;
result->stride = whandle.stride;
if (surf->format == PIPE_FORMAT_R8_UNORM)
diff --git a/src/gallium/state_trackers/xa/xa_tracker.c b/src/gallium/state_trackers/xa/xa_tracker.c
index e091b083..d98bd2d 100644
--- a/src/gallium/state_trackers/xa/xa_tracker.c
+++ b/src/gallium/state_trackers/xa/xa_tracker.c
@@ -542,21 +542,22 @@ xa_surface_handle(struct xa_surface *srf,
enum xa_handle_type type,
uint32_t * handle, unsigned int *stride)
{
struct winsys_handle whandle;
struct pipe_screen *screen = srf->xa->screen;
boolean res;
memset(&whandle, 0, sizeof(whandle));
whandle.type = handle_type(type);
- res = screen->resource_get_handle(screen, srf->tex, &whandle,
+ res = screen->resource_get_handle(screen, srf->xa->default_ctx->pipe,
+ srf->tex, &whandle,
PIPE_HANDLE_USAGE_READ_WRITE);
if (!res)
return -XA_ERR_INVAL;
*handle = whandle.handle;
*stride = whandle.stride;
return XA_ERR_NONE;
}
diff --git a/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c b/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c
index e130cd2..47cf7f0 100644
--- a/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c
+++ b/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c
@@ -195,21 +195,21 @@ wsw_dt_from_handle(struct sw_winsys *ws,
static boolean
wsw_dt_get_handle(struct sw_winsys *ws,
struct sw_displaytarget *dt,
struct winsys_handle *whandle)
{
struct wrapper_sw_winsys *wsw = wrapper_sw_winsys(ws);
struct wrapper_sw_displaytarget *wdt = wrapper_sw_displaytarget(dt);
struct pipe_resource *tex = wdt->tex;
- return wsw->screen->resource_get_handle(wsw->screen, tex, whandle,
+ return wsw->screen->resource_get_handle(wsw->screen, NULL, tex, whandle,
PIPE_HANDLE_USAGE_READ_WRITE);
}
static void *
wsw_dt_map(struct sw_winsys *ws,
struct sw_displaytarget *dt,
unsigned flags)
{
struct wrapper_sw_displaytarget *wdt = wrapper_sw_displaytarget(dt);
struct pipe_context *pipe = wdt->winsys->pipe;
--
2.7.4
More information about the mesa-dev
mailing list