gallium: add resource_get_info to pipe_screen
authorJulien Isorce <jisorce@oblong.com>
Tue, 23 Apr 2019 21:26:33 +0000 (14:26 -0700)
committerJulien Isorce <julien.isorce@gmail.com>
Tue, 30 Apr 2019 17:53:12 +0000 (17:53 +0000)
Generic plumbing.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=110443
Signed-off-by: Julien Isorce <jisorce@oblong.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/auxiliary/driver_ddebug/dd_screen.c
src/gallium/auxiliary/driver_rbug/rbug_screen.c
src/gallium/auxiliary/driver_trace/tr_screen.c
src/gallium/include/pipe/p_screen.h

index b2108adfa3257a85f55781455a011f3300a67d34..ce9f697ad08a115f3f8126dcdf39948ffc956b32 100644 (file)
@@ -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);
index 693e7fab912c69da5ed75fc38891d340acba4f53..6d93fb8e953375d3adf93f8612c2f7936dff21d6 100644 (file)
@@ -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;
index e42aef635520bd64da68220f6f67eb15733688b5..d14d46d123f15ff9c5eaafcf9c26d74ba690fd7d 100644 (file)
@@ -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;
index d4e2d9f63acfd39f2ab7b13e0b638d58620c55fa..3f9bad4709505e192fa82f31eca0d441217a3de4 100644 (file)
@@ -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.