Finish support for GL_ARB_texture_compression.

Fill in __glXDisp_GetCompressedTexImageARB and
__glXDispSwap_GetCompressedTexImageARB to finish support for
GL_ARB_texture_compression.  With this extension (and the related
compression extensions), the server-side GLX supports all of the
protocol for GL 1.4.  w00t!

The bad news is that this has received only minimal testing, and Mesa
does not contain any good tests for GL_ARB_texture_compression.
This commit is contained in:
Ian Romanick 2006-08-24 20:33:57 -07:00
parent cd2da4e41e
commit c33e39c86b
5 changed files with 141 additions and 11 deletions

View File

@ -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 \

View File

@ -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 "

View File

@ -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 <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"
#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
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;
}

View File

@ -515,8 +515,3 @@ int __glXDisp_GetColorTableSGI(__GLXclientState *cl, GLbyte *pc)
return Success;
}
int __glXDisp_GetCompressedTexImageARB(__GLXclientState *cl, GLbyte *pc)
{
return BadRequest;
}

View File

@ -576,8 +576,3 @@ int __glXDispSwap_GetColorTableSGI(__GLXclientState *cl, GLbyte *pc)
return Success;
}
int __glXDispSwap_GetCompressedTexImageARB(__GLXclientState *cl, GLbyte *pc)
{
return BadRequest;
}