2 * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
3 * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice including the dates of first publication and
13 * either this permission notice or a reference to
14 * http://oss.sgi.com/projects/FreeB/
15 * shall be included in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
22 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 * Except as contained in this notice, the name of Silicon Graphics, Inc.
26 * shall not be used in advertising or otherwise to promote the sale, use or
27 * other dealings in this Software without prior written authorization from
28 * Silicon Graphics, Inc.
33 #include "glxclient.h"
34 #include "packsingle.h"
35 #include "glxextensions.h"
37 #include "indirect_vertex_array.h"
38 #include "glapitable.h"
43 #include <X11/Xlib-xcb.h>
46 #if !defined(__GNUC__)
47 # define __builtin_expect(x, y) x
50 /* Used for GL_ARB_transpose_matrix */
52 TransposeMatrixf(GLfloat m[16])
55 for (i = 0; i < 4; i++) {
56 for (j = 0; j < i; j++) {
57 GLfloat tmp = m[i * 4 + j];
58 m[i * 4 + j] = m[j * 4 + i];
64 /* Used for GL_ARB_transpose_matrix */
66 TransposeMatrixb(GLboolean m[16])
69 for (i = 0; i < 4; i++) {
70 for (j = 0; j < i; j++) {
71 GLboolean tmp = m[i * 4 + j];
72 m[i * 4 + j] = m[j * 4 + i];
78 /* Used for GL_ARB_transpose_matrix */
80 TransposeMatrixd(GLdouble m[16])
83 for (i = 0; i < 4; i++) {
84 for (j = 0; j < i; j++) {
85 GLdouble tmp = m[i * 4 + j];
86 m[i * 4 + j] = m[j * 4 + i];
92 /* Used for GL_ARB_transpose_matrix */
94 TransposeMatrixi(GLint m[16])
97 for (i = 0; i < 4; i++) {
98 for (j = 0; j < i; j++) {
99 GLint tmp = m[i * 4 + j];
100 m[i * 4 + j] = m[j * 4 + i];
108 * Remap a transpose-matrix enum to a non-transpose-matrix enum. Enums
109 * that are not transpose-matrix enums are unaffected.
112 RemapTransposeEnum(GLenum e)
115 case GL_TRANSPOSE_MODELVIEW_MATRIX:
116 case GL_TRANSPOSE_PROJECTION_MATRIX:
117 case GL_TRANSPOSE_TEXTURE_MATRIX:
118 return e - (GL_TRANSPOSE_MODELVIEW_MATRIX - GL_MODELVIEW_MATRIX);
119 case GL_TRANSPOSE_COLOR_MATRIX:
120 return GL_COLOR_MATRIX;
128 __indirect_glGetError(void)
130 __GLX_SINGLE_DECLARE_VARIABLES();
131 GLuint retval = GL_NO_ERROR;
132 xGLXGetErrorReply reply;
135 /* Use internal error first */
137 gc->error = GL_NO_ERROR;
141 __GLX_SINGLE_LOAD_VARIABLES();
142 __GLX_SINGLE_BEGIN(X_GLsop_GetError, 0);
143 __GLX_SINGLE_READ_XREPLY();
144 retval = reply.error;
152 * Get the selected attribute from the client state.
155 * On success \c GL_TRUE is returned. Otherwise, \c GL_FALSE is returned.
158 get_client_data(struct glx_context * gc, GLenum cap, GLintptr * data)
160 GLboolean retval = GL_TRUE;
161 __GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
162 const GLint tex_unit = __glXGetActiveTextureUnit(state);
166 case GL_VERTEX_ARRAY:
167 case GL_NORMAL_ARRAY:
170 case GL_EDGE_FLAG_ARRAY:
171 case GL_SECONDARY_COLOR_ARRAY:
172 case GL_FOG_COORD_ARRAY:
173 retval = __glXGetArrayEnable(state, cap, 0, data);
176 case GL_VERTEX_ARRAY_SIZE:
177 retval = __glXGetArraySize(state, GL_VERTEX_ARRAY, 0, data);
179 case GL_COLOR_ARRAY_SIZE:
180 retval = __glXGetArraySize(state, GL_COLOR_ARRAY, 0, data);
182 case GL_SECONDARY_COLOR_ARRAY_SIZE:
183 retval = __glXGetArraySize(state, GL_SECONDARY_COLOR_ARRAY, 0, data);
186 case GL_VERTEX_ARRAY_TYPE:
187 retval = __glXGetArrayType(state, GL_VERTEX_ARRAY, 0, data);
189 case GL_NORMAL_ARRAY_TYPE:
190 retval = __glXGetArrayType(state, GL_NORMAL_ARRAY, 0, data);
192 case GL_INDEX_ARRAY_TYPE:
193 retval = __glXGetArrayType(state, GL_INDEX_ARRAY, 0, data);
195 case GL_COLOR_ARRAY_TYPE:
196 retval = __glXGetArrayType(state, GL_COLOR_ARRAY, 0, data);
198 case GL_SECONDARY_COLOR_ARRAY_TYPE:
199 retval = __glXGetArrayType(state, GL_SECONDARY_COLOR_ARRAY, 0, data);
201 case GL_FOG_COORD_ARRAY_TYPE:
202 retval = __glXGetArrayType(state, GL_FOG_COORD_ARRAY, 0, data);
205 case GL_VERTEX_ARRAY_STRIDE:
206 retval = __glXGetArrayStride(state, GL_VERTEX_ARRAY, 0, data);
208 case GL_NORMAL_ARRAY_STRIDE:
209 retval = __glXGetArrayStride(state, GL_NORMAL_ARRAY, 0, data);
211 case GL_INDEX_ARRAY_STRIDE:
212 retval = __glXGetArrayStride(state, GL_INDEX_ARRAY, 0, data);
214 case GL_EDGE_FLAG_ARRAY_STRIDE:
215 retval = __glXGetArrayStride(state, GL_EDGE_FLAG_ARRAY, 0, data);
217 case GL_COLOR_ARRAY_STRIDE:
218 retval = __glXGetArrayStride(state, GL_COLOR_ARRAY, 0, data);
220 case GL_SECONDARY_COLOR_ARRAY_STRIDE:
221 retval = __glXGetArrayStride(state, GL_SECONDARY_COLOR_ARRAY, 0, data);
223 case GL_FOG_COORD_ARRAY_STRIDE:
224 retval = __glXGetArrayStride(state, GL_FOG_COORD_ARRAY, 0, data);
227 case GL_TEXTURE_COORD_ARRAY:
229 __glXGetArrayEnable(state, GL_TEXTURE_COORD_ARRAY, tex_unit, data);
231 case GL_TEXTURE_COORD_ARRAY_SIZE:
233 __glXGetArraySize(state, GL_TEXTURE_COORD_ARRAY, tex_unit, data);
235 case GL_TEXTURE_COORD_ARRAY_TYPE:
237 __glXGetArrayType(state, GL_TEXTURE_COORD_ARRAY, tex_unit, data);
239 case GL_TEXTURE_COORD_ARRAY_STRIDE:
241 __glXGetArrayStride(state, GL_TEXTURE_COORD_ARRAY, tex_unit, data);
244 case GL_MAX_ELEMENTS_VERTICES:
245 case GL_MAX_ELEMENTS_INDICES:
251 case GL_PACK_ROW_LENGTH:
252 *data = (GLintptr) state->storePack.rowLength;
254 case GL_PACK_IMAGE_HEIGHT:
255 *data = (GLintptr) state->storePack.imageHeight;
257 case GL_PACK_SKIP_ROWS:
258 *data = (GLintptr) state->storePack.skipRows;
260 case GL_PACK_SKIP_PIXELS:
261 *data = (GLintptr) state->storePack.skipPixels;
263 case GL_PACK_SKIP_IMAGES:
264 *data = (GLintptr) state->storePack.skipImages;
266 case GL_PACK_ALIGNMENT:
267 *data = (GLintptr) state->storePack.alignment;
269 case GL_PACK_SWAP_BYTES:
270 *data = (GLintptr) state->storePack.swapEndian;
272 case GL_PACK_LSB_FIRST:
273 *data = (GLintptr) state->storePack.lsbFirst;
275 case GL_UNPACK_ROW_LENGTH:
276 *data = (GLintptr) state->storeUnpack.rowLength;
278 case GL_UNPACK_IMAGE_HEIGHT:
279 *data = (GLintptr) state->storeUnpack.imageHeight;
281 case GL_UNPACK_SKIP_ROWS:
282 *data = (GLintptr) state->storeUnpack.skipRows;
284 case GL_UNPACK_SKIP_PIXELS:
285 *data = (GLintptr) state->storeUnpack.skipPixels;
287 case GL_UNPACK_SKIP_IMAGES:
288 *data = (GLintptr) state->storeUnpack.skipImages;
290 case GL_UNPACK_ALIGNMENT:
291 *data = (GLintptr) state->storeUnpack.alignment;
293 case GL_UNPACK_SWAP_BYTES:
294 *data = (GLintptr) state->storeUnpack.swapEndian;
296 case GL_UNPACK_LSB_FIRST:
297 *data = (GLintptr) state->storeUnpack.lsbFirst;
299 case GL_CLIENT_ATTRIB_STACK_DEPTH:
300 *data = (GLintptr) (gc->attributes.stackPointer - gc->attributes.stack);
302 case GL_MAX_CLIENT_ATTRIB_STACK_DEPTH:
303 *data = (GLintptr) __GL_CLIENT_ATTRIB_STACK_DEPTH;
305 case GL_CLIENT_ACTIVE_TEXTURE:
306 *data = (GLintptr) (tex_unit + GL_TEXTURE0);
320 __indirect_glGetBooleanv(GLenum val, GLboolean * b)
322 const GLenum origVal = val;
323 __GLX_SINGLE_DECLARE_VARIABLES();
324 xGLXSingleReply reply;
326 val = RemapTransposeEnum(val);
328 __GLX_SINGLE_LOAD_VARIABLES();
329 __GLX_SINGLE_BEGIN(X_GLsop_GetBooleanv, 4);
330 __GLX_SINGLE_PUT_LONG(0, val);
331 __GLX_SINGLE_READ_XREPLY();
332 __GLX_SINGLE_GET_SIZE(compsize);
336 ** Error occured; don't modify user's buffer.
343 ** We still needed to send the request to the server in order to
344 ** find out whether it was legal to make a query (it's illegal,
345 ** for example, to call a query between glBegin() and glEnd()).
348 if (get_client_data(gc, val, &data)) {
349 *b = (GLboolean) data;
353 ** Not a local value, so use what we got from the server.
356 __GLX_SINGLE_GET_CHAR(b);
359 __GLX_SINGLE_GET_CHAR_ARRAY(b, compsize);
360 if (val != origVal) {
361 /* matrix transpose */
371 __indirect_glGetDoublev(GLenum val, GLdouble * d)
373 const GLenum origVal = val;
374 __GLX_SINGLE_DECLARE_VARIABLES();
375 xGLXSingleReply reply;
377 val = RemapTransposeEnum(val);
379 __GLX_SINGLE_LOAD_VARIABLES();
380 __GLX_SINGLE_BEGIN(X_GLsop_GetDoublev, 4);
381 __GLX_SINGLE_PUT_LONG(0, val);
382 __GLX_SINGLE_READ_XREPLY();
383 __GLX_SINGLE_GET_SIZE(compsize);
387 ** Error occured; don't modify user's buffer.
394 ** We still needed to send the request to the server in order to
395 ** find out whether it was legal to make a query (it's illegal,
396 ** for example, to call a query between glBegin() and glEnd()).
399 if (get_client_data(gc, val, &data)) {
400 *d = (GLdouble) data;
404 ** Not a local value, so use what we got from the server.
407 __GLX_SINGLE_GET_DOUBLE(d);
410 __GLX_SINGLE_GET_DOUBLE_ARRAY(d, compsize);
411 if (val != origVal) {
412 /* matrix transpose */
422 __indirect_glGetFloatv(GLenum val, GLfloat * f)
424 const GLenum origVal = val;
425 __GLX_SINGLE_DECLARE_VARIABLES();
426 xGLXSingleReply reply;
428 val = RemapTransposeEnum(val);
430 __GLX_SINGLE_LOAD_VARIABLES();
431 __GLX_SINGLE_BEGIN(X_GLsop_GetFloatv, 4);
432 __GLX_SINGLE_PUT_LONG(0, val);
433 __GLX_SINGLE_READ_XREPLY();
434 __GLX_SINGLE_GET_SIZE(compsize);
438 ** Error occured; don't modify user's buffer.
445 ** We still needed to send the request to the server in order to
446 ** find out whether it was legal to make a query (it's illegal,
447 ** for example, to call a query between glBegin() and glEnd()).
450 if (get_client_data(gc, val, &data)) {
455 ** Not a local value, so use what we got from the server.
458 __GLX_SINGLE_GET_FLOAT(f);
461 __GLX_SINGLE_GET_FLOAT_ARRAY(f, compsize);
462 if (val != origVal) {
463 /* matrix transpose */
473 __indirect_glGetIntegerv(GLenum val, GLint * i)
475 const GLenum origVal = val;
476 __GLX_SINGLE_DECLARE_VARIABLES();
477 xGLXSingleReply reply;
479 val = RemapTransposeEnum(val);
481 __GLX_SINGLE_LOAD_VARIABLES();
482 __GLX_SINGLE_BEGIN(X_GLsop_GetIntegerv, 4);
483 __GLX_SINGLE_PUT_LONG(0, val);
484 __GLX_SINGLE_READ_XREPLY();
485 __GLX_SINGLE_GET_SIZE(compsize);
489 ** Error occured; don't modify user's buffer.
496 ** We still needed to send the request to the server in order to
497 ** find out whether it was legal to make a query (it's illegal,
498 ** for example, to call a query between glBegin() and glEnd()).
501 if (get_client_data(gc, val, &data)) {
506 ** Not a local value, so use what we got from the server.
509 __GLX_SINGLE_GET_LONG(i);
512 __GLX_SINGLE_GET_LONG_ARRAY(i, compsize);
513 if (val != origVal) {
514 /* matrix transpose */
524 ** Send all pending commands to server.
527 __indirect_glFlush(void)
529 __GLX_SINGLE_DECLARE_VARIABLES();
534 __GLX_SINGLE_LOAD_VARIABLES();
535 __GLX_SINGLE_BEGIN(X_GLsop_Flush, 0);
538 /* And finally flush the X protocol data */
543 __indirect_glFeedbackBuffer(GLsizei size, GLenum type, GLfloat * buffer)
545 __GLX_SINGLE_DECLARE_VARIABLES();
550 __GLX_SINGLE_LOAD_VARIABLES();
551 __GLX_SINGLE_BEGIN(X_GLsop_FeedbackBuffer, 8);
552 __GLX_SINGLE_PUT_LONG(0, size);
553 __GLX_SINGLE_PUT_LONG(4, type);
556 gc->feedbackBuf = buffer;
560 __indirect_glSelectBuffer(GLsizei numnames, GLuint * buffer)
562 __GLX_SINGLE_DECLARE_VARIABLES();
567 __GLX_SINGLE_LOAD_VARIABLES();
568 __GLX_SINGLE_BEGIN(X_GLsop_SelectBuffer, 4);
569 __GLX_SINGLE_PUT_LONG(0, numnames);
572 gc->selectBuf = buffer;
576 __indirect_glRenderMode(GLenum mode)
578 __GLX_SINGLE_DECLARE_VARIABLES();
580 xGLXRenderModeReply reply;
585 __GLX_SINGLE_LOAD_VARIABLES();
586 __GLX_SINGLE_BEGIN(X_GLsop_RenderMode, 4);
587 __GLX_SINGLE_PUT_LONG(0, mode);
588 __GLX_SINGLE_READ_XREPLY();
589 __GLX_SINGLE_GET_RETVAL(retval, GLint);
591 if (reply.newMode != mode) {
593 ** Switch to new mode did not take effect, therefore an error
594 ** occured. When an error happens the server won't send us any
599 /* Read the feedback or selection data */
600 if (gc->renderMode == GL_FEEDBACK) {
601 __GLX_SINGLE_GET_SIZE(compsize);
602 __GLX_SINGLE_GET_FLOAT_ARRAY(gc->feedbackBuf, compsize);
604 else if (gc->renderMode == GL_SELECT) {
605 __GLX_SINGLE_GET_SIZE(compsize);
606 __GLX_SINGLE_GET_LONG_ARRAY(gc->selectBuf, compsize);
608 gc->renderMode = mode;
616 __indirect_glFinish(void)
618 __GLX_SINGLE_DECLARE_VARIABLES();
619 xGLXSingleReply reply;
621 __GLX_SINGLE_LOAD_VARIABLES();
622 __GLX_SINGLE_BEGIN(X_GLsop_Finish, 0);
623 __GLX_SINGLE_READ_XREPLY();
629 * Extract the major and minor version numbers from a version string.
632 version_from_string(const char *ver, int *major_version, int *minor_version)
638 major = strtol(ver, (char **) &end, 10);
639 minor = strtol(end + 1, NULL, 10);
640 *major_version = major;
641 *minor_version = minor;
646 __indirect_glGetString(GLenum name)
648 struct glx_context *gc = __glXGetCurrentContext();
649 Display *dpy = gc->currentDpy;
656 ** Return the cached copy if the string has already been fetched
673 return gc->extensions;
676 __glXSetError(gc, GL_INVALID_ENUM);
681 ** Get requested string from server
684 (void) __glXFlushRenderBuffer(gc, gc->pc);
685 s = (GLubyte *) __glXGetString(dpy, gc->majorOpcode, gc->currentContextTag,
688 /* Throw data on the floor */
689 __glXSetError(gc, GL_OUT_OF_MEMORY);
693 ** Update local cache
708 version_from_string((char *) s,
709 &gc->server_major, &gc->server_minor);
710 __glXGetGLVersion(&client_major, &client_minor);
712 if ((gc->server_major < client_major)
713 || ((gc->server_major == client_major)
714 && (gc->server_minor <= client_minor))) {
718 /* Allow 7 bytes for the client-side GL version. This allows
719 * for upto version 999.999. I'm not holding my breath for
720 * that one! The extra 4 is for the ' ()\0' that will be
723 const size_t size = 7 + strlen((char *) s) + 4;
725 gc->version = Xmalloc(size);
726 if (gc->version == NULL) {
727 /* If we couldn't allocate memory for the new string,
728 * make a best-effort and just copy the client-side version
729 * to the string and use that. It probably doesn't
730 * matter what is done here. If there not memory available
731 * for a short string, the system is probably going to die
734 snprintf((char *) s, strlen((char *) s) + 1, "%u.%u",
735 client_major, client_minor);
739 snprintf((char *) gc->version, size, "%u.%u (%s)",
740 client_major, client_minor, s);
752 /* This code is currently disabled. I was reminded that some
753 * vendors intentionally exclude some extensions from their
754 * extension string that are part of the core version they
755 * advertise. In particular, on Nvidia drivers this means that
756 * the functionality is supported by the driver, but is not
757 * hardware accelerated. For example, a TNT will show core
758 * version 1.5, but most of the post-1.2 functionality is a
761 * I don't want to break applications that rely on this odd
762 * behavior. At the same time, the code is written and tested,
763 * so I didn't want to throw it away. Therefore, the code is here
764 * but disabled. In the future, we may wish to and an environment
765 * variable to enable it.
769 /* Call glGetString just to make sure that gc->server_major and
770 * gc->server_minor are set. This version may be higher than we
771 * can completely support, but it may imply support for some
772 * extensions that we can support.
774 * For example, at the time of this writing, the client-side
775 * library only supports upto core GL version 1.2. However, cubic
776 * textures, multitexture, multisampling, and some other 1.3
777 * features are supported. If the server reports back version
778 * 1.3, but does not report all of those extensions, we will
781 (void *) glGetString(GL_VERSION);
782 major = gc->server_major, minor = gc->server_minor;
785 __glXCalculateUsableGLExtensions(gc, (char *) s, major, minor);
796 __indirect_glIsEnabled(GLenum cap)
798 __GLX_SINGLE_DECLARE_VARIABLES();
799 __GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
800 xGLXSingleReply reply;
801 GLboolean retval = 0;
808 case GL_VERTEX_ARRAY:
809 case GL_NORMAL_ARRAY:
812 case GL_EDGE_FLAG_ARRAY:
813 case GL_SECONDARY_COLOR_ARRAY:
814 case GL_FOG_COORD_ARRAY:
815 retval = __glXGetArrayEnable(state, cap, 0, &enable);
817 return (GLboolean) enable;
819 case GL_TEXTURE_COORD_ARRAY:
820 retval = __glXGetArrayEnable(state, GL_TEXTURE_COORD_ARRAY,
821 __glXGetActiveTextureUnit(state), &enable);
823 return (GLboolean) enable;
827 __GLX_SINGLE_LOAD_VARIABLES();
828 __GLX_SINGLE_BEGIN(X_GLsop_IsEnabled, 4);
829 __GLX_SINGLE_PUT_LONG(0, cap);
830 __GLX_SINGLE_READ_XREPLY();
831 __GLX_SINGLE_GET_RETVAL(retval, GLboolean);
837 __indirect_glGetPointerv(GLenum pname, void **params)
839 struct glx_context *gc = __glXGetCurrentContext();
840 __GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
841 Display *dpy = gc->currentDpy;
847 case GL_VERTEX_ARRAY_POINTER:
848 case GL_NORMAL_ARRAY_POINTER:
849 case GL_COLOR_ARRAY_POINTER:
850 case GL_INDEX_ARRAY_POINTER:
851 case GL_EDGE_FLAG_ARRAY_POINTER:
852 __glXGetArrayPointer(state, pname - GL_VERTEX_ARRAY_POINTER
853 + GL_VERTEX_ARRAY, 0, params);
855 case GL_TEXTURE_COORD_ARRAY_POINTER:
856 __glXGetArrayPointer(state, GL_TEXTURE_COORD_ARRAY,
857 __glXGetActiveTextureUnit(state), params);
859 case GL_SECONDARY_COLOR_ARRAY_POINTER:
860 case GL_FOG_COORD_ARRAY_POINTER:
861 __glXGetArrayPointer(state, pname - GL_FOG_COORD_ARRAY_POINTER
862 + GL_FOG_COORD_ARRAY, 0, params);
864 case GL_FEEDBACK_BUFFER_POINTER:
865 *params = (void *) gc->feedbackBuf;
867 case GL_SELECTION_BUFFER_POINTER:
868 *params = (void *) gc->selectBuf;
871 __glXSetError(gc, GL_INVALID_ENUM);
879 * This was previously auto-generated, but we need to special-case
880 * how we handle writing into the 'residences' buffer when n%4!=0.
882 #define X_GLsop_AreTexturesResident 143
884 __indirect_glAreTexturesResident(GLsizei n, const GLuint * textures,
885 GLboolean * residences)
887 struct glx_context *const gc = __glXGetCurrentContext();
888 Display *const dpy = gc->currentDpy;
889 GLboolean retval = (GLboolean) 0;
890 const GLuint cmdlen = 4 + __GLX_PAD((n * 4));
891 if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) {
893 xcb_connection_t *c = XGetXCBConnection(dpy);
894 (void) __glXFlushRenderBuffer(gc, gc->pc);
895 xcb_glx_are_textures_resident_reply_t *reply =
896 xcb_glx_are_textures_resident_reply(c,
897 xcb_glx_are_textures_resident
898 (c, gc->currentContextTag, n,
900 (void) memcpy(residences, xcb_glx_are_textures_resident_data(reply),
901 xcb_glx_are_textures_resident_data_length(reply) *
903 retval = reply->ret_val;
907 __glXSetupSingleRequest(gc, X_GLsop_AreTexturesResident, cmdlen);
908 (void) memcpy((void *) (pc + 0), (void *) (&n), 4);
909 (void) memcpy((void *) (pc + 4), (void *) (textures), (n * 4));
911 /* n is not a multiple of four.
912 * When reply_is_always_array is TRUE, __glXReadReply() will
913 * put a multiple of four bytes into the dest buffer. If the
914 * caller's buffer is not a multiple of four in size, we'll write
915 * out of bounds. So use a temporary buffer that's a few bytes
918 GLboolean *res4 = malloc((n + 3) & ~3);
919 retval = (GLboolean) __glXReadReply(dpy, 1, res4, GL_TRUE);
920 memcpy(residences, res4, n);
924 retval = (GLboolean) __glXReadReply(dpy, 1, residences, GL_TRUE);
935 * This was previously auto-generated, but we need to special-case
936 * how we handle writing into the 'residences' buffer when n%4!=0.
938 #define X_GLvop_AreTexturesResidentEXT 11
940 glAreTexturesResidentEXT(GLsizei n, const GLuint * textures,
941 GLboolean * residences)
943 struct glx_context *const gc = __glXGetCurrentContext();
946 return GET_DISPATCH()->AreTexturesResident(n, textures, residences);
949 struct glx_context *const gc = __glXGetCurrentContext();
950 Display *const dpy = gc->currentDpy;
951 GLboolean retval = (GLboolean) 0;
952 const GLuint cmdlen = 4 + __GLX_PAD((n * 4));
953 if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) {
955 __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply,
956 X_GLvop_AreTexturesResidentEXT,
958 (void) memcpy((void *) (pc + 0), (void *) (&n), 4);
959 (void) memcpy((void *) (pc + 4), (void *) (textures), (n * 4));
961 /* see comments in __indirect_glAreTexturesResident() */
962 GLboolean *res4 = malloc((n + 3) & ~3);
963 retval = (GLboolean) __glXReadReply(dpy, 1, res4, GL_TRUE);
964 memcpy(residences, res4, n);
968 retval = (GLboolean) __glXReadReply(dpy, 1, residences, GL_TRUE);