mesa: Prevent classic swrast crash on a surfaceless context v2.
authorMathias Fröhlich <mathias.froehlich@web.de>
Wed, 8 May 2019 06:07:24 +0000 (08:07 +0200)
committerMathias Fröhlich <Mathias.Froehlich@gmx.net>
Tue, 28 May 2019 06:27:16 +0000 (08:27 +0200)
This fixes the egl_mesa_platform_surfaceless piglit test as well
as the new egl_ext_device_base piglit test on classic swrast.

v2: Fix swrast surfaceless contexts on the driver side.

Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Signed-off-by: Mathias Fröhlich <Mathias.Froehlich@web.de>
src/mesa/drivers/dri/swrast/swrast.c

index 94758e60862056b0ae2489db492aa27929d52ff1..8e8d6bd628e33c9d0041f8b1a67307e5bf15c41c 100644 (file)
@@ -36,6 +36,7 @@
 #include "main/api_exec.h"
 #include "main/context.h"
 #include "main/extensions.h"
+#include "main/fbobject.h"
 #include "main/formats.h"
 #include "main/framebuffer.h"
 #include "main/imports.h"
@@ -679,7 +680,7 @@ swrast_check_and_update_window_size( struct gl_context *ctx, struct gl_framebuff
 {
     GLsizei width, height;
 
-    if (!fb)
+    if (!fb || fb == _mesa_get_incomplete_framebuffer())
         return;
 
     get_window_size(fb, &width, &height);
@@ -877,6 +878,12 @@ dri_make_current(__DRIcontext * cPriv,
            mesaDraw = &draw->Base;
            mesaRead = &read->Base;
         }
+        else {
+           struct gl_framebuffer *incomplete
+              = _mesa_get_incomplete_framebuffer();
+           mesaDraw = incomplete;
+           mesaRead = incomplete;
+        }
 
         /* check for same context and buffer */
         if (mesaCtx == _mesa_get_current_context()