1cdc920a0Smrg/* 2cdc920a0Smrg * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) 3cdc920a0Smrg * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. 4cdc920a0Smrg * 5cdc920a0Smrg * Permission is hereby granted, free of charge, to any person obtaining a 6cdc920a0Smrg * copy of this software and associated documentation files (the "Software"), 7cdc920a0Smrg * to deal in the Software without restriction, including without limitation 8cdc920a0Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9cdc920a0Smrg * and/or sell copies of the Software, and to permit persons to whom the 10cdc920a0Smrg * Software is furnished to do so, subject to the following conditions: 11cdc920a0Smrg * 12cdc920a0Smrg * The above copyright notice including the dates of first publication and 13cdc920a0Smrg * either this permission notice or a reference to 14cdc920a0Smrg * http://oss.sgi.com/projects/FreeB/ 15cdc920a0Smrg * shall be included in all copies or substantial portions of the Software. 16cdc920a0Smrg * 17cdc920a0Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18cdc920a0Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19cdc920a0Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20cdc920a0Smrg * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21cdc920a0Smrg * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 22cdc920a0Smrg * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23cdc920a0Smrg * SOFTWARE. 24cdc920a0Smrg * 25cdc920a0Smrg * Except as contained in this notice, the name of Silicon Graphics, Inc. 26cdc920a0Smrg * shall not be used in advertising or otherwise to promote the sale, use or 27cdc920a0Smrg * other dealings in this Software without prior written authorization from 28cdc920a0Smrg * Silicon Graphics, Inc. 29cdc920a0Smrg */ 30cdc920a0Smrg 31cdc920a0Smrg#include <stdio.h> 32cdc920a0Smrg#include <assert.h> 33cdc920a0Smrg#include "glxclient.h" 34cdc920a0Smrg#include "packsingle.h" 35cdc920a0Smrg#include "glxextensions.h" 36cdc920a0Smrg#include "indirect.h" 37cdc920a0Smrg#include "indirect_vertex_array.h" 38cdc920a0Smrg#include "glapi.h" 39cdc920a0Smrg#include <xcb/xcb.h> 40cdc920a0Smrg#include <xcb/glx.h> 41cdc920a0Smrg#include <X11/Xlib-xcb.h> 42cdc920a0Smrg 433464ebd5Sriastradh#if !defined(__GNUC__) 443464ebd5Sriastradh# define __builtin_expect(x, y) x 453464ebd5Sriastradh#endif 46cdc920a0Smrg 47cdc920a0Smrg/* Used for GL_ARB_transpose_matrix */ 48cdc920a0Smrgstatic void 49cdc920a0SmrgTransposeMatrixf(GLfloat m[16]) 50cdc920a0Smrg{ 51cdc920a0Smrg int i, j; 52cdc920a0Smrg for (i = 0; i < 4; i++) { 53cdc920a0Smrg for (j = 0; j < i; j++) { 54cdc920a0Smrg GLfloat tmp = m[i * 4 + j]; 55cdc920a0Smrg m[i * 4 + j] = m[j * 4 + i]; 56cdc920a0Smrg m[j * 4 + i] = tmp; 57cdc920a0Smrg } 58cdc920a0Smrg } 59cdc920a0Smrg} 60cdc920a0Smrg 61cdc920a0Smrg/* Used for GL_ARB_transpose_matrix */ 62cdc920a0Smrgstatic void 63cdc920a0SmrgTransposeMatrixb(GLboolean m[16]) 64cdc920a0Smrg{ 65cdc920a0Smrg int i, j; 66cdc920a0Smrg for (i = 0; i < 4; i++) { 67cdc920a0Smrg for (j = 0; j < i; j++) { 68cdc920a0Smrg GLboolean tmp = m[i * 4 + j]; 69cdc920a0Smrg m[i * 4 + j] = m[j * 4 + i]; 70cdc920a0Smrg m[j * 4 + i] = tmp; 71cdc920a0Smrg } 72cdc920a0Smrg } 73cdc920a0Smrg} 74cdc920a0Smrg 75cdc920a0Smrg/* Used for GL_ARB_transpose_matrix */ 76cdc920a0Smrgstatic void 77cdc920a0SmrgTransposeMatrixd(GLdouble m[16]) 78cdc920a0Smrg{ 79cdc920a0Smrg int i, j; 80cdc920a0Smrg for (i = 0; i < 4; i++) { 81cdc920a0Smrg for (j = 0; j < i; j++) { 82cdc920a0Smrg GLdouble tmp = m[i * 4 + j]; 83cdc920a0Smrg m[i * 4 + j] = m[j * 4 + i]; 84cdc920a0Smrg m[j * 4 + i] = tmp; 85cdc920a0Smrg } 86cdc920a0Smrg } 87cdc920a0Smrg} 88cdc920a0Smrg 89cdc920a0Smrg/* Used for GL_ARB_transpose_matrix */ 90cdc920a0Smrgstatic void 91cdc920a0SmrgTransposeMatrixi(GLint m[16]) 92cdc920a0Smrg{ 93cdc920a0Smrg int i, j; 94cdc920a0Smrg for (i = 0; i < 4; i++) { 95cdc920a0Smrg for (j = 0; j < i; j++) { 96cdc920a0Smrg GLint tmp = m[i * 4 + j]; 97cdc920a0Smrg m[i * 4 + j] = m[j * 4 + i]; 98cdc920a0Smrg m[j * 4 + i] = tmp; 99cdc920a0Smrg } 100cdc920a0Smrg } 101cdc920a0Smrg} 102cdc920a0Smrg 103cdc920a0Smrg 104cdc920a0Smrg/** 105cdc920a0Smrg * Remap a transpose-matrix enum to a non-transpose-matrix enum. Enums 106cdc920a0Smrg * that are not transpose-matrix enums are unaffected. 107cdc920a0Smrg */ 108cdc920a0Smrgstatic GLenum 109cdc920a0SmrgRemapTransposeEnum(GLenum e) 110cdc920a0Smrg{ 111cdc920a0Smrg switch (e) { 112cdc920a0Smrg case GL_TRANSPOSE_MODELVIEW_MATRIX: 113cdc920a0Smrg case GL_TRANSPOSE_PROJECTION_MATRIX: 114cdc920a0Smrg case GL_TRANSPOSE_TEXTURE_MATRIX: 115cdc920a0Smrg return e - (GL_TRANSPOSE_MODELVIEW_MATRIX - GL_MODELVIEW_MATRIX); 116cdc920a0Smrg case GL_TRANSPOSE_COLOR_MATRIX: 117cdc920a0Smrg return GL_COLOR_MATRIX; 118cdc920a0Smrg default: 119cdc920a0Smrg return e; 120cdc920a0Smrg }; 121cdc920a0Smrg} 122cdc920a0Smrg 123cdc920a0Smrg 124cdc920a0SmrgGLenum 125cdc920a0Smrg__indirect_glGetError(void) 126cdc920a0Smrg{ 127cdc920a0Smrg __GLX_SINGLE_DECLARE_VARIABLES(); 128cdc920a0Smrg GLuint retval = GL_NO_ERROR; 129cdc920a0Smrg xGLXGetErrorReply reply; 130cdc920a0Smrg 131cdc920a0Smrg if (gc->error) { 132cdc920a0Smrg /* Use internal error first */ 133cdc920a0Smrg retval = gc->error; 134cdc920a0Smrg gc->error = GL_NO_ERROR; 135cdc920a0Smrg return retval; 136cdc920a0Smrg } 137cdc920a0Smrg 138cdc920a0Smrg __GLX_SINGLE_LOAD_VARIABLES(); 139cdc920a0Smrg __GLX_SINGLE_BEGIN(X_GLsop_GetError, 0); 140cdc920a0Smrg __GLX_SINGLE_READ_XREPLY(); 141cdc920a0Smrg retval = reply.error; 142cdc920a0Smrg __GLX_SINGLE_END(); 143cdc920a0Smrg 144cdc920a0Smrg return retval; 145cdc920a0Smrg} 146cdc920a0Smrg 147cdc920a0Smrg 148cdc920a0Smrg/** 149cdc920a0Smrg * Get the selected attribute from the client state. 150cdc920a0Smrg * 151cdc920a0Smrg * \returns 152cdc920a0Smrg * On success \c GL_TRUE is returned. Otherwise, \c GL_FALSE is returned. 153cdc920a0Smrg */ 154cdc920a0Smrgstatic GLboolean 1553464ebd5Sriastradhget_client_data(struct glx_context * gc, GLenum cap, GLintptr * data) 156cdc920a0Smrg{ 157cdc920a0Smrg GLboolean retval = GL_TRUE; 158cdc920a0Smrg __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); 159cdc920a0Smrg const GLint tex_unit = __glXGetActiveTextureUnit(state); 160cdc920a0Smrg 161cdc920a0Smrg 162cdc920a0Smrg switch (cap) { 163cdc920a0Smrg case GL_VERTEX_ARRAY: 164cdc920a0Smrg case GL_NORMAL_ARRAY: 165cdc920a0Smrg case GL_COLOR_ARRAY: 166cdc920a0Smrg case GL_INDEX_ARRAY: 167cdc920a0Smrg case GL_EDGE_FLAG_ARRAY: 168cdc920a0Smrg case GL_SECONDARY_COLOR_ARRAY: 169cdc920a0Smrg case GL_FOG_COORD_ARRAY: 170cdc920a0Smrg retval = __glXGetArrayEnable(state, cap, 0, data); 171cdc920a0Smrg break; 172cdc920a0Smrg 173cdc920a0Smrg case GL_VERTEX_ARRAY_SIZE: 174cdc920a0Smrg retval = __glXGetArraySize(state, GL_VERTEX_ARRAY, 0, data); 175cdc920a0Smrg break; 176cdc920a0Smrg case GL_COLOR_ARRAY_SIZE: 177cdc920a0Smrg retval = __glXGetArraySize(state, GL_COLOR_ARRAY, 0, data); 178cdc920a0Smrg break; 179cdc920a0Smrg case GL_SECONDARY_COLOR_ARRAY_SIZE: 180cdc920a0Smrg retval = __glXGetArraySize(state, GL_SECONDARY_COLOR_ARRAY, 0, data); 181cdc920a0Smrg break; 182cdc920a0Smrg 183cdc920a0Smrg case GL_VERTEX_ARRAY_TYPE: 184cdc920a0Smrg retval = __glXGetArrayType(state, GL_VERTEX_ARRAY, 0, data); 185cdc920a0Smrg break; 186cdc920a0Smrg case GL_NORMAL_ARRAY_TYPE: 187cdc920a0Smrg retval = __glXGetArrayType(state, GL_NORMAL_ARRAY, 0, data); 188cdc920a0Smrg break; 189cdc920a0Smrg case GL_INDEX_ARRAY_TYPE: 190cdc920a0Smrg retval = __glXGetArrayType(state, GL_INDEX_ARRAY, 0, data); 191cdc920a0Smrg break; 192cdc920a0Smrg case GL_COLOR_ARRAY_TYPE: 193cdc920a0Smrg retval = __glXGetArrayType(state, GL_COLOR_ARRAY, 0, data); 194cdc920a0Smrg break; 195cdc920a0Smrg case GL_SECONDARY_COLOR_ARRAY_TYPE: 196cdc920a0Smrg retval = __glXGetArrayType(state, GL_SECONDARY_COLOR_ARRAY, 0, data); 197cdc920a0Smrg break; 198cdc920a0Smrg case GL_FOG_COORD_ARRAY_TYPE: 199cdc920a0Smrg retval = __glXGetArrayType(state, GL_FOG_COORD_ARRAY, 0, data); 200cdc920a0Smrg break; 201cdc920a0Smrg 202cdc920a0Smrg case GL_VERTEX_ARRAY_STRIDE: 203cdc920a0Smrg retval = __glXGetArrayStride(state, GL_VERTEX_ARRAY, 0, data); 204cdc920a0Smrg break; 205cdc920a0Smrg case GL_NORMAL_ARRAY_STRIDE: 206cdc920a0Smrg retval = __glXGetArrayStride(state, GL_NORMAL_ARRAY, 0, data); 207cdc920a0Smrg break; 208cdc920a0Smrg case GL_INDEX_ARRAY_STRIDE: 209cdc920a0Smrg retval = __glXGetArrayStride(state, GL_INDEX_ARRAY, 0, data); 210cdc920a0Smrg break; 211cdc920a0Smrg case GL_EDGE_FLAG_ARRAY_STRIDE: 212cdc920a0Smrg retval = __glXGetArrayStride(state, GL_EDGE_FLAG_ARRAY, 0, data); 213cdc920a0Smrg break; 214cdc920a0Smrg case GL_COLOR_ARRAY_STRIDE: 215cdc920a0Smrg retval = __glXGetArrayStride(state, GL_COLOR_ARRAY, 0, data); 216cdc920a0Smrg break; 217cdc920a0Smrg case GL_SECONDARY_COLOR_ARRAY_STRIDE: 218cdc920a0Smrg retval = __glXGetArrayStride(state, GL_SECONDARY_COLOR_ARRAY, 0, data); 219cdc920a0Smrg break; 220cdc920a0Smrg case GL_FOG_COORD_ARRAY_STRIDE: 221cdc920a0Smrg retval = __glXGetArrayStride(state, GL_FOG_COORD_ARRAY, 0, data); 222cdc920a0Smrg break; 223cdc920a0Smrg 224cdc920a0Smrg case GL_TEXTURE_COORD_ARRAY: 225cdc920a0Smrg retval = 226cdc920a0Smrg __glXGetArrayEnable(state, GL_TEXTURE_COORD_ARRAY, tex_unit, data); 227cdc920a0Smrg break; 228cdc920a0Smrg case GL_TEXTURE_COORD_ARRAY_SIZE: 229cdc920a0Smrg retval = 230cdc920a0Smrg __glXGetArraySize(state, GL_TEXTURE_COORD_ARRAY, tex_unit, data); 231cdc920a0Smrg break; 232cdc920a0Smrg case GL_TEXTURE_COORD_ARRAY_TYPE: 233cdc920a0Smrg retval = 234cdc920a0Smrg __glXGetArrayType(state, GL_TEXTURE_COORD_ARRAY, tex_unit, data); 235cdc920a0Smrg break; 236cdc920a0Smrg case GL_TEXTURE_COORD_ARRAY_STRIDE: 237cdc920a0Smrg retval = 238cdc920a0Smrg __glXGetArrayStride(state, GL_TEXTURE_COORD_ARRAY, tex_unit, data); 239cdc920a0Smrg break; 240cdc920a0Smrg 241cdc920a0Smrg case GL_MAX_ELEMENTS_VERTICES: 242cdc920a0Smrg case GL_MAX_ELEMENTS_INDICES: 243cdc920a0Smrg retval = GL_TRUE; 244cdc920a0Smrg *data = ~0UL; 245cdc920a0Smrg break; 246cdc920a0Smrg 247cdc920a0Smrg 248cdc920a0Smrg case GL_PACK_ROW_LENGTH: 249cdc920a0Smrg *data = (GLintptr) state->storePack.rowLength; 250cdc920a0Smrg break; 251cdc920a0Smrg case GL_PACK_IMAGE_HEIGHT: 252cdc920a0Smrg *data = (GLintptr) state->storePack.imageHeight; 253cdc920a0Smrg break; 254cdc920a0Smrg case GL_PACK_SKIP_ROWS: 255cdc920a0Smrg *data = (GLintptr) state->storePack.skipRows; 256cdc920a0Smrg break; 257cdc920a0Smrg case GL_PACK_SKIP_PIXELS: 258cdc920a0Smrg *data = (GLintptr) state->storePack.skipPixels; 259cdc920a0Smrg break; 260cdc920a0Smrg case GL_PACK_SKIP_IMAGES: 261cdc920a0Smrg *data = (GLintptr) state->storePack.skipImages; 262cdc920a0Smrg break; 263cdc920a0Smrg case GL_PACK_ALIGNMENT: 264cdc920a0Smrg *data = (GLintptr) state->storePack.alignment; 265cdc920a0Smrg break; 266cdc920a0Smrg case GL_PACK_SWAP_BYTES: 267cdc920a0Smrg *data = (GLintptr) state->storePack.swapEndian; 268cdc920a0Smrg break; 269cdc920a0Smrg case GL_PACK_LSB_FIRST: 270cdc920a0Smrg *data = (GLintptr) state->storePack.lsbFirst; 271cdc920a0Smrg break; 272cdc920a0Smrg case GL_UNPACK_ROW_LENGTH: 273cdc920a0Smrg *data = (GLintptr) state->storeUnpack.rowLength; 274cdc920a0Smrg break; 275cdc920a0Smrg case GL_UNPACK_IMAGE_HEIGHT: 276cdc920a0Smrg *data = (GLintptr) state->storeUnpack.imageHeight; 277cdc920a0Smrg break; 278cdc920a0Smrg case GL_UNPACK_SKIP_ROWS: 279cdc920a0Smrg *data = (GLintptr) state->storeUnpack.skipRows; 280cdc920a0Smrg break; 281cdc920a0Smrg case GL_UNPACK_SKIP_PIXELS: 282cdc920a0Smrg *data = (GLintptr) state->storeUnpack.skipPixels; 283cdc920a0Smrg break; 284cdc920a0Smrg case GL_UNPACK_SKIP_IMAGES: 285cdc920a0Smrg *data = (GLintptr) state->storeUnpack.skipImages; 286cdc920a0Smrg break; 287cdc920a0Smrg case GL_UNPACK_ALIGNMENT: 288cdc920a0Smrg *data = (GLintptr) state->storeUnpack.alignment; 289cdc920a0Smrg break; 290cdc920a0Smrg case GL_UNPACK_SWAP_BYTES: 291cdc920a0Smrg *data = (GLintptr) state->storeUnpack.swapEndian; 292cdc920a0Smrg break; 293cdc920a0Smrg case GL_UNPACK_LSB_FIRST: 294cdc920a0Smrg *data = (GLintptr) state->storeUnpack.lsbFirst; 295cdc920a0Smrg break; 296cdc920a0Smrg case GL_CLIENT_ATTRIB_STACK_DEPTH: 297cdc920a0Smrg *data = (GLintptr) (gc->attributes.stackPointer - gc->attributes.stack); 298cdc920a0Smrg break; 299cdc920a0Smrg case GL_MAX_CLIENT_ATTRIB_STACK_DEPTH: 300cdc920a0Smrg *data = (GLintptr) __GL_CLIENT_ATTRIB_STACK_DEPTH; 301cdc920a0Smrg break; 302cdc920a0Smrg case GL_CLIENT_ACTIVE_TEXTURE: 303cdc920a0Smrg *data = (GLintptr) (tex_unit + GL_TEXTURE0); 304cdc920a0Smrg break; 305cdc920a0Smrg 306cdc920a0Smrg default: 307cdc920a0Smrg retval = GL_FALSE; 308cdc920a0Smrg break; 309cdc920a0Smrg } 310cdc920a0Smrg 311cdc920a0Smrg 312cdc920a0Smrg return retval; 313cdc920a0Smrg} 314cdc920a0Smrg 315cdc920a0Smrg 316cdc920a0Smrgvoid 317cdc920a0Smrg__indirect_glGetBooleanv(GLenum val, GLboolean * b) 318cdc920a0Smrg{ 319cdc920a0Smrg const GLenum origVal = val; 320cdc920a0Smrg __GLX_SINGLE_DECLARE_VARIABLES(); 321cdc920a0Smrg xGLXSingleReply reply; 322cdc920a0Smrg 323cdc920a0Smrg val = RemapTransposeEnum(val); 324cdc920a0Smrg 325cdc920a0Smrg __GLX_SINGLE_LOAD_VARIABLES(); 326cdc920a0Smrg __GLX_SINGLE_BEGIN(X_GLsop_GetBooleanv, 4); 327cdc920a0Smrg __GLX_SINGLE_PUT_LONG(0, val); 328cdc920a0Smrg __GLX_SINGLE_READ_XREPLY(); 329cdc920a0Smrg __GLX_SINGLE_GET_SIZE(compsize); 330cdc920a0Smrg 331cdc920a0Smrg if (compsize == 0) { 332cdc920a0Smrg /* 33301e04c3fSmrg ** Error occurred; don't modify user's buffer. 334cdc920a0Smrg */ 335cdc920a0Smrg } 336cdc920a0Smrg else { 337cdc920a0Smrg GLintptr data; 338cdc920a0Smrg 339cdc920a0Smrg /* 340cdc920a0Smrg ** We still needed to send the request to the server in order to 341cdc920a0Smrg ** find out whether it was legal to make a query (it's illegal, 342cdc920a0Smrg ** for example, to call a query between glBegin() and glEnd()). 343cdc920a0Smrg */ 344cdc920a0Smrg 345cdc920a0Smrg if (get_client_data(gc, val, &data)) { 346cdc920a0Smrg *b = (GLboolean) data; 347cdc920a0Smrg } 348cdc920a0Smrg else { 349cdc920a0Smrg /* 350cdc920a0Smrg ** Not a local value, so use what we got from the server. 351cdc920a0Smrg */ 352cdc920a0Smrg if (compsize == 1) { 353cdc920a0Smrg __GLX_SINGLE_GET_CHAR(b); 354cdc920a0Smrg } 355cdc920a0Smrg else { 356cdc920a0Smrg __GLX_SINGLE_GET_CHAR_ARRAY(b, compsize); 357cdc920a0Smrg if (val != origVal) { 358cdc920a0Smrg /* matrix transpose */ 359cdc920a0Smrg TransposeMatrixb(b); 360cdc920a0Smrg } 361cdc920a0Smrg } 362cdc920a0Smrg } 363cdc920a0Smrg } 364cdc920a0Smrg __GLX_SINGLE_END(); 365cdc920a0Smrg} 366cdc920a0Smrg 367cdc920a0Smrgvoid 368cdc920a0Smrg__indirect_glGetDoublev(GLenum val, GLdouble * d) 369cdc920a0Smrg{ 370cdc920a0Smrg const GLenum origVal = val; 371cdc920a0Smrg __GLX_SINGLE_DECLARE_VARIABLES(); 372cdc920a0Smrg xGLXSingleReply reply; 373cdc920a0Smrg 374cdc920a0Smrg val = RemapTransposeEnum(val); 375cdc920a0Smrg 376cdc920a0Smrg __GLX_SINGLE_LOAD_VARIABLES(); 377cdc920a0Smrg __GLX_SINGLE_BEGIN(X_GLsop_GetDoublev, 4); 378cdc920a0Smrg __GLX_SINGLE_PUT_LONG(0, val); 379cdc920a0Smrg __GLX_SINGLE_READ_XREPLY(); 380cdc920a0Smrg __GLX_SINGLE_GET_SIZE(compsize); 381cdc920a0Smrg 382cdc920a0Smrg if (compsize == 0) { 383cdc920a0Smrg /* 38401e04c3fSmrg ** Error occurred; don't modify user's buffer. 385cdc920a0Smrg */ 386cdc920a0Smrg } 387cdc920a0Smrg else { 388cdc920a0Smrg GLintptr data; 389cdc920a0Smrg 390cdc920a0Smrg /* 391cdc920a0Smrg ** We still needed to send the request to the server in order to 392cdc920a0Smrg ** find out whether it was legal to make a query (it's illegal, 393cdc920a0Smrg ** for example, to call a query between glBegin() and glEnd()). 394cdc920a0Smrg */ 395cdc920a0Smrg 396cdc920a0Smrg if (get_client_data(gc, val, &data)) { 397cdc920a0Smrg *d = (GLdouble) data; 398cdc920a0Smrg } 399cdc920a0Smrg else { 400cdc920a0Smrg /* 401cdc920a0Smrg ** Not a local value, so use what we got from the server. 402cdc920a0Smrg */ 403cdc920a0Smrg if (compsize == 1) { 404cdc920a0Smrg __GLX_SINGLE_GET_DOUBLE(d); 405cdc920a0Smrg } 406cdc920a0Smrg else { 407cdc920a0Smrg __GLX_SINGLE_GET_DOUBLE_ARRAY(d, compsize); 408cdc920a0Smrg if (val != origVal) { 409cdc920a0Smrg /* matrix transpose */ 410cdc920a0Smrg TransposeMatrixd(d); 411cdc920a0Smrg } 412cdc920a0Smrg } 413cdc920a0Smrg } 414cdc920a0Smrg } 415cdc920a0Smrg __GLX_SINGLE_END(); 416cdc920a0Smrg} 417cdc920a0Smrg 418cdc920a0Smrgvoid 419cdc920a0Smrg__indirect_glGetFloatv(GLenum val, GLfloat * f) 420cdc920a0Smrg{ 421cdc920a0Smrg const GLenum origVal = val; 422cdc920a0Smrg __GLX_SINGLE_DECLARE_VARIABLES(); 423cdc920a0Smrg xGLXSingleReply reply; 424cdc920a0Smrg 425cdc920a0Smrg val = RemapTransposeEnum(val); 426cdc920a0Smrg 427cdc920a0Smrg __GLX_SINGLE_LOAD_VARIABLES(); 428cdc920a0Smrg __GLX_SINGLE_BEGIN(X_GLsop_GetFloatv, 4); 429cdc920a0Smrg __GLX_SINGLE_PUT_LONG(0, val); 430cdc920a0Smrg __GLX_SINGLE_READ_XREPLY(); 431cdc920a0Smrg __GLX_SINGLE_GET_SIZE(compsize); 432cdc920a0Smrg 433cdc920a0Smrg if (compsize == 0) { 434cdc920a0Smrg /* 43501e04c3fSmrg ** Error occurred; don't modify user's buffer. 436cdc920a0Smrg */ 437cdc920a0Smrg } 438cdc920a0Smrg else { 439cdc920a0Smrg GLintptr data; 440cdc920a0Smrg 441cdc920a0Smrg /* 442cdc920a0Smrg ** We still needed to send the request to the server in order to 443cdc920a0Smrg ** find out whether it was legal to make a query (it's illegal, 444cdc920a0Smrg ** for example, to call a query between glBegin() and glEnd()). 445cdc920a0Smrg */ 446cdc920a0Smrg 447cdc920a0Smrg if (get_client_data(gc, val, &data)) { 448cdc920a0Smrg *f = (GLfloat) data; 449cdc920a0Smrg } 450cdc920a0Smrg else { 451cdc920a0Smrg /* 452cdc920a0Smrg ** Not a local value, so use what we got from the server. 453cdc920a0Smrg */ 454cdc920a0Smrg if (compsize == 1) { 455cdc920a0Smrg __GLX_SINGLE_GET_FLOAT(f); 456cdc920a0Smrg } 457cdc920a0Smrg else { 458cdc920a0Smrg __GLX_SINGLE_GET_FLOAT_ARRAY(f, compsize); 459cdc920a0Smrg if (val != origVal) { 460cdc920a0Smrg /* matrix transpose */ 461cdc920a0Smrg TransposeMatrixf(f); 462cdc920a0Smrg } 463cdc920a0Smrg } 464cdc920a0Smrg } 465cdc920a0Smrg } 466cdc920a0Smrg __GLX_SINGLE_END(); 467cdc920a0Smrg} 468cdc920a0Smrg 469cdc920a0Smrgvoid 470cdc920a0Smrg__indirect_glGetIntegerv(GLenum val, GLint * i) 471cdc920a0Smrg{ 472cdc920a0Smrg const GLenum origVal = val; 473cdc920a0Smrg __GLX_SINGLE_DECLARE_VARIABLES(); 474cdc920a0Smrg xGLXSingleReply reply; 475cdc920a0Smrg 476cdc920a0Smrg val = RemapTransposeEnum(val); 477cdc920a0Smrg 478cdc920a0Smrg __GLX_SINGLE_LOAD_VARIABLES(); 479cdc920a0Smrg __GLX_SINGLE_BEGIN(X_GLsop_GetIntegerv, 4); 480cdc920a0Smrg __GLX_SINGLE_PUT_LONG(0, val); 481cdc920a0Smrg __GLX_SINGLE_READ_XREPLY(); 482cdc920a0Smrg __GLX_SINGLE_GET_SIZE(compsize); 483cdc920a0Smrg 484cdc920a0Smrg if (compsize == 0) { 485cdc920a0Smrg /* 48601e04c3fSmrg ** Error occurred; don't modify user's buffer. 487cdc920a0Smrg */ 488cdc920a0Smrg } 489cdc920a0Smrg else { 490cdc920a0Smrg GLintptr data; 491cdc920a0Smrg 492cdc920a0Smrg /* 493cdc920a0Smrg ** We still needed to send the request to the server in order to 494cdc920a0Smrg ** find out whether it was legal to make a query (it's illegal, 495cdc920a0Smrg ** for example, to call a query between glBegin() and glEnd()). 496cdc920a0Smrg */ 497cdc920a0Smrg 498cdc920a0Smrg if (get_client_data(gc, val, &data)) { 499cdc920a0Smrg *i = (GLint) data; 500cdc920a0Smrg } 501cdc920a0Smrg else { 502cdc920a0Smrg /* 503cdc920a0Smrg ** Not a local value, so use what we got from the server. 504cdc920a0Smrg */ 505cdc920a0Smrg if (compsize == 1) { 506cdc920a0Smrg __GLX_SINGLE_GET_LONG(i); 507cdc920a0Smrg } 508cdc920a0Smrg else { 509cdc920a0Smrg __GLX_SINGLE_GET_LONG_ARRAY(i, compsize); 510cdc920a0Smrg if (val != origVal) { 511cdc920a0Smrg /* matrix transpose */ 512cdc920a0Smrg TransposeMatrixi(i); 513cdc920a0Smrg } 514cdc920a0Smrg } 515cdc920a0Smrg } 516cdc920a0Smrg } 517cdc920a0Smrg __GLX_SINGLE_END(); 518cdc920a0Smrg} 519cdc920a0Smrg 520cdc920a0Smrg/* 521cdc920a0Smrg** Send all pending commands to server. 522cdc920a0Smrg*/ 523cdc920a0Smrgvoid 524cdc920a0Smrg__indirect_glFlush(void) 525cdc920a0Smrg{ 526cdc920a0Smrg __GLX_SINGLE_DECLARE_VARIABLES(); 527cdc920a0Smrg 528cdc920a0Smrg if (!dpy) 529cdc920a0Smrg return; 530cdc920a0Smrg 531cdc920a0Smrg __GLX_SINGLE_LOAD_VARIABLES(); 532cdc920a0Smrg __GLX_SINGLE_BEGIN(X_GLsop_Flush, 0); 533cdc920a0Smrg __GLX_SINGLE_END(); 534cdc920a0Smrg 535cdc920a0Smrg /* And finally flush the X protocol data */ 536cdc920a0Smrg XFlush(dpy); 537cdc920a0Smrg} 538cdc920a0Smrg 539cdc920a0Smrgvoid 540cdc920a0Smrg__indirect_glFeedbackBuffer(GLsizei size, GLenum type, GLfloat * buffer) 541cdc920a0Smrg{ 542cdc920a0Smrg __GLX_SINGLE_DECLARE_VARIABLES(); 543cdc920a0Smrg 544cdc920a0Smrg if (!dpy) 545cdc920a0Smrg return; 546cdc920a0Smrg 547cdc920a0Smrg __GLX_SINGLE_LOAD_VARIABLES(); 548cdc920a0Smrg __GLX_SINGLE_BEGIN(X_GLsop_FeedbackBuffer, 8); 549cdc920a0Smrg __GLX_SINGLE_PUT_LONG(0, size); 550cdc920a0Smrg __GLX_SINGLE_PUT_LONG(4, type); 551cdc920a0Smrg __GLX_SINGLE_END(); 552cdc920a0Smrg 553cdc920a0Smrg gc->feedbackBuf = buffer; 554cdc920a0Smrg} 555cdc920a0Smrg 556cdc920a0Smrgvoid 557cdc920a0Smrg__indirect_glSelectBuffer(GLsizei numnames, GLuint * buffer) 558cdc920a0Smrg{ 559cdc920a0Smrg __GLX_SINGLE_DECLARE_VARIABLES(); 560cdc920a0Smrg 561cdc920a0Smrg if (!dpy) 562cdc920a0Smrg return; 563cdc920a0Smrg 564cdc920a0Smrg __GLX_SINGLE_LOAD_VARIABLES(); 565cdc920a0Smrg __GLX_SINGLE_BEGIN(X_GLsop_SelectBuffer, 4); 566cdc920a0Smrg __GLX_SINGLE_PUT_LONG(0, numnames); 567cdc920a0Smrg __GLX_SINGLE_END(); 568cdc920a0Smrg 569cdc920a0Smrg gc->selectBuf = buffer; 570cdc920a0Smrg} 571cdc920a0Smrg 572cdc920a0SmrgGLint 573cdc920a0Smrg__indirect_glRenderMode(GLenum mode) 574cdc920a0Smrg{ 575cdc920a0Smrg __GLX_SINGLE_DECLARE_VARIABLES(); 576cdc920a0Smrg GLint retval = 0; 577cdc920a0Smrg xGLXRenderModeReply reply; 578cdc920a0Smrg 579cdc920a0Smrg if (!dpy) 580cdc920a0Smrg return -1; 581cdc920a0Smrg 582cdc920a0Smrg __GLX_SINGLE_LOAD_VARIABLES(); 583cdc920a0Smrg __GLX_SINGLE_BEGIN(X_GLsop_RenderMode, 4); 584cdc920a0Smrg __GLX_SINGLE_PUT_LONG(0, mode); 585cdc920a0Smrg __GLX_SINGLE_READ_XREPLY(); 586cdc920a0Smrg __GLX_SINGLE_GET_RETVAL(retval, GLint); 587cdc920a0Smrg 588cdc920a0Smrg if (reply.newMode != mode) { 589cdc920a0Smrg /* 590cdc920a0Smrg ** Switch to new mode did not take effect, therefore an error 59101e04c3fSmrg ** occurred. When an error happens the server won't send us any 592cdc920a0Smrg ** other data. 593cdc920a0Smrg */ 594cdc920a0Smrg } 595cdc920a0Smrg else { 596cdc920a0Smrg /* Read the feedback or selection data */ 597cdc920a0Smrg if (gc->renderMode == GL_FEEDBACK) { 598cdc920a0Smrg __GLX_SINGLE_GET_SIZE(compsize); 599cdc920a0Smrg __GLX_SINGLE_GET_FLOAT_ARRAY(gc->feedbackBuf, compsize); 600cdc920a0Smrg } 601cdc920a0Smrg else if (gc->renderMode == GL_SELECT) { 602cdc920a0Smrg __GLX_SINGLE_GET_SIZE(compsize); 603cdc920a0Smrg __GLX_SINGLE_GET_LONG_ARRAY(gc->selectBuf, compsize); 604cdc920a0Smrg } 605cdc920a0Smrg gc->renderMode = mode; 606cdc920a0Smrg } 607cdc920a0Smrg __GLX_SINGLE_END(); 608cdc920a0Smrg 609cdc920a0Smrg return retval; 610cdc920a0Smrg} 611cdc920a0Smrg 612cdc920a0Smrgvoid 613cdc920a0Smrg__indirect_glFinish(void) 614cdc920a0Smrg{ 615cdc920a0Smrg __GLX_SINGLE_DECLARE_VARIABLES(); 616cdc920a0Smrg xGLXSingleReply reply; 617cdc920a0Smrg 618cdc920a0Smrg __GLX_SINGLE_LOAD_VARIABLES(); 619cdc920a0Smrg __GLX_SINGLE_BEGIN(X_GLsop_Finish, 0); 620cdc920a0Smrg __GLX_SINGLE_READ_XREPLY(); 621cdc920a0Smrg __GLX_SINGLE_END(); 622cdc920a0Smrg} 623cdc920a0Smrg 624cdc920a0Smrg 625cdc920a0Smrg/** 626cdc920a0Smrg * Extract the major and minor version numbers from a version string. 627cdc920a0Smrg */ 628cdc920a0Smrgstatic void 629cdc920a0Smrgversion_from_string(const char *ver, int *major_version, int *minor_version) 630cdc920a0Smrg{ 631cdc920a0Smrg const char *end; 632cdc920a0Smrg long major; 633cdc920a0Smrg long minor; 634cdc920a0Smrg 635cdc920a0Smrg major = strtol(ver, (char **) &end, 10); 636cdc920a0Smrg minor = strtol(end + 1, NULL, 10); 637cdc920a0Smrg *major_version = major; 638cdc920a0Smrg *minor_version = minor; 639cdc920a0Smrg} 640cdc920a0Smrg 641cdc920a0Smrg 642cdc920a0Smrgconst GLubyte * 643cdc920a0Smrg__indirect_glGetString(GLenum name) 644cdc920a0Smrg{ 6453464ebd5Sriastradh struct glx_context *gc = __glXGetCurrentContext(); 646cdc920a0Smrg Display *dpy = gc->currentDpy; 647cdc920a0Smrg GLubyte *s = NULL; 648cdc920a0Smrg 649cdc920a0Smrg if (!dpy) 650cdc920a0Smrg return 0; 651cdc920a0Smrg 652cdc920a0Smrg /* 653cdc920a0Smrg ** Return the cached copy if the string has already been fetched 654cdc920a0Smrg */ 655cdc920a0Smrg switch (name) { 656cdc920a0Smrg case GL_VENDOR: 657cdc920a0Smrg if (gc->vendor) 658cdc920a0Smrg return gc->vendor; 659cdc920a0Smrg break; 660cdc920a0Smrg case GL_RENDERER: 661cdc920a0Smrg if (gc->renderer) 662cdc920a0Smrg return gc->renderer; 663cdc920a0Smrg break; 664cdc920a0Smrg case GL_VERSION: 665cdc920a0Smrg if (gc->version) 666cdc920a0Smrg return gc->version; 667cdc920a0Smrg break; 668cdc920a0Smrg case GL_EXTENSIONS: 669cdc920a0Smrg if (gc->extensions) 670cdc920a0Smrg return gc->extensions; 671cdc920a0Smrg break; 672cdc920a0Smrg default: 673cdc920a0Smrg __glXSetError(gc, GL_INVALID_ENUM); 674cdc920a0Smrg return 0; 675cdc920a0Smrg } 676cdc920a0Smrg 677cdc920a0Smrg /* 678cdc920a0Smrg ** Get requested string from server 679cdc920a0Smrg */ 680cdc920a0Smrg 681cdc920a0Smrg (void) __glXFlushRenderBuffer(gc, gc->pc); 6827ec681f3Smrg s = (GLubyte *) __glXGetString(dpy, gc->currentContextTag, name); 683cdc920a0Smrg if (!s) { 684cdc920a0Smrg /* Throw data on the floor */ 685cdc920a0Smrg __glXSetError(gc, GL_OUT_OF_MEMORY); 686cdc920a0Smrg } 687cdc920a0Smrg else { 688cdc920a0Smrg /* 689cdc920a0Smrg ** Update local cache 690cdc920a0Smrg */ 691cdc920a0Smrg switch (name) { 692cdc920a0Smrg case GL_VENDOR: 693cdc920a0Smrg gc->vendor = s; 694cdc920a0Smrg break; 695cdc920a0Smrg 696cdc920a0Smrg case GL_RENDERER: 697cdc920a0Smrg gc->renderer = s; 698cdc920a0Smrg break; 699cdc920a0Smrg 700cdc920a0Smrg case GL_VERSION:{ 7017ec681f3Smrg const int client_major = 1; 7027ec681f3Smrg const int client_minor = 4; 703cdc920a0Smrg 704cdc920a0Smrg version_from_string((char *) s, 705cdc920a0Smrg &gc->server_major, &gc->server_minor); 706cdc920a0Smrg 707cdc920a0Smrg if ((gc->server_major < client_major) 708cdc920a0Smrg || ((gc->server_major == client_major) 709cdc920a0Smrg && (gc->server_minor <= client_minor))) { 710cdc920a0Smrg gc->version = s; 711cdc920a0Smrg } 712cdc920a0Smrg else { 713cdc920a0Smrg /* Allow 7 bytes for the client-side GL version. This allows 714cdc920a0Smrg * for upto version 999.999. I'm not holding my breath for 715cdc920a0Smrg * that one! The extra 4 is for the ' ()\0' that will be 716cdc920a0Smrg * added. 717cdc920a0Smrg */ 718cdc920a0Smrg const size_t size = 7 + strlen((char *) s) + 4; 719cdc920a0Smrg 720af69d88dSmrg gc->version = malloc(size); 721cdc920a0Smrg if (gc->version == NULL) { 722cdc920a0Smrg /* If we couldn't allocate memory for the new string, 723cdc920a0Smrg * make a best-effort and just copy the client-side version 724cdc920a0Smrg * to the string and use that. It probably doesn't 725cdc920a0Smrg * matter what is done here. If there not memory available 726cdc920a0Smrg * for a short string, the system is probably going to die 727cdc920a0Smrg * soon anyway. 728cdc920a0Smrg */ 729cdc920a0Smrg snprintf((char *) s, strlen((char *) s) + 1, "%u.%u", 730cdc920a0Smrg client_major, client_minor); 731cdc920a0Smrg gc->version = s; 732cdc920a0Smrg } 733cdc920a0Smrg else { 734cdc920a0Smrg snprintf((char *) gc->version, size, "%u.%u (%s)", 735cdc920a0Smrg client_major, client_minor, s); 736af69d88dSmrg free(s); 737cdc920a0Smrg s = gc->version; 738cdc920a0Smrg } 739cdc920a0Smrg } 740cdc920a0Smrg break; 741cdc920a0Smrg } 742cdc920a0Smrg 743cdc920a0Smrg case GL_EXTENSIONS:{ 7447ec681f3Smrg __glXCalculateUsableGLExtensions(gc, (char *) s); 745af69d88dSmrg free(s); 746cdc920a0Smrg s = gc->extensions; 747cdc920a0Smrg break; 748cdc920a0Smrg } 749cdc920a0Smrg } 750cdc920a0Smrg } 751cdc920a0Smrg return s; 752cdc920a0Smrg} 753cdc920a0Smrg 754cdc920a0SmrgGLboolean 755cdc920a0Smrg__indirect_glIsEnabled(GLenum cap) 756cdc920a0Smrg{ 757cdc920a0Smrg __GLX_SINGLE_DECLARE_VARIABLES(); 758cdc920a0Smrg __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); 759cdc920a0Smrg xGLXSingleReply reply; 760cdc920a0Smrg GLboolean retval = 0; 761cdc920a0Smrg GLintptr enable; 762cdc920a0Smrg 763cdc920a0Smrg if (!dpy) 764cdc920a0Smrg return 0; 765cdc920a0Smrg 766cdc920a0Smrg switch (cap) { 767cdc920a0Smrg case GL_VERTEX_ARRAY: 768cdc920a0Smrg case GL_NORMAL_ARRAY: 769cdc920a0Smrg case GL_COLOR_ARRAY: 770cdc920a0Smrg case GL_INDEX_ARRAY: 771cdc920a0Smrg case GL_EDGE_FLAG_ARRAY: 772cdc920a0Smrg case GL_SECONDARY_COLOR_ARRAY: 773cdc920a0Smrg case GL_FOG_COORD_ARRAY: 774cdc920a0Smrg retval = __glXGetArrayEnable(state, cap, 0, &enable); 775cdc920a0Smrg assert(retval); 776cdc920a0Smrg return (GLboolean) enable; 777cdc920a0Smrg break; 778cdc920a0Smrg case GL_TEXTURE_COORD_ARRAY: 779cdc920a0Smrg retval = __glXGetArrayEnable(state, GL_TEXTURE_COORD_ARRAY, 780cdc920a0Smrg __glXGetActiveTextureUnit(state), &enable); 781cdc920a0Smrg assert(retval); 782cdc920a0Smrg return (GLboolean) enable; 783cdc920a0Smrg break; 784cdc920a0Smrg } 785cdc920a0Smrg 786cdc920a0Smrg __GLX_SINGLE_LOAD_VARIABLES(); 787cdc920a0Smrg __GLX_SINGLE_BEGIN(X_GLsop_IsEnabled, 4); 788cdc920a0Smrg __GLX_SINGLE_PUT_LONG(0, cap); 789cdc920a0Smrg __GLX_SINGLE_READ_XREPLY(); 790cdc920a0Smrg __GLX_SINGLE_GET_RETVAL(retval, GLboolean); 791cdc920a0Smrg __GLX_SINGLE_END(); 792cdc920a0Smrg return retval; 793cdc920a0Smrg} 794cdc920a0Smrg 795cdc920a0Smrgvoid 796cdc920a0Smrg__indirect_glGetPointerv(GLenum pname, void **params) 797cdc920a0Smrg{ 7983464ebd5Sriastradh struct glx_context *gc = __glXGetCurrentContext(); 799cdc920a0Smrg __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); 800cdc920a0Smrg Display *dpy = gc->currentDpy; 801cdc920a0Smrg 802cdc920a0Smrg if (!dpy) 803cdc920a0Smrg return; 804cdc920a0Smrg 805cdc920a0Smrg switch (pname) { 806cdc920a0Smrg case GL_VERTEX_ARRAY_POINTER: 807cdc920a0Smrg case GL_NORMAL_ARRAY_POINTER: 808cdc920a0Smrg case GL_COLOR_ARRAY_POINTER: 809cdc920a0Smrg case GL_INDEX_ARRAY_POINTER: 810cdc920a0Smrg case GL_EDGE_FLAG_ARRAY_POINTER: 811cdc920a0Smrg __glXGetArrayPointer(state, pname - GL_VERTEX_ARRAY_POINTER 812cdc920a0Smrg + GL_VERTEX_ARRAY, 0, params); 813cdc920a0Smrg return; 814cdc920a0Smrg case GL_TEXTURE_COORD_ARRAY_POINTER: 815cdc920a0Smrg __glXGetArrayPointer(state, GL_TEXTURE_COORD_ARRAY, 816cdc920a0Smrg __glXGetActiveTextureUnit(state), params); 817cdc920a0Smrg return; 818cdc920a0Smrg case GL_SECONDARY_COLOR_ARRAY_POINTER: 819cdc920a0Smrg case GL_FOG_COORD_ARRAY_POINTER: 820cdc920a0Smrg __glXGetArrayPointer(state, pname - GL_FOG_COORD_ARRAY_POINTER 821cdc920a0Smrg + GL_FOG_COORD_ARRAY, 0, params); 822cdc920a0Smrg return; 823cdc920a0Smrg case GL_FEEDBACK_BUFFER_POINTER: 824cdc920a0Smrg *params = (void *) gc->feedbackBuf; 825cdc920a0Smrg return; 826cdc920a0Smrg case GL_SELECTION_BUFFER_POINTER: 827cdc920a0Smrg *params = (void *) gc->selectBuf; 828cdc920a0Smrg return; 829cdc920a0Smrg default: 830cdc920a0Smrg __glXSetError(gc, GL_INVALID_ENUM); 831cdc920a0Smrg return; 832cdc920a0Smrg } 833cdc920a0Smrg} 834cdc920a0Smrg 835cdc920a0Smrg 836cdc920a0Smrg 837cdc920a0Smrg/** 838cdc920a0Smrg * This was previously auto-generated, but we need to special-case 839cdc920a0Smrg * how we handle writing into the 'residences' buffer when n%4!=0. 840cdc920a0Smrg */ 841cdc920a0Smrg#define X_GLsop_AreTexturesResident 143 842cdc920a0SmrgGLboolean 843cdc920a0Smrg__indirect_glAreTexturesResident(GLsizei n, const GLuint * textures, 844cdc920a0Smrg GLboolean * residences) 845cdc920a0Smrg{ 8463464ebd5Sriastradh struct glx_context *const gc = __glXGetCurrentContext(); 847cdc920a0Smrg Display *const dpy = gc->currentDpy; 848cdc920a0Smrg GLboolean retval = (GLboolean) 0; 849cdc920a0Smrg if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) { 850cdc920a0Smrg xcb_connection_t *c = XGetXCBConnection(dpy); 851af69d88dSmrg xcb_glx_are_textures_resident_reply_t *reply; 852cdc920a0Smrg (void) __glXFlushRenderBuffer(gc, gc->pc); 853af69d88dSmrg reply = 854cdc920a0Smrg xcb_glx_are_textures_resident_reply(c, 855cdc920a0Smrg xcb_glx_are_textures_resident 856cdc920a0Smrg (c, gc->currentContextTag, n, 857cdc920a0Smrg textures), NULL); 858cdc920a0Smrg (void) memcpy(residences, xcb_glx_are_textures_resident_data(reply), 859cdc920a0Smrg xcb_glx_are_textures_resident_data_length(reply) * 860cdc920a0Smrg sizeof(GLboolean)); 861cdc920a0Smrg retval = reply->ret_val; 862cdc920a0Smrg free(reply); 863cdc920a0Smrg } 864cdc920a0Smrg return retval; 865cdc920a0Smrg} 866cdc920a0Smrg 867cdc920a0Smrg 868cdc920a0Smrg/** 869cdc920a0Smrg * This was previously auto-generated, but we need to special-case 870cdc920a0Smrg * how we handle writing into the 'residences' buffer when n%4!=0. 871cdc920a0Smrg */ 872cdc920a0Smrg#define X_GLvop_AreTexturesResidentEXT 11 873cdc920a0SmrgGLboolean 874cdc920a0SmrgglAreTexturesResidentEXT(GLsizei n, const GLuint * textures, 875cdc920a0Smrg GLboolean * residences) 876cdc920a0Smrg{ 8773464ebd5Sriastradh struct glx_context *const gc = __glXGetCurrentContext(); 878cdc920a0Smrg 879cdc920a0Smrg if (gc->isDirect) { 880af69d88dSmrg const _glapi_proc *const table = (_glapi_proc *) GET_DISPATCH(); 881af69d88dSmrg PFNGLARETEXTURESRESIDENTEXTPROC p = 882af69d88dSmrg (PFNGLARETEXTURESRESIDENTEXTPROC) table[332]; 883af69d88dSmrg 884af69d88dSmrg return p(n, textures, residences); 885cdc920a0Smrg } 886cdc920a0Smrg else { 8873464ebd5Sriastradh struct glx_context *const gc = __glXGetCurrentContext(); 888cdc920a0Smrg Display *const dpy = gc->currentDpy; 889cdc920a0Smrg GLboolean retval = (GLboolean) 0; 890cdc920a0Smrg const GLuint cmdlen = 4 + __GLX_PAD((n * 4)); 891cdc920a0Smrg if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) { 892cdc920a0Smrg GLubyte const *pc = 893cdc920a0Smrg __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, 894cdc920a0Smrg X_GLvop_AreTexturesResidentEXT, 895cdc920a0Smrg cmdlen); 896cdc920a0Smrg (void) memcpy((void *) (pc + 0), (void *) (&n), 4); 897cdc920a0Smrg (void) memcpy((void *) (pc + 4), (void *) (textures), (n * 4)); 898cdc920a0Smrg if (n & 3) { 899cdc920a0Smrg /* see comments in __indirect_glAreTexturesResident() */ 900cdc920a0Smrg GLboolean *res4 = malloc((n + 3) & ~3); 901cdc920a0Smrg retval = (GLboolean) __glXReadReply(dpy, 1, res4, GL_TRUE); 902cdc920a0Smrg memcpy(residences, res4, n); 903cdc920a0Smrg free(res4); 904cdc920a0Smrg } 905cdc920a0Smrg else { 906cdc920a0Smrg retval = (GLboolean) __glXReadReply(dpy, 1, residences, GL_TRUE); 907cdc920a0Smrg } 908cdc920a0Smrg UnlockDisplay(dpy); 909cdc920a0Smrg SyncHandle(); 910cdc920a0Smrg } 911cdc920a0Smrg return retval; 912cdc920a0Smrg } 913cdc920a0Smrg} 914