gallium: rework PIPE_HANDLE_USAGE_* flags
authorMarek Olšák <marek.olsak@amd.com>
Thu, 25 Oct 2018 19:33:00 +0000 (15:33 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 30 Oct 2018 20:03:02 +0000 (16:03 -0400)
Only radeonsi uses them, so adjust them to match its needs.

18 files changed:
src/gallium/auxiliary/renderonly/renderonly.c
src/gallium/auxiliary/vl/vl_winsys_dri.c
src/gallium/auxiliary/vl/vl_winsys_dri3.c
src/gallium/drivers/etnaviv/etnaviv_resource.c
src/gallium/drivers/r600/r600_texture.c
src/gallium/drivers/radeonsi/si_texture.c
src/gallium/drivers/tegra/tegra_screen.c
src/gallium/include/pipe/p_defines.h
src/gallium/state_trackers/dri/dri2.c
src/gallium/state_trackers/dri/drisw.c
src/gallium/state_trackers/nine/swapchain9.c
src/gallium/state_trackers/va/buffer.c
src/gallium/state_trackers/va/surface.c
src/gallium/state_trackers/vdpau/output.c
src/gallium/state_trackers/vdpau/surface.c
src/gallium/state_trackers/xa/xa_tracker.c
src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c
src/mesa/state_tracker/st_vdpau.c

index f83910a94041fd8cca9ac369233711c4d1bf8912..d6a344009378f6cec7d830bef05e242e1ee705d8 100644 (file)
@@ -138,7 +138,7 @@ renderonly_create_gpu_import_for_resource(struct pipe_resource *rsc,
       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;
 
index 137885d9475e5a14aab19048f1c74345daf70239..1905516a761acf97ad986f4bbf26595760c75d14 100644 (file)
@@ -249,7 +249,7 @@ vl_dri2_screen_texture_from_drawable(struct vl_screen *vscreen, void *drawable)
 
    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;
index d6a1ec0bfdd50f855c687c8c54e3e801103c56fc..152d28e59fc0b13730aec54edf26f761812e880e 100644 (file)
@@ -272,7 +272,7 @@ dri3_alloc_back_buffer(struct vl_dri3_screen *scrn)
    }
    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);
@@ -507,7 +507,7 @@ dri3_get_front_buffer(struct vl_dri3_screen *scrn)
    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;
index 7fd374ae23d5ee781d13caa878c705744fada499..3808c293e6e6d77af2c83cfdce51874bd6b74517 100644 (file)
@@ -254,7 +254,7 @@ etna_resource_alloc(struct pipe_screen *pscreen, unsigned layout,
       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;
index d08c6e5637cdd0415799fabfad72ec5d5396ab3f..def4cbf86b23f0e5f2e0fab7b8f07eb111d8d199 100644 (file)
@@ -1942,7 +1942,7 @@ r600_texture_from_memobj(struct pipe_screen *screen,
        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);
index bcff226a5868ffdcc6f7e614d9ad205acc291a91..2fb79253a72dc746bca4de90d1973517de81d02a 100644 (file)
@@ -445,7 +445,7 @@ 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,
@@ -763,7 +763,7 @@ static boolean si_texture_get_handle(struct pipe_screen* screen,
                 * 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 */
@@ -2373,7 +2373,8 @@ si_texture_from_memobj(struct pipe_screen *screen,
        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;
index 243bdde8d2c5729f7a1038ffa7ef1c9ee3c49618..1051c167189f85ab669e5883ca0902fc2f314cea 100644 (file)
@@ -167,7 +167,6 @@ tegra_screen_can_create_resource(struct pipe_screen *pscreen,
 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;
@@ -177,7 +176,7 @@ static int tegra_screen_import_resource(struct tegra_screen *screen,
    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;
 
index c58f165962548800ff4ece78bf4f30a5e29dd0fa..dacedf5b936473ec522be86300d32ee86757c69e 100644 (file)
@@ -621,12 +621,10 @@ enum pipe_conservative_raster_mode
  * 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.
index 2fb3e59284490697a0eff4adcae0525d5533096c..a09787bb2155d7483b26aa05c5ded3f18b0c1418 100644 (file)
@@ -651,7 +651,7 @@ dri2_allocate_buffer(__DRIscreen *sPriv,
 
    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;
@@ -839,7 +839,7 @@ dri2_allocate_textures(struct dri_context *ctx,
          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]);
       }
    }
@@ -1067,7 +1067,7 @@ dri2_create_image_from_winsys(__DRIscreen *_screen,
       }
 
       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);
@@ -1287,9 +1287,9 @@ dri2_query_image(__DRIimage *image, int attrib, int *value)
    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));
 
