X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fegl%2Fdrivers%2Fdri2%2Fplatform_x11.c;h=0ccc2b34bff12bc48809dc1783129290b36cfe76;hb=bc38fe8425f402c86d8446e92cc4a3be492d0aa1;hp=be9eb513243a51be9280cae214b8cbda5cd8f4bd;hpb=2282ec0ad6581b588f7bdde1211357123316b4b9;p=mesa.git diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c index be9eb513243..0ccc2b34bff 100644 --- a/src/egl/drivers/dri2/platform_x11.c +++ b/src/egl/drivers/dri2/platform_x11.c @@ -42,6 +42,7 @@ #include #include "util/debug.h" #include "util/macros.h" +#include "util/bitscan.h" #include "egl_dri2.h" #include "egl_dri2_fallbacks.h" @@ -261,7 +262,7 @@ dri2_x11_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type, (void) drv; - dri2_surf = malloc(sizeof *dri2_surf); + dri2_surf = calloc(1, sizeof *dri2_surf); if (!dri2_surf) { _eglError(EGL_BAD_ALLOC, "dri2_create_surface"); return NULL; @@ -290,7 +291,7 @@ dri2_x11_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type, goto cleanup_pixmap; } - if (!dri2_create_drawable(dri2_dpy, config, dri2_surf)) + if (!dri2_create_drawable(dri2_dpy, config, dri2_surf, dri2_surf)) goto cleanup_pixmap; if (type != EGL_PBUFFER_BIT) { @@ -338,7 +339,7 @@ dri2_x11_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type, } } else { if (type == EGL_PBUFFER_BIT) { - dri2_surf->depth = _eglGetConfigKey(conf, EGL_BUFFER_SIZE); + dri2_surf->depth = conf->BufferSize; } swrastCreateDrawable(dri2_dpy, dri2_surf); } @@ -754,18 +755,6 @@ dri2_x11_authenticate(_EGLDisplay *disp, uint32_t id) 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) @@ -806,16 +795,23 @@ dri2_x11_add_configs_for_visuals(struct dri2_egl_display *dri2_dpy, 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++; @@ -829,11 +825,14 @@ dri2_x11_add_configs_for_visuals(struct dri2_egl_display *dri2_dpy, * 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]); + 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_masks); + rgba_shifts, rgba_sizes); if (dri2_conf) if (dri2_conf->base.ConfigID == config_count + 1) config_count++; @@ -844,41 +843,6 @@ dri2_x11_add_configs_for_visuals(struct dri2_egl_display *dri2_dpy, 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. */ - 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)) { - 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; @@ -1217,15 +1181,8 @@ static const struct dri2_egl_display_vtbl dri2_x11_swrast_display_vtbl = { .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 */ - .copy_buffers = dri2_fallback_copy_buffers, - .query_buffer_age = dri2_fallback_query_buffer_age, .query_surface = dri2_query_surface, - .create_wayland_buffer_from_image = dri2_fallback_create_wayland_buffer_from_image, - .get_sync_values = dri2_fallback_get_sync_values, .get_dri_drawable = dri2_surface_get_dri_drawable, }; @@ -1238,14 +1195,10 @@ static const struct dri2_egl_display_vtbl dri2_x11_display_vtbl = { .create_image = dri2_x11_create_image_khr, .swap_interval = dri2_x11_swap_interval, .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, .query_surface = dri2_query_surface, - .create_wayland_buffer_from_image = dri2_fallback_create_wayland_buffer_from_image, .get_sync_values = dri2_x11_get_sync_values, .get_dri_drawable = dri2_surface_get_dri_drawable, };