[Mesa-dev] [PATCH] gallium: rework PIPE_HANDLE_USAGE_* flags

Marek Olšák maraeo at gmail.com
Thu Oct 25 20:31:12 UTC 2018


From: Marek Olšák <marek.olsak at amd.com>

Only radeonsi uses them, so adjust them to match its needs.
---
 src/gallium/auxiliary/renderonly/renderonly.c  |  2 +-
 src/gallium/auxiliary/vl/vl_winsys_dri.c       |  2 +-
 src/gallium/auxiliary/vl/vl_winsys_dri3.c      |  4 ++--
 src/gallium/drivers/etnaviv/etnaviv_resource.c |  2 +-
 src/gallium/drivers/r600/r600_texture.c        |  2 +-
 src/gallium/drivers/radeonsi/si_texture.c      |  7 ++++---
 src/gallium/drivers/tegra/tegra_screen.c       |  3 +--
 src/gallium/include/pipe/p_defines.h           |  8 +++-----
 src/gallium/state_trackers/dri/dri2.c          | 18 ++++++++----------
 src/gallium/state_trackers/dri/drisw.c         |  2 +-
 src/gallium/state_trackers/nine/swapchain9.c   |  5 ++---
 src/gallium/state_trackers/va/buffer.c         |  2 +-
 src/gallium/state_trackers/va/surface.c        |  6 ++----
 src/gallium/state_trackers/vdpau/output.c      |  2 +-
 src/gallium/state_trackers/vdpau/surface.c     |  2 +-
 src/gallium/state_trackers/xa/xa_tracker.c     |  4 ++--
 .../winsys/sw/wrapper/wrapper_sw_winsys.c      |  4 ++--
 src/mesa/state_tracker/st_vdpau.c              |  2 +-
 18 files changed, 35 insertions(+), 42 deletions(-)

diff --git a/src/gallium/auxiliary/renderonly/renderonly.c b/src/gallium/auxiliary/renderonly/renderonly.c
index f83910a9404..d6a34400937 100644
--- a/src/gallium/auxiliary/renderonly/renderonly.c
+++ b/src/gallium/auxiliary/renderonly/renderonly.c
@@ -131,21 +131,21 @@ renderonly_create_gpu_import_for_resource(struct pipe_resource *rsc,
    int fd, err;
    struct winsys_handle handle = {
       .type = WINSYS_HANDLE_TYPE_FD
    };
 
    scanout = CALLOC_STRUCT(renderonly_scanout);
    if (!scanout)
       return NULL;
 
    status = screen->resource_get_handle(screen, NULL, rsc, &handle,
-         PIPE_HANDLE_USAGE_READ_WRITE);
+         PIPE_HANDLE_USAGE_FRAMEBUFFER_WRITE);
    if (!status)
       goto free_scanout;
 
    scanout->stride = handle.stride;
    fd = handle.handle;
 
    err = drmPrimeFDToHandle(ro->kms_fd, fd, &scanout->handle);
    close(fd);
 
    if (err < 0) {
diff --git a/src/gallium/auxiliary/vl/vl_winsys_dri.c b/src/gallium/auxiliary/vl/vl_winsys_dri.c
index 137885d9475..1905516a761 100644
--- a/src/gallium/auxiliary/vl/vl_winsys_dri.c
+++ b/src/gallium/auxiliary/vl/vl_winsys_dri.c
@@ -242,21 +242,21 @@ vl_dri2_screen_texture_from_drawable(struct vl_screen *vscreen, void *drawable)
    templ.width0 = reply->width;
    templ.height0 = reply->height;
    templ.depth0 = 1;
    templ.array_size = 1;
    templ.usage = PIPE_USAGE_DEFAULT;
    templ.bind = PIPE_BIND_RENDER_TARGET;
    templ.flags = 0;
 
    tex = scrn->base.pscreen->resource_from_handle(scrn->base.pscreen, &templ,
                                                   &dri2_handle,
-                                                  PIPE_HANDLE_USAGE_READ_WRITE);
+                                                  PIPE_HANDLE_USAGE_FRAMEBUFFER_WRITE);
    free(reply);
 
    return tex;
 }
 
 static struct u_rect *
 vl_dri2_screen_get_dirty_area(struct vl_screen *vscreen)
 {
    struct vl_dri_screen *scrn = (struct vl_dri_screen *)vscreen;
    assert(scrn);
diff --git a/src/gallium/auxiliary/vl/vl_winsys_dri3.c b/src/gallium/auxiliary/vl/vl_winsys_dri3.c
index d6a1ec0bfdd..152d28e59fc 100644
--- a/src/gallium/auxiliary/vl/vl_winsys_dri3.c
+++ b/src/gallium/auxiliary/vl/vl_winsys_dri3.c
@@ -265,21 +265,21 @@ dri3_alloc_back_buffer(struct vl_dri3_screen *scrn)
    } else {
       templ.bind |= PIPE_BIND_SCANOUT | PIPE_BIND_SHARED;
       buffer->texture = (scrn->output_texture) ? scrn->output_texture :
                         scrn->base.pscreen->resource_create(scrn->base.pscreen, &templ);
       if (!buffer->texture)
          goto unmap_shm;
       pixmap_buffer_texture = buffer->texture;
    }
    memset(&whandle, 0, sizeof(whandle));
    whandle.type= WINSYS_HANDLE_TYPE_FD;
