This is optional (and no CAP).
Implemented by radeonsi, ddebug, rbug, trace.
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
return screen->resource_get_handle(screen, pipe, resource, handle, usage);
}
+static bool
+dd_screen_check_resource_capability(struct pipe_screen *_screen,
+ struct pipe_resource *resource,
+ unsigned bind)
+{
+ struct pipe_screen *screen = dd_screen(_screen)->screen;
+
+ return screen->check_resource_capability(screen, resource, bind);
+}
+
/********************************************************************
* fence
dscreen->base.resource_from_handle = dd_screen_resource_from_handle;
SCR_INIT(resource_from_memobj);
SCR_INIT(resource_from_user_memory);
+ SCR_INIT(check_resource_capability);
dscreen->base.resource_get_handle = dd_screen_resource_get_handle;
SCR_INIT(resource_changed);
dscreen->base.resource_destroy = dd_screen_resource_destroy;
return &rtex->resource.b.b;
}
+static bool si_check_resource_capability(struct pipe_screen *screen,
+ struct pipe_resource *resource,
+ unsigned bind)
+{
+ struct r600_texture *tex = (struct r600_texture*)resource;
+
+ /* Buffers only support the linear flag. */
+ if (resource->target == PIPE_BUFFER)
+ return (bind & ~PIPE_BIND_LINEAR) == 0;
+
+ if (bind & PIPE_BIND_LINEAR && !tex->surface.is_linear)
+ return false;
+
+ if (bind & PIPE_BIND_SCANOUT && !tex->surface.is_displayable)
+ return false;
+
+ /* TODO: PIPE_BIND_CURSOR - do we care? */
+ return true;
+}
+
void si_init_screen_texture_functions(struct r600_common_screen *rscreen)
{
rscreen->b.resource_from_handle = r600_texture_from_handle;
rscreen->b.resource_from_memobj = r600_texture_from_memobj;
rscreen->b.memobj_create_from_handle = r600_memobj_from_handle;
rscreen->b.memobj_destroy = r600_memobj_destroy;
+ rscreen->b.check_resource_capability = si_check_resource_capability;
}
void si_init_context_texture_functions(struct r600_common_context *rctx)
return result;
}
+static bool
+rbug_screen_check_resource_capability(struct pipe_screen *_screen,
+ struct pipe_resource *_resource,
+ unsigned bind)
+{
+ struct rbug_screen *rb_screen = rbug_screen(_screen);
+ struct rbug_resource *rb_resource = rbug_resource(_resource);
+ struct pipe_screen *screen = rb_screen->screen;
+ struct pipe_resource *resource = rb_resource->resource;
+
+ return screen->check_resource_capability(screen, resource, bind);
+}
+
static boolean
rbug_screen_resource_get_handle(struct pipe_screen *_screen,
struct pipe_context *_pipe,
rb_screen->base.context_create = rbug_screen_context_create;
rb_screen->base.resource_create = rbug_screen_resource_create;
rb_screen->base.resource_from_handle = rbug_screen_resource_from_handle;
+ SCR_INIT(check_resource_capability);
rb_screen->base.resource_get_handle = rbug_screen_resource_get_handle;
SCR_INIT(resource_changed);
rb_screen->base.resource_destroy = rbug_screen_resource_destroy;
return result;
}
+static bool
+trace_screen_check_resource_capability(struct pipe_screen *_screen,
+ struct pipe_resource *resource,
+ unsigned bind)
+{
+ struct pipe_screen *screen = trace_screen(_screen)->screen;
+
+ return screen->check_resource_capability(screen, resource, bind);
+}
+
static boolean
trace_screen_resource_get_handle(struct pipe_screen *_screen,
struct pipe_context *_pipe,
tr_scr->base.context_create = trace_screen_context_create;
tr_scr->base.resource_create = trace_screen_resource_create;
tr_scr->base.resource_from_handle = trace_screen_resource_from_handle;
+ SCR_INIT(check_resource_capability);
tr_scr->base.resource_get_handle = trace_screen_resource_get_handle;
SCR_INIT(resource_from_memobj);
SCR_INIT(resource_changed);
const struct pipe_resource *t,
void *user_memory);
+ /**
+ * Unlike pipe_resource::bind, which describes what state trackers want,
+ * resources can have much greater capabilities in practice, often implied
+ * by the tiling layout or memory placement. This function allows querying
+ * whether a capability is supported beyond what was requested by state
+ * trackers. It's also useful for querying capabilities of imported
+ * resources where the capabilities are unknown at first.
+ *
+ * Only these flags are allowed:
+ * - PIPE_BIND_SCANOUT
+ * - PIPE_BIND_CURSOR
+ * - PIPE_BIND_LINEAR
+ */
+ bool (*check_resource_capability)(struct pipe_screen *screen,
+ struct pipe_resource *resource,
+ unsigned bind);
+
/**
* Get a winsys_handle from a texture. Some platforms/winsys requires
* that the texture is created with a special usage flag like