diff --git a/GL/glx/Makefile.am b/GL/glx/Makefile.am index 4e21e5012..f8af30eb9 100644 --- a/GL/glx/Makefile.am +++ b/GL/glx/Makefile.am @@ -60,6 +60,7 @@ libglx_la_SOURCES = \ indirect_size_get.h \ indirect_table.c \ indirect_table.h \ + indirect_texture_compression.c \ indirect_util.c \ indirect_util.h \ render2.c \ diff --git a/GL/glx/glxscreens.c b/GL/glx/glxscreens.c index 763e55ed7..c94c27c82 100644 --- a/GL/glx/glxscreens.c +++ b/GL/glx/glxscreens.c @@ -45,7 +45,7 @@ #include "glxutil.h" #include "glxext.h" -const char GLServerVersion[] = "1.2"; +const char GLServerVersion[] = "1.4"; static const char GLServerExtensions[] = "GL_ARB_depth_texture " "GL_ARB_draw_buffers " @@ -59,6 +59,7 @@ static const char GLServerExtensions[] = "GL_ARB_shadow_ambient " "GL_ARB_texture_border_clamp " "GL_ARB_texture_cube_map " + "GL_ARB_texture_compression " "GL_ARB_texture_env_add " "GL_ARB_texture_env_combine " "GL_ARB_texture_env_crossbar " @@ -94,6 +95,8 @@ static const char GLServerExtensions[] = "GL_EXT_subtexture " "GL_EXT_texture " "GL_EXT_texture3D " + "GL_EXT_texture_compression_dxt1 " + "GL_EXT_texture_compression_s3tc " "GL_EXT_texture_edge_clamp " "GL_EXT_texture_env_add " "GL_EXT_texture_env_combine " @@ -104,6 +107,7 @@ static const char GLServerExtensions[] = "GL_EXT_texture_object " "GL_EXT_texture_rectangle " "GL_EXT_vertex_array " + "GL_3DFX_texture_compression_FXT1 " "GL_APPLE_packed_pixels " "GL_ATI_draw_buffers " "GL_ATI_texture_env_combine3 " @@ -120,9 +124,11 @@ static const char GLServerExtensions[] = "GL_NV_multisample_filter_hint " "GL_NV_point_sprite " "GL_NV_texgen_reflection " + "GL_NV_texture_compression_vtc " "GL_NV_texture_env_combine4 " "GL_NV_texture_expand_normal " "GL_NV_texture_rectangle " + "GL_OES_compressed_paletted_texture " "GL_SGI_color_matrix " "GL_SGI_color_table " "GL_SGIS_generate_mipmap " diff --git a/GL/glx/indirect_texture_compression.c b/GL/glx/indirect_texture_compression.c new file mode 100644 index 000000000..0c42ea034 --- /dev/null +++ b/GL/glx/indirect_texture_compression.c @@ -0,0 +1,133 @@ +/* + * (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 + * IBM, + * 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. + */ + +#define NEED_REPLIES +#ifdef HAVE_DIX_CONFIG_H +#include +#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" + +#ifdef __linux__ +#include +#elif defined(__OpenBSD__) +#include +#define bswap_16 __swap16 +#define bswap_32 __swap32 +#define bswap_64 __swap64 +#else +#include +#define bswap_16 bswap16 +#define bswap_32 bswap32 +#define bswap_64 bswap64 +#endif + +int __glXDisp_GetCompressedTexImageARB(struct __GLXclientStateRec *cl, GLbyte *pc) +{ + xGLXSingleReq * const req = (xGLXSingleReq *) pc; + int error; + __GLXcontext * const cx = __glXForceCurrent( cl, req->contextTag, & error ); + ClientPtr client = cl->client; + + + pc += __GLX_SINGLE_HDR_SIZE; + if ( cx != NULL ) { + const GLenum target = *(GLenum *)(pc + 0); + const GLint level = *(GLint *)(pc + 4); + GLint compsize = 0; + char *answer, answerBuffer[200]; + + CALL_GetTexLevelParameteriv(GET_DISPATCH(), (target, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &compsize)); + + if ( compsize != 0 ) { + __GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1); + __glXClearErrorOccured(); + CALL_GetCompressedTexImageARB(GET_DISPATCH(), (target, level, 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 __glXDispSwap_GetCompressedTexImageARB(struct __GLXclientStateRec *cl, GLbyte *pc) +{ + xGLXSingleReq * const req = (xGLXSingleReq *) pc; + int error; + __GLXcontext * const cx = __glXForceCurrent( cl, bswap_32( req->contextTag ), & error ); + ClientPtr client = cl->client; + + + pc += __GLX_SINGLE_HDR_SIZE; + if ( cx != NULL ) { + const GLenum target = (GLenum) bswap_32( *(int *)(pc + 0) ); + const GLint level = (GLint ) bswap_32( *(int *)(pc + 4) ); + GLint compsize = 0; + char *answer, answerBuffer[200]; + + CALL_GetTexLevelParameteriv(GET_DISPATCH(), (target, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &compsize)); + + if ( compsize != 0 ) { + __GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1); + __glXClearErrorOccured(); + CALL_GetCompressedTexImageARB(GET_DISPATCH(), (target, level, 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; +} diff --git a/GL/glx/singlepix.c b/GL/glx/singlepix.c index 62588b0d0..3f76e5e62 100644 --- a/GL/glx/singlepix.c +++ b/GL/glx/singlepix.c @@ -515,8 +515,3 @@ int __glXDisp_GetColorTableSGI(__GLXclientState *cl, GLbyte *pc) return Success; } - -int __glXDisp_GetCompressedTexImageARB(__GLXclientState *cl, GLbyte *pc) -{ - return BadRequest; -} diff --git a/GL/glx/singlepixswap.c b/GL/glx/singlepixswap.c index d5510b9c0..c2e06d13d 100644 --- a/GL/glx/singlepixswap.c +++ b/GL/glx/singlepixswap.c @@ -576,8 +576,3 @@ int __glXDispSwap_GetColorTableSGI(__GLXclientState *cl, GLbyte *pc) return Success; } - -int __glXDispSwap_GetCompressedTexImageARB(__GLXclientState *cl, GLbyte *pc) -{ - return BadRequest; -}