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>
diff --git a/src/glx/glxextensions.c b/src/glx/glxextensions.c
index d26168e..ba14487 100644
--- a/src/glx/glxextensions.c
+++ b/src/glx/glxextensions.c
@@ -695,17 +695,33 @@
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;
}
}