From: Eric Anholt Date: Tue, 23 Jul 2019 20:18:21 +0000 (-0700) Subject: surfaceless: Fix swrast path. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6a8d39dccdc1268e439a9ea0bc6fc89b3cd36815;p=mesa.git surfaceless: Fix swrast path. We get a getDrawableInfo() call in the MakeCurrent path, which platform_device was handling correctly by returning the pbuffer's width/height but platform_surfaceless segfaulted for. Reuse platform_device's implementation. Reviewed-by: Gurchetan Singh --- diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index 52babb53ff5..8dd1890ee07 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -149,6 +149,29 @@ const __DRIuseInvalidateExtension use_invalidate = { .base = { __DRI_USE_INVALIDATE, 1 } }; +static void +dri2_get_pbuffer_drawable_info(__DRIdrawable * draw, + int *x, int *y, int *w, int *h, + void *loaderPrivate) +{ + struct dri2_egl_surface *dri2_surf = loaderPrivate; + + *x = *y = 0; + *w = dri2_surf->base.Width; + *h = dri2_surf->base.Height; +} + +/* HACK: technically we should have swrast_null, instead of these. We + * get away since only pbuffers are supported, thus the callbacks are + * unused. + */ +const __DRIswrastLoaderExtension swrast_pbuffer_loader_extension = { + .base = { __DRI_SWRAST_LOADER, 1 }, + .getDrawableInfo = dri2_get_pbuffer_drawable_info, + .putImage = NULL, + .getImage = NULL, +}; + static const EGLint dri2_to_egl_attribute_map[__DRI_ATTRIB_MAX] = { [__DRI_ATTRIB_BUFFER_SIZE ] = EGL_BUFFER_SIZE, [__DRI_ATTRIB_LEVEL] = EGL_LEVEL, diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h index 43c41bdeba2..bb3352f1b69 100644 --- a/src/egl/drivers/dri2/egl_dri2.h +++ b/src/egl/drivers/dri2/egl_dri2.h @@ -374,6 +374,7 @@ _EGL_DRIVER_TYPECAST(dri2_egl_sync, _EGLSync, obj) extern const __DRIimageLookupExtension image_lookup_extension; extern const __DRIuseInvalidateExtension use_invalidate; extern const __DRIbackgroundCallableExtension background_callable_extension; +extern const __DRIswrastLoaderExtension swrast_pbuffer_loader_extension; EGLBoolean dri2_load_driver(_EGLDisplay *disp); diff --git a/src/egl/drivers/dri2/platform_device.c b/src/egl/drivers/dri2/platform_device.c index e7ae3a3aa2a..a73ea415396 100644 --- a/src/egl/drivers/dri2/platform_device.c +++ b/src/egl/drivers/dri2/platform_device.c @@ -248,29 +248,6 @@ static const __DRIimageLoaderExtension image_loader_extension = { .flushFrontBuffer = device_flush_front_buffer, }; -static void -device_get_drawable_info(__DRIdrawable * draw, - int *x, int *y, int *w, int *h, - void *loaderPrivate) -{ - struct dri2_egl_surface *dri2_surf = loaderPrivate; - - *x = *y = 0; - *w = dri2_surf->base.Width; - *h = dri2_surf->base.Height; -} - -/* HACK: technically we should have swrast_null, instead of these. We - * get away since only pbuffers are supported, thus the callbacks are - * unused. - */ -static const __DRIswrastLoaderExtension swrast_loader_extension = { - .base = { __DRI_SWRAST_LOADER, 1 }, - .getDrawableInfo = device_get_drawable_info, - .putImage = NULL, - .getImage = NULL, -}; - static const __DRIextension *image_loader_extensions[] = { &image_loader_extension.base, &image_lookup_extension.base, @@ -278,9 +255,8 @@ static const __DRIextension *image_loader_extensions[] = { NULL, }; -/* HACK: second part of the hack above. */ static const __DRIextension *swrast_loader_extensions[] = { - &swrast_loader_extension.base, + &swrast_pbuffer_loader_extension.base, &image_lookup_extension.base, &use_invalidate.base, NULL, diff --git a/src/egl/drivers/dri2/platform_surfaceless.c b/src/egl/drivers/dri2/platform_surfaceless.c index 142165807c3..210f8188b96 100644 --- a/src/egl/drivers/dri2/platform_surfaceless.c +++ b/src/egl/drivers/dri2/platform_surfaceless.c @@ -242,13 +242,6 @@ static const __DRIimageLoaderExtension image_loader_extension = { .flushFrontBuffer = surfaceless_flush_front_buffer, }; -static const __DRIswrastLoaderExtension swrast_loader_extension = { - .base = { __DRI_SWRAST_LOADER, 1 }, - .getDrawableInfo = NULL, - .putImage = NULL, - .getImage = NULL, -}; - static const __DRIextension *image_loader_extensions[] = { &image_loader_extension.base, &image_lookup_extension.base, @@ -257,7 +250,7 @@ static const __DRIextension *image_loader_extensions[] = { }; static const __DRIextension *swrast_loader_extensions[] = { - &swrast_loader_extension.base, + &swrast_pbuffer_loader_extension.base, &image_loader_extension.base, &image_lookup_extension.base, &use_invalidate.base,