[Mesa-dev] [PATCH 2/5] st/dri: get drirc options before creating pipe_screen
Marek Olšák
maraeo at gmail.com
Tue Jun 20 22:54:38 UTC 2017
From: Marek Olšák <marek.olsak at amd.com>
dri_init_options_get_screen_flags will return the flags for create_screen().
---
src/gallium/state_trackers/dri/dri2.c | 17 ++++++++++++-----
src/gallium/state_trackers/dri/dri_screen.c | 28 +++++++++++++++++-----------
src/gallium/state_trackers/dri/dri_screen.h | 7 +++++--
src/gallium/state_trackers/dri/drisw.c | 6 ++++--
4 files changed, 38 insertions(+), 20 deletions(-)
diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c
index 2d0e78c..2402c61 100644
--- a/src/gallium/state_trackers/dri/dri2.c
+++ b/src/gallium/state_trackers/dri/dri2.c
@@ -2018,22 +2018,27 @@ dri2_init_screen(__DRIscreen * sPriv)
screen->sPriv = sPriv;
screen->fd = sPriv->fd;
(void) mtx_init(&screen->opencl_func_mutex, mtx_plain);
sPriv->driverPrivate = (void *)screen;
if (screen->fd < 0 || (fd = fcntl(screen->fd, F_DUPFD_CLOEXEC, 3)) < 0)
goto free_screen;
- if (pipe_loader_drm_probe_fd(&screen->dev, fd))
- pscreen = pipe_loader_create_screen(screen->dev, 0);
+
+ if (pipe_loader_drm_probe_fd(&screen->dev, fd)) {
+ unsigned flags =
+ dri_init_options_get_screen_flags(screen, screen->dev->driver_name);
+
+ pscreen = pipe_loader_create_screen(screen->dev, flags);
+ }
if (!pscreen)
goto release_pipe;
throttle_ret = pipe_loader_configuration(screen->dev, DRM_CONF_THROTTLE);
dmabuf_ret = pipe_loader_configuration(screen->dev, DRM_CONF_SHARE_FD);
if (throttle_ret && throttle_ret->val.val_int != -1) {
screen->throttling_enabled = TRUE;
screen->default_throttle_frames = throttle_ret->val.val_int;
@@ -2057,21 +2062,21 @@ dri2_init_screen(__DRIscreen * sPriv)
}
}
if (pscreen->get_param(pscreen, PIPE_CAP_DEVICE_RESET_STATUS_QUERY)) {
sPriv->extensions = dri_robust_screen_extensions;
screen->has_reset_status_query = true;
}
else
sPriv->extensions = dri_screen_extensions;
- configs = dri_init_screen_helper(screen, pscreen, screen->dev->driver_name);
+ configs = dri_init_screen_helper(screen, pscreen);
if (!configs)
goto destroy_screen;
screen->can_share_buffer = true;
screen->auto_fake_front = dri_with_format(sPriv);
screen->broken_invalidate = !sPriv->dri2.useInvalidate;
screen->lookup_egl_image = dri2_lookup_egl_image;
return configs;
@@ -2109,42 +2114,44 @@ dri_kms_init_screen(__DRIscreen * sPriv)
return NULL;
screen->sPriv = sPriv;
screen->fd = sPriv->fd;
sPriv->driverPrivate = (void *)screen;
if (screen->fd < 0 || (fd = fcntl(screen->fd, F_DUPFD_CLOEXEC, 3)) < 0)
goto free_screen;
+ unsigned flags = dri_init_options_get_screen_flags(screen, "swrast");
+
if (pipe_loader_sw_probe_kms(&screen->dev, fd))
- pscreen = pipe_loader_create_screen(screen->dev, 0);
+ pscreen = pipe_loader_create_screen(screen->dev, flags);
if (!pscreen)
goto release_pipe;
if (pscreen->resource_create_with_modifiers)
dri2ImageExtension.createImageWithModifiers =
dri2_create_image_with_modifiers;
if (drmGetCap(sPriv->fd, DRM_CAP_PRIME, &cap) == 0 &&
(cap & DRM_PRIME_CAP_IMPORT)) {
dri2ImageExtension.createImageFromFds = dri2_from_fds;
dri2ImageExtension.createImageFromDmaBufs = dri2_from_dma_bufs;
dri2ImageExtension.createImageFromDmaBufs2 = dri2_from_dma_bufs2;
dri2ImageExtension.queryDmaBufFormats = dri2_query_dma_buf_formats;
dri2ImageExtension.queryDmaBufModifiers = dri2_query_dma_buf_modifiers;
}
sPriv->extensions = dri_screen_extensions;
- configs = dri_init_screen_helper(screen, pscreen, "swrast");
+ configs = dri_init_screen_helper(screen, pscreen);
if (!configs)
goto destroy_screen;
screen->can_share_buffer = false;
screen->auto_fake_front = dri_with_format(sPriv);
screen->broken_invalidate = !sPriv->dri2.useInvalidate;
screen->lookup_egl_image = dri2_lookup_egl_image;
return configs;
diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c
index a66689e..1b414b2 100644
--- a/src/gallium/state_trackers/dri/dri_screen.c
+++ b/src/gallium/state_trackers/dri/dri_screen.c
@@ -453,48 +453,54 @@ dri_set_background_context(struct st_context_iface *st)
ctx->sPriv->dri2.backgroundCallable;
/* Note: Mesa will only call this function if GL multithreading is enabled
* We only do that if the loader exposed the __DRI_BACKGROUND_CALLABLE
* extension. So we know that backgroundCallable is not NULL.
*/
assert(backgroundCallable);
backgroundCallable->setBackgroundContext(ctx->cPriv->loaderPrivate);
}
+unsigned
+dri_init_options_get_screen_flags(struct dri_screen *screen,
+ const char* driver_name)
+{
+ unsigned flags = 0;
+
+ driParseOptionInfo(&screen->optionCacheDefaults, gallium_config_options.xml);
+ driParseConfigFiles(&screen->optionCache,
+ &screen->optionCacheDefaults,
+ screen->sPriv->myNum,
+ driver_name);
+ dri_fill_st_options(screen);
+
+ return flags;
+}
+
const __DRIconfig **
dri_init_screen_helper(struct dri_screen *screen,
- struct pipe_screen *pscreen,
- const char* driver_name)
+ struct pipe_screen *pscreen)
{
screen->base.screen = pscreen;
screen->base.get_egl_image = dri_get_egl_image;
screen->base.get_param = dri_get_param;
screen->base.set_background_context = dri_set_background_context;
screen->st_api = st_gl_api_create();
if (!screen->st_api)
return NULL;
if(pscreen->get_param(pscreen, PIPE_CAP_NPOT_TEXTURES))
screen->target = PIPE_TEXTURE_2D;
else
screen->target = PIPE_TEXTURE_RECT;
- driParseOptionInfo(&screen->optionCacheDefaults, gallium_config_options.xml);
-
- driParseConfigFiles(&screen->optionCache,
- &screen->optionCacheDefaults,
- screen->sPriv->myNum,
- driver_name);
-
- dri_fill_st_options(screen);
-
/* Handle force_s3tc_enable. */
if (!util_format_s3tc_enabled && screen->options.force_s3tc_enable) {
/* Ensure libtxc_dxtn has been loaded if available.
* Forcing S3TC on before calling this would prevent loading
* the library.
* This is just a precaution, the driver should have called it
* already.
*/
util_format_s3tc_init();
diff --git a/src/gallium/state_trackers/dri/dri_screen.h b/src/gallium/state_trackers/dri/dri_screen.h
index 7f5fd13..550bc51 100644
--- a/src/gallium/state_trackers/dri/dri_screen.h
+++ b/src/gallium/state_trackers/dri/dri_screen.h
@@ -130,24 +130,27 @@ dri_with_format(__DRIscreen * sPriv)
return loader
&& (loader->base.version >= 3)
&& (loader->getBuffersWithFormat != NULL);
}
void
dri_fill_st_visual(struct st_visual *stvis, struct dri_screen *screen,
const struct gl_config *mode);
+unsigned
+dri_init_options_get_screen_flags(struct dri_screen *screen,
+ const char* driver_name);
+
const __DRIconfig **
dri_init_screen_helper(struct dri_screen *screen,
- struct pipe_screen *pscreen,
- const char* driver_name);
+ struct pipe_screen *pscreen);
void
dri_destroy_screen_helper(struct dri_screen * screen);
void
dri_destroy_screen(__DRIscreen * sPriv);
extern const struct __DriverAPIRec dri_kms_driver_api;
extern const struct __DriverAPIRec galliumdrm_driver_api;
diff --git a/src/gallium/state_trackers/dri/drisw.c b/src/gallium/state_trackers/dri/drisw.c
index 877aa71..189d61c 100644
--- a/src/gallium/state_trackers/dri/drisw.c
+++ b/src/gallium/state_trackers/dri/drisw.c
@@ -392,27 +392,29 @@ drisw_init_screen(__DRIscreen * sPriv)
return NULL;
screen->sPriv = sPriv;
screen->fd = -1;
swrast_no_present = debug_get_option_swrast_no_present();
sPriv->driverPrivate = (void *)screen;
sPriv->extensions = drisw_screen_extensions;
+ unsigned flags = dri_init_options_get_screen_flags(screen, "swrast");
+
if (pipe_loader_sw_probe_dri(&screen->dev, &drisw_lf))
- pscreen = pipe_loader_create_screen(screen->dev, 0);
+ pscreen = pipe_loader_create_screen(screen->dev, flags);
if (!pscreen)
goto fail;
- configs = dri_init_screen_helper(screen, pscreen, "swrast");
+ configs = dri_init_screen_helper(screen, pscreen);
if (!configs)
goto fail;
return configs;
fail:
dri_destroy_screen_helper(screen);
if (screen->dev)
pipe_loader_release(&screen->dev, 1);
FREE(screen);
return NULL;
--
2.7.4
More information about the mesa-dev
mailing list