summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2018-10-25 15:33:00 -0400
committerMarek Olšák <[email protected]>2018-10-30 16:03:02 -0400
commit8ad12c8bec4bd20ea4241e412b477a155a42186b (patch)
tree4155600e79320d788e4f1df43e2b9230b5f67684
parent00fc56a68d21d7aa91b95f0eaacba59a96c466f5 (diff)
gallium: rework PIPE_HANDLE_USAGE_* flags
Only radeonsi uses them, so adjust them to match its needs.
-rw-r--r--src/gallium/auxiliary/renderonly/renderonly.c2
-rw-r--r--src/gallium/auxiliary/vl/vl_winsys_dri.c2
-rw-r--r--src/gallium/auxiliary/vl/vl_winsys_dri3.c4
-rw-r--r--src/gallium/drivers/etnaviv/etnaviv_resource.c2
-rw-r--r--src/gallium/drivers/r600/r600_texture.c2
-rw-r--r--src/gallium/drivers/radeonsi/si_texture.c7
-rw-r--r--src/gallium/drivers/tegra/tegra_screen.c3
-rw-r--r--src/gallium/include/pipe/p_defines.h8
-rw-r--r--src/gallium/state_trackers/dri/dri2.c18
-rw-r--r--src/gallium/state_trackers/dri/drisw.c2
-rw-r--r--src/gallium/state_trackers/nine/swapchain9.c5
-rw-r--r--src/gallium/state_trackers/va/buffer.c2
-rw-r--r--src/gallium/state_trackers/va/surface.c6
-rw-r--r--src/gallium/state_trackers/vdpau/output.c2
-rw-r--r--src/gallium/state_trackers/vdpau/surface.c2
-rw-r--r--src/gallium/state_trackers/xa/xa_tracker.c4
-rw-r--r--src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c4
-rw-r--r--src/mesa/state_tracker/st_vdpau.c2
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
@@ -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;
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
@@ -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;
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
@@ -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;
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
@@ -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;
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
@@ -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);
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
@@ -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;
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
@@ -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;
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
@@ -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.
diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c
index 2fb3e592844..a09787bb215 100644
--- a/src/gallium/state_trackers/dri/dri2.c
+++ b/src/gallium/state_trackers/dri/dri2.c
@@ -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;
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
@@ -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);
diff --git a/src/gallium/state_trackers/nine/swapchain9.c b/src/gallium/state_trackers/nine/swapchain9.c
index cd77081e915..0958a907013 100644
--- a/src/gallium/state_trackers/nine/swapchain9.c
+++ b/src/gallium/state_trackers/nine/swapchain9.c
@@ -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;
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
@@ -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;
}
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
@@ -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;
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
@@ -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;
}
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
@@ -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;
}
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
@@ -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;
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
@@ -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 *
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
@@ -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;