-   usage = PIPE_HANDLE_USAGE_EXPLICIT_FLUSH | PIPE_HANDLE_USAGE_READ;
+   usage = PIPE_HANDLE_USAGE_EXPLICIT_FLUSH;
    scrn->base.pscreen->resource_get_handle(scrn->base.pscreen, NULL,
                                            pixmap_buffer_texture, &whandle,
                                            usage);
    buffer_fd = whandle.handle;
    buffer->pitch = whandle.stride;
    buffer->width = templ.width0;
    buffer->height = templ.height0;
 
    xcb_dri3_pixmap_from_buffer(scrn->conn,
                                (pixmap = xcb_generate_id(scrn->conn)),
@@ -500,21 +500,21 @@ dri3_get_front_buffer(struct vl_dri3_screen *scrn)
    templ.format = vl_dri2_format_for_depth(&scrn->base, bp_reply->depth);
    templ.target = PIPE_TEXTURE_2D;
    templ.last_level = 0;
    templ.width0 = bp_reply->width;
    templ.height0 = bp_reply->height;
    templ.depth0 = 1;
    templ.array_size = 1;
    scrn->front_buffer->texture =
       scrn->base.pscreen->resource_from_handle(scrn->base.pscreen,
                                                &templ, &whandle,
-                                               PIPE_HANDLE_USAGE_READ_WRITE);
+                                               PIPE_HANDLE_USAGE_FRAMEBUFFER_WRITE);
    close(fds[0]);
    if (!scrn->front_buffer->texture)
       goto free_reply;
 
    xcb_dri3_fence_from_fd(scrn->conn,
                           scrn->drawable,
                           (sync_fence = xcb_generate_id(scrn->conn)),
                           false,
                           fence_fd);
 
diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c b/src/gallium/drivers/etnaviv/etnaviv_resource.c
index 7fd374ae23d..3808c293e6e 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_resource.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c
@@ -247,21 +247,21 @@ etna_resource_alloc(struct pipe_screen *pscreen, unsigned layout,
 
       scanout = renderonly_scanout_for_resource(&scanout_templat,
                                                 screen->ro, &handle);
       if (!scanout)
          return NULL;
 
       assert(handle.type == WINSYS_HANDLE_TYPE_FD);
       handle.modifier = modifier;
       rsc = etna_resource(pscreen->resource_from_handle(pscreen, templat,
                                                         &handle,
-                                                        PIPE_HANDLE_USAGE_WRITE));
+                                                        PIPE_HANDLE_USAGE_FRAMEBUFFER_WRITE));
       close(handle.handle);
       if (!rsc)
          return NULL;
 
       rsc->scanout = scanout;
 
       return &rsc->base;
    }
 
    rsc = CALLOC_STRUCT(etna_resource);
