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"
42 #include <X11/Xlib-xcb.h>
45 #if !defined(__GNUC__)
46 # define __builtin_expect(x, y) x
49 /* Used for GL_ARB_transpose_matrix */
51 TransposeMatrixf(GLfloat m
[16])
54 for (i
= 0; i
< 4; i
++) {
55 for (j
= 0; j
< i
; j
++) {
56 GLfloat tmp
= m
[i
* 4 + j
];
57 m
[i
* 4 + j
] = m
[j
* 4 + i
];
63 /* Used for GL_ARB_transpose_matrix */
65 TransposeMatrixb(GLboolean m
[16])
68 for (i
= 0; i
< 4; i
++) {
69 for (j
= 0; j
< i
; j
++) {
70 GLboolean tmp
= m
[i
* 4 + j
];
71 m
[i
* 4 + j
] = m
[j
* 4 + i
];
77 /* Used for GL_ARB_transpose_matrix */
79 TransposeMatrixd(GLdouble m
[16])
82 for (i
= 0; i
< 4; i
++) {
83 for (j
= 0; j
< i
; j
++) {
84 GLdouble tmp
= m
[i
* 4 + j
];
85 m
[i
* 4 + j
] = m
[j
* 4 + i
];
91 /* Used for GL_ARB_transpose_matrix */
93 TransposeMatrixi(GLint m
[16])
96 for (i
= 0; i
< 4; i
++) {
97 for (j
= 0; j
< i
; j
++) {
98 GLint tmp
= m
[i
* 4 + j
];
99 m
[i
* 4 + j
] = m
[j
* 4 + i
];
107 * Remap a transpose-matrix enum to a non-transpose-matrix enum. Enums
108 * that are not transpose-matrix enums are unaffected.
111 RemapTransposeEnum(GLenum e
)
114 case GL_TRANSPOSE_MODELVIEW_MATRIX
:
115 case GL_TRANSPOSE_PROJECTION_MATRIX
:
116 case GL_TRANSPOSE_TEXTURE_MATRIX
:
117 return e
- (GL_TRANSPOSE_MODELVIEW_MATRIX
- GL_MODELVIEW_MATRIX
);
118 case GL_TRANSPOSE_COLOR_MATRIX
:
119 return GL_COLOR_MATRIX
;
127 __indirect_glGetError(void)
129 __GLX_SINGLE_DECLARE_VARIABLES();
130 GLuint retval
= GL_NO_ERROR
;
131 xGLXGetErrorReply reply
;
134 /* Use internal error first */
136 gc
->error
= GL_NO_ERROR
;
140 __GLX_SINGLE_LOAD_VARIABLES();
141 __GLX_SINGLE_BEGIN(X_GLsop_GetError
, 0);
142 __GLX_SINGLE_READ_XREPLY();
143 retval
= reply
.error
;
151 * Get the selected attribute from the client state.
154 * On success \c GL_TRUE is returned. Otherwise, \c GL_FALSE is returned.
157 get_client_data(struct glx_context
* gc
, GLenum cap
, GLintptr
* data
)
159 GLboolean retval
= GL_TRUE
;
160 __GLXattribute
*state
= (__GLXattribute
*) (gc
->client_state_private
);
161 const GLint tex_unit
= __glXGetActiveTextureUnit(state
);
165 case GL_VERTEX_ARRAY
:
166 case GL_NORMAL_ARRAY
:
169 case GL_EDGE_FLAG_ARRAY
:
170 case GL_SECONDARY_COLOR_ARRAY
:
171 case GL_FOG_COORD_ARRAY
:
172 retval
= __glXGetArrayEnable(state
, cap
, 0, data
);
175 case GL_VERTEX_ARRAY_SIZE
:
176 retval
= __glXGetArraySize(state
, GL_VERTEX_ARRAY
, 0, data
);
178 case GL_COLOR_ARRAY_SIZE
:
179 retval
= __glXGetArraySize(state
, GL_COLOR_ARRAY
, 0, data
);
181 case GL_SECONDARY_COLOR_ARRAY_SIZE
:
182 retval
= __glXGetArraySize(state
, GL_SECONDARY_COLOR_ARRAY
, 0, data
);
185 case GL_VERTEX_ARRAY_TYPE
:
186 retval
= __glXGetArrayType(state
, GL_VERTEX_ARRAY
, 0, data
);
188 case GL_NORMAL_ARRAY_TYPE
:
189 retval
= __glXGetArrayType(state
, GL_NORMAL_ARRAY
, 0, data
);
191 case GL_INDEX_ARRAY_TYPE
:
192 retval
= __glXGetArrayType(state
, GL_INDEX_ARRAY
, 0, data
);
194 case GL_COLOR_ARRAY_TYPE
:
195 retval
= __glXGetArrayType(state
, GL_COLOR_ARRAY
, 0, data
);
197 case GL_SECONDARY_COLOR_ARRAY_TYPE
:
198 retval
= __glXGetArrayType(state
, GL_SECONDARY_COLOR_ARRAY
, 0, data
);
200 case GL_FOG_COORD_ARRAY_TYPE
:
201 retval
= __glXGetArrayType(state
, GL_FOG_COORD_ARRAY
, 0, data
);
204 case GL_VERTEX_ARRAY_STRIDE
:
205 retval
= __glXGetArrayStride(state
, GL_VERTEX_ARRAY
, 0, data
);
207 case GL_NORMAL_ARRAY_STRIDE
:
208 retval
= __glXGetArrayStride(state
, GL_NORMAL_ARRAY
, 0, data
);
210 case GL_INDEX_ARRAY_STRIDE
:
211 retval
= __glXGetArrayStride(state
, GL_INDEX_ARRAY
, 0, data
);
213 case GL_EDGE_FLAG_ARRAY_STRIDE
:
214 retval
= __glXGetArrayStride(state
, GL_EDGE_FLAG_ARRAY
, 0, data
);
216 case GL_COLOR_ARRAY_STRIDE
:
217 retval
= __glXGetArrayStride(state
, GL_COLOR_ARRAY
, 0, data
);
219 case GL_SECONDARY_COLOR_ARRAY_STRIDE
:
220 retval
= __glXGetArrayStride(state
, GL_SECONDARY_COLOR_ARRAY
, 0, data
);
222 case GL_FOG_COORD_ARRAY_STRIDE
:
223 retval
= __glXGetArrayStride(state
, GL_FOG_COORD_ARRAY
, 0, data
);
226 case GL_TEXTURE_COORD_ARRAY
:
228 __glXGetArrayEnable(state
, GL_TEXTURE_COORD_ARRAY
, tex_unit
, data
);
230 case GL_TEXTURE_COORD_ARRAY_SIZE
:
232 __glXGetArraySize(state
, GL_TEXTURE_COORD_ARRAY
, tex_unit
, data
);
234 case GL_TEXTURE_COORD_ARRAY_TYPE
:
236 __glXGetArrayType(state
, GL_TEXTURE_COORD_ARRAY
, tex_unit
, data
);
238 case GL_TEXTURE_COORD_ARRAY_STRIDE
:
240 __glXGetArrayStride(state
, GL_TEXTURE_COORD_ARRAY
, tex_unit
, data
);
243 case GL_MAX_ELEMENTS_VERTICES
:
244 case GL_MAX_ELEMENTS_INDICES
:
250 case GL_PACK_ROW_LENGTH
:
251 *data
= (GLintptr
) state
->storePack
.rowLength
;
253 case GL_PACK_IMAGE_HEIGHT
:
254 *data
= (GLintptr
) state
->storePack
.imageHeight
;
256 case GL_PACK_SKIP_ROWS
:
257 *data
= (GLintptr
) state
->storePack
.skipRows
;
259 case GL_PACK_SKIP_PIXELS
:
260 *data
= (GLintptr
) state
->storePack
.skipPixels
;
262 case GL_PACK_SKIP_IMAGES
:
263 *data
= (GLintptr
) state
->storePack
.skipImages
;
265 case GL_PACK_ALIGNMENT
:
266 *data
= (GLintptr
) state
->storePack
.alignment
;
268 case GL_PACK_SWAP_BYTES
:
269 *data
= (GLintptr
) state
->storePack
.swapEndian
;
271 case GL_PACK_LSB_FIRST
:
272 *data
= (GLintptr
) state
->storePack
.lsbFirst
;
274 case GL_UNPACK_ROW_LENGTH
:
275 *data
= (GLintptr
) state
->storeUnpack
.rowLength
;
277 case GL_UNPACK_IMAGE_HEIGHT
:
278 *data
= (GLintptr
) state
->storeUnpack
.imageHeight
;
280 case GL_UNPACK_SKIP_ROWS
:
281 *data
= (GLintptr
) state
->storeUnpack
.skipRows
;
283 case GL_UNPACK_SKIP_PIXELS
:
284 *data
= (GLintptr
) state
->storeUnpack
.skipPixels
;
286 case GL_UNPACK_SKIP_IMAGES
:
287 *data
= (GLintptr
) state
->storeUnpack
.skipImages
;
289 case GL_UNPACK_ALIGNMENT
:
290 *data
= (GLintptr
) state
->storeUnpack
.alignment
;
292 case GL_UNPACK_SWAP_BYTES
:
293 *data
= (GLintptr
) state
->storeUnpack
.swapEndian
;
295 case GL_UNPACK_LSB_FIRST
:
296 *data
= (GLintptr
) state
->storeUnpack
.lsbFirst
;
298 case GL_CLIENT_ATTRIB_STACK_DEPTH
:
299 *data
= (GLintptr
) (gc
->attributes
.stackPointer
- gc
->attributes
.stack
);
301 case GL_MAX_CLIENT_ATTRIB_STACK_DEPTH
:
302 *data
= (GLintptr
) __GL_CLIENT_ATTRIB_STACK_DEPTH
;
304 case GL_CLIENT_ACTIVE_TEXTURE
:
305 *data
= (GLintptr
) (tex_unit
+ GL_TEXTURE0
);
319 __indirect_glGetBooleanv(GLenum val
, GLboolean
* b
)
321 const GLenum origVal
= val
;
322 __GLX_SINGLE_DECLARE_VARIABLES();
323 xGLXSingleReply reply
;
325 val
= RemapTransposeEnum(val
);
327 __GLX_SINGLE_LOAD_VARIABLES();
328 __GLX_SINGLE_BEGIN(X_GLsop_GetBooleanv
, 4);
329 __GLX_SINGLE_PUT_LONG(0, val
);
330 __GLX_SINGLE_READ_XREPLY();
331 __GLX_SINGLE_GET_SIZE(compsize
);
335 ** Error occured; don't modify user's buffer.
342 ** We still needed to send the request to the server in order to
343 ** find out whether it was legal to make a query (it's illegal,
344 ** for example, to call a query between glBegin() and glEnd()).
347 if (get_client_data(gc
, val
, &data
)) {
348 *b
= (GLboolean
) data
;
352 ** Not a local value, so use what we got from the server.
355 __GLX_SINGLE_GET_CHAR(b
);
358 __GLX_SINGLE_GET_CHAR_ARRAY(b
, compsize
);
359 if (val
!= origVal
) {
360 /* matrix transpose */
370 __indirect_glGetDoublev(GLenum val
, GLdouble
* d
)
372 const GLenum origVal
= val
;
373 __GLX_SINGLE_DECLARE_VARIABLES();
374 xGLXSingleReply reply
;
376 val
= RemapTransposeEnum(val
);
378 __GLX_SINGLE_LOAD_VARIABLES();
379 __GLX_SINGLE_BEGIN(X_GLsop_GetDoublev
, 4);
380 __GLX_SINGLE_PUT_LONG(0, val
);
381 __GLX_SINGLE_READ_XREPLY();
382 __GLX_SINGLE_GET_SIZE(compsize
);
386 ** Error occured; don't modify user's buffer.
393 ** We still needed to send the request to the server in order to
394 ** find out whether it was legal to make a query (it's illegal,
395 ** for example, to call a query between glBegin() and glEnd()).
398 if (get_client_data(gc
, val
, &data
)) {
399 *d
= (GLdouble
) data
;
403 ** Not a local value, so use what we got from the server.
406 __GLX_SINGLE_GET_DOUBLE(d
);
409 __GLX_SINGLE_GET_DOUBLE_ARRAY(d
, compsize
);
410 if (val
!= origVal
) {
411 /* matrix transpose */
421 __indirect_glGetFloatv(GLenum val
, GLfloat
* f
)
423 const GLenum origVal
= val
;
424 __GLX_SINGLE_DECLARE_VARIABLES();
425 xGLXSingleReply reply
;
427 val
= RemapTransposeEnum(val
);
429 __GLX_SINGLE_LOAD_VARIABLES();
430 __GLX_SINGLE_BEGIN(X_GLsop_GetFloatv
, 4);
431 __GLX_SINGLE_PUT_LONG(0, val
);
432 __GLX_SINGLE_READ_XREPLY();
433 __GLX_SINGLE_GET_SIZE(compsize
);
437 ** Error occured; don't modify user's buffer.
444 ** We still needed to send the request to the server in order to
445 ** find out whether it was legal to make a query (it's illegal,
446 ** for example, to call a query between glBegin() and glEnd()).
449 if (get_client_data(gc
, val
, &data
)) {
454 ** Not a local value, so use what we got from the server.
457 __GLX_SINGLE_GET_FLOAT(f
);
460 __GLX_SINGLE_GET_FLOAT_ARRAY(f
, compsize
);
461 if (val
!= origVal
) {
462 /* matrix transpose */
472 __indirect_glGetIntegerv(GLenum val
, GLint
* i
)
474 const GLenum origVal
= val
;
475 __GLX_SINGLE_DECLARE_VARIABLES();
476 xGLXSingleReply reply
;
478 val
= RemapTransposeEnum(val
);
480 __GLX_SINGLE_LOAD_VARIABLES();
481 __GLX_SINGLE_BEGIN(X_GLsop_GetIntegerv
, 4);
482 __GLX_SINGLE_PUT_LONG(0, val
);
483 __GLX_SINGLE_READ_XREPLY();
484 __GLX_SINGLE_GET_SIZE(compsize
);
488 ** Error occured; don't modify user's buffer.
495 ** We still needed to send the request to the server in order to
496 ** find out whether it was legal to make a query (it's illegal,
497 ** for example, to call a query between glBegin() and glEnd()).
500 if (get_client_data(gc
, val
, &data
)) {
505 ** Not a local value, so use what we got from the server.
508 __GLX_SINGLE_GET_LONG(i
);
511 __GLX_SINGLE_GET_LONG_ARRAY(i
, compsize
);
512 if (val
!= origVal
) {
513 /* matrix transpose */
523 ** Send all pending commands to server.
526 __indirect_glFlush(void)
528 __GLX_SINGLE_DECLARE_VARIABLES();
533 __GLX_SINGLE_LOAD_VARIABLES();
534 __GLX_SINGLE_BEGIN(X_GLsop_Flush
, 0);
537 /* And finally flush the X protocol data */
542 __indirect_glFeedbackBuffer(GLsizei size
, GLenum type
, GLfloat
* buffer
)
544 __GLX_SINGLE_DECLARE_VARIABLES();
549 __GLX_SINGLE_LOAD_VARIABLES();
550 __GLX_SINGLE_BEGIN(X_GLsop_FeedbackBuffer
, 8);
551 __GLX_SINGLE_PUT_LONG(0, size
);
552 __GLX_SINGLE_PUT_LONG(4, type
);
555 gc
->feedbackBuf
= buffer
;
559 __indirect_glSelectBuffer(GLsizei numnames
, GLuint
* buffer
)
561 __GLX_SINGLE_DECLARE_VARIABLES();
566 __GLX_SINGLE_LOAD_VARIABLES();
567 __GLX_SINGLE_BEGIN(X_GLsop_SelectBuffer
, 4);
568 __GLX_SINGLE_PUT_LONG(0, numnames
);
571 gc
->selectBuf
= buffer
;
575 __indirect_glRenderMode(GLenum mode
)
577 __GLX_SINGLE_DECLARE_VARIABLES();
579 xGLXRenderModeReply reply
;
584 __GLX_SINGLE_LOAD_VARIABLES();
585 __GLX_SINGLE_BEGIN(X_GLsop_RenderMode
, 4);
586 __GLX_SINGLE_PUT_LONG(0, mode
);
587 __GLX_SINGLE_READ_XREPLY();
588 __GLX_SINGLE_GET_RETVAL(retval
, GLint
);
590 if (reply
.newMode
!= mode
) {
592 ** Switch to new mode did not take effect, therefore an error
593 ** occured. When an error happens the server won't send us any
598 /* Read the feedback or selection data */
599 if (gc
->renderMode
== GL_FEEDBACK
) {
600 __GLX_SINGLE_GET_SIZE(compsize
);
601 __GLX_SINGLE_GET_FLOAT_ARRAY(gc
->feedbackBuf
, compsize
);
603 else if (gc
->renderMode
== GL_SELECT
) {
604 __GLX_SINGLE_GET_SIZE(compsize
);
605 __GLX_SINGLE_GET_LONG_ARRAY(gc
->selectBuf
, compsize
);
607 gc
->renderMode
= mode
;
615 __indirect_glFinish(void)
617 __GLX_SINGLE_DECLARE_VARIABLES();
618 xGLXSingleReply reply
;
620 __GLX_SINGLE_LOAD_VARIABLES();
621 __GLX_SINGLE_BEGIN(X_GLsop_Finish
, 0);
622 __GLX_SINGLE_READ_XREPLY();
628 * Extract the major and minor version numbers from a version string.
631 version_from_string(const char *ver
, int *major_version
, int *minor_version
)
637 major
= strtol(ver
, (char **) &end
, 10);
638 minor
= strtol(end
+ 1, NULL
, 10);
639 *major_version
= major
;
640 *minor_version
= minor
;
645 __indirect_glGetString(GLenum name
)
647 struct glx_context
*gc
= __glXGetCurrentContext();
648 Display
*dpy
= gc
->currentDpy
;
655 ** Return the cached copy if the string has already been fetched
672 return gc
->extensions
;
675 __glXSetError(gc
, GL_INVALID_ENUM
);
680 ** Get requested string from server
683 (void) __glXFlushRenderBuffer(gc
, gc
->pc
);
684 s
= (GLubyte
*) __glXGetString(dpy
, gc
->majorOpcode
, gc
->currentContextTag
,
687 /* Throw data on the floor */
688 __glXSetError(gc
, GL_OUT_OF_MEMORY
);
692 ** Update local cache
707 version_from_string((char *) s
,
708 &gc
->server_major
, &gc
->server_minor
);
709 __glXGetGLVersion(&client_major
, &client_minor
);
711 if ((gc
->server_major
< client_major
)
712 || ((gc
->server_major
== client_major
)
713 && (gc
->server_minor
<= client_minor
))) {
717 /* Allow 7 bytes for the client-side GL version. This allows
718 * for upto version 999.999. I'm not holding my breath for
719 * that one! The extra 4 is for the ' ()\0' that will be
722 const size_t size
= 7 + strlen((char *) s
) + 4;
724 gc
->version
= malloc(size
);
725 if (gc
->version
== NULL
) {
726 /* If we couldn't allocate memory for the new string,
727 * make a best-effort and just copy the client-side version
728 * to the string and use that. It probably doesn't
729 * matter what is done here. If there not memory available
730 * for a short string, the system is probably going to die
733 snprintf((char *) s
, strlen((char *) s
) + 1, "%u.%u",
734 client_major
, client_minor
);
738 snprintf((char *) gc
->version
, size
, "%u.%u (%s)",
739 client_major
, client_minor
, s
);
751 /* This code is currently disabled. I was reminded that some
752 * vendors intentionally exclude some extensions from their
753 * extension string that are part of the core version they
754 * advertise. In particular, on Nvidia drivers this means that
755 * the functionality is supported by the driver, but is not
756 * hardware accelerated. For example, a TNT will show core
757 * version 1.5, but most of the post-1.2 functionality is a
760 * I don't want to break applications that rely on this odd
761 * behavior. At the same time, the code is written and tested,
762 * so I didn't want to throw it away. Therefore, the code is here
763 * but disabled. In the future, we may wish to and an environment
764 * variable to enable it.
768 /* Call glGetString just to make sure that gc->server_major and
769 * gc->server_minor are set. This version may be higher than we
770 * can completely support, but it may imply support for some
771 * extensions that we can support.
773 * For example, at the time of this writing, the client-side
774 * library only supports upto core GL version 1.2. However, cubic
775 * textures, multitexture, multisampling, and some other 1.3
776 * features are supported. If the server reports back version
777 * 1.3, but does not report all of those extensions, we will
780 (void *) glGetString(GL_VERSION
);
781 major
= gc
->server_major
, minor
= gc
->server_minor
;
784 __glXCalculateUsableGLExtensions(gc
, (char *) s
, major
, minor
);
795 __indirect_glIsEnabled(GLenum cap
)
797 __GLX_SINGLE_DECLARE_VARIABLES();
798 __GLXattribute
*state
= (__GLXattribute
*) (gc
->client_state_private
);
799 xGLXSingleReply reply
;
800 GLboolean retval
= 0;
807 case GL_VERTEX_ARRAY
:
808 case GL_NORMAL_ARRAY
:
811 case GL_EDGE_FLAG_ARRAY
:
812 case GL_SECONDARY_COLOR_ARRAY
:
813 case GL_FOG_COORD_ARRAY
:
814 retval
= __glXGetArrayEnable(state
, cap
, 0, &enable
);
816 return (GLboolean
) enable
;
818 case GL_TEXTURE_COORD_ARRAY
:
819 retval
= __glXGetArrayEnable(state
, GL_TEXTURE_COORD_ARRAY
,
820 __glXGetActiveTextureUnit(state
), &enable
);
822 return (GLboolean
) enable
;
826 __GLX_SINGLE_LOAD_VARIABLES();
827 __GLX_SINGLE_BEGIN(X_GLsop_IsEnabled
, 4);
828 __GLX_SINGLE_PUT_LONG(0, cap
);
829 __GLX_SINGLE_READ_XREPLY();
830 __GLX_SINGLE_GET_RETVAL(retval
, GLboolean
);
836 __indirect_glGetPointerv(GLenum pname
, void **params
)
838 struct glx_context
*gc
= __glXGetCurrentContext();
839 __GLXattribute
*state
= (__GLXattribute
*) (gc
->client_state_private
);
840 Display
*dpy
= gc
->currentDpy
;
846 case GL_VERTEX_ARRAY_POINTER
:
847 case GL_NORMAL_ARRAY_POINTER
:
848 case GL_COLOR_ARRAY_POINTER
:
849 case GL_INDEX_ARRAY_POINTER
:
850 case GL_EDGE_FLAG_ARRAY_POINTER
:
851 __glXGetArrayPointer(state
, pname
- GL_VERTEX_ARRAY_POINTER
852 + GL_VERTEX_ARRAY
, 0, params
);
854 case GL_TEXTURE_COORD_ARRAY_POINTER
:
855 __glXGetArrayPointer(state
, GL_TEXTURE_COORD_ARRAY
,
856 __glXGetActiveTextureUnit(state
), params
);
858 case GL_SECONDARY_COLOR_ARRAY_POINTER
:
859 case GL_FOG_COORD_ARRAY_POINTER
:
860 __glXGetArrayPointer(state
, pname
- GL_FOG_COORD_ARRAY_POINTER
861 + GL_FOG_COORD_ARRAY
, 0, params
);
863 case GL_FEEDBACK_BUFFER_POINTER
:
864 *params
= (void *) gc
->feedbackBuf
;
866 case GL_SELECTION_BUFFER_POINTER
:
867 *params
= (void *) gc
->selectBuf
;
870 __glXSetError(gc
, GL_INVALID_ENUM
);
878 * This was previously auto-generated, but we need to special-case
879 * how we handle writing into the 'residences' buffer when n%4!=0.
881 #define X_GLsop_AreTexturesResident 143
883 __indirect_glAreTexturesResident(GLsizei n
, const GLuint
* textures
,
884 GLboolean
* residences
)
886 struct glx_context
*const gc
= __glXGetCurrentContext();
887 Display
*const dpy
= gc
->currentDpy
;
888 GLboolean retval
= (GLboolean
) 0;
889 if (__builtin_expect((n
>= 0) && (dpy
!= NULL
), 1)) {
891 xcb_connection_t
*c
= XGetXCBConnection(dpy
);
892 (void) __glXFlushRenderBuffer(gc
, gc
->pc
);
893 xcb_glx_are_textures_resident_reply_t
*reply
=
894 xcb_glx_are_textures_resident_reply(c
,
895 xcb_glx_are_textures_resident
896 (c
, gc
->currentContextTag
, n
,
898 (void) memcpy(residences
, xcb_glx_are_textures_resident_data(reply
),
899 xcb_glx_are_textures_resident_data_length(reply
) *
901 retval
= reply
->ret_val
;
904 const GLuint cmdlen
= 4 + __GLX_PAD((n
* 4));
906 __glXSetupSingleRequest(gc
, X_GLsop_AreTexturesResident
, cmdlen
);
907 (void) memcpy((void *) (pc
+ 0), (void *) (&n
), 4);
908 (void) memcpy((void *) (pc
+ 4), (void *) (textures
), (n
* 4));
910 /* n is not a multiple of four.
911 * When reply_is_always_array is TRUE, __glXReadReply() will
912 * put a multiple of four bytes into the dest buffer. If the
913 * caller's buffer is not a multiple of four in size, we'll write
914 * out of bounds. So use a temporary buffer that's a few bytes
917 GLboolean
*res4
= malloc((n
+ 3) & ~3);
918 retval
= (GLboolean
) __glXReadReply(dpy
, 1, res4
, GL_TRUE
);
919 memcpy(residences
, res4
, n
);
923 retval
= (GLboolean
) __glXReadReply(dpy
, 1, residences
, GL_TRUE
);
934 * This was previously auto-generated, but we need to special-case
935 * how we handle writing into the 'residences' buffer when n%4!=0.
937 #define X_GLvop_AreTexturesResidentEXT 11
939 glAreTexturesResidentEXT(GLsizei n
, const GLuint
* textures
,
940 GLboolean
* residences
)
942 struct glx_context
*const gc
= __glXGetCurrentContext();
945 const _glapi_proc
*const table
= (_glapi_proc
*) GET_DISPATCH();
946 PFNGLARETEXTURESRESIDENTEXTPROC p
=
947 (PFNGLARETEXTURESRESIDENTEXTPROC
) table
[332];
949 return p(n
, textures
, residences
);
952 struct glx_context
*const gc
= __glXGetCurrentContext();
953 Display
*const dpy
= gc
->currentDpy
;
954 GLboolean retval
= (GLboolean
) 0;
955 const GLuint cmdlen
= 4 + __GLX_PAD((n
* 4));
956 if (__builtin_expect((n
>= 0) && (dpy
!= NULL
), 1)) {
958 __glXSetupVendorRequest(gc
, X_GLXVendorPrivateWithReply
,
959 X_GLvop_AreTexturesResidentEXT
,
961 (void) memcpy((void *) (pc
+ 0), (void *) (&n
), 4);
962 (void) memcpy((void *) (pc
+ 4), (void *) (textures
), (n
* 4));
964 /* see comments in __indirect_glAreTexturesResident() */
965 GLboolean
*res4
= malloc((n
+ 3) & ~3);
966 retval
= (GLboolean
) __glXReadReply(dpy
, 1, res4
, GL_TRUE
);
967 memcpy(residences
, res4
, n
);
971 retval
= (GLboolean
) __glXReadReply(dpy
, 1, residences
, GL_TRUE
);