loader/glx: move multibuffers check to loader
make this code more reusable Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30128>
This commit is contained in:
committed by
Marge Bot
parent
63191107ab
commit
293c7b38ff
@@ -2414,3 +2414,73 @@ dri3_find_back_alloc(struct loader_dri3_drawable *draw)
|
||||
|
||||
return back;
|
||||
}
|
||||
|
||||
/* Only request versions of these protocols which we actually support. */
|
||||
#define DRI3_SUPPORTED_MAJOR 1
|
||||
#define PRESENT_SUPPORTED_MAJOR 1
|
||||
|
||||
#ifdef HAVE_DRI3_MODIFIERS
|
||||
#define DRI3_SUPPORTED_MINOR 2
|
||||
#define PRESENT_SUPPORTED_MINOR 2
|
||||
#else
|
||||
#define PRESENT_SUPPORTED_MINOR 0
|
||||
#define DRI3_SUPPORTED_MINOR 0
|
||||
#endif
|
||||
|
||||
bool
|
||||
loader_dri3_check_multibuffer(xcb_connection_t *c, bool *err)
|
||||
{
|
||||
xcb_dri3_query_version_cookie_t dri3_cookie;
|
||||
xcb_dri3_query_version_reply_t *dri3_reply;
|
||||
xcb_present_query_version_cookie_t present_cookie;
|
||||
xcb_present_query_version_reply_t *present_reply;
|
||||
xcb_generic_error_t *error;
|
||||
const xcb_query_extension_reply_t *extension;
|
||||
|
||||
xcb_prefetch_extension_data(c, &xcb_dri3_id);
|
||||
xcb_prefetch_extension_data(c, &xcb_present_id);
|
||||
|
||||
extension = xcb_get_extension_data(c, &xcb_dri3_id);
|
||||
if (!(extension && extension->present))
|
||||
goto error;
|
||||
|
||||
extension = xcb_get_extension_data(c, &xcb_present_id);
|
||||
if (!(extension && extension->present))
|
||||
goto error;
|
||||
|
||||
dri3_cookie = xcb_dri3_query_version(c,
|
||||
DRI3_SUPPORTED_MAJOR,
|
||||
DRI3_SUPPORTED_MINOR);
|
||||
present_cookie = xcb_present_query_version(c,
|
||||
PRESENT_SUPPORTED_MAJOR,
|
||||
PRESENT_SUPPORTED_MINOR);
|
||||
|
||||
dri3_reply = xcb_dri3_query_version_reply(c, dri3_cookie, &error);
|
||||
if (!dri3_reply) {
|
||||
free(error);
|
||||
goto error;
|
||||
}
|
||||
|
||||
int dri3Major = dri3_reply->major_version;
|
||||
int dri3Minor = dri3_reply->minor_version;
|
||||
free(dri3_reply);
|
||||
|
||||
present_reply = xcb_present_query_version_reply(c, present_cookie, &error);
|
||||
if (!present_reply) {
|
||||
free(error);
|
||||
goto error;
|
||||
}
|
||||
int presentMajor = present_reply->major_version;
|
||||
int presentMinor = present_reply->minor_version;
|
||||
free(present_reply);
|
||||
|
||||
#ifdef HAVE_DRI3_MODIFIERS
|
||||
if ((dri3Major > 1 || (dri3Major == 1 && dri3Minor >= 2)) &&
|
||||
(presentMajor > 1 || (presentMajor == 1 && presentMinor >= 2)))
|
||||
return true;
|
||||
#endif
|
||||
return false;
|
||||
error:
|
||||
*err = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -297,4 +297,6 @@ loader_dri3_swapbuffer_barrier(struct loader_dri3_drawable *draw);
|
||||
void
|
||||
loader_dri3_close_screen(__DRIscreen *dri_screen);
|
||||
|
||||
bool
|
||||
loader_dri3_check_multibuffer(xcb_connection_t *c, bool *err);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user