diff --git a/src/gallium/drivers/r600/r600_texture.c b/src/gallium/drivers/r600/r600_texture.c
index d08c6e5637c..def4cbf86b2 100644
--- a/src/gallium/drivers/r600/r600_texture.c
+++ b/src/gallium/drivers/r600/r600_texture.c
@@ -1935,21 +1935,21 @@ r600_texture_from_memobj(struct pipe_screen *screen,
 	rtex = r600_texture_create_object(screen, templ, memobj->buf, &surface);
 	if (!rtex)
 		return NULL;
 
 	/* r600_texture_create_object doesn't increment refcount of
 	 * memobj->buf, so increment it here.
 	 */
 	pb_reference(&buf, memobj->buf);
 
 	rtex->resource.b.is_shared = true;
-	rtex->resource.external_usage = PIPE_HANDLE_USAGE_READ_WRITE;
+	rtex->resource.external_usage = PIPE_HANDLE_USAGE_FRAMEBUFFER_WRITE;
 
 	if (rscreen->apply_opaque_metadata)
 		rscreen->apply_opaque_metadata(rscreen, rtex, &metadata);
 
 	return &rtex->resource.b.b;
 }
 
 void r600_init_screen_texture_functions(struct r600_common_screen *rscreen)
 {
 	rscreen->b.resource_from_handle = r600_texture_from_handle;
diff --git a/src/gallium/drivers/radeonsi/si_texture.c b/src/gallium/drivers/radeonsi/si_texture.c
index bcff226a586..2fb79253a72 100644
--- a/src/gallium/drivers/radeonsi/si_texture.c
+++ b/src/gallium/drivers/radeonsi/si_texture.c
@@ -438,21 +438,21 @@ void si_texture_discard_cmask(struct si_screen *sscreen,
 	/* Notify all contexts about the change. */
 	p_atomic_inc(&sscreen->dirty_tex_counter);
 	p_atomic_inc(&sscreen->compressed_colortex_counter);
 }
 
 static bool si_can_disable_dcc(struct si_texture *tex)
 {
 	/* We can't disable DCC if it can be written by another process. */
 	return tex->dcc_offset &&
 	       (!tex->buffer.b.is_shared ||
-		!(tex->buffer.external_usage & PIPE_HANDLE_USAGE_WRITE));
+		!(tex->buffer.external_usage & PIPE_HANDLE_USAGE_FRAMEBUFFER_WRITE));
 }
 
 static bool si_texture_discard_dcc(struct si_screen *sscreen,
 				   struct si_texture *tex)
 {
 	if (!si_can_disable_dcc(tex))
 		return false;
 
 	assert(tex->dcc_separate_buffer == NULL);
 
@@ -756,21 +756,21 @@ static boolean si_texture_get_handle(struct pipe_screen* screen,
 			assert(res->b.b.bind & PIPE_BIND_SHARED);
 			assert(res->flags & RADEON_FLAG_NO_SUBALLOC);
 			assert(!(res->flags & RADEON_FLAG_NO_INTERPROCESS_SHARING));
 			assert(tex->surface.tile_swizzle == 0);
 		}
 
 		/* Since shader image stores don't support DCC on VI,
 		 * disable it for external clients that want write
 		 * access.
 		 */
-		if (usage & PIPE_HANDLE_USAGE_WRITE && tex->dcc_offset) {
+		if (usage & PIPE_HANDLE_USAGE_SHADER_WRITE && tex->dcc_offset) {
 			if (si_texture_disable_dcc(sctx, tex)) {
 				update_metadata = true;
 				/* si_texture_disable_dcc flushes the context */
 				flush = false;
 			}
 		}
 
 		if (!(usage & PIPE_HANDLE_USAGE_EXPLICIT_FLUSH) &&
 		    (tex->cmask_buffer || tex->dcc_offset)) {
 			/* Eliminate fast clear (both CMASK and DCC) */
@@ -2366,21 +2366,22 @@ static struct pipe_resource *
 si_texture_from_memobj(struct pipe_screen *screen,
 		       const struct pipe_resource *templ,
 		       struct pipe_memory_object *_memobj,
 		       uint64_t offset)
 {
 	struct si_screen *sscreen = (struct si_screen*)screen;
 	struct si_memory_object *memobj = (struct si_memory_object *)_memobj;
 	struct pipe_resource *tex =
 		si_texture_from_winsys_buffer(sscreen, templ, memobj->buf,
 					      memobj->stride, offset,
-					      PIPE_HANDLE_USAGE_READ_WRITE,
+					      PIPE_HANDLE_USAGE_FRAMEBUFFER_WRITE |
+					      PIPE_HANDLE_USAGE_SHADER_WRITE,
 					      memobj->b.dedicated);
 	if (!tex)
 		return NULL;
 
 	/* si_texture_from_winsys_buffer doesn't increment refcount of
 	 * memobj->buf, so increment it here.
 	 */
 	struct pb_buffer *buf = NULL;
 	pb_reference(&buf, memobj->buf);
 	return tex;
diff --git a/src/gallium/drivers/tegra/tegra_screen.c b/src/gallium/drivers/tegra/tegra_screen.c
index 243bdde8d2c..1051c167189 100644
--- a/src/gallium/drivers/tegra/tegra_screen.c
+++ b/src/gallium/drivers/tegra/tegra_screen.c
@@ -160,31 +160,30 @@ tegra_screen_can_create_resource(struct pipe_screen *pscreen,
                                  const struct pipe_resource *template)
 {
    struct tegra_screen *screen = to_tegra_screen(pscreen);
 
    return screen->gpu->can_create_resource(screen->gpu, template);
 }
 
 static int tegra_screen_import_resource(struct tegra_screen *screen,
                                         struct tegra_resource *resource)
 {
-   unsigned usage = PIPE_HANDLE_USAGE_READ;
    struct winsys_handle handle;
    boolean status;
    int fd, err;
 
    memset(&handle, 0, sizeof(handle));
    handle.modifier = DRM_FORMAT_MOD_INVALID;
    handle.type = WINSYS_HANDLE_TYPE_FD;
 
    status = screen->gpu->resource_get_handle(screen->gpu, NULL, resource->gpu,
-                                             &handle, usage);
+                                             &handle, 0);
    if (!status)
       return -EINVAL;
 
    assert(handle.modifier != DRM_FORMAT_MOD_INVALID);
 
    if (handle.modifier == DRM_FORMAT_MOD_INVALID) {
       close(handle.handle);
       return -EINVAL;
    }
 
diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h
index c58f1659625..dacedf5b936 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -614,26 +614,24 @@ enum pipe_conservative_raster_mode
    PIPE_CONSERVATIVE_RASTER_OFF,
    PIPE_CONSERVATIVE_RASTER_POST_SNAP,
    PIPE_CONSERVATIVE_RASTER_PRE_SNAP,
 };
 
 
 /**
  * resource_get_handle flags.
  */
 /* Requires pipe_context::flush_resource before external use. */
-#define PIPE_HANDLE_USAGE_EXPLICIT_FLUSH  (1 << 0)
+#define PIPE_HANDLE_USAGE_EXPLICIT_FLUSH     (1 << 0)
 /* Expected external use of the resource: */
-#define PIPE_HANDLE_USAGE_READ            (1 << 1)
-#define PIPE_HANDLE_USAGE_WRITE           (1 << 2)
-#define PIPE_HANDLE_USAGE_READ_WRITE      (PIPE_HANDLE_USAGE_READ | \
-                                           PIPE_HANDLE_USAGE_WRITE)
+#define PIPE_HANDLE_USAGE_FRAMEBUFFER_WRITE  (1 << 1)
+#define PIPE_HANDLE_USAGE_SHADER_WRITE       (1 << 2)
 
 /**
  * pipe_image_view access flags.
  */
 #define PIPE_IMAGE_ACCESS_READ       (1 << 0)
 #define PIPE_IMAGE_ACCESS_WRITE      (1 << 1)
 #define PIPE_IMAGE_ACCESS_READ_WRITE (PIPE_IMAGE_ACCESS_READ | \
                                       PIPE_IMAGE_ACCESS_WRITE)
 
 /**
diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c
index 4efc4334b65..2f0ef890ca7 100644
--- a/src/gallium/state_trackers/dri/dri2.c
+++ b/src/gallium/state_trackers/dri/dri2.c
@@ -644,21 +644,21 @@ dri2_allocate_buffer(__DRIscreen *sPriv,
    }
 
    memset(&whandle, 0, sizeof(whandle));
    if (screen->can_share_buffer)
       whandle.type = WINSYS_HANDLE_TYPE_SHARED;
    else
       whandle.type = WINSYS_HANDLE_TYPE_KMS;
 
    screen->base.screen->resource_get_handle(screen->base.screen, NULL,
          buffer->resource, &whandle,
-         PIPE_HANDLE_USAGE_EXPLICIT_FLUSH | PIPE_HANDLE_USAGE_READ);
+         PIPE_HANDLE_USAGE_EXPLICIT_FLUSH);
 
    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;
 }
 
 static void
@@ -832,21 +832,21 @@ dri2_allocate_textures(struct dri_context *ctx,
          whandle.stride = buf->pitch;
          whandle.offset = 0;
          whandle.modifier = DRM_FORMAT_MOD_INVALID;
          if (screen->can_share_buffer)
             whandle.type = WINSYS_HANDLE_TYPE_SHARED;
          else
             whandle.type = WINSYS_HANDLE_TYPE_KMS;
          drawable->textures[statt] =
             screen->base.screen->resource_from_handle(screen->base.screen,
                   &templ, &whandle,
-                  PIPE_HANDLE_USAGE_EXPLICIT_FLUSH | PIPE_HANDLE_USAGE_READ);
+                  PIPE_HANDLE_USAGE_EXPLICIT_FLUSH);
          assert(drawable->textures[statt]);
       }
    }
 
    /* Allocate private MSAA colorbuffers. */
    if (drawable->stvis.samples > 1) {
       for (i = 0; i < statts_count; i++) {
          enum st_attachment_type statt = statts[i];
 
          if (statt == ST_ATTACHMENT_DEPTH_STENCIL)
@@ -1060,21 +1060,21 @@ dri2_create_image_from_winsys(__DRIscreen *_screen,
       case 2:
          templ.width0 = width / 2;
          templ.height0 = height / 2;
          templ.format = PIPE_FORMAT_R8_UNORM;
          break;
       default:
          unreachable("too many planes!");
       }
 
       tex = pscreen->resource_from_handle(pscreen,
-            &templ, &whandle[i], PIPE_HANDLE_USAGE_READ_WRITE);
+            &templ, &whandle[i], PIPE_HANDLE_USAGE_FRAMEBUFFER_WRITE);
       if (!tex) {
          pipe_resource_reference(&img->texture, NULL);
          FREE(img);
          return NULL;
       }
 
       tex->next = img->texture;
       img->texture = tex;
    }
 
@@ -1280,23 +1280,23 @@ dri2_create_image_with_modifiers(__DRIscreen *dri_screen,
                                    loaderPrivate);
 }
 
 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;
