1 /* $XFree86: xc/lib/GL/glx/renderpix.c,v 1.5 2003/09/28 20:15:04 alanh Exp $ */
3 ** License Applicability. Except to the extent portions of this file are
4 ** made subject to an alternative license as permitted in the SGI Free
5 ** Software License B, Version 1.1 (the "License"), the contents of this
6 ** file are subject only to the provisions of the License. You may not use
7 ** this file except in compliance with the License. You may obtain a copy
8 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
9 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
11 ** http://oss.sgi.com/projects/FreeB
13 ** Note that, as provided in the License, the Software is distributed on an
14 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
15 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
16 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
17 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
19 ** Original Code. The Original Code is: OpenGL Sample Implementation,
20 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
21 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
22 ** Copyright in any portions created by third parties is as indicated
23 ** elsewhere herein. All Rights Reserved.
25 ** Additional Notice Provisions: The application programming interfaces
26 ** established by SGI in conjunction with the Original Code are The
27 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
28 ** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
29 ** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
30 ** Window System(R) (Version 1.3), released October 19, 1998. This software
31 ** was created using the OpenGL(R) version 1.2.1 Sample Implementation
32 ** published by SGI, but has not been independently verified as being
33 ** compliant with the OpenGL(R) version 1.2.1 Specification.
37 #include "packrender.h"
40 ** This file contains routines that deal with unpacking data from client
41 ** memory using the pixel store unpack modes and then shipping it to
42 ** the server. For all of these routines (except glPolygonStipple) there
43 ** are two forms of the transport - small and large. Small commands are
44 ** the commands that fit into the "rendering" transport buffer. Large
45 ** commands are sent to the server in chunks by __glXSendLargeCommand.
47 ** All of the commands send over a pixel header (see glxproto.h) which
48 ** describes the pixel store modes that the server must use to properly
49 ** handle the data. Any pixel store modes not done by the __glFillImage
50 ** routine are passed on to the server.
54 ** Send a large image to the server. If necessary, a buffer is allocated
55 ** to hold the unpacked data that is copied from the clients memory.
57 static void SendLargeImage(__GLXcontext
*gc
, GLint compsize
, GLint dim
,
58 GLint width
, GLint height
, GLint depth
,
59 GLenum format
, GLenum type
, const GLvoid
*src
,
60 GLubyte
*pc
, GLubyte
*modes
)
62 if (!gc
->fastImageUnpack
) {
63 /* Allocate a temporary holding buffer */
64 GLubyte
*buf
= (GLubyte
*) Xmalloc(compsize
);
66 __glXSetError(gc
, GL_OUT_OF_MEMORY
);
70 /* Apply pixel store unpack modes to copy data into buf */
71 (*gc
->fillImage
)(gc
, dim
, width
, height
, depth
, format
, type
, src
, buf
,
74 /* Send large command */
75 __glXSendLargeCommand(gc
, gc
->pc
, pc
- gc
->pc
, buf
, compsize
);
80 /* Just send the data straight as is */
81 __glXSendLargeCommand(gc
, gc
->pc
, pc
- gc
->pc
, pc
, compsize
);
86 ** Send a large null image to the server. To be backwards compatible,
87 ** data must be sent to the server even when the application has passed
88 ** a null pointer into glTexImage1D, glTexImage2D or glTexImage3D.
90 static void SendLargeNULLImage(__GLXcontext
*gc
, GLint compsize
,
91 GLint width
, GLint height
, GLint depth
,
92 GLenum format
, GLenum type
, const GLvoid
*src
,
93 GLubyte
*pc
, GLubyte
*modes
)
95 GLubyte
*buf
= (GLubyte
*) Xmalloc(compsize
);
97 /* Allocate a temporary holding buffer */
99 __glXSetError(gc
, GL_OUT_OF_MEMORY
);
103 /* Send large command */
104 __glXSendLargeCommand(gc
, gc
->pc
, pc
- gc
->pc
, buf
, compsize
);
110 /************************************************************************/
112 void __indirect_glPolygonStipple(const GLubyte
*mask
)
114 __GLX_DECLARE_VARIABLES();
116 __GLX_LOAD_VARIABLES();
117 compsize
= __glImageSize(32, 32, 1, GL_COLOR_INDEX
, GL_BITMAP
);
118 cmdlen
= __GLX_PAD(__GLX_POLYGONSTIPPLE_CMD_HDR_SIZE
+ compsize
);
119 if (!gc
->currentDpy
) return;
121 __GLX_BEGIN(X_GLrop_PolygonStipple
,cmdlen
);
122 pc
+= __GLX_RENDER_HDR_SIZE
;
124 pc
+= __GLX_PIXEL_HDR_SIZE
;
125 (*gc
->fillImage
)(gc
, 2, 32, 32, 1, GL_COLOR_INDEX
, GL_BITMAP
,
126 mask
, pc
, pixelHeaderPC
);
127 __GLX_END(__GLX_PAD(compsize
));
130 void __indirect_glBitmap(GLsizei width
, GLsizei height
, GLfloat xorig
, GLfloat yorig
,
131 GLfloat xmove
, GLfloat ymove
, const GLubyte
*bitmap
)
133 __GLX_DECLARE_VARIABLES();
135 __GLX_LOAD_VARIABLES();
136 compsize
= __glImageSize(width
, height
, 1, GL_COLOR_INDEX
, GL_BITMAP
);
137 cmdlen
= __GLX_PAD(__GLX_BITMAP_CMD_HDR_SIZE
+ compsize
);
138 if (!gc
->currentDpy
) return;
140 if (cmdlen
<= gc
->maxSmallRenderCommandSize
) {
141 /* Use GLXRender protocol to send small command */
142 __GLX_BEGIN_VARIABLE_WITH_PIXEL(X_GLrop_Bitmap
,cmdlen
);
143 __GLX_PUT_LONG(0,width
);
144 __GLX_PUT_LONG(4,height
);
145 __GLX_PUT_FLOAT(8,xorig
);
146 __GLX_PUT_FLOAT(12,yorig
);
147 __GLX_PUT_FLOAT(16,xmove
);
148 __GLX_PUT_FLOAT(20,ymove
);
149 pc
+= __GLX_BITMAP_HDR_SIZE
;
151 (*gc
->fillImage
)(gc
, 2, width
, height
, 1, GL_COLOR_INDEX
,
152 GL_BITMAP
, bitmap
, pc
, pixelHeaderPC
);
154 /* Setup default store modes */
155 GLubyte
*pc
= pixelHeaderPC
;
156 __GLX_PUT_CHAR(0,GL_FALSE
);
157 __GLX_PUT_CHAR(1,GL_FALSE
);
162 __GLX_PUT_LONG(12,0);
163 __GLX_PUT_LONG(16,1);
165 __GLX_END(__GLX_PAD(compsize
));
167 /* Use GLXRenderLarge protocol to send command */
168 __GLX_BEGIN_VARIABLE_LARGE_WITH_PIXEL(X_GLrop_Bitmap
,cmdlen
+4);
169 __GLX_PUT_LONG(0,width
);
170 __GLX_PUT_LONG(4,height
);
171 __GLX_PUT_FLOAT(8,xorig
);
172 __GLX_PUT_FLOAT(12,yorig
);
173 __GLX_PUT_FLOAT(16,xmove
);
174 __GLX_PUT_FLOAT(20,ymove
);
175 pc
+= __GLX_BITMAP_HDR_SIZE
;
176 SendLargeImage(gc
, compsize
, 2, width
, height
, 1, GL_COLOR_INDEX
,
177 GL_BITMAP
, bitmap
, pc
, pixelHeaderPC
);
181 void __indirect_glTexImage1D(GLenum target
, GLint level
, GLint components
,
182 GLsizei width
, GLint border
, GLenum format
, GLenum type
,
185 __GLX_DECLARE_VARIABLES();
187 __GLX_LOAD_VARIABLES();
188 if (target
== GL_PROXY_TEXTURE_1D
) {
191 compsize
= __glImageSize(width
, 1, 1, format
, type
);
193 cmdlen
= __GLX_PAD(__GLX_TEXIMAGE_CMD_HDR_SIZE
+ compsize
);
194 if (!gc
->currentDpy
) return;
196 if (cmdlen
<= gc
->maxSmallRenderCommandSize
) {
197 /* Use GLXRender protocol to send small command */
198 __GLX_BEGIN_VARIABLE_WITH_PIXEL(X_GLrop_TexImage1D
,cmdlen
);
199 __GLX_PUT_LONG(0,target
);
200 __GLX_PUT_LONG(4,level
);
201 __GLX_PUT_LONG(8,components
);
202 __GLX_PUT_LONG(12,width
);
203 __GLX_PUT_LONG(20,border
);
204 __GLX_PUT_LONG(24,format
);
205 __GLX_PUT_LONG(28,type
);
206 pc
+= __GLX_TEXIMAGE_HDR_SIZE
;
207 if (compsize
> 0 && image
!= NULL
) {
208 (*gc
->fillImage
)(gc
, 1, width
, 1, 1, format
, type
,
209 image
, pc
, pixelHeaderPC
);
211 /* Setup default store modes */
212 GLubyte
*pc
= pixelHeaderPC
;
213 __GLX_PUT_CHAR(0,GL_FALSE
);
214 __GLX_PUT_CHAR(1,GL_FALSE
);
219 __GLX_PUT_LONG(12,0);
220 __GLX_PUT_LONG(16,1);
222 __GLX_END(__GLX_PAD(compsize
));
224 /* Use GLXRenderLarge protocol to send command */
225 __GLX_BEGIN_VARIABLE_LARGE_WITH_PIXEL(X_GLrop_TexImage1D
,cmdlen
+4);
226 __GLX_PUT_LONG(0,target
);
227 __GLX_PUT_LONG(4,level
);
228 __GLX_PUT_LONG(8,components
);
229 __GLX_PUT_LONG(12,width
);
230 __GLX_PUT_LONG(16,1);
231 __GLX_PUT_LONG(20,border
);
232 __GLX_PUT_LONG(24,format
);
233 __GLX_PUT_LONG(28,type
);
234 pc
+= __GLX_TEXIMAGE_HDR_SIZE
;
236 SendLargeImage(gc
, compsize
, 1, width
, 1, 1, format
,
237 type
, image
, pc
, pixelHeaderPC
);
239 /* Setup default store modes */
241 GLubyte
*pc
= pixelHeaderPC
;
242 __GLX_PUT_CHAR(0,GL_FALSE
);
243 __GLX_PUT_CHAR(1,GL_FALSE
);
248 __GLX_PUT_LONG(12,0);
249 __GLX_PUT_LONG(16,1);
251 SendLargeNULLImage(gc
, compsize
, width
, 1, 1, format
,
252 type
, image
, pc
, pixelHeaderPC
);
257 void __indirect_glTexImage2D(GLenum target
, GLint level
, GLint components
,
258 GLsizei width
, GLsizei height
, GLint border
, GLenum format
,
259 GLenum type
, const GLvoid
*image
)
261 __GLX_DECLARE_VARIABLES();
263 __GLX_LOAD_VARIABLES();
264 if (target
== GL_PROXY_TEXTURE_2D
||
265 target
== GL_PROXY_TEXTURE_CUBE_MAP_ARB
) {
268 compsize
= __glImageSize(width
, height
, 1, format
, type
);
270 cmdlen
= __GLX_PAD(__GLX_TEXIMAGE_CMD_HDR_SIZE
+ compsize
);
271 if (!gc
->currentDpy
) return;
273 if (cmdlen
<= gc
->maxSmallRenderCommandSize
) {
274 /* Use GLXRender protocol to send small command */
275 __GLX_BEGIN_VARIABLE_WITH_PIXEL(X_GLrop_TexImage2D
,cmdlen
);
276 __GLX_PUT_LONG(0,target
);
277 __GLX_PUT_LONG(4,level
);
278 __GLX_PUT_LONG(8,components
);
279 __GLX_PUT_LONG(12,width
);
280 __GLX_PUT_LONG(16,height
);
281 __GLX_PUT_LONG(20,border
);
282 __GLX_PUT_LONG(24,format
);
283 __GLX_PUT_LONG(28,type
);
284 pc
+= __GLX_TEXIMAGE_HDR_SIZE
;
285 if (compsize
> 0 && image
!= NULL
) {
286 (*gc
->fillImage
)(gc
, 2, width
, height
, 1, format
, type
,
287 image
, pc
, pixelHeaderPC
);
289 /* Setup default store modes */
290 GLubyte
*pc
= pixelHeaderPC
;
291 __GLX_PUT_CHAR(0,GL_FALSE
);
292 __GLX_PUT_CHAR(1,GL_FALSE
);
297 __GLX_PUT_LONG(12,0);
298 __GLX_PUT_LONG(16,1);
300 __GLX_END(__GLX_PAD(compsize
));
302 /* Use GLXRenderLarge protocol to send command */
303 __GLX_BEGIN_VARIABLE_LARGE_WITH_PIXEL(X_GLrop_TexImage2D
,cmdlen
+4);
304 __GLX_PUT_LONG(0,target
);
305 __GLX_PUT_LONG(4,level
);
306 __GLX_PUT_LONG(8,components
);
307 __GLX_PUT_LONG(12,width
);
308 __GLX_PUT_LONG(16,height
);
309 __GLX_PUT_LONG(20,border
);
310 __GLX_PUT_LONG(24,format
);
311 __GLX_PUT_LONG(28,type
);
312 pc
+= __GLX_TEXIMAGE_HDR_SIZE
;
314 SendLargeImage(gc
, compsize
, 2, width
, height
, 1, format
,
315 type
, image
, pc
, pixelHeaderPC
);
317 /* Setup default store modes */
319 GLubyte
*pc
= pixelHeaderPC
;
320 __GLX_PUT_CHAR(0,GL_FALSE
);
321 __GLX_PUT_CHAR(1,GL_FALSE
);
326 __GLX_PUT_LONG(12,0);
327 __GLX_PUT_LONG(16,1);
329 SendLargeNULLImage(gc
, compsize
, width
, height
, 1, format
,
330 type
, image
, pc
, pixelHeaderPC
);
335 void __indirect_glDrawPixels(GLsizei width
, GLsizei height
, GLenum format
, GLenum type
,
338 __GLX_DECLARE_VARIABLES();
340 __GLX_LOAD_VARIABLES();
341 compsize
= __glImageSize(width
, height
, 1, format
, type
);
342 cmdlen
= __GLX_PAD(__GLX_DRAWPIXELS_CMD_HDR_SIZE
+ compsize
);
343 if (!gc
->currentDpy
) return;
345 if (cmdlen
<= gc
->maxSmallRenderCommandSize
) {
346 /* Use GLXRender protocol to send small command */
347 __GLX_BEGIN_VARIABLE_WITH_PIXEL(X_GLrop_DrawPixels
,cmdlen
);
348 __GLX_PUT_LONG(0,width
);
349 __GLX_PUT_LONG(4,height
);
350 __GLX_PUT_LONG(8,format
);
351 __GLX_PUT_LONG(12,type
);
352 pc
+= __GLX_DRAWPIXELS_HDR_SIZE
;
354 (*gc
->fillImage
)(gc
, 2, width
, height
, 1, format
, type
,
355 image
, pc
, pixelHeaderPC
);
357 /* Setup default store modes */
358 GLubyte
*pc
= pixelHeaderPC
;
359 __GLX_PUT_CHAR(0,GL_FALSE
);
360 __GLX_PUT_CHAR(1,GL_FALSE
);
365 __GLX_PUT_LONG(12,0);
366 __GLX_PUT_LONG(16,1);
368 __GLX_END(__GLX_PAD(compsize
));
370 /* Use GLXRenderLarge protocol to send command */
371 __GLX_BEGIN_VARIABLE_LARGE_WITH_PIXEL(X_GLrop_DrawPixels
,cmdlen
+4);
372 __GLX_PUT_LONG(0,width
);
373 __GLX_PUT_LONG(4,height
);
374 __GLX_PUT_LONG(8,format
);
375 __GLX_PUT_LONG(12,type
);
376 pc
+= __GLX_DRAWPIXELS_HDR_SIZE
;
377 SendLargeImage(gc
, compsize
, 2, width
, height
, 1, format
,
378 type
, image
, pc
, pixelHeaderPC
);
382 static void __glx_TexSubImage1D2D(GLshort opcode
, GLenum target
, GLint level
,
383 GLint xoffset
, GLint yoffset
, GLsizei width
,
384 GLsizei height
, GLenum format
, GLenum type
,
385 const GLvoid
*image
, GLint dim
)
387 __GLX_DECLARE_VARIABLES();
389 __GLX_LOAD_VARIABLES();
393 compsize
= __glImageSize(width
, height
, 1, format
, type
);
396 cmdlen
= __GLX_PAD(__GLX_TEXSUBIMAGE_CMD_HDR_SIZE
+ compsize
);
397 if (!gc
->currentDpy
) return;
399 if (cmdlen
<= gc
->maxSmallRenderCommandSize
) {
400 /* Use GLXRender protocol to send small command */
401 __GLX_BEGIN_VARIABLE_WITH_PIXEL(opcode
, cmdlen
);
402 __GLX_PUT_LONG(0,target
);
403 __GLX_PUT_LONG(4,level
);
404 __GLX_PUT_LONG(8,xoffset
);
405 __GLX_PUT_LONG(12,yoffset
);
406 __GLX_PUT_LONG(16,width
);
407 __GLX_PUT_LONG(20,height
);
408 __GLX_PUT_LONG(24,format
);
409 __GLX_PUT_LONG(28,type
);
411 __GLX_PUT_LONG(32,GL_TRUE
);
413 __GLX_PUT_LONG(32,GL_FALSE
);
415 pc
+= __GLX_TEXSUBIMAGE_HDR_SIZE
;
417 (*gc
->fillImage
)(gc
, dim
, width
, height
, 1, format
, type
, image
,
420 /* Setup default store modes */
421 GLubyte
*pc
= pixelHeaderPC
;
422 __GLX_PUT_CHAR(0,GL_FALSE
);
423 __GLX_PUT_CHAR(1,GL_FALSE
);
428 __GLX_PUT_LONG(12,0);
429 __GLX_PUT_LONG(16,1);
431 __GLX_END(__GLX_PAD(compsize
));
433 /* Use GLXRenderLarge protocol to send command */
434 __GLX_BEGIN_VARIABLE_LARGE_WITH_PIXEL(opcode
,cmdlen
+4);
435 __GLX_PUT_LONG(0,target
);
436 __GLX_PUT_LONG(4,level
);
437 __GLX_PUT_LONG(8,xoffset
);
438 __GLX_PUT_LONG(12,yoffset
);
439 __GLX_PUT_LONG(16,width
);
440 __GLX_PUT_LONG(20,height
);
441 __GLX_PUT_LONG(24,format
);
442 __GLX_PUT_LONG(28,type
);
444 __GLX_PUT_LONG(32,GL_TRUE
);
446 __GLX_PUT_LONG(32,GL_FALSE
);
448 pc
+= __GLX_TEXSUBIMAGE_HDR_SIZE
;
449 SendLargeImage(gc
, compsize
, dim
, width
, height
, 1,
450 format
, type
, image
, pc
, pixelHeaderPC
);
454 void __indirect_glTexSubImage1D(GLenum target
, GLint level
, GLint xoffset
,
455 GLsizei width
, GLenum format
, GLenum type
,
458 __glx_TexSubImage1D2D(X_GLrop_TexSubImage1D
, target
, level
, xoffset
,
459 0, width
, 1, format
, type
, image
, 1);
462 void __indirect_glTexSubImage2D(GLenum target
, GLint level
, GLint xoffset
,
463 GLint yoffset
, GLsizei width
, GLsizei height
,
464 GLenum format
, GLenum type
, const GLvoid
*image
)
466 __glx_TexSubImage1D2D(X_GLrop_TexSubImage2D
, target
, level
, xoffset
,
467 yoffset
, width
, height
, format
, type
, image
, 2);
470 void __indirect_glColorTable(GLenum target
, GLenum internalformat
, GLsizei width
,
471 GLenum format
, GLenum type
, const GLvoid
*table
)
473 __GLX_DECLARE_VARIABLES();
475 __GLX_LOAD_VARIABLES();
477 case GL_PROXY_TEXTURE_1D
:
478 case GL_PROXY_TEXTURE_2D
:
479 case GL_PROXY_TEXTURE_3D
:
480 case GL_PROXY_COLOR_TABLE
:
481 case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE
:
482 case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE
:
483 case GL_PROXY_TEXTURE_CUBE_MAP_ARB
:
487 compsize
= __glImageSize(width
, 1, 1, format
, type
);
490 cmdlen
= __GLX_PAD(__GLX_COLOR_TABLE_CMD_HDR_SIZE
+ compsize
);
491 if (!gc
->currentDpy
) {
495 if (cmdlen
<= gc
->maxSmallRenderCommandSize
) {
496 /* Use GLXRender protocol to send small command */
497 __GLX_BEGIN_VARIABLE_WITH_PIXEL(X_GLrop_ColorTable
, (short)cmdlen
);
498 __GLX_PUT_LONG(0, (long)target
);
499 __GLX_PUT_LONG(4, (long)internalformat
);
500 __GLX_PUT_LONG(8, width
);
501 __GLX_PUT_LONG(12, (long)format
);
502 __GLX_PUT_LONG(16, (long)type
);
503 pc
+= __GLX_COLOR_TABLE_HDR_SIZE
;
504 if (compsize
> 0 && table
!= NULL
) {
505 (*gc
->fillImage
)(gc
, 1, width
, 1, 1, format
, type
, table
, pc
,
508 /* Setup default store modes */
509 GLubyte
*pc
= pixelHeaderPC
;
510 __GLX_PUT_CHAR(0, GL_FALSE
);
511 __GLX_PUT_CHAR(1, GL_FALSE
);
512 __GLX_PUT_CHAR(2, 0);
513 __GLX_PUT_CHAR(3, 0);
514 __GLX_PUT_LONG(4, 0);
515 __GLX_PUT_LONG(8, 0);
516 __GLX_PUT_LONG(12, 0);
517 __GLX_PUT_LONG(16, 1);
519 __GLX_END(__GLX_PAD(compsize
));
521 /* Use GLXRenderLarge protocol to send command */
522 __GLX_BEGIN_VARIABLE_LARGE_WITH_PIXEL(X_GLrop_ColorTable
, cmdlen
+4);
523 __GLX_PUT_LONG(0, (long)target
);
524 __GLX_PUT_LONG(4, (long)internalformat
);
525 __GLX_PUT_LONG(8, width
);
526 __GLX_PUT_LONG(12, (long)format
);
527 __GLX_PUT_LONG(16, (long)type
);
528 pc
+= __GLX_COLOR_TABLE_HDR_SIZE
;
529 SendLargeImage(gc
, compsize
, 1, width
, 1, 1, format
,
530 type
, table
, pc
, pixelHeaderPC
);
534 void __indirect_glColorSubTable(GLenum target
, GLsizei start
, GLsizei count
,
535 GLenum format
, GLenum type
, const GLvoid
*table
)
537 __GLX_DECLARE_VARIABLES();
539 __GLX_LOAD_VARIABLES();
540 compsize
= __glImageSize(count
, 1, 1, format
, type
);
541 cmdlen
= __GLX_PAD(__GLX_COLOR_SUBTABLE_CMD_HDR_SIZE
+ compsize
);
542 if (!gc
->currentDpy
) {
546 if (cmdlen
<= gc
->maxSmallRenderCommandSize
) {
547 /* Use GLXRender protocol to send small command */
548 __GLX_BEGIN_VARIABLE_WITH_PIXEL(X_GLrop_ColorSubTable
, (short)cmdlen
);
549 __GLX_PUT_LONG(0, (long)target
);
550 __GLX_PUT_LONG(4, start
);
551 __GLX_PUT_LONG(8, count
);
552 __GLX_PUT_LONG(12, (long)format
);
553 __GLX_PUT_LONG(16, (long)type
);
554 pc
+= __GLX_COLOR_SUBTABLE_HDR_SIZE
;
555 if (compsize
> 0 && table
!= NULL
) {
556 (*gc
->fillImage
)(gc
, 1, start
+count
, 1, 1, format
, type
, table
, pc
,
559 /* Setup default store modes */
560 GLubyte
*pc
= pixelHeaderPC
;
561 __GLX_PUT_CHAR(0, GL_FALSE
);
562 __GLX_PUT_CHAR(1, GL_FALSE
);
563 __GLX_PUT_CHAR(2, 0);
564 __GLX_PUT_CHAR(3, 0);
565 __GLX_PUT_LONG(4, 0);
566 __GLX_PUT_LONG(8, 0);
567 __GLX_PUT_LONG(12, 0);
568 __GLX_PUT_LONG(16, 1);
570 __GLX_END(__GLX_PAD(compsize
));
572 /* Use GLXRenderLarge protocol to send command */
573 __GLX_BEGIN_VARIABLE_LARGE_WITH_PIXEL(X_GLrop_ColorSubTable
, cmdlen
+4);
574 __GLX_PUT_LONG(0, (long)target
);
575 __GLX_PUT_LONG(4, start
);
576 __GLX_PUT_LONG(8, count
);
577 __GLX_PUT_LONG(12, (long)format
);
578 __GLX_PUT_LONG(16, (long)type
);
579 pc
+= __GLX_COLOR_SUBTABLE_HDR_SIZE
;
580 SendLargeImage(gc
, compsize
, 1, start
+count
, 1, 1, format
,
581 type
, table
, pc
, pixelHeaderPC
);
585 static void __glx_ConvolutionFilter1D2D(GLshort opcode
, GLint dim
,
587 GLenum internalformat
,
588 GLsizei width
, GLsizei height
,
589 GLenum format
, GLenum type
, const GLvoid
*image
)
591 __GLX_DECLARE_VARIABLES();
593 __GLX_LOAD_VARIABLES();
594 compsize
= __glImageSize(width
, height
, 1, format
, type
);
595 cmdlen
= __GLX_PAD(__GLX_CONV_FILT_CMD_HDR_SIZE
+ compsize
);
596 if (!gc
->currentDpy
) return;
598 if (cmdlen
<= gc
->maxSmallRenderCommandSize
) {
599 /* Use GLXRender protocol to send small command */
600 __GLX_BEGIN_VARIABLE_WITH_PIXEL(opcode
, cmdlen
);
601 __GLX_PUT_LONG(0,target
);
602 __GLX_PUT_LONG(4,internalformat
);
603 __GLX_PUT_LONG(8,width
);
604 __GLX_PUT_LONG(12,height
);
605 __GLX_PUT_LONG(16,format
);
606 __GLX_PUT_LONG(20,type
);
607 pc
+= __GLX_CONV_FILT_HDR_SIZE
;
609 (*gc
->fillImage
)(gc
, dim
, width
, height
, 1, format
, type
,
610 image
, pc
, pixelHeaderPC
);
612 /* Setup default store modes */
613 GLubyte
*pc
= pixelHeaderPC
;
614 __GLX_PUT_CHAR(0,GL_FALSE
);
615 __GLX_PUT_CHAR(1,GL_FALSE
);
620 __GLX_PUT_LONG(12,0);
621 __GLX_PUT_LONG(16,1);
623 __GLX_END(__GLX_PAD(compsize
));
625 /* Use GLXRenderLarge protocol to send command */
626 __GLX_BEGIN_VARIABLE_LARGE_WITH_PIXEL(opcode
,cmdlen
+4);
627 __GLX_PUT_LONG(0,target
);
628 __GLX_PUT_LONG(4,internalformat
);
629 __GLX_PUT_LONG(8,width
);
630 __GLX_PUT_LONG(12,height
);
631 __GLX_PUT_LONG(16,format
);
632 __GLX_PUT_LONG(20,type
);
633 pc
+= __GLX_CONV_FILT_HDR_SIZE
;
634 SendLargeImage(gc
, compsize
, dim
, width
, height
, 1, format
,
635 type
, image
, pc
, pixelHeaderPC
);
639 void __indirect_glConvolutionFilter1D(GLenum target
, GLenum internalformat
,
640 GLsizei width
, GLenum format
,
641 GLenum type
, const GLvoid
*image
)
643 __glx_ConvolutionFilter1D2D(X_GLrop_ConvolutionFilter1D
, 1, target
,
644 internalformat
, width
, 1, format
, type
,
648 void __indirect_glConvolutionFilter2D(GLenum target
, GLenum internalformat
,
649 GLsizei width
, GLsizei height
, GLenum format
,
650 GLenum type
, const GLvoid
*image
)
652 __glx_ConvolutionFilter1D2D(X_GLrop_ConvolutionFilter2D
, 2, target
,
653 internalformat
, width
, height
, format
, type
,
657 void __indirect_glSeparableFilter2D(GLenum target
, GLenum internalformat
,
658 GLsizei width
, GLsizei height
, GLenum format
,
659 GLenum type
, const GLvoid
*row
,
660 const GLvoid
*column
)
662 __GLX_DECLARE_VARIABLES();
663 GLuint compsize2
, hdrlen
, totalhdrlen
, image1len
, image2len
;
665 __GLX_LOAD_VARIABLES();
666 compsize
= __glImageSize(width
, 1, 1, format
, type
);
667 compsize2
= __glImageSize(height
, 1, 1, format
, type
);
668 totalhdrlen
= __GLX_PAD(__GLX_CONV_FILT_CMD_HDR_SIZE
);
669 hdrlen
= __GLX_PAD(__GLX_CONV_FILT_HDR_SIZE
);
670 image1len
= __GLX_PAD(compsize
);
671 image2len
= __GLX_PAD(compsize2
);
672 cmdlen
= totalhdrlen
+ image1len
+ image2len
;
673 if (!gc
->currentDpy
) return;
675 if (cmdlen
<= gc
->maxSmallRenderCommandSize
) {
676 /* Use GLXRender protocol to send small command */
677 __GLX_BEGIN_VARIABLE_WITH_PIXEL(X_GLrop_SeparableFilter2D
, cmdlen
);
678 __GLX_PUT_LONG(0,target
);
679 __GLX_PUT_LONG(4,internalformat
);
680 __GLX_PUT_LONG(8,width
);
681 __GLX_PUT_LONG(12,height
);
682 __GLX_PUT_LONG(16,format
);
683 __GLX_PUT_LONG(20,type
);
686 (*gc
->fillImage
)(gc
, 1, width
, 1, 1, format
, type
,
687 row
, pc
, pixelHeaderPC
);
691 (*gc
->fillImage
)(gc
, 1, height
, 1, 1, format
, type
,
695 if ((compsize
== 0) && (compsize2
== 0)) {
696 /* Setup default store modes */
697 GLubyte
*pc
= pixelHeaderPC
;
698 __GLX_PUT_CHAR(0,GL_FALSE
);
699 __GLX_PUT_CHAR(1,GL_FALSE
);
704 __GLX_PUT_LONG(12,0);
705 __GLX_PUT_LONG(16,1);
711 bufsize
= image1len
+ image2len
;
713 /* Use GLXRenderLarge protocol to send command */
714 __GLX_BEGIN_VARIABLE_LARGE_WITH_PIXEL(X_GLrop_SeparableFilter2D
,cmdlen
+4);
715 __GLX_PUT_LONG(0,target
);
716 __GLX_PUT_LONG(4,internalformat
);
717 __GLX_PUT_LONG(8,width
);
718 __GLX_PUT_LONG(12,height
);
719 __GLX_PUT_LONG(16,format
);
720 __GLX_PUT_LONG(20,type
);
723 if (!gc
->fastImageUnpack
) {
724 /* Allocate a temporary holding buffer */
725 GLubyte
*buf
= (GLubyte
*) Xmalloc(bufsize
);
727 __glXSetError(gc
, GL_OUT_OF_MEMORY
);
730 (*gc
->fillImage
)(gc
, 1, width
, 1, 1, format
, type
, row
, buf
, pixelHeaderPC
);
732 (*gc
->fillImage
)(gc
, 1, height
, 1, 1, format
, type
, column
,
733 buf
+ image1len
, pixelHeaderPC
);
735 /* Send large command */
736 __glXSendLargeCommand(gc
, gc
->pc
, (GLint
)(pc
- gc
->pc
), buf
, bufsize
);
740 /* Just send the data straight as is */
741 __glXSendLargeCommand(gc
, gc
->pc
, (GLint
)(pc
- gc
->pc
), pc
, bufsize
);
746 void __indirect_glTexImage3D(GLenum target
, GLint level
, GLint internalformat
,
747 GLsizei width
, GLsizei height
, GLsizei depth
, GLint border
,
748 GLenum format
, GLenum type
, const GLvoid
*image
)
750 __GLX_DECLARE_VARIABLES();
752 __GLX_LOAD_VARIABLES();
753 if ((target
== GL_PROXY_TEXTURE_3D
) || (image
== NULL
)) {
756 compsize
= __glImageSize(width
, height
, depth
, format
, type
);
758 cmdlen
= __GLX_PAD(__GLX_TEXIMAGE_3D_CMD_HDR_SIZE
+ compsize
);
759 if (!gc
->currentDpy
) return;
761 if (cmdlen
<= gc
->maxSmallRenderCommandSize
) {
762 /* Use GLXRender protocol to send small command */
763 __GLX_BEGIN_VARIABLE_WITH_PIXEL_3D(X_GLrop_TexImage3D
,cmdlen
);
764 __GLX_PUT_LONG(0,target
);
765 __GLX_PUT_LONG(4,level
);
766 __GLX_PUT_LONG(8,internalformat
);
767 __GLX_PUT_LONG(12,width
);
768 __GLX_PUT_LONG(16,height
);
769 __GLX_PUT_LONG(20,depth
);
770 __GLX_PUT_LONG(24,0); /* size4d */
771 __GLX_PUT_LONG(28,border
);
772 __GLX_PUT_LONG(32,format
);
773 __GLX_PUT_LONG(36,type
);
775 __GLX_PUT_LONG(40,GL_TRUE
);
777 __GLX_PUT_LONG(40,GL_FALSE
);
779 pc
+= __GLX_TEXIMAGE_3D_HDR_SIZE
;
780 if (compsize
> 0 && image
!= NULL
) {
781 (*gc
->fillImage
)(gc
, 3, width
, height
, depth
, format
, type
,
782 image
, pc
, pixelHeaderPC
);
784 /* Setup default store modes */
785 GLubyte
*pc
= pixelHeaderPC
;
786 __GLX_PUT_CHAR(0,GL_FALSE
);
787 __GLX_PUT_CHAR(1,GL_FALSE
);
792 __GLX_PUT_LONG(12,0);
793 __GLX_PUT_LONG(16,0);
794 __GLX_PUT_LONG(20,0);
795 __GLX_PUT_LONG(24,0);
796 __GLX_PUT_LONG(28,0);
797 __GLX_PUT_LONG(32,1);
799 __GLX_END(__GLX_PAD(compsize
));
801 /* Use GLXRenderLarge protocol to send command */
802 __GLX_BEGIN_VARIABLE_LARGE_WITH_PIXEL_3D(X_GLrop_TexImage3D
,cmdlen
+4);
803 __GLX_PUT_LONG(0,target
);
804 __GLX_PUT_LONG(4,level
);
805 __GLX_PUT_LONG(8,internalformat
);
806 __GLX_PUT_LONG(12,width
);
807 __GLX_PUT_LONG(16,height
);
808 __GLX_PUT_LONG(20,depth
);
809 __GLX_PUT_LONG(24,0); /* size4d */
810 __GLX_PUT_LONG(28,border
);
811 __GLX_PUT_LONG(32,format
);
812 __GLX_PUT_LONG(36,type
);
814 __GLX_PUT_LONG(40,GL_TRUE
);
816 __GLX_PUT_LONG(40,GL_FALSE
);
818 pc
+= __GLX_TEXIMAGE_3D_HDR_SIZE
;
819 SendLargeImage(gc
, compsize
, 3, width
, height
, depth
, format
,
820 type
, image
, pc
, pixelHeaderPC
);
824 void __indirect_glTexSubImage3D(GLenum target
, GLint level
, GLint xoffset
, GLint yoffset
,
825 GLint zoffset
, GLsizei width
, GLsizei height
,
826 GLsizei depth
, GLenum format
, GLenum type
,
829 __GLX_DECLARE_VARIABLES();
831 __GLX_LOAD_VARIABLES();
835 compsize
= __glImageSize(width
, height
, depth
, format
, type
);
837 cmdlen
= __GLX_PAD(__GLX_TEXSUBIMAGE_3D_CMD_HDR_SIZE
+ compsize
);
838 if (!gc
->currentDpy
) return;
840 if (cmdlen
<= gc
->maxSmallRenderCommandSize
) {
841 /* Use GLXRender protocol to send small command */
842 __GLX_BEGIN_VARIABLE_WITH_PIXEL_3D(X_GLrop_TexSubImage3D
,cmdlen
);
843 __GLX_PUT_LONG(0,target
);
844 __GLX_PUT_LONG(4,level
);
845 __GLX_PUT_LONG(8,xoffset
);
846 __GLX_PUT_LONG(12,yoffset
);
847 __GLX_PUT_LONG(16,zoffset
);
848 __GLX_PUT_LONG(20,0); /* woffset */
849 __GLX_PUT_LONG(24,width
);
850 __GLX_PUT_LONG(28,height
);
851 __GLX_PUT_LONG(32,depth
);
852 __GLX_PUT_LONG(36,0); /* size4d */
853 __GLX_PUT_LONG(40,format
);
854 __GLX_PUT_LONG(44,type
);
856 __GLX_PUT_LONG(48,GL_TRUE
);
858 __GLX_PUT_LONG(48,GL_FALSE
);
860 pc
+= __GLX_TEXSUBIMAGE_3D_HDR_SIZE
;
862 (*gc
->fillImage
)(gc
, 3, width
, height
, depth
, format
, type
, image
,
865 /* Setup default store modes */
866 GLubyte
*pc
= pixelHeaderPC
;
867 __GLX_PUT_CHAR(0,GL_FALSE
);
868 __GLX_PUT_CHAR(1,GL_FALSE
);
873 __GLX_PUT_LONG(12,0);
874 __GLX_PUT_LONG(16,0);
875 __GLX_PUT_LONG(20,0);
876 __GLX_PUT_LONG(24,0);
877 __GLX_PUT_LONG(28,0);
878 __GLX_PUT_LONG(32,1);
880 __GLX_END(__GLX_PAD(compsize
));
882 /* Use GLXRenderLarge protocol to send command */
883 __GLX_BEGIN_VARIABLE_LARGE_WITH_PIXEL_3D(X_GLrop_TexSubImage3D
,
885 __GLX_PUT_LONG(0,target
);
886 __GLX_PUT_LONG(4,level
);
887 __GLX_PUT_LONG(8,xoffset
);
888 __GLX_PUT_LONG(12,yoffset
);
889 __GLX_PUT_LONG(16,zoffset
);
890 __GLX_PUT_LONG(20,0); /* woffset */
891 __GLX_PUT_LONG(24,width
);
892 __GLX_PUT_LONG(28,height
);
893 __GLX_PUT_LONG(32,depth
);
894 __GLX_PUT_LONG(36,0); /* size4d */
895 __GLX_PUT_LONG(40,format
);
896 __GLX_PUT_LONG(44,type
);
898 __GLX_PUT_LONG(48,GL_TRUE
);
900 __GLX_PUT_LONG(48,GL_FALSE
);
902 pc
+= __GLX_TEXSUBIMAGE_3D_HDR_SIZE
;
903 SendLargeImage(gc
, compsize
, 3, width
, height
, depth
, format
, type
,
904 image
, pc
, pixelHeaderPC
);