Re: [Mesa-dev] [PATCH v3 3/3] egl: add config debug printout (v3)

2019-04-01 Thread Silvestrs Timofejevs
On Mon, Jan 14, 2019 at 08:20:09PM +, Emil Velikov wrote:
>  e aOn Fri, 11 Jan 2019 at 16:34, Silvestrs Timofejevs
>  wrote:
> >
> > Feature to print out EGL returned configs for debug purposes.
> >
> > 'eglChooseConfig' and 'eglGetConfigs' debug information printout is
> > enabled when the log level equals '_EGL_DEBUG'. The configs are
> > printed, and if any of them are "chosen" they are marked with their
> > index in the chosen configs array.
> >
> > v2:
> >a) refactor the code in line with Eric's comments
> >b) rename function _snprintfStrcat, split it out and put into the
> >   src/util/u_string.h, make it a separate patch.
> > v3:
> >remove unnecessary 'const' qualifiers from the function prototype
> >
> > Signed-off-by: Silvestrs Timofejevs 
> > Reviewed-by: Eric Engestrom 
> > ---
> >  src/egl/Makefile.sources  |   4 +-
> >  src/egl/main/eglconfig.c  |  20 +++-
> >  src/egl/main/eglconfigdebug.c | 265 
> > ++
> >  src/egl/main/eglconfigdebug.h |  55 +
> >  src/egl/meson.build   |   2 +
> >  5 files changed, 341 insertions(+), 5 deletions(-)
> >  create mode 100644 src/egl/main/eglconfigdebug.c
> >  create mode 100644 src/egl/main/eglconfigdebug.h
> >
> > diff --git a/src/egl/Makefile.sources b/src/egl/Makefile.sources
> > index 0cc5f1b..353a848 100644
> > --- a/src/egl/Makefile.sources
> > +++ b/src/egl/Makefile.sources
> > @@ -28,7 +28,9 @@ LIBEGL_C_FILES := \
> > main/eglsync.c \
> > main/eglsync.h \
> > main/eglentrypoint.h \
> > -   main/egltypedefs.h
> > +   main/egltypedefs.h \
> > +   main/eglconfigdebug.h \
> > +   main/eglconfigdebug.c
> >
> >  dri2_backend_core_FILES := \
> > drivers/dri2/egl_dri2.c \
> > diff --git a/src/egl/main/eglconfig.c b/src/egl/main/eglconfig.c
> > index a346f93..0095dc2 100644
> > --- a/src/egl/main/eglconfig.c
> > +++ b/src/egl/main/eglconfig.c
> > @@ -40,6 +40,7 @@
> >  #include "util/macros.h"
> >
> >  #include "eglconfig.h"
> > +#include "eglconfigdebug.h"
> >  #include "egldisplay.h"
> >  #include "eglcurrent.h"
> >  #include "egllog.h"
> > @@ -797,14 +798,21 @@ _eglChooseConfig(_EGLDriver *drv, _EGLDisplay *disp, 
> > const EGLint *attrib_list,
> >   EGLConfig *configs, EGLint config_size, EGLint 
> > *num_configs)
> >  {
> > _EGLConfig criteria;
> > +   EGLBoolean result;
> >
> > if (!_eglParseConfigAttribList(, disp, attrib_list))
> >return _eglError(EGL_BAD_ATTRIBUTE, "eglChooseConfig");
> >
> > -   return _eglFilterConfigArray(disp->Configs,
> > - configs, config_size, num_configs,
> > - _eglFallbackMatch, _eglFallbackCompare,
> > - (void *) );
> > +   result = _eglFilterConfigArray(disp->Configs,
> > +  configs, config_size, num_configs,
> > +  _eglFallbackMatch, _eglFallbackCompare,
> > +  (void *) );
> > +
> > +   if (result && (_eglGetLogLevel() == _EGL_DEBUG))
> > +  eglPrintConfigDebug(drv, disp, configs, *num_configs,
> > +  EGL_CONFIG_DEBUG_CHOOSE);
> > +
> > +   return result;
> >  }
> >
> >
> > @@ -857,5 +865,9 @@ _eglGetConfigs(_EGLDriver *drv, _EGLDisplay *disp, 
> > EGLConfig *configs,
> > *num_config = _eglFlattenArray(disp->Configs, (void *) configs,
> >   sizeof(configs[0]), config_size, _eglFlattenConfig);
> >
> > +   if (_eglGetLogLevel() == _EGL_DEBUG)
> > +  eglPrintConfigDebug(drv, disp, configs, *num_config,
> > +  EGL_CONFIG_DEBUG_GET);
> > +
> > return EGL_TRUE;
> >  }
> > diff --git a/src/egl/main/eglconfigdebug.c b/src/egl/main/eglconfigdebug.c
> > new file mode 100644
> > index 000..0617c99
> > --- /dev/null
> > +++ b/src/egl/main/eglconfigdebug.c
> > @@ -0,0 +1,265 @@
> > +/*
> > + * Copyright 2017 Imagination Technologies.
> > + * All Rights Reserved.
> > + *
> > + * Based on eglinfo, which has copyright:
> > + * Copyright (C) 2005  Brian Paul   All Rights Reserved.
> > + *
> > + * Permission is hereby granted, free of charge, to any person obtaining a
> > + * copy of this software and associated documentation files (the 
> > "Software"),
> > + * to deal in the Software without restriction, including without 
> > limitation
> > + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> > + * and/or sell copies of the Software, and to permit persons to whom the
> > + * Software is furnished to do so, subject to the following conditions:
> > + *
> > + * The above copyright notice and this permission notice shall be included
> > + * in all copies or substantial portions of the Software.
> > + *
> > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
> > + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
> > MERCHANTABILITY,
> > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> > + * BRIAN 

Re: [Mesa-dev] [PATCH v3 3/3] egl: add config debug printout (v3)

2019-01-14 Thread Emil Velikov
 e aOn Fri, 11 Jan 2019 at 16:34, Silvestrs Timofejevs
 wrote:
>
> Feature to print out EGL returned configs for debug purposes.
>
> 'eglChooseConfig' and 'eglGetConfigs' debug information printout is
> enabled when the log level equals '_EGL_DEBUG'. The configs are
> printed, and if any of them are "chosen" they are marked with their
> index in the chosen configs array.
>
> v2:
>a) refactor the code in line with Eric's comments
>b) rename function _snprintfStrcat, split it out and put into the
>   src/util/u_string.h, make it a separate patch.
> v3:
>remove unnecessary 'const' qualifiers from the function prototype
>
> Signed-off-by: Silvestrs Timofejevs 
> Reviewed-by: Eric Engestrom 
> ---
>  src/egl/Makefile.sources  |   4 +-
>  src/egl/main/eglconfig.c  |  20 +++-
>  src/egl/main/eglconfigdebug.c | 265 
> ++
>  src/egl/main/eglconfigdebug.h |  55 +
>  src/egl/meson.build   |   2 +
>  5 files changed, 341 insertions(+), 5 deletions(-)
>  create mode 100644 src/egl/main/eglconfigdebug.c
>  create mode 100644 src/egl/main/eglconfigdebug.h
>
> diff --git a/src/egl/Makefile.sources b/src/egl/Makefile.sources
> index 0cc5f1b..353a848 100644
> --- a/src/egl/Makefile.sources
> +++ b/src/egl/Makefile.sources
> @@ -28,7 +28,9 @@ LIBEGL_C_FILES := \
> main/eglsync.c \
> main/eglsync.h \
> main/eglentrypoint.h \
> -   main/egltypedefs.h
> +   main/egltypedefs.h \
> +   main/eglconfigdebug.h \
> +   main/eglconfigdebug.c
>
>  dri2_backend_core_FILES := \
> drivers/dri2/egl_dri2.c \
> diff --git a/src/egl/main/eglconfig.c b/src/egl/main/eglconfig.c
> index a346f93..0095dc2 100644
> --- a/src/egl/main/eglconfig.c
> +++ b/src/egl/main/eglconfig.c
> @@ -40,6 +40,7 @@
>  #include "util/macros.h"
>
>  #include "eglconfig.h"
> +#include "eglconfigdebug.h"
>  #include "egldisplay.h"
>  #include "eglcurrent.h"
>  #include "egllog.h"
> @@ -797,14 +798,21 @@ _eglChooseConfig(_EGLDriver *drv, _EGLDisplay *disp, 
> const EGLint *attrib_list,
>   EGLConfig *configs, EGLint config_size, EGLint *num_configs)
>  {
> _EGLConfig criteria;
> +   EGLBoolean result;
>
> if (!_eglParseConfigAttribList(, disp, attrib_list))
>return _eglError(EGL_BAD_ATTRIBUTE, "eglChooseConfig");
>
> -   return _eglFilterConfigArray(disp->Configs,
> - configs, config_size, num_configs,
> - _eglFallbackMatch, _eglFallbackCompare,
> - (void *) );
> +   result = _eglFilterConfigArray(disp->Configs,
> +  configs, config_size, num_configs,
> +  _eglFallbackMatch, _eglFallbackCompare,
> +  (void *) );
> +
> +   if (result && (_eglGetLogLevel() == _EGL_DEBUG))
> +  eglPrintConfigDebug(drv, disp, configs, *num_configs,
> +  EGL_CONFIG_DEBUG_CHOOSE);
> +
> +   return result;
>  }
>
>
> @@ -857,5 +865,9 @@ _eglGetConfigs(_EGLDriver *drv, _EGLDisplay *disp, 
> EGLConfig *configs,
> *num_config = _eglFlattenArray(disp->Configs, (void *) configs,
>   sizeof(configs[0]), config_size, _eglFlattenConfig);
>
> +   if (_eglGetLogLevel() == _EGL_DEBUG)
> +  eglPrintConfigDebug(drv, disp, configs, *num_config,
> +  EGL_CONFIG_DEBUG_GET);
> +
> return EGL_TRUE;
>  }
> diff --git a/src/egl/main/eglconfigdebug.c b/src/egl/main/eglconfigdebug.c
> new file mode 100644
> index 000..0617c99
> --- /dev/null
> +++ b/src/egl/main/eglconfigdebug.c
> @@ -0,0 +1,265 @@
> +/*
> + * Copyright 2017 Imagination Technologies.
> + * All Rights Reserved.
> + *
> + * Based on eglinfo, which has copyright:
> + * Copyright (C) 2005  Brian Paul   All Rights Reserved.
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice shall be included
> + * in all copies or substantial portions of the Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
> + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
> MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
> + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
> + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "eglarray.h"
> 

[Mesa-dev] [PATCH v3 3/3] egl: add config debug printout (v3)

2019-01-11 Thread Silvestrs Timofejevs
Feature to print out EGL returned configs for debug purposes.

'eglChooseConfig' and 'eglGetConfigs' debug information printout is
enabled when the log level equals '_EGL_DEBUG'. The configs are
printed, and if any of them are "chosen" they are marked with their
index in the chosen configs array.

v2:
   a) refactor the code in line with Eric's comments
   b) rename function _snprintfStrcat, split it out and put into the
  src/util/u_string.h, make it a separate patch.
v3:
   remove unnecessary 'const' qualifiers from the function prototype

Signed-off-by: Silvestrs Timofejevs 
Reviewed-by: Eric Engestrom 
---
 src/egl/Makefile.sources  |   4 +-
 src/egl/main/eglconfig.c  |  20 +++-
 src/egl/main/eglconfigdebug.c | 265 ++
 src/egl/main/eglconfigdebug.h |  55 +
 src/egl/meson.build   |   2 +
 5 files changed, 341 insertions(+), 5 deletions(-)
 create mode 100644 src/egl/main/eglconfigdebug.c
 create mode 100644 src/egl/main/eglconfigdebug.h

diff --git a/src/egl/Makefile.sources b/src/egl/Makefile.sources
index 0cc5f1b..353a848 100644
--- a/src/egl/Makefile.sources
+++ b/src/egl/Makefile.sources
@@ -28,7 +28,9 @@ LIBEGL_C_FILES := \
main/eglsync.c \
main/eglsync.h \
main/eglentrypoint.h \
-   main/egltypedefs.h
+   main/egltypedefs.h \
+   main/eglconfigdebug.h \
+   main/eglconfigdebug.c
 
 dri2_backend_core_FILES := \
drivers/dri2/egl_dri2.c \
diff --git a/src/egl/main/eglconfig.c b/src/egl/main/eglconfig.c
index a346f93..0095dc2 100644
--- a/src/egl/main/eglconfig.c
+++ b/src/egl/main/eglconfig.c
@@ -40,6 +40,7 @@
 #include "util/macros.h"
 
 #include "eglconfig.h"
+#include "eglconfigdebug.h"
 #include "egldisplay.h"
 #include "eglcurrent.h"
 #include "egllog.h"
@@ -797,14 +798,21 @@ _eglChooseConfig(_EGLDriver *drv, _EGLDisplay *disp, 
const EGLint *attrib_list,
  EGLConfig *configs, EGLint config_size, EGLint *num_configs)
 {
_EGLConfig criteria;
+   EGLBoolean result;
 
if (!_eglParseConfigAttribList(, disp, attrib_list))
   return _eglError(EGL_BAD_ATTRIBUTE, "eglChooseConfig");
 
-   return _eglFilterConfigArray(disp->Configs,
- configs, config_size, num_configs,
- _eglFallbackMatch, _eglFallbackCompare,
- (void *) );
+   result = _eglFilterConfigArray(disp->Configs,
+  configs, config_size, num_configs,
+  _eglFallbackMatch, _eglFallbackCompare,
+  (void *) );
+
+   if (result && (_eglGetLogLevel() == _EGL_DEBUG))
+  eglPrintConfigDebug(drv, disp, configs, *num_configs,
+  EGL_CONFIG_DEBUG_CHOOSE);
+
+   return result;
 }
 
 
@@ -857,5 +865,9 @@ _eglGetConfigs(_EGLDriver *drv, _EGLDisplay *disp, 
EGLConfig *configs,
*num_config = _eglFlattenArray(disp->Configs, (void *) configs,
  sizeof(configs[0]), config_size, _eglFlattenConfig);
 
+   if (_eglGetLogLevel() == _EGL_DEBUG)
+  eglPrintConfigDebug(drv, disp, configs, *num_config,
+  EGL_CONFIG_DEBUG_GET);
+
return EGL_TRUE;
 }
diff --git a/src/egl/main/eglconfigdebug.c b/src/egl/main/eglconfigdebug.c
new file mode 100644
index 000..0617c99
--- /dev/null
+++ b/src/egl/main/eglconfigdebug.c
@@ -0,0 +1,265 @@
+/*
+ * Copyright 2017 Imagination Technologies.
+ * All Rights Reserved.
+ *
+ * Based on eglinfo, which has copyright:
+ * Copyright (C) 2005  Brian Paul   All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include "eglarray.h"
+#include "eglconfig.h"
+#include "eglconfigdebug.h"
+#include "egldisplay.h"
+#include "egllog.h"
+#include "egltypedefs.h"
+#include "util/macros.h"
+#include "util/u_string.h"
+
+/* Max debug message length */
+#define CONFIG_DEBUG_MSG_MAX 1000
+
+/*
+ * These are X visual types, so if you're running eglinfo