2 * (C) Copyright IBM Corporation 2005, 2006
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, sub license,
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 and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19 * THE COPYRIGHT HOLDERS, THE AUTHORS, AND/OR THEIR SUPPLIERS BE LIABLE FOR
20 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
22 * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 * \file indirect_program.c
27 * Hand-coded routines needed to support programmable pipeline extensions.
29 * \author Ian Romanick <idr@us.ibm.com>
32 #ifdef HAVE_DIX_CONFIG_H
33 #include <dix-config.h>
36 #include "glxserver.h"
37 #include "glxbyteorder.h"
39 #include "singlesize.h"
41 #include "indirect_size_get.h"
42 #include "indirect_dispatch.h"
45 * Handle both types of glGetProgramString calls.
48 DoGetProgramString(struct __GLXclientStateRec
*cl
, GLbyte
* pc
,
49 PFNGLGETPROGRAMIVARBPROC get_programiv
,
50 PFNGLGETPROGRAMSTRINGARBPROC get_program_string
,
53 xGLXVendorPrivateWithReplyReq
*const req
=
54 (xGLXVendorPrivateWithReplyReq
*) pc
;
56 __GLXcontext
*const cx
= __glXForceCurrent(cl
, req
->contextTag
, &error
);
57 ClientPtr client
= cl
->client
;
59 pc
+= __GLX_VENDPRIV_HDR_SIZE
;
64 char *answer
= NULL
, answerBuffer
[200];
67 target
= (GLenum
) bswap_32(*(int *) (pc
+ 0));
68 pname
= (GLenum
) bswap_32(*(int *) (pc
+ 4));
71 target
= *(GLenum
*) (pc
+ 0);
72 pname
= *(GLuint
*) (pc
+ 4);
75 /* The value of the GL_PROGRAM_LENGTH_ARB and GL_PROGRAM_LENGTH_NV
76 * enumerants is the same.
78 get_programiv(target
, GL_PROGRAM_LENGTH_ARB
, &compsize
);
81 __GLX_GET_ANSWER_BUFFER(answer
, cl
, compsize
, 1);
82 __glXClearErrorOccured();
84 get_program_string(target
, pname
, (GLubyte
*) answer
);
87 if (__glXErrorOccured()) {
92 __GLX_BEGIN_REPLY(compsize
);
93 ((xGLXGetTexImageReply
*) &__glXReply
)->width
= compsize
;
95 __GLX_SEND_VOID_ARRAY(compsize
);
105 __glXDisp_GetProgramStringARB(struct __GLXclientStateRec
*cl
, GLbyte
* pc
)
107 PFNGLGETPROGRAMIVARBPROC get_program
=
108 __glGetProcAddress("glGetProgramivARB");
109 PFNGLGETPROGRAMSTRINGARBPROC get_program_string
=
110 __glGetProcAddress("glGetProgramStringARB");
112 return DoGetProgramString(cl
, pc
, get_program
, get_program_string
, False
);
116 __glXDispSwap_GetProgramStringARB(struct __GLXclientStateRec
*cl
, GLbyte
* pc
)
118 PFNGLGETPROGRAMIVARBPROC get_program
=
119 __glGetProcAddress("glGetProgramivARB");
120 PFNGLGETPROGRAMSTRINGARBPROC get_program_string
=
121 __glGetProcAddress("glGetProgramStringARB");
123 return DoGetProgramString(cl
, pc
, get_program
, get_program_string
, True
);
127 __glXDisp_GetProgramStringNV(struct __GLXclientStateRec
*cl
, GLbyte
* pc
)
129 PFNGLGETPROGRAMIVARBPROC get_program
=
130 __glGetProcAddress("glGetProgramivARB");
131 PFNGLGETPROGRAMSTRINGARBPROC get_program_string
=
132 __glGetProcAddress("glGetProgramStringARB");
134 return DoGetProgramString(cl
, pc
, get_program
, get_program_string
, False
);
138 __glXDispSwap_GetProgramStringNV(struct __GLXclientStateRec
*cl
, GLbyte
* pc
)
140 PFNGLGETPROGRAMIVARBPROC get_program
=
141 __glGetProcAddress("glGetProgramivARB");
142 PFNGLGETPROGRAMSTRINGARBPROC get_program_string
=
143 __glGetProcAddress("glGetProgramStringARB");
145 return DoGetProgramString(cl
, pc
, get_program
, get_program_string
, True
);