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"
43 #include "glapitable.h"
47 #include "glapioffsets.h"
49 static int DoGetProgramString(struct __GLXclientStateRec *cl, GLbyte *pc,
50 unsigned get_programiv_offset, unsigned get_program_string_offset,
54 * Handle both types of glGetProgramString calls.
56 * This single function handles both \c glGetProgramStringARB and
57 * \c glGetProgramStringNV. The dispatch offsets for the functions to use
58 * for \c glGetProgramivARB and \c glGetProgramStringARB are passed in by the
59 * caller. These can be the offsets of either the ARB versions or the NV
62 int DoGetProgramString(struct __GLXclientStateRec *cl, GLbyte *pc,
63 unsigned get_programiv_offset,
64 unsigned get_program_string_offset,
67 xGLXVendorPrivateWithReplyReq * const req =
68 (xGLXVendorPrivateWithReplyReq *) pc;
70 __GLXcontext * const cx = __glXForceCurrent(cl, req->contextTag, & error);
71 ClientPtr client = cl->client;
74 pc += __GLX_VENDPRIV_HDR_SIZE;
79 char *answer = NULL, answerBuffer[200];
82 target = (GLenum) bswap_32(*(int *)(pc + 0));
83 pname = (GLenum) bswap_32(*(int *)(pc + 4));
86 target = *(GLenum *)(pc + 0);
87 pname = *(GLuint *)(pc + 4);
90 /* The value of the GL_PROGRAM_LENGTH_ARB and GL_PROGRAM_LENGTH_NV
91 * enumerants is the same.
93 CALL_by_offset(GET_DISPATCH(),
94 (void (GLAPIENTRYP)(GLuint, GLenum, GLint *)),
96 (target, GL_PROGRAM_LENGTH_ARB, &compsize));
99 __GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1);
100 __glXClearErrorOccured();
102 CALL_by_offset(GET_DISPATCH(),
103 (void (GLAPIENTRYP)(GLuint, GLenum, GLubyte *)),
104 get_program_string_offset,
105 (target, pname, (GLubyte *)answer));
108 if (__glXErrorOccured()) {
109 __GLX_BEGIN_REPLY(0);
112 __GLX_BEGIN_REPLY(compsize);
113 ((xGLXGetTexImageReply *)&__glXReply)->width = compsize;
115 __GLX_SEND_VOID_ARRAY(compsize);
124 int __glXDisp_GetProgramStringARB(struct __GLXclientStateRec *cl, GLbyte *pc)
126 return DoGetProgramString(cl, pc, _gloffset_GetProgramivARB,
127 _gloffset_GetProgramStringARB, False);
131 int __glXDispSwap_GetProgramStringARB(struct __GLXclientStateRec *cl, GLbyte *pc)
133 return DoGetProgramString(cl, pc, _gloffset_GetProgramivARB,
134 _gloffset_GetProgramStringARB, True);
138 int __glXDisp_GetProgramStringNV(struct __GLXclientStateRec *cl, GLbyte *pc)
140 return DoGetProgramString(cl, pc, _gloffset_GetProgramivNV,
141 _gloffset_GetProgramStringNV, False);
145 int __glXDispSwap_GetProgramStringNV(struct __GLXclientStateRec *cl, GLbyte *pc)
147 return DoGetProgramString(cl, pc, _gloffset_GetProgramivNV,
148 _gloffset_GetProgramStringNV, True);