Unverified Commit c893ad65 authored by Mike Gabriel's avatar Mike Gabriel

Merge branch 'sunweaver-pr/drop-glx-ansic' into 3.6.x

parents b38d5b97 4e33fd4b
......@@ -31,31 +31,17 @@
* \author Ian Romanick <idr@us.ibm.com>
*/
#if defined(IN_MINI_GLX)
# include <stdlib.h>
# include <string.h>
#if defined(IN_MINI_GLX)
# include <GL/gl.h>
# include "GL/internal/dri_interface.h"
# include "imports.h"
# define __glXMemset memset
#else
# include <nx-X11/X.h>
# include <GL/glx.h>
# include "GL/glxint.h"
# ifdef XFree86Server
void *memset( void * ptr, int val, size_t size);
# include "GL/glx_ansic.h"
extern void * __glXMalloc( size_t size );
extern void __glXFree( void * ptr );
# define _mesa_malloc(b) __glXMalloc(b)
# define _mesa_free(m) __glXFree(m)
# else
# include <nx-X11/Xlibint.h>
# define __glXMemset memset
# define _mesa_malloc(b) Xmalloc(b)
# define _mesa_free(m) Xfree(m)
# endif /* XFree86Server */
#endif /* !defined(IN_MINI_GLX) */
#include "glcontextmodes.h"
......@@ -127,7 +113,7 @@ _gl_copy_visual_to_context_mode( __GLcontextModes * mode,
{
__GLcontextModes * const next = mode->next;
(void) __glXMemset( mode, 0, sizeof( __GLcontextModes ) );
(void) memset( mode, 0, sizeof( __GLcontextModes ) );
mode->next = next;
mode->visualID = config->vid;
......@@ -361,14 +347,14 @@ _gl_context_modes_create( unsigned count, size_t minimum_size )
next = & base;
for ( i = 0 ; i < count ; i++ ) {
*next = (__GLcontextModes *) _mesa_malloc( size );
*next = (__GLcontextModes *) malloc( size );
if ( *next == NULL ) {
_gl_context_modes_destroy( base );
base = NULL;
break;
}
(void) __glXMemset( *next, 0, size );
(void) memset( *next, 0, size );
(*next)->visualID = GLX_DONT_CARE;
(*next)->visualType = GLX_DONT_CARE;
(*next)->visualRating = GLX_NONE;
......@@ -402,7 +388,7 @@ _gl_context_modes_destroy( __GLcontextModes * modes )
while ( modes != NULL ) {
__GLcontextModes * const next = modes->next;
_mesa_free( modes );
free( modes );
modes = next;
}
}
......
......@@ -38,7 +38,6 @@
# include "resource.h"
# include "windowstr.h"
# include "gcstruct.h"
# include "GL/xf86glx.h"
# include "xf86glx_util.h"
#else
......
......@@ -28,7 +28,6 @@
#ifdef XFree86Server
# include "GL/xf86glx.h"
# include "xf86glx_util.h"
#elif defined(USE_XSHM)
# include <X11/extensions/XShm.h>
......
......@@ -109,18 +109,18 @@ _mesa_Hint( GLenum target, GLenum mode )
return;
FLUSH_VERTICES(ctx, _NEW_HINT);
ctx->Hint.GenerateMipmap = mode;
break;
/* GL_ARB_fragment_shader */
case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB:
if (!ctx->Extensions.ARB_fragment_shader) {
_mesa_error(ctx, GL_INVALID_ENUM, "glHint(target)");
return;
}
if (ctx->Hint.FragmentShaderDerivative == mode)
return;
FLUSH_VERTICES(ctx, _NEW_HINT);
ctx->Hint.FragmentShaderDerivative = mode;
break;
/* GL_ARB_fragment_shader */
case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB:
if (!ctx->Extensions.ARB_fragment_shader) {
_mesa_error(ctx, GL_INVALID_ENUM, "glHint(target)");
return;
}
if (ctx->Hint.FragmentShaderDerivative == mode)
return;
FLUSH_VERTICES(ctx, _NEW_HINT);
ctx->Hint.FragmentShaderDerivative = mode;
break;
default:
......@@ -148,6 +148,6 @@ void _mesa_init_hint( GLcontext * ctx )
ctx->Hint.Fog = GL_DONT_CARE;
ctx->Hint.ClipVolumeClipping = GL_DONT_CARE;
ctx->Hint.TextureCompression = GL_DONT_CARE;
ctx->Hint.GenerateMipmap = GL_DONT_CARE;
ctx->Hint.GenerateMipmap = GL_DONT_CARE;
ctx->Hint.FragmentShaderDerivative = GL_DONT_CARE;
}
......@@ -155,14 +155,14 @@ extern void GLAPIENTRY
_mesa_GetActiveAttribARB (GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *);
extern GLint GLAPIENTRY
_mesa_GetAttribLocationARB (GLhandleARB, const GLcharARB *);
_mesa_GetAttribLocationARB (GLhandleARB, const GLcharARB *);
#endif
extern void
extern void
_mesa_init_shaderobjects (GLcontext *ctx);
#endif
#endif
/*
* Mesa 3-D graphics library
* Version: 6.3
*
* Copyright (C) 2005 Brian Paul 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, sublicense,
* 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL 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.
*/
#ifndef SHADEROBJECTS_3DLABS_H
#define SHADEROBJECTS_3DLABS_H
#include "mtypes.h"
extern GLhandleARB
_mesa_3dlabs_create_shader_object (GLenum);
extern GLhandleARB
_mesa_3dlabs_create_program_object (void);
extern void
_mesa_init_shaderobjects_3dlabs (GLcontext *ctx);
#endif
/*
* Mesa 3-D graphics library
* Version: 6.3
*
* Copyright (C) 2005 Brian Paul 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, sublicense,
* 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL 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.
*/
#ifndef SHADEROBJECTS_3DLABS_H
#define SHADEROBJECTS_3DLABS_H
#include "mtypes.h"
extern GLhandleARB
_mesa_3dlabs_create_shader_object (GLenum);
extern GLhandleARB
_mesa_3dlabs_create_program_object (void);
extern void
_mesa_init_shaderobjects_3dlabs (GLcontext *ctx);
#endif
".syntax version_directive;\n"
"version_directive\n"
" version_directive_1 .and .loop version_directive_2;\n"
"version_directive_1\n"
" prior_optional_spaces .and optional_version_directive .and .true .emit $;\n"
"version_directive_2\n"
" prior_optional_spaces .and version_directive_body .and .true .emit $;\n"
"optional_version_directive\n"
" version_directive_body .or .true .emit 10 .emit 1;\n"
"version_directive_body\n"
" '#' .and optional_space .and \"version\" .and space .and version_number .and optional_space .and\n"
" new_line;\n"
"version_number\n"
" version_number_110;\n"
"version_number_110\n"
" leading_zeroes .and \"110\" .emit 10 .emit 1;\n"
"leading_zeroes\n"
" .loop zero;\n"
"zero\n"
" '0';\n"
"space\n"
" single_space .and .loop single_space;\n"
"optional_space\n"
" .loop single_space;\n"
"single_space\n"
" ' ' .or '\\t';\n"
"prior_optional_spaces\n"
" .loop prior_space;\n"
"prior_space\n"
" c_style_comment_block .or cpp_style_comment_block .or space .or new_line;\n"
"c_style_comment_block\n"
" '/' .and '*' .and c_style_comment_rest;\n"
"c_style_comment_rest\n"
" .loop c_style_comment_char_no_star .and c_style_comment_rest_1;\n"
"c_style_comment_rest_1\n"
" c_style_comment_end .or c_style_comment_rest_2;\n"
"c_style_comment_rest_2\n"
" '*' .and c_style_comment_rest;\n"
"c_style_comment_char_no_star\n"
" '\\x2B'-'\\xFF' .or '\\x01'-'\\x29';\n"
"c_style_comment_end\n"
" '*' .and '/';\n"
"cpp_style_comment_block\n"
" '/' .and '/' .and cpp_style_comment_block_1;\n"
"cpp_style_comment_block_1\n"
" cpp_style_comment_block_2 .or cpp_style_comment_block_3;\n"
"cpp_style_comment_block_2\n"
" .loop cpp_style_comment_char .and new_line;\n"
"cpp_style_comment_block_3\n"
" .loop cpp_style_comment_char;\n"
"cpp_style_comment_char\n"
" '\\x0E'-'\\xFF' .or '\\x01'-'\\x09' .or '\\x0B'-'\\x0C';\n"
"new_line\n"
" cr_lf .or lf_cr .or '\\n' .or '\\r';\n"
"cr_lf\n"
" '\\r' .and '\\n';\n"
"lf_cr\n"
" '\\n' .and '\\r';\n"
".string __string_filter;\n"
"__string_filter\n"
" .loop __identifier_char;\n"
"__identifier_char\n"
" 'a'-'z' .or 'A'-'Z' .or '_' .or '0'-'9';\n"
""
".syntax version_directive;\n"
"version_directive\n"
" version_directive_1 .and .loop version_directive_2;\n"
"version_directive_1\n"
" prior_optional_spaces .and optional_version_directive .and .true .emit $;\n"
"version_directive_2\n"
" prior_optional_spaces .and version_directive_body .and .true .emit $;\n"
"optional_version_directive\n"
" version_directive_body .or .true .emit 10 .emit 1;\n"
"version_directive_body\n"
" '#' .and optional_space .and \"version\" .and space .and version_number .and optional_space .and\n"
" new_line;\n"
"version_number\n"
" version_number_110;\n"
"version_number_110\n"
" leading_zeroes .and \"110\" .emit 10 .emit 1;\n"
"leading_zeroes\n"
" .loop zero;\n"
"zero\n"
" '0';\n"
"space\n"
" single_space .and .loop single_space;\n"
"optional_space\n"
" .loop single_space;\n"
"single_space\n"
" ' ' .or '\\t';\n"
"prior_optional_spaces\n"
" .loop prior_space;\n"
"prior_space\n"
" c_style_comment_block .or cpp_style_comment_block .or space .or new_line;\n"
"c_style_comment_block\n"
" '/' .and '*' .and c_style_comment_rest;\n"
"c_style_comment_rest\n"
" .loop c_style_comment_char_no_star .and c_style_comment_rest_1;\n"
"c_style_comment_rest_1\n"
" c_style_comment_end .or c_style_comment_rest_2;\n"
"c_style_comment_rest_2\n"
" '*' .and c_style_comment_rest;\n"
"c_style_comment_char_no_star\n"
" '\\x2B'-'\\xFF' .or '\\x01'-'\\x29';\n"
"c_style_comment_end\n"
" '*' .and '/';\n"
"cpp_style_comment_block\n"
" '/' .and '/' .and cpp_style_comment_block_1;\n"
"cpp_style_comment_block_1\n"
" cpp_style_comment_block_2 .or cpp_style_comment_block_3;\n"
"cpp_style_comment_block_2\n"
" .loop cpp_style_comment_char .and new_line;\n"
"cpp_style_comment_block_3\n"
" .loop cpp_style_comment_char;\n"
"cpp_style_comment_char\n"
" '\\x0E'-'\\xFF' .or '\\x01'-'\\x09' .or '\\x0B'-'\\x0C';\n"
"new_line\n"
" cr_lf .or lf_cr .or '\\n' .or '\\r';\n"
"cr_lf\n"
" '\\r' .and '\\n';\n"
"lf_cr\n"
" '\\n' .and '\\r';\n"
".string __string_filter;\n"
"__string_filter\n"
" .loop __identifier_char;\n"
"__identifier_char\n"
" 'a'-'z' .or 'A'-'Z' .or '_' .or '0'-'9';\n"
""
/*
* Mesa 3-D graphics library
* Version: 6.3
*
* Copyright (C) 2005 Brian Paul 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, sublicense,
* 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL 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.
*/
#if !defined SLANG_ASSEMBLE_H
#define SLANG_ASSEMBLE_H
#include "slang_compile.h"
#if defined __cplusplus
extern "C" {
#endif
typedef enum slang_assembly_type_
{
/* core */
slang_asm_none,
slang_asm_float_copy,
slang_asm_float_move,
slang_asm_float_push,
slang_asm_float_deref,
slang_asm_float_add,
slang_asm_float_multiply,
slang_asm_float_divide,
slang_asm_float_negate,
slang_asm_float_less,
slang_asm_float_equal,
slang_asm_float_to_int,
slang_asm_int_copy,
slang_asm_int_move,
slang_asm_int_push,
slang_asm_int_deref,
slang_asm_int_to_float,
slang_asm_int_to_addr,
slang_asm_bool_copy,
slang_asm_bool_move,
slang_asm_bool_push,
slang_asm_bool_deref,
slang_asm_addr_copy,
slang_asm_addr_push,
slang_asm_addr_deref,
slang_asm_addr_add,
slang_asm_addr_multiply,
slang_asm_jump,
slang_asm_jump_if_zero,
slang_asm_enter,
slang_asm_leave,
slang_asm_local_alloc,
slang_asm_local_free,
slang_asm_local_addr,
slang_asm_call,
slang_asm_return,
slang_asm_discard,
slang_asm_exit,
slang_asm__last
} slang_assembly_type;
typedef struct slang_assembly_
{
slang_assembly_type type;
GLfloat literal;
GLuint param[2];
} slang_assembly;
typedef struct slang_assembly_file_
{
slang_assembly *code;
unsigned int count;
} slang_assembly_file;
void slang_assembly_file_construct (slang_assembly_file *);
void slang_assembly_file_destruct (slang_assembly_file *);
int slang_assembly_file_push (slang_assembly_file *, slang_assembly_type);
int slang_assembly_file_push_label (slang_assembly_file *, slang_assembly_type, GLuint);
int slang_assembly_file_push_label2 (slang_assembly_file *, slang_assembly_type, GLuint, GLuint);
int slang_assembly_file_push_literal (slang_assembly_file *, slang_assembly_type, GLfloat);
typedef struct slang_assembly_flow_control_
{
unsigned int loop_start; /* for "continue" statement */
unsigned int loop_end; /* for "break" statement */
unsigned int function_end; /* for "return" statement */
} slang_assembly_flow_control;
typedef struct slang_assembly_name_space_
{
struct slang_function_scope_ *funcs;
struct slang_struct_scope_ *structs;
struct slang_variable_scope_ *vars;
} slang_assembly_name_space;
slang_function *_slang_locate_function (const char *name, slang_operation *params,
unsigned int num_params, slang_assembly_name_space *space);
int _slang_assemble_function (slang_assembly_file *, struct slang_function_ *,
slang_assembly_name_space *);
typedef struct slang_assembly_stack_info_
{
unsigned int swizzle_mask;
} slang_assembly_stack_info;
int _slang_cleanup_stack (slang_assembly_file *, slang_operation *, int ref,
slang_assembly_name_space *);
typedef struct slang_assembly_local_info_
{
unsigned int ret_size;
unsigned int addr_tmp;
unsigned int swizzle_tmp;
} slang_assembly_local_info;
int _slang_assemble_operation (slang_assembly_file *, struct slang_operation_ *, int reference,
slang_assembly_flow_control *, slang_assembly_name_space *, slang_assembly_local_info *,
slang_assembly_stack_info *);
void xxx_first (slang_assembly_file *);
void xxx_prolog (slang_assembly_file *, unsigned int);
#ifdef __cplusplus
}
#endif
#endif
/*
* Mesa 3-D graphics library
* Version: 6.3
*
* Copyright (C) 2005 Brian Paul 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, sublicense,
* 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL 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.
*/
#if !defined SLANG_ASSEMBLE_H
#define SLANG_ASSEMBLE_H
#include "slang_compile.h"
#if defined __cplusplus
extern "C" {
#endif
typedef enum slang_assembly_type_
{
/* core */
slang_asm_none,
slang_asm_float_copy,
slang_asm_float_move,
slang_asm_float_push,
slang_asm_float_deref,
slang_asm_float_add,
slang_asm_float_multiply,
slang_asm_float_divide,
slang_asm_float_negate,
slang_asm_float_less,
slang_asm_float_equal,
slang_asm_float_to_int,
slang_asm_int_copy,
slang_asm_int_move,
slang_asm_int_push,
slang_asm_int_deref,
slang_asm_int_to_float,
slang_asm_int_to_addr,
slang_asm_bool_copy,
slang_asm_bool_move,
slang_asm_bool_push,
slang_asm_bool_deref,
slang_asm_addr_copy,
slang_asm_addr_push,
slang_asm_addr_deref,
slang_asm_addr_add,
slang_asm_addr_multiply,
slang_asm_jump,
slang_asm_jump_if_zero,
slang_asm_enter,
slang_asm_leave,
slang_asm_local_alloc,
slang_asm_local_free,
slang_asm_local_addr,
slang_asm_call,
slang_asm_return,
slang_asm_discard,
slang_asm_exit,
slang_asm__last
} slang_assembly_type;
typedef struct slang_assembly_
{
slang_assembly_type type;
GLfloat literal;
GLuint param[2];
} slang_assembly;
typedef struct slang_assembly_file_
{
slang_assembly *code;
unsigned int count;
} slang_assembly_file;
void slang_assembly_file_construct (slang_assembly_file *);
void slang_assembly_file_destruct (slang_assembly_file *);
int slang_assembly_file_push (slang_assembly_file *, slang_assembly_type);
int slang_assembly_file_push_label (slang_assembly_file *, slang_assembly_type, GLuint);
int slang_assembly_file_push_label2 (slang_assembly_file *, slang_assembly_type, GLuint, GLuint);
int slang_assembly_file_push_literal (slang_assembly_file *, slang_assembly_type, GLfloat);
typedef struct slang_assembly_flow_control_
{
unsigned int loop_start; /* for "continue" statement */
unsigned int loop_end; /* for "break" statement */
unsigned int function_end; /* for "return" statement */
} slang_assembly_flow_control;
typedef struct slang_assembly_name_space_
{
struct slang_function_scope_ *funcs;
struct slang_struct_scope_ *structs;
struct slang_variable_scope_ *vars;
} slang_assembly_name_space;
slang_function *_slang_locate_function (const char *name, slang_operation *params,
unsigned int num_params, slang_assembly_name_space *space);
int _slang_assemble_function (slang_assembly_file *, struct slang_function_ *,
slang_assembly_name_space *);
typedef struct slang_assembly_stack_info_
{
unsigned int swizzle_mask;
} slang_assembly_stack_info;
int _slang_cleanup_stack (slang_assembly_file *, slang_operation *, int ref,
slang_assembly_name_space *);
typedef struct slang_assembly_local_info_
{
unsigned int ret_size;
unsigned int addr_tmp;
unsigned int swizzle_tmp;
} slang_assembly_local_info;
int _slang_assemble_operation (slang_assembly_file *, struct slang_operation_ *, int reference,
slang_assembly_flow_control *, slang_assembly_name_space *, slang_assembly_local_info *,
slang_assembly_stack_info *);
void xxx_first (slang_assembly_file *);
void xxx_prolog (slang_assembly_file *, unsigned int);
#ifdef __cplusplus
}
#endif
#endif
/*
* Mesa 3-D graphics library
* Version: 6.3
*
* Copyright (C) 2005 Brian Paul 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, sublicense,
* 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL 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.
*/
#if !defined SLANG_ASSEMBLE_ASSIGNMENT_H
#define SLANG_ASSEMBLE_ASSIGNMENT_H
#include "slang_assemble.h"
#if defined __cplusplus
extern "C" {
#endif
int _slang_assemble_assignment (slang_assembly_file *, slang_operation *,
slang_assembly_name_space *, slang_assembly_local_info *);
int _slang_assemble_assign (slang_assembly_file *, slang_operation *, const char *, int ref,
slang_assembly_name_space *, slang_assembly_local_info *);
#ifdef __cplusplus
}
#endif
#endif
/*
* Mesa 3-D graphics library
* Version: 6.3
*
* Copyright (C) 2005 Brian Paul 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, sublicense,
* 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL 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.
*/
#if !defined SLANG_ASSEMBLE_ASSIGNMENT_H
#define SLANG_ASSEMBLE_ASSIGNMENT_H
#include "slang_assemble.h"
#if defined __cplusplus
extern "C" {
#endif
int _slang_assemble_assignment (slang_assembly_file *, slang_operation *,
slang_assembly_name_space *, slang_assembly_local_info *);
int _slang_assemble_assign (slang_assembly_file *, slang_operation *, const char *, int ref,
slang_assembly_name_space *, slang_assembly_local_info *);
#ifdef __cplusplus
}
#endif
#endif
/*
* Mesa 3-D graphics library
* Version: 6.3
*
* Copyright (C) 2005 Brian Paul 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, sublicense,
* 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL 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.
*/
#if !defined SLANG_ASSEMBLE_CONDITIONAL_H
#define SLANG_ASSEMBLE_CONDITIONAL_H
#include "slang_assemble.h"
#if defined __cplusplus
extern "C" {
#endif
int _slang_assemble_logicaland (slang_assembly_file *file, slang_operation *op,
slang_assembly_flow_control *flow, slang_assembly_name_space *space,
slang_assembly_local_info *info);
int _slang_assemble_logicalor (slang_assembly_file *file, slang_operation *op,
slang_assembly_flow_control *flow, slang_assembly_name_space *space,
slang_assembly_local_info *info);
int _slang_assemble_select (slang_assembly_file *file, slang_operation *op,
slang_assembly_flow_control *flow, slang_assembly_name_space *space,
slang_assembly_local_info *info);
int _slang_assemble_for (slang_assembly_file *file, slang_operation *op,
slang_assembly_flow_control *flow, slang_assembly_name_space *space,
slang_assembly_local_info *info);
int _slang_assemble_do (slang_assembly_file *file, slang_operation *op,
slang_assembly_flow_control *flow, slang_assembly_name_space *space,
slang_assembly_local_info *info);
int _slang_assemble_while (slang_assembly_file *file, slang_operation *op,
slang_assembly_flow_control *flow, slang_assembly_name_space *space,
slang_assembly_local_info *info);
int _slang_assemble_if (slang_assembly_file *file, slang_operation *op,
slang_assembly_flow_control *flow, slang_assembly_name_space *space,
slang_assembly_local_info *info);
#ifdef __cplusplus
}
#endif
#endif
/*
* Mesa 3-D graphics library
* Version: 6.3
*
* Copyright (C) 2005 Brian Paul 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, sublicense,
* 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL 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.
*/
#if !defined SLANG_ASSEMBLE_CONDITIONAL_H
#define SLANG_ASSEMBLE_CONDITIONAL_H
#include "slang_assemble.h"
#if defined __cplusplus
extern "C" {
#endif
int _slang_assemble_logicaland (slang_assembly_file *file, slang_operation *op,
slang_assembly_flow_control *flow, slang_assembly_name_space *space,
slang_assembly_local_info *info);
int _slang_assemble_logicalor (slang_assembly_file *file, slang_operation *op,
slang_assembly_flow_control *flow, slang_assembly_name_space *space,
slang_assembly_local_info *info);
int _slang_assemble_select (slang_assembly_file *file, slang_operation *op,
slang_assembly_flow_control *flow, slang_assembly_name_space *space,
slang_assembly_local_info *info);
int _slang_assemble_for (slang_assembly_file *file, slang_operation *op,
slang_assembly_flow_control *flow, slang_assembly_name_space *space,
slang_assembly_local_info *info);
int _slang_assemble_do (slang_assembly_file *file, slang_operation *op,
slang_assembly_flow_control *flow, slang_assembly_name_space *space,
slang_assembly_local_info *info);
int _slang_assemble_while (slang_assembly_file *file, slang_operation *op,
slang_assembly_flow_control *flow, slang_assembly_name_space *space,
slang_assembly_local_info *info);
int _slang_assemble_if (slang_assembly_file *file, slang_operation *op,
slang_assembly_flow_control *flow, slang_assembly_name_space *space,
slang_assembly_local_info *info);
#ifdef __cplusplus
}
#endif
#endif
/*
* Mesa 3-D graphics library
* Version: 6.3
*
* Copyright (C) 2005 Brian Paul 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, sublicense,
* 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL 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.
*/
#if !defined SLANG_ASSEMBLE_CONSTRUCTOR_H
#define SLANG_ASSEMBLE_CONSTRUCTOR_H
#include "slang_assemble.h"
#include "slang_compile.h"
#if defined __cplusplus
extern "C" {
#endif
/*
holds a complete information about vector swizzle - the <swizzle> array contains
vector component sources indices, where 0 is "x", 1 is "y", ...
example: "xwz" --> { 3, { 0, 3, 2, n/u } }
*/
typedef struct slang_swizzle_
{
unsigned int num_components;
unsigned int swizzle[4];
} slang_swizzle;
/*
checks if a field selector is a general swizzle (an r-value swizzle with replicated
components or an l-value swizzle mask) for a vector
returns 1 if this is the case, <swz> is filled with swizzle information
returns 0 otherwise
*/
int _slang_is_swizzle (const char *field, unsigned int rows, slang_swizzle *swz);
/*
checks if a general swizzle is an l-value swizzle - these swizzles do not have
duplicated fields and they are specified in order
returns 1 if this is a swizzle mask
returns 0 otherwise
*/
int _slang_is_swizzle_mask (const slang_swizzle *swz, unsigned int rows);
/*
combines two swizzles to form single swizzle
example: "wzyx.yx" --> "zw"
*/
void _slang_multiply_swizzles (slang_swizzle *, const slang_swizzle *, const slang_swizzle *);
int _slang_assemble_constructor (slang_assembly_file *file, slang_operation *op,
slang_assembly_flow_control *flow, slang_assembly_name_space *space,
slang_assembly_local_info *info);
int _slang_assemble_constructor_from_swizzle (slang_assembly_file *file, const slang_swizzle *swz,
slang_type_specifier *spec, slang_type_specifier *master_spec, slang_assembly_local_info *info);
#ifdef __cplusplus
}
#endif
#endif
/*
* Mesa 3-D graphics library
* Version: 6.3
*
* Copyright (C) 2005 Brian Paul 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, sublicense,
* 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL 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.
*/
#if !defined SLANG_ASSEMBLE_CONSTRUCTOR_H
#define SLANG_ASSEMBLE_CONSTRUCTOR_H
#include "slang_assemble.h"
#include "slang_compile.h"
#if defined __cplusplus
extern "C" {
#endif
/*
holds a complete information about vector swizzle - the <swizzle> array contains
vector component sources indices, where 0 is "x", 1 is "y", ...
example: "xwz" --> { 3, { 0, 3, 2, n/u } }
*/
typedef struct slang_swizzle_
{
unsigned int num_components;
unsigned int swizzle[4];
} slang_swizzle;
/*
checks if a field selector is a general swizzle (an r-value swizzle with replicated
components or an l-value swizzle mask) for a vector
returns 1 if this is the case, <swz> is filled with swizzle information
returns 0 otherwise
*/
int _slang_is_swizzle (const char *field, unsigned int rows, slang_swizzle *swz);
/*
checks if a general swizzle is an l-value swizzle - these swizzles do not have
duplicated fields and they are specified in order
returns 1 if this is a swizzle mask
returns 0 otherwise
*/
int _slang_is_swizzle_mask (const slang_swizzle *swz, unsigned int rows);
/*
combines two swizzles to form single swizzle
example: "wzyx.yx" --> "zw"
*/
void _slang_multiply_swizzles (slang_swizzle *, const slang_swizzle *, const slang_swizzle *);
int _slang_assemble_constructor (slang_assembly_file *file, slang_operation *op,
slang_assembly_flow_control *flow, slang_assembly_name_space *space,
slang_assembly_local_info *info);
int _slang_assemble_constructor_from_swizzle (slang_assembly_file *file, const slang_swizzle *swz,
slang_type_specifier *spec, slang_type_specifier *master_spec, slang_assembly_local_info *info);
#ifdef __cplusplus
}
#endif
#endif
/*
* Mesa 3-D graphics library
* Version: 6.3
*
* Copyright (C) 2005 Brian Paul 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, sublicense,
* 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL 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.
*/
#if !defined SLANG_ASSEMBLE_TYPEINFO_H
#define SLANG_ASSEMBLE_TYPEINFO_H
#include "slang_assemble_constructor.h"
#include "slang_compile.h"
#if defined __cplusplus
extern "C" {
#endif
typedef struct slang_assembly_typeinfo_
{
int can_be_referenced;
int is_swizzled;
slang_swizzle swz;
slang_type_specifier spec;
} slang_assembly_typeinfo;
void slang_assembly_typeinfo_construct (slang_assembly_typeinfo *);
void slang_assembly_typeinfo_destruct (slang_assembly_typeinfo *);
/*
retrieves type information about an operation
returns 1 on success
returns 0 otherwise
*/
int _slang_typeof_operation (slang_operation *, slang_assembly_name_space *,
slang_assembly_typeinfo *);
/*
retrieves type of a function prototype, if one exists
returns 1 on success, even if the function was not found
returns 0 otherwise
*/
int _slang_typeof_function (const char *name, slang_operation *params, unsigned int num_params,
slang_assembly_name_space *space, slang_type_specifier *spec, int *exists);
#ifdef __cplusplus
}
#endif
#endif
/*
* Mesa 3-D graphics library
* Version: 6.3
*
* Copyright (C) 2005 Brian Paul 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, sublicense,
* 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL 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.
*/
#if !defined SLANG_ASSEMBLE_TYPEINFO_H
#define SLANG_ASSEMBLE_TYPEINFO_H
#include "slang_assemble_constructor.h"
#include "slang_compile.h"
#if defined __cplusplus
extern "C" {
#endif
typedef struct slang_assembly_typeinfo_
{
int can_be_referenced;
int is_swizzled;
slang_swizzle swz;
slang_type_specifier spec;
} slang_assembly_typeinfo;
void slang_assembly_typeinfo_construct (slang_assembly_typeinfo *);
void slang_assembly_typeinfo_destruct (slang_assembly_typeinfo *);
/*
retrieves type information about an operation
returns 1 on success
returns 0 otherwise
*/
int _slang_typeof_operation (slang_operation *, slang_assembly_name_space *,
slang_assembly_typeinfo *);
/*
retrieves type of a function prototype, if one exists
returns 1 on success, even if the function was not found
returns 0 otherwise
*/
int _slang_typeof_function (const char *name, slang_operation *params, unsigned int num_params,
slang_assembly_name_space *space, slang_type_specifier *spec, int *exists);
#ifdef __cplusplus
}
#endif
#endif
......@@ -68,8 +68,8 @@ typedef enum slang_type_specifier_type_
slang_spec_sampler2DShadow,
slang_spec_struct,
slang_spec_array
} slang_type_specifier_type;
} slang_type_specifier_type;
slang_type_specifier_type slang_type_specifier_type_from_string (const char *);
typedef struct slang_type_specifier_
......@@ -77,11 +77,11 @@ typedef struct slang_type_specifier_
slang_type_specifier_type type;
struct slang_struct_ *_struct; /* spec_struct */
struct slang_type_specifier_ *_array; /* spec_array */
} slang_type_specifier;
void slang_type_specifier_construct (slang_type_specifier *);
void slang_type_specifier_destruct (slang_type_specifier *);
int slang_type_specifier_copy (slang_type_specifier *, const slang_type_specifier *);
} slang_type_specifier;
void slang_type_specifier_construct (slang_type_specifier *);
void slang_type_specifier_destruct (slang_type_specifier *);
int slang_type_specifier_copy (slang_type_specifier *, const slang_type_specifier *);
int slang_type_specifier_equal (const slang_type_specifier *, const slang_type_specifier *);
typedef struct slang_fully_specified_type_
......@@ -171,9 +171,9 @@ typedef struct slang_operation_
float literal; /* bool, literal_int, literal_float */
char *identifier; /* asm, identifier, call, field */
slang_variable_scope *locals;
} slang_operation;
int slang_operation_construct_a (slang_operation *);
} slang_operation;
int slang_operation_construct_a (slang_operation *);
void slang_operation_destruct (slang_operation *);
typedef struct slang_variable_
......@@ -181,10 +181,10 @@ typedef struct slang_variable_
slang_fully_specified_type type;
char *name;
slang_operation *array_size; /* spec_array */
slang_operation *initializer;
slang_operation *initializer;
unsigned int address;
} slang_variable;
} slang_variable;
slang_variable *_slang_locate_variable (slang_variable_scope *scope, const char *name, int all);
typedef struct slang_struct_scope_
......@@ -192,8 +192,8 @@ typedef struct slang_struct_scope_
struct slang_struct_ *structs;
unsigned int num_structs;
struct slang_struct_scope_ *outer_scope;
} slang_struct_scope;
} slang_struct_scope;
struct slang_struct_ *slang_struct_scope_find (slang_struct_scope *, const char *, int);
typedef struct slang_struct_
......@@ -201,9 +201,9 @@ typedef struct slang_struct_
char *name;
slang_variable_scope *fields;
slang_struct_scope *structs;
} slang_struct;
int slang_struct_construct_a (slang_struct *);
} slang_struct;
int slang_struct_construct_a (slang_struct *);
int slang_struct_copy (slang_struct *, const slang_struct *);
typedef enum slang_function_kind_
......@@ -219,7 +219,7 @@ typedef struct slang_function_
slang_variable header;
slang_variable_scope *parameters;
unsigned int param_count;
slang_operation *body;
slang_operation *body;
unsigned int address;
} slang_function;
......
/*
* Mesa 3-D graphics library
* Version: 6.3
*
* Copyright (C) 2005 Brian Paul 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, sublicense,
* 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL 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.
*/
#if !defined SLANG_EXECUTE_H
#define SLANG_EXECUTE_H
#if defined __cplusplus
extern "C" {
#endif
#define SLANG_MACHINE_STACK_SIZE 1024
typedef struct slang_machine_
{
GLuint ip; /* instruction pointer, for flow control */
GLuint sp; /* stack pointer, for stack access */
GLuint bp; /* base pointer, for local variable access */
GLuint kill; /* discard the fragment */
GLuint exit; /* terminate the shader */
union stack_
{
GLfloat _float[SLANG_MACHINE_STACK_SIZE];
GLfloat *_floatp[SLANG_MACHINE_STACK_SIZE];
GLuint _addr[SLANG_MACHINE_STACK_SIZE];
GLuint *_addrp[SLANG_MACHINE_STACK_SIZE];
} stack;
} slang_machine;
int _slang_execute (const slang_assembly_file *);
#ifdef __cplusplus
}
#endif
#endif
/*
* Mesa 3-D graphics library
* Version: 6.3
*
* Copyright (C) 2005 Brian Paul 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, sublicense,
* 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL 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.
*/
#if !defined SLANG_EXECUTE_H
#define SLANG_EXECUTE_H
#if defined __cplusplus
extern "C" {
#endif
#define SLANG_MACHINE_STACK_SIZE 1024
typedef struct slang_machine_
{
GLuint ip; /* instruction pointer, for flow control */
GLuint sp; /* stack pointer, for stack access */
GLuint bp; /* base pointer, for local variable access */
GLuint kill; /* discard the fragment */
GLuint exit; /* terminate the shader */
union stack_
{
GLfloat _float[SLANG_MACHINE_STACK_SIZE];
GLfloat *_floatp[SLANG_MACHINE_STACK_SIZE];
GLuint _addr[SLANG_MACHINE_STACK_SIZE];
GLuint *_addrp[SLANG_MACHINE_STACK_SIZE];
} stack;
} slang_machine;
int _slang_execute (const slang_assembly_file *);
#ifdef __cplusplus
}
#endif
#endif
/*
* Mesa 3-D graphics library
* Version: 6.3
*
* Copyright (C) 2005 Brian Paul 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, sublicense,
* 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL 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 slang_preprocess.c
* slang preprocessor
* \author Michal Krol
*/
#include "imports.h"
#include "grammar_mesa.h"
#include "slang_compile.h"
#include "slang_preprocess.h"
static const char *slang_version_syn =
#include "library/slang_version_syn.h"
;
int _slang_preprocess_version (const char *text, unsigned int *version, unsigned int *eaten,
slang_info_log *log)
{
grammar id;
byte *prod, *I;
unsigned int size;
id = grammar_load_from_text ((const byte *) slang_version_syn);
if (id == 0)
{
char buf[1024];
unsigned int pos;
grammar_get_last_error ( (unsigned char*) buf, 1024, (int*) &pos);
slang_info_log_error (log, buf);
return 0;
}
if (!grammar_fast_check (id, (const byte *) text, &prod, &size, 8))
{
char buf[1024];
unsigned int pos;
grammar_get_last_error ( (unsigned char*) buf, 1024, (int*) &pos);
slang_info_log_error (log, buf);
grammar_destroy (id);
return 0;
}
grammar_destroy (id);
/* there can be multiple #version directives - grab the last one */
I = prod;
while (I < prod + size)
{
*version =
(unsigned int) I[0] +
(unsigned int) I[1] * 100;
*eaten =
((unsigned int) I[2]) +
((unsigned int) I[3] << 8) +
((unsigned int) I[4] << 16) +
((unsigned int) I[5] << 24);
I += 6;
}
grammar_alloc_free (prod);
return 1;
}
/*
* Mesa 3-D graphics library
* Version: 6.3
*
* Copyright (C) 2005 Brian Paul 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, sublicense,
* 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL 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 slang_preprocess.c
* slang preprocessor
* \author Michal Krol
*/
#include "imports.h"
#include "grammar_mesa.h"
#include "slang_compile.h"
#include "slang_preprocess.h"
static const char *slang_version_syn =
#include "library/slang_version_syn.h"
;
int _slang_preprocess_version (const char *text, unsigned int *version, unsigned int *eaten,
slang_info_log *log)
{
grammar id;
byte *prod, *I;
unsigned int size;
id = grammar_load_from_text ((const byte *) slang_version_syn);
if (id == 0)
{
char buf[1024];
unsigned int pos;
grammar_get_last_error ( (unsigned char*) buf, 1024, (int*) &pos);
slang_info_log_error (log, buf);
return 0;
}
if (!grammar_fast_check (id, (const byte *) text, &prod, &size, 8))
{
char buf[1024];
unsigned int pos;
grammar_get_last_error ( (unsigned char*) buf, 1024, (int*) &pos);
slang_info_log_error (log, buf);
grammar_destroy (id);
return 0;
}
grammar_destroy (id);
/* there can be multiple #version directives - grab the last one */
I = prod;
while (I < prod + size)
{
*version =
(unsigned int) I[0] +
(unsigned int) I[1] * 100;
*eaten =
((unsigned int) I[2]) +
((unsigned int) I[3] << 8) +
((unsigned int) I[4] << 16) +
((unsigned int) I[5] << 24);
I += 6;
}
grammar_alloc_free (prod);
return 1;
}
/*
* Mesa 3-D graphics library
* Version: 6.3
*
* Copyright (C) 2005 Brian Paul 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, sublicense,
* 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL 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.
*/
#if !defined SLANG_PREPROCESS_H
#define SLANG_PREPROCESS_H
#if defined __cplusplus
extern "C" {
#endif
int _slang_preprocess_version (const char *, unsigned int *, unsigned int *, slang_info_log *);
#ifdef __cplusplus
}
#endif
#endif
/*
* Mesa 3-D graphics library
* Version: 6.3
*
* Copyright (C) 2005 Brian Paul 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, sublicense,
* 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL 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.
*/
#if !defined SLANG_PREPROCESS_H
#define SLANG_PREPROCESS_H
#if defined __cplusplus
extern "C" {
#endif
int _slang_preprocess_version (const char *, unsigned int *, unsigned int *, slang_info_log *);
#ifdef __cplusplus
}
#endif
#endif
/*
* Mesa 3-D graphics library
* Version: 6.3
*
* Copyright (C) 2005 Brian Paul 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, sublicense,
* 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL 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 slang_utility.c
* slang utilities
* \author Michal Krol
*/
#include "imports.h"
#include "slang_utility.h"
void slang_alloc_free (void *ptr)
{
_mesa_free (ptr);
}
void *slang_alloc_malloc (unsigned int size)
{
return _mesa_malloc (size);
}
void *slang_alloc_realloc (void *ptr, unsigned int old_size, unsigned int size)
{
return _mesa_realloc (ptr, old_size, size);
}
int slang_string_compare (const char *str1, const char *str2)
{
return _mesa_strcmp (str1, str2);
}
char *slang_string_copy (char *dst, const char *src)
{
return _mesa_strcpy (dst, src);
}
char *slang_string_concat (char *dst, const char *src)
{
return _mesa_strcpy (dst + _mesa_strlen (dst), src);
}
char *slang_string_duplicate (const char *src)
{
return _mesa_strdup (src);
}
unsigned int slang_string_length (const char *str)
{
return _mesa_strlen (str);
}
/*
* Mesa 3-D graphics library
* Version: 6.3
*
* Copyright (C) 2005 Brian Paul 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, sublicense,
* 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL 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 slang_utility.c
* slang utilities
* \author Michal Krol
*/
#include "imports.h"
#include "slang_utility.h"
void slang_alloc_free (void *ptr)
{
_mesa_free (ptr);
}
void *slang_alloc_malloc (unsigned int size)
{
return _mesa_malloc (size);
}
void *slang_alloc_realloc (void *ptr, unsigned int old_size, unsigned int size)
{
return _mesa_realloc (ptr, old_size, size);
}
int slang_string_compare (const char *str1, const char *str2)
{
return _mesa_strcmp (str1, str2);
}
char *slang_string_copy (char *dst, const char *src)
{
return _mesa_strcpy (dst, src);
}
char *slang_string_concat (char *dst, const char *src)
{
return _mesa_strcpy (dst + _mesa_strlen (dst), src);
}
char *slang_string_duplicate (const char *src)
{
return _mesa_strdup (src);
}
unsigned int slang_string_length (const char *str)
{
return _mesa_strlen (str);
}
/*
* Mesa 3-D graphics library
* Version: 6.3
*
* Copyright (C) 2005 Brian Paul 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, sublicense,
* 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL 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.
*/
#if !defined SLANG_UTILITY_H
#define SLANG_UTILITY_H
#if defined __cplusplus
extern "C" {
#endif
/* Compile-time assertions. If the expression is zero, try to declare an
* array of size [-1] to cause compilation error.
*/
#define static_assert(expr) do { int _array[(expr) ? 1 : -1]; _array[0]; } while (0)
void slang_alloc_free (void *);
void *slang_alloc_malloc (unsigned int);
void *slang_alloc_realloc (void *, unsigned int, unsigned int);
int slang_string_compare (const char *, const char *);
char *slang_string_copy (char *, const char *);
char *slang_string_concat (char *, const char *);
char *slang_string_duplicate (const char *);
unsigned int slang_string_length (const char *);
#ifdef __cplusplus
}
#endif
#endif
/*
* Mesa 3-D graphics library
* Version: 6.3
*
* Copyright (C) 2005 Brian Paul 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, sublicense,
* 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL 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.
*/
#if !defined SLANG_UTILITY_H
#define SLANG_UTILITY_H
#if defined __cplusplus
extern "C" {
#endif
/* Compile-time assertions. If the expression is zero, try to declare an
* array of size [-1] to cause compilation error.
*/
#define _static_assert(expr) do { int _array[(expr) ? 1 : -1]; _array[0]; } while (0)
void slang_alloc_free (void *);
void *slang_alloc_malloc (unsigned int);
void *slang_alloc_realloc (void *, unsigned int, unsigned int);
int slang_string_compare (const char *, const char *);
char *slang_string_copy (char *, const char *);
char *slang_string_concat (char *, const char *);
char *slang_string_duplicate (const char *);
unsigned int slang_string_length (const char *);
#ifdef __cplusplus
}
#endif
#endif
/*
* Mesa 3-D graphics library
* Version: 6.3
*
* Copyright (C) 2005 Brian Paul 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, sublicense,
* 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL 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 traverse_wrap.h
* Handy TIntermTraverser class wrapper
* \author Michal Krol
*/
#ifndef __TRAVERSE_WRAP_H__
#define __TRAVERSE_WRAP_H__
#include "Include/intermediate.h"
/*
The original TIntermTraverser class that is used to walk the intermediate tree,
is not very elegant in its design. One must define static functions with
appropriate prototypes, construct TIntermTraverser object, and set its member
function pointers to one's static functions. If traversal-specific data
is needed, a new class must be derived, and one must up-cast the object
passed as a parameter to the static function.
The class below eliminates this burden by providing virtual methods that are
to be overridden in the derived class.
*/
class traverse_wrap: private TIntermTraverser
{
private:
static void _visitSymbol (TIntermSymbol *S, TIntermTraverser *T) {
static_cast<traverse_wrap *> (T)->Symbol (*S);
}
static void _visitConstantUnion (TIntermConstantUnion *U, TIntermTraverser *T) {
static_cast<traverse_wrap *> (T)->ConstantUnion (*U);
}
static bool _visitBinary (bool preVisit, TIntermBinary *B, TIntermTraverser *T) {
return static_cast<traverse_wrap *> (T)->Binary (preVisit, *B);
}
static bool _visitUnary (bool preVisit, TIntermUnary *U, TIntermTraverser *T) {
return static_cast<traverse_wrap *> (T)->Unary (preVisit, *U);
}
static bool _visitSelection (bool preVisit, TIntermSelection *S, TIntermTraverser *T) {
return static_cast<traverse_wrap *> (T)->Selection (preVisit, *S);
}
static bool _visitAggregate (bool preVisit, TIntermAggregate *A, TIntermTraverser *T) {
return static_cast<traverse_wrap *> (T)->Aggregate (preVisit, *A);
}
static bool _visitLoop (bool preVisit, TIntermLoop *L, TIntermTraverser *T) {
return static_cast<traverse_wrap *> (T)->Loop (preVisit, *L);
}
static bool _visitBranch (bool preVisit, TIntermBranch *B, TIntermTraverser *T) {
return static_cast<traverse_wrap *> (T)->Branch (preVisit, *B);
}
public:
traverse_wrap () {
visitSymbol = _visitSymbol;
visitConstantUnion = _visitConstantUnion;
visitBinary = _visitBinary;
visitUnary = _visitUnary;
visitSelection = _visitSelection;
visitAggregate = _visitAggregate;
visitLoop = _visitLoop;
visitBranch = _visitBranch;
}
protected:
virtual void Symbol (const TIntermSymbol &) {
}
virtual void ConstantUnion (const TIntermConstantUnion &) {
}
virtual bool Binary (bool, const TIntermBinary &) {
return true;
}
virtual bool Unary (bool, const TIntermUnary &) {
return true;
}
virtual bool Selection (bool, const TIntermSelection &) {
return true;
}
virtual bool Aggregate (bool, const TIntermAggregate &) {
return true;
}
virtual bool Loop (bool, const TIntermLoop &) {
return true;
}
virtual bool Branch (bool, const TIntermBranch &) {
return true;
}
};
#endif
/*
* Mesa 3-D graphics library
* Version: 6.3
*
* Copyright (C) 2005 Brian Paul 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, sublicense,
* 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL 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 traverse_wrap.h
* Handy TIntermTraverser class wrapper
* \author Michal Krol
*/
#ifndef __TRAVERSE_WRAP_H__
#define __TRAVERSE_WRAP_H__
#include "Include/intermediate.h"
/*
The original TIntermTraverser class that is used to walk the intermediate tree,
is not very elegant in its design. One must define static functions with
appropriate prototypes, construct TIntermTraverser object, and set its member
function pointers to one's static functions. If traversal-specific data
is needed, a new class must be derived, and one must up-cast the object
passed as a parameter to the static function.
The class below eliminates this burden by providing virtual methods that are
to be overridden in the derived class.
*/
class traverse_wrap: private TIntermTraverser
{
private:
static void _visitSymbol (TIntermSymbol *S, TIntermTraverser *T) {
static_cast<traverse_wrap *> (T)->Symbol (*S);
}
static void _visitConstantUnion (TIntermConstantUnion *U, TIntermTraverser *T) {
static_cast<traverse_wrap *> (T)->ConstantUnion (*U);
}
static bool _visitBinary (bool preVisit, TIntermBinary *B, TIntermTraverser *T) {
return static_cast<traverse_wrap *> (T)->Binary (preVisit, *B);
}
static bool _visitUnary (bool preVisit, TIntermUnary *U, TIntermTraverser *T) {
return static_cast<traverse_wrap *> (T)->Unary (preVisit, *U);
}
static bool _visitSelection (bool preVisit, TIntermSelection *S, TIntermTraverser *T) {
return static_cast<traverse_wrap *> (T)->Selection (preVisit, *S);
}
static bool _visitAggregate (bool preVisit, TIntermAggregate *A, TIntermTraverser *T) {
return static_cast<traverse_wrap *> (T)->Aggregate (preVisit, *A);
}
static bool _visitLoop (bool preVisit, TIntermLoop *L, TIntermTraverser *T) {
return static_cast<traverse_wrap *> (T)->Loop (preVisit, *L);
}
static bool _visitBranch (bool preVisit, TIntermBranch *B, TIntermTraverser *T) {
return static_cast<traverse_wrap *> (T)->Branch (preVisit, *B);
}
public:
traverse_wrap () {
visitSymbol = _visitSymbol;
visitConstantUnion = _visitConstantUnion;
visitBinary = _visitBinary;
visitUnary = _visitUnary;
visitSelection = _visitSelection;
visitAggregate = _visitAggregate;
visitLoop = _visitLoop;
visitBranch = _visitBranch;
}
protected:
virtual void Symbol (const TIntermSymbol &) {
}
virtual void ConstantUnion (const TIntermConstantUnion &) {
}
virtual bool Binary (bool, const TIntermBinary &) {
return true;
}
virtual bool Unary (bool, const TIntermUnary &) {
return true;
}
virtual bool Selection (bool, const TIntermSelection &) {
return true;
}
virtual bool Aggregate (bool, const TIntermAggregate &) {
return true;
}
virtual bool Loop (bool, const TIntermLoop &) {
return true;
}
virtual bool Branch (bool, const TIntermBranch &) {
return true;
}
};
#endif
......@@ -39,6 +39,7 @@
#endif
#include <string.h>
#include <assert.h>
#include "glxserver.h"
#include <GL/glxtokens.h>
......@@ -50,7 +51,6 @@
#include "glximports.h"
#include "glxutil.h"
#include "glxext.h"
#include "GL/glx_ansic.h"
#include "glcontextmodes.h"
/************************************************************************/
......@@ -193,11 +193,11 @@ int DoCreateContext(__GLXclientState *cl, GLXContextID gcId,
/*
** Allocate memory for the new context
*/
glxc = (__GLXcontext *) __glXMalloc(sizeof(__GLXcontext));
glxc = (__GLXcontext *) malloc(sizeof(__GLXcontext));
if (!glxc) {
return BadAlloc;
}
__glXMemset(glxc, 0, sizeof(__GLXcontext));
memset(glxc, 0, sizeof(__GLXcontext));
/*
** Initially, setup the part of the context that could be used by
......@@ -216,7 +216,7 @@ int DoCreateContext(__GLXclientState *cl, GLXContextID gcId,
imports.other = (void *)glxc;
glxc->gc = (*pGlxScreen->createContext)(&imports, glxc->modes, shareGC);
if (!glxc->gc) {
__glXFree(glxc);
free(glxc);
client->errorValue = gcId;
return BadAlloc;
}
......@@ -233,7 +233,7 @@ int DoCreateContext(__GLXclientState *cl, GLXContextID gcId,
if (!isDirect) {
(*glxc->gc->exports.destroyContext)((__GLcontext *)glxc->gc);
}
__glXFree(glxc);
free(glxc);
client->errorValue = gcId;
return BadAlloc;
}
......@@ -335,9 +335,9 @@ static int AddCurrentContext(__GLXclientState *cl, __GLXcontext *glxc)
** Didn't find a free slot, so we'll have to grow the table.
*/
if (!num) {
table = (__GLXcontext **) __glXMalloc(sizeof(__GLXcontext *));
table = (__GLXcontext **) malloc(sizeof(__GLXcontext *));
} else {
table = (__GLXcontext **) __glXRealloc(table,
table = (__GLXcontext **) realloc(table,
(num+1)*sizeof(__GLXcontext *));
}
table[num] = glxc;
......@@ -685,7 +685,7 @@ int DoMakeCurrent( __GLXclientState *cl,
** refcount of the X pixmap and free only if it's zero.
*/
(*prevglxc->readPixmap->pScreen->DestroyPixmap)(pPixmap);
__glXFree(prevglxc->readPixmap);
free(prevglxc->readPixmap);
}
}
......@@ -701,7 +701,7 @@ int DoMakeCurrent( __GLXclientState *cl,
** refcount of the X pixmap and free only if it's zero.
*/
(*prevglxc->drawPixmap->pScreen->DestroyPixmap)(pPixmap);
__glXFree(prevglxc->drawPixmap);
free(prevglxc->drawPixmap);
}
prevglxc->drawPixmap = NULL;
......@@ -1192,7 +1192,7 @@ int DoCreateGLXPixmap(__GLXclientState *cl, VisualID visual,
return BadValue;
}
pGlxPixmap = (__GLXpixmap *) __glXMalloc(sizeof(__GLXpixmap));
pGlxPixmap = (__GLXpixmap *) malloc(sizeof(__GLXpixmap));
if (!pGlxPixmap) {
return BadAlloc;
}
......@@ -1382,7 +1382,7 @@ int __glXQueryContextInfoEXT(__GLXclientState *cl, GLbyte *pc)
reply.n = nProps;
nReplyBytes = reply.length << 2;
sendBuf = (int *)__glXMalloc((size_t)nReplyBytes);
sendBuf = (int *)malloc((size_t)nReplyBytes);
if (sendBuf == NULL) {
return __glXBadContext; /* XXX: Is this correct? */
}
......@@ -1400,7 +1400,7 @@ int __glXQueryContextInfoEXT(__GLXclientState *cl, GLbyte *pc)
WriteToClient(client, sz_xGLXQueryContextInfoEXTReply, &reply);
WriteToClient(client, nReplyBytes, sendBuf);
}
__glXFree((char *)sendBuf);
free((char *)sendBuf);
return Success;
}
......@@ -1626,17 +1626,17 @@ int __glXRenderLarge(__GLXclientState *cl, GLbyte *pc)
*/
if (cl->largeCmdBufSize < cmdlen) {
if (!cl->largeCmdBuf) {
cl->largeCmdBuf = (GLbyte *) __glXMalloc((size_t)cmdlen);
cl->largeCmdBuf = (GLbyte *) malloc((size_t)cmdlen);
} else {
cl->largeCmdBuf = (GLbyte *) __glXRealloc(cl->largeCmdBuf,
(size_t)cmdlen);
cl->largeCmdBuf = (GLbyte *) realloc(cl->largeCmdBuf,
(size_t)cmdlen);
}
if (!cl->largeCmdBuf) {
return BadAlloc;
}
cl->largeCmdBufSize = cmdlen;
}
__glXMemcpy(cl->largeCmdBuf, pc, dataBytes);
memcpy(cl->largeCmdBuf, pc, dataBytes);
cl->largeCmdBytesSoFar = dataBytes;
cl->largeCmdBytesTotal = cmdlen;
......@@ -1679,7 +1679,7 @@ int __glXRenderLarge(__GLXclientState *cl, GLbyte *pc)
__glXResetLargeCommandStatus(cl);
return __glXBadLargeRequest;
}
__glXMemcpy(cl->largeCmdBuf + cl->largeCmdBytesSoFar, pc, dataBytes);
memcpy(cl->largeCmdBuf + cl->largeCmdBytesSoFar, pc, dataBytes);
cl->largeCmdBytesSoFar += dataBytes;
cl->largeCmdRequestsSoFar++;
......@@ -2074,17 +2074,18 @@ int __glXQueryExtensionsString(__GLXclientState *cl, GLbyte *pc)
ptr = __glXActiveScreens[screen].GLXextensions;
n = __glXStrlen(ptr) + 1;
n = strlen(ptr) + 1;
length = __GLX_PAD(n) >> 2;
reply.type = X_Reply;
reply.sequenceNumber = client->sequence;
reply.length = length;
reply.n = n;
if ((buf = (char *) __glXMalloc(length << 2)) == NULL) {
/* Allocate buffer to make sure it's a multiple of 4 bytes big.*/
buf = (char *) malloc(length << 2);
if (buf == NULL)
return BadAlloc;
}
__glXStrncpy(buf, ptr, n);
memcpy(buf, ptr, n);
if (client->swapped) {
glxSwapQueryExtensionsStringReply(client, &reply, buf);
......@@ -2093,7 +2094,7 @@ int __glXQueryExtensionsString(__GLXclientState *cl, GLbyte *pc)
WriteToClient(client, (int)(length << 2), buf);
}
__glXFree(buf);
free(buf);
return Success;
}
......@@ -2131,7 +2132,7 @@ int __glXQueryServerString(__GLXclientState *cl, GLbyte *pc)
return BadValue;
}
n = __glXStrlen(ptr) + 1;
n = strlen(ptr) + 1;
length = __GLX_PAD(n) >> 2;
reply.type = X_Reply;
reply.sequenceNumber = client->sequence;
......@@ -2141,7 +2142,7 @@ int __glXQueryServerString(__GLXclientState *cl, GLbyte *pc)
if ((buf = (char *) malloc(length << 2)) == NULL) {
return BadAlloc;
}
__glXStrncpy(buf, ptr, n);
memcpy(buf, ptr, n);
if (client->swapped) {
glxSwapQueryServerStringReply(client, &reply, buf);
......@@ -2150,7 +2151,7 @@ int __glXQueryServerString(__GLXclientState *cl, GLbyte *pc)
WriteToClient(client, (int)(length << 2), buf);
}
__glXFree(buf);
free(buf);
return Success;
}
......@@ -2161,9 +2162,10 @@ int __glXClientInfo(__GLXclientState *cl, GLbyte *pc)
cl->GLClientmajorVersion = req->major;
cl->GLClientminorVersion = req->minor;
if (cl->GLClientextensions) __glXFree(cl->GLClientextensions);
if (cl->GLClientextensions)
free(cl->GLClientextensions);
buf = (const char *)(req+1);
cl->GLClientextensions = __glXStrdup(buf);
cl->GLClientextensions = xstrdup(buf);
return Success;
}
......
......@@ -47,7 +47,6 @@
#include <pixmapstr.h>
#include <windowstr.h>
#include "glxext.h"
#include "GL/glx_ansic.h"
static int __glXSwapGetFBConfigsSGIX(__GLXclientState *cl, GLbyte *pc);
static int __glXSwapCreateContextWithConfigSGIX(__GLXclientState *cl, GLbyte *pc);
......@@ -683,16 +682,16 @@ int __glXSwapRenderLarge(__GLXclientState *cl, GLbyte *pc)
*/
if (cl->largeCmdBufSize < cmdlen) {
if (!cl->largeCmdBuf) {
cl->largeCmdBuf = (GLbyte *) __glXMalloc(cmdlen);
cl->largeCmdBuf = (GLbyte *) malloc(cmdlen);
} else {
cl->largeCmdBuf = (GLbyte *) __glXRealloc(cl->largeCmdBuf, cmdlen);
cl->largeCmdBuf = (GLbyte *) realloc(cl->largeCmdBuf, cmdlen);
}
if (!cl->largeCmdBuf) {
return BadAlloc;
}
cl->largeCmdBufSize = cmdlen;
}
__glXMemcpy(cl->largeCmdBuf, pc, dataBytes);
memcpy(cl->largeCmdBuf, pc, dataBytes);
cl->largeCmdBytesSoFar = dataBytes;
cl->largeCmdBytesTotal = cmdlen;
......@@ -735,7 +734,7 @@ int __glXSwapRenderLarge(__GLXclientState *cl, GLbyte *pc)
__glXResetLargeCommandStatus(cl);
return __glXBadLargeRequest;
}
__glXMemcpy(cl->largeCmdBuf + cl->largeCmdBytesSoFar, pc, dataBytes);
memcpy(cl->largeCmdBuf + cl->largeCmdBytesSoFar, pc, dataBytes);
cl->largeCmdBytesSoFar += dataBytes;
cl->largeCmdRequestsSoFar++;
......
......@@ -62,17 +62,18 @@ static void ResetClientState(int clientIndex)
{
__GLXclientState *cl = __glXClients[clientIndex];
if (cl->returnBuf) __glXFree(cl->returnBuf);
if (cl->largeCmdBuf) __glXFree(cl->largeCmdBuf);
if (cl->currentContexts) __glXFree(cl->currentContexts);
__glXMemset(cl, 0, sizeof(__GLXclientState));
if (cl->returnBuf) free(cl->returnBuf);
if (cl->largeCmdBuf) free(cl->largeCmdBuf);
if (cl->currentContexts) free(cl->currentContexts);
memset(cl, 0, sizeof(__GLXclientState));
/*
** By default, assume that the client supports
** GLX major version 1 minor version 0 protocol.
*/
cl->GLClientmajorVersion = 1;
cl->GLClientminorVersion = 0;
if (cl->GLClientextensions) __glXFree(cl->GLClientextensions);
if (cl->GLClientextensions)
free(cl->GLClientextensions);
}
......@@ -151,7 +152,7 @@ static int PixmapGone(__GLXpixmap *pGlxPixmap, XID id)
** only if it's zero.
*/
(*pGlxPixmap->pScreen->DestroyPixmap)(pPixmap);
__glXFree(pGlxPixmap);
free(pGlxPixmap);
}
return True;
......@@ -169,9 +170,9 @@ GLboolean __glXFreeContext(__GLXcontext *cx)
return GL_FALSE;
}
}
if (cx->feedbackBuf) __glXFree(cx->feedbackBuf);
if (cx->selectBuf) __glXFree(cx->selectBuf);
__glXFree(cx);
if (cx->feedbackBuf) free(cx->feedbackBuf);
if (cx->selectBuf) free(cx->selectBuf);
free(cx);
if (cx == __glXLastContext) {
__glXFlushContextCache();
}
......@@ -404,12 +405,12 @@ static int __glXDispatch(ClientPtr client)
opcode = stuff->glxCode;
cl = __glXClients[client->index];
if (!cl) {
cl = (__GLXclientState *) __glXMalloc(sizeof(__GLXclientState));
cl = (__GLXclientState *) malloc(sizeof(__GLXclientState));
__glXClients[client->index] = cl;
if (!cl) {
return BadAlloc;
}
__glXMemset(cl, 0, sizeof(__GLXclientState));
memset(cl, 0, sizeof(__GLXclientState));
}
if (!cl->inUse) {
......@@ -458,12 +459,12 @@ static int __glXSwapDispatch(ClientPtr client)
opcode = stuff->glxCode;
cl = __glXClients[client->index];
if (!cl) {
cl = (__GLXclientState *) __glXMalloc(sizeof(__GLXclientState));
cl = (__GLXclientState *) malloc(sizeof(__GLXclientState));
__glXClients[client->index] = cl;
if (!cl) {
return BadAlloc;
}
__glXMemset(cl, 0, sizeof(__GLXclientState));
memset(cl, 0, sizeof(__GLXclientState));
}
if (!cl->inUse) {
......
......@@ -130,7 +130,7 @@ Free(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv)
FreeScratchGC(bufferInfo->pGC);
}
__glXFree(bufferInfo);
free(bufferInfo);
buf->other = NULL;
}
......@@ -173,7 +173,7 @@ __glXInitFB(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv, GLint bits)
buf->free = Free;
/* allocate local information */
bufferInfo = (__GLFBbufferInfo *) __glXMalloc(sizeof(__GLFBbufferInfo));
bufferInfo = (__GLFBbufferInfo *) malloc(sizeof(__GLFBbufferInfo));
buf->other = (void *) bufferInfo;
pGC = CreateScratchGC(glxPriv->pDraw->pScreen,
......
......@@ -44,7 +44,6 @@
#include "glxserver.h"
#include "glxcontext.h"
#include "glximports.h"
#include "GL/glx_ansic.h"
void *__glXImpMalloc(__GLcontext *gc, size_t size)
{
......@@ -76,7 +75,7 @@ void *__glXImpCalloc(__GLcontext *gc, size_t numElements, size_t elementSize)
return NULL;
}
/* zero out memory */
__glXMemset(addr, 0, size);
memset(addr, 0, size);
return addr;
}
......@@ -119,17 +118,17 @@ void __glXImpWarning(__GLcontext *gc, char *msg)
void __glXImpFatal(__GLcontext *gc, char *msg)
{
ErrorF("%s",(char *)msg);
__glXAbort();
abort();
}
char *__glXImpGetenv(__GLcontext *gc, const char *var)
{
return __glXGetenv(var);
return getenv(var);
}
int __glXImpAtoi(__GLcontext *gc, const char *str)
{
return __glXAtoi(str);
return atoi(str);
}
int __glXImpSprintf(__GLcontext *gc, char *str, const char *fmt, ...)
......@@ -139,7 +138,7 @@ int __glXImpSprintf(__GLcontext *gc, char *str, const char *fmt, ...)
/* have to deal with var args */
va_start(ap, fmt);
ret = __glXVsprintf(str, fmt, ap);
ret = vsprintf(str, fmt, ap);
va_end(ap);
return ret;
......@@ -147,12 +146,12 @@ int __glXImpSprintf(__GLcontext *gc, char *str, const char *fmt, ...)
void *__glXImpFopen(__GLcontext *gc, const char *path, const char *mode)
{
return (void *) __glXFopen(path, mode);
return (void *) fopen(path, mode);
}
int __glXImpFclose(__GLcontext *gc, void *stream)
{
return __glXFclose((FILE *)stream);
return fclose((FILE *)stream);
}
int __glXImpFprintf(__GLcontext *gc, void *stream, const char *fmt, ...)
......@@ -162,7 +161,7 @@ int __glXImpFprintf(__GLcontext *gc, void *stream, const char *fmt, ...)
/* have to deal with var args */
va_start(ap, fmt);
ret = __glXVfprintf((FILE *)stream, fmt, ap);
ret = vfprintf((FILE *)stream, fmt, ap);
va_end(ap);
return ret;
......
......@@ -95,7 +95,7 @@ Free(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv)
FreeScratchGC(bufferInfo->pGC);
}
__glXFree(bufferInfo);
free(bufferInfo);
buf->other = NULL;
}
......@@ -123,7 +123,7 @@ __glXInitPix(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv,
buf->free = Free;
/* allocate local information */
bufferInfo = (__GLPixBufferInfo *) __glXMalloc(sizeof(__GLPixBufferInfo));
bufferInfo = (__GLPixBufferInfo *) malloc(sizeof(__GLPixBufferInfo));
buf->other = (void *) bufferInfo;
bufferInfo->pGC = CreateScratchGC(pGlxPixmap->pDraw->pScreen,
......
......@@ -288,7 +288,7 @@ static void wrapPositionWindow(int screen)
void __glXHyperpipeInit(int screen, __GLXHyperpipeExtensionFuncs *funcs)
{
if (__glXNumHyperpipeFuncs < screen + 1) {
__glXHyperpipeFuncs = __glXRealloc(__glXHyperpipeFuncs,
__glXHyperpipeFuncs = realloc(__glXHyperpipeFuncs,
(screen+1) * sizeof(__GLXHyperpipeExtensionFuncs));
__glXNumHyperpipeFuncs = screen + 1;
}
......@@ -306,7 +306,7 @@ void __glXHyperpipeInit(int screen, __GLXHyperpipeExtensionFuncs *funcs)
void __glXSwapBarrierInit(int screen, __GLXSwapBarrierExtensionFuncs *funcs)
{
if (__glXNumSwapBarrierFuncs < screen + 1) {
__glXSwapBarrierFuncs = __glXRealloc(__glXSwapBarrierFuncs,
__glXSwapBarrierFuncs = realloc(__glXSwapBarrierFuncs,
(screen+1) * sizeof(__GLXSwapBarrierExtensionFuncs));
__glXNumSwapBarrierFuncs = screen + 1;
}
......@@ -327,7 +327,7 @@ void __glXScreenInit(GLint numscreens)
** This alloc has to work or else the server might as well core dump.
*/
__glXActiveScreens =
(__GLXscreenInfo *) __glXMalloc(sizeof(__GLXscreenInfo) * numscreens);
(__GLXscreenInfo *) malloc(sizeof(__GLXscreenInfo) * numscreens);
for (i=0; i < numscreens; i++) {
/*
......@@ -338,10 +338,10 @@ void __glXScreenInit(GLint numscreens)
__glXActiveScreens[i] = *__glXScreens[j];
__glXActiveScreens[i].numUsableVisuals = __glXActiveScreens[i].numVisuals;
__glXActiveScreens[i].GLextensions = __glXStrdup(GLServerExtensions);
__glXActiveScreens[i].GLXvendor = __glXStrdup(GLXServerVendorName);
__glXActiveScreens[i].GLXversion = __glXStrdup(GLXServerVersion);
__glXActiveScreens[i].GLXextensions = __glXStrdup(GLXServerExtensions);
__glXActiveScreens[i].GLextensions = strdup(GLServerExtensions);
__glXActiveScreens[i].GLXvendor = strdup(GLXServerVendorName);
__glXActiveScreens[i].GLXversion = strdup(GLXServerVersion);
__glXActiveScreens[i].GLXextensions = strdup(GLXServerExtensions);
__glXDrawableRes = CreateNewResourceType((DeleteType)DrawableGone);
wrapPositionWindow(i);
......@@ -356,10 +356,10 @@ void __glXScreenReset(void)
int i;
for (i = 0; i < __glXNumActiveScreens; i++) {
__glXFree(__glXActiveScreens[i].GLXvendor);
__glXFree(__glXActiveScreens[i].GLXversion);
__glXFree(__glXActiveScreens[i].GLXextensions);
__glXFree(__glXActiveScreens[i].GLextensions);
free(__glXActiveScreens[i].GLXvendor);
free(__glXActiveScreens[i].GLXversion);
free(__glXActiveScreens[i].GLXextensions);
free(__glXActiveScreens[i].GLextensions);
}
free(__glXActiveScreens);
free(__glXHyperpipeFuncs);
......
......@@ -50,7 +50,6 @@
#include <extnsionst.h>
#include <resource.h>
#include <scrnintstr.h>
#include "GL/glx_ansic.h"
#include "protocol-versions.h"
#include <limits.h>
......
......@@ -47,7 +47,6 @@
#include <windowstr.h>
#include "glxutil.h"
#include "glxbuf.h"
#include "GL/glx_ansic.h"
#include "GL/internal/glcore.h"
#include "GL/glxint.h"
#include "glcontextmodes.h"
......@@ -58,81 +57,8 @@ void __glXNop(void) {}
/************************************************************************/
/* Memory Allocation for GLX */
void *
__glXMalloc(size_t size)
{
void *addr;
if (size == 0) {
return NULL;
}
addr = (void *) malloc(size);
if (addr == NULL) {
/* XXX: handle out of memory error */
return NULL;
}
return addr;
}
void *
__glXCalloc(size_t numElements, size_t elementSize)
{
void *addr;
size_t size;
if ((numElements == 0) || (elementSize == 0)) {
return NULL;
}
size = numElements * elementSize;
addr = (void *) malloc(size);
if (addr == NULL) {
/* XXX: handle out of memory error */
return NULL;
}
__glXMemset(addr, 0, size);
return addr;
}
void *
__glXRealloc(void *addr, size_t newSize)
{
void *newAddr;
if (addr) {
if (newSize == 0) {
free(addr);
return NULL;
} else {
newAddr = realloc(addr, newSize);
}
} else {
if (newSize == 0) {
return NULL;
} else {
newAddr = malloc(newSize);
}
}
if (newAddr == NULL) {
return NULL; /* XXX: out of memory */
}
return newAddr;
}
void
__glXFree(void *addr)
{
if (addr) {
free(addr);
}
}
/************************************************************************/
/* Context stuff */
/*
** associate a context with a drawable
*/
......@@ -299,8 +225,8 @@ __glXCreateDrawablePrivate(DrawablePtr pDraw, XID drawId,
__GLdrawablePrivate *glPriv;
__GLXscreenInfo *pGlxScreen;
glxPriv = (__GLXdrawablePrivate *) __glXMalloc(sizeof(*glxPriv));
__glXMemset(glxPriv, 0, sizeof(__GLXdrawablePrivate));
glxPriv = (__GLXdrawablePrivate *) malloc(sizeof(*glxPriv));
memset(glxPriv, 0, sizeof(__GLXdrawablePrivate));
glxPriv->type = pDraw->type;
glxPriv->pDraw = pDraw;
......@@ -312,18 +238,18 @@ __glXCreateDrawablePrivate(DrawablePtr pDraw, XID drawId,
/* since we are creating the drawablePrivate, drawId should be new */
if (!AddResource(drawId, __glXDrawableRes, glxPriv)) {
/* oops! */
__glXFree(glxPriv);
free(glxPriv);
return NULL;
}
/* fill up glPriv */
glPriv = &glxPriv->glPriv;
glPriv->modes = (__GLcontextModes *) __glXMalloc(sizeof(__GLcontextModes));
glPriv->modes = (__GLcontextModes *) malloc(sizeof(__GLcontextModes));
*glPriv->modes = *modes;
glPriv->malloc = __glXMalloc;
glPriv->calloc = __glXCalloc;
glPriv->realloc = __glXRealloc;
glPriv->free = __glXFree;
glPriv->malloc = malloc;
glPriv->calloc = calloc;
glPriv->realloc = realloc;
glPriv->free = free;
glPriv->addSwapRect = NULL;
glPriv->setClipRect = (void (*)(__GLdrawablePrivate *, GLint, GLint, GLsizei, GLsizei)) __glXNop;
glPriv->lockDP = LockDP;
......@@ -334,7 +260,7 @@ __glXCreateDrawablePrivate(DrawablePtr pDraw, XID drawId,
/* allocate a one-rect ownership region */
glPriv->ownershipRegion.rects =
(__GLregionRect *)__glXCalloc(1, sizeof(__GLregionRect));
(__GLregionRect *)calloc(1, sizeof(__GLregionRect));
glPriv->ownershipRegion.numRects = 1;
glxPriv->freeBuffers = __glXFreeBuffers;
......@@ -377,9 +303,9 @@ __glXDestroyDrawablePrivate(__GLXdrawablePrivate *glxPriv)
}
/* Free the drawable Private */
__glXFree(glxPriv->glPriv.modes);
__glXFree(glxPriv->glPriv.ownershipRegion.rects);
__glXFree(glxPriv);
free(glxPriv->glPriv.modes);
free(glxPriv->glPriv.ownershipRegion.rects);
free(glxPriv);
return GL_TRUE;
}
......
......@@ -42,12 +42,6 @@
extern void __glXNop(void);
/* memory management */
extern void *__glXMalloc(size_t size);
extern void *__glXCalloc(size_t numElements, size_t elementSize);
extern void *__glXRealloc(void *addr, size_t newSize);
extern void __glXFree(void *ptr);
/* relate contexts with drawables */
extern void __glXAssociateContext(__GLXcontext *glxc);
extern void __glXDeassociateContext(__GLXcontext *glxc);
......
......@@ -46,7 +46,6 @@
#include "glxext.h"
#include "unpack.h"
#include "g_disptab.h"
#include "GL/glx_ansic.h"
int __glXDisp_FeedbackBuffer(__GLXclientState *cl, GLbyte *pc)
{
......@@ -67,7 +66,7 @@ int __glXDisp_FeedbackBuffer(__GLXclientState *cl, GLbyte *pc)
size = *(GLsizei *)(pc+0);
type = *(GLenum *)(pc+4);
if (cx->feedbackBufSize < size) {
cx->feedbackBuf = (GLfloat *) __glXRealloc(cx->feedbackBuf,
cx->feedbackBuf = (GLfloat *) realloc(cx->feedbackBuf,
(size_t)size
* __GLX_SIZE_FLOAT32);
if (!cx->feedbackBuf) {
......@@ -97,7 +96,7 @@ int __glXDisp_SelectBuffer(__GLXclientState *cl, GLbyte *pc)
pc += __GLX_SINGLE_HDR_SIZE;
size = *(GLsizei *)(pc+0);
if (cx->selectBufSize < size) {
cx->selectBuf = (GLuint *) __glXRealloc(cx->selectBuf,
cx->selectBuf = (GLuint *) realloc(cx->selectBuf,
(size_t) size
* __GLX_SIZE_CARD32);
if (!cx->selectBuf) {
......@@ -268,24 +267,30 @@ char *__glXcombine_strings(const char *cext_string, const char *sext_string)
** pull tokens out of shortest string
** include space in combo_string for final separator and null terminator
*/
if ( (clen = __glXStrlen(cext_string)) > (slen = __glXStrlen(sext_string)) ) {
combo_string = (char *) __glXMalloc(slen + 2);
s1 = (char *) __glXMalloc(slen + 2); __glXStrcpy(s1, sext_string);
clen = strlen(cext_string);
slen = strlen(sext_string);
if (clen > slen) {
combo_string = (char *) malloc(slen + 2);
s1 = (char *) malloc(slen + 2);
strcpy(s1, sext_string);
s2 = cext_string;
} else {
combo_string = (char *) __glXMalloc(clen + 2);
s1 = (char *) __glXMalloc(clen + 2); __glXStrcpy(s1, cext_string);
combo_string = (char *) malloc(clen + 2);
s1 = (char *) malloc(clen + 2);
strcpy(s1, cext_string);
s2 = sext_string;
}
if (!combo_string || !s1) {
if (combo_string) __glXFree(combo_string);
if (s1) __glXFree(s1);
if (combo_string)
free(combo_string);
if (s1)
free(s1);
return NULL;
}
combo_string[0] = '\0';
/* Get first extension token */
token = __glXStrtok( s1, SEPARATOR);
token = strtok( s1, SEPARATOR);
while ( token != NULL ) {
/*
......@@ -293,20 +298,20 @@ char *__glXcombine_strings(const char *cext_string, const char *sext_string)
** beware of extension names which are prefixes of other extension names
*/
const char *p = s2;
end = p + __glXStrlen(p);
end = p + strlen(p);
while (p < end) {
size_t n = __glXStrcspn(p, SEPARATOR);
if ((__glXStrlen(token) == n) && (__glXStrncmp(token, p, n) == 0)) {
combo_string = __glXStrcat( combo_string, token);
combo_string = __glXStrcat( combo_string, SEPARATOR);
size_t n = strcspn(p, SEPARATOR);
if ((strlen(token) == n) && (strncmp(token, p, n) == 0)) {
combo_string = strcat(combo_string, token);
combo_string = strcat(combo_string, SEPARATOR);
}
p += (n + 1);
}
/* Get next extension token */
token = __glXStrtok( NULL, SEPARATOR);
token = strtok( NULL, SEPARATOR);
}
__glXFree(s1);
free(s1);
return combo_string;
}
......@@ -351,26 +356,24 @@ int DoGetString(__GLXclientState *cl, GLbyte *pc, GLboolean need_swap)
buf = __glXcombine_strings(buf1,
cx->pGlxScreen->GLextensions);
if (buf1 != NULL) {
__glXFree(buf1);
free(buf1);
}
string = buf;
}
else if ( name == GL_VERSION ) {
if ( atof( string ) > atof( GLServerVersion ) ) {
buf = __glXMalloc( __glXStrlen( string )
+ __glXStrlen( GLServerVersion )
+ 4 );
buf = malloc( strlen( string ) + strlen( GLServerVersion ) + 4 );
if ( buf == NULL ) {
string = GLServerVersion;
}
else {
__glXSprintf( buf, "%s (%s)", GLServerVersion, string );
sprintf( buf, "%s (%s)", GLServerVersion, string );
string = buf;
}
}
}
if (string) {
length = __glXStrlen((const char *) string) + 1;
length = strlen((const char *) string) + 1;
}
__GLX_BEGIN_REPLY(length);
......@@ -384,7 +387,7 @@ int DoGetString(__GLXclientState *cl, GLbyte *pc, GLboolean need_swap)
__GLX_SEND_HEADER();
WriteToClient(client, length, string);
if (buf != NULL) {
__glXFree(buf);
free(buf);
}
return Success;
}
......
......@@ -42,7 +42,6 @@
#include "glxext.h"
#include "unpack.h"
#include "g_disptab.h"
#include "GL/glx_ansic.h"
int __glXDispSwap_FeedbackBuffer(__GLXclientState *cl, GLbyte *pc)
{
......@@ -66,7 +65,7 @@ int __glXDispSwap_FeedbackBuffer(__GLXclientState *cl, GLbyte *pc)
size = *(GLsizei *)(pc+0);
type = *(GLenum *)(pc+4);
if (cx->feedbackBufSize < size) {
cx->feedbackBuf = (GLfloat *) __glXRealloc(cx->feedbackBuf,
cx->feedbackBuf = (GLfloat *) realloc(cx->feedbackBuf,
(size_t) size
* __GLX_SIZE_FLOAT32);
if (!cx->feedbackBuf) {
......@@ -99,7 +98,7 @@ int __glXDispSwap_SelectBuffer(__GLXclientState *cl, GLbyte *pc)
__GLX_SWAP_INT(pc+0);
size = *(GLsizei *)(pc+0);
if (cx->selectBufSize < size) {
cx->selectBuf = (GLuint *) __glXRealloc(cx->selectBuf,
cx->selectBuf = (GLuint *) realloc(cx->selectBuf,
(size_t) size
* __GLX_SIZE_CARD32);
if (!cx->selectBuf) {
......
......@@ -77,7 +77,7 @@ static int __glXMakeBitmapFromGlyph(FontPtr font, CharInfoPtr pci)
p = buf;
allocbuf = 0;
} else {
p = (unsigned char *) __glXMalloc(allocBytes);
p = (unsigned char *) malloc(allocBytes);
if (!p)
return BadAlloc;
allocbuf = p;
......@@ -99,7 +99,7 @@ static int __glXMakeBitmapFromGlyph(FontPtr font, CharInfoPtr pci)
pci->metrics.characterWidth, 0, allocbuf ? allocbuf : buf);
if (allocbuf) {
__glXFree(allocbuf);
free(allocbuf);
}
return Success;
#undef __GL_CHAR_BUF_SIZE
......
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#ifndef _glx_ansic_h_
#define _glx_ansic_h_
/*
** License Applicability. Except to the extent portions of this file are
** made subject to an alternative license as permitted in the SGI Free
** Software License B, Version 1.1 (the "License"), the contents of this
** file are subject only to the provisions of the License. You may not use
** this file except in compliance with the License. You may obtain a copy
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
**
** http://oss.sgi.com/projects/FreeB
**
** Note that, as provided in the License, the Software is distributed on an
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
**
** Original Code. The Original Code is: OpenGL Sample Implementation,
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
** Copyright in any portions created by third parties is as indicated
** elsewhere herein. All Rights Reserved.
**
** Additional Notice Provisions: The application programming interfaces
** established by SGI in conjunction with the Original Code are The
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
** Window System(R) (Version 1.3), released October 19, 1998. This software
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
** published by SGI, but has not been independently verified as being
** compliant with the OpenGL(R) version 1.2.1 Specification.
*/
/*
** this needs to check whether we're using XFree86 at all, and then
** which version we're using. Use these macros if version is 3.9+, else
** use normal commands below.
*/
/*
** turns out this include file only exists for XFree86 3.9+
** I notice that not having it is not an error and does not stop the build,
** but having it will allow opengl and glx to be built for 3.9+. We no longer
** need an explicit define in the Makefile, just point to the correct X source
** tree and all should be taken care of.
*/
#ifdef XFree86Server
#ifndef assert
#define assert(a)
#endif
#else
#if defined(Lynx) && defined(__assert_h)
#undef __assert_h
#endif
#ifdef assert
#undef assert
#endif
#include <assert.h>
#endif
#define GLX_STDOUT stdout
#define GLX_STDERR stderr
#define __glXPrintf printf
#define __glXFprintf fprintf
#define __glXSprintf sprintf
#define __glXVfprintf vfprintf
#define __glXVsprintf vsprintf
#define __glXFopen fopen
#define __glXFclose fclose
#define __glXCos(x) cos(x)
#define __glXSin(x) sin(x)
#define __glXAtan(x) atan(x)
#define __glXAbs(x) abs(x)
#define __glXLog(x) log(x)
#define __glXCeil(x) ceil(x)
#define __glXFloor(x) floor(x)
#define __glXSqrt(x) sqrt(x)
#define __glXPow(x, y) pow(x, y)
#define __glXMemmove(dest, src, n) memmove(dest, src, n)
#define __glXMemcpy(dest, src, n) memcpy(dest, src, n)
#define __glXMemset(s, c, n) memset(s, c, n)
#define __glXStrdup(str) xstrdup(str)
#define __glXStrcpy(dest, src) strcpy(dest, src)
#define __glXStrncpy(dest, src, n) strncpy(dest, src, n)
#define __glXStrcat(dest, src) strcat(dest, src)
#define __glXStrncat(dest, src, n) strncat(dest, src, n)
#define __glXStrcmp(s1, s2) strcmp(s1, s2)
#define __glXStrncmp(s1, s2, n) strncmp(s1, s2, n)
#define __glXStrlen(str) strlen(str)
#define __glXAbort() abort()
#define __glXStrtok(s, delim) strtok(s, delim)
#define __glXStrcspn(s, reject) strcspn(s, reject)
#define __glXGetenv(a) getenv(a)
#define __glXAtoi(a) atoi(a)
#endif /* _glx_ansic_h_ */
/**************************************************************************
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
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 PRECISION INSIGHT AND/OR ITS 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.
**************************************************************************/
/*
* Authors:
* Kevin E. Martin <kevin@precisioninsight.com>
*
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include "miscstruct.h"
......@@ -52,7 +52,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "xf86glxint.h"
#include "context.h"
#include "xmesaP.h"
#include <GL/xf86glx.h>
#include "context.h"
/*
......@@ -319,15 +318,15 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp,
/* Alloc space for the list of new GLX visuals */
pNewVisualConfigs = (__GLXvisualConfig *)
__glXMalloc(numNewConfigs * sizeof(__GLXvisualConfig));
malloc(numNewConfigs * sizeof(__GLXvisualConfig));
if (!pNewVisualConfigs) {
return FALSE;
}
/* Alloc space for the list of new GLX visual privates */
pNewVisualPriv = (void **) __glXMalloc(numNewConfigs * sizeof(void *));
pNewVisualPriv = (void **) malloc(numNewConfigs * sizeof(void *));
if (!pNewVisualPriv) {
__glXFree(pNewVisualConfigs);
free(pNewVisualConfigs);
return FALSE;
}
......@@ -371,40 +370,40 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp,
numConfigs = 0;
/* Alloc temp space for the list of orig VisualIDs for each new visual */
orig_vid = (VisualID *)__glXMalloc(numNewVisuals * sizeof(VisualID));
orig_vid = (VisualID *)malloc(numNewVisuals * sizeof(VisualID));
if (!orig_vid) {
__glXFree(pNewVisualPriv);
__glXFree(pNewVisualConfigs);
free(pNewVisualPriv);
free(pNewVisualConfigs);
return FALSE;
}
/* Alloc space for the list of glXVisuals */
modes = _gl_context_modes_create(numNewVisuals, sizeof(__GLcontextModes));
if (modes == NULL) {
__glXFree(orig_vid);
__glXFree(pNewVisualPriv);
__glXFree(pNewVisualConfigs);
free(orig_vid);
free(pNewVisualPriv);
free(pNewVisualConfigs);
return FALSE;
}
/* Alloc space for the list of glXVisualPrivates */
glXVisualPriv = (void **)__glXMalloc(numNewVisuals * sizeof(void *));
glXVisualPriv = (void **)malloc(numNewVisuals * sizeof(void *));
if (!glXVisualPriv) {
_gl_context_modes_destroy( modes );
__glXFree(orig_vid);
__glXFree(pNewVisualPriv);
__glXFree(pNewVisualConfigs);
free(orig_vid);
free(pNewVisualPriv);
free(pNewVisualConfigs);
return FALSE;
}
/* Alloc space for the new list of the X server's visuals */
pVisualNew = (VisualPtr)__glXMalloc(numNewVisuals * sizeof(VisualRec));
pVisualNew = (VisualPtr)malloc(numNewVisuals * sizeof(VisualRec));
if (!pVisualNew) {
__glXFree(glXVisualPriv);
free(glXVisualPriv);
_gl_context_modes_destroy( modes );
__glXFree(orig_vid);
__glXFree(pNewVisualPriv);
__glXFree(pNewVisualConfigs);
free(orig_vid);
free(pNewVisualPriv);
free(pNewVisualConfigs);
return FALSE;
}
......@@ -487,7 +486,7 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp,
numVids++;
/* Allocate a new list of VisualIDs for this depth */
pVids = (VisualID *)__glXMalloc(numVids * sizeof(VisualID));
pVids = (VisualID *)malloc(numVids * sizeof(VisualID));
/* Initialize the new list of VisualIDs for this depth */
for (j = 0; j < pdepth[i].numVids; j++)
......@@ -496,7 +495,7 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp,
pVids[n++] = pVisualNew[k].vid;
/* Update this depth's list of VisualIDs */
__glXFree(pdepth[i].vids);
free(pdepth[i].vids);
pdepth[i].vids = pVids;
pdepth[i].numVids = numVids;
}
......@@ -506,12 +505,12 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp,
*visualp = pVisualNew;
/* Free the old list of the X server's visuals */
__glXFree(pVisual);
free(pVisual);
/* Clean up temporary allocations */
__glXFree(orig_vid);
__glXFree(pNewVisualPriv);
__glXFree(pNewVisualConfigs);
free(orig_vid);
free(pNewVisualPriv);
free(pNewVisualConfigs);
/* Free the private list created by DDX HW driver */
if (visualPrivates)
......@@ -581,19 +580,19 @@ static void init_screen_visuals(int screen)
int i, j;
/* Alloc space for the list of XMesa visuals */
pXMesaVisual = (XMesaVisual *)__glXMalloc(MESAScreens[screen].num_vis *
pXMesaVisual = (XMesaVisual *)malloc(MESAScreens[screen].num_vis *
sizeof(XMesaVisual));
__glXMemset(pXMesaVisual, 0,
memset(pXMesaVisual, 0,
MESAScreens[screen].num_vis * sizeof(XMesaVisual));
/* FIXME: Change 'used' to be a array of bits (rather than of ints),
* FIXME: create a stack array of 8 or 16 bytes. If 'numVisuals' is less
* FIXME: than 64 or 128 the stack array can be used instead of calling
* FIXME: __glXMalloc / __glXFree. If nothing else, convert 'used' to
* FIXME: malloc / free. If nothing else, convert 'used' to
* FIXME: array of bytes instead of ints!
*/
used = (int *)__glXMalloc(pScreen->numVisuals * sizeof(int));
__glXMemset(used, 0, pScreen->numVisuals * sizeof(int));
used = (int *)malloc(pScreen->numVisuals * sizeof(int));
memset(used, 0, pScreen->numVisuals * sizeof(int));
i = 0;
for ( modes = MESAScreens[screen].modes
......@@ -652,7 +651,7 @@ static void init_screen_visuals(int screen)
i++;
}
__glXFree(used);
free(used);
MESAScreens[screen].xm_vis = pXMesaVisual;
}
......@@ -703,9 +702,9 @@ extern void __MESA_resetExtension(void)
}
_gl_context_modes_destroy( MESAScreens[i].modes );
MESAScreens[i].modes = NULL;
__glXFree(MESAScreens[i].private);
free(MESAScreens[i].private);
MESAScreens[i].private = NULL;
__glXFree(MESAScreens[i].xm_vis);
free(MESAScreens[i].xm_vis);
MESAScreens[i].xm_vis = NULL;
MESAScreens[i].num_vis = 0;
}
......@@ -725,7 +724,7 @@ void __MESA_createBuffer(__GLXdrawablePrivate *glxPriv)
ErrorF("find_mesa_visual returned NULL for visualID = 0x%04x\n",
glxPriv->modes->visualID);
}
buf = (__MESA_buffer)__glXMalloc(sizeof(struct __MESA_bufferRec));
buf = (__MESA_buffer)malloc(sizeof(struct __MESA_bufferRec));
/* Create Mesa's buffers */
if (glxPriv->type == DRAWABLE_WINDOW) {
......@@ -793,7 +792,7 @@ void __MESA_destroyBuffer(__GLdrawablePrivate *glPriv)
glxPriv->swapBuffers = buf->fbswap;
glPriv->frontBuffer.resize = buf->fbresize;
__glXFree(glPriv->private);
free(glPriv->private);
glPriv->private = NULL;
}
......
......@@ -41,7 +41,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "pixmapstr.h"
#include "xf86glx_util.h"
#include <nx-X11/Xmd.h>
#include "GL/xf86glx.h"
#ifdef ROUNDUP
#undef ROUNDUP
......
......@@ -67,12 +67,12 @@ static int __glXDispatch(ClientPtr client)
opcode = stuff->glxCode;
cl = __glXClients[client->index];
if (!cl) {
cl = (__GLXclientState *) __glXMalloc(sizeof(__GLXclientState));
cl = (__GLXclientState *) malloc(sizeof(__GLXclientState));
__glXClients[client->index] = cl;
if (!cl) {
return BadAlloc;
}
__glXMemset(cl, 0, sizeof(__GLXclientState));
memset(cl, 0, sizeof(__GLXclientState));
}
if (!cl->inUse) {
......@@ -145,12 +145,12 @@ static int __glXSwapDispatch(ClientPtr client)
opcode = stuff->glxCode;
cl = __glXClients[client->index];
if (!cl) {
cl = (__GLXclientState *) __glXMalloc(sizeof(__GLXclientState));
cl = (__GLXclientState *) malloc(sizeof(__GLXclientState));
__glXClients[client->index] = cl;
if (!cl) {
return BadAlloc;
}
__glXMemset(cl, 0, sizeof(__GLXclientState));
memset(cl, 0, sizeof(__GLXclientState));
}
if (!cl->inUse) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment