[Glamor] Discussing DRI3 support

davyaxel at free.fr davyaxel at free.fr
Fri Nov 29 11:23:39 PST 2013


>    Could you tell more detail about when the texture may be of wrong format?
On intel, creating the texture with the GL_RGBA format creates an ARGB8888 texture.
However on gallium drivers, it creates an ABGR8888 texture.

>  I think, we still need to try our best to eliminate that one time extra copy if possible. Another special case which I really don't want to put it to the glamor_egl
> side is the large pixmap which may allocate a texture array for it.
>
>     so I need to have glamor_egl_dri3_fd_from_pixmap in glamor.c,
>     which would get the texture and check the type, and then call a glamor_egl function
>     to create the fd.
>
>  The same issue why we could not use the texture->image->gbm_bo->fd solution?
The solution I was first proposing, was, everytime we need a texture, and the asked format is GL_RGBA, and dri3 support is enabled, to call an egl function to get the texture, and be sure it is ARGB8888.

I did a first implementation, in which I do not store the gbm_bo with the pixmap:

Concretely, _glamor_create_tex(glamor_fbo.c) becomes that:

static int
_glamor_create_tex(glamor_screen_private *glamor_priv,
           int w, int h, GLenum format)
{
    glamor_gl_dispatch *dispatch;
    unsigned int tex = 0;

    /* With dri3, we want to allocate ARGB8888 pixmaps only.
     * Depending on the implementation, GL_RGBA might not
     * give use ARGB8888. We ask glamor_egl to get
     * an ARGB8888 based texture for us. */
    if (glamor_priv->dri3_enabled && format == GL_RGBA)
    {
        tex = glamor_egl_create_argb8888_based_texture(glamor_priv->screen,
                                w, h);
    }
    if (!tex)
    {
        dispatch = glamor_get_dispatch(glamor_priv);
        dispatch->glGenTextures(1, &tex);
        dispatch->glBindTexture(GL_TEXTURE_2D, tex);
        dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
                      GL_NEAREST);
        dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
                        GL_NEAREST);
        dispatch->glTexImage2D(GL_TEXTURE_2D, 0, format, w, h, 0,
                       format, GL_UNSIGNED_BYTE, NULL);
        glamor_put_dispatch(glamor_priv);
    }
    return tex;
}

Here I don't store the gbm_bo glamor_egl side, since I don't have access to the pixmap.
With this I'm sure that texture->image->gbm_bo will give the correct format later, on exportable pixmaps ( for pixmaps of depth 24 or 32, ie for which we create the texture with the GL_RGBA format).

This includes the large pixmaps case, etc. And we don't need to call glamor_egl when destructing the pixmap since the gbm_bo to create the texture was destroyed.

This solution doesn't need any copy when we want to export the pixmap, and do not store an image of the texture when the pixmap was never exported.
Since _glamor_create_tex isn't called when the DDX creates a textured pixmap, the DDX can still create its own pixmaps.

I have written an implementation with it, but I have issues with the enabling of dri3:
If I bypass the negocation to enable dri3 between glamor and glamor_egl, I have a working implementation.

Do you want I keep working on this solution?

Axel Davy


More information about the Glamor mailing list