summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2016-02-24 18:51:15 +0100
committerMarek Olšák <[email protected]>2016-03-09 15:02:25 +0100
commit82db518f1519cec9e3842f23455a105e2006afbd (patch)
tree5baa1ddfa03e94f1edc53b10473c67b9dce26fee /src/gallium/state_trackers
parentd943ac432de1f46cea47bdbf5ffe5365e2aef386 (diff)
gallium: add external usage flags to resource_from(get)_handle (v2)
This will allow drivers to make better decisions about texture sharing for DRI2, DRI3, Wayland, and OpenCL. v2: add read/write flags, take advantage of __DRI_IMAGE_USE_BACKBUFFER Reviewed-by: Axel Davy <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers')
-rw-r--r--src/gallium/state_trackers/dri/dri2.c25
-rw-r--r--src/gallium/state_trackers/dri/dri_screen.h1
-rw-r--r--src/gallium/state_trackers/nine/swapchain9.c4
-rw-r--r--src/gallium/state_trackers/va/buffer.c3
-rw-r--r--src/gallium/state_trackers/va/surface.c3
-rw-r--r--src/gallium/state_trackers/xa/xa_tracker.c6
6 files changed, 30 insertions, 12 deletions
diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c
index a11a6cbbb0c..7f7fbc47e6d 100644
--- a/src/gallium/state_trackers/dri/dri2.c
+++ b/src/gallium/state_trackers/dri/dri2.c
@@ -354,7 +354,8 @@ 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 | PIPE_HANDLE_USAGE_READ);
buffer->base.attachment = attachment;
buffer->base.name = whandle.handle;
@@ -539,7 +540,8 @@ dri2_allocate_textures(struct dri_context *ctx,
whandle.type = DRM_API_HANDLE_TYPE_KMS;
drawable->textures[statt] =
screen->base.screen->resource_from_handle(screen->base.screen,
- &templ, &whandle);
+ &templ, &whandle,
+ PIPE_HANDLE_USAGE_EXPLICIT_FLUSH | PIPE_HANDLE_USAGE_READ);
assert(drawable->textures[statt]);
}
}
@@ -756,7 +758,7 @@ dri2_create_image_from_winsys(__DRIscreen *_screen,
whandle->stride = pitch * util_format_get_blocksize(pf);
img->texture = screen->base.screen->resource_from_handle(screen->base.screen,
- &templ, whandle);
+ &templ, whandle, PIPE_HANDLE_USAGE_READ_WRITE);
if (!img->texture) {
FREE(img);
return NULL;
@@ -765,6 +767,7 @@ dri2_create_image_from_winsys(__DRIscreen *_screen,
img->level = 0;
img->layer = 0;
img->dri_format = format;
+ img->use = 0;
img->loader_private = loaderPrivate;
return img;
@@ -884,6 +887,7 @@ dri2_create_image(__DRIscreen *_screen,
img->layer = 0;
img->dri_format = format;
img->dri_components = 0;
+ img->use = use;
img->loader_private = loaderPrivate;
return img;
@@ -893,31 +897,38 @@ static GLboolean
dri2_query_image(__DRIimage *image, int attrib, int *value)
{
struct winsys_handle whandle;
+ unsigned usage;
+
+ if (image->use & __DRI_IMAGE_USE_BACKBUFFER)
+ 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);
+ 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);
+ 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);
+ 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);
+ image->texture, &whandle, usage);
*value = whandle.handle;
return GL_TRUE;
case __DRI_IMAGE_ATTRIB_FORMAT:
diff --git a/src/gallium/state_trackers/dri/dri_screen.h b/src/gallium/state_trackers/dri/dri_screen.h
index 45459906588..dc4692a1c6b 100644
--- a/src/gallium/state_trackers/dri/dri_screen.h
+++ b/src/gallium/state_trackers/dri/dri_screen.h
@@ -109,6 +109,7 @@ struct __DRIimageRec {
unsigned layer;
uint32_t dri_format;
uint32_t dri_components;
+ unsigned use;
void *loader_private;
diff --git a/src/gallium/state_trackers/nine/swapchain9.c b/src/gallium/state_trackers/nine/swapchain9.c
index 1ab339c459c..e2fb4d4a1e3 100644
--- a/src/gallium/state_trackers/nine/swapchain9.c
+++ b/src/gallium/state_trackers/nine/swapchain9.c
@@ -87,7 +87,9 @@ 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 |
+ PIPE_HANDLE_USAGE_READ);
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 c2c24d693f2..2fd86612e9a 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_READ_WRITE))
return VA_STATUS_ERROR_INVALID_BUFFER;
buf_info->handle = (intptr_t)whandle.handle;
diff --git a/src/gallium/state_trackers/va/surface.c b/src/gallium/state_trackers/va/surface.c
index 84a94949c47..861dac260a9 100644
--- a/src/gallium/state_trackers/va/surface.c
+++ b/src/gallium/state_trackers/va/surface.c
@@ -470,7 +470,8 @@ suface_from_external_memory(VADriverContextP ctx, vlVaSurface *surface,
whandle.handle = memory_attibute->buffers[index];
whandle.stride = memory_attibute->pitches[index];
- resource = pscreen->resource_from_handle(pscreen, &res_templ, &whandle);
+ resource = pscreen->resource_from_handle(pscreen, &res_templ, &whandle,
+ PIPE_HANDLE_USAGE_READ_WRITE);
if (!resource)
return VA_STATUS_ERROR_ALLOCATION_FAILED;
diff --git a/src/gallium/state_trackers/xa/xa_tracker.c b/src/gallium/state_trackers/xa/xa_tracker.c
index d57464b7d60..f09baed1d84 100644
--- a/src/gallium/state_trackers/xa/xa_tracker.c
+++ b/src/gallium/state_trackers/xa/xa_tracker.c
@@ -362,7 +362,8 @@ surface_create(struct xa_tracker *xa,
template->bind |= PIPE_BIND_SCANOUT;
if (whandle)
- srf->tex = xa->screen->resource_from_handle(xa->screen, template, whandle);
+ srf->tex = xa->screen->resource_from_handle(xa->screen, template, whandle,
+ PIPE_HANDLE_USAGE_READ_WRITE);
else
srf->tex = xa->screen->resource_create(xa->screen, template);
if (!srf->tex)
@@ -548,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->tex, &whandle,
+ PIPE_HANDLE_USAGE_READ_WRITE);
if (!res)
return -XA_ERR_INVAL;