@@ -1966,14 +1966,12 @@ dri2_interop_export_object(__DRIcontext *_ctx,
 
    /* 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;
index 1fba71bdd9737687cc75c4b22feb1fdd96dbe514..886f94dc02c2f6df5772e859d5713158a2217ee9 100644 (file)
@@ -129,7 +129,7 @@ get_image_shm(__DRIdrawable *dPriv, int x, int y, int width, int height,
    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);
index cd77081e915891056a637e883e087e6cd485ccdd..0958a907013e164ae432ef925e81cd3dcb7b9746 100644 (file)
@@ -100,9 +100,8 @@ D3DWindowBuffer_create(struct NineSwapChain9 *This,
     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;
index 42ec9730fc1ece54a1392c4b62121b2c41f4073e..0691b7023b21239444f37723ab5f678a9c1d625c 100644 (file)
@@ -309,7 +309,7 @@ vlVaAcquireBufferHandle(VADriverContextP ctx, VABufferID buf_id,
 
          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;
          }
index cc26efe1c1a66b214ed0e3977d2b6790cc46bafa..5376be28531adeb6be067d13ffa13b4d41701cf1 100644 (file)
@@ -583,7 +583,7 @@ surface_from_external_memory(VADriverContextP ctx, vlVaSurface *surface,
       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;
@@ -1000,10 +1000,8 @@ vlVaExportSurfaceHandle(VADriverContextP ctx,
    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;
index 878a35467270af4b95e7b0a26fdea1d8c9c3c61b..1f873daa8144ebb4e3d7972926670dddf897c149 100644 (file)
@@ -811,7 +811,7 @@ VdpStatus vlVdpOutputSurfaceDMABuf(VdpOutputSurface surface,
    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;
    }
index 95bab8790dba602f8baccd33719473d26f2ce9c0..e9d55a282e218ecd6ef8e1ea0fcd4e640b7539e3 100644 (file)
@@ -532,7 +532,7 @@ VdpStatus vlVdpVideoSurfaceDMABuf(VdpVideoSurface surface,
    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;
    }
index d07cd146af93bca5b79164ca4feb1142ec3e97de..5ac98f8eed0b2749e360ff9753cdd2026ca3a8bc 100644 (file)
@@ -358,7 +358,7 @@ surface_create(struct xa_tracker *xa,
 
     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)
@@ -546,7 +546,7 @@ xa_surface_handle(struct xa_surface *srf,
     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;
 
index c5370c7a1b2641fb5ace8c63e919781c57ddb9ae..31b00e873218d6b759f8eff6e844b637849db266 100644 (file)
@@ -186,7 +186,7 @@ wsw_dt_from_handle(struct 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;
 
@@ -203,7 +203,7 @@ wsw_dt_get_handle(struct sw_winsys *ws,
    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 *
index d0b9cfbf4f84061d00da86b544ead44f3f178a7e..bfc6adf7f77fe7eb3d23982200ae1bad3f75b730 100644 (file)
@@ -133,7 +133,7 @@ st_vdpau_resource_from_description(struct gl_context *ctx,
    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;