<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Nov 30, 2013 at 3:23 AM,  <span dir="ltr"><<a href="mailto:davyaxel@free.fr" target="_blank">davyaxel@free.fr</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">>    Could you tell more detail about when the texture may be of wrong format?<br>
</div>On intel, creating the texture with the GL_RGBA format creates an ARGB8888 texture.<br>
However on gallium drivers, it creates an ABGR8888 texture.<br>
<div class="im"><br>
>  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<br>
> side is the large pixmap which may allocate a texture array for it.<br>
><br>
</div><div class="im">>     so I need to have glamor_egl_dri3_fd_from_pixmap in glamor.c,<br>
>     which would get the texture and check the type, and then call a glamor_egl function<br>
>     to create the fd.<br>
><br>
>  The same issue why we could not use the texture->image->gbm_bo->fd solution?<br>
</div>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.<br>
<br>
I did a first implementation, in which I do not store the gbm_bo with the pixmap:<br>
<br>
Concretely, _glamor_create_tex(glamor_fbo.c) becomes that:<br>
<br>
static int<br>
_glamor_create_tex(glamor_screen_private *glamor_priv,<br>
           int w, int h, GLenum format)<br>
{<br>
    glamor_gl_dispatch *dispatch;<br>
    unsigned int tex = 0;<br>
<br>
    /* With dri3, we want to allocate ARGB8888 pixmaps only.<br>
     * Depending on the implementation, GL_RGBA might not<br>
     * give use ARGB8888. We ask glamor_egl to get<br>
     * an ARGB8888 based texture for us. */<br>
    if (glamor_priv->dri3_enabled && format == GL_RGBA)<br>
    {<br>
        tex = glamor_egl_create_argb8888_based_texture(glamor_priv->screen,<br>
                                w, h); <br></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
    }<br>
    if (!tex)<br>
    {<br>
        dispatch = glamor_get_dispatch(glamor_priv);<br>
        dispatch->glGenTextures(1, &tex);<br>
        dispatch->glBindTexture(GL_TEXTURE_2D, tex);<br>
        dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,<br>
                      GL_NEAREST);<br>
        dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,<br>
                        GL_NEAREST);<br>
        dispatch->glTexImage2D(GL_TEXTURE_2D, 0, format, w, h, 0,<br>
                       format, GL_UNSIGNED_BYTE, NULL);<br>
        glamor_put_dispatch(glamor_priv);<br>
    }<br>
    return tex;<br>
}<br>
<br>
Here I don't store the gbm_bo glamor_egl side, since I don't have access to the pixmap.<br>
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).<br>
<br>
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.<br>
<br>
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.<br>
Since _glamor_create_tex isn't called when the DDX creates a textured pixmap, the DDX can still create its own pixmaps.<br>
<br>
I have written an implementation with it, but I have issues with the enabling of dri3:<br>
If I bypass the negocation to enable dri3 between glamor and glamor_egl, I have a working implementation.<br>
<br>
Do you want I keep working on this solution?<br></blockquote><div> It looks good to me. Only one minor concern is that it calls to glamor_egl function directly.  But I'm ok with it currently. Please go ahead.<br> Thanks for your contribution.<br>
</div><div> Zhigang Gong.<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="HOEnZb"><font color="#888888"><br>
Axel Davy<br>
</font></span></blockquote></div><br></div></div>