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>
33 #ifdef HAVE_DIX_CONFIG_H
34 #include <dix-config.h>
37 #include "glxserver.h"
38 #include "glxbyteorder.h"
40 #include "singlesize.h"
42 #include "indirect_size_get.h"
43 #include "indirect_dispatch.h"
44 #include "glapitable.h"
48 #include "glapioffsets.h"
50 static int DoGetProgramString(struct __GLXclientStateRec
*cl
, GLbyte
*pc
,
51 unsigned get_programiv_offset
, unsigned get_program_string_offset
,
55 * Handle both types of glGetProgramString calls.
57 * This single function handles both \c glGetProgramStringARB and
58 * \c glGetProgramStringNV. The dispatch offsets for the functions to use
59 * for \c glGetProgramivARB and \c glGetProgramStringARB are passed in by the
60 * caller. These can be the offsets of either the ARB versions or the NV
63 int DoGetProgramString(struct __GLXclientStateRec
*cl
, GLbyte
*pc
,
64 unsigned get_programiv_offset
,
65 unsigned get_program_string_offset
,
68 xGLXVendorPrivateWithReplyReq
* const req
=
69 (xGLXVendorPrivateWithReplyReq
*) pc
;
71 __GLXcontext
* const cx
= __glXForceCurrent(cl
, req
->contextTag
, & error
);
72 ClientPtr client
= cl
->client
;
75 pc
+= __GLX_VENDPRIV_HDR_SIZE
;
80 char *answer
= NULL
, answerBuffer
[200];
83 target
= (GLenum
) bswap_32(*(int *)(pc
+ 0));
84 pname
= (GLenum
) bswap_32(*(int *)(pc
+ 4));
87 target
= *(GLenum
*)(pc
+ 0);
88 pname
= *(GLuint
*)(pc
+ 4);
91 /* The value of the GL_PROGRAM_LENGTH_ARB and GL_PROGRAM_LENGTH_NV
92 * enumerants is the same.
94 CALL_by_offset(GET_DISPATCH(),
95 (void (GLAPIENTRYP
)(GLuint
, GLenum
, GLint
*)),
97 (target
, GL_PROGRAM_LENGTH_ARB
, &compsize
));
100 __GLX_GET_ANSWER_BUFFER(answer
,cl
,compsize
,1);
101 __glXClearErrorOccured();
103 CALL_by_offset(GET_DISPATCH(),
104 (void (GLAPIENTRYP
)(GLuint
, GLenum
, GLubyte
*)),
105 get_program_string_offset
,
106 (target
, pname
, answer
));
109 if (__glXErrorOccured()) {
110 __GLX_BEGIN_REPLY(0);
113 __GLX_BEGIN_REPLY(compsize
);
114 ((xGLXGetTexImageReply
*)&__glXReply
)->width
= compsize
;
116 __GLX_SEND_VOID_ARRAY(compsize
);
125 int __glXDisp_GetProgramStringARB(struct __GLXclientStateRec
*cl
, GLbyte
*pc
)
127 return DoGetProgramString(cl
, pc
, _gloffset_GetProgramivARB
,
128 _gloffset_GetProgramStringARB
, False
);
132 int __glXDispSwap_GetProgramStringARB(struct __GLXclientStateRec
*cl
, GLbyte
*pc
)
134 return DoGetProgramString(cl
, pc
, _gloffset_GetProgramivARB
,
135 _gloffset_GetProgramStringARB
, True
);
139 int __glXDisp_GetProgramStringNV(struct __GLXclientStateRec
*cl
, GLbyte
*pc
)
141 return DoGetProgramString(cl
, pc
, _gloffset_GetProgramivNV
,
142 _gloffset_GetProgramStringNV
, False
);
146 int __glXDispSwap_GetProgramStringNV(struct __GLXclientStateRec
*cl
, GLbyte
*pc
)
148 return DoGetProgramString(cl
, pc
, _gloffset_GetProgramivNV
,
149 _gloffset_GetProgramStringNV
, True
);