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 <ian.d.romanick@intel.com>
Signed-off-by: Martin Peres <martin.peres@mupuf.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7212>
This commit is contained in:
Ian Romanick
2020-10-21 08:40:44 +03:00
committed by Martin Peres
parent 1331b86299
commit 74722c3ab9

View File

@@ -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;
}
}