From 34e89e4d3802ec9b4d7da178757bd82c44310653 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michel=20D=C3=A4nzer?= Date: Thu, 12 Jul 2018 16:29:51 +0200 Subject: [PATCH] gallium: Check pipe_screen::resource_changed before dereferencing it 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 --- src/gallium/auxiliary/driver_ddebug/dd_screen.c | 3 ++- src/gallium/auxiliary/driver_rbug/rbug_screen.c | 3 ++- src/gallium/auxiliary/driver_trace/tr_screen.c | 3 ++- src/mesa/state_tracker/st_cb_eglimage.c | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/gallium/auxiliary/driver_ddebug/dd_screen.c b/src/gallium/auxiliary/driver_ddebug/dd_screen.c index 5b2be28..5f922d8 100644 --- a/src/gallium/auxiliary/driver_ddebug/dd_screen.c +++ b/src/gallium/auxiliary/driver_ddebug/dd_screen.c @@ -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 diff --git a/src/gallium/auxiliary/driver_rbug/rbug_screen.c b/src/gallium/auxiliary/driver_rbug/rbug_screen.c index 2477edb..a1a77ad 100644 --- a/src/gallium/auxiliary/driver_rbug/rbug_screen.c +++ b/src/gallium/auxiliary/driver_rbug/rbug_screen.c @@ -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 diff --git a/src/gallium/auxiliary/driver_trace/tr_screen.c b/src/gallium/auxiliary/driver_trace/tr_screen.c index d5a8124..704b2a3 100644 --- a/src/gallium/auxiliary/driver_trace/tr_screen.c +++ b/src/gallium/auxiliary/driver_trace/tr_screen.c @@ -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(); } diff --git a/src/mesa/state_tracker/st_cb_eglimage.c b/src/mesa/state_tracker/st_cb_eglimage.c index 4f33cb4..0db2efc 100644 --- a/src/mesa/state_tracker/st_cb_eglimage.c +++ b/src/mesa/state_tracker/st_cb_eglimage.c @@ -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; -- 2.7.4