egl/wayland: replace EGL_DRI2_MAX_FORMATS by EGL_DRI2_NUM_FORMATS
Currently we have a weird design. We have a hardcoded array (named dri2_wl_visuals) with all the formats that we support, which are 9. And we also have EGL_DRI2_MAX_FORMATS, which is a constant set to 10. In patches in which people added new formats to dri2_wl_visuals, this constant had its value increased. This is confusing, as its name gives the idea that we can't support more formats. This constant is only used to define the bitset size of dri2_egl_display::formats. And it should work just fine if we created this bitset with the number of formats supported. To make things clearer, replace EGL_DRI2_MAX_FORMATS by EGL_DRI2_NUM_FORMATS, which must be equal to ARRAY_SIZE(dri2_wl_visuals) (i.e. the number of supported formats). In the next commits we get rid of this constant completely, as it is prone to errors. Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com> Reviewed-by: Daniel Stone <daniels@collabora.com> Reviewed-by: Simon Ser <contact@emersion.fr> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11248>
This commit is contained in:
parent
42a0e5caa9
commit
3022ad7e15
|
@ -89,7 +89,7 @@ struct zwp_linux_dmabuf_v1;
|
|||
#include "util/u_vector.h"
|
||||
#include "util/bitset.h"
|
||||
|
||||
#define EGL_DRI2_MAX_FORMATS 11
|
||||
#define EGL_DRI2_NUM_FORMATS 11
|
||||
|
||||
struct wl_buffer;
|
||||
|
||||
|
@ -246,7 +246,7 @@ struct dri2_egl_display
|
|||
struct zwp_linux_dmabuf_v1 *wl_dmabuf;
|
||||
struct u_vector *wl_modifiers;
|
||||
bool authenticated;
|
||||
BITSET_DECLARE(formats, EGL_DRI2_MAX_FORMATS);
|
||||
BITSET_DECLARE(formats, EGL_DRI2_NUM_FORMATS);
|
||||
uint32_t capabilities;
|
||||
char *device_name;
|
||||
#endif
|
||||
|
|
|
@ -151,9 +151,10 @@ static const struct dri2_wl_visual {
|
|||
},
|
||||
};
|
||||
|
||||
static_assert(ARRAY_SIZE(dri2_wl_visuals) <= EGL_DRI2_MAX_FORMATS,
|
||||
"dri2_egl_display::formats is not large enough for "
|
||||
"the formats in dri2_wl_visuals");
|
||||
static_assert(ARRAY_SIZE(dri2_wl_visuals) == EGL_DRI2_NUM_FORMATS,
|
||||
"dri2_egl_display::formats and dri2_wl_visuals must "
|
||||
"have the same size. If you are adding a new format "
|
||||
"to dri2_wl_visuals, increment EGL_DRI2_NUM_FORMATS");
|
||||
|
||||
static int
|
||||
dri2_wl_visual_idx_from_config(struct dri2_egl_display *dri2_dpy,
|
||||
|
@ -2112,7 +2113,7 @@ dri2_initialize_wayland_swrast(_EGLDisplay *disp)
|
|||
goto cleanup;
|
||||
|
||||
if (roundtrip(dri2_dpy) < 0 || !BITSET_TEST_RANGE(dri2_dpy->formats,
|
||||
0, EGL_DRI2_MAX_FORMATS))
|
||||
0, EGL_DRI2_NUM_FORMATS))
|
||||
goto cleanup;
|
||||
|
||||
dri2_dpy->driver_name = strdup("swrast");
|
||||
|
|
Loading…
Reference in New Issue