From 74722c3ab910921296a87596ea6d7460e1f75818 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 21 Oct 2020 08:40:44 +0300 Subject: [PATCH] glx: rework __glXCalculateUsableExtensions to be more readable We are about to make the GLX extension equation even more complex by adding force-enable/disable. Before doing so, split the line into multiple stages that can get a proper comment to explain what is going on. The code is taken mostly verbatim from Ian Romanick's comment: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7212#note_668045 Reviewed-by: Ian Romanick Signed-off-by: Martin Peres Part-of: --- src/glx/glxextensions.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/src/glx/glxextensions.c b/src/glx/glxextensions.c index d26168e4176..ba14487b070 100644 --- a/src/glx/glxextensions.c +++ b/src/glx/glxextensions.c @@ -695,17 +695,33 @@ __glXCalculateUsableExtensions(struct glx_screen * psc, if (display_is_direct_capable) { for (i = 0; i < __GLX_EXT_BYTES; i++) { - usable[i] = (client_glx_support[i] & client_glx_only[i]) - | (client_glx_support[i] & psc->direct_support[i] & - server_support[i]) - | (client_glx_support[i] & psc->direct_support[i] & - direct_glx_only[i]); + /* Enable extensions that the client supports that only have a client-side + * component. + */ + unsigned char u = client_glx_support[i] & client_glx_only[i]; + + /* Enable extensions that the client supports, are supported for direct + * rendering, and either are supported by the server or only have a + * direct-rendering component. + */ + u |= client_glx_support[i] & psc->direct_support[i] & + (server_support[i] | direct_glx_only[i]); + + usable[i] = u; + } } else { for (i = 0; i < __GLX_EXT_BYTES; i++) { - usable[i] = (client_glx_support[i] & client_glx_only[i]) - | (client_glx_support[i] & server_support[i]); + /* Enable extensions that the client supports that only have a + * client-side component. + */ + unsigned char u = client_glx_support[i] & client_glx_only[i]; + + /* Enable extensions that the client and server both support */ + u |= client_glx_support[i] & server_support[i]; + + usable[i] = u; } }