Re: [Mesa-dev] [PATCH 5/6] glx: Prepare driFetchDrawable for no-config contexts

2017-12-01 Thread Adam Jackson
On Tue, 2017-11-14 at 14:03 -0800, Ian Romanick wrote:
> On 11/14/2017 12:13 PM, Adam Jackson wrote:
> > diff --git a/src/glx/glx_pbuffer.c b/src/glx/glx_pbuffer.c
> > index 933b5d9ecd..42e7996e37 100644
> > --- a/src/glx/glx_pbuffer.c
> > +++ b/src/glx/glx_pbuffer.c
> > @@ -272,7 +272,7 @@ DestroyDRIDrawable(Display *dpy, GLXDrawable drawable, 
> > int destroy_xdrawable)
> >   * 10.  Given that, this routine should try to use an array on the stack to
> >   * capture the reply rather than always calling Xmalloc.
> >   */
> > -static int
> > +int
> >  GetDrawableAttribute(Display * dpy, GLXDrawable drawable,
> 
> I'm trying to decide whether or not this needs a __glX prefix now.  Yes?

Eh, sure. Anyone whose toolchain still doesn't have visibility control
is losing pretty hard, but we may as well be consistent.

> Other than that, this patch is
> 
> Reviewed-by: Ian Romanick 

Merged 1 2 and 5, will respin the rest.

- ajax
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 5/6] glx: Prepare driFetchDrawable for no-config contexts

2017-11-14 Thread Ian Romanick
On 11/14/2017 12:13 PM, Adam Jackson wrote:
> When we look up the DRI drawable state we need to associate an fbconfig
> with the drawable. With GLX_EXT_no_config_context we can no longer infer
> that from the context and must instead query the server.
> 
> Signed-off-by: Adam Jackson 
> ---
>  src/glx/dri_common.c  | 22 --
>  src/glx/glx_pbuffer.c |  2 +-
>  src/glx/glxclient.h   |  4 
>  3 files changed, 25 insertions(+), 3 deletions(-)
> 
> diff --git a/src/glx/dri_common.c b/src/glx/dri_common.c
> index 3b82309fa2..0d0b2d997b 100644
> --- a/src/glx/dri_common.c
> +++ b/src/glx/dri_common.c
> @@ -396,12 +396,25 @@ driDestroyConfigs(const __DRIconfig **configs)
> free(configs);
>  }
>  
> +static struct glx_config *
> +driInferDrawableConfig(struct glx_screen *psc, GLXDrawable draw)
> +{
> +   unsigned int fbconfig = 0;
> +
> +   if (GetDrawableAttribute(psc->dpy, draw, GLX_FBCONFIG_ID, &fbconfig)) {
> +  return glx_config_find_fbconfig(psc->configs, fbconfig);
> +   }
> +
> +   return NULL;
> +}
> +
>  _X_HIDDEN __GLXDRIdrawable *
>  driFetchDrawable(struct glx_context *gc, GLXDrawable glxDrawable)
>  {
> struct glx_display *const priv = __glXInitialize(gc->psc->dpy);
> __GLXDRIdrawable *pdraw;
> struct glx_screen *psc;
> +   struct glx_config *config = gc->config;
>  
> if (priv == NULL)
>return NULL;
> @@ -418,8 +431,13 @@ driFetchDrawable(struct glx_context *gc, GLXDrawable 
> glxDrawable)
>return pdraw;
> }
>  
> -   pdraw = psc->driScreen->createDrawable(psc, glxDrawable,
> -  glxDrawable, gc->config);
> +   if (config == NULL)
> +  config = driInferDrawableConfig(gc->psc, glxDrawable);
> +   if (config == NULL)
> +  return NULL;
> +
> +   pdraw = psc->driScreen->createDrawable(psc, glxDrawable, glxDrawable,
> +  config);
>  
> if (pdraw == NULL) {
>ErrorMessageF("failed to create drawable\n");
> diff --git a/src/glx/glx_pbuffer.c b/src/glx/glx_pbuffer.c
> index 933b5d9ecd..42e7996e37 100644
> --- a/src/glx/glx_pbuffer.c
> +++ b/src/glx/glx_pbuffer.c
> @@ -272,7 +272,7 @@ DestroyDRIDrawable(Display *dpy, GLXDrawable drawable, 
> int destroy_xdrawable)
>   * 10.  Given that, this routine should try to use an array on the stack to
>   * capture the reply rather than always calling Xmalloc.
>   */
> -static int
> +int
>  GetDrawableAttribute(Display * dpy, GLXDrawable drawable,

I'm trying to decide whether or not this needs a __glX prefix now.  Yes?

Other than that, this patch is

Reviewed-by: Ian Romanick 

>   int attribute, unsigned int *value)
>  {
> diff --git a/src/glx/glxclient.h b/src/glx/glxclient.h
> index 0d29e5635e..a448c4c000 100644
> --- a/src/glx/glxclient.h
> +++ b/src/glx/glxclient.h
> @@ -841,6 +841,10 @@ indirect_create_context_attribs(struct glx_screen *base,
>  const uint32_t *attribs,
>  unsigned *error);
>  
> +
> +extern int GetDrawableAttribute(Display * dpy, GLXDrawable drawable,
> +int attribute, unsigned int *value);
> +
>  #ifdef __cplusplus
>  }
>  #endif
> 

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 5/6] glx: Prepare driFetchDrawable for no-config contexts

