diff options
author | Ian Romanick <idr@umwelt.(none)> | 2006-08-25 12:05:16 -0700 |
---|---|---|
committer | Ian Romanick <idr@umwelt.(none)> | 2006-08-25 12:05:16 -0700 |
commit | e2d529963ed40b5f113cf82c17809d241cd4aac1 (patch) | |
tree | c002302de4eab9be3e7b1976ff2ad44b94902f41 /GL/glx | |
parent | c33e39c86be2010b169ffbd8adbe53b93222dc5f (diff) |
Enable vertex and fragment programs.
Implement glGetProgramStringARB and glGetProgramStringNV. With these
functions implemented, GL_ARB_{vertex,fragment}_program,
GL_NV_{vertex,fragment}_program, and related extensions can be enabled.
Diffstat (limited to 'GL/glx')
-rw-r--r-- | GL/glx/Makefile.am | 1 | ||||
-rw-r--r-- | GL/glx/glxscreens.c | 13 | ||||
-rw-r--r-- | GL/glx/indirect_program.c | 163 | ||||
-rw-r--r-- | GL/glx/single2.c | 10 | ||||
-rw-r--r-- | GL/glx/single2swap.c | 10 |
5 files changed, 176 insertions, 21 deletions
diff --git a/GL/glx/Makefile.am b/GL/glx/Makefile.am index f8af30eb9..339fbe04e 100644 --- a/GL/glx/Makefile.am +++ b/GL/glx/Makefile.am @@ -54,6 +54,7 @@ libglx_la_SOURCES = \ indirect_dispatch.c \ indirect_dispatch.h \ indirect_dispatch_swap.c \ + indirect_program.c \ indirect_reqsize.c \ indirect_reqsize.h \ indirect_size_get.c \ diff --git a/GL/glx/glxscreens.c b/GL/glx/glxscreens.c index c94c27c82..41e08aff2 100644 --- a/GL/glx/glxscreens.c +++ b/GL/glx/glxscreens.c @@ -49,6 +49,8 @@ const char GLServerVersion[] = "1.4"; static const char GLServerExtensions[] = "GL_ARB_depth_texture " "GL_ARB_draw_buffers " + "GL_ARB_fragment_program " + "GL_ARB_fragment_program_shadow " "GL_ARB_imaging " "GL_ARB_multisample " "GL_ARB_multitexture " @@ -58,8 +60,8 @@ static const char GLServerExtensions[] = "GL_ARB_shadow " "GL_ARB_shadow_ambient " "GL_ARB_texture_border_clamp " - "GL_ARB_texture_cube_map " "GL_ARB_texture_compression " + "GL_ARB_texture_cube_map " "GL_ARB_texture_env_add " "GL_ARB_texture_env_combine " "GL_ARB_texture_env_crossbar " @@ -67,6 +69,7 @@ static const char GLServerExtensions[] = "GL_ARB_texture_mirrored_repeat " "GL_ARB_texture_non_power_of_two " "GL_ARB_transpose_matrix " + "GL_ARB_vertex_program " "GL_ARB_window_pos " "GL_EXT_abgr " "GL_EXT_bgra " @@ -120,6 +123,9 @@ static const char GLServerExtensions[] = "GL_NV_blend_square " "GL_NV_depth_clamp " "GL_NV_fog_distance " + "GL_NV_fragment_program " + "GL_NV_fragment_program_option " + "GL_NV_fragment_program2 " "GL_NV_light_max_exponent " "GL_NV_multisample_filter_hint " "GL_NV_point_sprite " @@ -128,6 +134,11 @@ static const char GLServerExtensions[] = "GL_NV_texture_env_combine4 " "GL_NV_texture_expand_normal " "GL_NV_texture_rectangle " + "GL_NV_vertex_program " + "GL_NV_vertex_program1_1 " + "GL_NV_vertex_program2 " + "GL_NV_vertex_program2_option " + "GL_NV_vertex_program3 " "GL_OES_compressed_paletted_texture " "GL_SGI_color_matrix " "GL_SGI_color_table " diff --git a/GL/glx/indirect_program.c b/GL/glx/indirect_program.c new file mode 100644 index 000000000..d0fd3d135 --- /dev/null +++ b/GL/glx/indirect_program.c @@ -0,0 +1,163 @@ +/* + * (C) Copyright IBM Corporation 2005, 2006 + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sub license, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS, THE AUTHORS, AND/OR THEIR SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * \file indirect_program.c + * Hand-coded routines needed to support programmable pipeline extensions. + * + * \author Ian Romanick <idr@us.ibm.com> + */ + +#define NEED_REPLIES +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#include "glxserver.h" +#include "glxext.h" +#include "singlesize.h" +#include "unpack.h" +#include "indirect_size_get.h" +#include "indirect_dispatch.h" +#include "glapitable.h" +#include "glapi.h" +#include "glthread.h" +#include "dispatch.h" +#include "glapioffsets.h" + +#ifdef __linux__ +#include <byteswap.h> +#elif defined(__OpenBSD__) +#include <sys/endian.h> +#define bswap_16 __swap16 +#define bswap_32 __swap32 +#define bswap_64 __swap64 +#else +#include <sys/endian.h> +#define bswap_16 bswap16 +#define bswap_32 bswap32 +#define bswap_64 bswap64 +#endif + +static int DoGetProgramString(struct __GLXclientStateRec *cl, GLbyte *pc, + unsigned get_programiv_offset, unsigned get_program_string_offset, + Bool do_swap); + +/** + * Handle both types of glGetProgramString calls. + * + * This single function handles both \c glGetProgramStringARB and + * \c glGetProgramStringNV. The dispatch offsets for the functions to use + * for \c glGetProgramivARB and \c glGetProgramStringARB are passed in by the + * caller. These can be the offsets of either the ARB versions or the NV + * versions. + */ +int DoGetProgramString(struct __GLXclientStateRec *cl, GLbyte *pc, + unsigned get_programiv_offset, + unsigned get_program_string_offset, + Bool do_swap) +{ + xGLXVendorPrivateWithReplyReq * const req = + (xGLXVendorPrivateWithReplyReq *) pc; + int error; + __GLXcontext * const cx = __glXForceCurrent(cl, req->contextTag, & error); + ClientPtr client = cl->client; + + + pc += __GLX_VENDPRIV_HDR_SIZE; + if (cx != NULL) { + GLenum target; + GLenum pname; + GLint compsize = 0; + char *answer = NULL, answerBuffer[200]; + + if (do_swap) { + target = (GLenum) bswap_32(*(int *)(pc + 0)); + pname = (GLenum) bswap_32(*(int *)(pc + 4)); + } + else { + target = *(GLenum *)(pc + 0); + pname = *(GLuint *)(pc + 4); + } + + /* The value of the GL_PROGRAM_LENGTH_ARB and GL_PROGRAM_LENGTH_NV + * enumerants is the same. + */ + CALL_by_offset(GET_DISPATCH(), + (void (GLAPIENTRYP)(GLuint, GLenum, GLint *)), + get_programiv_offset, + (target, GL_PROGRAM_LENGTH_ARB, &compsize)); + + if (compsize != 0) { + __GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1); + __glXClearErrorOccured(); + + CALL_by_offset(GET_DISPATCH(), + (void (GLAPIENTRYP)(GLuint, GLenum, GLubyte *)), + get_program_string_offset, + (target, pname, answer)); + } + + if (__glXErrorOccured()) { + __GLX_BEGIN_REPLY(0); + __GLX_SEND_HEADER(); + } else { + __GLX_BEGIN_REPLY(compsize); + ((xGLXGetTexImageReply *)&__glXReply)->width = compsize; + __GLX_SEND_HEADER(); + __GLX_SEND_VOID_ARRAY(compsize); + } + + error = Success; + } + + return error; +} + +int __glXDisp_GetProgramStringARB(struct __GLXclientStateRec *cl, GLbyte *pc) +{ + return DoGetProgramString(cl, pc, _gloffset_GetProgramivARB, + _gloffset_GetProgramStringARB, False); +} + + +int __glXDispSwap_GetProgramStringARB(struct __GLXclientStateRec *cl, GLbyte *pc) +{ + return DoGetProgramString(cl, pc, _gloffset_GetProgramivARB, + _gloffset_GetProgramStringARB, True); +} + + +int __glXDisp_GetProgramStringNV(struct __GLXclientStateRec *cl, GLbyte *pc) +{ + return DoGetProgramString(cl, pc, _gloffset_GetProgramivNV, + _gloffset_GetProgramStringNV, False); +} + + +int __glXDispSwap_GetProgramStringNV(struct __GLXclientStateRec *cl, GLbyte *pc) +{ + return DoGetProgramString(cl, pc, _gloffset_GetProgramivNV, + _gloffset_GetProgramStringNV, True); +} diff --git a/GL/glx/single2.c b/GL/glx/single2.c index 357cd317e..3387af2a2 100644 --- a/GL/glx/single2.c +++ b/GL/glx/single2.c @@ -392,13 +392,3 @@ int __glXDisp_GetString(__GLXclientState *cl, GLbyte *pc) { return DoGetString(cl, pc, GL_FALSE); } - -int __glXDisp_GetProgramStringARB(__GLXclientState *cl, GLbyte *pc) -{ - return BadRequest; -} - -int __glXDisp_GetProgramStringNV(__GLXclientState *cl, GLbyte *pc) -{ - return BadRequest; -} diff --git a/GL/glx/single2swap.c b/GL/glx/single2swap.c index 6d5e5ce0d..41a42bb0f 100644 --- a/GL/glx/single2swap.c +++ b/GL/glx/single2swap.c @@ -270,13 +270,3 @@ int __glXDispSwap_GetString(__GLXclientState *cl, GLbyte *pc) { return DoGetString(cl, pc, GL_TRUE); } - -int __glXDispSwap_GetProgramStringARB(__GLXclientState *cl, GLbyte *pc) -{ - return BadRequest; -} - -int __glXDispSwap_GetProgramStringNV(__GLXclientState *cl, GLbyte *pc) -{ - return BadRequest; -} |