[xserver patch v4 3/5] glx: Enforce a 1:1 correspondence between GLX and X11 windows.

Kristian Høgsberg krh at bitplanet.net
Mon Feb 8 14:26:43 PST 2010


On Mon, Feb 8, 2010 at 1:25 PM, Francisco Jerez <currojerez at riseup.net> wrote:
> The spec says (regarding glXCreateWindow): "If there is already a
> GLXFBConfig associated with win (as a result of a previous
> glXCreateWindow call), then a BadAlloc error is generated.". It will
> also come useful to implement DRI2InvalidateBuffers for the indirect
> case.

(from elsewhere in the thread:)
>> Can you just use the existing __glXDrawableRes for tracking this?
>>
> I don't think so. To implement DRI2InvalidateBuffers we need a way to
> map an X11 window to its GLX window: In the GLX1.3 world the client
> decides the IDs of its GLX drawables so in general GLX and X11 drawable
> IDs aren't going to be the same.

Ah yes, you're right.   A few comments below.

> Signed-off-by: Francisco Jerez <currojerez at riseup.net>
> ---
>  glx/glxcmds.c   |   51 +++++++++++++++++++++++++++++++++++++++++++++------
>  glx/glxserver.h |    1 +
>  2 files changed, 46 insertions(+), 6 deletions(-)
>
> diff --git a/glx/glxcmds.c b/glx/glxcmds.c
> index 77afbf4..0e1c89c 100644
> --- a/glx/glxcmds.c
> +++ b/glx/glxcmds.c
> @@ -51,6 +51,15 @@
>  #include "indirect_table.h"
>  #include "indirect_util.h"
>
> +static int glxWindowPrivateKeyIndex;
> +static DevPrivateKey glxWindowPrivateKey = &glxWindowPrivateKeyIndex;
> +
> +__GLXdrawable *
> +glxGetDrawableFromWindow(WindowPtr pWin)
> +{
> +       return dixLookupPrivate(&pWin->devPrivates, glxWindowPrivateKey);
> +}
> +
>  static int
>  validGlxScreen(ClientPtr client, int screen, __GLXscreen **pGlxScreen, int *err)
>  {
> @@ -473,6 +482,7 @@ __glXGetDrawable(__GLXcontext *glxc, GLXDrawable drawId, ClientPtr client,
>                 int *error)
>  {
>     DrawablePtr pDraw;
> +    WindowPtr pWin;
>     __GLXdrawable *pGlxDraw;
>     int rc;
>
> @@ -499,6 +509,12 @@ __glXGetDrawable(__GLXcontext *glxc, GLXDrawable drawId, ClientPtr client,
>        return NULL;
>     }
>
> +    pWin = (WindowPtr)pDraw;
> +
> +    pGlxDraw = glxGetDrawableFromWindow(pWin);
> +    if (pGlxDraw)
> +           return pGlxDraw;

If there already is a GLXWindow for the window, the validGlxDrawable()
call above should return the __GLXdrawable for it, so this hunk
shouldn't be necessary.

>     if (pDraw->pScreen != glxc->pGlxScreen->pScreen) {
>        client->errorValue = pDraw->pScreen->myNum;
>        *error = BadMatch;
> @@ -519,6 +535,8 @@ __glXGetDrawable(__GLXcontext *glxc, GLXDrawable drawId, ClientPtr client,
>        return NULL;
>     }
>
> +    dixSetPrivate(&pWin->devPrivates, glxWindowPrivateKey, pGlxDraw);
> +
>     return pGlxDraw;
>  }
>
> @@ -1107,9 +1125,10 @@ __glXDrawableRelease(__GLXdrawable *drawable)
>     }
>  }
>
> -static int
> +static int
>  DoCreateGLXDrawable(ClientPtr client, __GLXscreen *pGlxScreen, __GLXconfig *config,
> -                   DrawablePtr pDraw, XID glxDrawableId, int type)
> +                   DrawablePtr pDraw, XID glxDrawableId, int type,
> +                   __GLXdrawable **ret)
>  {
>     __GLXdrawable *pGlxDraw;
>
> @@ -1128,6 +1147,9 @@ DoCreateGLXDrawable(ClientPtr client, __GLXscreen *pGlxScreen, __GLXconfig *conf
>        return BadAlloc;
>     }
>
> +    if (ret)
> +       *ret = pGlxDraw;
> +

I would just see if type is GLX_DRAWABLE_WINDOW and set the window
private in DoCreateGLXDrawable() if it is.  Less code churn.

The rest looks good.
Kristian


More information about the xorg-devel mailing list