summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2017-10-09 18:44:50 +0200
committerMarek Olšák <[email protected]>2017-10-12 19:03:33 +0200
commit07fdc0a09cd8f7af8231c4bede158588c6649ce4 (patch)
tree585e11ca368297335aae9bdc57ba2f4c1b603b0c /src/gallium/drivers
parent5f2073be3282a233a8b5bcb5342ea5e599b9b316 (diff)
gallium: add pipe_screen::check_resource_capability
This is optional (and no CAP). Implemented by radeonsi, ddebug, rbug, trace. Reviewed-by: Daniel Stone <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r--src/gallium/drivers/ddebug/dd_screen.c11
-rw-r--r--src/gallium/drivers/radeon/r600_texture.c21
-rw-r--r--src/gallium/drivers/rbug/rbug_screen.c14
-rw-r--r--src/gallium/drivers/trace/tr_screen.c11
4 files changed, 57 insertions, 0 deletions
diff --git a/src/gallium/drivers/ddebug/dd_screen.c b/src/gallium/drivers/ddebug/dd_screen.c
index c518f5f9e9d..caf31f6df0f 100644
--- a/src/gallium/drivers/ddebug/dd_screen.c
+++ b/src/gallium/drivers/ddebug/dd_screen.c
@@ -308,6 +308,16 @@ dd_screen_resource_get_handle(struct pipe_screen *_screen,
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
@@ -467,6 +477,7 @@ ddebug_screen_create(struct pipe_screen *screen)
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;
diff --git a/src/gallium/drivers/radeon/r600_texture.c b/src/gallium/drivers/radeon/r600_texture.c
index 78d49c289d1..a237c3cd4d8 100644
--- a/src/gallium/drivers/radeon/r600_texture.c
+++ b/src/gallium/drivers/radeon/r600_texture.c
@@ -2878,6 +2878,26 @@ r600_texture_from_memobj(struct pipe_screen *screen,
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;
@@ -2885,6 +2905,7 @@ void si_init_screen_texture_functions(struct r600_common_screen *rscreen)
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)
diff --git a/src/gallium/drivers/rbug/rbug_screen.c b/src/gallium/drivers/rbug/rbug_screen.c
index b12f029b3ea..2477edbadf0 100644
--- a/src/gallium/drivers/rbug/rbug_screen.c
+++ b/src/gallium/drivers/rbug/rbug_screen.c
@@ -183,6 +183,19 @@ rbug_screen_resource_from_handle(struct pipe_screen *_screen,
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,
@@ -301,6 +314,7 @@ rbug_screen_create(struct pipe_screen *screen)
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;
diff --git a/src/gallium/drivers/trace/tr_screen.c b/src/gallium/drivers/trace/tr_screen.c
index 539b17e2702..d5a81249b51 100644
--- a/src/gallium/drivers/trace/tr_screen.c
+++ b/src/gallium/drivers/trace/tr_screen.c
@@ -379,6 +379,16 @@ trace_screen_resource_from_handle(struct pipe_screen *_screen,
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,
@@ -636,6 +646,7 @@ trace_screen_create(struct pipe_screen *screen)
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);