+      usage = PIPE_HANDLE_USAGE_EXPLICIT_FLUSH;
    else
-      usage = PIPE_HANDLE_USAGE_READ_WRITE;
+      usage = PIPE_HANDLE_USAGE_FRAMEBUFFER_WRITE;
 
    memset(&whandle, 0, sizeof(whandle));
 
    switch (attrib) {
    case __DRI_IMAGE_ATTRIB_STRIDE:
       whandle.type = WINSYS_HANDLE_TYPE_KMS;
       if (!image->texture->screen->resource_get_handle(image->texture->screen,
             NULL, image->texture, &whandle, usage))
          return GL_FALSE;
       *value = whandle.stride;
@@ -1959,28 +1959,26 @@ dri2_interop_export_object(__DRIcontext *_ctx,
          out->internal_format = obj->Image[0][0]->InternalFormat;
          out->view_minlevel = obj->MinLevel;
          out->view_numlevels = obj->NumLevels;
          out->view_minlayer = obj->MinLayer;
          out->view_numlayers = obj->NumLayers;
       }
    }
 
    /* Get the handle. */
    switch (in->access) {
-   case MESA_GLINTEROP_ACCESS_READ_WRITE:
-      usage = PIPE_HANDLE_USAGE_READ_WRITE;
-      break;
    case MESA_GLINTEROP_ACCESS_READ_ONLY:
-      usage = PIPE_HANDLE_USAGE_READ;
+      usage = 0;
       break;
+   case MESA_GLINTEROP_ACCESS_READ_WRITE:
    case MESA_GLINTEROP_ACCESS_WRITE_ONLY:
-      usage = PIPE_HANDLE_USAGE_WRITE;
+      usage = PIPE_HANDLE_USAGE_SHADER_WRITE;
       break;
    default:
       usage = 0;
    }
 
    memset(&whandle, 0, sizeof(whandle));
    whandle.type = WINSYS_HANDLE_TYPE_FD;
 
    success = screen->resource_get_handle(screen, st->pipe, res, &whandle,
                                          usage);
