aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2016-08-21 12:24:59 +0200
committerMarek Olšák <[email protected]>2016-08-25 14:09:48 +0200
commit9daaa6f5a66ab6cc99c6f0af37fc1007ab3d09af (patch)
tree47e62319d0ddea75f93bccf52305133e2e0be5f3
parentb662c70aeab6a92751514f30719c13a6de253b40 (diff)
gallium: add a pipe_context parameter to resource_get_handle
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. Reviewed-by: Brian Paul <[email protected]>
-rw-r--r--src/gallium/auxiliary/util/u_transfer.c1
-rw-r--r--src/gallium/auxiliary/util/u_transfer.h1
-rw-r--r--src/gallium/auxiliary/vl/vl_winsys_dri3.c2
-rw-r--r--src/gallium/drivers/ddebug/dd_screen.c4
-rw-r--r--src/gallium/drivers/ilo/ilo_resource.c1
-rw-r--r--src/gallium/drivers/llvmpipe/lp_texture.c1
-rw-r--r--src/gallium/drivers/noop/noop_pipe.c1
-rw-r--r--src/gallium/drivers/r300/r300_texture.c1
-rw-r--r--src/gallium/drivers/r300/r300_texture.h1
-rw-r--r--src/gallium/drivers/radeon/r600_texture.c1
-rw-r--r--src/gallium/drivers/rbug/rbug_screen.c5
-rw-r--r--src/gallium/drivers/softpipe/sp_texture.c1
-rw-r--r--src/gallium/drivers/trace/tr_screen.c5
-rw-r--r--src/gallium/include/pipe/p_screen.h7
-rw-r--r--src/gallium/state_trackers/dri/dri2.c13
-rw-r--r--src/gallium/state_trackers/nine/swapchain9.c3
-rw-r--r--src/gallium/state_trackers/va/buffer.c3
-rw-r--r--src/gallium/state_trackers/vdpau/output.c3
-rw-r--r--src/gallium/state_trackers/vdpau/surface.c3
-rw-r--r--src/gallium/state_trackers/xa/xa_tracker.c3
-rw-r--r--src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c2
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 82cf68db958..ba4b9dcc6b3 100644
--- a/src/gallium/auxiliary/util/u_transfer.c
+++ b/src/gallium/auxiliary/util/u_transfer.c
@@ -111,6 +111,7 @@ u_resource( struct pipe_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)
diff --git a/src/gallium/auxiliary/util/u_transfer.h b/src/gallium/auxiliary/util/u_transfer.h
index 7f680bc6582..ab787abdce3 100644
--- a/src/gallium/auxiliary/util/u_transfer.h
+++ b/src/gallium/auxiliary/util/u_transfer.h
@@ -73,6 +73,7 @@ struct u_resource {
boolean u_resource_get_handle_vtbl(struct pipe_screen *screen,
+ struct pipe_context *ctx,
struct pipe_resource *resource,
struct winsys_handle *handle,
unsigned usage);
diff --git a/src/gallium/auxiliary/vl/vl_winsys_dri3.c b/src/gallium/auxiliary/vl/vl_winsys_dri3.c
index 61d6205b326..3d596a6d112 100644
--- a/src/gallium/auxiliary/vl/vl_winsys_dri3.c
+++ b/src/gallium/auxiliary/vl/vl_winsys_dri3.c
@@ -243,7 +243,7 @@ dri3_alloc_back_buffer(struct vl_dri3_screen *scrn)
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;
diff --git a/src/gallium/drivers/ddebug/dd_screen.c b/src/gallium/drivers/ddebug/dd_screen.c
index 3deba0a6e27..4050e39a124 100644
--- a/src/gallium/drivers/ddebug/dd_screen.c
+++ b/src/gallium/drivers/ddebug/dd_screen.c
@@ -237,13 +237,15 @@ dd_screen_resource_destroy(struct pipe_screen *_screen,
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);
}
diff --git a/src/gallium/drivers/ilo/ilo_resource.c b/src/gallium/drivers/ilo/ilo_resource.c
index 0afbfc69ee0..7961288179d 100644
--- a/src/gallium/drivers/ilo/ilo_resource.c
+++ b/src/gallium/drivers/ilo/ilo_resource.c
@@ -725,6 +725,7 @@ ilo_resource_from_handle(struct pipe_screen *screen,
static boolean
ilo_resource_get_handle(struct pipe_screen *screen,
+ struct pipe_context *ctx,
struct pipe_resource *res,
struct winsys_handle *handle,
unsigned usage)
diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c
index 0d4c4efe0b9..733253b0b08 100644
--- a/src/gallium/drivers/llvmpipe/lp_texture.c
+++ b/src/gallium/drivers/llvmpipe/lp_texture.c
@@ -485,6 +485,7 @@ no_lpr:
static boolean
llvmpipe_resource_get_handle(struct pipe_screen *screen,
+ struct pipe_context *ctx,
struct pipe_resource *pt,
struct winsys_handle *whandle,
unsigned usage)
diff --git a/src/gallium/drivers/noop/noop_pipe.c b/src/gallium/drivers/noop/noop_pipe.c
index cf20681e306..4eb6051d9bc 100644
--- a/src/gallium/drivers/noop/noop_pipe.c
+++ b/src/gallium/drivers/noop/noop_pipe.c
@@ -135,6 +135,7 @@ static struct pipe_resource *noop_resource_from_handle(struct pipe_screen *scree
}
static boolean noop_resource_get_handle(struct pipe_screen *screen,
+ struct pipe_context *ctx,
struct pipe_resource *resource,
struct winsys_handle *handle,
unsigned usage)
diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c
index 2fc93c2dfd6..5f459e4819e 100644
--- a/src/gallium/drivers/r300/r300_texture.c
+++ b/src/gallium/drivers/r300/r300_texture.c
@@ -1036,6 +1036,7 @@ static void r300_texture_destroy(struct pipe_screen *screen,
}
boolean r300_resource_get_handle(struct pipe_screen* screen,
+ struct pipe_context *ctx,
struct pipe_resource *texture,
struct winsys_handle *whandle,
unsigned usage)
diff --git a/src/gallium/drivers/r300/r300_texture.h b/src/gallium/drivers/r300/r300_texture.h
index 4c339429eca..33416710e43 100644
--- a/src/gallium/drivers/r300/r300_texture.h
+++ b/src/gallium/drivers/r300/r300_texture.h
@@ -62,6 +62,7 @@ void r300_texture_setup_format_state(struct r300_screen *screen,
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);
diff --git a/src/gallium/drivers/radeon/r600_texture.c b/src/gallium/drivers/radeon/r600_texture.c
index 8c7bfa328d9..9629fbbccb8 100644
--- a/src/gallium/drivers/radeon/r600_texture.c
+++ b/src/gallium/drivers/radeon/r600_texture.c
@@ -511,6 +511,7 @@ static void r600_degrade_tile_mode_to_linear(struct r600_common_context *rctx,
}
static boolean r600_texture_get_handle(struct pipe_screen* screen,
+ struct pipe_context *ctx,
struct pipe_resource *resource,
struct winsys_handle *whandle,
unsigned usage)
diff --git a/src/gallium/drivers/rbug/rbug_screen.c b/src/gallium/drivers/rbug/rbug_screen.c
index 8d216691fdb..3742c103306 100644
--- a/src/gallium/drivers/rbug/rbug_screen.c
+++ b/src/gallium/drivers/rbug/rbug_screen.c
@@ -176,16 +176,19 @@ rbug_screen_resource_from_handle(struct pipe_screen *_screen,
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);
}
diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c
index 9c64397d0b9..8dca15860e4 100644
--- a/src/gallium/drivers/softpipe/sp_texture.c
+++ b/src/gallium/drivers/softpipe/sp_texture.c
@@ -251,6 +251,7 @@ softpipe_resource_from_handle(struct pipe_screen *screen,
static boolean
softpipe_resource_get_handle(struct pipe_screen *screen,
+ struct pipe_context *ctx,
struct pipe_resource *pt,
struct winsys_handle *whandle,
unsigned usage)
diff --git a/src/gallium/drivers/trace/tr_screen.c b/src/gallium/drivers/trace/tr_screen.c
index 67241ca2ba1..493725cbcaa 100644
--- a/src/gallium/drivers/trace/tr_screen.c
+++ b/src/gallium/drivers/trace/tr_screen.c
@@ -333,18 +333,21 @@ trace_screen_resource_from_handle(struct pipe_screen *_screen,
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);
}
diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h
index dd40e07b7ee..255647ed273 100644
--- a/src/gallium/include/pipe/p_screen.h
+++ b/src/gallium/include/pipe/p_screen.h
@@ -206,6 +206,12 @@ struct pipe_screen {
* 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)
@@ -213,6 +219,7 @@ struct pipe_screen {
* \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);
diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c
index 9803b0e1971..f391c77b657 100644
--- a/src/gallium/state_trackers/dri/dri2.c
+++ b/src/gallium/state_trackers/dri/dri2.c
@@ -404,7 +404,7 @@ dri2_allocate_buffer(__DRIscreen *sPriv,
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);
@@ -963,25 +963,25 @@ dri2_query_image(__DRIimage *image, int attrib, int *value)
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:
@@ -1720,7 +1720,8 @@ dri2_interop_export_object(__DRIcontext *_ctx,
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)
diff --git a/src/gallium/state_trackers/nine/swapchain9.c b/src/gallium/state_trackers/nine/swapchain9.c
index 08ee482f0d3..bc1c4b108cb 100644
--- a/src/gallium/state_trackers/nine/swapchain9.c
+++ b/src/gallium/state_trackers/nine/swapchain9.c
@@ -88,7 +88,8 @@ D3DWindowBuffer_create(struct NineSwapChain9 *This,
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 |
diff --git a/src/gallium/state_trackers/va/buffer.c b/src/gallium/state_trackers/va/buffer.c
index dfcebbe4bd5..3c9b9d1a1e5 100644
--- a/src/gallium/state_trackers/va/buffer.c
+++ b/src/gallium/state_trackers/va/buffer.c
@@ -302,7 +302,8 @@ vlVaAcquireBufferHandle(VADriverContextP ctx, VABufferID buf_id,
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;
diff --git a/src/gallium/state_trackers/vdpau/output.c b/src/gallium/state_trackers/vdpau/output.c
index 0b4f081be3e..85751ea5701 100644
--- a/src/gallium/state_trackers/vdpau/output.c
+++ b/src/gallium/state_trackers/vdpau/output.c
@@ -796,7 +796,8 @@ VdpStatus vlVdpOutputSurfaceDMABuf(VdpVideoSurface surface,
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;
diff --git a/src/gallium/state_trackers/vdpau/surface.c b/src/gallium/state_trackers/vdpau/surface.c
index 177483e0f6f..69afce00499 100644
--- a/src/gallium/state_trackers/vdpau/surface.c
+++ b/src/gallium/state_trackers/vdpau/surface.c
@@ -470,7 +470,8 @@ VdpStatus vlVdpVideoSurfaceDMABuf(VdpVideoSurface surface,
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;
diff --git a/src/gallium/state_trackers/xa/xa_tracker.c b/src/gallium/state_trackers/xa/xa_tracker.c
index e091b083411..d98bd2dc922 100644
--- a/src/gallium/state_trackers/xa/xa_tracker.c
+++ b/src/gallium/state_trackers/xa/xa_tracker.c
@@ -549,7 +549,8 @@ xa_surface_handle(struct xa_surface *srf,
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;
diff --git a/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c b/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c
index e130cd256e9..47cf7f02870 100644
--- a/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c
+++ b/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c
@@ -202,7 +202,7 @@ wsw_dt_get_handle(struct 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);
}