[Mesa-dev] [PATCH v2 2/2] i965: expose RGBA visuals only on Android

Emil Velikov emil.l.velikov at gmail.com
Mon Jul 31 18:46:23 UTC 2017


From: Emil Velikov <emil.velikov at collabora.com>

As Marek pointed out in earlier commit - exposing RGBA on other
platforms introduces ~500 Visuals, which are not tested.

v2: Rebase, while keeping loaderPrivate

Fixes: 1bf703e4ea5 ("dri_interface,egl,gallium: only expose RGBA visuals
on Android")
Cc: Tomasz Figa <tfiga at chromium.org>
Cc: Chad Versace <chadversary at chromium.org>
Cc: Marek Olšák <maraeo at gmail.com>
Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
---
 src/mesa/drivers/dri/i965/intel_screen.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c
index ced80cb8790..48b412bd06a 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -1746,6 +1746,20 @@ intel_supported_msaa_modes(const struct intel_screen  *screen)
    }
 }
 
+static int
+intel_loader_get_cap(const __DRIscreen *dri_screen, enum dri_loader_cap cap)
+{
+   if (dri_screen->dri2.loader && dri_screen->dri2.loader->base.version >= 4 &&
+       dri_screen->dri2.loader->getCapability)
+      return dri_screen->dri2.loader->getCapability(dri_screen->loaderPrivate, cap);
+
+   if (dri_screen->image.loader && dri_screen->image.loader->base.version >= 2 &&
+       dri_screen->image.loader->getCapability)
+      return dri_screen->image.loader->getCapability(dri_screen->loaderPrivate, cap);
+
+   return 0;
+}
+
 static __DRIconfig**
 intel_screen_make_configs(__DRIscreen *dri_screen)
 {
@@ -1789,8 +1803,15 @@ intel_screen_make_configs(__DRIscreen *dri_screen)
    uint8_t depth_bits[4], stencil_bits[4];
    __DRIconfig **configs = NULL;
 
+   /* Expose only BGRA ordering if the loader doesn't support RGBA ordering. */
+   unsigned num_formats;
+   if (intel_loader_get_cap(dri_screen, DRI_LOADER_CAP_RGBA_ORDERING))
+      num_formats = ARRAY_SIZE(formats);
+   else
+      num_formats = 3;
+
    /* Generate singlesample configs without accumulation buffer. */
-   for (unsigned i = 0; i < ARRAY_SIZE(formats); i++) {
+   for (unsigned i = 0; i < num_formats; i++) {
       __DRIconfig **new_configs;
       int num_depth_stencil_bits = 2;
 
-- 
2.13.3



More information about the mesa-dev mailing list