[Mesa-dev] [PATCH 2/2] gallium: add usage flags to resource_from_handle
Marek Olšák
maraeo at gmail.com
Wed Feb 24 23:10:08 UTC 2016
From: Marek Olšák <marek.olsak at amd.com>
These are the same flags as for resource_get_handle.
---
src/gallium/auxiliary/vl/vl_winsys_dri.c | 3 ++-
src/gallium/drivers/ddebug/dd_screen.c | 5 +++--
src/gallium/drivers/freedreno/freedreno_resource.c | 3 ++-
src/gallium/drivers/i915/i915_resource.c | 3 ++-
src/gallium/drivers/ilo/ilo_resource.c | 3 ++-
src/gallium/drivers/llvmpipe/lp_texture.c | 3 ++-
src/gallium/drivers/noop/noop_pipe.c | 5 +++--
src/gallium/drivers/nouveau/nv30/nv30_resource.c | 3 ++-
src/gallium/drivers/nouveau/nv50/nv50_resource.c | 3 ++-
src/gallium/drivers/nouveau/nvc0/nvc0_resource.c | 3 ++-
src/gallium/drivers/r300/r300_texture.c | 3 ++-
src/gallium/drivers/r300/r300_texture.h | 3 ++-
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/svga/svga_resource.c | 3 ++-
src/gallium/drivers/trace/tr_screen.c | 5 +++--
src/gallium/drivers/vc4/vc4_resource.c | 3 ++-
src/gallium/drivers/virgl/virgl_resource.c | 3 ++-
src/gallium/include/pipe/p_screen.h | 3 ++-
src/gallium/state_trackers/dri/dri2.c | 4 ++--
src/gallium/state_trackers/va/surface.c | 3 ++-
src/gallium/state_trackers/xa/xa_tracker.c | 3 ++-
src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c | 3 ++-
24 files changed, 52 insertions(+), 29 deletions(-)
diff --git a/src/gallium/auxiliary/vl/vl_winsys_dri.c b/src/gallium/auxiliary/vl/vl_winsys_dri.c
index 758f50d..cf6ad8e 100644
--- a/src/gallium/auxiliary/vl/vl_winsys_dri.c
+++ b/src/gallium/auxiliary/vl/vl_winsys_dri.c
@@ -248,7 +248,8 @@ vl_dri2_screen_texture_from_drawable(struct vl_screen *vscreen, void *drawable)
template.flags = 0;
tex = scrn->base.pscreen->resource_from_handle(scrn->base.pscreen, &template,
- &dri2_handle);
+ &dri2_handle,
+ PIPE_HANDLE_USAGE_COHERENT);
free(reply);
return tex;
diff --git a/src/gallium/drivers/ddebug/dd_screen.c b/src/gallium/drivers/ddebug/dd_screen.c
index a5bbdd0..2867f0b 100644
--- a/src/gallium/drivers/ddebug/dd_screen.c
+++ b/src/gallium/drivers/ddebug/dd_screen.c
@@ -179,11 +179,12 @@ dd_screen_resource_create(struct pipe_screen *_screen,
static struct pipe_resource *
dd_screen_resource_from_handle(struct pipe_screen *_screen,
const struct pipe_resource *templ,
- struct winsys_handle *handle)
+ struct winsys_handle *handle,
+ enum pipe_handle_usage usage)
{
struct pipe_screen *screen = dd_screen(_screen)->screen;
struct pipe_resource *res =
- screen->resource_from_handle(screen, templ, handle);
+ screen->resource_from_handle(screen, templ, handle, usage);
if (!res)
return NULL;
diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c b/src/gallium/drivers/freedreno/freedreno_resource.c
index bcdd518..9dc57ec 100644
--- a/src/gallium/drivers/freedreno/freedreno_resource.c
+++ b/src/gallium/drivers/freedreno/freedreno_resource.c
@@ -637,7 +637,8 @@ fail:
static struct pipe_resource *
fd_resource_from_handle(struct pipe_screen *pscreen,
const struct pipe_resource *tmpl,
- struct winsys_handle *handle)
+ struct winsys_handle *handle,
+ enum pipe_handle_usage usage)
{
struct fd_resource *rsc = CALLOC_STRUCT(fd_resource);
struct fd_resource_slice *slice = &rsc->slices[0];
diff --git a/src/gallium/drivers/i915/i915_resource.c b/src/gallium/drivers/i915/i915_resource.c
index 627ed2b..7075f86 100644
--- a/src/gallium/drivers/i915/i915_resource.c
+++ b/src/gallium/drivers/i915/i915_resource.c
@@ -23,7 +23,8 @@ i915_resource_create(struct pipe_screen *screen,
static struct pipe_resource *
i915_resource_from_handle(struct pipe_screen * screen,
const struct pipe_resource *template,
- struct winsys_handle *whandle)
+ struct winsys_handle *whandle,
+ enum pipe_handle_usage usage)
{
if (template->target == PIPE_BUFFER)
return NULL;
diff --git a/src/gallium/drivers/ilo/ilo_resource.c b/src/gallium/drivers/ilo/ilo_resource.c
index a6f63e1..546441f 100644
--- a/src/gallium/drivers/ilo/ilo_resource.c
+++ b/src/gallium/drivers/ilo/ilo_resource.c
@@ -714,7 +714,8 @@ ilo_resource_create(struct pipe_screen *screen,
static struct pipe_resource *
ilo_resource_from_handle(struct pipe_screen *screen,
const struct pipe_resource *templ,
- struct winsys_handle *handle)
+ struct winsys_handle *handle,
+ enum pipe_handle_usage usage)
{
if (templ->target == PIPE_BUFFER)
return NULL;
diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c
index b3e4650..a70d969 100644
--- a/src/gallium/drivers/llvmpipe/lp_texture.c
+++ b/src/gallium/drivers/llvmpipe/lp_texture.c
@@ -434,7 +434,8 @@ llvmpipe_resource_data(struct pipe_resource *resource)
static struct pipe_resource *
llvmpipe_resource_from_handle(struct pipe_screen *screen,
const struct pipe_resource *template,
- 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;
diff --git a/src/gallium/drivers/noop/noop_pipe.c b/src/gallium/drivers/noop/noop_pipe.c
index bdd4ccc..bf23b0c 100644
--- a/src/gallium/drivers/noop/noop_pipe.c
+++ b/src/gallium/drivers/noop/noop_pipe.c
@@ -114,14 +114,15 @@ static struct pipe_resource *noop_resource_create(struct pipe_screen *screen,
static struct pipe_resource *noop_resource_from_handle(struct pipe_screen *screen,
const struct pipe_resource *templ,
- struct winsys_handle *handle)
+ struct winsys_handle *handle,
+ enum pipe_handle_usage usage)
{
struct noop_pipe_screen *noop_screen = (struct noop_pipe_screen*)screen;
struct pipe_screen *oscreen = noop_screen->oscreen;
struct pipe_resource *result;
struct pipe_resource *noop_resource;
- result = oscreen->resource_from_handle(oscreen, templ, handle);
+ result = oscreen->resource_from_handle(oscreen, templ, handle, usage);
noop_resource = noop_resource_create(screen, result);
pipe_resource_reference(&result, NULL);
return noop_resource;
diff --git a/src/gallium/drivers/nouveau/nv30/nv30_resource.c b/src/gallium/drivers/nouveau/nv30/nv30_resource.c
index a98a646..9775535 100644
--- a/src/gallium/drivers/nouveau/nv30/nv30_resource.c
+++ b/src/gallium/drivers/nouveau/nv30/nv30_resource.c
@@ -66,7 +66,8 @@ nv30_resource_create(struct pipe_screen *pscreen,
static struct pipe_resource *
nv30_resource_from_handle(struct pipe_screen *pscreen,
const struct pipe_resource *tmpl,
- struct winsys_handle *handle)
+ struct winsys_handle *handle,
+ enum pipe_handle_usage usage)
{
if (tmpl->target == PIPE_BUFFER)
return NULL;
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_resource.c b/src/gallium/drivers/nouveau/nv50/nv50_resource.c
index 5d415ae7..35b09be 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_resource.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_resource.c
@@ -22,7 +22,8 @@ nv50_resource_create(struct pipe_screen *screen,
static struct pipe_resource *
nv50_resource_from_handle(struct pipe_screen * screen,
const struct pipe_resource *templ,
- struct winsys_handle *whandle)
+ struct winsys_handle *whandle,
+ enum pipe_handle_usage usage)
{
if (templ->target == PIPE_BUFFER)
return NULL;
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_resource.c b/src/gallium/drivers/nouveau/nvc0/nvc0_resource.c
index 7fbc6e1..4413384 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_resource.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_resource.c
@@ -19,7 +19,8 @@ nvc0_resource_create(struct pipe_screen *screen,
static struct pipe_resource *
nvc0_resource_from_handle(struct pipe_screen * screen,
const struct pipe_resource *templ,
- struct winsys_handle *whandle)
+ struct winsys_handle *whandle,
+ enum pipe_handle_usage usage)
{
if (templ->target == PIPE_BUFFER) {
return NULL;
diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c
index 27f8277..3d873ce 100644
--- a/src/gallium/drivers/r300/r300_texture.c
+++ b/src/gallium/drivers/r300/r300_texture.c
@@ -1099,7 +1099,8 @@ struct pipe_resource *r300_texture_create(struct pipe_screen *screen,
struct pipe_resource *r300_texture_from_handle(struct pipe_screen *screen,
const struct pipe_resource *base,
- struct winsys_handle *whandle)
+ struct winsys_handle *whandle,
+ enum pipe_handle_usage usage)
{
struct r300_screen *rscreen = r300_screen(screen);
struct radeon_winsys *rws = rscreen->rws;
diff --git a/src/gallium/drivers/r300/r300_texture.h b/src/gallium/drivers/r300/r300_texture.h
index a8117a3..5b80839 100644
--- a/src/gallium/drivers/r300/r300_texture.h
+++ b/src/gallium/drivers/r300/r300_texture.h
@@ -69,7 +69,8 @@ boolean r300_resource_get_handle(struct pipe_screen* screen,
struct pipe_resource*
r300_texture_from_handle(struct pipe_screen* screen,
const struct pipe_resource* base,
- struct winsys_handle *whandle);
+ struct winsys_handle *whandle,
+ enum pipe_handle_usage usage);
struct pipe_resource*
r300_texture_create(struct pipe_screen* screen,
diff --git a/src/gallium/drivers/radeon/r600_texture.c b/src/gallium/drivers/radeon/r600_texture.c
index b583d50..1d5296c 100644
--- a/src/gallium/drivers/radeon/r600_texture.c
+++ b/src/gallium/drivers/radeon/r600_texture.c
@@ -887,7 +887,8 @@ struct pipe_resource *r600_texture_create(struct pipe_screen *screen,
static struct pipe_resource *r600_texture_from_handle(struct pipe_screen *screen,
const struct pipe_resource *templ,
- struct winsys_handle *whandle)
+ struct winsys_handle *whandle,
+ enum pipe_handle_usage usage)
{
struct r600_common_screen *rscreen = (struct r600_common_screen*)screen;
struct pb_buffer *buf = NULL;
diff --git a/src/gallium/drivers/rbug/rbug_screen.c b/src/gallium/drivers/rbug/rbug_screen.c
index aee20df..cc76203 100644
--- a/src/gallium/drivers/rbug/rbug_screen.c
+++ b/src/gallium/drivers/rbug/rbug_screen.c
@@ -160,13 +160,14 @@ rbug_screen_resource_create(struct pipe_screen *_screen,
static struct pipe_resource *
rbug_screen_resource_from_handle(struct pipe_screen *_screen,
const struct pipe_resource *templ,
- struct winsys_handle *handle)
+ struct winsys_handle *handle,
+ enum pipe_handle_usage usage)
{
struct rbug_screen *rb_screen = rbug_screen(_screen);
struct pipe_screen *screen = rb_screen->screen;
struct pipe_resource *result;
- result = screen->resource_from_handle(screen, templ, handle);
+ result = screen->resource_from_handle(screen, templ, handle, usage);
result = rbug_resource_create(rbug_screen(_screen), result);
diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c
index b381562..0d1e410 100644
--- a/src/gallium/drivers/softpipe/sp_texture.c
+++ b/src/gallium/drivers/softpipe/sp_texture.c
@@ -218,7 +218,8 @@ softpipe_resource_destroy(struct pipe_screen *pscreen,
static struct pipe_resource *
softpipe_resource_from_handle(struct pipe_screen *screen,
const struct pipe_resource *templat,
- 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 = CALLOC_STRUCT(softpipe_resource);
diff --git a/src/gallium/drivers/svga/svga_resource.c b/src/gallium/drivers/svga/svga_resource.c
index 1c3bcd6..f3e47aa 100644
--- a/src/gallium/drivers/svga/svga_resource.c
+++ b/src/gallium/drivers/svga/svga_resource.c
@@ -47,7 +47,8 @@ svga_resource_create(struct pipe_screen *screen,
static struct pipe_resource *
svga_resource_from_handle(struct pipe_screen * screen,
const struct pipe_resource *template,
- struct winsys_handle *whandle)
+ struct winsys_handle *whandle,
+ enum pipe_handle_usage usage)
{
if (template->target == PIPE_BUFFER)
return NULL;
diff --git a/src/gallium/drivers/trace/tr_screen.c b/src/gallium/drivers/trace/tr_screen.c
index d1a10f8..a196197 100644
--- a/src/gallium/drivers/trace/tr_screen.c
+++ b/src/gallium/drivers/trace/tr_screen.c
@@ -313,7 +313,8 @@ trace_screen_resource_create(struct pipe_screen *_screen,
static struct pipe_resource *
trace_screen_resource_from_handle(struct pipe_screen *_screen,
const struct pipe_resource *templ,
- struct winsys_handle *handle)
+ struct winsys_handle *handle,
+ enum pipe_handle_usage usage)
{
struct trace_screen *tr_screen = trace_screen(_screen);
struct pipe_screen *screen = tr_screen->screen;
@@ -321,7 +322,7 @@ trace_screen_resource_from_handle(struct pipe_screen *_screen,
/* TODO trace call */
- result = screen->resource_from_handle(screen, templ, handle);
+ result = screen->resource_from_handle(screen, templ, handle, usage);
result = trace_resource_create(trace_screen(_screen), result);
diff --git a/src/gallium/drivers/vc4/vc4_resource.c b/src/gallium/drivers/vc4/vc4_resource.c
index 036da32..3e4f66f 100644
--- a/src/gallium/drivers/vc4/vc4_resource.c
+++ b/src/gallium/drivers/vc4/vc4_resource.c
@@ -523,7 +523,8 @@ fail:
static struct pipe_resource *
vc4_resource_from_handle(struct pipe_screen *pscreen,
const struct pipe_resource *tmpl,
- struct winsys_handle *handle)
+ struct winsys_handle *handle,
+ enum pipe_handle_usage usage)
{
struct vc4_resource *rsc = vc4_resource_setup(pscreen, tmpl);
struct pipe_resource *prsc = &rsc->base.b;
diff --git a/src/gallium/drivers/virgl/virgl_resource.c b/src/gallium/drivers/virgl/virgl_resource.c
index 0b2fc4e..3bb3a5d 100644
--- a/src/gallium/drivers/virgl/virgl_resource.c
+++ b/src/gallium/drivers/virgl/virgl_resource.c
@@ -64,7 +64,8 @@ static struct pipe_resource *virgl_resource_create(struct pipe_screen *screen,
static struct pipe_resource *virgl_resource_from_handle(struct pipe_screen *screen,
const struct pipe_resource *templ,
- struct winsys_handle *whandle)
+ struct winsys_handle *whandle,
+ enum pipe_handle_usage usage)
{
struct virgl_screen *vs = virgl_screen(screen);
if (templ->target == PIPE_BUFFER)
diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h
index b650672..7336561 100644
--- a/src/gallium/include/pipe/p_screen.h
+++ b/src/gallium/include/pipe/p_screen.h
@@ -185,7 +185,8 @@ struct pipe_screen {
*/
struct pipe_resource * (*resource_from_handle)(struct pipe_screen *,
const struct pipe_resource *templat,
- struct winsys_handle *handle);
+ struct winsys_handle *handle,
+ enum pipe_handle_usage usage);
/**
* Create a resource from user memory. This maps the user memory into
diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c
index 0c37da6..7298191 100644
--- a/src/gallium/state_trackers/dri/dri2.c
+++ b/src/gallium/state_trackers/dri/dri2.c
@@ -539,7 +539,7 @@ 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);
assert(drawable->textures[statt]);
}
}
@@ -756,7 +756,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_COHERENT);
if (!img->texture) {
FREE(img);
return NULL;
diff --git a/src/gallium/state_trackers/va/surface.c b/src/gallium/state_trackers/va/surface.c
index 84a9494..fcfa75b 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_COHERENT);
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 708fb2f..6d3b9a2 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_COHERENT);
else
srf->tex = xa->screen->resource_create(xa->screen, template);
if (!srf->tex)
diff --git a/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c b/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c
index 5fae986..a7ddd78e 100644
--- a/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c
+++ b/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c
@@ -185,7 +185,8 @@ wsw_dt_from_handle(struct sw_winsys *ws,
struct wrapper_sw_winsys *wsw = wrapper_sw_winsys(ws);
struct pipe_resource *tex;
- tex = wsw->screen->resource_from_handle(wsw->screen, templ, whandle);
+ tex = wsw->screen->resource_from_handle(wsw->screen, templ, whandle,
+ PIPE_HANDLE_USAGE_COHERENT);
if (!tex)
return NULL;
--
2.5.0
More information about the mesa-dev
mailing list