14642e01fSmrg/* 24642e01fSmrg * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) 34642e01fSmrg * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. 44642e01fSmrg * 54642e01fSmrg * Permission is hereby granted, free of charge, to any person obtaining a 64642e01fSmrg * copy of this software and associated documentation files (the "Software"), 74642e01fSmrg * to deal in the Software without restriction, including without limitation 84642e01fSmrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 94642e01fSmrg * and/or sell copies of the Software, and to permit persons to whom the 104642e01fSmrg * Software is furnished to do so, subject to the following conditions: 114642e01fSmrg * 124642e01fSmrg * The above copyright notice including the dates of first publication and 134642e01fSmrg * either this permission notice or a reference to 144642e01fSmrg * http://oss.sgi.com/projects/FreeB/ 154642e01fSmrg * shall be included in all copies or substantial portions of the Software. 164642e01fSmrg * 174642e01fSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 184642e01fSmrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 194642e01fSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 204642e01fSmrg * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 214642e01fSmrg * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 224642e01fSmrg * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 234642e01fSmrg * SOFTWARE. 244642e01fSmrg * 254642e01fSmrg * Except as contained in this notice, the name of Silicon Graphics, Inc. 264642e01fSmrg * shall not be used in advertising or otherwise to promote the sale, use or 274642e01fSmrg * other dealings in this Software without prior written authorization from 284642e01fSmrg * Silicon Graphics, Inc. 294642e01fSmrg */ 304642e01fSmrg 314642e01fSmrg#ifdef HAVE_DIX_CONFIG_H 324642e01fSmrg#include <dix-config.h> 334642e01fSmrg#endif 344642e01fSmrg 354642e01fSmrg#include <glxserver.h> 364642e01fSmrg#include "unpack.h" 374642e01fSmrg#include "indirect_size.h" 384642e01fSmrg#include "indirect_dispatch.h" 394642e01fSmrg 4035c4bbdfSmrgvoid 4135c4bbdfSmrg__glXDisp_Map1f(GLbyte * pc) 424642e01fSmrg{ 434642e01fSmrg GLint order, k; 444642e01fSmrg GLfloat u1, u2, *points; 454642e01fSmrg GLenum target; 464642e01fSmrg 4735c4bbdfSmrg target = *(GLenum *) (pc + 0); 4835c4bbdfSmrg order = *(GLint *) (pc + 12); 4935c4bbdfSmrg u1 = *(GLfloat *) (pc + 4); 5035c4bbdfSmrg u2 = *(GLfloat *) (pc + 8); 5135c4bbdfSmrg points = (GLfloat *) (pc + 16); 524642e01fSmrg k = __glMap1f_size(target); 534642e01fSmrg 5435c4bbdfSmrg glMap1f(target, u1, u2, k, order, points); 554642e01fSmrg} 564642e01fSmrg 5735c4bbdfSmrgvoid 5835c4bbdfSmrg__glXDisp_Map2f(GLbyte * pc) 594642e01fSmrg{ 604642e01fSmrg GLint uorder, vorder, ustride, vstride, k; 614642e01fSmrg GLfloat u1, u2, v1, v2, *points; 624642e01fSmrg GLenum target; 634642e01fSmrg 6435c4bbdfSmrg target = *(GLenum *) (pc + 0); 6535c4bbdfSmrg uorder = *(GLint *) (pc + 12); 6635c4bbdfSmrg vorder = *(GLint *) (pc + 24); 6735c4bbdfSmrg u1 = *(GLfloat *) (pc + 4); 6835c4bbdfSmrg u2 = *(GLfloat *) (pc + 8); 6935c4bbdfSmrg v1 = *(GLfloat *) (pc + 16); 7035c4bbdfSmrg v2 = *(GLfloat *) (pc + 20); 7135c4bbdfSmrg points = (GLfloat *) (pc + 28); 724642e01fSmrg 734642e01fSmrg k = __glMap2f_size(target); 744642e01fSmrg ustride = vorder * k; 754642e01fSmrg vstride = k; 764642e01fSmrg 7735c4bbdfSmrg glMap2f(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points); 784642e01fSmrg} 794642e01fSmrg 8035c4bbdfSmrgvoid 8135c4bbdfSmrg__glXDisp_Map1d(GLbyte * pc) 824642e01fSmrg{ 834642e01fSmrg GLint order, k; 8435c4bbdfSmrg 854642e01fSmrg#ifdef __GLX_ALIGN64 864642e01fSmrg GLint compsize; 874642e01fSmrg#endif 884642e01fSmrg GLenum target; 894642e01fSmrg GLdouble u1, u2, *points; 904642e01fSmrg 9135c4bbdfSmrg target = *(GLenum *) (pc + 16); 9235c4bbdfSmrg order = *(GLint *) (pc + 20); 934642e01fSmrg k = __glMap1d_size(target); 944642e01fSmrg 954642e01fSmrg#ifdef __GLX_ALIGN64 964642e01fSmrg if (order < 0 || k < 0) { 9735c4bbdfSmrg compsize = 0; 9835c4bbdfSmrg } 9935c4bbdfSmrg else { 10035c4bbdfSmrg compsize = order * k; 1014642e01fSmrg } 1024642e01fSmrg#endif 1034642e01fSmrg 10435c4bbdfSmrg __GLX_GET_DOUBLE(u1, pc); 10535c4bbdfSmrg __GLX_GET_DOUBLE(u2, pc + 8); 1064642e01fSmrg pc += 24; 1074642e01fSmrg 1084642e01fSmrg#ifdef __GLX_ALIGN64 10935c4bbdfSmrg if (((unsigned long) pc) & 7) { 11035c4bbdfSmrg /* 11135c4bbdfSmrg ** Copy the doubles up 4 bytes, trashing the command but aligning 11235c4bbdfSmrg ** the data in the process 11335c4bbdfSmrg */ 11435c4bbdfSmrg __GLX_MEM_COPY(pc - 4, pc, compsize * 8); 11535c4bbdfSmrg points = (GLdouble *) (pc - 4); 11635c4bbdfSmrg } 11735c4bbdfSmrg else { 11835c4bbdfSmrg points = (GLdouble *) pc; 1194642e01fSmrg } 1204642e01fSmrg#else 12135c4bbdfSmrg points = (GLdouble *) pc; 1224642e01fSmrg#endif 12335c4bbdfSmrg glMap1d(target, u1, u2, k, order, points); 1244642e01fSmrg} 1254642e01fSmrg 12635c4bbdfSmrgvoid 12735c4bbdfSmrg__glXDisp_Map2d(GLbyte * pc) 1284642e01fSmrg{ 1294642e01fSmrg GLdouble u1, u2, v1, v2, *points; 1304642e01fSmrg GLint uorder, vorder, ustride, vstride, k; 13135c4bbdfSmrg 1324642e01fSmrg#ifdef __GLX_ALIGN64 1334642e01fSmrg GLint compsize; 1344642e01fSmrg#endif 1354642e01fSmrg GLenum target; 1364642e01fSmrg 13735c4bbdfSmrg target = *(GLenum *) (pc + 32); 13835c4bbdfSmrg uorder = *(GLint *) (pc + 36); 13935c4bbdfSmrg vorder = *(GLint *) (pc + 40); 1404642e01fSmrg k = __glMap2d_size(target); 1414642e01fSmrg 1424642e01fSmrg#ifdef __GLX_ALIGN64 1434642e01fSmrg if (vorder < 0 || uorder < 0 || k < 0) { 14435c4bbdfSmrg compsize = 0; 14535c4bbdfSmrg } 14635c4bbdfSmrg else { 14735c4bbdfSmrg compsize = uorder * vorder * k; 1484642e01fSmrg } 1494642e01fSmrg#endif 1504642e01fSmrg 15135c4bbdfSmrg __GLX_GET_DOUBLE(u1, pc); 15235c4bbdfSmrg __GLX_GET_DOUBLE(u2, pc + 8); 15335c4bbdfSmrg __GLX_GET_DOUBLE(v1, pc + 16); 15435c4bbdfSmrg __GLX_GET_DOUBLE(v2, pc + 24); 1554642e01fSmrg pc += 44; 1564642e01fSmrg 1574642e01fSmrg ustride = vorder * k; 1584642e01fSmrg vstride = k; 1594642e01fSmrg 1604642e01fSmrg#ifdef __GLX_ALIGN64 16135c4bbdfSmrg if (((unsigned long) pc) & 7) { 16235c4bbdfSmrg /* 16335c4bbdfSmrg ** Copy the doubles up 4 bytes, trashing the command but aligning 16435c4bbdfSmrg ** the data in the process 16535c4bbdfSmrg */ 16635c4bbdfSmrg __GLX_MEM_COPY(pc - 4, pc, compsize * 8); 16735c4bbdfSmrg points = (GLdouble *) (pc - 4); 16835c4bbdfSmrg } 16935c4bbdfSmrg else { 17035c4bbdfSmrg points = (GLdouble *) pc; 1714642e01fSmrg } 1724642e01fSmrg#else 17335c4bbdfSmrg points = (GLdouble *) pc; 1744642e01fSmrg#endif 17535c4bbdfSmrg glMap2d(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points); 1764642e01fSmrg} 1774642e01fSmrg 17835c4bbdfSmrgvoid 17935c4bbdfSmrg__glXDisp_DrawArrays(GLbyte * pc) 1804642e01fSmrg{ 18135c4bbdfSmrg __GLXdispatchDrawArraysHeader *hdr = (__GLXdispatchDrawArraysHeader *) pc; 1824642e01fSmrg __GLXdispatchDrawArraysComponentHeader *compHeader; 1834642e01fSmrg GLint numVertexes = hdr->numVertexes; 1844642e01fSmrg GLint numComponents = hdr->numComponents; 1854642e01fSmrg GLenum primType = hdr->primType; 1864642e01fSmrg GLint stride = 0; 1874642e01fSmrg int i; 1884642e01fSmrg 1894642e01fSmrg pc += sizeof(__GLXdispatchDrawArraysHeader); 19035c4bbdfSmrg compHeader = (__GLXdispatchDrawArraysComponentHeader *) pc; 1914642e01fSmrg 1924642e01fSmrg /* compute stride (same for all component arrays) */ 1934642e01fSmrg for (i = 0; i < numComponents; i++) { 19435c4bbdfSmrg GLenum datatype = compHeader[i].datatype; 19535c4bbdfSmrg GLint numVals = compHeader[i].numVals; 1964642e01fSmrg 19735c4bbdfSmrg stride += __GLX_PAD(numVals * __glXTypeSize(datatype)); 1984642e01fSmrg } 1994642e01fSmrg 2004642e01fSmrg pc += numComponents * sizeof(__GLXdispatchDrawArraysComponentHeader); 2014642e01fSmrg 2024642e01fSmrg /* set up component arrays */ 2034642e01fSmrg for (i = 0; i < numComponents; i++) { 20435c4bbdfSmrg GLenum datatype = compHeader[i].datatype; 20535c4bbdfSmrg GLint numVals = compHeader[i].numVals; 20635c4bbdfSmrg GLenum component = compHeader[i].component; 20735c4bbdfSmrg 20835c4bbdfSmrg switch (component) { 20935c4bbdfSmrg case GL_VERTEX_ARRAY: 21035c4bbdfSmrg glEnableClientState(GL_VERTEX_ARRAY); 21135c4bbdfSmrg glVertexPointer(numVals, datatype, stride, pc); 21235c4bbdfSmrg break; 21335c4bbdfSmrg case GL_NORMAL_ARRAY: 21435c4bbdfSmrg glEnableClientState(GL_NORMAL_ARRAY); 21535c4bbdfSmrg glNormalPointer(datatype, stride, pc); 21635c4bbdfSmrg break; 21735c4bbdfSmrg case GL_COLOR_ARRAY: 21835c4bbdfSmrg glEnableClientState(GL_COLOR_ARRAY); 21935c4bbdfSmrg glColorPointer(numVals, datatype, stride, pc); 22035c4bbdfSmrg break; 22135c4bbdfSmrg case GL_INDEX_ARRAY: 22235c4bbdfSmrg glEnableClientState(GL_INDEX_ARRAY); 22335c4bbdfSmrg glIndexPointer(datatype, stride, pc); 22435c4bbdfSmrg break; 22535c4bbdfSmrg case GL_TEXTURE_COORD_ARRAY: 22635c4bbdfSmrg glEnableClientState(GL_TEXTURE_COORD_ARRAY); 22735c4bbdfSmrg glTexCoordPointer(numVals, datatype, stride, pc); 22835c4bbdfSmrg break; 22935c4bbdfSmrg case GL_EDGE_FLAG_ARRAY: 23035c4bbdfSmrg glEnableClientState(GL_EDGE_FLAG_ARRAY); 23135c4bbdfSmrg glEdgeFlagPointer(stride, (const GLboolean *) pc); 23235c4bbdfSmrg break; 23335c4bbdfSmrg case GL_SECONDARY_COLOR_ARRAY: 23435c4bbdfSmrg { 23535c4bbdfSmrg PFNGLSECONDARYCOLORPOINTERPROC SecondaryColorPointerEXT = 23635c4bbdfSmrg __glGetProcAddress("glSecondaryColorPointerEXT"); 23735c4bbdfSmrg glEnableClientState(GL_SECONDARY_COLOR_ARRAY); 23835c4bbdfSmrg SecondaryColorPointerEXT(numVals, datatype, stride, pc); 23935c4bbdfSmrg break; 24035c4bbdfSmrg } 24135c4bbdfSmrg case GL_FOG_COORD_ARRAY: 24235c4bbdfSmrg { 24335c4bbdfSmrg PFNGLFOGCOORDPOINTERPROC FogCoordPointerEXT = 24435c4bbdfSmrg __glGetProcAddress("glFogCoordPointerEXT"); 24535c4bbdfSmrg glEnableClientState(GL_FOG_COORD_ARRAY); 24635c4bbdfSmrg FogCoordPointerEXT(datatype, stride, pc); 24735c4bbdfSmrg break; 24835c4bbdfSmrg } 24935c4bbdfSmrg default: 25035c4bbdfSmrg break; 25135c4bbdfSmrg } 25235c4bbdfSmrg 25335c4bbdfSmrg pc += __GLX_PAD(numVals * __glXTypeSize(datatype)); 2544642e01fSmrg } 2554642e01fSmrg 25635c4bbdfSmrg glDrawArrays(primType, 0, numVertexes); 2574642e01fSmrg 2584642e01fSmrg /* turn off anything we might have turned on */ 25935c4bbdfSmrg glDisableClientState(GL_VERTEX_ARRAY); 26035c4bbdfSmrg glDisableClientState(GL_NORMAL_ARRAY); 26135c4bbdfSmrg glDisableClientState(GL_COLOR_ARRAY); 26235c4bbdfSmrg glDisableClientState(GL_INDEX_ARRAY); 26335c4bbdfSmrg glDisableClientState(GL_TEXTURE_COORD_ARRAY); 26435c4bbdfSmrg glDisableClientState(GL_EDGE_FLAG_ARRAY); 26535c4bbdfSmrg glDisableClientState(GL_SECONDARY_COLOR_ARRAY); 26635c4bbdfSmrg glDisableClientState(GL_FOG_COORD_ARRAY); 2674642e01fSmrg} 268