glx: don't call GL functions directly, use the current dispatch instead

With glvnd, GL functions will not be publicly exported from libGLX_mesa
and we don't even need them privately defined.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33634>
This commit is contained in:
Marek Olšák 2025-02-21 01:14:39 -05:00 committed by Marge Bot
parent 0204609365
commit ebf6008434
3 changed files with 29 additions and 25 deletions

View file

@ -43,6 +43,8 @@
#include "kopper_interface.h"
#include "loader_dri_helper.h"
#include "dri_util.h"
#include "mapi/glapi/glapi.h"
#include "mesa/main/dispatch.h"
static int xshm_error = 0;
static int xshm_opcode = -1;
@ -540,7 +542,7 @@ driswSwapBuffers(__GLXDRIdrawable * pdraw,
(void) remainder;
if (flush) {
glFlush();
CALL_Flush(GET_DISPATCH(), ());
}
if (psc->kopper)
@ -556,7 +558,7 @@ drisw_copy_sub_buffer(__GLXDRIdrawable * pdraw,
int x, int y, int width, int height, Bool flush)
{
if (flush) {
glFlush();
CALL_Flush(GET_DISPATCH(), ());
}
driswCopySubBuffer(pdraw->dri_drawable, x, y, width, height);

View file

@ -113,7 +113,7 @@ if with_platform_windows
endif
libglx = static_library(
'glx',
[files_libglx, glx_generated],
[files_libglx, glx_generated, main_dispatch_h],
include_directories : [inc_include, inc_src, inc_glapi, inc_loader, inc_loader_x11,
inc_gallium, inc_mesa, inc_st_dri, inc_gallium_aux],
c_args : [

View file

@ -36,6 +36,8 @@
#ifdef GLX_DIRECT_RENDERING
#include "glxclient.h"
#include "mapi/glapi/glapi.h"
#include "mesa/main/dispatch.h"
/* Implementation. */
@ -197,22 +199,22 @@ DRI_glXUseXFont(struct glx_context *CC, Font font, int first, int count, int lis
#endif
/* Save the current packing mode for bitmaps. */
glGetIntegerv(GL_UNPACK_SWAP_BYTES, &swapbytes);
glGetIntegerv(GL_UNPACK_LSB_FIRST, &lsbfirst);
glGetIntegerv(GL_UNPACK_ROW_LENGTH, &rowlength);
glGetIntegerv(GL_UNPACK_SKIP_ROWS, &skiprows);
glGetIntegerv(GL_UNPACK_SKIP_PIXELS, &skippixels);
glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment);
CALL_GetIntegerv(GET_DISPATCH(), (GL_UNPACK_SWAP_BYTES, &swapbytes));
CALL_GetIntegerv(GET_DISPATCH(), (GL_UNPACK_LSB_FIRST, &lsbfirst));
CALL_GetIntegerv(GET_DISPATCH(), (GL_UNPACK_ROW_LENGTH, &rowlength));
CALL_GetIntegerv(GET_DISPATCH(), (GL_UNPACK_SKIP_ROWS, &skiprows));
CALL_GetIntegerv(GET_DISPATCH(), (GL_UNPACK_SKIP_PIXELS, &skippixels));
CALL_GetIntegerv(GET_DISPATCH(), (GL_UNPACK_ALIGNMENT, &alignment));
/* Enforce a standard packing mode which is compatible with
fill_bitmap() from above. This is actually the default mode,
except for the (non)alignment. */
glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE);
glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE);
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
CALL_PixelStorei(GET_DISPATCH(), (GL_UNPACK_SWAP_BYTES, GL_FALSE));
CALL_PixelStorei(GET_DISPATCH(), (GL_UNPACK_LSB_FIRST, GL_FALSE));
CALL_PixelStorei(GET_DISPATCH(), (GL_UNPACK_ROW_LENGTH, 0));
CALL_PixelStorei(GET_DISPATCH(), (GL_UNPACK_SKIP_ROWS, 0));
CALL_PixelStorei(GET_DISPATCH(), (GL_UNPACK_SKIP_PIXELS, 0));
CALL_PixelStorei(GET_DISPATCH(), (GL_UNPACK_ALIGNMENT, 1));
pixmap = XCreatePixmap(dpy, RootWindow(dpy, screen), 10, 10, 1);
values.foreground = BlackPixel(dpy, DefaultScreen(dpy));
@ -260,18 +262,18 @@ DRI_glXUseXFont(struct glx_context *CC, Font font, int first, int count, int lis
bm_width = (width + 7) / 8;
bm_height = height;
glNewList(list, GL_COMPILE);
CALL_NewList(GET_DISPATCH(), (list, GL_COMPILE));
if (valid && (bm_width > 0) && (bm_height > 0)) {
memset(bm, '\0', bm_width * bm_height);
fill_bitmap(dpy, screen, gc, bm_width, bm_height, x, y, c, bm);
glBitmap(width, height, x0, y0, dx, dy, bm);
CALL_Bitmap(GET_DISPATCH(), (width, height, x0, y0, dx, dy, bm));
}
else {
glBitmap(0, 0, 0.0, 0.0, dx, dy, NULL);
CALL_Bitmap(GET_DISPATCH(), (0, 0, 0.0, 0.0, dx, dy, NULL));
}
glEndList();
CALL_EndList(GET_DISPATCH(), ());
}
free(bm);
@ -279,12 +281,12 @@ DRI_glXUseXFont(struct glx_context *CC, Font font, int first, int count, int lis
XFreeGC(dpy, gc);
/* Restore saved packing modes. */
glPixelStorei(GL_UNPACK_SWAP_BYTES, swapbytes);
glPixelStorei(GL_UNPACK_LSB_FIRST, lsbfirst);
glPixelStorei(GL_UNPACK_ROW_LENGTH, rowlength);
glPixelStorei(GL_UNPACK_SKIP_ROWS, skiprows);
glPixelStorei(GL_UNPACK_SKIP_PIXELS, skippixels);
glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
CALL_PixelStorei(GET_DISPATCH(), (GL_UNPACK_SWAP_BYTES, swapbytes));
CALL_PixelStorei(GET_DISPATCH(), (GL_UNPACK_LSB_FIRST, lsbfirst));
CALL_PixelStorei(GET_DISPATCH(), (GL_UNPACK_ROW_LENGTH, rowlength));
CALL_PixelStorei(GET_DISPATCH(), (GL_UNPACK_SKIP_ROWS, skiprows));
CALL_PixelStorei(GET_DISPATCH(), (GL_UNPACK_SKIP_PIXELS, skippixels));
CALL_PixelStorei(GET_DISPATCH(), (GL_UNPACK_ALIGNMENT, alignment));
}
#endif