1cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#ifndef __GLX_packrender_h__
2cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#define __GLX_packrender_h__
3cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
4cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/*
5dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
6dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
7dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson *
8dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * Permission is hereby granted, free of charge, to any person obtaining a
9dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * copy of this software and associated documentation files (the "Software"),
10dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * to deal in the Software without restriction, including without limitation
11dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * and/or sell copies of the Software, and to permit persons to whom the
13dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * Software is furnished to do so, subject to the following conditions:
14dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson *
15dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * The above copyright notice including the dates of first publication and
16dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * either this permission notice or a reference to
17dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * http://oss.sgi.com/projects/FreeB/
18dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * shall be included in all copies or substantial portions of the Software.
19dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson *
20dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
24dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
25dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * SOFTWARE.
27dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson *
28dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * Except as contained in this notice, the name of Silicon Graphics, Inc.
29dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * shall not be used in advertising or otherwise to promote the sale, use or
30dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * other dealings in this Software without prior written authorization from
31dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson * Silicon Graphics, Inc.
32dc8058c3370588bfcad49fadace1691da47d58cdAdam Jackson */
33cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
34cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#include "glxclient.h"
35cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
36cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/*
37cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** The macros in this header convert the client machine's native data types to
38cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** wire protocol data types.  The header is part of the porting layer of the
39cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** client library, and it is intended that hardware vendors will rewrite this
40cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** header to suit their own machines.
41cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson*/
42cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
43cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/*
44cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** Pad a count of bytes to the nearest multiple of 4.  The X protocol
45cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** transfers data in 4 byte quantities, so this macro is used to
46cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** insure the right amount of data being sent.
47cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson*/
48cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#define __GLX_PAD(a) (((a)+3) & ~3)
49cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
50cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/*
510cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf** Network size parameters
520cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf*/
53cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#define sz_double 8
54cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
55cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/* Setup for all commands */
560cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf#define __GLX_DECLARE_VARIABLES()               \
57c356f5867f2c1fad7155df538b9affa8dbdcf869Kristian Høgsberg   struct glx_context *gc;                            \
580cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   GLubyte *pc, *pixelHeaderPC;                 \
590cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   GLuint compsize, cmdlen
600cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf
610cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf#define __GLX_LOAD_VARIABLES()     \
620cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   gc = __glXGetCurrentContext();  \
630cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   pc = gc->pc;                    \
640cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   /* Muffle compilers */                  \
650cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   cmdlen = 0;         (void)cmdlen;          \
660cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   compsize = 0;       (void)compsize;        \
670cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   pixelHeaderPC = 0;  (void)pixelHeaderPC
68cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
69cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/*
70cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** Variable sized command support macro.  This macro is used by calls
71cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** that are potentially larger than __GLX_SMALL_RENDER_CMD_SIZE.
72cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** Because of their size, they may not automatically fit in the buffer.
73cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** If the buffer can't hold the command then it is flushed so that
74cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** the command will fit in the next buffer.
75cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson*/
760cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf#define __GLX_BEGIN_VARIABLE(opcode,size)       \
770cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   if (pc + (size) > gc->bufEnd) {              \
780cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf      pc = __glXFlushRenderBuffer(gc, pc);      \
790cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   }                                            \
800cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   __GLX_PUT_SHORT(0,size);                     \
810cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   __GLX_PUT_SHORT(2,opcode)
820cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf
830cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf#define __GLX_BEGIN_VARIABLE_LARGE(opcode,size) \
840cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   pc = __glXFlushRenderBuffer(gc, pc);         \
850cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   __GLX_PUT_LONG(0,size);                      \
860cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   __GLX_PUT_LONG(4,opcode)
870cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf
880cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf#define __GLX_BEGIN_VARIABLE_WITH_PIXEL(opcode,size)  \
890cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   if (pc + (size) > gc->bufEnd) {                    \
900cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf      pc = __glXFlushRenderBuffer(gc, pc);            \
910cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   }                                                  \
920cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   __GLX_PUT_SHORT(0,size);                           \
930cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   __GLX_PUT_SHORT(2,opcode);                         \
940cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   pc += __GLX_RENDER_HDR_SIZE;                       \
950cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   pixelHeaderPC = pc;                                \
960cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   pc += __GLX_PIXEL_HDR_SIZE
970cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf
980cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf#define __GLX_BEGIN_VARIABLE_LARGE_WITH_PIXEL(opcode,size)  \
990cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   pc = __glXFlushRenderBuffer(gc, pc);                     \
1000cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   __GLX_PUT_LONG(0,size);                                  \
1010cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   __GLX_PUT_LONG(4,opcode);                                \
1020cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   pc += __GLX_RENDER_LARGE_HDR_SIZE;                       \
1030cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   pixelHeaderPC = pc;                                      \
1040cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   pc += __GLX_PIXEL_HDR_SIZE
1050cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf
1060cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf#define __GLX_BEGIN_VARIABLE_WITH_PIXEL_3D(opcode,size)  \
1070cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   if (pc + (size) > gc->bufEnd) {                       \
1080cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf      pc = __glXFlushRenderBuffer(gc, pc);               \
1090cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   }                                                     \
1100cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   __GLX_PUT_SHORT(0,size);                              \
1110cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   __GLX_PUT_SHORT(2,opcode);                            \
1120cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   pc += __GLX_RENDER_HDR_SIZE;                          \
1130cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   pixelHeaderPC = pc;                                   \
1140cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   pc += __GLX_PIXEL_3D_HDR_SIZE
1150cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf
1160cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf#define __GLX_BEGIN_VARIABLE_LARGE_WITH_PIXEL_3D(opcode,size)  \
1170cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   pc = __glXFlushRenderBuffer(gc, pc);                        \
1180cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   __GLX_PUT_LONG(0,size);                                     \
1190cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   __GLX_PUT_LONG(4,opcode);                                   \
1200cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   pc += __GLX_RENDER_LARGE_HDR_SIZE;                          \
1210cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   pixelHeaderPC = pc;                                         \
1220cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   pc += __GLX_PIXEL_3D_HDR_SIZE
123cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
124cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/*
125cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** Fixed size command support macro.  This macro is used by calls that
126cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** are never larger than __GLX_SMALL_RENDER_CMD_SIZE.  Because they
127cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** always fit in the buffer, and because the buffer promises to
128cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** maintain enough room for them, we don't need to check for space
129cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** before doing the storage work.
130cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson*/
131cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#define __GLX_BEGIN(opcode,size) \
1320cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   __GLX_PUT_SHORT(0,size);      \
1330cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   __GLX_PUT_SHORT(2,opcode)
134cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
135cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/*
136cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** Finish a rendering command by advancing the pc.  If the pc is now past
137cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** the limit pointer then there is no longer room for a
138cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** __GLX_SMALL_RENDER_CMD_SIZE sized command, which will break the
139cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** assumptions present in the __GLX_BEGIN macro.  In this case the
140cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** rendering buffer is flushed out into the X protocol stream (which may
141cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** or may not do I/O).
142cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson*/
1430cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf#define __GLX_END(size)           \
1440cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   pc += size;                       \
1450cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   if (pc > gc->limit) {                  \
1460cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf      (void) __glXFlushRenderBuffer(gc, pc);    \
1470cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   } else {                                     \
1480cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf      gc->pc = pc;                              \
1490cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   }
150cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
151cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/* Array copy macros */
1520cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf#define __GLX_MEM_COPY(dest,src,bytes)          \
1530cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   if (src && dest)                             \
1540cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf      memcpy(dest, src, bytes)
155cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
156cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/* Single item copy macros */
1570cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf#define __GLX_PUT_CHAR(offset,a)                \
1580cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   *((INT8 *) (pc + offset)) = a
159cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
160cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#ifndef _CRAY
1610cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf#define __GLX_PUT_SHORT(offset,a)               \
1620cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   *((INT16 *) (pc + offset)) = a
163cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
1640cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf#define __GLX_PUT_LONG(offset,a)                \
1650cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   *((INT32 *) (pc + offset)) = a
166cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
1670cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf#define __GLX_PUT_FLOAT(offset,a)               \
1680cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   *((FLOAT32 *) (pc + offset)) = a
169cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
170cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#else
1710cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf#define __GLX_PUT_SHORT(offset,a)               \
1720cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   { GLubyte *cp = (pc+offset);                 \
1730cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf      int shift = (64-16) - ((int)(cp) >> (64-6));                      \
1740cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf      *(int *)cp = (*(int *)cp & ~(0xffff << shift)) | ((a & 0xffff) << shift); }
175cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
1760cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf#define __GLX_PUT_LONG(offset,a)                \
1770cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   { GLubyte *cp = (pc+offset);                 \
1780cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf      int shift = (64-32) - ((int)(cp) >> (64-6));                      \
1790cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf      *(int *)cp = (*(int *)cp & ~(0xffffffff << shift)) | ((a & 0xffffffff) << shift); }
180cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
1810cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf#define __GLX_PUT_FLOAT(offset,a)               \
1820cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   gl_put_float((pc + offset),a)
183cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
1840cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf#define __GLX_PUT_DOUBLE(offset,a)              \
1850cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   gl_put_double(pc + offset, a)
186cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
1870cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristófextern void gl_put_float( /*GLubyte *, struct cray_single */ );
1880cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristófextern void gl_put_double( /*GLubyte *, struct cray_double */ );
189cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#endif
190cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
191cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#ifndef _CRAY
192cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
193cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#ifdef __GLX_ALIGN64
194cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/*
195cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** This can certainly be done better for a particular machine
196cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson** architecture!
197cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson*/
1980cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf#define __GLX_PUT_DOUBLE(offset,a)              \
1990cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   __GLX_MEM_COPY(pc + offset, &a, 8)
200cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#else
2010cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf#define __GLX_PUT_DOUBLE(offset,a)              \
2020cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   *((FLOAT64 *) (pc + offset)) = a
203cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#endif
204cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
205cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#endif
206cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
2070cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf#define __GLX_PUT_CHAR_ARRAY(offset,a,alen)                 \
2080cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   __GLX_MEM_COPY(pc + offset, a, alen * __GLX_SIZE_INT8)
209cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
210cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#ifndef _CRAY
2110cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf#define __GLX_PUT_SHORT_ARRAY(offset,a,alen)                \
2120cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   __GLX_MEM_COPY(pc + offset, a, alen * __GLX_SIZE_INT16)
213cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
2140cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf#define __GLX_PUT_LONG_ARRAY(offset,a,alen)                 \
2150cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   __GLX_MEM_COPY(pc + offset, a, alen * __GLX_SIZE_INT32)
216cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
2170cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf#define __GLX_PUT_FLOAT_ARRAY(offset,a,alen)                   \
2180cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   __GLX_MEM_COPY(pc + offset, a, alen * __GLX_SIZE_FLOAT32)
219cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
2200cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf#define __GLX_PUT_DOUBLE_ARRAY(offset,a,alen)                  \
2210cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   __GLX_MEM_COPY(pc + offset, a, alen * __GLX_SIZE_FLOAT64)
222cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
223cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#else
2240cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf#define __GLX_PUT_SHORT_ARRAY(offset,a,alen)                            \
2250cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   gl_put_short_array((GLubyte *)(pc + offset), a, alen * __GLX_SIZE_INT16)
226cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
2270cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf#define __GLX_PUT_LONG_ARRAY(offset,a,alen)                             \
2280cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   gl_put_long_array((GLubyte *)(pc + offset), (long *)a, alen * __GLX_SIZE_INT32)
229cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
2300cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf#define __GLX_PUT_FLOAT_ARRAY(offset,a,alen)                            \
2310cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   gl_put_float_array((GLubyte *)(pc + offset), (float *)a, alen * __GLX_SIZE_FLOAT32)
232cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
2330cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf#define __GLX_PUT_DOUBLE_ARRAY(offset,a,alen)                           \
2340cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristóf   gl_put_double_array((GLubyte *)(pc + offset), (double *)a, alen * __GLX_SIZE_FLOAT64)
235cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
2360cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristófextern gl_put_short_array(GLubyte *, short *, int);
2370cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristófextern gl_put_long_array(GLubyte *, long *, int);
2380cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristófextern gl_put_float_array(GLubyte *, float *, int);
2390cff716e70e2194f4946f4faea5b24e97104f975RALOVICH, Kristófextern gl_put_double_array(GLubyte *, double *, int);
240cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
241cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#endif /* _CRAY */
242cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson
243cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#endif /* !__GLX_packrender_h__ */
244