render2.c revision 4642e01f
1/* 2 * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) 3 * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. 4 * 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: 11 * 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. 16 * 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 23 * SOFTWARE. 24 * 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. 29 */ 30 31/* #define NEED_REPLIES */ 32#ifdef HAVE_DIX_CONFIG_H 33#include <dix-config.h> 34#endif 35 36#include <glxserver.h> 37#include "unpack.h" 38#include "indirect_size.h" 39#include "indirect_dispatch.h" 40#include "glapitable.h" 41#include "glapi.h" 42#include "glthread.h" 43#include "dispatch.h" 44 45 46void __glXDisp_Map1f(GLbyte *pc) 47{ 48 GLint order, k; 49 GLfloat u1, u2, *points; 50 GLenum target; 51 52 target = *(GLenum *)(pc + 0); 53 order = *(GLint *)(pc + 12); 54 u1 = *(GLfloat *)(pc + 4); 55 u2 = *(GLfloat *)(pc + 8); 56 points = (GLfloat *)(pc + 16); 57 k = __glMap1f_size(target); 58 59 CALL_Map1f( GET_DISPATCH(), (target, u1, u2, k, order, points) ); 60} 61 62void __glXDisp_Map2f(GLbyte *pc) 63{ 64 GLint uorder, vorder, ustride, vstride, k; 65 GLfloat u1, u2, v1, v2, *points; 66 GLenum target; 67 68 target = *(GLenum *)(pc + 0); 69 uorder = *(GLint *)(pc + 12); 70 vorder = *(GLint *)(pc + 24); 71 u1 = *(GLfloat *)(pc + 4); 72 u2 = *(GLfloat *)(pc + 8); 73 v1 = *(GLfloat *)(pc + 16); 74 v2 = *(GLfloat *)(pc + 20); 75 points = (GLfloat *)(pc + 28); 76 77 k = __glMap2f_size(target); 78 ustride = vorder * k; 79 vstride = k; 80 81 CALL_Map2f( GET_DISPATCH(), (target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points) ); 82} 83 84void __glXDisp_Map1d(GLbyte *pc) 85{ 86 GLint order, k; 87#ifdef __GLX_ALIGN64 88 GLint compsize; 89#endif 90 GLenum target; 91 GLdouble u1, u2, *points; 92 93 target = *(GLenum*) (pc + 16); 94 order = *(GLint*) (pc + 20); 95 k = __glMap1d_size(target); 96 97#ifdef __GLX_ALIGN64 98 if (order < 0 || k < 0) { 99 compsize = 0; 100 } else { 101 compsize = order * k; 102 } 103#endif 104 105 __GLX_GET_DOUBLE(u1,pc); 106 __GLX_GET_DOUBLE(u2,pc+8); 107 pc += 24; 108 109#ifdef __GLX_ALIGN64 110 if (((unsigned long)pc) & 7) { 111 /* 112 ** Copy the doubles up 4 bytes, trashing the command but aligning 113 ** the data in the process 114 */ 115 __GLX_MEM_COPY(pc-4, pc, compsize*8); 116 points = (GLdouble*) (pc - 4); 117 } else { 118 points = (GLdouble*) pc; 119 } 120#else 121 points = (GLdouble*) pc; 122#endif 123 CALL_Map1d( GET_DISPATCH(), (target, u1, u2, k, order, points) ); 124} 125 126void __glXDisp_Map2d(GLbyte *pc) 127{ 128 GLdouble u1, u2, v1, v2, *points; 129 GLint uorder, vorder, ustride, vstride, k; 130#ifdef __GLX_ALIGN64 131 GLint compsize; 132#endif 133 GLenum target; 134 135 target = *(GLenum *)(pc + 32); 136 uorder = *(GLint *)(pc + 36); 137 vorder = *(GLint *)(pc + 40); 138 k = __glMap2d_size(target); 139 140#ifdef __GLX_ALIGN64 141 if (vorder < 0 || uorder < 0 || k < 0) { 142 compsize = 0; 143 } else { 144 compsize = uorder * vorder * k; 145 } 146#endif 147 148 __GLX_GET_DOUBLE(u1,pc); 149 __GLX_GET_DOUBLE(u2,pc+8); 150 __GLX_GET_DOUBLE(v1,pc+16); 151 __GLX_GET_DOUBLE(v2,pc+24); 152 pc += 44; 153 154 ustride = vorder * k; 155 vstride = k; 156 157#ifdef __GLX_ALIGN64 158 if (((unsigned long)pc) & 7) { 159 /* 160 ** Copy the doubles up 4 bytes, trashing the command but aligning 161 ** the data in the process 162 */ 163 __GLX_MEM_COPY(pc-4, pc, compsize*8); 164 points = (GLdouble*) (pc - 4); 165 } else { 166 points = (GLdouble*) pc; 167 } 168#else 169 points = (GLdouble*) pc; 170#endif 171 CALL_Map2d( GET_DISPATCH(), (target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points) ); 172} 173 174void __glXDisp_DrawArrays(GLbyte *pc) 175{ 176 __GLXdispatchDrawArraysHeader *hdr = (__GLXdispatchDrawArraysHeader *)pc; 177 __GLXdispatchDrawArraysComponentHeader *compHeader; 178 GLint numVertexes = hdr->numVertexes; 179 GLint numComponents = hdr->numComponents; 180 GLenum primType = hdr->primType; 181 GLint stride = 0; 182 int i; 183 184 pc += sizeof(__GLXdispatchDrawArraysHeader); 185 compHeader = (__GLXdispatchDrawArraysComponentHeader *)pc; 186 187 /* compute stride (same for all component arrays) */ 188 for (i = 0; i < numComponents; i++) { 189 GLenum datatype = compHeader[i].datatype; 190 GLint numVals = compHeader[i].numVals; 191 192 stride += __GLX_PAD(numVals * __glXTypeSize(datatype)); 193 } 194 195 pc += numComponents * sizeof(__GLXdispatchDrawArraysComponentHeader); 196 197 /* set up component arrays */ 198 for (i = 0; i < numComponents; i++) { 199 GLenum datatype = compHeader[i].datatype; 200 GLint numVals = compHeader[i].numVals; 201 GLenum component = compHeader[i].component; 202 203 switch (component) { 204 case GL_VERTEX_ARRAY: 205 CALL_EnableClientState( GET_DISPATCH(), (GL_VERTEX_ARRAY) ); 206 CALL_VertexPointer( GET_DISPATCH(), (numVals, datatype, stride, pc) ); 207 break; 208 case GL_NORMAL_ARRAY: 209 CALL_EnableClientState( GET_DISPATCH(), (GL_NORMAL_ARRAY) ); 210 CALL_NormalPointer( GET_DISPATCH(), (datatype, stride, pc) ); 211 break; 212 case GL_COLOR_ARRAY: 213 CALL_EnableClientState( GET_DISPATCH(), (GL_COLOR_ARRAY) ); 214 CALL_ColorPointer( GET_DISPATCH(), (numVals, datatype, stride, pc) ); 215 break; 216 case GL_INDEX_ARRAY: 217 CALL_EnableClientState( GET_DISPATCH(), (GL_INDEX_ARRAY) ); 218 CALL_IndexPointer( GET_DISPATCH(), (datatype, stride, pc) ); 219 break; 220 case GL_TEXTURE_COORD_ARRAY: 221 CALL_EnableClientState( GET_DISPATCH(), (GL_TEXTURE_COORD_ARRAY) ); 222 CALL_TexCoordPointer( GET_DISPATCH(), (numVals, datatype, stride, pc) ); 223 break; 224 case GL_EDGE_FLAG_ARRAY: 225 CALL_EnableClientState( GET_DISPATCH(), (GL_EDGE_FLAG_ARRAY) ); 226 CALL_EdgeFlagPointer( GET_DISPATCH(), (stride, (const GLboolean *)pc) ); 227 break; 228 case GL_SECONDARY_COLOR_ARRAY: 229 CALL_EnableClientState( GET_DISPATCH(), (GL_SECONDARY_COLOR_ARRAY) ); 230 CALL_SecondaryColorPointerEXT( GET_DISPATCH(), (numVals, datatype, stride, pc) ); 231 break; 232 case GL_FOG_COORD_ARRAY: 233 CALL_EnableClientState( GET_DISPATCH(), (GL_FOG_COORD_ARRAY) ); 234 CALL_FogCoordPointerEXT( GET_DISPATCH(), (datatype, stride, pc) ); 235 break; 236 default: 237 break; 238 } 239 240 pc += __GLX_PAD(numVals * __glXTypeSize(datatype)); 241 } 242 243 CALL_DrawArrays( GET_DISPATCH(), (primType, 0, numVertexes) ); 244 245 /* turn off anything we might have turned on */ 246 CALL_DisableClientState( GET_DISPATCH(), (GL_VERTEX_ARRAY) ); 247 CALL_DisableClientState( GET_DISPATCH(), (GL_NORMAL_ARRAY) ); 248 CALL_DisableClientState( GET_DISPATCH(), (GL_COLOR_ARRAY) ); 249 CALL_DisableClientState( GET_DISPATCH(), (GL_INDEX_ARRAY) ); 250 CALL_DisableClientState( GET_DISPATCH(), (GL_TEXTURE_COORD_ARRAY) ); 251 CALL_DisableClientState( GET_DISPATCH(), (GL_EDGE_FLAG_ARRAY) ); 252 CALL_DisableClientState( GET_DISPATCH(), (GL_SECONDARY_COLOR_ARRAY) ); 253 CALL_DisableClientState( GET_DISPATCH(), (GL_FOG_COORD_ARRAY) ); 254} 255 256void __glXDisp_DrawArraysEXT(GLbyte *pc) 257{ 258 __glXDisp_DrawArrays(pc); 259} 260