From a3c202de0a963c0562796cf75e3a9b3eedf1afad Mon Sep 17 00:00:00 2001 From: Julien Isorce Date: Tue, 23 Apr 2019 14:26:33 -0700 Subject: [PATCH] gallium: add resource_get_info to pipe_screen MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Generic plumbing. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=110443 Signed-off-by: Julien Isorce Reviewed-by: Marek Olšák --- src/gallium/auxiliary/driver_ddebug/dd_screen.c | 12 ++++++++++++ src/gallium/auxiliary/driver_rbug/rbug_screen.c | 15 +++++++++++++++ src/gallium/auxiliary/driver_trace/tr_screen.c | 15 +++++++++++++++ src/gallium/include/pipe/p_screen.h | 9 +++++++++ 4 files changed, 51 insertions(+) diff --git a/src/gallium/auxiliary/driver_ddebug/dd_screen.c b/src/gallium/auxiliary/driver_ddebug/dd_screen.c index b2108adfa32..ce9f697ad08 100644 --- a/src/gallium/auxiliary/driver_ddebug/dd_screen.c +++ b/src/gallium/auxiliary/driver_ddebug/dd_screen.c @@ -311,6 +311,17 @@ dd_screen_resource_get_handle(struct pipe_screen *_screen, return screen->resource_get_handle(screen, pipe, resource, handle, usage); } +static void +dd_screen_resource_get_info(struct pipe_screen *_screen, + struct pipe_resource *resource, + unsigned *stride, + unsigned *offset) +{ + struct pipe_screen *screen = dd_screen(_screen)->screen; + + screen->resource_get_info(screen, resource, stride, offset); +} + static bool dd_screen_check_resource_capability(struct pipe_screen *_screen, struct pipe_resource *resource, @@ -554,6 +565,7 @@ ddebug_screen_create(struct pipe_screen *screen) SCR_INIT(resource_from_user_memory); SCR_INIT(check_resource_capability); dscreen->base.resource_get_handle = dd_screen_resource_get_handle; + SCR_INIT(resource_get_info); SCR_INIT(resource_changed); dscreen->base.resource_destroy = dd_screen_resource_destroy; SCR_INIT(flush_frontbuffer); diff --git a/src/gallium/auxiliary/driver_rbug/rbug_screen.c b/src/gallium/auxiliary/driver_rbug/rbug_screen.c index 693e7fab912..6d93fb8e953 100644 --- a/src/gallium/auxiliary/driver_rbug/rbug_screen.c +++ b/src/gallium/auxiliary/driver_rbug/rbug_screen.c @@ -215,6 +215,20 @@ rbug_screen_resource_get_handle(struct pipe_screen *_screen, resource, handle, usage); } +static void +rbug_screen_resource_get_info(struct pipe_screen *_screen, + struct pipe_resource *_resource, + unsigned *stride, + unsigned *offset) +{ + 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; + + screen->resource_get_info(screen, resource, stride, offset); +} + static void rbug_screen_resource_changed(struct pipe_screen *_screen, struct pipe_resource *_resource) @@ -319,6 +333,7 @@ rbug_screen_create(struct pipe_screen *screen) 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_get_info); SCR_INIT(resource_changed); rb_screen->base.resource_destroy = rbug_screen_resource_destroy; rb_screen->base.flush_frontbuffer = rbug_screen_flush_frontbuffer; diff --git a/src/gallium/auxiliary/driver_trace/tr_screen.c b/src/gallium/auxiliary/driver_trace/tr_screen.c index e42aef63552..d14d46d123f 100644 --- a/src/gallium/auxiliary/driver_trace/tr_screen.c +++ b/src/gallium/auxiliary/driver_trace/tr_screen.c @@ -407,6 +407,20 @@ trace_screen_resource_get_handle(struct pipe_screen *_screen, resource, handle, usage); } +static void +trace_screen_resource_get_info(struct pipe_screen *_screen, + struct pipe_resource *resource, + unsigned *stride, + unsigned *offset) +{ + struct trace_screen *tr_screen = trace_screen(_screen); + struct pipe_screen *screen = tr_screen->screen; + + /* TODO trace call */ + + screen->resource_get_info(screen, resource, stride, offset); +} + static struct pipe_resource * trace_screen_resource_from_memobj(struct pipe_screen *_screen, const struct pipe_resource *templ, @@ -673,6 +687,7 @@ trace_screen_create(struct pipe_screen *screen) 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_get_info); SCR_INIT(resource_from_memobj); SCR_INIT(resource_changed); tr_scr->base.resource_destroy = trace_screen_resource_destroy; diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h index d4e2d9f63ac..3f9bad47095 100644 --- a/src/gallium/include/pipe/p_screen.h +++ b/src/gallium/include/pipe/p_screen.h @@ -262,6 +262,15 @@ struct pipe_screen { struct winsys_handle *handle, unsigned usage); + /** + * Get stride and offset for the given pipe resource without the need to get + * a winsys_handle. + */ + void (*resource_get_info)(struct pipe_screen *screen, + struct pipe_resource *resource, + unsigned *stride, + unsigned *offset); + /** * Mark the resource as changed so derived internal resources will be * recreated on next use. -- 2.30.2