[1/2] swrast: Avoid creating front buffers with __DRI_SWRAST_LOADER < 3.

Submitted by Mathias Fröhlich on June 6, 2019, 11:10 a.m.

Details

Message ID 5af8ca501bdebf07763725f37694c30ad1af547a.1559818218.git.Mathias.Froehlich@gmx.net
State New
Headers show
Series "Followups on the just landed EGL_platform_device." ( rev: 2 1 ) in Mesa

Not browsing as part of any series.

Commit Message

Mathias Fröhlich June 6, 2019, 11:10 a.m.
From: Mathias Fröhlich <mathias.froehlich@web.de>

Align classic swrast with galliums software renderer with respect
to front buffer creation.
In case of front buffers swrast uses the __DRI_SWRAST_LOADER extensions
getImage/putImage callbacks to keep the front buffer in sync between
the X server and the mesa software rendering. Gallium sofware rasterizers
only allocates front buffers if the __DRI_SWRAST_LOADER extension version
is >= 3. By that the getImage/putImage NULL pointers of the recent
EGL_platform_device, which announces __DRI_SWRAST_LOADER version 1, are
never called and thus this combination works fine.
The change makes classic swrast work together with EGL_platform_device
by using the same __DRI_SWRAST_LOADER version check than egl.
For reference see drisw_allocate_textures in
src/gallium/state_trackers/dri/drisw.c.

Signed-off-by: Mathias Fröhlich <Mathias.Froehlich@web.de>
---
 src/mesa/drivers/dri/swrast/swrast.c | 5 ++++-
 1 file changed, 4 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 8e8d6bd628e..832a45f1d88 100644
--- a/src/mesa/drivers/dri/swrast/swrast.c
+++ b/src/mesa/drivers/dri/swrast/swrast.c
@@ -572,7 +572,10 @@  dri_create_buffer(__DRIscreen * sPriv,
     _mesa_initialize_window_framebuffer(fb, visual);

     /* add front renderbuffer */
-    frontrb = swrast_new_renderbuffer(visual, dPriv, GL_TRUE);
+    if (sPriv->swrast_loader->base.version >= 3)
+       frontrb = swrast_new_renderbuffer(visual, dPriv, GL_TRUE);
+    else
+       frontrb = swrast_new_renderbuffer(visual, dPriv, GL_FALSE);
     _mesa_attach_and_own_rb(fb, BUFFER_FRONT_LEFT, &frontrb->Base.Base);

     /* add back renderbuffer */

Comments

On 2019/06/06, Mathias.Froehlich@gmx.net wrote:
> From: Mathias Fröhlich <mathias.froehlich@web.de>
> 
> Align classic swrast with galliums software renderer with respect
> to front buffer creation.
> In case of front buffers swrast uses the __DRI_SWRAST_LOADER extensions
> getImage/putImage callbacks to keep the front buffer in sync between
> the X server and the mesa software rendering. Gallium sofware rasterizers
> only allocates front buffers if the __DRI_SWRAST_LOADER extension version
> is >= 3. By that the getImage/putImage NULL pointers of the recent
> EGL_platform_device, which announces __DRI_SWRAST_LOADER version 1, are
> never called and thus this combination works fine.
> The change makes classic swrast work together with EGL_platform_device
> by using the same __DRI_SWRAST_LOADER version check than egl.
> For reference see drisw_allocate_textures in
> src/gallium/state_trackers/dri/drisw.c.
> 
> Signed-off-by: Mathias Fröhlich <Mathias.Froehlich@web.de>
> ---
>  src/mesa/drivers/dri/swrast/swrast.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/src/mesa/drivers/dri/swrast/swrast.c b/src/mesa/drivers/dri/swrast/swrast.c
> index 8e8d6bd628e..832a45f1d88 100644
> --- a/src/mesa/drivers/dri/swrast/swrast.c
> +++ b/src/mesa/drivers/dri/swrast/swrast.c
> @@ -572,7 +572,10 @@ dri_create_buffer(__DRIscreen * sPriv,
>      _mesa_initialize_window_framebuffer(fb, visual);
> 
>      /* add front renderbuffer */
> -    frontrb = swrast_new_renderbuffer(visual, dPriv, GL_TRUE);
> +    if (sPriv->swrast_loader->base.version >= 3)
> +       frontrb = swrast_new_renderbuffer(visual, dPriv, GL_TRUE);
> +    else
> +       frontrb = swrast_new_renderbuffer(visual, dPriv, GL_FALSE);
>      _mesa_attach_and_own_rb(fb, BUFFER_FRONT_LEFT, &frontrb->Base.Base);
> 
Doubt I'll be able to look at the classic swrast, anytime soon. Sorry :-\

-Emil
Hi Emil,

On Monday, 17 June 2019 19:35:10 CEST Emil Velikov wrote:
> On 2019/06/06, Mathias.Froehlich@gmx.net wrote:
> > From: Mathias Fröhlich <mathias.froehlich@web.de>
> > 
> > Align classic swrast with galliums software renderer with respect
> > to front buffer creation.
> > In case of front buffers swrast uses the __DRI_SWRAST_LOADER extensions
> > getImage/putImage callbacks to keep the front buffer in sync between
> > the X server and the mesa software rendering. Gallium sofware rasterizers
> > only allocates front buffers if the __DRI_SWRAST_LOADER extension version
> > is >= 3. By that the getImage/putImage NULL pointers of the recent
> > EGL_platform_device, which announces __DRI_SWRAST_LOADER version 1, are
> > never called and thus this combination works fine.
> > The change makes classic swrast work together with EGL_platform_device
> > by using the same __DRI_SWRAST_LOADER version check than egl.
> > For reference see drisw_allocate_textures in
> > src/gallium/state_trackers/dri/drisw.c.
> > 
> > Signed-off-by: Mathias Fröhlich <Mathias.Froehlich@web.de>
> > ---
> >  src/mesa/drivers/dri/swrast/swrast.c | 5 ++++-
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> > 
> > diff --git a/src/mesa/drivers/dri/swrast/swrast.c b/src/mesa/drivers/dri/swrast/swrast.c
> > index 8e8d6bd628e..832a45f1d88 100644
> > --- a/src/mesa/drivers/dri/swrast/swrast.c
> > +++ b/src/mesa/drivers/dri/swrast/swrast.c
> > @@ -572,7 +572,10 @@ dri_create_buffer(__DRIscreen * sPriv,
> >      _mesa_initialize_window_framebuffer(fb, visual);
> > 
> >      /* add front renderbuffer */
> > -    frontrb = swrast_new_renderbuffer(visual, dPriv, GL_TRUE);
> > +    if (sPriv->swrast_loader->base.version >= 3)
> > +       frontrb = swrast_new_renderbuffer(visual, dPriv, GL_TRUE);
> > +    else
> > +       frontrb = swrast_new_renderbuffer(visual, dPriv, GL_FALSE);
> >      _mesa_attach_and_own_rb(fb, BUFFER_FRONT_LEFT, &frontrb->Base.Base);
> > 
> Doubt I'll be able to look at the classic swrast, anytime soon. Sorry :-\

Thanks for that information.
Anybody else?

Or can I do something else to make that work?
Emil, I provided already working implementations as ready to be squashed updates to
your egl device branch that implemented getImage/putImage, but you did not want to
implement getImage/putImage by any means. Now that is the port of the if clause that
that makes llvmpipe work with your implementation of the egl device without
getImage/putImage.
So what do you suggest?

best and thanks

Mathias

> 
> -Emil
>