2017-11-14 Thread Adam Jackson
When we look up the DRI drawable state we need to associate an fbconfig
with the drawable. With GLX_EXT_no_config_context we can no longer infer
that from the context and must instead query the server.

Signed-off-by: Adam Jackson 
---
 src/glx/dri_common.c  | 22 --
 src/glx/glx_pbuffer.c |  2 +-
 src/glx/glxclient.h   |  4 
 3 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/src/glx/dri_common.c b/src/glx/dri_common.c
index 3b82309fa2..0d0b2d997b 100644
--- a/src/glx/dri_common.c
+++ b/src/glx/dri_common.c
@@ -396,12 +396,25 @@ driDestroyConfigs(const __DRIconfig **configs)
free(configs);
 }
 
+static struct glx_config *
+driInferDrawableConfig(struct glx_screen *psc, GLXDrawable draw)
+{
+   unsigned int fbconfig = 0;
+
+   if (GetDrawableAttribute(psc->dpy, draw, GLX_FBCONFIG_ID, &fbconfig)) {
+  return glx_config_find_fbconfig(psc->configs, fbconfig);
+   }
+
+   return NULL;
+}
+
 _X_HIDDEN __GLXDRIdrawable *
 driFetchDrawable(struct glx_context *gc, GLXDrawable glxDrawable)
 {
struct glx_display *const priv = __glXInitialize(gc->psc->dpy);
__GLXDRIdrawable *pdraw;
struct glx_screen *psc;
+   struct glx_config *config = gc->config;
 
if (priv == NULL)
   return NULL;
@@ -418,8 +431,13 @@ driFetchDrawable(struct glx_context *gc, GLXDrawable 
glxDrawable)
   return pdraw;
}
 
-   pdraw = psc->driScreen->createDrawable(psc, glxDrawable,
-  glxDrawable, gc->config);
+   if (config == NULL)
+  config = driInferDrawableConfig(gc->psc, glxDrawable);
+   if (config == NULL)
+  return NULL;
+
+   pdraw = psc->driScreen->createDrawable(psc, glxDrawable, glxDrawable,
+  config);
 
if (pdraw == NULL) {
   ErrorMessageF("failed to create drawable\n");
diff --git a/src/glx/glx_pbuffer.c b/src/glx/glx_pbuffer.c
index 933b5d9ecd..42e7996e37 100644
--- a/src/glx/glx_pbuffer.c
+++ b/src/glx/glx_pbuffer.c
@@ -272,7 +272,7 @@ DestroyDRIDrawable(Display *dpy, GLXDrawable drawable, int 
destroy_xdrawable)
  * 10.  Given that, this routine should try to use an array on the stack to
  * capture the reply rather than always calling Xmalloc.
  */
-static int
+int
 GetDrawableAttribute(Display * dpy, GLXDrawable drawable,
  int attribute, unsigned int *value)
 {
diff --git a/src/glx/glxclient.h b/src/glx/glxclient.h
index 0d29e5635e..a448c4c000 100644
--- a/src/glx/glxclient.h
+++ b/src/glx/glxclient.h
@@ -841,6 +841,10 @@ indirect_create_context_attribs(struct glx_screen *base,
 const uint32_t *attribs,
 unsigned *error);
 
+
+extern int GetDrawableAttribute(Display * dpy, GLXDrawable drawable,
+int attribute, unsigned int *value);
+
 #ifdef __cplusplus
 }
 #endif
-- 
2.14.3

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev