2 * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
3 * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
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:
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.
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
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.
31 #ifdef HAVE_DIX_CONFIG_H
32 #include <dix-config.h>
35 #include "glxserver.h"
38 #include "indirect_dispatch.h"
42 __glXDispSwap_FeedbackBuffer(__GLXclientState
* cl
, GLbyte
* pc
)
47 __GLX_DECLARE_SWAP_VARIABLES
;
51 __GLX_SWAP_INT(&((xGLXSingleReq
*) pc
)->contextTag
);
52 cx
= __glXForceCurrent(cl
, __GLX_GET_SINGLE_CONTEXT_TAG(pc
), &error
);
57 pc
+= __GLX_SINGLE_HDR_SIZE
;
58 __GLX_SWAP_INT(pc
+ 0);
59 __GLX_SWAP_INT(pc
+ 4);
60 size
= *(GLsizei
*) (pc
+ 0);
61 type
= *(GLenum
*) (pc
+ 4);
62 if (cx
->feedbackBufSize
< size
) {
63 cx
->feedbackBuf
= (GLfloat
*) realloc(cx
->feedbackBuf
,
65 * __GLX_SIZE_FLOAT32
);
66 if (!cx
->feedbackBuf
) {
67 cl
->client
->errorValue
= size
;
70 cx
->feedbackBufSize
= size
;
72 glFeedbackBuffer(size
, type
, cx
->feedbackBuf
);
73 cx
->hasUnflushedCommands
= GL_TRUE
;
78 __glXDispSwap_SelectBuffer(__GLXclientState
* cl
, GLbyte
* pc
)
83 __GLX_DECLARE_SWAP_VARIABLES
;
86 __GLX_SWAP_INT(&((xGLXSingleReq
*) pc
)->contextTag
);
87 cx
= __glXForceCurrent(cl
, __GLX_GET_SINGLE_CONTEXT_TAG(pc
), &error
);
92 pc
+= __GLX_SINGLE_HDR_SIZE
;
93 __GLX_SWAP_INT(pc
+ 0);
94 size
= *(GLsizei
*) (pc
+ 0);
95 if (cx
->selectBufSize
< size
) {
96 cx
->selectBuf
= (GLuint
*) realloc(cx
->selectBuf
,
97 (size_t) size
* __GLX_SIZE_CARD32
);
99 cl
->client
->errorValue
= size
;
102 cx
->selectBufSize
= size
;
104 glSelectBuffer(size
, cx
->selectBuf
);
105 cx
->hasUnflushedCommands
= GL_TRUE
;
110 __glXDispSwap_RenderMode(__GLXclientState
* cl
, GLbyte
* pc
)
114 xGLXRenderModeReply reply
;
115 GLint nitems
= 0, retBytes
= 0, retval
, newModeCheck
;
116 GLubyte
*retBuffer
= NULL
;
119 __GLX_DECLARE_SWAP_VARIABLES
;
120 __GLX_DECLARE_SWAP_ARRAY_VARIABLES
;
123 __GLX_SWAP_INT(&((xGLXSingleReq
*) pc
)->contextTag
);
124 cx
= __glXForceCurrent(cl
, __GLX_GET_SINGLE_CONTEXT_TAG(pc
), &error
);
129 pc
+= __GLX_SINGLE_HDR_SIZE
;
131 newMode
= *(GLenum
*) pc
;
132 retval
= glRenderMode(newMode
);
134 /* Check that render mode worked */
135 glGetIntegerv(GL_RENDER_MODE
, &newModeCheck
);
136 if (newModeCheck
!= newMode
) {
137 /* Render mode change failed. Bail */
138 newMode
= newModeCheck
;
139 goto noChangeAllowed
;
143 ** Render mode might have still failed if we get here. But in this
144 ** case we can't really tell, nor does it matter. If it did fail, it
145 ** will return 0, and thus we won't send any data across the wire.
148 switch (cx
->renderMode
) {
150 cx
->renderMode
= newMode
;
154 /* Overflow happened. Copy the entire buffer */
155 nitems
= cx
->feedbackBufSize
;
160 retBytes
= nitems
* __GLX_SIZE_FLOAT32
;
161 retBuffer
= (GLubyte
*) cx
->feedbackBuf
;
162 __GLX_SWAP_FLOAT_ARRAY((GLbyte
*) retBuffer
, nitems
);
163 cx
->renderMode
= newMode
;
167 /* Overflow happened. Copy the entire buffer */
168 nitems
= cx
->selectBufSize
;
171 GLuint
*bp
= cx
->selectBuf
;
175 ** Figure out how many bytes of data need to be sent. Parse
176 ** the selection buffer to determine this fact as the
177 ** return value is the number of hits, not the number of
178 ** items in the buffer.
185 /* Parse select data for this hit */
189 nitems
= bp
- cx
->selectBuf
;
191 retBytes
= nitems
* __GLX_SIZE_CARD32
;
192 retBuffer
= (GLubyte
*) cx
->selectBuf
;
193 __GLX_SWAP_INT_ARRAY((GLbyte
*) retBuffer
, nitems
);
194 cx
->renderMode
= newMode
;
199 ** First reply is the number of elements returned in the feedback or
200 ** selection array, as per the API for glRenderMode itself.
204 reply
= (xGLXRenderModeReply
) {
206 .sequenceNumber
= client
->sequence
,
212 __GLX_SWAP_SHORT(&reply
.sequenceNumber
);
213 __GLX_SWAP_INT(&reply
.length
);
214 __GLX_SWAP_INT(&reply
.retval
);
215 __GLX_SWAP_INT(&reply
.size
);
216 __GLX_SWAP_INT(&reply
.newMode
);
217 WriteToClient(client
, sz_xGLXRenderModeReply
, &reply
);
219 WriteToClient(client
, retBytes
, retBuffer
);
225 __glXDispSwap_Flush(__GLXclientState
* cl
, GLbyte
* pc
)
230 __GLX_DECLARE_SWAP_VARIABLES
;
232 __GLX_SWAP_INT(&((xGLXSingleReq
*) pc
)->contextTag
);
233 cx
= __glXForceCurrent(cl
, __GLX_GET_SINGLE_CONTEXT_TAG(pc
), &error
);
239 cx
->hasUnflushedCommands
= GL_FALSE
;
244 __glXDispSwap_Finish(__GLXclientState
* cl
, GLbyte
* pc
)
250 __GLX_DECLARE_SWAP_VARIABLES
;
252 __GLX_SWAP_INT(&((xGLXSingleReq
*) pc
)->contextTag
);
253 cx
= __glXForceCurrent(cl
, __GLX_GET_SINGLE_CONTEXT_TAG(pc
), &error
);
258 /* Do a local glFinish */
260 cx
->hasUnflushedCommands
= GL_FALSE
;
262 /* Send empty reply packet to indicate finish is finished */
264 __GLX_BEGIN_REPLY(0);
266 __GLX_SWAP_REPLY_HEADER();
273 __glXDispSwap_GetString(__GLXclientState
* cl
, GLbyte
* pc
)
275 return DoGetString(cl
, pc
, GL_TRUE
);