[Mesa-dev] [PATCH 1/2] gallium: add usage flags to resource_get_handle
Marek Olšák
maraeo at gmail.com
Wed Feb 24 23:10:07 UTC 2016
From: Marek Olšák <marek.olsak at amd.com>
This will help differentiate between window-system framebuffers and other
buffers.
PIPE_HANDLE_USAGE_EXPLICIT_FLUSH should yield higher performance (e.g. allows
delayed clears), but PIPE_HANDLE_USAGE_COHERENT is more flexible.
Sadly, it looks like st/dri can't distinguish between a DRI3 framebuffer
and EGL image export.
---
src/gallium/auxiliary/util/u_transfer.c | 3 ++-
src/gallium/auxiliary/util/u_transfer.h | 3 ++-
src/gallium/drivers/ddebug/dd_screen.c | 5 +++--
src/gallium/drivers/ilo/ilo_resource.c | 3 ++-
src/gallium/drivers/llvmpipe/lp_texture.c | 3 ++-
src/gallium/drivers/noop/noop_pipe.c | 3 ++-
src/gallium/drivers/r300/r300_texture.c | 3 ++-
src/gallium/drivers/r300/r300_texture.h | 4 +++-
src/gallium/drivers/radeon/r600_texture.c | 3 ++-
src/gallium/drivers/rbug/rbug_screen.c | 5 +++--
src/gallium/drivers/softpipe/sp_texture.c | 3 ++-
src/gallium/drivers/trace/tr_screen.c | 5 +++--
src/gallium/include/pipe/p_defines.h | 11 +++++++++++
src/gallium/include/pipe/p_screen.h | 3 ++-
src/gallium/state_trackers/dri/dri2.c | 10 +++++-----
src/gallium/state_trackers/nine/swapchain9.c | 3 ++-
src/gallium/state_trackers/va/buffer.c | 3 ++-
src/gallium/state_trackers/xa/xa_tracker.c | 3 ++-
src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c | 3 ++-
19 files changed, 54 insertions(+), 25 deletions(-)
diff --git a/src/gallium/auxiliary/util/u_transfer.c b/src/gallium/auxiliary/util/u_transfer.c
index adae84b..8f41355 100644
--- a/src/gallium/auxiliary/util/u_transfer.c
+++ b/src/gallium/auxiliary/util/u_transfer.c
@@ -98,7 +98,8 @@ u_resource( struct pipe_resource *res )
boolean u_resource_get_handle_vtbl(struct pipe_screen *screen,
struct pipe_resource *resource,
- struct winsys_handle *handle)
+ struct winsys_handle *handle,
+ enum pipe_handle_usage usage)
{
struct u_resource *ur = u_resource(resource);
return ur->vtbl->resource_get_handle(screen, resource, handle);
diff --git a/src/gallium/auxiliary/util/u_transfer.h b/src/gallium/auxiliary/util/u_transfer.h
index 6c25ee0..63e6a00 100644
--- a/src/gallium/auxiliary/util/u_transfer.h
+++ b/src/gallium/auxiliary/util/u_transfer.h
@@ -78,7 +78,8 @@ struct u_resource {
boolean u_resource_get_handle_vtbl(struct pipe_screen *screen,
struct pipe_resource *resource,
- struct winsys_handle *handle);
+ struct winsys_handle *handle,
+ enum pipe_handle_usage usage);
void u_resource_destroy_vtbl(struct pipe_screen *screen,
struct pipe_resource *resource);
diff --git a/src/gallium/drivers/ddebug/dd_screen.c b/src/gallium/drivers/ddebug/dd_screen.c
index 3706b2d..a5bbdd0 100644
--- a/src/gallium/drivers/ddebug/dd_screen.c
+++ b/src/gallium/drivers/ddebug/dd_screen.c
@@ -218,11 +218,12 @@ dd_screen_resource_destroy(struct pipe_screen *_screen,
static boolean
dd_screen_resource_get_handle(struct pipe_screen *_screen,
struct pipe_resource *resource,
- struct winsys_handle *handle)
+ struct winsys_handle *handle,
+ enum pipe_handle_usage usage)
{
struct pipe_screen *screen = dd_screen(_screen)->screen;
- return screen->resource_get_handle(screen, resource, handle);
+ return screen->resource_get_handle(screen, resource, handle, usage);
}
diff --git a/src/gallium/drivers/ilo/ilo_resource.c b/src/gallium/drivers/ilo/ilo_resource.c
index 9026ba9..a6f63e1 100644
--- a/src/gallium/drivers/ilo/ilo_resource.c
+++ b/src/gallium/drivers/ilo/ilo_resource.c
@@ -725,7 +725,8 @@ ilo_resource_from_handle(struct pipe_screen *screen,
static boolean
ilo_resource_get_handle(struct pipe_screen *screen,
struct pipe_resource *res,
- struct winsys_handle *handle)
+ struct winsys_handle *handle,
+ enum pipe_handle_usage usage)
{
if (res->target == PIPE_BUFFER)
return false;
diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c
index ae266ce..b3e4650 100644
--- a/src/gallium/drivers/llvmpipe/lp_texture.c
+++ b/src/gallium/drivers/llvmpipe/lp_texture.c
@@ -485,7 +485,8 @@ no_lpr:
static boolean
llvmpipe_resource_get_handle(struct pipe_screen *screen,
struct pipe_resource *pt,
- struct winsys_handle *whandle)
+ struct winsys_handle *whandle,
+ enum pipe_handle_usage usage)
{
struct sw_winsys *winsys = llvmpipe_screen(screen)->winsys;
struct llvmpipe_resource *lpr = llvmpipe_resource(pt);
diff --git a/src/gallium/drivers/noop/noop_pipe.c b/src/gallium/drivers/noop/noop_pipe.c
index 165284a..bdd4ccc 100644
--- a/src/gallium/drivers/noop/noop_pipe.c
+++ b/src/gallium/drivers/noop/noop_pipe.c
@@ -129,7 +129,8 @@ static struct pipe_resource *noop_resource_from_handle(struct pipe_screen *scree
static boolean noop_resource_get_handle(struct pipe_screen *screen,
struct pipe_resource *resource,
- struct winsys_handle *handle)
+ struct winsys_handle *handle,
+ enum pipe_handle_usage usage)
{
return FALSE;
}
diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c
index 3adee8e..27f8277 100644
--- a/src/gallium/drivers/r300/r300_texture.c
+++ b/src/gallium/drivers/r300/r300_texture.c
@@ -971,7 +971,8 @@ static void r300_texture_destroy(struct pipe_screen *screen,
boolean r300_resource_get_handle(struct pipe_screen* screen,
struct pipe_resource *texture,
- struct winsys_handle *whandle)
+ struct winsys_handle *whandle,
+ enum pipe_handle_usage usage)
{
struct radeon_winsys *rws = r300_screen(screen)->rws;
struct r300_resource* tex = (struct r300_resource*)texture;
diff --git a/src/gallium/drivers/r300/r300_texture.h b/src/gallium/drivers/r300/r300_texture.h
index 213bdff..a8117a3 100644
--- a/src/gallium/drivers/r300/r300_texture.h
+++ b/src/gallium/drivers/r300/r300_texture.h
@@ -25,6 +25,7 @@
#include "pipe/p_compiler.h"
#include "pipe/p_format.h"
+#include "pipe/p_screen.h"
struct pipe_screen;
struct pipe_context;
@@ -62,7 +63,8 @@ void r300_texture_setup_format_state(struct r300_screen *screen,
boolean r300_resource_get_handle(struct pipe_screen* screen,
struct pipe_resource *texture,
- struct winsys_handle *whandle);
+ struct winsys_handle *whandle,
+ enum pipe_handle_usage usage);
struct pipe_resource*
r300_texture_from_handle(struct pipe_screen* screen,
diff --git a/src/gallium/drivers/radeon/r600_texture.c b/src/gallium/drivers/radeon/r600_texture.c
index c21d06f..b583d50 100644
--- a/src/gallium/drivers/radeon/r600_texture.c
+++ b/src/gallium/drivers/radeon/r600_texture.c
@@ -251,7 +251,8 @@ static void r600_texture_init_metadata(struct r600_texture *rtex,
static boolean r600_texture_get_handle(struct pipe_screen* screen,
struct pipe_resource *resource,
- struct winsys_handle *whandle)
+ struct winsys_handle *whandle,
+ enum pipe_handle_usage usage)
{
struct r600_common_screen *rscreen = (struct r600_common_screen*)screen;
struct r600_resource *res = (struct r600_resource*)resource;
diff --git a/src/gallium/drivers/rbug/rbug_screen.c b/src/gallium/drivers/rbug/rbug_screen.c
index ac76402..aee20df 100644
--- a/src/gallium/drivers/rbug/rbug_screen.c
+++ b/src/gallium/drivers/rbug/rbug_screen.c
@@ -176,14 +176,15 @@ rbug_screen_resource_from_handle(struct pipe_screen *_screen,
static boolean
rbug_screen_resource_get_handle(struct pipe_screen *_screen,
struct pipe_resource *_resource,
- struct winsys_handle *handle)
+ struct winsys_handle *handle,
+ enum pipe_handle_usage usage)
{
struct rbug_screen *rb_screen = rbug_screen(_screen);
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);
+ return screen->resource_get_handle(screen, resource, handle, usage);
}
diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c
index 52df895..b381562 100644
--- a/src/gallium/drivers/softpipe/sp_texture.c
+++ b/src/gallium/drivers/softpipe/sp_texture.c
@@ -251,7 +251,8 @@ softpipe_resource_from_handle(struct pipe_screen *screen,
static boolean
softpipe_resource_get_handle(struct pipe_screen *screen,
struct pipe_resource *pt,
- struct winsys_handle *whandle)
+ struct winsys_handle *whandle,
+ enum pipe_handle_usage usage)
{
struct sw_winsys *winsys = softpipe_screen(screen)->winsys;
struct softpipe_resource *spr = softpipe_resource(pt);
diff --git a/src/gallium/drivers/trace/tr_screen.c b/src/gallium/drivers/trace/tr_screen.c
index 0612109..d1a10f8 100644
--- a/src/gallium/drivers/trace/tr_screen.c
+++ b/src/gallium/drivers/trace/tr_screen.c
@@ -331,7 +331,8 @@ trace_screen_resource_from_handle(struct pipe_screen *_screen,
static boolean
trace_screen_resource_get_handle(struct pipe_screen *_screen,
struct pipe_resource *_resource,
- struct winsys_handle *handle)
+ struct winsys_handle *handle,
+ enum pipe_handle_usage usage)
{
struct trace_screen *tr_screen = trace_screen(_screen);
struct trace_resource *tr_resource = trace_resource(_resource);
@@ -340,7 +341,7 @@ trace_screen_resource_get_handle(struct pipe_screen *_screen,
/* TODO trace call */
- return screen->resource_get_handle(screen, resource, handle);
+ return screen->resource_get_handle(screen, resource, handle, usage);
}
diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h
index 010be62..69a36d1 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -530,6 +530,17 @@ enum pipe_reset_status
/**
+ * resource_get_handle flags.
+ */
+enum pipe_handle_usage {
+ /* Requires pipe_context::flush_resource before external use. */
+ PIPE_HANDLE_USAGE_EXPLICIT_FLUSH,
+
+ /* All other cases. */
+ PIPE_HANDLE_USAGE_COHERENT,
+};
+
+/**
* Implementation capabilities/limits which are queried through
* pipe_screen::get_param()
*/
diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h
index 211bc24..b650672 100644
--- a/src/gallium/include/pipe/p_screen.h
+++ b/src/gallium/include/pipe/p_screen.h
@@ -206,7 +206,8 @@ struct pipe_screen {
*/
boolean (*resource_get_handle)(struct pipe_screen *,
struct pipe_resource *tex,
- struct winsys_handle *handle);
+ struct winsys_handle *handle,
+ enum pipe_handle_usage usage);
void (*resource_destroy)(struct pipe_screen *,
diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c
index a11a6cb..0c37da6 100644
--- a/src/gallium/state_trackers/dri/dri2.c
+++ b/src/gallium/state_trackers/dri/dri2.c
@@ -354,7 +354,7 @@ dri2_allocate_buffer(__DRIscreen *sPriv,
whandle.type = DRM_API_HANDLE_TYPE_KMS;
screen->base.screen->resource_get_handle(screen->base.screen,
- buffer->resource, &whandle);
+ buffer->resource, &whandle, PIPE_HANDLE_USAGE_EXPLICIT_FLUSH);
buffer->base.attachment = attachment;
buffer->base.name = whandle.handle;
@@ -899,25 +899,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);
+ image->texture, &whandle, PIPE_HANDLE_USAGE_COHERENT);
*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);
+ image->texture, &whandle, PIPE_HANDLE_USAGE_COHERENT);
*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);
+ image->texture, &whandle, PIPE_HANDLE_USAGE_COHERENT);
*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);
+ image->texture, &whandle, PIPE_HANDLE_USAGE_COHERENT);
*value = whandle.handle;
return GL_TRUE;
case __DRI_IMAGE_ATTRIB_FORMAT:
diff --git a/src/gallium/state_trackers/nine/swapchain9.c b/src/gallium/state_trackers/nine/swapchain9.c
index 1ab339c..c4a29cf 100644
--- a/src/gallium/state_trackers/nine/swapchain9.c
+++ b/src/gallium/state_trackers/nine/swapchain9.c
@@ -87,7 +87,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, resource, &whandle,
+ PIPE_HANDLE_USAGE_EXPLICIT_FLUSH);
stride = whandle.stride;
dmaBufFd = whandle.handle;
ID3DPresent_NewD3DWindowBufferFromDmaBuf(This->present,
diff --git a/src/gallium/state_trackers/va/buffer.c b/src/gallium/state_trackers/va/buffer.c
index c2c24d6..75a5a5c 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, &whandle))
+ if (!screen->resource_get_handle(screen, buf->derived_surface.resource,
+ &whandle, PIPE_HANDLE_USAGE_COHERENT))
return VA_STATUS_ERROR_INVALID_BUFFER;
buf_info->handle = (intptr_t)whandle.handle;
diff --git a/src/gallium/state_trackers/xa/xa_tracker.c b/src/gallium/state_trackers/xa/xa_tracker.c
index d57464b..708fb2f 100644
--- a/src/gallium/state_trackers/xa/xa_tracker.c
+++ b/src/gallium/state_trackers/xa/xa_tracker.c
@@ -548,7 +548,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->tex, &whandle,
+ PIPE_HANDLE_USAGE_COHERENT);
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 4d87a58..5fae986 100644
--- a/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c
+++ b/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c
@@ -201,7 +201,8 @@ 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, tex, whandle,
+ PIPE_HANDLE_USAGE_COHERENT);
}
static void *
--
2.5.0
More information about the mesa-dev
mailing list