diff --git a/src/gallium/state_trackers/dri/drisw.c b/src/gallium/state_trackers/dri/drisw.c
index 1fba71bdd97..886f94dc02c 100644
--- a/src/gallium/state_trackers/dri/drisw.c
+++ b/src/gallium/state_trackers/dri/drisw.c
@@ -122,21 +122,21 @@ get_image_shm(__DRIdrawable *dPriv, int x, int y, int width, int height,
 {
    __DRIscreen *sPriv = dPriv->driScreenPriv;
    const __DRIswrastLoaderExtension *loader = sPriv->swrast_loader;
    struct winsys_handle whandle;
 
    whandle.type = WINSYS_HANDLE_TYPE_SHMID;
 
    if (loader->base.version < 4 || !loader->getImageShm)
       return FALSE;
 
-   if (!res->screen->resource_get_handle(res->screen, NULL, res, &whandle, PIPE_HANDLE_USAGE_WRITE))
+   if (!res->screen->resource_get_handle(res->screen, NULL, res, &whandle, PIPE_HANDLE_USAGE_FRAMEBUFFER_WRITE))
       return FALSE;
 
    loader->getImageShm(dPriv, x, y, width, height, whandle.handle, dPriv->loaderPrivate);
    return TRUE;
 }
 
 static void
 drisw_update_drawable_info(struct dri_drawable *drawable)
 {
    __DRIdrawable *dPriv = drawable->dPriv;
diff --git a/src/gallium/state_trackers/nine/swapchain9.c b/src/gallium/state_trackers/nine/swapchain9.c
index aa485a6268b..0f6a8b9cbc9 100644
--- a/src/gallium/state_trackers/nine/swapchain9.c
+++ b/src/gallium/state_trackers/nine/swapchain9.c
@@ -93,23 +93,22 @@ D3DWindowBuffer_create(struct NineSwapChain9 *This,
     struct pipe_context *pipe = nine_context_get_pipe_acquire(This->base.device);
     struct winsys_handle whandle;
     int stride, dmaBufFd;
     HRESULT hr;
 
     memset(&whandle, 0, sizeof(whandle));
     whandle.type = WINSYS_HANDLE_TYPE_FD;
     This->screen->resource_get_handle(This->screen, pipe, resource,
                                       &whandle,
                                       for_frontbuffer_reading ?
-                                          PIPE_HANDLE_USAGE_WRITE :
-                                          PIPE_HANDLE_USAGE_EXPLICIT_FLUSH |
-                                          PIPE_HANDLE_USAGE_READ);
+                                          PIPE_HANDLE_USAGE_FRAMEBUFFER_WRITE :
+                                          PIPE_HANDLE_USAGE_EXPLICIT_FLUSH);
     nine_context_get_pipe_release(This->base.device);
     stride = whandle.stride;
     dmaBufFd = whandle.handle;
     hr = ID3DPresent_NewD3DWindowBufferFromDmaBuf(This->present,
                                                   dmaBufFd,
                                                   resource->width0,
                                                   resource->height0,
                                                   stride,
                                                   depth,
                                                   32,
diff --git a/src/gallium/state_trackers/va/buffer.c b/src/gallium/state_trackers/va/buffer.c
index 42ec9730fc1..0691b7023b2 100644
--- a/src/gallium/state_trackers/va/buffer.c
+++ b/src/gallium/state_trackers/va/buffer.c
@@ -302,21 +302,21 @@ vlVaAcquireBufferHandle(VADriverContextP ctx, VABufferID buf_id,
          struct winsys_handle whandle;
 
          mtx_lock(&drv->mutex);
          drv->pipe->flush(drv->pipe, NULL, 0);
 
          memset(&whandle, 0, sizeof(whandle));
          whandle.type = WINSYS_HANDLE_TYPE_FD;
 
          if (!screen->resource_get_handle(screen, drv->pipe,
                                           buf->derived_surface.resource,
-                                          &whandle, PIPE_HANDLE_USAGE_READ_WRITE)) {
+                                          &whandle, PIPE_HANDLE_USAGE_FRAMEBUFFER_WRITE)) {
             mtx_unlock(&drv->mutex);
             return VA_STATUS_ERROR_INVALID_BUFFER;
          }
 
          mtx_unlock(&drv->mutex);
 
          buf_info->handle = (intptr_t)whandle.handle;
          break;
       }
       default:
diff --git a/src/gallium/state_trackers/va/surface.c b/src/gallium/state_trackers/va/surface.c
index cc26efe1c1a..5376be28531 100644
--- a/src/gallium/state_trackers/va/surface.c
+++ b/src/gallium/state_trackers/va/surface.c
@@ -576,21 +576,21 @@ surface_from_external_memory(VADriverContextP ctx, vlVaSurface *surface,
    for (i = 0; i < memory_attribute->num_planes; i++) {
       res_templ.format = resource_formats[i];
       if (res_templ.format == PIPE_FORMAT_NONE) {
          result = VA_STATUS_ERROR_INVALID_PARAMETER;
          goto fail;
       }
 
       whandle.stride = memory_attribute->pitches[i];
       whandle.offset = memory_attribute->offsets[i];
       resources[i] = pscreen->resource_from_handle(pscreen, &res_templ, &whandle,
-                                                   PIPE_HANDLE_USAGE_READ_WRITE);
+                                                   PIPE_HANDLE_USAGE_FRAMEBUFFER_WRITE);
       if (!resources[i]) {
          result = VA_STATUS_ERROR_ALLOCATION_FAILED;
          goto fail;
       }
    }
 
    surface->buffer = vl_video_buffer_create_ex2(drv->pipe, templat, resources);
    if (!surface->buffer) {
       result = VA_STATUS_ERROR_ALLOCATION_FAILED;
       goto fail;
@@ -993,24 +993,22 @@ vlVaExportSurfaceHandle(VADriverContextP ctx,
                                    interlaced, surf->buffer,
                                    &src_rect, &dst_rect,
                                    VL_COMPOSITOR_WEAVE);
 
       interlaced->destroy(interlaced);
    }
 
    surfaces = surf->buffer->get_surfaces(surf->buffer);
 
    usage = 0;
-   if (flags & VA_EXPORT_SURFACE_READ_ONLY)
-      usage |= PIPE_HANDLE_USAGE_READ;
    if (flags & VA_EXPORT_SURFACE_WRITE_ONLY)
-      usage |= PIPE_HANDLE_USAGE_WRITE;
+      usage |= PIPE_HANDLE_USAGE_FRAMEBUFFER_WRITE;
 
    desc->fourcc = PipeFormatToVaFourcc(surf->buffer->buffer_format);
    desc->width  = surf->buffer->width;
    desc->height = surf->buffer->height;
 
    for (p = 0; p < VL_MAX_SURFACES; p++) {
       struct winsys_handle whandle;
       struct pipe_resource *resource;
       uint32_t drm_format;
 
diff --git a/src/gallium/state_trackers/vdpau/output.c b/src/gallium/state_trackers/vdpau/output.c
index 878a3546727..1f873daa814 100644
--- a/src/gallium/state_trackers/vdpau/output.c
+++ b/src/gallium/state_trackers/vdpau/output.c
@@ -804,21 +804,21 @@ VdpStatus vlVdpOutputSurfaceDMABuf(VdpOutputSurface surface,
 
    mtx_lock(&vlsurface->device->mutex);
    vlsurface->device->context->flush(vlsurface->device->context, NULL, 0);
 
    memset(&whandle, 0, sizeof(struct winsys_handle));
    whandle.type = WINSYS_HANDLE_TYPE_FD;
 
    pscreen = vlsurface->surface->texture->screen;
    if (!pscreen->resource_get_handle(pscreen, vlsurface->device->context,
                                      vlsurface->surface->texture, &whandle,
-                                     PIPE_HANDLE_USAGE_READ_WRITE)) {
+                                     PIPE_HANDLE_USAGE_FRAMEBUFFER_WRITE)) {
       mtx_unlock(&vlsurface->device->mutex);
       return VDP_STATUS_NO_IMPLEMENTATION;
    }
 
    mtx_unlock(&vlsurface->device->mutex);
 
    result->handle = whandle.handle;
    result->width = vlsurface->surface->width;
    result->height = vlsurface->surface->height;
    result->offset = whandle.offset;
diff --git a/src/gallium/state_trackers/vdpau/surface.c b/src/gallium/state_trackers/vdpau/surface.c
index 95bab8790db..e9d55a282e2 100644
--- a/src/gallium/state_trackers/vdpau/surface.c
+++ b/src/gallium/state_trackers/vdpau/surface.c
@@ -525,21 +525,21 @@ VdpStatus vlVdpVideoSurfaceDMABuf(VdpVideoSurface surface,
       return VDP_STATUS_RESOURCES;
    }
 
    memset(&whandle, 0, sizeof(struct winsys_handle));
    whandle.type = WINSYS_HANDLE_TYPE_FD;
    whandle.layer = surf->u.tex.first_layer;
 
    pscreen = surf->texture->screen;
    if (!pscreen->resource_get_handle(pscreen, p_surf->device->context,
                                      surf->texture, &whandle,
-                                     PIPE_HANDLE_USAGE_READ_WRITE)) {
+                                     PIPE_HANDLE_USAGE_FRAMEBUFFER_WRITE)) {
       mtx_unlock(&p_surf->device->mutex);
       return VDP_STATUS_NO_IMPLEMENTATION;
    }
 
    mtx_unlock(&p_surf->device->mutex);
 
    result->handle = whandle.handle;
    result->width = surf->width;
    result->height = surf->height;
    result->offset = whandle.offset;
diff --git a/src/gallium/state_trackers/xa/xa_tracker.c b/src/gallium/state_trackers/xa/xa_tracker.c
index d07cd146af9..5ac98f8eed0 100644
--- a/src/gallium/state_trackers/xa/xa_tracker.c
+++ b/src/gallium/state_trackers/xa/xa_tracker.c
@@ -351,21 +351,21 @@ surface_create(struct xa_tracker *xa,
 
     if (flags & XA_FLAG_SHARED)
 	template->bind |= PIPE_BIND_SHARED;
     if (flags & XA_FLAG_RENDER_TARGET)
 	template->bind |= PIPE_BIND_RENDER_TARGET;
     if (flags & XA_FLAG_SCANOUT)
 	template->bind |= PIPE_BIND_SCANOUT;
 
     if (whandle)
 	srf->tex = xa->screen->resource_from_handle(xa->screen, template, whandle,
-                                                    PIPE_HANDLE_USAGE_READ_WRITE);
+                                                    PIPE_HANDLE_USAGE_FRAMEBUFFER_WRITE);
     else
 	srf->tex = xa->screen->resource_create(xa->screen, template);
     if (!srf->tex)
 	goto out_no_tex;
 
     srf->refcount = 1;
     srf->xa = xa;
     srf->flags = flags;
     srf->fdesc = fdesc;
 
@@ -539,21 +539,21 @@ xa_surface_handle(struct xa_surface *srf,
 {
     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->xa->default_ctx->pipe,
                                       srf->tex, &whandle,
-                                      PIPE_HANDLE_USAGE_READ_WRITE);
+                                      PIPE_HANDLE_USAGE_FRAMEBUFFER_WRITE);
     if (!res)
 	return -XA_ERR_INVAL;
 
     *handle = whandle.handle;
     *stride = whandle.stride;
 
     return XA_ERR_NONE;
 }
 
 XA_EXPORT enum xa_formats
diff --git a/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c b/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c
index c5370c7a1b2..31b00e87321 100644
--- a/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c
+++ b/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c
@@ -179,38 +179,38 @@ wsw_dt_create(struct sw_winsys *ws,
 static struct sw_displaytarget *
 wsw_dt_from_handle(struct sw_winsys *ws,
                    const struct pipe_resource *templ,
                    struct winsys_handle *whandle,
                    unsigned *stride)
 {
    struct wrapper_sw_winsys *wsw = wrapper_sw_winsys(ws);
    struct pipe_resource *tex;
 
    tex = wsw->screen->resource_from_handle(wsw->screen, templ, whandle,
-                                           PIPE_HANDLE_USAGE_READ_WRITE);
+                                           PIPE_HANDLE_USAGE_FRAMEBUFFER_WRITE);
    if (!tex)
       return NULL;
 
    return wsw_dt_wrap_texture(wsw, tex, stride);
 }
 
 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, NULL, tex, whandle,
-                                           PIPE_HANDLE_USAGE_READ_WRITE);
+                                           PIPE_HANDLE_USAGE_FRAMEBUFFER_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;
    struct pipe_resource *tex = wdt->tex;
