2 * Xephyr - A kdrive X server thats runs in a host X window.
3 * Authored by Matthew Allum <mallum@openedhand.com>
5 * Copyright © 2007 OpenedHand Ltd
7 * Permission to use, copy, modify, distribute, and sell this software and its
8 * documentation for any purpose is hereby granted without fee, provided that
9 * the above copyright notice appear in all copies and that both that
10 * copyright notice and this permission notice appear in supporting
11 * documentation, and that the name of OpenedHand Ltd not be used in
12 * advertising or publicity pertaining to distribution of the software without
13 * specific, written prior permission. OpenedHand Ltd makes no
14 * representations about the suitability of this software for any purpose. It
15 * is provided "as is" without express or implied warranty.
17 * OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
18 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
19 * EVENT SHALL OpenedHand Ltd BE LIABLE FOR ANY SPECIAL, INDIRECT OR
20 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
21 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
22 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
23 * PERFORMANCE OF THIS SOFTWARE.
26 * Dodji Seketeli <dodji@openedhand.com>
29 #include <kdrive-config.h>
33 #include "extnsionst.h"
34 #include "ephyrglxext.h"
35 #include "ephyrhostglx.h"
36 #define _HAVE_XALLOC_DECLS
38 #include <GL/glxproto.h>
39 #include "glx/glxserver.h"
40 #include "glx/indirect_table.h"
41 #include "glx/indirect_util.h"
42 #include "glx/unpack.h"
53 int ephyrGLXQueryVersion(__GLXclientState
* cl
, GLbyte
* pc
);
54 int ephyrGLXQueryVersionSwap(__GLXclientState
* cl
, GLbyte
* pc
);
55 int ephyrGLXGetVisualConfigs(__GLXclientState
* cl
, GLbyte
* pc
);
56 int ephyrGLXGetVisualConfigsSwap(__GLXclientState
* cl
, GLbyte
* pc
);
57 int ephyrGLXClientInfo(__GLXclientState
* cl
, GLbyte
* pc
);
58 int ephyrGLXClientInfoSwap(__GLXclientState
* cl
, GLbyte
* pc
);
59 int ephyrGLXQueryServerString(__GLXclientState
* a_cl
, GLbyte
* a_pc
);
60 int ephyrGLXQueryServerStringSwap(__GLXclientState
* a_cl
, GLbyte
* a_pc
);
61 int ephyrGLXGetFBConfigsSGIX(__GLXclientState
* a_cl
, GLbyte
* a_pc
);
62 int ephyrGLXGetFBConfigsSGIXSwap(__GLXclientState
* a_cl
, GLbyte
* a_pc
);
63 int ephyrGLXCreateContext(__GLXclientState
* a_cl
, GLbyte
* a_pc
);
64 int ephyrGLXCreateContextSwap(__GLXclientState
* a_cl
, GLbyte
* a_pc
);
65 int ephyrGLXCreateNewContext(__GLXclientState
* a_cl
, GLbyte
* a_pc
);
66 int ephyrGLXCreateNewContextSwap(__GLXclientState
* a_cl
, GLbyte
* a_pc
);
67 int ephyrGLXDestroyContext(__GLXclientState
* a_cl
, GLbyte
* a_pc
);
68 int ephyrGLXDestroyContextSwap(__GLXclientState
* a_cl
, GLbyte
* a_pc
);
69 int ephyrGLXMakeCurrent(__GLXclientState
* a_cl
, GLbyte
* a_pc
);
70 int ephyrGLXMakeCurrentSwap(__GLXclientState
* a_cl
, GLbyte
* a_pc
);
71 int ephyrGLXMakeCurrentReadSGI(__GLXclientState
* a_cl
, GLbyte
* a_pc
);
72 int ephyrGLXMakeCurrentReadSGISwap(__GLXclientState
* a_cl
, GLbyte
* a_pc
);
73 int ephyrGLXMakeContextCurrent(__GLXclientState
* a_cl
, GLbyte
* a_pc
);
74 int ephyrGLXMakeContextCurrentSwap(__GLXclientState
* a_cl
, GLbyte
* a_pc
);
75 int ephyrGLXGetString(__GLXclientState
* a_cl
, GLbyte
* a_pc
);
76 int ephyrGLXGetStringSwap(__GLXclientState
* a_cl
, GLbyte
* a_pc
);
77 int ephyrGLXGetIntegerv(__GLXclientState
* a_cl
, GLbyte
* a_pc
);
78 int ephyrGLXGetIntegervSwap(__GLXclientState
* a_cl
, GLbyte
* a_pc
);
79 int ephyrGLXIsDirect(__GLXclientState
* a_cl
, GLbyte
* a_pc
);
80 int ephyrGLXIsDirectSwap(__GLXclientState
* a_cl
, GLbyte
* a_pc
);
83 ephyrHijackGLXExtension(void)
85 const void *(*dispatch_functions
)[2];
87 if (!host_has_extension(&xcb_glx_id
)) {
88 EPHYR_LOG("host X does not have GLX\n");
91 EPHYR_LOG("host X does have GLX\n");
93 if (!Single_dispatch_info
.dispatch_functions
) {
94 EPHYR_LOG_ERROR("could not get dispatch functions table\n");
98 * hijack some single entry point dispatch functions
100 dispatch_functions
= Single_dispatch_info
.dispatch_functions
;
101 EPHYR_RETURN_VAL_IF_FAIL(dispatch_functions
, FALSE
);
103 dispatch_functions
[X_GLXQueryVersion
][0] = ephyrGLXQueryVersion
;
104 dispatch_functions
[X_GLXQueryVersion
][1] = ephyrGLXQueryVersionSwap
;
106 dispatch_functions
[X_GLXGetVisualConfigs
][0] = ephyrGLXGetVisualConfigs
;
107 dispatch_functions
[X_GLXGetVisualConfigs
][1] = ephyrGLXGetVisualConfigsSwap
;
108 dispatch_functions
[X_GLXClientInfo
][0] = ephyrGLXClientInfo
;
109 dispatch_functions
[X_GLXClientInfo
][1] = ephyrGLXClientInfoSwap
;
111 dispatch_functions
[X_GLXQueryServerString
][0] = ephyrGLXQueryServerString
;
112 dispatch_functions
[X_GLXQueryServerString
][1] =
113 ephyrGLXQueryServerStringSwap
;
115 dispatch_functions
[X_GLXCreateContext
][0] = ephyrGLXCreateContext
;
116 dispatch_functions
[X_GLXCreateContext
][1] = ephyrGLXCreateContextSwap
;
118 dispatch_functions
[X_GLXCreateNewContext
][0] = ephyrGLXCreateNewContext
;
119 dispatch_functions
[X_GLXCreateNewContext
][1] = ephyrGLXCreateNewContextSwap
;
121 dispatch_functions
[X_GLXDestroyContext
][0] = ephyrGLXDestroyContext
;
122 dispatch_functions
[X_GLXDestroyContext
][1] = ephyrGLXDestroyContextSwap
;
124 dispatch_functions
[X_GLXMakeCurrent
][0] = ephyrGLXMakeCurrent
;
125 dispatch_functions
[X_GLXMakeCurrent
][1] = ephyrGLXMakeCurrentSwap
;
127 dispatch_functions
[X_GLXIsDirect
][0] = ephyrGLXIsDirect
;
128 dispatch_functions
[X_GLXIsDirect
][1] = ephyrGLXIsDirectSwap
;
130 dispatch_functions
[73][0] = ephyrGLXGetString
;
131 dispatch_functions
[73][1] = ephyrGLXGetStringSwap
;
133 dispatch_functions
[61][0] = ephyrGLXGetIntegerv
;
134 dispatch_functions
[61][1] = ephyrGLXGetIntegervSwap
;
136 dispatch_functions
[X_GLXMakeContextCurrent
][0] =
137 ephyrGLXMakeContextCurrent
;
138 dispatch_functions
[X_GLXMakeContextCurrent
][1] =
139 ephyrGLXMakeContextCurrentSwap
;
142 * hijack some vendor priv entry point dispatch functions
144 dispatch_functions
= VendorPriv_dispatch_info
.dispatch_functions
;
145 dispatch_functions
[92][0] = ephyrGLXGetFBConfigsSGIX
;
146 dispatch_functions
[92][1] = ephyrGLXGetFBConfigsSGIXSwap
;
148 dispatch_functions
[89][0] = ephyrGLXMakeCurrentReadSGI
;
149 dispatch_functions
[89][1] = ephyrGLXMakeCurrentReadSGISwap
;
151 EPHYR_LOG("hijacked glx entry points to forward requests to host X\n");
157 /*********************
161 ********************/
164 ephyrGLXQueryVersion(__GLXclientState
* a_cl
, GLbyte
* a_pc
)
166 ClientPtr client
= a_cl
->client
;
167 xGLXQueryVersionReq
*req
= (xGLXQueryVersionReq
*) a_pc
;
168 xGLXQueryVersionReply reply
;
170 int res
= BadImplementation
;
172 EPHYR_LOG("enter\n");
174 major
= req
->majorVersion
;
175 minor
= req
->minorVersion
;
177 if (!ephyrHostGLXQueryVersion(&major
, &minor
)) {
178 EPHYR_LOG_ERROR("ephyrHostGLXQueryVersion() failed\n");
181 EPHYR_LOG("major:%d, minor:%d\n", major
, minor
);
182 reply
= (xGLXQueryVersionReply
) {
184 .sequenceNumber
= client
->sequence
,
186 .majorVersion
= major
,
187 .minorVersion
= minor
190 if (client
->swapped
) {
191 __glXSwapQueryVersionReply(client
, &reply
);
194 WriteToClient(client
, sz_xGLXQueryVersionReply
, &reply
);
199 EPHYR_LOG("leave\n");
204 ephyrGLXQueryVersionSwap(__GLXclientState
* a_cl
, GLbyte
* a_pc
)
206 xGLXQueryVersionReq
*req
= (xGLXQueryVersionReq
*) a_pc
;
208 __GLX_DECLARE_SWAP_VARIABLES
;
210 __GLX_SWAP_SHORT(&req
->length
);
211 __GLX_SWAP_INT(&req
->majorVersion
);
212 __GLX_SWAP_INT(&req
->minorVersion
);
213 return ephyrGLXQueryVersion(a_cl
, a_pc
);
217 ephyrGLXGetVisualConfigsReal(__GLXclientState
* a_cl
,
218 GLbyte
* a_pc
, Bool a_do_swap
)
220 xGLXGetVisualConfigsReq
*req
= (xGLXGetVisualConfigsReq
*) a_pc
;
221 ClientPtr client
= a_cl
->client
;
222 xGLXGetVisualConfigsReply reply
;
223 int32_t *props_buf
= NULL
, num_visuals
= 0,
224 num_props
= 0, res
= BadImplementation
, i
= 0,
225 props_per_visual_size
= 0, props_buf_size
= 0;
226 __GLX_DECLARE_SWAP_VARIABLES
;
227 __GLX_DECLARE_SWAP_ARRAY_VARIABLES
;
229 EPHYR_LOG("enter\n");
231 if (!ephyrHostGLXGetVisualConfigs(req
->screen
,
234 &props_buf_size
, &props_buf
)) {
235 EPHYR_LOG_ERROR("ephyrHostGLXGetVisualConfigs() failed\n");
238 EPHYR_LOG("num_visuals:%d, num_props:%d\n", num_visuals
, num_props
);
240 reply
= (xGLXGetVisualConfigsReply
) {
242 .sequenceNumber
= client
->sequence
,
243 .length
= (num_visuals
* __GLX_SIZE_CARD32
* num_props
) >> 2,
244 .numVisuals
= num_visuals
,
245 .numProps
= num_props
249 __GLX_SWAP_SHORT(&reply
.sequenceNumber
);
250 __GLX_SWAP_INT(&reply
.length
);
251 __GLX_SWAP_INT(&reply
.numVisuals
);
252 __GLX_SWAP_INT(&reply
.numProps
);
253 __GLX_SWAP_INT_ARRAY(props_buf
, num_props
);
255 WriteToClient(client
, sz_xGLXGetVisualConfigsReply
, &reply
);
256 props_per_visual_size
= props_buf_size
/ num_visuals
;
257 for (i
= 0; i
< num_visuals
; i
++) {
258 WriteToClient(client
,
259 props_per_visual_size
,
260 (char *) props_buf
+ i
* props_per_visual_size
);
265 EPHYR_LOG("leave\n");
273 ephyrGLXGetFBConfigsSGIXReal(__GLXclientState
* a_cl
,
274 GLbyte
* a_pc
, Bool a_do_swap
)
276 xGLXGetFBConfigsSGIXReq
*req
= (xGLXGetFBConfigsSGIXReq
*) a_pc
;
277 ClientPtr client
= a_cl
->client
;
278 xGLXGetVisualConfigsReply reply
;
279 int32_t *props_buf
= NULL
, num_visuals
= 0,
280 num_props
= 0, res
= BadImplementation
, i
= 0,
281 props_per_visual_size
= 0, props_buf_size
= 0;
282 __GLX_DECLARE_SWAP_VARIABLES
;
283 __GLX_DECLARE_SWAP_ARRAY_VARIABLES
;
285 EPHYR_LOG("enter\n");
287 if (!ephyrHostGLXVendorPrivGetFBConfigsSGIX(req
->screen
,
290 &props_buf_size
, &props_buf
)) {
291 EPHYR_LOG_ERROR("ephyrHostGLXGetVisualConfigs() failed\n");
294 EPHYR_LOG("num_visuals:%d, num_props:%d\n", num_visuals
, num_props
);
296 reply
= (xGLXGetVisualConfigsReply
) {
298 .sequenceNumber
= client
->sequence
,
299 .length
= props_buf_size
>> 2,
300 .numVisuals
= num_visuals
,
301 .numProps
= num_props
305 __GLX_SWAP_SHORT(&reply
.sequenceNumber
);
306 __GLX_SWAP_INT(&reply
.length
);
307 __GLX_SWAP_INT(&reply
.numVisuals
);
308 __GLX_SWAP_INT(&reply
.numProps
);
309 __GLX_SWAP_INT_ARRAY(props_buf
, num_props
);
311 WriteToClient(client
, sz_xGLXGetVisualConfigsReply
, &reply
);
312 props_per_visual_size
= props_buf_size
/ num_visuals
;
313 for (i
= 0; i
< num_visuals
; i
++) {
314 WriteToClient(client
,
315 props_per_visual_size
,
316 &((char *) props_buf
)[i
* props_per_visual_size
]);
321 EPHYR_LOG("leave\n");
329 ephyrGLXGetVisualConfigs(__GLXclientState
* a_cl
, GLbyte
* a_pc
)
331 return ephyrGLXGetVisualConfigsReal(a_cl
, a_pc
, FALSE
);
335 ephyrGLXGetVisualConfigsSwap(__GLXclientState
* a_cl
, GLbyte
* a_pc
)
337 return ephyrGLXGetVisualConfigsReal(a_cl
, a_pc
, TRUE
);
341 ephyrGLXClientInfo(__GLXclientState
* a_cl
, GLbyte
* a_pc
)
343 int res
= BadImplementation
;
344 xGLXClientInfoReq
*req
= (xGLXClientInfoReq
*) a_pc
;
346 EPHYR_LOG("enter\n");
347 if (!ephyrHostGLXSendClientInfo(req
->major
, req
->minor
, (char *) req
+ 1)) {
348 EPHYR_LOG_ERROR("failed to send client info to host\n");
354 EPHYR_LOG("leave\n");
359 ephyrGLXClientInfoSwap(__GLXclientState
* a_cl
, GLbyte
* a_pc
)
361 xGLXClientInfoReq
*req
= (xGLXClientInfoReq
*) a_pc
;
363 __GLX_DECLARE_SWAP_VARIABLES
;
365 __GLX_SWAP_SHORT(&req
->length
);
366 __GLX_SWAP_INT(&req
->major
);
367 __GLX_SWAP_INT(&req
->minor
);
368 __GLX_SWAP_INT(&req
->numbytes
);
370 return ephyrGLXClientInfo(a_cl
, a_pc
);
374 ephyrGLXQueryServerString(__GLXclientState
* a_cl
, GLbyte
* a_pc
)
376 int res
= BadImplementation
;
377 ClientPtr client
= a_cl
->client
;
378 xGLXQueryServerStringReq
*req
= (xGLXQueryServerStringReq
*) a_pc
;
379 xGLXQueryServerStringReply reply
;
380 char *server_string
= NULL
;
383 EPHYR_LOG("enter\n");
384 if (!ephyrHostGLXQueryServerString(req
->screen
,
387 EPHYR_LOG_ERROR("failed to query string from host\n");
390 EPHYR_LOG("string: %s\n", server_string
);
391 length
= strlen(server_string
) + 1;
392 reply
= (xGLXQueryServerStringReply
) {
394 .sequenceNumber
= client
->sequence
,
395 .length
= __GLX_PAD(length
) >> 2,
399 WriteToClient(client
, sz_xGLXQueryServerStringReply
, &reply
);
400 WriteToClient(client
, (int) (reply
.length
<< 2), server_string
);
405 EPHYR_LOG("leave\n");
407 server_string
= NULL
;
413 ephyrGLXQueryServerStringSwap(__GLXclientState
* a_cl
, GLbyte
* a_pc
)
415 EPHYR_LOG_ERROR("not yet implemented\n");
416 return BadImplementation
;
420 ephyrGLXGetFBConfigsSGIX(__GLXclientState
* a_cl
, GLbyte
* a_pc
)
422 return ephyrGLXGetFBConfigsSGIXReal(a_cl
, a_pc
, FALSE
);
426 ephyrGLXGetFBConfigsSGIXSwap(__GLXclientState
* a_cl
, GLbyte
* a_pc
)
428 return ephyrGLXGetFBConfigsSGIXReal(a_cl
, a_pc
, TRUE
);
432 ephyrGLXCreateContextReal(xGLXCreateContextReq
* a_req
, Bool a_do_swap
)
434 int res
= BadImplementation
;
435 EphyrHostWindowAttributes host_w_attrs
;
437 __GLX_DECLARE_SWAP_VARIABLES
;
439 EPHYR_RETURN_VAL_IF_FAIL(a_req
, BadValue
);
440 EPHYR_LOG("enter\n");
443 __GLX_SWAP_SHORT(&a_req
->length
);
444 __GLX_SWAP_INT(&a_req
->context
);
445 __GLX_SWAP_INT(&a_req
->visual
);
446 __GLX_SWAP_INT(&a_req
->screen
);
447 __GLX_SWAP_INT(&a_req
->shareList
);
450 EPHYR_LOG("context creation requested. localid:%d, "
451 "screen:%d, visual:%d, direct:%d\n",
452 (int) a_req
->context
, (int) a_req
->screen
,
453 (int) a_req
->visual
, (int) a_req
->isDirect
);
455 memset(&host_w_attrs
, 0, sizeof(host_w_attrs
));
456 if (!hostx_get_window_attributes(hostx_get_window(a_req
->screen
),
458 EPHYR_LOG_ERROR("failed to get host window attrs\n");
462 EPHYR_LOG("host window visual id: %d\n", host_w_attrs
.visualid
);
464 if (!ephyrHostGLXCreateContext(a_req
->screen
,
465 host_w_attrs
.visualid
,
468 a_req
->isDirect
, X_GLXCreateContext
)) {
469 EPHYR_LOG_ERROR("ephyrHostGLXCreateContext() failed\n");
474 EPHYR_LOG("leave\n");
479 ephyrGLXCreateNewContextReal(xGLXCreateNewContextReq
* a_req
, Bool a_do_swap
)
481 int res
= BadImplementation
;
483 __GLX_DECLARE_SWAP_VARIABLES
;
485 EPHYR_RETURN_VAL_IF_FAIL(a_req
, BadValue
);
486 EPHYR_LOG("enter\n");
489 __GLX_SWAP_SHORT(&a_req
->length
);
490 __GLX_SWAP_INT(&a_req
->context
);
491 __GLX_SWAP_INT(&a_req
->fbconfig
);
492 __GLX_SWAP_INT(&a_req
->screen
);
493 __GLX_SWAP_INT(&a_req
->renderType
);
494 __GLX_SWAP_INT(&a_req
->shareList
);
497 EPHYR_LOG("context creation requested. localid:%d, "
498 "screen:%d, fbconfig:%d, renderType:%d, direct:%d\n",
499 (int) a_req
->context
, (int) a_req
->screen
,
500 (int) a_req
->fbconfig
, (int) a_req
->renderType
,
501 (int) a_req
->isDirect
);
503 if (!ephyrHostGLXCreateContext(a_req
->screen
,
506 a_req
->shareList
, a_req
->renderType
,
507 a_req
->isDirect
, X_GLXCreateNewContext
)) {
508 EPHYR_LOG_ERROR("ephyrHostGLXCreateNewContext() failed\n");
513 EPHYR_LOG("leave\n");
518 ephyrGLXCreateContext(__GLXclientState
* cl
, GLbyte
* pc
)
520 xGLXCreateContextReq
*req
= (xGLXCreateContextReq
*) pc
;
522 return ephyrGLXCreateContextReal(req
, FALSE
);
526 ephyrGLXCreateContextSwap(__GLXclientState
* cl
, GLbyte
* pc
)
528 xGLXCreateContextReq
*req
= (xGLXCreateContextReq
*) pc
;
530 return ephyrGLXCreateContextReal(req
, TRUE
);
534 ephyrGLXCreateNewContext(__GLXclientState
* cl
, GLbyte
* pc
)
536 xGLXCreateNewContextReq
*req
= (xGLXCreateNewContextReq
*) pc
;
538 return ephyrGLXCreateNewContextReal(req
, FALSE
);
542 ephyrGLXCreateNewContextSwap(__GLXclientState
* cl
, GLbyte
* pc
)
544 xGLXCreateNewContextReq
*req
= (xGLXCreateNewContextReq
*) pc
;
546 return ephyrGLXCreateNewContextReal(req
, TRUE
);
550 ephyrGLXDestroyContextReal(__GLXclientState
* a_cl
,
551 GLbyte
* a_pc
, Bool a_do_swap
)
553 int res
= BadImplementation
;
554 ClientPtr client
= a_cl
->client
;
555 xGLXDestroyContextReq
*req
= (xGLXDestroyContextReq
*) a_pc
;
557 EPHYR_LOG("enter. id:%d\n", (int) req
->context
);
558 if (!ephyrHostDestroyContext(req
->context
)) {
559 EPHYR_LOG_ERROR("ephyrHostDestroyContext() failed\n");
560 client
->errorValue
= req
->context
;
566 EPHYR_LOG("leave\n");
571 ephyrGLXDestroyContext(__GLXclientState
* a_cl
, GLbyte
* a_pc
)
573 return ephyrGLXDestroyContextReal(a_cl
, a_pc
, FALSE
);
577 ephyrGLXDestroyContextSwap(__GLXclientState
* a_cl
, GLbyte
* a_pc
)
579 return ephyrGLXDestroyContextReal(a_cl
, a_pc
, TRUE
);
583 ephyrGLXMakeCurrentReal(__GLXclientState
* a_cl
, GLXDrawable write
,
584 GLXDrawable read
, GLXContextTag ctx
,
585 GLXContextTag old_ctx
, Bool a_do_swap
)
587 int res
= BadImplementation
;
588 xGLXMakeCurrentReply reply
;
589 DrawablePtr drawableR
= NULL
, drawableW
= NULL
;
590 GLXContextTag new_ctx
= 0;
592 EPHYR_LOG("enter\n");
593 res
= dixLookupDrawable(&drawableW
, write
, a_cl
->client
, 0, DixReadAccess
);
594 EPHYR_RETURN_VAL_IF_FAIL(drawableW
, BadValue
);
595 EPHYR_RETURN_VAL_IF_FAIL(drawableW
->pScreen
, BadValue
);
596 EPHYR_LOG("screen nummber requested:%d\n", drawableW
->pScreen
->myNum
);
599 res
= dixLookupDrawable(&drawableR
, read
, a_cl
->client
, 0,
601 EPHYR_RETURN_VAL_IF_FAIL(drawableR
, BadValue
);
602 EPHYR_RETURN_VAL_IF_FAIL(drawableR
->pScreen
, BadValue
);
605 drawableR
= drawableW
;
608 if (!ephyrHostGLXMakeCurrent(hostx_get_window(drawableW
->pScreen
->myNum
),
609 hostx_get_window(drawableR
->pScreen
->myNum
),
610 ctx
, old_ctx
, (int *) &new_ctx
)) {
611 EPHYR_LOG_ERROR("ephyrHostGLXMakeCurrent() failed\n");
614 reply
= (xGLXMakeCurrentReply
) {
616 .sequenceNumber
= a_cl
->client
->sequence
,
618 .contextTag
= new_ctx
621 __GLX_DECLARE_SWAP_VARIABLES
;
622 __GLX_SWAP_SHORT(&reply
.sequenceNumber
);
623 __GLX_SWAP_INT(&reply
.length
);
624 __GLX_SWAP_INT(&reply
.contextTag
);
626 WriteToClient(a_cl
->client
, sz_xGLXMakeCurrentReply
, &reply
);
630 EPHYR_LOG("leave\n");
635 ephyrGLXMakeCurrent(__GLXclientState
* a_cl
, GLbyte
* a_pc
)
637 xGLXMakeCurrentReq
*req
= (xGLXMakeCurrentReq
*) a_pc
;
638 return ephyrGLXMakeCurrentReal(a_cl
, req
->drawable
, req
->drawable
,
639 req
->context
, req
->oldContextTag
, FALSE
);
643 ephyrGLXMakeCurrentSwap(__GLXclientState
* a_cl
, GLbyte
* a_pc
)
645 xGLXMakeCurrentReq
*req
= (xGLXMakeCurrentReq
*) a_pc
;
646 __GLX_DECLARE_SWAP_VARIABLES
;
648 __GLX_SWAP_INT(&req
->drawable
);
649 __GLX_SWAP_INT(&req
->context
);
650 __GLX_SWAP_INT(&req
->oldContextTag
);
652 return ephyrGLXMakeCurrentReal(a_cl
, req
->drawable
, req
->drawable
,
653 req
->context
, req
->oldContextTag
, TRUE
);
657 ephyrGLXMakeCurrentReadSGI(__GLXclientState
* a_cl
, GLbyte
* a_pc
)
659 xGLXMakeCurrentReadSGIReq
*req
= (xGLXMakeCurrentReadSGIReq
*) a_pc
;
661 return ephyrGLXMakeCurrentReal(a_cl
, req
->drawable
, req
->readable
,
662 req
->context
, req
->oldContextTag
, FALSE
);
666 ephyrGLXMakeCurrentReadSGISwap(__GLXclientState
* a_cl
, GLbyte
* a_pc
)
668 xGLXMakeCurrentReadSGIReq
*req
= (xGLXMakeCurrentReadSGIReq
*) a_pc
;
669 __GLX_DECLARE_SWAP_VARIABLES
;
671 __GLX_SWAP_INT(&req
->drawable
);
672 __GLX_SWAP_INT(&req
->readable
);
673 __GLX_SWAP_INT(&req
->context
);
674 __GLX_SWAP_INT(&req
->oldContextTag
);
676 return ephyrGLXMakeCurrentReal(a_cl
, req
->drawable
, req
->readable
,
677 req
->context
, req
->oldContextTag
, TRUE
);
681 ephyrGLXMakeContextCurrent(__GLXclientState
* a_cl
, GLbyte
* a_pc
)
683 xGLXMakeContextCurrentReq
*req
= (xGLXMakeContextCurrentReq
*) a_pc
;
685 return ephyrGLXMakeCurrentReal(a_cl
, req
->drawable
, req
->readdrawable
,
686 req
->context
, req
->oldContextTag
, FALSE
);
690 ephyrGLXMakeContextCurrentSwap(__GLXclientState
* a_cl
, GLbyte
* a_pc
)
692 xGLXMakeContextCurrentReq
*req
= (xGLXMakeContextCurrentReq
*) a_pc
;
693 __GLX_DECLARE_SWAP_VARIABLES
;
695 __GLX_SWAP_INT(&req
->drawable
);
696 __GLX_SWAP_INT(&req
->readdrawable
);
697 __GLX_SWAP_INT(&req
->context
);
698 __GLX_SWAP_INT(&req
->oldContextTag
);
700 return ephyrGLXMakeCurrentReal(a_cl
, req
->drawable
, req
->readdrawable
,
701 req
->context
, req
->oldContextTag
, TRUE
);
705 ephyrGLXGetStringReal(__GLXclientState
* a_cl
, GLbyte
* a_pc
, Bool a_do_swap
)
707 ClientPtr client
= NULL
;
708 int context_tag
= 0, name
= 0, res
= BadImplementation
, length
= 0;
711 __GLX_DECLARE_SWAP_VARIABLES
;
713 EPHYR_RETURN_VAL_IF_FAIL(a_cl
&& a_pc
, BadValue
);
715 EPHYR_LOG("enter\n");
717 client
= a_cl
->client
;
720 __GLX_SWAP_INT(a_pc
+ 4);
721 __GLX_SWAP_INT(a_pc
+ __GLX_SINGLE_HDR_SIZE
);
723 context_tag
= __GLX_GET_SINGLE_CONTEXT_TAG(a_pc
);
724 a_pc
+= __GLX_SINGLE_HDR_SIZE
;
725 name
= *(GLenum
*) (a_pc
+ 0);
726 EPHYR_LOG("context_tag:%d, name:%d\n", context_tag
, name
);
727 if (!ephyrHostGLXGetString(context_tag
, name
, &string
)) {
728 EPHYR_LOG_ERROR("failed to get string from server\n");
732 length
= strlen(string
) + 1;
733 EPHYR_LOG("got string:'%s', size:%d\n", string
, length
);
736 EPHYR_LOG("got string: string (null)\n");
738 __GLX_BEGIN_REPLY(length
);
739 __GLX_PUT_SIZE(length
);
742 __GLX_SWAP_REPLY_SIZE();
743 __GLX_SWAP_REPLY_HEADER();
745 WriteToClient(client
, length
, string
);
749 EPHYR_LOG("leave\n");
754 ephyrGLXGetString(__GLXclientState
* a_cl
, GLbyte
* a_pc
)
756 return ephyrGLXGetStringReal(a_cl
, a_pc
, FALSE
);
760 ephyrGLXGetStringSwap(__GLXclientState
* a_cl
, GLbyte
* a_pc
)
762 return ephyrGLXGetStringReal(a_cl
, a_pc
, TRUE
);
766 ephyrGLXGetIntegervReal(__GLXclientState
* a_cl
, GLbyte
* a_pc
, Bool a_do_swap
)
768 int res
= BadImplementation
;
769 xGLXSingleReq
*const req
= (xGLXSingleReq
*) a_pc
;
772 GLint answer_buf_room
[200];
775 EPHYR_LOG("enter\n");
777 a_pc
+= __GLX_SINGLE_HDR_SIZE
;
779 int_name
= *(GLenum
*) (a_pc
+ 0);
780 if (!ephyrHostGetIntegerValue(req
->contextTag
, int_name
, &value
)) {
781 EPHYR_LOG_ERROR("ephyrHostGetIntegerValue() failed\n");
784 buf
= __glXGetAnswerBuffer(a_cl
, sizeof(value
),
785 answer_buf_room
, sizeof(answer_buf_room
), 4);
788 EPHYR_LOG_ERROR("failed to allocate reply buffer\n");
792 __glXSendReply(a_cl
->client
, buf
, 1, sizeof(value
), GL_FALSE
, 0);
796 EPHYR_LOG("leave\n");
801 ephyrGLXGetIntegerv(__GLXclientState
* a_cl
, GLbyte
* a_pc
)
803 return ephyrGLXGetIntegervReal(a_cl
, a_pc
, FALSE
);
807 ephyrGLXGetIntegervSwap(__GLXclientState
* a_cl
, GLbyte
* a_pc
)
809 return ephyrGLXGetIntegervReal(a_cl
, a_pc
, TRUE
);
813 ephyrGLXIsDirectReal(__GLXclientState
* a_cl
, GLbyte
* a_pc
, Bool a_do_swap
)
815 int res
= BadImplementation
;
816 ClientPtr client
= a_cl
->client
;
817 xGLXIsDirectReq
*req
= (xGLXIsDirectReq
*) a_pc
;
818 xGLXIsDirectReply reply
;
821 EPHYR_RETURN_VAL_IF_FAIL(a_cl
&& a_pc
, FALSE
);
823 EPHYR_LOG("enter\n");
825 if (!ephyrHostIsContextDirect(req
->context
, (int *) &is_direct
)) {
826 EPHYR_LOG_ERROR("ephyrHostIsContextDirect() failed\n");
829 reply
= (xGLXIsDirectReply
) {
831 .sequenceNumber
= client
->sequence
,
833 .isDirect
= is_direct
836 WriteToClient(client
, sz_xGLXIsDirectReply
, &reply
);
840 EPHYR_LOG("leave\n");
845 ephyrGLXIsDirect(__GLXclientState
* a_cl
, GLbyte
* a_pc
)
847 return ephyrGLXIsDirectReal(a_cl
, a_pc
, FALSE
);
851 ephyrGLXIsDirectSwap(__GLXclientState
* a_cl
, GLbyte
* a_pc
)
853 return ephyrGLXIsDirectReal(a_cl
, a_pc
, TRUE
);