gallium: Only call dri_init_options when the screen is actually created

Avoid calling this function on screen creation failure as we will discard its
result right after.

Signed-off-by: Corentin Noël <corentin.noel@collabora.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23054>
This commit is contained in:
Corentin Noël 2023-05-24 16:32:26 +02:00 committed by Marge Bot
parent 09f65f266e
commit 4d25ae350f
3 changed files with 10 additions and 12 deletions

View file

@ -2285,14 +2285,13 @@ dri2_init_screen(struct dri_screen *screen)
(void) mtx_init(&screen->opencl_func_mutex, mtx_plain);
if (pipe_loader_drm_probe_fd(&screen->dev, screen->fd)) {
if (pipe_loader_drm_probe_fd(&screen->dev, screen->fd))
pscreen = pipe_loader_create_screen(screen->dev);
dri_init_options(screen);
}
if (!pscreen)
goto fail;
dri_init_options(screen);
screen->throttle = pscreen->get_param(pscreen, PIPE_CAP_THROTTLE);
dri2_init_screen_extensions(screen, pscreen, false);
@ -2342,15 +2341,14 @@ dri_swrast_kms_init_screen(struct dri_screen *screen)
struct pipe_screen *pscreen = NULL;
#ifdef HAVE_DRISW_KMS
if (pipe_loader_sw_probe_kms(&screen->dev, screen->fd)) {
if (pipe_loader_sw_probe_kms(&screen->dev, screen->fd))
pscreen = pipe_loader_create_screen(screen->dev);
dri_init_options(screen);
}
#endif
if (!pscreen)
goto fail;
dri_init_options(screen);
dri2_init_screen_extensions(screen, pscreen, true);
configs = dri_init_screen_helper(screen, pscreen);

View file

@ -560,14 +560,14 @@ drisw_init_screen(struct dri_screen *screen)
#endif
if (!success)
success = pipe_loader_sw_probe_dri(&screen->dev, lf);
if (success) {
if (success)
pscreen = pipe_loader_create_screen(screen->dev);
dri_init_options(screen);
}
if (!pscreen)
goto fail;
dri_init_options(screen);
configs = dri_init_screen_helper(screen, pscreen);
if (!configs)
goto fail;

View file

@ -130,14 +130,14 @@ kopper_init_screen(struct dri_screen *screen)
success = pipe_loader_drm_probe_fd(&screen->dev, screen->fd);
else
success = pipe_loader_vk_probe_dri(&screen->dev, NULL);
if (success) {
if (success)
pscreen = pipe_loader_create_screen(screen->dev);
dri_init_options(screen);
}
if (!pscreen)
goto fail;
dri_init_options(screen);
screen->unwrapped_screen = trace_screen_unwrap(pscreen);
configs = dri_init_screen_helper(screen, pscreen);