diff --git a/src/mesa/state_tracker/st_vdpau.c b/src/mesa/state_tracker/st_vdpau.c
index d0b9cfbf4f8..bfc6adf7f77 100644
--- a/src/mesa/state_tracker/st_vdpau.c
+++ b/src/mesa/state_tracker/st_vdpau.c
@@ -126,21 +126,21 @@ st_vdpau_resource_from_description(struct gl_context *ctx,
    templ.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET;
    templ.usage = PIPE_USAGE_DEFAULT;
 
    memset(&whandle, 0, sizeof(whandle));
    whandle.type = WINSYS_HANDLE_TYPE_FD;
    whandle.handle = desc->handle;
    whandle.offset = desc->offset;
    whandle.stride = desc->stride;
 
    res = st->pipe->screen->resource_from_handle(st->pipe->screen, &templ, &whandle,
-						PIPE_HANDLE_USAGE_READ_WRITE);
+						PIPE_HANDLE_USAGE_FRAMEBUFFER_WRITE);
    close(desc->handle);
 
    return res;
 }
 
 static struct pipe_resource *
 st_vdpau_output_surface_dma_buf(struct gl_context *ctx, const void *vdpSurface)
 {
    int (*getProcAddr)(uint32_t device, uint32_t id, void **ptr);
    uint32_t device = (uintptr_t)ctx->vdpDevice;
-- 
2.17.1



More information about the mesa-dev mailing list