mesa: Prevent classic swrast crash on a surfaceless context v2.

Submitted by Mathias Fröhlich on May 27, 2019, 8:17 a.m.

Details

Message ID 1d7c37e7527c0f44c7cb6c8360ef4d7bff240223.1558944286.git.Mathias.Froehlich@gmx.net
State New
Headers show
Series "mesa: Prevent classic swrast crash on a surfaceless context." ( rev: 2 ) in Mesa

Not browsing as part of any series.

Commit Message

Mathias Fröhlich May 27, 2019, 8:17 a.m.
From: Mathias Fröhlich <mathias.froehlich@web.de>

Hi Emil,

thanks for that hint to look at _mesa_get_incomplete_framebuffer.
That one seems definitely more appropriate!

Though, I miss a bit the idea how I can create either a sensible
helper function for that task or how I can create something above
in the call stack to the MakeCurrent call that already catches
this case. Since that incomplete framebuffer is a mesa side thing I
cannot easily pull that above the __DriverAPIRec::MakeCurrent call.
But really putting those hand full lines of code into a helper does
as well not gain much. So I implemented that for the swrast case
directly.

So, to mention, I sent that change including our egl device code
with some unrelated egl device fixes through intels CI and did not
get regressions.

please review

thanks and best
Mathias





This fixes the egl_mesa_platform_surfaceless piglit test as well
as the new device egl extensions piglit test on classic swrast.

v2: Fix swrast surfaceless contexts on the driver side.

Signed-off-by: Mathias Fröhlich <Mathias.Froehlich@web.de>
---
 src/mesa/drivers/dri/swrast/swrast.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

--
2.21.0

Patch hide | download patch | download mbox

diff --git a/src/mesa/drivers/dri/swrast/swrast.c b/src/mesa/drivers/dri/swrast/swrast.c
index 36cf11334cb..4899fb2df95 100644
--- a/src/mesa/drivers/dri/swrast/swrast.c
+++ b/src/mesa/drivers/dri/swrast/swrast.c
@@ -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"
@@ -686,7 +687,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);
@@ -884,6 +885,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()

Comments


Pushed that.
Thanks!
best
Mathias

On Monday, 27 May 2019 17:34:29 CEST Marek Olšák wrote:
> Reviewed-by: Marek Olšák <marek.olsak@amd.com>
> 
> M.
> 
> On Mon, May 27, 2019, 4:17 AM <Mathias.Froehlich@gmx.net> wrote:
> 
> > From: Mathias Fröhlich <mathias.froehlich@web.de>
> >
> > Hi Emil,
> >
> > thanks for that hint to look at _mesa_get_incomplete_framebuffer.
> > That one seems definitely more appropriate!
> >
> > Though, I miss a bit the idea how I can create either a sensible
> > helper function for that task or how I can create something above
> > in the call stack to the MakeCurrent call that already catches
> > this case. Since that incomplete framebuffer is a mesa side thing I
> > cannot easily pull that above the __DriverAPIRec::MakeCurrent call.
> > But really putting those hand full lines of code into a helper does
> > as well not gain much. So I implemented that for the swrast case
> > directly.
> >
> > So, to mention, I sent that change including our egl device code
> > with some unrelated egl device fixes through intels CI and did not
> > get regressions.
> >
> > please review
> >
> > thanks and best
> > Mathias
> >
> >
> >
> >
> >
> > This fixes the egl_mesa_platform_surfaceless piglit test as well
> > as the new device egl extensions piglit test on classic swrast.
> >
> > v2: Fix swrast surfaceless contexts on the driver side.
> >
> > Signed-off-by: Mathias Fröhlich <Mathias.Froehlich@web.de>
> > ---
> >  src/mesa/drivers/dri/swrast/swrast.c | 9 ++++++++-
> >  1 file changed, 8 insertions(+), 1 deletion(-)
> >
> > diff --git a/src/mesa/drivers/dri/swrast/swrast.c
> > b/src/mesa/drivers/dri/swrast/swrast.c
> > index 36cf11334cb..4899fb2df95 100644
> > --- a/src/mesa/drivers/dri/swrast/swrast.c
> > +++ b/src/mesa/drivers/dri/swrast/swrast.c
> > @@ -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"
> > @@ -686,7 +687,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);
> > @@ -884,6 +885,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()
> > --
> > 2.21.0
> >
> >
>