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
@@ -1051,78 +1051,6 @@ dri3_destroy_display(__GLXDRIdisplay * dpy)
|
|||||||
free(dpy);
|
free(dpy);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 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
|
|
||||||
dri3_check_multibuffer(Display * dpy, bool *err)
|
|
||||||
{
|
|
||||||
xcb_connection_t *c = XGetXCBConnection(dpy);
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** dri3_create_display
|
/** dri3_create_display
|
||||||
*
|
*
|
||||||
* Allocate, initialize and return a __DRIdisplayPrivate object.
|
* Allocate, initialize and return a __DRIdisplayPrivate object.
|
||||||
@@ -1135,7 +1063,7 @@ dri3_create_display(Display * dpy)
|
|||||||
{
|
{
|
||||||
struct dri3_display *pdp;
|
struct dri3_display *pdp;
|
||||||
bool err = false;
|
bool err = false;
|
||||||
bool has_multibuffer = dri3_check_multibuffer(dpy, &err);
|
bool has_multibuffer = loader_dri3_check_multibuffer(XGetXCBConnection(dpy), &err);
|
||||||
if (err)
|
if (err)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@@ -119,9 +119,6 @@ struct dri3_drawable {
|
|||||||
unsigned frames;
|
unsigned frames;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool
|
|
||||||
dri3_check_multibuffer(Display * dpy, bool *err);
|
|
||||||
|
|
||||||
_X_HIDDEN int
|
_X_HIDDEN int
|
||||||
dri3_query_renderer_integer(struct glx_screen *base, int attribute,
|
dri3_query_renderer_integer(struct glx_screen *base, int attribute,
|
||||||
unsigned int *value);
|
unsigned int *value);
|
||||||
|
@@ -999,7 +999,7 @@ driswCreateScreenDriver(int screen, struct glx_display *priv,
|
|||||||
#if defined(HAVE_DRI3)
|
#if defined(HAVE_DRI3)
|
||||||
if (pdpyp->zink) {
|
if (pdpyp->zink) {
|
||||||
bool err;
|
bool err;
|
||||||
psc->has_multibuffer = dri3_check_multibuffer(priv->dpy, &err);
|
psc->has_multibuffer = loader_dri3_check_multibuffer(XGetXCBConnection(priv->dpy), &err);
|
||||||
if (!psc->has_multibuffer &&
|
if (!psc->has_multibuffer &&
|
||||||
!debug_get_bool_option("LIBGL_ALWAYS_SOFTWARE", false) &&
|
!debug_get_bool_option("LIBGL_ALWAYS_SOFTWARE", false) &&
|
||||||
!debug_get_bool_option("LIBGL_KOPPER_DRI2", false)) {
|
!debug_get_bool_option("LIBGL_KOPPER_DRI2", false)) {
|
||||||
|
@@ -2414,3 +2414,73 @@ dri3_find_back_alloc(struct loader_dri3_drawable *draw)
|
|||||||
|
|
||||||
return back;
|
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
|
void
|
||||||
loader_dri3_close_screen(__DRIscreen *dri_screen);
|
loader_dri3_close_screen(__DRIscreen *dri_screen);
|
||||||
|
|
||||||
|
bool
|
||||||
|
loader_dri3_check_multibuffer(xcb_connection_t *c, bool *err);
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user