#include <sys/stat.h>
#include "util/debug.h"
#include "util/macros.h"
+#include "util/bitscan.h"
#include "egl_dri2.h"
#include "egl_dri2_fallbacks.h"
return dri2_x11_do_authenticate(dri2_dpy, id);
}
-static bool
-dri2_x11_config_match_attrib(struct dri2_egl_display *dri2_dpy,
- const __DRIconfig *config,
- unsigned int attrib,
- unsigned int value)
-{
- uint32_t config_val;
- if (!dri2_dpy->core->getConfigAttrib(config, attrib, &config_val))
- return false;
- return config_val == value;
-}
-
static EGLBoolean
dri2_x11_add_configs_for_visuals(struct dri2_egl_display *dri2_dpy,
_EGLDisplay *disp, bool supports_preserved)
EGL_NONE
};
- unsigned int rgba_masks[4] = {
- visuals[i].red_mask,
- visuals[i].green_mask,
- visuals[i].blue_mask,
+ int rgba_shifts[4] = {
+ ffs(visuals[i].red_mask) - 1,
+ ffs(visuals[i].green_mask) - 1,
+ ffs(visuals[i].blue_mask) - 1,
+ -1,
+ };
+
+ unsigned int rgba_sizes[4] = {
+ util_bitcount(visuals[i].red_mask),
+ util_bitcount(visuals[i].green_mask),
+ util_bitcount(visuals[i].blue_mask),
0,
};
dri2_conf = dri2_add_config(disp, config, config_count + 1,
surface_type, config_attrs,
- rgba_masks);
+ rgba_shifts, rgba_sizes);
if (dri2_conf)
if (dri2_conf->base.ConfigID == config_count + 1)
config_count++;
- /* Allow a 24-bit RGB visual to match a 32-bit RGBA EGLConfig.
- * Ditto for 30-bit RGB visuals to match a 32-bit RGBA EGLConfig.
+ /* Allows RGB visuals to match a 32-bit RGBA EGLConfig.
* Otherwise it will only match a 32-bit RGBA visual. On a
* composited window manager on X11, this will make all of the
* EGLConfigs with destination alpha get blended by the
* compositor. This is probably not what the application
* wants... especially on drivers that only have 32-bit RGBA
* EGLConfigs! */
- if (d.data->depth == 24 || d.data->depth == 30) {
- rgba_masks[3] =
- ~(rgba_masks[0] | rgba_masks[1] | rgba_masks[2]);
- dri2_conf = dri2_add_config(disp, config, config_count + 1,
- surface_type, config_attrs,
- rgba_masks);
- if (dri2_conf)
- if (dri2_conf->base.ConfigID == config_count + 1)
- config_count++;
- }
- }
+ unsigned int rgba_mask = ~(visuals[i].red_mask |
+ visuals[i].green_mask |
+ visuals[i].blue_mask);
+ rgba_shifts[3] = ffs(rgba_mask) - 1;
+ rgba_sizes[3] = util_bitcount(rgba_mask);
+ dri2_conf = dri2_add_config(disp, config, config_count + 1,
+ surface_type, config_attrs,
+ rgba_shifts, rgba_sizes);
+ if (dri2_conf)
+ if (dri2_conf->base.ConfigID == config_count + 1)
+ config_count++;
+ }
}
xcb_depth_next(&d);
}
- /* Add a 565-no-depth-no-stencil pbuffer-only config. If X11 is depth 24,
- * we wouldn't have 565 available, which the CTS demands.
- */
- for (int j = 0; dri2_dpy->driver_configs[j]; j++) {
- const __DRIconfig *config = dri2_dpy->driver_configs[j];
- const EGLint config_attrs[] = {
- EGL_NATIVE_VISUAL_ID, 0,
- EGL_NATIVE_VISUAL_TYPE, EGL_NONE,
- EGL_NONE
- };
- EGLint surface_type = EGL_PBUFFER_BIT;
- unsigned int rgba_masks[4] = {
- 0x1f << 11,
- 0x3f << 5,
- 0x1f << 0,
- 0,
- };
-
- /* Check that we've found single-sample, no depth, no stencil,
- * and single-buffered.
- */
- if (!dri2_x11_config_match_attrib(dri2_dpy, config,
- __DRI_ATTRIB_DEPTH_SIZE, 0) ||
- !dri2_x11_config_match_attrib(dri2_dpy, config,
- __DRI_ATTRIB_STENCIL_SIZE, 0) ||
- !dri2_x11_config_match_attrib(dri2_dpy, config,
- __DRI_ATTRIB_SAMPLES, 0) ||
- !dri2_x11_config_match_attrib(dri2_dpy, config,
- __DRI_ATTRIB_DOUBLE_BUFFER, 0)) {
- continue;
- }
-
- if (dri2_add_config(disp, config, config_count + 1, surface_type,
- config_attrs, rgba_masks)) {
- config_count++;
- break;
- }
- }
-
if (!config_count) {
_eglLog(_EGL_WARNING, "DRI2: failed to create any config");
return EGL_FALSE;
.destroy_surface = dri2_x11_destroy_surface,
.create_image = dri2_create_image_khr,
.swap_buffers = dri2_x11_swap_buffers,
- .set_damage_region = dri2_fallback_set_damage_region,
.swap_buffers_region = dri2_fallback_swap_buffers_region,
.post_sub_buffer = dri2_fallback_post_sub_buffer,
/* XXX: should really implement this since X11 has pixmaps */
.swap_buffers = dri2_x11_swap_buffers,
.swap_buffers_with_damage = dri2_fallback_swap_buffers_with_damage,
.swap_buffers_region = dri2_x11_swap_buffers_region,
- .set_damage_region = dri2_fallback_set_damage_region,
.post_sub_buffer = dri2_x11_post_sub_buffer,
.copy_buffers = dri2_x11_copy_buffers,
.query_buffer_age = dri2_fallback_query_buffer_age,