gallium: Check pipe_screen::resource_changed before dereferencing it
authorMichel Dänzer <michel.daenzer@amd.com>
Thu, 12 Jul 2018 14:29:51 +0000 (16:29 +0200)
committerMichel Dänzer <michel@daenzer.net>
Thu, 12 Jul 2018 15:39:12 +0000 (17:39 +0200)
It's optional, only implemented by the etnaviv driver so far.

Fixes: 501d0edeca32 "st/mesa: call resource_changed when binding a
                     EGLImage to a texture"
Fixes: a37cf630b4d1 "gallium: add pipe_screen::resource_changed callback
                     wrappers"
Reviewed-by: Lucas Stach <l.stach@pengutronix.de>
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/mesa/state_tracker/st_cb_eglimage.c

index 5b2be28a96942b284db34430c46b146fb24eb2e6..5f922d884fe120a12110288f47f87bd39f097b02 100644 (file)
@@ -284,7 +284,8 @@ dd_screen_resource_changed(struct pipe_screen *_screen,
 {
    struct pipe_screen *screen = dd_screen(_screen)->screen;
 
-   screen->resource_changed(screen, res);
+   if (screen->resource_changed)
+      screen->resource_changed(screen, res);
 }
 
 static void
index 2477edbadf07c8706f14608b65da88170699eaec..a1a77add7341d7da06c85e9d253918975cefb516 100644 (file)
@@ -222,7 +222,8 @@ rbug_screen_resource_changed(struct pipe_screen *_screen,
    struct pipe_screen *screen = rb_screen->screen;
    struct pipe_resource *resource = rb_resource->resource;
 
-   screen->resource_changed(screen, resource);
+   if (screen->resource_changed)
+      screen->resource_changed(screen, resource);
 }
 
 static void
index d5a81249b519f5512bed14b6dd5a881618d53756..704b2a3c72de1be6400aac5da4658564064ccbb5 100644 (file)
@@ -444,7 +444,8 @@ trace_screen_resource_changed(struct pipe_screen *_screen,
    trace_dump_arg(ptr, screen);
    trace_dump_arg(ptr, resource);
 
-   screen->resource_changed(screen, resource);
+   if (screen->resource_changed)
+      screen->resource_changed(screen, resource);
 
    trace_dump_call_end();
 }
index 4f33cb4bb0621d79abea1ce37178cf3d6b2d9906..0db2efc01cf2281126a5abc769c3c10e5d86a497 100644 (file)
@@ -229,7 +229,8 @@ st_bind_egl_image(struct gl_context *ctx,
    pipe_resource_reference(&stObj->pt, stimg->texture);
    st_texture_release_all_sampler_views(st, stObj);
    pipe_resource_reference(&stImage->pt, stObj->pt);
-   st->pipe->screen->resource_changed(st->pipe->screen, stImage->pt);
+   if (st->pipe->screen->resource_changed)
+      st->pipe->screen->resource_changed(st->pipe->screen, stImage->pt);
 
    stObj->surface_format = stimg->format;
    stObj->level_override = stimg->level;