[Mesa-dev] [PATCH] dri: use 'bool' instead 'int' for boolean variables

Ian Romanick idr at freedesktop.org
Mon Aug 8 17:45:05 UTC 2016


On 08/08/2016 10:20 AM, Rob Clark wrote:
> how strict are we on that actually?  I think whenever we add new gl
> entry points (ie. implementing new extension, etc) we kinda sorta
> break ABI, don't we?  I thought mixing/matching libGL vs *_dri.so was
> at least not recommended..

No... we go to great lengths to make *_dri.so query libGL to know where
a new function goes in the dispatch table.  If libGL doesn't know a
location for the new function, it dynamically assigns one.  That's what
all the remap table stuff is.

> BR,
> -R
> 
> On Mon, Aug 8, 2016 at 12:22 PM, Ian Romanick <idr at freedesktop.org> wrote:
>> I'm pretty sure this breaks ABI.  Did you try using an unpatched libGL
>> with a patched *_dri.so (and vice-versa)?
>>
>> On 08/01/2016 06:21 AM, Jan Ziak wrote:
>>> Signed-off-by: Jan Ziak (http://atom-symbol.net) <0xe2.0x9a.0x9b at gmail.com>
>>> ---
>>>  src/egl/drivers/dri2/egl_dri2.h           | 19 ++++++++++---------
>>>  src/gallium/auxiliary/vl/vl_winsys_dri3.c |  3 ++-
>>>  src/glx/dri3_priv.h                       |  5 +++--
>>>  src/loader/loader.c                       |  7 ++++---
>>>  src/loader/loader.h                       |  4 +++-
>>>  5 files changed, 22 insertions(+), 16 deletions(-)
>>>
>>> diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
>>> index 4577875..e406443 100644
>>> --- a/src/egl/drivers/dri2/egl_dri2.h
>>> +++ b/src/egl/drivers/dri2/egl_dri2.h
>>> @@ -28,6 +28,7 @@
>>>  #ifndef EGL_DRI2_INCLUDED
>>>  #define EGL_DRI2_INCLUDED
>>>
>>> +#include <stdbool.h>
>>>  #include <stdint.h>
>>>
>>>  #ifdef HAVE_X11_PLATFORM
>>> @@ -160,7 +161,7 @@ struct dri2_egl_display
>>>     int                       dri2_major;
>>>     int                       dri2_minor;
>>>     __DRIscreen              *dri_screen;
>>> -   int                       own_dri_screen;
>>> +   bool                      own_dri_screen;
>>>     const __DRIconfig       **driver_configs;
>>>     void                     *driver;
>>>     const __DRIcoreExtension       *core;
>>> @@ -181,8 +182,8 @@ struct dri2_egl_display
>>>      * dri2_make_current (tracks if there are active contexts/surfaces). */
>>>     int                       ref_count;
>>>
>>> -   int                       own_device;
>>> -   int                       invalidate_available;
>>> +   bool                      own_device;
>>> +   bool                      invalidate_available;
>>>     int                       min_swap_interval;
>>>     int                       max_swap_interval;
>>>     int                       default_swap_interval;
>>> @@ -201,7 +202,7 @@ struct dri2_egl_display
>>>  #ifdef HAVE_X11_PLATFORM
>>>     xcb_connection_t         *conn;
>>>     int                      screen;
>>> -   int                      swap_available;
>>> +   bool                     swap_available;
>>>  #ifdef HAVE_DRI3
>>>     struct loader_dri3_extensions loader_dri3_ext;
>>>  #endif
>>> @@ -214,13 +215,13 @@ struct dri2_egl_display
>>>     struct wl_drm            *wl_drm;
>>>     struct wl_shm            *wl_shm;
>>>     struct wl_event_queue    *wl_queue;
>>> -   int                            authenticated;
>>> +   bool                      authenticated;
>>>     int                            formats;
>>>     uint32_t                  capabilities;
>>>  #endif
>>>
>>> -   int              is_render_node;
>>> -   int                            is_different_gpu;
>>> +   bool is_render_node;
>>> +   bool is_different_gpu;
>>>  };
>>>
>>>  struct dri2_egl_context
>>> @@ -244,7 +245,7 @@ struct dri2_egl_surface
>>>     __DRIdrawable       *dri_drawable;
>>>     __DRIbuffer          buffers[5];
>>>     int                  buffer_count;
>>> -   int                  have_fake_front;
>>> +   bool                 have_fake_front;
>>>
>>>  #ifdef HAVE_X11_PLATFORM
>>>     xcb_drawable_t       drawable;
>>> @@ -282,7 +283,7 @@ struct dri2_egl_surface
>>>  #ifdef HAVE_DRM_PLATFORM
>>>        struct gbm_bo       *bo;
>>>  #endif
>>> -      int                 locked;
>>> +      bool                locked;
>>>        int                 age;
>>>     } color_buffers[4], *back, *current;
>>>  #endif
>>> diff --git a/src/gallium/auxiliary/vl/vl_winsys_dri3.c b/src/gallium/auxiliary/vl/vl_winsys_dri3.c
>>> index 493e645..7cb6c18 100644
>>> --- a/src/gallium/auxiliary/vl/vl_winsys_dri3.c
>>> +++ b/src/gallium/auxiliary/vl/vl_winsys_dri3.c
>>> @@ -25,6 +25,7 @@
>>>   *
>>>   **************************************************************************/
>>>
>>> +#include <stdbool.h>
>>>  #include <fcntl.h>
>>>
>>>  #include <X11/Xlib-xcb.h>
>>> @@ -627,7 +628,7 @@ vl_dri3_screen_create(Display *display, int screen)
>>>     xcb_dri3_open_reply_t *open_reply;
>>>     xcb_get_geometry_cookie_t geom_cookie;
>>>     xcb_get_geometry_reply_t *geom_reply;
>>> -   int is_different_gpu;
>>> +   bool is_different_gpu;
>>>     int fd;
>>>
>>>     assert(display);
>>> diff --git a/src/glx/dri3_priv.h b/src/glx/dri3_priv.h
>>> index 0822377..bfb0786 100644
>>> --- a/src/glx/dri3_priv.h
>>> +++ b/src/glx/dri3_priv.h
>>> @@ -54,6 +54,7 @@
>>>   *   Kristian Høgsberg (krh at redhat.com)
>>>   */
>>>
>>> +#include <stdbool.h>
>>>  #include <xcb/xcb.h>
>>>  #include <xcb/dri3.h>
>>>  #include <xcb/present.h>
>>> @@ -78,7 +79,7 @@ struct dri3_display
>>>     int dri3Minor;
>>>
>>>     /* Present bits */
>>> -   int hasPresent;
>>> +   bool hasPresent;
>>>     int presentMajor;
>>>     int presentMinor;
>>>  };
>>> @@ -101,7 +102,7 @@ struct dri3_screen {
>>>
>>>     void *driver;
>>>     int fd;
>>> -   int is_different_gpu;
>>> +   bool is_different_gpu;
>>>
>>>     int show_fps_interval;
>>>
>>> diff --git a/src/loader/loader.c b/src/loader/loader.c
>>> index 56ffc5d..a3b75c7 100644
>>> --- a/src/loader/loader.c
>>> +++ b/src/loader/loader.c
>>> @@ -356,7 +356,7 @@ DRI_CONF_BEGIN
>>>  DRI_CONF_END;
>>>  #endif
>>>
>>> -int loader_get_user_preferred_fd(int default_fd, int *different_device)
>>> +int loader_get_user_preferred_fd(int default_fd, bool *different_device)
>>>  {
>>>     struct udev *udev;
>>>  #ifdef USE_DRICONF
>>> @@ -365,7 +365,8 @@ int loader_get_user_preferred_fd(int default_fd, int *different_device)
>>>  #endif
>>>     const char *dri_prime = getenv("DRI_PRIME");
>>>     char *prime = NULL;
>>> -   int is_different_device = 0, fd = default_fd;
>>> +   bool is_different_device = 0;
>>> +   int fd = default_fd;
>>>     char *default_device_id_path_tag;
>>>     char *device_name = NULL;
>>>     char another_tag = 0;
>>> @@ -441,7 +442,7 @@ int loader_get_user_preferred_fd(int default_fd, int *different_device)
>>>     return fd;
>>>  }
>>>  #else
>>> -int loader_get_user_preferred_fd(int default_fd, int *different_device)
>>> +int loader_get_user_preferred_fd(int default_fd, bool *different_device)
>>>  {
>>>     *different_device = 0;
>>>     return default_fd;
>>> diff --git a/src/loader/loader.h b/src/loader/loader.h
>>> index 055dc78..cead7a3 100644
>>> --- a/src/loader/loader.h
>>> +++ b/src/loader/loader.h
>>> @@ -27,6 +27,8 @@
>>>  #ifndef LOADER_H
>>>  #define LOADER_H
>>>
>>> +#include <stdbool.h>
>>> +
>>>  #ifdef __cplusplus
>>>  extern "C" {
>>>  #endif
>>> @@ -54,7 +56,7 @@ loader_get_device_name_for_fd(int fd);
>>>   */
>>>
>>>  int
>>> -loader_get_user_preferred_fd(int default_fd, int *different_device);
>>> +loader_get_user_preferred_fd(int default_fd, bool *different_device);
>>>
>>>  /* for logging.. keep this aligned with egllog.h so we can just use
>>>   * _eglLog directly.
>>> _______________________________________________
>>> mesa-dev mailing list
>>> mesa-dev at lists.freedesktop.org
>>> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>>>
>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
> 



More information about the mesa-dev mailing list